From 17fc10a8afedb7c0a281fe90d7ceb5f8b142148c Mon Sep 17 00:00:00 2001 From: Yaroslav Chernyshev Date: Tue, 9 Feb 2021 12:02:34 +0300 Subject: [PATCH 001/368] Mark obsolete Gradle JVM options as Deprecated with Error Options `includeRuntime`, `noStdlib` and `noReflect` were affected #Fixed KT-44361 --- .../cli/common/arguments/DeprecatedOption.kt | 13 ++++++++ .../arguments/K2JVMCompilerArguments.kt | 3 ++ .../arguments/GenerateGradleOptions.kt | 30 +++++++++++++++++-- .../kotlin/gradle/dsl/KotlinJvmOptions.kt | 3 ++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/DeprecatedOption.kt diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/DeprecatedOption.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/DeprecatedOption.kt new file mode 100644 index 00000000000..51a0b8ad15f --- /dev/null +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/DeprecatedOption.kt @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2021 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.cli.common.arguments + +@Retention(AnnotationRetention.RUNTIME) +annotation class DeprecatedOption( + val message: String = "This option has no effect and will be removed in a future release.", + val removeAfter: String, + val level: DeprecationLevel +) \ No newline at end of file diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index 9eb8a13aed3..2690da7b26f 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -25,6 +25,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { description = "List of directories and JAR/ZIP archives to search for user class files") var classpath: String? by NullableStringFreezableVar(null) + @DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR) @GradleOption(DefaultValues.BooleanFalseDefault::class) @Argument(value = "-include-runtime", description = "Include Kotlin runtime into the resulting JAR") var includeRuntime: Boolean by FreezableVar(false) @@ -41,10 +42,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { @Argument(value = "-no-jdk", description = "Don't automatically include the Java runtime into the classpath") var noJdk: Boolean by FreezableVar(false) + @DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR) @GradleOption(DefaultValues.BooleanTrueDefault::class) @Argument(value = "-no-stdlib", description = "Don't automatically include the Kotlin/JVM stdlib and Kotlin reflection into the classpath") var noStdlib: Boolean by FreezableVar(false) + @DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR) @GradleOption(DefaultValues.BooleanTrueDefault::class) @Argument(value = "-no-reflect", description = "Don't automatically include Kotlin reflection into the classpath") var noReflect: Boolean by FreezableVar(false) diff --git a/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt b/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt index 91f7264992f..00b34b829cc 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/arguments/GenerateGradleOptions.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.generators.arguments import org.jetbrains.kotlin.cli.common.arguments.* +import org.jetbrains.kotlin.config.LanguageVersion import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.utils.Printer import java.io.File @@ -159,8 +160,15 @@ fun main() { generateKotlinGradleOptions(::getPrinter) } +private inline fun List>.filterToBeDeleted() = filter { prop -> + prop.findAnnotation() + ?.let { LanguageVersion.fromVersionString(it.removeAfter) } + ?.let { it >= LanguageVersion.LATEST_STABLE } + ?: true +} + private inline fun gradleOptions(): List> = - T::class.declaredMemberProperties.filter { it.findAnnotation() != null }.sortedBy { it.name } + T::class.declaredMemberProperties.filter { it.findAnnotation() != null }.filterToBeDeleted().sortedBy { it.name } private fun File(baseDir: File, fqName: FqName): File { val fileRelativePath = fqName.asString().replace(".", "/") + ".kt" @@ -173,6 +181,7 @@ private fun Printer.generateInterface(type: FqName, properties: List, modi println("$modifiers var ${property.name}: $returnType") } +private fun Printer.generateOptionDeprecation(property: KProperty1<*, *>) { + property.findAnnotation() + ?.let { DeprecatedOptionAnnotator.generateOptionAnnotation(it) } + ?.also { println(it) } +} + private fun Printer.generateDoc(property: KProperty1<*, *>) { val description = property.findAnnotation()!!.description val possibleValues = property.gradleValues.possibleValues @@ -274,6 +289,8 @@ private fun generateMarkdown(properties: List>) { for (property in properties) { val name = property.name if (name == "includeRuntime") continue // This option has no effect in Gradle builds + val renderName = listOfNotNull("`$name`", property.findAnnotation()?.let { "__(Deprecated)__" }) + .joinToString(" ") val description = property.findAnnotation()!!.description val possibleValues = property.gradleValues.possibleValues val defaultValue = when (property.gradleDefaultValue) { @@ -282,7 +299,7 @@ private fun generateMarkdown(properties: List>) { else -> property.gradleDefaultValue } - println("| `$name` | $description | ${possibleValues.orEmpty().joinToString()} | $defaultValue |") + println("| $renderName | $description | ${possibleValues.orEmpty().joinToString()} | $defaultValue |") } } @@ -304,3 +321,12 @@ private val KProperty1<*, *>.gradleReturnType: String private inline fun KAnnotatedElement.findAnnotation(): T? = annotations.filterIsInstance().firstOrNull() + +object DeprecatedOptionAnnotator { + fun generateOptionAnnotation(annotation: DeprecatedOption): String { + val message = annotation.message.takeIf { it.isNotEmpty() }?.let { "message = \"$it\"" } + val level = "level = DeprecationLevel.${annotation.level.name}" + val arguments = listOfNotNull(message, level).joinToString() + return "@Deprecated($arguments)" + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJvmOptions.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJvmOptions.kt index d1b1e9eb076..850d925c275 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJvmOptions.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinJvmOptions.kt @@ -8,6 +8,7 @@ interface KotlinJvmOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOption * Include Kotlin runtime into the resulting JAR * Default value: false */ + @Deprecated(message = "This option has no effect and will be removed in a future release.", level = DeprecationLevel.ERROR) var includeRuntime: kotlin.Boolean /** @@ -45,12 +46,14 @@ interface KotlinJvmOptions : org.jetbrains.kotlin.gradle.dsl.KotlinCommonOption * Don't automatically include Kotlin reflection into the classpath * Default value: true */ + @Deprecated(message = "This option has no effect and will be removed in a future release.", level = DeprecationLevel.ERROR) var noReflect: kotlin.Boolean /** * Don't automatically include the Kotlin/JVM stdlib and Kotlin reflection into the classpath * Default value: true */ + @Deprecated(message = "This option has no effect and will be removed in a future release.", level = DeprecationLevel.ERROR) var noStdlib: kotlin.Boolean /** From 73aa465ee973aaeecbf1aecba5da167858946a7a Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 3 Feb 2021 15:03:30 +0100 Subject: [PATCH 002/368] Add tests for issues fixed in JVM IR Note that KT-30696 is fixed only in the single-module case, and KT-42012 is not fixed fully (see KT-44855). #KT-30041 #KT-30629 #KT-30696 #KT-30933 #KT-32351 #KT-32749 #KT-38849 #KT-42012 #KT-42990 #KT-44234 #KT-44529 #KT-44631 #KT-44647 --- .../FirBlackBoxCodegenTestGenerated.java | 66 +++++++++++++++++++ ...FirBlackBoxInlineCodegenTestGenerated.java | 12 ++++ .../genericBoundPropertyAsCrossinline.kt | 41 ++++++++++++ .../nestedLambdaInNonInlineCallExactlyOnce.kt | 27 ++++++++ .../named/callTopLevelFromLocal.kt | 32 +++++++++ .../box/inlineClasses/customIterator.kt | 25 +++++++ .../box/jvmStatic/extensionPropertyGetter.kt | 23 +++++++ .../defaultParameterInConstructor.kt | 13 ++++ .../testData/codegen/box/objects/kt32351.kt | 27 ++++++++ .../testData/codegen/box/objects/kt32749.kt | 20 ++++++ .../box/operatorConventions/kt44647.kt | 11 ++++ .../lateinit/privateVarInCompanion.kt | 26 ++++++++ .../visibility/protectedAndPackage/kt42012.kt | 36 ++++++++++ .../boxInline/anonymousObject/kt30696.kt | 22 +++++++ .../callableReference/bound/kt30933.kt | 21 ++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 66 +++++++++++++++++++ .../BlackBoxInlineCodegenTestGenerated.java | 12 ++++ ...otlinAgainstInlineKotlinTestGenerated.java | 12 ++++ .../IrBlackBoxCodegenTestGenerated.java | 66 +++++++++++++++++++ .../IrBlackBoxInlineCodegenTestGenerated.java | 12 ++++ ...otlinAgainstInlineKotlinTestGenerated.java | 12 ++++ ...JvmIrAgainstOldBoxInlineTestGenerated.java | 12 ++++ ...JvmOldAgainstIrBoxInlineTestGenerated.java | 12 ++++ .../LightAnalysisModeTestGenerated.java | 55 ++++++++++++++++ .../IrJsCodegenBoxES6TestGenerated.java | 45 +++++++++++++ .../IrJsCodegenInlineES6TestGenerated.java | 5 ++ .../IrJsCodegenBoxTestGenerated.java | 45 +++++++++++++ .../IrJsCodegenInlineTestGenerated.java | 5 ++ .../semantics/JsCodegenBoxTestGenerated.java | 45 +++++++++++++ .../JsCodegenInlineTestGenerated.java | 5 ++ .../IrCodegenBoxWasmTestGenerated.java | 15 +++++ 31 files changed, 826 insertions(+) create mode 100644 compiler/testData/codegen/box/callableReference/bound/genericBoundPropertyAsCrossinline.kt create mode 100644 compiler/testData/codegen/box/contracts/nestedLambdaInNonInlineCallExactlyOnce.kt create mode 100644 compiler/testData/codegen/box/coroutines/localFunctions/named/callTopLevelFromLocal.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/customIterator.kt create mode 100644 compiler/testData/codegen/box/jvmStatic/extensionPropertyGetter.kt create mode 100644 compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt create mode 100644 compiler/testData/codegen/box/objects/kt32351.kt create mode 100644 compiler/testData/codegen/box/objects/kt32749.kt create mode 100644 compiler/testData/codegen/box/operatorConventions/kt44647.kt create mode 100644 compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt create mode 100644 compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt create mode 100644 compiler/testData/codegen/boxInline/anonymousObject/kt30696.kt create mode 100644 compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 483e39195d3..5717b5cacbb 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -2829,6 +2829,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/callableReference/bound/enumEntryMember.kt"); } + @Test + @TestMetadata("genericBoundPropertyAsCrossinline.kt") + public void testGenericBoundPropertyAsCrossinline() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/genericBoundPropertyAsCrossinline.kt"); + } + @Test @TestMetadata("genericValOnLHS.kt") public void testGenericValOnLHS() throws Exception { @@ -7238,6 +7244,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/contracts/listAppend.kt"); } + @Test + @TestMetadata("nestedLambdaInNonInlineCallExactlyOnce.kt") + public void testNestedLambdaInNonInlineCallExactlyOnce() throws Exception { + runTest("compiler/testData/codegen/box/contracts/nestedLambdaInNonInlineCallExactlyOnce.kt"); + } + @Test @TestMetadata("valInWhen.kt") public void testValInWhen() throws Exception { @@ -10790,6 +10802,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/localFunctions/named"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("callTopLevelFromLocal.kt") + public void testCallTopLevelFromLocal() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/localFunctions/named/callTopLevelFromLocal.kt"); + } + @Test @TestMetadata("capturedParameters.kt") public void testCapturedParameters() throws Exception { @@ -16990,6 +17008,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inlineClasses/crossinlineWithInlineClassInParameter.kt"); } + @Test + @TestMetadata("customIterator.kt") + public void testCustomIterator() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/customIterator.kt"); + } + @Test @TestMetadata("defaultFunctionsFromAnyForInlineClass.kt") public void testDefaultFunctionsFromAnyForInlineClass() throws Exception { @@ -22416,6 +22440,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/jvmStatic/explicitObject.kt"); } + @Test + @TestMetadata("extensionPropertyGetter.kt") + public void testExtensionPropertyGetter() throws Exception { + runTest("compiler/testData/codegen/box/jvmStatic/extensionPropertyGetter.kt"); + } + @Test @TestMetadata("funAccess.kt") public void testFunAccess() throws Exception { @@ -22804,6 +22834,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/localClasses/closureWithSelfInstantiation.kt"); } + @Test + @TestMetadata("defaultParameterInConstructor.kt") + public void testDefaultParameterInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt"); + } + @Test @TestMetadata("inExtensionFunction.kt") public void testInExtensionFunction() throws Exception { @@ -24350,12 +24386,24 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/objects/kt2822.kt"); } + @Test + @TestMetadata("kt32351.kt") + public void testKt32351() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32351.kt"); + } + @Test @TestMetadata("kt3238.kt") public void testKt3238() throws Exception { runTest("compiler/testData/codegen/box/objects/kt3238.kt"); } + @Test + @TestMetadata("kt32749.kt") + public void testKt32749() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32749.kt"); + } + @Test @TestMetadata("kt3684.kt") public void testKt3684() throws Exception { @@ -24942,6 +24990,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); } + @Test + @TestMetadata("kt44647.kt") + public void testKt44647() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); + } + @Test @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { @@ -26807,6 +26861,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/properties/lateinit/privateSetterViaSubclass.kt"); } + @Test + @TestMetadata("privateVarInCompanion.kt") + public void testPrivateVarInCompanion() throws Exception { + runTest("compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt"); + } + @Test @TestMetadata("simpleVar.kt") public void testSimpleVar() throws Exception { @@ -39573,6 +39633,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("kt42012.kt") + public void testKt42012() throws Exception { + runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt"); + } + @Test @TestMetadata("overrideProtectedFunInPackage.kt") public void testOverrideProtectedFunInPackage() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java index c9b99edc41d..ba89e8032d5 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java @@ -280,6 +280,12 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn runTest("compiler/testData/codegen/boxInline/anonymousObject/kt29595.kt"); } + @Test + @TestMetadata("kt30696.kt") + public void testKt30696() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt30696.kt"); + } + @Test @TestMetadata("kt34656.kt") public void testKt34656() throws Exception { @@ -1159,6 +1165,12 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt18728_4.kt"); } + @Test + @TestMetadata("kt30933.kt") + public void testKt30933() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt"); + } + @Test @TestMetadata("lambdaOnLhs.kt") public void testLambdaOnLhs() throws Exception { diff --git a/compiler/testData/codegen/box/callableReference/bound/genericBoundPropertyAsCrossinline.kt b/compiler/testData/codegen/box/callableReference/bound/genericBoundPropertyAsCrossinline.kt new file mode 100644 index 00000000000..adc5ed04381 --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/bound/genericBoundPropertyAsCrossinline.kt @@ -0,0 +1,41 @@ +// IGNORE_BACKEND: JVM +// DONT_TARGET_EXACT_BACKEND: WASM +// WASM_MUTE_REASON: BINDING_RECEIVERS +// KT-30629 + +abstract class BaseFragment { + lateinit var viewModel: T + + open fun onActivityCreated(): String { + viewModel = retrieveViewModel() + return "Fail" + } + + abstract fun retrieveViewModel(): T +} + +class DerivedFragment : BaseFragment() { + override fun onActivityCreated(): String { + super.onActivityCreated() + + return bind(viewModel::property) + } + + override fun retrieveViewModel(): DerivedViewModel = DerivedViewModel() + inline fun bind(crossinline viewModelGet: () -> T?): String { + return setOnFocusChangeListener { viewModelGet() as String } + } + + fun setOnFocusChangeListener(l: () -> String): String { + return l() + } +} + +abstract class BaseViewModel +class DerivedViewModel : BaseViewModel() { + var property: String? = "OK" +} + +fun box(): String { + return DerivedFragment().onActivityCreated() +} diff --git a/compiler/testData/codegen/box/contracts/nestedLambdaInNonInlineCallExactlyOnce.kt b/compiler/testData/codegen/box/contracts/nestedLambdaInNonInlineCallExactlyOnce.kt new file mode 100644 index 00000000000..716786eb9ba --- /dev/null +++ b/compiler/testData/codegen/box/contracts/nestedLambdaInNonInlineCallExactlyOnce.kt @@ -0,0 +1,27 @@ +// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts +// IGNORE_BACKEND: JVM +// WITH_RUNTIME +// KT-38849 + +import kotlin.contracts.* + +fun block(lambda: () -> Unit) { + contract { + callsInPlace(lambda, InvocationKind.EXACTLY_ONCE) + } + lambda() +} + +fun box(): String { + val list: List + + block { + list = listOf(1, 2, 3) + } + + block { + if (listOf(2, 3, 4).first { list.contains(it) } != 2) throw AssertionError("Fail") + } + + return "OK" +} diff --git a/compiler/testData/codegen/box/coroutines/localFunctions/named/callTopLevelFromLocal.kt b/compiler/testData/codegen/box/coroutines/localFunctions/named/callTopLevelFromLocal.kt new file mode 100644 index 00000000000..e8c3432d6d8 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/localFunctions/named/callTopLevelFromLocal.kt @@ -0,0 +1,32 @@ +// IGNORE_BACKEND: JVM +// WITH_RUNTIME +// WITH_COROUTINES +// KT-30041 + +import helpers.* +import kotlin.coroutines.* + +var result = 0 + +fun builder(block: suspend () -> Unit) { + block.startCoroutine(EmptyContinuation) +} + +suspend fun test() { + suspend fun local() { + builder { + if (result++ < 1) { + local() + } + } + } + + local() +} + +fun box(): String { + builder { + test() + } + return if (result == 2) "OK" else "Fail: $result" +} diff --git a/compiler/testData/codegen/box/inlineClasses/customIterator.kt b/compiler/testData/codegen/box/inlineClasses/customIterator.kt new file mode 100644 index 00000000000..a693afea492 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/customIterator.kt @@ -0,0 +1,25 @@ +// IGNORE_BACKEND: JVM +// DONT_TARGET_EXACT_BACKEND: WASM +// WASM_MUTE_REASON: STDLIB_TEXT +// WITH_RUNTIME +// KT-44529 + +inline class InlineDouble3(val values: DoubleArray) { + operator fun iterator(): DoubleIterator = IteratorImpl(values) +} + +// This iterator returns the first 3 elements of this.values +private class IteratorImpl(private val values: DoubleArray) : DoubleIterator() { + private var index = 0 + override fun hasNext(): Boolean = index < 3 + override fun nextDouble(): Double = values[index++] +} + +fun box(): String { + val values = doubleArrayOf(1.0, 2.0, 3.0, 4.0) + var result = "" + for (i in InlineDouble3(values)) { + result += i.toString().substring(0, 1) + } + return if (result == "123") "OK" else "Fail: $result" +} diff --git a/compiler/testData/codegen/box/jvmStatic/extensionPropertyGetter.kt b/compiler/testData/codegen/box/jvmStatic/extensionPropertyGetter.kt new file mode 100644 index 00000000000..72bff4c7570 --- /dev/null +++ b/compiler/testData/codegen/box/jvmStatic/extensionPropertyGetter.kt @@ -0,0 +1,23 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND: JVM +// WITH_RUNTIME +// KT-42990 + +object O { + val todo: String = TODO() + + fun test(): Int = Bar(todo.bar).result + + val String.bar: Int + @JvmStatic + get() = 42 +} + +class Bar(val result: Int) + +fun box(): String = try { + O.test() + "Fail" +} catch (e: NotImplementedError) { + "OK" +} diff --git a/compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt b/compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt new file mode 100644 index 00000000000..5f4e69077b9 --- /dev/null +++ b/compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt @@ -0,0 +1,13 @@ +// IGNORE_BACKEND: JVM +// KT-44631 + +class Something(val now: String) + +fun box(): String { + val a: Something.() -> String = { + class MyEvent(val result: String = now) + + MyEvent().result + } + return Something("OK").a() +} diff --git a/compiler/testData/codegen/box/objects/kt32351.kt b/compiler/testData/codegen/box/objects/kt32351.kt new file mode 100644 index 00000000000..4636ad9616d --- /dev/null +++ b/compiler/testData/codegen/box/objects/kt32351.kt @@ -0,0 +1,27 @@ +// IGNORE_BACKEND: JVM +// DONT_TARGET_EXACT_BACKEND: WASM +// WASM_MUTE_REASON: UNKNOWN +// WITH_RUNTIME + +interface Runnable { + fun run() +} + +class AnonymousClassInLambda { + fun run(): Int { + var x = 0 + val threads = (1..10).map { + object : Runnable { + override fun run() { + x++ + } + } + } + threads.forEach { it.run() } + return x + } +} + +fun box(): String { + return if (AnonymousClassInLambda().run() == 10) "OK" else "Fail" +} diff --git a/compiler/testData/codegen/box/objects/kt32749.kt b/compiler/testData/codegen/box/objects/kt32749.kt new file mode 100644 index 00000000000..7aeac240fea --- /dev/null +++ b/compiler/testData/codegen/box/objects/kt32749.kt @@ -0,0 +1,20 @@ +// IGNORE_BACKEND: JVM +// WITH_RUNTIME + +class X { + val num = 42 + val map: Int = 1.apply { + object : Y({ true }) { + override fun fun1() { + println(num) + } + } + } +} + +abstract class Y(val lambda: () -> Boolean) { + abstract fun fun1() +} + +fun box(): String = + if (X().map == 1) "OK" else "Fail" diff --git a/compiler/testData/codegen/box/operatorConventions/kt44647.kt b/compiler/testData/codegen/box/operatorConventions/kt44647.kt new file mode 100644 index 00000000000..252c6bae01f --- /dev/null +++ b/compiler/testData/codegen/box/operatorConventions/kt44647.kt @@ -0,0 +1,11 @@ +// IGNORE_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS +// DONT_TARGET_EXACT_BACKEND: WASM +// WASM_MUTE_REASON: STDLIB_STRING_BUILDER +// WITH_RUNTIME + +fun box(): String { + val sb = StringBuilder("NK") + sb[0]++ + return sb.toString() +} diff --git a/compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt b/compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt new file mode 100644 index 00000000000..c651457ace9 --- /dev/null +++ b/compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt @@ -0,0 +1,26 @@ +// IGNORE_BACKEND: JVM +// KT-44234 + +class App { + val context: Context = Context() + + fun onCreate() { + instance = this + } + + companion object { + private lateinit var instance: App set + val context: Context get() = instance.context + } + +} + +class Context { + fun print(): String = "OK" +} + +fun box(): String { + val app = App() + app.onCreate() + return App.context.print() +} diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt b/compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt new file mode 100644 index 00000000000..78671eab885 --- /dev/null +++ b/compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt @@ -0,0 +1,36 @@ +// IGNORE_BACKEND: JVM +// TARGET_BACKEND: JVM +// MODULE: lib +// FILE: test/Parent.java + +package test; + +public class Parent { + protected String qqq = ""; + + public String getQqq() { + return qqq; + } +} + +// MODULE: main(lib) +// FILE: 1.kt + +import test.Parent + +open class Child : Parent() { + inner class QQQ { + fun z(x: Parent?) { + x as Child + val q = x.qqq + x.qqq = q + "OK" + } + } +} + +fun box(): String { + val c = Child() + val d = c.QQQ() + d.z(c) + return c.qqq +} diff --git a/compiler/testData/codegen/boxInline/anonymousObject/kt30696.kt b/compiler/testData/codegen/boxInline/anonymousObject/kt30696.kt new file mode 100644 index 00000000000..8b46643d3ae --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/kt30696.kt @@ -0,0 +1,22 @@ +// TARGET_BACKEND: JVM +// NO_CHECK_LAMBDA_INLINING +// WITH_RUNTIME +// IGNORE_BACKEND: JVM +// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_IR, JVM_MULTI_MODULE_OLD_AGAINST_IR, JVM_MULTI_MODULE_IR_AGAINST_OLD +// FILE: 1.kt + +interface Flow { + val result: String +} + +inline fun foo() = + object { + fun test() = object : Flow { + override val result: String = "OK" + } + }.test() + +// FILE: 2.kt + +fun box(): String = + foo().result diff --git a/compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt b/compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt new file mode 100644 index 00000000000..e79c4c38161 --- /dev/null +++ b/compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt @@ -0,0 +1,21 @@ +// IGNORE_BACKEND: JVM +// FILE: 1.kt + +package test + +class Path { + val events: String = "OK" +} + +inline fun doSomething(path: Path): String { + val f = path::events + return f() +} + +// FILE: 2.kt + +import test.* + +fun box(): String { + return doSomething(Path()) +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 881b0294160..6b2921c3420 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -2829,6 +2829,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/callableReference/bound/enumEntryMember.kt"); } + @Test + @TestMetadata("genericBoundPropertyAsCrossinline.kt") + public void testGenericBoundPropertyAsCrossinline() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/genericBoundPropertyAsCrossinline.kt"); + } + @Test @TestMetadata("genericValOnLHS.kt") public void testGenericValOnLHS() throws Exception { @@ -7238,6 +7244,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/contracts/listAppend.kt"); } + @Test + @TestMetadata("nestedLambdaInNonInlineCallExactlyOnce.kt") + public void testNestedLambdaInNonInlineCallExactlyOnce() throws Exception { + runTest("compiler/testData/codegen/box/contracts/nestedLambdaInNonInlineCallExactlyOnce.kt"); + } + @Test @TestMetadata("valInWhen.kt") public void testValInWhen() throws Exception { @@ -10790,6 +10802,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/localFunctions/named"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("callTopLevelFromLocal.kt") + public void testCallTopLevelFromLocal() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/localFunctions/named/callTopLevelFromLocal.kt"); + } + @Test @TestMetadata("capturedParameters.kt") public void testCapturedParameters() throws Exception { @@ -16990,6 +17008,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/crossinlineWithInlineClassInParameter.kt"); } + @Test + @TestMetadata("customIterator.kt") + public void testCustomIterator() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/customIterator.kt"); + } + @Test @TestMetadata("defaultFunctionsFromAnyForInlineClass.kt") public void testDefaultFunctionsFromAnyForInlineClass() throws Exception { @@ -22416,6 +22440,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/jvmStatic/explicitObject.kt"); } + @Test + @TestMetadata("extensionPropertyGetter.kt") + public void testExtensionPropertyGetter() throws Exception { + runTest("compiler/testData/codegen/box/jvmStatic/extensionPropertyGetter.kt"); + } + @Test @TestMetadata("funAccess.kt") public void testFunAccess() throws Exception { @@ -22804,6 +22834,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/localClasses/closureWithSelfInstantiation.kt"); } + @Test + @TestMetadata("defaultParameterInConstructor.kt") + public void testDefaultParameterInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt"); + } + @Test @TestMetadata("inExtensionFunction.kt") public void testInExtensionFunction() throws Exception { @@ -24350,12 +24386,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/objects/kt2822.kt"); } + @Test + @TestMetadata("kt32351.kt") + public void testKt32351() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32351.kt"); + } + @Test @TestMetadata("kt3238.kt") public void testKt3238() throws Exception { runTest("compiler/testData/codegen/box/objects/kt3238.kt"); } + @Test + @TestMetadata("kt32749.kt") + public void testKt32749() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32749.kt"); + } + @Test @TestMetadata("kt3684.kt") public void testKt3684() throws Exception { @@ -25148,6 +25196,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); } + @Test + @TestMetadata("kt44647.kt") + public void testKt44647() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); + } + @Test @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { @@ -27013,6 +27067,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/properties/lateinit/privateSetterViaSubclass.kt"); } + @Test + @TestMetadata("privateVarInCompanion.kt") + public void testPrivateVarInCompanion() throws Exception { + runTest("compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt"); + } + @Test @TestMetadata("simpleVar.kt") public void testSimpleVar() throws Exception { @@ -39779,6 +39839,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("kt42012.kt") + public void testKt42012() throws Exception { + runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt"); + } + @Test @TestMetadata("overrideProtectedFunInPackage.kt") public void testOverrideProtectedFunInPackage() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java index 72138fbfd89..c5518687452 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -280,6 +280,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/anonymousObject/kt29595.kt"); } + @Test + @TestMetadata("kt30696.kt") + public void testKt30696() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt30696.kt"); + } + @Test @TestMetadata("kt34656.kt") public void testKt34656() throws Exception { @@ -1159,6 +1165,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt18728_4.kt"); } + @Test + @TestMetadata("kt30933.kt") + public void testKt30933() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt"); + } + @Test @TestMetadata("lambdaOnLhs.kt") public void testLambdaOnLhs() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index d0f0178aca3..5e2563c6f44 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -280,6 +280,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/anonymousObject/kt29595.kt"); } + @Test + @TestMetadata("kt30696.kt") + public void testKt30696() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt30696.kt"); + } + @Test @TestMetadata("kt34656.kt") public void testKt34656() throws Exception { @@ -1159,6 +1165,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt18728_4.kt"); } + @Test + @TestMetadata("kt30933.kt") + public void testKt30933() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt"); + } + @Test @TestMetadata("lambdaOnLhs.kt") public void testLambdaOnLhs() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index fe98e42f7e8..c7dd2e03258 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -2829,6 +2829,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/callableReference/bound/enumEntryMember.kt"); } + @Test + @TestMetadata("genericBoundPropertyAsCrossinline.kt") + public void testGenericBoundPropertyAsCrossinline() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/genericBoundPropertyAsCrossinline.kt"); + } + @Test @TestMetadata("genericValOnLHS.kt") public void testGenericValOnLHS() throws Exception { @@ -7238,6 +7244,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/contracts/listAppend.kt"); } + @Test + @TestMetadata("nestedLambdaInNonInlineCallExactlyOnce.kt") + public void testNestedLambdaInNonInlineCallExactlyOnce() throws Exception { + runTest("compiler/testData/codegen/box/contracts/nestedLambdaInNonInlineCallExactlyOnce.kt"); + } + @Test @TestMetadata("valInWhen.kt") public void testValInWhen() throws Exception { @@ -10790,6 +10802,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/localFunctions/named"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("callTopLevelFromLocal.kt") + public void testCallTopLevelFromLocal() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/localFunctions/named/callTopLevelFromLocal.kt"); + } + @Test @TestMetadata("capturedParameters.kt") public void testCapturedParameters() throws Exception { @@ -16990,6 +17008,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/crossinlineWithInlineClassInParameter.kt"); } + @Test + @TestMetadata("customIterator.kt") + public void testCustomIterator() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/customIterator.kt"); + } + @Test @TestMetadata("defaultFunctionsFromAnyForInlineClass.kt") public void testDefaultFunctionsFromAnyForInlineClass() throws Exception { @@ -22416,6 +22440,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/jvmStatic/explicitObject.kt"); } + @Test + @TestMetadata("extensionPropertyGetter.kt") + public void testExtensionPropertyGetter() throws Exception { + runTest("compiler/testData/codegen/box/jvmStatic/extensionPropertyGetter.kt"); + } + @Test @TestMetadata("funAccess.kt") public void testFunAccess() throws Exception { @@ -22804,6 +22834,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/localClasses/closureWithSelfInstantiation.kt"); } + @Test + @TestMetadata("defaultParameterInConstructor.kt") + public void testDefaultParameterInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt"); + } + @Test @TestMetadata("inExtensionFunction.kt") public void testInExtensionFunction() throws Exception { @@ -24350,12 +24386,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/objects/kt2822.kt"); } + @Test + @TestMetadata("kt32351.kt") + public void testKt32351() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32351.kt"); + } + @Test @TestMetadata("kt3238.kt") public void testKt3238() throws Exception { runTest("compiler/testData/codegen/box/objects/kt3238.kt"); } + @Test + @TestMetadata("kt32749.kt") + public void testKt32749() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32749.kt"); + } + @Test @TestMetadata("kt3684.kt") public void testKt3684() throws Exception { @@ -24942,6 +24990,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); } + @Test + @TestMetadata("kt44647.kt") + public void testKt44647() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); + } + @Test @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { @@ -26807,6 +26861,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/properties/lateinit/privateSetterViaSubclass.kt"); } + @Test + @TestMetadata("privateVarInCompanion.kt") + public void testPrivateVarInCompanion() throws Exception { + runTest("compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt"); + } + @Test @TestMetadata("simpleVar.kt") public void testSimpleVar() throws Exception { @@ -39573,6 +39633,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("kt42012.kt") + public void testKt42012() throws Exception { + runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt"); + } + @Test @TestMetadata("overrideProtectedFunInPackage.kt") public void testOverrideProtectedFunInPackage() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java index 58f7c16bd5b..923d5b8216d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java @@ -280,6 +280,12 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/anonymousObject/kt29595.kt"); } + @Test + @TestMetadata("kt30696.kt") + public void testKt30696() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt30696.kt"); + } + @Test @TestMetadata("kt34656.kt") public void testKt34656() throws Exception { @@ -1159,6 +1165,12 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt18728_4.kt"); } + @Test + @TestMetadata("kt30933.kt") + public void testKt30933() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt"); + } + @Test @TestMetadata("lambdaOnLhs.kt") public void testLambdaOnLhs() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 656b29eb9e4..77a112550c6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -280,6 +280,12 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/anonymousObject/kt29595.kt"); } + @Test + @TestMetadata("kt30696.kt") + public void testKt30696() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt30696.kt"); + } + @Test @TestMetadata("kt34656.kt") public void testKt34656() throws Exception { @@ -1159,6 +1165,12 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt18728_4.kt"); } + @Test + @TestMetadata("kt30933.kt") + public void testKt30933() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt"); + } + @Test @TestMetadata("lambdaOnLhs.kt") public void testLambdaOnLhs() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java index d50581746ff..fc5e88ed307 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -280,6 +280,12 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO runTest("compiler/testData/codegen/boxInline/anonymousObject/kt29595.kt"); } + @Test + @TestMetadata("kt30696.kt") + public void testKt30696() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt30696.kt"); + } + @Test @TestMetadata("kt34656.kt") public void testKt34656() throws Exception { @@ -1159,6 +1165,12 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt18728_4.kt"); } + @Test + @TestMetadata("kt30933.kt") + public void testKt30933() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt"); + } + @Test @TestMetadata("lambdaOnLhs.kt") public void testLambdaOnLhs() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java index cb3218d01f0..0595eeddb3f 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -280,6 +280,12 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst runTest("compiler/testData/codegen/boxInline/anonymousObject/kt29595.kt"); } + @Test + @TestMetadata("kt30696.kt") + public void testKt30696() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/kt30696.kt"); + } + @Test @TestMetadata("kt34656.kt") public void testKt34656() throws Exception { @@ -1159,6 +1165,12 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt18728_4.kt"); } + @Test + @TestMetadata("kt30933.kt") + public void testKt30933() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt"); + } + @Test @TestMetadata("lambdaOnLhs.kt") public void testLambdaOnLhs() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index e970f3d16d1..6de3b5de938 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -2415,6 +2415,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class Bound extends AbstractLightAnalysisModeTest { + @TestMetadata("genericBoundPropertyAsCrossinline.kt") + public void ignoreGenericBoundPropertyAsCrossinline() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/genericBoundPropertyAsCrossinline.kt"); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } @@ -5506,6 +5511,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class Contracts extends AbstractLightAnalysisModeTest { + @TestMetadata("nestedLambdaInNonInlineCallExactlyOnce.kt") + public void ignoreNestedLambdaInNonInlineCallExactlyOnce() throws Exception { + runTest("compiler/testData/codegen/box/contracts/nestedLambdaInNonInlineCallExactlyOnce.kt"); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } @@ -8656,6 +8666,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class Named extends AbstractLightAnalysisModeTest { + @TestMetadata("callTopLevelFromLocal.kt") + public void ignoreCallTopLevelFromLocal() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/localFunctions/named/callTopLevelFromLocal.kt"); + } + @TestMetadata("defaultArgument.kt") public void ignoreDefaultArgument() throws Exception { runTest("compiler/testData/codegen/box/coroutines/localFunctions/named/defaultArgument.kt"); @@ -13946,6 +13961,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/anySuperCall.kt"); } + @TestMetadata("customIterator.kt") + public void ignoreCustomIterator() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/customIterator.kt"); + } + @TestMetadata("inlineClassWithCustomEquals.kt") public void ignoreInlineClassWithCustomEquals() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassWithCustomEquals.kt"); @@ -18888,6 +18908,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class JvmStatic extends AbstractLightAnalysisModeTest { + @TestMetadata("extensionPropertyGetter.kt") + public void ignoreExtensionPropertyGetter() throws Exception { + runTest("compiler/testData/codegen/box/jvmStatic/extensionPropertyGetter.kt"); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } @@ -19250,6 +19275,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/localClasses/closureWithSelfInstantiation.kt"); } + @TestMetadata("defaultParameterInConstructor.kt") + public void ignoreDefaultParameterInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt"); + } + @TestMetadata("kt10835.kt") public void ignoreKt10835() throws Exception { runTest("compiler/testData/codegen/box/localClasses/kt10835.kt"); @@ -20530,6 +20560,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class Objects extends AbstractLightAnalysisModeTest { + @TestMetadata("kt32351.kt") + public void ignoreKt32351() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32351.kt"); + } + + @TestMetadata("kt32749.kt") + public void ignoreKt32749() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32749.kt"); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } @@ -21350,6 +21390,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class OperatorConventions extends AbstractLightAnalysisModeTest { + @TestMetadata("kt44647.kt") + public void ignoreKt44647() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } @@ -22974,6 +23019,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/properties/lateinit/kt30548.kt"); } + @TestMetadata("privateVarInCompanion.kt") + public void ignorePrivateVarInCompanion() throws Exception { + runTest("compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt"); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } @@ -32039,6 +32089,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class ProtectedAndPackage extends AbstractLightAnalysisModeTest { + @TestMetadata("kt42012.kt") + public void ignoreKt42012() throws Exception { + runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt"); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 576fd3cbf45..f1413024a07 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -1743,6 +1743,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/callableReference/bound/enumEntryMember.kt"); } + @TestMetadata("genericBoundPropertyAsCrossinline.kt") + public void testGenericBoundPropertyAsCrossinline() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/genericBoundPropertyAsCrossinline.kt"); + } + @TestMetadata("genericValOnLHS.kt") public void testGenericValOnLHS() throws Exception { runTest("compiler/testData/codegen/box/callableReference/bound/genericValOnLHS.kt"); @@ -4829,6 +4834,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/contracts/listAppend.kt"); } + @TestMetadata("nestedLambdaInNonInlineCallExactlyOnce.kt") + public void testNestedLambdaInNonInlineCallExactlyOnce() throws Exception { + runTest("compiler/testData/codegen/box/contracts/nestedLambdaInNonInlineCallExactlyOnce.kt"); + } + @TestMetadata("valInWhen.kt") public void testValInWhen() throws Exception { runTest("compiler/testData/codegen/box/contracts/valInWhen.kt"); @@ -7749,6 +7759,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/localFunctions/named"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + @TestMetadata("callTopLevelFromLocal.kt") + public void testCallTopLevelFromLocal() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/localFunctions/named/callTopLevelFromLocal.kt"); + } + @TestMetadata("capturedParameters.kt") public void testCapturedParameters() throws Exception { runTest("compiler/testData/codegen/box/coroutines/localFunctions/named/capturedParameters.kt"); @@ -12409,6 +12424,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/inlineClasses/crossinlineWithInlineClassInParameter.kt"); } + @TestMetadata("customIterator.kt") + public void testCustomIterator() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/customIterator.kt"); + } + @TestMetadata("defaultFunctionsFromAnyForInlineClass.kt") public void testDefaultFunctionsFromAnyForInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/defaultFunctionsFromAnyForInlineClass.kt"); @@ -15443,6 +15463,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/localClasses/closureWithSelfInstantiation.kt"); } + @TestMetadata("defaultParameterInConstructor.kt") + public void testDefaultParameterInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt"); + } + @TestMetadata("inExtensionFunction.kt") public void testInExtensionFunction() throws Exception { runTest("compiler/testData/codegen/box/localClasses/inExtensionFunction.kt"); @@ -16613,11 +16638,21 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/objects/kt2822.kt"); } + @TestMetadata("kt32351.kt") + public void testKt32351() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32351.kt"); + } + @TestMetadata("kt3238.kt") public void testKt3238() throws Exception { runTest("compiler/testData/codegen/box/objects/kt3238.kt"); } + @TestMetadata("kt32749.kt") + public void testKt32749() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32749.kt"); + } + @TestMetadata("kt3684.kt") public void testKt3684() throws Exception { runTest("compiler/testData/codegen/box/objects/kt3684.kt"); @@ -17298,6 +17333,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); } + @TestMetadata("kt44647.kt") + public void testKt44647() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); @@ -18687,6 +18727,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/properties/lateinit/privateSetterViaSubclass.kt"); } + @TestMetadata("privateVarInCompanion.kt") + public void testPrivateVarInCompanion() throws Exception { + runTest("compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt"); + } + @TestMetadata("simpleVar.kt") public void testSimpleVar() throws Exception { runTest("compiler/testData/codegen/box/properties/lateinit/simpleVar.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java index 7873282c37d..cfbea859cb2 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java @@ -890,6 +890,11 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt18728_4.kt"); } + @TestMetadata("kt30933.kt") + public void testKt30933() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt"); + } + @TestMetadata("lambdaOnLhs.kt") public void testLambdaOnLhs() throws Exception { runTest("compiler/testData/codegen/boxInline/callableReference/bound/lambdaOnLhs.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index b57b4501bcc..9ece45229a7 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -1743,6 +1743,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/bound/enumEntryMember.kt"); } + @TestMetadata("genericBoundPropertyAsCrossinline.kt") + public void testGenericBoundPropertyAsCrossinline() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/genericBoundPropertyAsCrossinline.kt"); + } + @TestMetadata("genericValOnLHS.kt") public void testGenericValOnLHS() throws Exception { runTest("compiler/testData/codegen/box/callableReference/bound/genericValOnLHS.kt"); @@ -4314,6 +4319,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/contracts/listAppend.kt"); } + @TestMetadata("nestedLambdaInNonInlineCallExactlyOnce.kt") + public void testNestedLambdaInNonInlineCallExactlyOnce() throws Exception { + runTest("compiler/testData/codegen/box/contracts/nestedLambdaInNonInlineCallExactlyOnce.kt"); + } + @TestMetadata("valInWhen.kt") public void testValInWhen() throws Exception { runTest("compiler/testData/codegen/box/contracts/valInWhen.kt"); @@ -7234,6 +7244,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/localFunctions/named"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @TestMetadata("callTopLevelFromLocal.kt") + public void testCallTopLevelFromLocal() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/localFunctions/named/callTopLevelFromLocal.kt"); + } + @TestMetadata("capturedParameters.kt") public void testCapturedParameters() throws Exception { runTest("compiler/testData/codegen/box/coroutines/localFunctions/named/capturedParameters.kt"); @@ -11894,6 +11909,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/crossinlineWithInlineClassInParameter.kt"); } + @TestMetadata("customIterator.kt") + public void testCustomIterator() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/customIterator.kt"); + } + @TestMetadata("defaultFunctionsFromAnyForInlineClass.kt") public void testDefaultFunctionsFromAnyForInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/defaultFunctionsFromAnyForInlineClass.kt"); @@ -14928,6 +14948,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/localClasses/closureWithSelfInstantiation.kt"); } + @TestMetadata("defaultParameterInConstructor.kt") + public void testDefaultParameterInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt"); + } + @TestMetadata("inExtensionFunction.kt") public void testInExtensionFunction() throws Exception { runTest("compiler/testData/codegen/box/localClasses/inExtensionFunction.kt"); @@ -16098,11 +16123,21 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/objects/kt2822.kt"); } + @TestMetadata("kt32351.kt") + public void testKt32351() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32351.kt"); + } + @TestMetadata("kt3238.kt") public void testKt3238() throws Exception { runTest("compiler/testData/codegen/box/objects/kt3238.kt"); } + @TestMetadata("kt32749.kt") + public void testKt32749() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32749.kt"); + } + @TestMetadata("kt3684.kt") public void testKt3684() throws Exception { runTest("compiler/testData/codegen/box/objects/kt3684.kt"); @@ -16783,6 +16818,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); } + @TestMetadata("kt44647.kt") + public void testKt44647() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); @@ -18172,6 +18212,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/properties/lateinit/privateSetterViaSubclass.kt"); } + @TestMetadata("privateVarInCompanion.kt") + public void testPrivateVarInCompanion() throws Exception { + runTest("compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt"); + } + @TestMetadata("simpleVar.kt") public void testSimpleVar() throws Exception { runTest("compiler/testData/codegen/box/properties/lateinit/simpleVar.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index c2eb3216cec..edacdee1ae3 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -890,6 +890,11 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt18728_4.kt"); } + @TestMetadata("kt30933.kt") + public void testKt30933() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt"); + } + @TestMetadata("lambdaOnLhs.kt") public void testLambdaOnLhs() throws Exception { runTest("compiler/testData/codegen/boxInline/callableReference/bound/lambdaOnLhs.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 42e581345c0..09b27b46438 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -1743,6 +1743,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/bound/enumEntryMember.kt"); } + @TestMetadata("genericBoundPropertyAsCrossinline.kt") + public void testGenericBoundPropertyAsCrossinline() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/bound/genericBoundPropertyAsCrossinline.kt"); + } + @TestMetadata("genericValOnLHS.kt") public void testGenericValOnLHS() throws Exception { runTest("compiler/testData/codegen/box/callableReference/bound/genericValOnLHS.kt"); @@ -4314,6 +4319,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/contracts/listAppend.kt"); } + @TestMetadata("nestedLambdaInNonInlineCallExactlyOnce.kt") + public void testNestedLambdaInNonInlineCallExactlyOnce() throws Exception { + runTest("compiler/testData/codegen/box/contracts/nestedLambdaInNonInlineCallExactlyOnce.kt"); + } + @TestMetadata("valInWhen.kt") public void testValInWhen() throws Exception { runTest("compiler/testData/codegen/box/contracts/valInWhen.kt"); @@ -7234,6 +7244,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/localFunctions/named"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } + @TestMetadata("callTopLevelFromLocal.kt") + public void testCallTopLevelFromLocal() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/localFunctions/named/callTopLevelFromLocal.kt"); + } + @TestMetadata("capturedParameters.kt") public void testCapturedParameters() throws Exception { runTest("compiler/testData/codegen/box/coroutines/localFunctions/named/capturedParameters.kt"); @@ -11959,6 +11974,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/crossinlineWithInlineClassInParameter.kt"); } + @TestMetadata("customIterator.kt") + public void testCustomIterator() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/customIterator.kt"); + } + @TestMetadata("defaultFunctionsFromAnyForInlineClass.kt") public void testDefaultFunctionsFromAnyForInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/defaultFunctionsFromAnyForInlineClass.kt"); @@ -14993,6 +15013,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/localClasses/closureWithSelfInstantiation.kt"); } + @TestMetadata("defaultParameterInConstructor.kt") + public void testDefaultParameterInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt"); + } + @TestMetadata("inExtensionFunction.kt") public void testInExtensionFunction() throws Exception { runTest("compiler/testData/codegen/box/localClasses/inExtensionFunction.kt"); @@ -16163,11 +16188,21 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/objects/kt2822.kt"); } + @TestMetadata("kt32351.kt") + public void testKt32351() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32351.kt"); + } + @TestMetadata("kt3238.kt") public void testKt3238() throws Exception { runTest("compiler/testData/codegen/box/objects/kt3238.kt"); } + @TestMetadata("kt32749.kt") + public void testKt32749() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32749.kt"); + } + @TestMetadata("kt3684.kt") public void testKt3684() throws Exception { runTest("compiler/testData/codegen/box/objects/kt3684.kt"); @@ -16853,6 +16888,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); } + @TestMetadata("kt44647.kt") + public void testKt44647() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); @@ -18227,6 +18267,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/properties/lateinit/privateSetterViaSubclass.kt"); } + @TestMetadata("privateVarInCompanion.kt") + public void testPrivateVarInCompanion() throws Exception { + runTest("compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt"); + } + @TestMetadata("simpleVar.kt") public void testSimpleVar() throws Exception { runTest("compiler/testData/codegen/box/properties/lateinit/simpleVar.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index 16d7521b1f4..edf8a2f4844 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -890,6 +890,11 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt18728_4.kt"); } + @TestMetadata("kt30933.kt") + public void testKt30933() throws Exception { + runTest("compiler/testData/codegen/boxInline/callableReference/bound/kt30933.kt"); + } + @TestMetadata("lambdaOnLhs.kt") public void testLambdaOnLhs() throws Exception { runTest("compiler/testData/codegen/boxInline/callableReference/bound/lambdaOnLhs.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index d0369ce3b16..72c3b85e92f 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -8939,6 +8939,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/localClasses/closureOfLambdaInLocalClass.kt"); } + @TestMetadata("defaultParameterInConstructor.kt") + public void testDefaultParameterInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/localClasses/defaultParameterInConstructor.kt"); + } + @TestMetadata("inExtensionFunction.kt") public void testInExtensionFunction() throws Exception { runTest("compiler/testData/codegen/box/localClasses/inExtensionFunction.kt"); @@ -9989,6 +9994,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/objects/kt2822.kt"); } + @TestMetadata("kt32749.kt") + public void testKt32749() throws Exception { + runTest("compiler/testData/codegen/box/objects/kt32749.kt"); + } + @TestMetadata("kt3684.kt") public void testKt3684() throws Exception { runTest("compiler/testData/codegen/box/objects/kt3684.kt"); @@ -11521,6 +11531,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/properties/lateinit/privateSetterViaSubclass.kt"); } + @TestMetadata("privateVarInCompanion.kt") + public void testPrivateVarInCompanion() throws Exception { + runTest("compiler/testData/codegen/box/properties/lateinit/privateVarInCompanion.kt"); + } + @TestMetadata("simpleVar.kt") public void testSimpleVar() throws Exception { runTest("compiler/testData/codegen/box/properties/lateinit/simpleVar.kt"); From 2c4a6fdb982d842c4ea27e910cb52993105f1d96 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Thu, 11 Feb 2021 01:07:38 +0300 Subject: [PATCH 003/368] Revert "Use IDEA ASM in kapt module" This reverts commit 903defdf --- .../kotlin-gradle-plugin-integration-tests/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts index 7530f173133..48ba118ee31 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts @@ -45,7 +45,7 @@ dependencies { // Workaround for missing transitive import of the common(project `kotlin-test-common` // for `kotlin-test-jvm` into the IDE: testCompileOnly(project(":kotlin-test:kotlin-test-common")) { isTransitive = false } - compileOnly(intellijDep()) { includeJars("asm-all") } + testCompileOnly("org.jetbrains.intellij.deps:asm-all:9.0") } // Aapt2 from Android Gradle Plugin 3.2 and below does not handle long paths on Windows. From 67671afab4dcdb74b9ab5b8c92fe3b3932007960 Mon Sep 17 00:00:00 2001 From: Roman Artemev Date: Wed, 10 Feb 2021 16:58:49 +0300 Subject: [PATCH 004/368] [Plugin API] Fix missed call in `resolveBySignatureInModule` --- .../kotlin/backend/common/serialization/KotlinIrLinker.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIrLinker.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIrLinker.kt index 177775d8b70..6796aefbe2d 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIrLinker.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIrLinker.kt @@ -681,7 +681,9 @@ abstract class KotlinIrLinker( deserializersForModules.entries.find { it.key.name == moduleName }?.value ?: error("No module for name '$moduleName' found") assert(signature == signature.topLevelSignature()) { "Signature '$signature' has to be top level" } if (signature !in moduleDeserializer) error("No signature $signature in module $moduleName") - return moduleDeserializer.deserializeIrSymbol(signature, topLevelKindToSymbolKind(kind)) + return moduleDeserializer.deserializeIrSymbol(signature, topLevelKindToSymbolKind(kind)).also { + deserializeAllReachableTopLevels() + } } // The issue here is that an expect can not trigger its actual deserialization by reachability From 7050af9b7907256a4fe73abb7b1f7caf05eee2bd Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 10 Feb 2021 13:04:53 +0300 Subject: [PATCH 005/368] FIR2IR: use invariant projections for SAM_CONVERSION types --- .../kotlin/fir/backend/ConversionUtils.kt | 24 ++++++++++++++--- .../kotlin/fir/backend/Fir2IrTypeConverter.kt | 6 ++--- .../generators/CallAndReferenceGenerator.kt | 5 ++-- .../runners/ir/Fir2IrTextTestGenerated.java | 6 +++++ .../box/invokedynamic/sam/streamApi1.kt | 1 - .../box/invokedynamic/sam/streamApi2.kt | 1 - compiler/testData/codegen/box/sam/kt11519.kt | 1 - .../bytecodeText/invokedynamic/streamApi.kt | 1 - .../ir/irText/firProblems/kt19251.fir.kt.txt | 11 ++++++++ .../ir/irText/firProblems/kt19251.fir.txt | 26 +++++++++++++++++++ .../testData/ir/irText/firProblems/kt19251.kt | 14 ++++++++++ .../ir/irText/firProblems/kt19251.kt.txt | 11 ++++++++ .../ir/irText/firProblems/kt19251.txt | 26 +++++++++++++++++++ .../test/runners/ir/IrTextTestGenerated.java | 6 +++++ 14 files changed, 125 insertions(+), 14 deletions(-) create mode 100644 compiler/testData/ir/irText/firProblems/kt19251.fir.kt.txt create mode 100644 compiler/testData/ir/irText/firProblems/kt19251.fir.txt create mode 100644 compiler/testData/ir/irText/firProblems/kt19251.kt create mode 100644 compiler/testData/ir/irText/firProblems/kt19251.kt.txt create mode 100644 compiler/testData/ir/irText/firProblems/kt19251.txt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index 75c26fb8444..211c6b3f440 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -71,16 +71,32 @@ internal enum class ConversionTypeOrigin { class ConversionTypeContext internal constructor( internal val definitelyNotNull: Boolean, - internal val origin: ConversionTypeOrigin + internal val invariantProjection: Boolean = false, + internal val origin: ConversionTypeOrigin = ConversionTypeOrigin.DEFAULT, ) { - fun definitelyNotNull() = ConversionTypeContext(true, origin) + fun definitelyNotNull() = ConversionTypeContext( + definitelyNotNull = true, + invariantProjection = invariantProjection, + origin = origin + ) - fun inSetter() = ConversionTypeContext(definitelyNotNull, ConversionTypeOrigin.SETTER) + fun inSetter() = ConversionTypeContext( + definitelyNotNull = definitelyNotNull, + invariantProjection = invariantProjection, + origin = ConversionTypeOrigin.SETTER + ) + + fun withInvariantProjections() = ConversionTypeContext( + definitelyNotNull = definitelyNotNull, + invariantProjection = true, + origin = origin + ) companion object { internal val DEFAULT = ConversionTypeContext( - definitelyNotNull = false, origin = ConversionTypeOrigin.DEFAULT + definitelyNotNull = false, origin = ConversionTypeOrigin.DEFAULT, invariantProjection = false ) + internal val WITH_INVARIANT = DEFAULT.withInvariantProjections() } } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt index 18138333a5e..272b346a8cd 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt @@ -10,7 +10,6 @@ import org.jetbrains.kotlin.fir.expressions.classId import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.StandardClassIds -import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.* import org.jetbrains.kotlin.ir.expressions.IrConstructorCall @@ -20,7 +19,6 @@ import org.jetbrains.kotlin.ir.types.IrTypeArgument import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection -import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.types.Variance @@ -150,11 +148,11 @@ class Fir2IrTypeConverter( ConeStarProjection -> IrStarProjectionImpl is ConeKotlinTypeProjectionIn -> { val irType = this.type.toIrType(typeContext) - makeTypeProjection(irType, Variance.IN_VARIANCE) + makeTypeProjection(irType, if (typeContext.invariantProjection) Variance.INVARIANT else Variance.IN_VARIANCE) } is ConeKotlinTypeProjectionOut -> { val irType = this.type.toIrType(typeContext) - makeTypeProjection(irType, Variance.OUT_VARIANCE) + makeTypeProjection(irType, if (typeContext.invariantProjection) Variance.INVARIANT else Variance.OUT_VARIANCE) } is ConeKotlinType -> { if (this is ConeCapturedType && this in capturedTypeCache && this.isRecursive(mutableSetOf())) { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index 50463b06569..cb37d83c8bd 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -52,7 +52,8 @@ class CallAndReferenceGenerator( private val adapterGenerator = AdapterGenerator(components, conversionScope) private val samResolver = FirSamResolverImpl(session, scopeSession) - private fun FirTypeRef.toIrType(): IrType = with(typeConverter) { toIrType() } + private fun FirTypeRef.toIrType(conversionTypeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT): IrType = + with(typeConverter) { toIrType(conversionTypeContext) } private fun ConeKotlinType.toIrType(): IrType = with(typeConverter) { toIrType() } @@ -608,7 +609,7 @@ class CallAndReferenceGenerator( if (!needSamConversion(argument, parameter)) { return this } - var samType = parameter.returnTypeRef.toIrType() + var samType = parameter.returnTypeRef.toIrType(ConversionTypeContext.WITH_INVARIANT) if (shouldUnwrapVarargType) { samType = samType.getArrayElementType(irBuiltIns) } diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index 6c0c63e55c0..ce07fa4515b 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -2152,6 +2152,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/firProblems/JCTree.kt"); } + @Test + @TestMetadata("kt19251.kt") + public void testKt19251() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/kt19251.kt"); + } + @Test @TestMetadata("kt43342.kt") public void testKt43342() throws Exception { diff --git a/compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt b/compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt index 29d4105043f..8e2807d3f4f 100644 --- a/compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt +++ b/compiler/testData/codegen/box/invokedynamic/sam/streamApi1.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // JVM_TARGET: 1.8 // SAM_CONVERSIONS: INDY // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt b/compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt index acf3669d37f..5746bfd079b 100644 --- a/compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt +++ b/compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // JVM_TARGET: 1.8 // SAM_CONVERSIONS: INDY // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/sam/kt11519.kt b/compiler/testData/codegen/box/sam/kt11519.kt index 6555291dbbf..d99b46ff331 100644 --- a/compiler/testData/codegen/box/sam/kt11519.kt +++ b/compiler/testData/codegen/box/sam/kt11519.kt @@ -1,5 +1,4 @@ // DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE -// IGNORE_BACKEND_FIR: JVM_IR // SKIP_JDK6 // MODULE: lib // FILE: Custom.java diff --git a/compiler/testData/codegen/bytecodeText/invokedynamic/streamApi.kt b/compiler/testData/codegen/bytecodeText/invokedynamic/streamApi.kt index 52f0ae1029c..99dad35114a 100644 --- a/compiler/testData/codegen/bytecodeText/invokedynamic/streamApi.kt +++ b/compiler/testData/codegen/bytecodeText/invokedynamic/streamApi.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // JVM_TARGET: 1.8 // SAM_CONVERSIONS: INDY // WITH_RUNTIME diff --git a/compiler/testData/ir/irText/firProblems/kt19251.fir.kt.txt b/compiler/testData/ir/irText/firProblems/kt19251.fir.kt.txt new file mode 100644 index 00000000000..f2ec41e978f --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/kt19251.fir.kt.txt @@ -0,0 +1,11 @@ +fun box(): String { + val map: MutableMap = mutableMapOf() + val fn: Fun = local fun (it: String?): String? { + return TODO() + } + /*-> Fun */ + return map.computeIfAbsent(p0 = fn, p1 = local fun (it: Fun?): String? { + return "OK" + } + /*-> @FlexibleNullability Function */) +} diff --git a/compiler/testData/ir/irText/firProblems/kt19251.fir.txt b/compiler/testData/ir/irText/firProblems/kt19251.fir.txt new file mode 100644 index 00000000000..c3a84e3562b --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/kt19251.fir.txt @@ -0,0 +1,26 @@ +FILE fqName: fileName:/test.kt + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:map type:kotlin.collections.MutableMap<.Fun, kotlin.String> [val] + CALL 'public final fun mutableMapOf (): kotlin.collections.MutableMap [inline] declared in kotlin.collections.MapsKt' type=kotlin.collections.MutableMap<.Fun, kotlin.String> origin=null + : .Fun + : kotlin.String + VAR name:fn type:.Fun [val] + TYPE_OP type=.Fun origin=SAM_CONVERSION typeOperand=.Fun + FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.String?) returnType:kotlin.String? + VALUE_PARAMETER name:it index:0 type:kotlin.String? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: kotlin.String?): kotlin.String? declared in .box' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public open fun computeIfAbsent (p0: K of kotlin.collections.MutableMap, p1: @[FlexibleNullability] java.util.function.Function): V of kotlin.collections.MutableMap declared in kotlin.collections.MutableMap' type=kotlin.String origin=null + $this: GET_VAR 'val map: kotlin.collections.MutableMap<.Fun, kotlin.String> [val] declared in .box' type=kotlin.collections.MutableMap<.Fun, kotlin.String> origin=null + p0: GET_VAR 'val fn: .Fun [val] declared in .box' type=.Fun origin=null + p1: TYPE_OP type=@[FlexibleNullability] java.util.function.Function<.Fun?, kotlin.String?> origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] java.util.function.Function<.Fun?, kotlin.String?> + FUN_EXPR type=kotlin.Function1<.Fun?, kotlin.String?> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.Fun?) returnType:kotlin.String? + VALUE_PARAMETER name:it index:0 type:.Fun? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: .Fun?): kotlin.String? declared in .box' + CONST String type=kotlin.String value="OK" diff --git a/compiler/testData/ir/irText/firProblems/kt19251.kt b/compiler/testData/ir/irText/firProblems/kt19251.kt new file mode 100644 index 00000000000..5ab0fdecbd2 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/kt19251.kt @@ -0,0 +1,14 @@ +// WITH_RUNTIME +// FULL_JDK +// FILE: Fun.java +public interface Fun { + String invoke(String string); +} + +// FILE: test.kt +fun box(): String { + val map = mutableMapOf() + val fn = Fun { TODO() } + return map.computeIfAbsent(fn, { "OK" }) +} + diff --git a/compiler/testData/ir/irText/firProblems/kt19251.kt.txt b/compiler/testData/ir/irText/firProblems/kt19251.kt.txt new file mode 100644 index 00000000000..504268b1f0d --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/kt19251.kt.txt @@ -0,0 +1,11 @@ +fun box(): String { + val map: MutableMap = mutableMapOf() + val fn: Fun = local fun (it: @FlexibleNullability String?): @FlexibleNullability String? { + TODO() + } + /*-> Fun */ + return map.computeIfAbsent(p0 = fn, p1 = local fun (it: @EnhancedNullability Fun): @EnhancedNullability String { + return "OK" + } + /*-> @EnhancedNullability Function<@EnhancedNullability Fun, @EnhancedNullability String> */) /*!! String */ +} diff --git a/compiler/testData/ir/irText/firProblems/kt19251.txt b/compiler/testData/ir/irText/firProblems/kt19251.txt new file mode 100644 index 00000000000..9cc7b4ca1c7 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/kt19251.txt @@ -0,0 +1,26 @@ +FILE fqName: fileName:/test.kt + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:map type:kotlin.collections.MutableMap<.Fun, kotlin.String> [val] + CALL 'public final fun mutableMapOf (): kotlin.collections.MutableMap [inline] declared in kotlin.collections.MapsKt' type=kotlin.collections.MutableMap<.Fun, kotlin.String> origin=null + : .Fun + : kotlin.String + VAR name:fn type:.Fun [val] + TYPE_OP type=.Fun origin=SAM_CONVERSION typeOperand=.Fun + FUN_EXPR type=kotlin.Function1<@[ParameterName(name = 'string')] @[FlexibleNullability] kotlin.String?, @[FlexibleNullability] kotlin.String?> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:@[FlexibleNullability] kotlin.String?) returnType:@[FlexibleNullability] kotlin.String? + VALUE_PARAMETER name:it index:0 type:@[FlexibleNullability] kotlin.String? + BLOCK_BODY + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun computeIfAbsent (p0: @[EnhancedNullability] K of kotlin.collections.MutableMap, p1: @[EnhancedNullability] java.util.function.Function): @[EnhancedNullability] V of kotlin.collections.MutableMap declared in kotlin.collections.MutableMap' type=@[EnhancedNullability] kotlin.String origin=null + $this: GET_VAR 'val map: kotlin.collections.MutableMap<.Fun, kotlin.String> [val] declared in .box' type=kotlin.collections.MutableMap<.Fun, kotlin.String> origin=null + p0: GET_VAR 'val fn: .Fun [val] declared in .box' type=.Fun origin=null + p1: TYPE_OP type=@[EnhancedNullability] java.util.function.Function<@[EnhancedNullability] .Fun, @[EnhancedNullability] kotlin.String> origin=SAM_CONVERSION typeOperand=@[EnhancedNullability] java.util.function.Function<@[EnhancedNullability] .Fun, @[EnhancedNullability] kotlin.String> + FUN_EXPR type=kotlin.Function1<@[EnhancedNullability] .Fun, @[EnhancedNullability] kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:@[EnhancedNullability] .Fun) returnType:@[EnhancedNullability] kotlin.String + VALUE_PARAMETER name:it index:0 type:@[EnhancedNullability] .Fun + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: @[EnhancedNullability] .Fun): @[EnhancedNullability] kotlin.String declared in .box' + CONST String type=kotlin.String value="OK" diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index b7324e8531e..ceff6e39e78 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -2152,6 +2152,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/firProblems/JCTree.kt"); } + @Test + @TestMetadata("kt19251.kt") + public void testKt19251() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/kt19251.kt"); + } + @Test @TestMetadata("kt43342.kt") public void testKt43342() throws Exception { From 346ffb3acf99e389a44fc3f265e60ff9cdc6ba2d Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 10 Feb 2021 17:13:30 +0300 Subject: [PATCH 006/368] FIR2IR: support substitution for SAM types --- .../generators/CallAndReferenceGenerator.kt | 38 ++++++++++++++----- ...dSubstitutedTypeForCallableSamParameter.kt | 1 - ...versionInGenericConstructorCall.fir.kt.txt | 4 +- ...ConversionInGenericConstructorCall.fir.txt | 4 +- ...sionInGenericConstructorCall_NI.fir.kt.txt | 8 ++-- ...versionInGenericConstructorCall_NI.fir.txt | 12 +++--- .../sam/samConversionToGeneric.fir.kt.txt | 12 +++--- .../sam/samConversionToGeneric.fir.txt | 12 +++--- .../samConversionsWithSmartCasts.fir.kt.txt | 2 +- .../sam/samConversionsWithSmartCasts.fir.txt | 3 +- 10 files changed, 57 insertions(+), 39 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index cb37d83c8bd..9b778371d07 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -25,6 +25,8 @@ import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType import org.jetbrains.kotlin.fir.resolve.inference.isKMutableProperty +import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor +import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutorByMap import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope import org.jetbrains.kotlin.fir.symbols.impl.* @@ -52,10 +54,10 @@ class CallAndReferenceGenerator( private val adapterGenerator = AdapterGenerator(components, conversionScope) private val samResolver = FirSamResolverImpl(session, scopeSession) - private fun FirTypeRef.toIrType(conversionTypeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT): IrType = - with(typeConverter) { toIrType(conversionTypeContext) } + private fun FirTypeRef.toIrType(): IrType = with(typeConverter) { toIrType() } - private fun ConeKotlinType.toIrType(): IrType = with(typeConverter) { toIrType() } + private fun ConeKotlinType.toIrType(conversionTypeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT): IrType = + with(typeConverter) { toIrType(conversionTypeContext) } fun convertToIrCallableReference( callableReferenceAccess: FirCallableReferenceAccess, @@ -439,6 +441,17 @@ class CallAndReferenceGenerator( } } + private fun FirFunctionCall.buildSubstitutorByCalledFunction(function: FirFunction<*>?): ConeSubstitutor? { + if (function == null) return null + val map = mutableMapOf() + for ((index, typeParameter) in function.typeParameters.withIndex()) { + val typeProjection = typeArguments.getOrNull(index) as? FirTypeProjectionWithVariance ?: continue + val type = typeProjection.typeRef.coneTypeSafe() ?: continue + map[typeParameter.symbol] = type + } + return ConeSubstitutorByMap(map) + } + internal fun IrExpression.applyCallArguments(call: FirCall?, annotationMode: Boolean): IrExpression { if (call == null) return this return when (this) { @@ -461,14 +474,15 @@ class CallAndReferenceGenerator( } val valueParameters = function?.valueParameters val argumentMapping = call.argumentMapping + val substitutor = (call as? FirFunctionCall)?.buildSubstitutorByCalledFunction(function) ?: ConeSubstitutor.Empty if (argumentMapping != null && (annotationMode || argumentMapping.isNotEmpty())) { if (valueParameters != null) { - return applyArgumentsWithReorderingIfNeeded(argumentMapping, valueParameters, annotationMode) + return applyArgumentsWithReorderingIfNeeded(argumentMapping, valueParameters, substitutor, annotationMode) } } for ((index, argument) in call.arguments.withIndex()) { val valueParameter = valueParameters?.get(index) - val argumentExpression = convertArgument(argument, valueParameter) + val argumentExpression = convertArgument(argument, valueParameter, substitutor) putValueArgument(index, argumentExpression) } } @@ -496,6 +510,7 @@ class CallAndReferenceGenerator( private fun IrMemberAccessExpression<*>.applyArgumentsWithReorderingIfNeeded( argumentMapping: LinkedHashMap, valueParameters: List, + substitutor: ConeSubstitutor, annotationMode: Boolean ): IrExpression { // Assuming compile-time constants only inside annotation, we don't need a block to reorder arguments to preserve semantics. @@ -506,7 +521,7 @@ class CallAndReferenceGenerator( return IrBlockImpl(startOffset, endOffset, type, IrStatementOrigin.ARGUMENTS_REORDERING_FOR_CALL).apply { for ((argument, parameter) in argumentMapping) { val parameterIndex = valueParameters.indexOf(parameter) - val irArgument = convertArgument(argument, parameter) + val irArgument = convertArgument(argument, parameter, substitutor) if (irArgument.hasNoSideEffects()) { putValueArgument(parameterIndex, irArgument) } else { @@ -521,7 +536,7 @@ class CallAndReferenceGenerator( } } else { for ((argument, parameter) in argumentMapping) { - val argumentExpression = convertArgument(argument, parameter, annotationMode) + val argumentExpression = convertArgument(argument, parameter, substitutor, annotationMode) putValueArgument(valueParameters.indexOf(parameter), argumentExpression) } if (annotationMode) { @@ -562,6 +577,7 @@ class CallAndReferenceGenerator( private fun convertArgument( argument: FirExpression, parameter: FirValueParameter?, + substitutor: ConeSubstitutor, annotationMode: Boolean = false ): IrExpression { var irArgument = visitor.convertToIrExpression(argument, annotationMode) @@ -574,7 +590,7 @@ class CallAndReferenceGenerator( if (parameter?.returnTypeRef is FirResolvedTypeRef) { // Java type case (from annotations) irArgument = irArgument.applySuspendConversionIfNeeded(argument, parameter) - irArgument = irArgument.applySamConversionIfNeeded(argument, parameter) + irArgument = irArgument.applySamConversionIfNeeded(argument, parameter, substitutor) } } return irArgument.applyAssigningArrayElementsToVarargInNamedForm(argument, parameter) @@ -583,6 +599,7 @@ class CallAndReferenceGenerator( private fun IrExpression.applySamConversionIfNeeded( argument: FirExpression, parameter: FirValueParameter?, + substitutor: ConeSubstitutor, shouldUnwrapVarargType: Boolean = false ): IrExpression { if (parameter == null) { @@ -600,7 +617,7 @@ class CallAndReferenceGenerator( if (irVarargElement is IrExpression) { val firVarargArgument = argumentMapping[irVarargElement] ?: error("Can't find the original FirExpression for ${irVarargElement.render()}") - irVarargElement.applySamConversionIfNeeded(firVarargArgument, parameter, shouldUnwrapVarargType = true) + irVarargElement.applySamConversionIfNeeded(firVarargArgument, parameter, substitutor, shouldUnwrapVarargType = true) } else irVarargElement } @@ -609,7 +626,8 @@ class CallAndReferenceGenerator( if (!needSamConversion(argument, parameter)) { return this } - var samType = parameter.returnTypeRef.toIrType(ConversionTypeContext.WITH_INVARIANT) + val samFirType = parameter.returnTypeRef.coneTypeSafe()?.let { substitutor.substituteOrSelf(it) } + var samType = samFirType?.toIrType(ConversionTypeContext.WITH_INVARIANT) ?: createErrorType() if (shouldUnwrapVarargType) { samType = samType.getArrayElementType(irBuiltIns) } diff --git a/compiler/testData/codegen/box/sam/recordSubstitutedTypeForCallableSamParameter.kt b/compiler/testData/codegen/box/sam/recordSubstitutedTypeForCallableSamParameter.kt index 613218c6f03..56ae5eedccf 100644 --- a/compiler/testData/codegen/box/sam/recordSubstitutedTypeForCallableSamParameter.kt +++ b/compiler/testData/codegen/box/sam/recordSubstitutedTypeForCallableSamParameter.kt @@ -1,7 +1,6 @@ // !LANGUAGE: +NewInference +SamConversionPerArgument +SamConversionForKotlinFunctions +FunctionalInterfaceConversion // WITH_REFLECT // FULL_JDK -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // FILE: Provider.java diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall.fir.kt.txt index 53195465e1f..933ecc446f7 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall.fir.kt.txt @@ -1,8 +1,8 @@ fun test1(f: Function1): C { - return C(jxx = f /*-> J? */) + return C(jxx = f /*-> J? */) } fun test2(x: Any) { x as Function1 /*~> Unit */ - C(jxx = x /*as Function1 */ /*-> J? */) /*~> Unit */ + C(jxx = x /*as Function1 */ /*-> J? */) /*~> Unit */ } diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall.fir.txt index e609956c03f..457d1b01784 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall.fir.txt @@ -5,7 +5,7 @@ FILE fqName: fileName:/samConversionInGenericConstructorCall.kt RETURN type=kotlin.Nothing from='public final fun test1 (f: kotlin.Function1): .C declared in ' CONSTRUCTOR_CALL 'public constructor (jxx: .J.C?, X of .C?>?) declared in .C' type=.C origin=null : kotlin.String? - jxx: TYPE_OP type=.J.C?, X of .C?>? origin=SAM_CONVERSION typeOperand=.J.C?, X of .C?>? + jxx: TYPE_OP type=.J? origin=SAM_CONVERSION typeOperand=.J? GET_VAR 'f: kotlin.Function1 declared in .test1' type=kotlin.Function1 origin=null FUN name:test2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:x index:0 type:kotlin.Any @@ -16,6 +16,6 @@ FILE fqName: fileName:/samConversionInGenericConstructorCall.kt TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CONSTRUCTOR_CALL 'public constructor (jxx: .J.C?, X of .C?>?) declared in .C' type=.C origin=null : kotlin.String? - jxx: TYPE_OP type=.J.C?, X of .C?>? origin=SAM_CONVERSION typeOperand=.J.C?, X of .C?>? + jxx: TYPE_OP type=.J? origin=SAM_CONVERSION typeOperand=.J? TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 GET_VAR 'x: kotlin.Any declared in .test2' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall_NI.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall_NI.fir.kt.txt index fcde5506071..755e77acfeb 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall_NI.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall_NI.fir.kt.txt @@ -1,5 +1,5 @@ fun test3(f1: Function1, f2: Function1): D { - return C(jxx = f1 /*-> J? */).D(jxy = f2 /*-> J? */) + return C(jxx = f1 /*-> J? */).D(jxy = f2 /*-> J? */) } class Outer { @@ -29,14 +29,14 @@ class Outer { } fun test4(f: Function1, g: Function1): Inner { - return Outer(j11 = f /*-> J */).Inner(j12 = g /*-> J */) + return Outer(j11 = f /*-> J */).Inner(j12 = g /*-> J */) } fun testGenericJavaCtor1(f: Function1): G { - return G(x = f /*-> J? */) + return G(x = f /*-> J? */) } fun testGenericJavaCtor2(x: Any) { x as Function1 /*~> Unit */ - G(x = x /*as Function1 */ /*-> J? */) /*~> Unit */ + G(x = x /*as Function1 */ /*-> J? */) /*~> Unit */ } diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall_NI.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall_NI.fir.txt index eddf1c4f215..d2185903d91 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall_NI.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall_NI.fir.txt @@ -8,9 +8,9 @@ FILE fqName: fileName:/samConversionInGenericConstructorCall_NI.kt : kotlin.Int? $outer: CONSTRUCTOR_CALL 'public constructor (jxx: .J.C?, X of .C?>?) declared in .C' type=.C origin=null : kotlin.String? - jxx: TYPE_OP type=.J.C?, X of .C?>? origin=SAM_CONVERSION typeOperand=.J.C?, X of .C?>? + jxx: TYPE_OP type=.J? origin=SAM_CONVERSION typeOperand=.J? GET_VAR 'f1: kotlin.Function1 declared in .test3' type=kotlin.Function1 origin=null - jxy: TYPE_OP type=.J.C.D?>? origin=SAM_CONVERSION typeOperand=.J.C.D?>? + jxy: TYPE_OP type=.J? origin=SAM_CONVERSION typeOperand=.J? GET_VAR 'f2: kotlin.Function1 declared in .test3' type=kotlin.Function1 origin=null CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Outer.Outer> @@ -86,9 +86,9 @@ FILE fqName: fileName:/samConversionInGenericConstructorCall_NI.kt : kotlin.Any? $outer: CONSTRUCTOR_CALL 'public constructor (j11: .J.Outer, T1 of .Outer>) [primary] declared in .Outer' type=.Outer origin=null : kotlin.String? - j11: TYPE_OP type=.J.Outer, T1 of .Outer> origin=SAM_CONVERSION typeOperand=.J.Outer, T1 of .Outer> + j11: TYPE_OP type=.J origin=SAM_CONVERSION typeOperand=.J GET_VAR 'f: kotlin.Function1 declared in .test4' type=kotlin.Function1 origin=null - j12: TYPE_OP type=.J.Outer.Inner> origin=SAM_CONVERSION typeOperand=.J.Outer.Inner> + j12: TYPE_OP type=.J origin=SAM_CONVERSION typeOperand=.J GET_VAR 'g: kotlin.Function1 declared in .test4' type=kotlin.Function1 origin=null FUN name:testGenericJavaCtor1 visibility:public modality:FINAL <> (f:kotlin.Function1) returnType:.G VALUE_PARAMETER name:f index:0 type:kotlin.Function1 @@ -97,7 +97,7 @@ FILE fqName: fileName:/samConversionInGenericConstructorCall_NI.kt CONSTRUCTOR_CALL 'public constructor (x: .J.G.?, TClass of .G?>?) declared in .G' type=.G origin=null : kotlin.String? : kotlin.Int? - x: TYPE_OP type=.J.G.?, TClass of .G?>? origin=SAM_CONVERSION typeOperand=.J.G.?, TClass of .G?>? + x: TYPE_OP type=.J? origin=SAM_CONVERSION typeOperand=.J? GET_VAR 'f: kotlin.Function1 declared in .testGenericJavaCtor1' type=kotlin.Function1 origin=null FUN name:testGenericJavaCtor2 visibility:public modality:FINAL <> (x:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:x index:0 type:kotlin.Any @@ -109,6 +109,6 @@ FILE fqName: fileName:/samConversionInGenericConstructorCall_NI.kt CONSTRUCTOR_CALL 'public constructor (x: .J.G.?, TClass of .G?>?) declared in .G' type=.G origin=null : kotlin.String? : kotlin.Int? - x: TYPE_OP type=.J.G.?, TClass of .G?>? origin=SAM_CONVERSION typeOperand=.J.G.?, TClass of .G?>? + x: TYPE_OP type=.J? origin=SAM_CONVERSION typeOperand=.J? TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 GET_VAR 'x: kotlin.Any declared in .testGenericJavaCtor2' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.kt.txt index d4621f45e1a..4a6b72912b2 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.kt.txt @@ -16,7 +16,7 @@ fun test3() { return bar(j = local fun (x: String): String? { return x } - /*-> J? */) + /*-> J? */) } fun test4(a: Any) { @@ -26,16 +26,16 @@ fun test4(a: Any) { fun test5(a: Any) { a as Function1 /*~> Unit */ - bar(j = a /*as Function1 */ /*-> J? */) + bar(j = a /*as Function1 */ /*-> J? */) } fun test6(a: Function1) { - bar(j = a /*-> J? */) + bar(j = a /*-> J? */) } fun test7(a: Any) { a as Function1 /*~> Unit */ - bar(j = a /*as Function1 */ /*-> J? */) + bar(j = a /*as Function1 */ /*-> J? */) } fun test8(efn: @ExtensionFunctionType Function1): J { @@ -43,9 +43,9 @@ fun test8(efn: @ExtensionFunctionType Function1): J { } fun test9(efn: @ExtensionFunctionType Function1) { - bar(j = efn /*-> J? */) + bar(j = efn /*-> J? */) } fun test10(fn: Function1) { - bar2x(j2x = fn /*-> J2X? */) + bar2x(j2x = fn /*-> J2X? */) } diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.txt index 00e1e8586da..8197321a138 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.txt @@ -24,7 +24,7 @@ FILE fqName: fileName:/samConversionToGeneric.kt RETURN type=kotlin.Nothing from='public final fun test3 (): kotlin.Unit declared in ' CALL 'public open fun bar (j: .J.H.bar?>?): kotlin.Unit declared in .H' type=kotlin.Unit origin=null : kotlin.String? - j: TYPE_OP type=.J.H.bar?>? origin=SAM_CONVERSION typeOperand=.J.H.bar?>? + j: TYPE_OP type=.J? origin=SAM_CONVERSION typeOperand=.J? FUN_EXPR type=kotlin.Function1 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (x:kotlin.String) returnType:kotlin.String? VALUE_PARAMETER name:x index:0 type:kotlin.String @@ -49,7 +49,7 @@ FILE fqName: fileName:/samConversionToGeneric.kt GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null CALL 'public open fun bar (j: .J.H.bar?>?): kotlin.Unit declared in .H' type=kotlin.Unit origin=null : kotlin.String? - j: TYPE_OP type=.J.H.bar?>? origin=SAM_CONVERSION typeOperand=.J.H.bar?>? + j: TYPE_OP type=.J? origin=SAM_CONVERSION typeOperand=.J? TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null FUN name:test6 visibility:public modality:FINAL (a:kotlin.Function1.test6, T of .test6>) returnType:kotlin.Unit @@ -58,7 +58,7 @@ FILE fqName: fileName:/samConversionToGeneric.kt BLOCK_BODY CALL 'public open fun bar (j: .J.H.bar?>?): kotlin.Unit declared in .H' type=kotlin.Unit origin=null : T of .test6? - j: TYPE_OP type=.J.H.bar?>? origin=SAM_CONVERSION typeOperand=.J.H.bar?>? + j: TYPE_OP type=.J.test6?>? origin=SAM_CONVERSION typeOperand=.J.test6?>? GET_VAR 'a: kotlin.Function1.test6, T of .test6> declared in .test6' type=kotlin.Function1.test6, T of .test6> origin=null FUN name:test7 visibility:public modality:FINAL (a:kotlin.Any) returnType:kotlin.Unit TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] @@ -69,7 +69,7 @@ FILE fqName: fileName:/samConversionToGeneric.kt GET_VAR 'a: kotlin.Any declared in .test7' type=kotlin.Any origin=null CALL 'public open fun bar (j: .J.H.bar?>?): kotlin.Unit declared in .H' type=kotlin.Unit origin=null : T of .test7? - j: TYPE_OP type=.J.H.bar?>? origin=SAM_CONVERSION typeOperand=.J.H.bar?>? + j: TYPE_OP type=.J.test7?>? origin=SAM_CONVERSION typeOperand=.J.test7?>? TYPE_OP type=kotlin.Function1.test7, T of .test7> origin=IMPLICIT_CAST typeOperand=kotlin.Function1.test7, T of .test7> GET_VAR 'a: kotlin.Any declared in .test7' type=kotlin.Any origin=null FUN name:test8 visibility:public modality:FINAL <> (efn:@[ExtensionFunctionType] kotlin.Function1) returnType:.J @@ -83,12 +83,12 @@ FILE fqName: fileName:/samConversionToGeneric.kt BLOCK_BODY CALL 'public open fun bar (j: .J.H.bar?>?): kotlin.Unit declared in .H' type=kotlin.Unit origin=null : kotlin.String? - j: TYPE_OP type=.J.H.bar?>? origin=SAM_CONVERSION typeOperand=.J.H.bar?>? + j: TYPE_OP type=.J? origin=SAM_CONVERSION typeOperand=.J? GET_VAR 'efn: @[ExtensionFunctionType] kotlin.Function1 declared in .test9' type=@[ExtensionFunctionType] kotlin.Function1 origin=null FUN name:test10 visibility:public modality:FINAL <> (fn:kotlin.Function1) returnType:kotlin.Unit VALUE_PARAMETER name:fn index:0 type:kotlin.Function1 BLOCK_BODY CALL 'public open fun bar2x (j2x: .J2X.H.bar2x?>?): kotlin.Unit declared in .H' type=kotlin.Unit origin=null : kotlin.Int? - j2x: TYPE_OP type=.J2X.H.bar2x?>? origin=SAM_CONVERSION typeOperand=.J2X.H.bar2x?>? + j2x: TYPE_OP type=.J2X? origin=SAM_CONVERSION typeOperand=.J2X? GET_VAR 'fn: kotlin.Function1 declared in .test10' type=kotlin.Function1 origin=null diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt index 8a6af5e2cfa..af0fe975b4a 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.kt.txt @@ -48,7 +48,7 @@ fun test7(a: Function1) { } fun test8(a: Function0) { - J().run1(r = id?>(x = a) /*-> Runnable? */) + J().run1(r = id?>(x = a /*-> Function0? */) /*-> Runnable? */) } fun test9() { diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt index 720cf65c0da..78d04844292 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt @@ -104,7 +104,8 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? CALL 'public open fun id (x: T of .J.id?): T of .J.id? declared in .J' type=kotlin.Function0? origin=null : kotlin.Function0? - x: GET_VAR 'a: kotlin.Function0 declared in .test8' type=kotlin.Function0 origin=null + x: TYPE_OP type=kotlin.Function0? origin=SAM_CONVERSION typeOperand=kotlin.Function0? + GET_VAR 'a: kotlin.Function0 declared in .test8' type=kotlin.Function0 origin=null FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null From 4bc630d82cb1d94527ebc22296562b57724320d2 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 10 Feb 2021 18:59:50 +0300 Subject: [PATCH 007/368] FIR2IR: enhance approximation of captured types --- .../org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt | 6 +++++- .../expressions/sam/genericSamProjectedOut.fir.kt.txt | 6 +++--- .../irText/expressions/sam/genericSamProjectedOut.fir.txt | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt index 272b346a8cd..1830877d9dc 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt @@ -120,7 +120,11 @@ class Fir2IrTypeConverter( if (cached == null) { val irType = lowerType?.toIrType(typeContext) ?: run { capturedTypeCache[this] = errorTypeForCapturedTypeStub - constructor.supertypes!!.first().toIrType(typeContext) + val supertypes = constructor.supertypes!! + val approximation = supertypes.find { + it == (constructor.projection as? ConeKotlinTypeProjection)?.type + } ?: supertypes.first() + approximation.toIrType(typeContext) } capturedTypeCache[this] = irType irType diff --git a/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.kt.txt index dbc03ed47f0..1fc96f0fbe5 100644 --- a/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.kt.txt @@ -2,13 +2,13 @@ fun test(a: SomeJavaClass) { a.someFunction(hello = local fun (it: String?) { return Unit } - /*-> Hello? */) + /*-> Hello? */) a.plus(hello = local fun (it: String?) { return Unit } - /*-> Hello? */) + /*-> Hello? */) a.get(hello = local fun (it: String?) { return Unit } - /*-> Hello? */) + /*-> Hello? */) } diff --git a/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt b/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt index b5176c83c8f..9f430d1e493 100644 --- a/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.fir.txt @@ -4,7 +4,7 @@ FILE fqName: fileName:/genericSamProjectedOut.kt BLOCK_BODY CALL 'public open fun someFunction (hello: example.Hello?): kotlin.Unit declared in example.SomeJavaClass' type=kotlin.Unit origin=null $this: GET_VAR 'a: example.SomeJavaClass declared in .test' type=example.SomeJavaClass origin=null - hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? + hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? FUN_EXPR type=kotlin.Function1 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.String?) returnType:kotlin.Unit VALUE_PARAMETER name:it index:0 type:kotlin.String? @@ -13,7 +13,7 @@ FILE fqName: fileName:/genericSamProjectedOut.kt GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit CALL 'public open fun plus (hello: example.Hello?): kotlin.Unit [operator] declared in example.SomeJavaClass' type=kotlin.Unit origin=PLUS $this: GET_VAR 'a: example.SomeJavaClass declared in .test' type=example.SomeJavaClass origin=null - hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? + hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? FUN_EXPR type=kotlin.Function1 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.String?) returnType:kotlin.Unit VALUE_PARAMETER name:it index:0 type:kotlin.String? @@ -22,7 +22,7 @@ FILE fqName: fileName:/genericSamProjectedOut.kt GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit CALL 'public open fun get (hello: example.Hello?): kotlin.Unit [operator] declared in example.SomeJavaClass' type=kotlin.Unit origin=null $this: GET_VAR 'a: example.SomeJavaClass declared in .test' type=example.SomeJavaClass origin=null - hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? + hello: TYPE_OP type=example.Hello? origin=SAM_CONVERSION typeOperand=example.Hello? FUN_EXPR type=kotlin.Function1 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.String?) returnType:kotlin.Unit VALUE_PARAMETER name:it index:0 type:kotlin.String? From 791f5891274f70fc9bb21dc0ba1101540502dcd6 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 11 Feb 2021 08:40:32 +0300 Subject: [PATCH 008/368] SymbolTable: Rewrite nasty code with if without else in elvis RHS --- .../src/org/jetbrains/kotlin/ir/util/SymbolTable.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt index f7186dd703c..83582141539 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt @@ -192,9 +192,10 @@ class SymbolTable( @OptIn(ObsoleteDescriptorBasedAPI::class) override fun set(s: S) { - s.signature?.let { - idSigToSymbol[it] = s - } ?: if (s.hasDescriptor) { + val signature = s.signature + if (signature != null) { + idSigToSymbol[signature] = s + } else if (s.hasDescriptor) { descriptorToSymbol[s.descriptor] = s } } From 5f3102bf2fa2bc9e79b91c8a4463d1012881a367 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 11 Feb 2021 09:41:53 +0300 Subject: [PATCH 009/368] FIR2IR: expand type before getting nullability #KT-44803 Fixed --- .../kotlin/fir/backend/Fir2IrTypeConverter.kt | 5 ++-- .../FirBlackBoxCodegenTestGenerated.java | 6 +++++ .../testData/codegen/box/fir/ClassBuilder.kt | 26 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 +++++ .../IrBlackBoxCodegenTestGenerated.java | 6 +++++ .../LightAnalysisModeTestGenerated.java | 5 ++++ 6 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/codegen/box/fir/ClassBuilder.kt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt index 1830877d9dc..992756eef13 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt @@ -105,9 +105,10 @@ class Fir2IrTypeConverter( if (annotations.any { it.classId == attributeAnnotation.classId }) continue typeAnnotations += callGenerator.convertToIrConstructorCall(attributeAnnotation) as? IrConstructorCall ?: continue } + val expandedType = fullyExpandedType(session) IrSimpleTypeImpl( - irSymbol, !typeContext.definitelyNotNull && this.isMarkedNullable, - fullyExpandedType(session).typeArguments.map { it.toIrTypeArgument(typeContext) }, + irSymbol, !typeContext.definitelyNotNull && expandedType.isMarkedNullable, + expandedType.typeArguments.map { it.toIrTypeArgument(typeContext) }, typeAnnotations ) } diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 5717b5cacbb..b4bf69ddaf2 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -14846,6 +14846,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("ClassBuilder.kt") + public void testClassBuilder() throws Exception { + runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt"); + } + @Test @TestMetadata("ConstValAccess.kt") public void testConstValAccess() throws Exception { diff --git a/compiler/testData/codegen/box/fir/ClassBuilder.kt b/compiler/testData/codegen/box/fir/ClassBuilder.kt new file mode 100644 index 00000000000..04201081d9a --- /dev/null +++ b/compiler/testData/codegen/box/fir/ClassBuilder.kt @@ -0,0 +1,26 @@ +// TARGET_BACKEND: JVM + +// FILE: ClassBuilder.java + +import org.jetbrains.annotations.Nullable; + +public interface ClassBuilder { + void newMethod(@Nullable String[] exceptions); +} + +// FILE: test.kt + +typealias JvmMethodExceptionTypes = Array? + +class TestClassBuilder : ClassBuilder { + override fun newMethod(exceptions: JvmMethodExceptionTypes) { + + } +} + +fun box(): String { + val arr = arrayOf("OK") + TestClassBuilder().newMethod(null) + TestClassBuilder().newMethod(arr) + return arr[0] +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 6b2921c3420..e22a1d45533 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -14846,6 +14846,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("ClassBuilder.kt") + public void testClassBuilder() throws Exception { + runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt"); + } + @Test @TestMetadata("ConstValAccess.kt") public void testConstValAccess() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index c7dd2e03258..670868564e0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -14846,6 +14846,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("ClassBuilder.kt") + public void testClassBuilder() throws Exception { + runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt"); + } + @Test @TestMetadata("ConstValAccess.kt") public void testConstValAccess() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 6de3b5de938..6c8a248169c 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -12278,6 +12278,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @TestMetadata("ClassBuilder.kt") + public void testClassBuilder() throws Exception { + runTest("compiler/testData/codegen/box/fir/ClassBuilder.kt"); + } + @TestMetadata("ConstValAccess.kt") public void testConstValAccess() throws Exception { runTest("compiler/testData/codegen/box/fir/ConstValAccess.kt"); From cd483ad2318176b331810366f769d4082b5c9230 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 11 Feb 2021 10:38:28 +0300 Subject: [PATCH 010/368] FIR2IR: fix raw SAM conversion (avoid * in type arguments) --- .../generators/CallAndReferenceGenerator.kt | 5 +- .../FirBlackBoxCodegenTestGenerated.java | 6 ++ .../box/fir/KotlinDocumentationProvider.kt | 61 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++ .../LightAnalysisModeTestGenerated.java | 5 ++ 6 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index 9b778371d07..77205c24102 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -626,7 +626,10 @@ class CallAndReferenceGenerator( if (!needSamConversion(argument, parameter)) { return this } - val samFirType = parameter.returnTypeRef.coneTypeSafe()?.let { substitutor.substituteOrSelf(it) } + val samFirType = parameter.returnTypeRef.coneTypeSafe()?.let { + val substituted = substitutor.substituteOrSelf(it) + if (substituted is ConeRawType) substituted.lowerBound else substituted + } var samType = samFirType?.toIrType(ConversionTypeContext.WITH_INVARIANT) ?: createErrorType() if (shouldUnwrapVarargType) { samType = samType.getArrayElementType(irBuiltIns) diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index b4bf69ddaf2..1da51faae4f 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -14882,6 +14882,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/fir/IrBuiltIns.kt"); } + @Test + @TestMetadata("KotlinDocumentationProvider.kt") + public void testKotlinDocumentationProvider() throws Exception { + runTest("compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt"); + } + @Test @TestMetadata("LookupTags.kt") public void testLookupTags() throws Exception { diff --git a/compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt b/compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt new file mode 100644 index 00000000000..eb84f4a9dae --- /dev/null +++ b/compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt @@ -0,0 +1,61 @@ +// TARGET_BACKEND: JVM +// FULL_JDK + +// MODULE: lib +// FILE: PsiElement.java + +public interface PsiElement { + +} + +// FILE: PsiElementProcessor.java + +import org.jetbrains.annotations.NotNull; + +public interface PsiElementProcessor { + boolean execute (@NotNull T element); +} + +// FILE: PsiTreeUtil.java + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class PsiTreeUtil { + public static boolean processElements(@Nullable PsiElement element, @NotNull PsiElementProcessor processor) { + return element != null; + } +} + +// MODULE: main(lib) +// FILE: KotlinDocumentationProvider.kt + +import java.util.function.Consumer + +interface PsiFile : PsiElement { + val name: String +} + +class KtFile(override val name: String) : PsiFile { + val docComment: PsiDocCommentBase get() = PsiDocCommentBase() +} + +class PsiDocCommentBase : PsiElement + +fun collectDocComments(file: PsiFile, sink: Consumer): String { + if (file !is KtFile) return "FAIL" + + PsiTreeUtil.processElements(file) { + val comment = (it as? KtFile)?.docComment + if (comment != null) sink.accept(comment) + true + } + + return file.name +} + +fun box(): String { + return collectDocComments(KtFile("OK")) { + + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index e22a1d45533..422a0c5d6cb 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -14882,6 +14882,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/fir/IrBuiltIns.kt"); } + @Test + @TestMetadata("KotlinDocumentationProvider.kt") + public void testKotlinDocumentationProvider() throws Exception { + runTest("compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt"); + } + @Test @TestMetadata("LookupTags.kt") public void testLookupTags() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 670868564e0..87555c2b540 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -14882,6 +14882,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/fir/IrBuiltIns.kt"); } + @Test + @TestMetadata("KotlinDocumentationProvider.kt") + public void testKotlinDocumentationProvider() throws Exception { + runTest("compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt"); + } + @Test @TestMetadata("LookupTags.kt") public void testLookupTags() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 6c8a248169c..8c224ed249f 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -12308,6 +12308,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/fir/IrBuiltIns.kt"); } + @TestMetadata("KotlinDocumentationProvider.kt") + public void testKotlinDocumentationProvider() throws Exception { + runTest("compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt"); + } + @TestMetadata("LookupTags.kt") public void testLookupTags() throws Exception { runTest("compiler/testData/codegen/box/fir/LookupTags.kt"); From 57e06992c9198308534ed706376966d591c4abd7 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 11 Feb 2021 12:59:23 +0300 Subject: [PATCH 011/368] Skip JDK 6 in failing BB test (java.util.function in use) --- compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt b/compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt index eb84f4a9dae..b88796b9a8b 100644 --- a/compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt +++ b/compiler/testData/codegen/box/fir/KotlinDocumentationProvider.kt @@ -1,3 +1,4 @@ +// SKIP_JDK6 // TARGET_BACKEND: JVM // FULL_JDK From 796222480451f823b1f4522546596d9908a8e6b7 Mon Sep 17 00:00:00 2001 From: Mark Punzalan Date: Wed, 10 Feb 2021 08:28:42 +0000 Subject: [PATCH 012/368] FIR IDE: Add quickfix for VAR_OVERRIDDEN_BY_VAL. --- .../kotlin/generators/tests/GenerateTests.kt | 1 + .../idea/quickfix/MainKtQuickFixRegistrar.kt | 5 ++ .../HighLevelQuickFixTestGenerated.java | 73 +++++++++++++++++++ .../quickfix/ChangeVariableMutabilityFix.kt | 14 ++-- .../changeMutability/funParameter.kt | 3 +- .../changeMutability/valOverrideVar.kt | 3 +- .../changeMutability/valOverrideVar.kt.after | 3 +- .../valOverrideVarConstructorParameter.kt | 3 +- ...alOverrideVarConstructorParameter.kt.after | 3 +- 9 files changed, 96 insertions(+), 12 deletions(-) diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index a6c56fe8408..a258ba4f77e 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -1105,6 +1105,7 @@ fun main(args: Array) { val pattern = "^([\\w\\-_]+)\\.kt$" model("quickfix/modifiers", pattern = pattern, filenameStartsLowerCase = true, recursive = false) model("quickfix/override/typeMismatchOnOverride", pattern = pattern, filenameStartsLowerCase = true, recursive = false) + model("quickfix/variables/changeMutability", pattern = pattern, filenameStartsLowerCase = true, recursive = false) } testClass { diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt index 43a79ab96c5..b8ee27b79ff 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt @@ -10,12 +10,14 @@ import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixRegistrar import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesList import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesListBuilder import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic +import org.jetbrains.kotlin.idea.quickfix.ChangeVariableMutabilityFix.Companion.VAR_OVERRIDDEN_BY_VAL_FACTORY import org.jetbrains.kotlin.idea.quickfix.fixes.ChangeTypeQuickFix import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtModifierListOwner class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { private val modifiers = KtQuickFixesListBuilder.registerPsiQuickFix { + // RemoveModifierFix registerPsiQuickFix(RemoveModifierFix.createRemoveModifierFactory(isRedundant = true)) registerPsiQuickFix(RemoveModifierFix.createRemoveModifierFactory(isRedundant = false)) registerPsiQuickFix(RemoveModifierFix.createRemoveModifierFactory(isRedundant = false)) @@ -27,6 +29,9 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { isRedundant = true ) ) + + // ChangeVariableMutabilityFix + registerPsiQuickFix(VAR_OVERRIDDEN_BY_VAL_FACTORY) } private val overrides = KtQuickFixesListBuilder.registerPsiQuickFix { diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java index 7a8e975175d..8422bcc0ff0 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java @@ -449,4 +449,77 @@ public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTes runTest("idea/testData/quickfix/override/typeMismatchOnOverride/returnTypeMismatchOnOverrideUnitInt.kt"); } } + + @TestMetadata("idea/testData/quickfix/variables/changeMutability") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ChangeMutability extends AbstractHighLevelQuickFixTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInChangeMutability() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/variables/changeMutability"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, false); + } + + @TestMetadata("capturedMemberValInitialization.kt") + public void testCapturedMemberValInitialization() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/capturedMemberValInitialization.kt"); + } + + @TestMetadata("capturedValInitialization.kt") + public void testCapturedValInitialization() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/capturedValInitialization.kt"); + } + + @TestMetadata("const.kt") + public void testConst() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/const.kt"); + } + + @TestMetadata("funParameter.kt") + public void testFunParameter() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/funParameter.kt"); + } + + @TestMetadata("localInGetter.kt") + public void testLocalInGetter() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/localInGetter.kt"); + } + + @TestMetadata("valOverrideVar.kt") + public void testValOverrideVar() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/valOverrideVar.kt"); + } + + @TestMetadata("valOverrideVarConstructorParameter.kt") + public void testValOverrideVarConstructorParameter() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/valOverrideVarConstructorParameter.kt"); + } + + @TestMetadata("valReassignmentLocal.kt") + public void testValReassignmentLocal() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/valReassignmentLocal.kt"); + } + + @TestMetadata("valReassignmentOuterDecl.kt") + public void testValReassignmentOuterDecl() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/valReassignmentOuterDecl.kt"); + } + + @TestMetadata("valReassignmentProperty.kt") + public void testValReassignmentProperty() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/valReassignmentProperty.kt"); + } + + @TestMetadata("valReassignmentPropertyConstructorParameter.kt") + public void testValReassignmentPropertyConstructorParameter() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/valReassignmentPropertyConstructorParameter.kt"); + } + + @TestMetadata("valWithSetter.kt") + public void testValWithSetter() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/valWithSetter.kt"); + } + } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt index fa1122c375d..44e3c7189b8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt @@ -19,12 +19,14 @@ package org.jetbrains.kotlin.idea.quickfix import com.intellij.codeInsight.intention.IntentionAction import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project +import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1 import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.CreatePropertyDelegateAccessorsActionFactory +import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType @@ -86,15 +88,13 @@ class ChangeVariableMutabilityFix( val CAPTURED_MEMBER_VAL_INITIALIZATION_FACTORY = ReassignmentActionFactory(Errors.CAPTURED_MEMBER_VAL_INITIALIZATION) - val VAR_OVERRIDDEN_BY_VAL_FACTORY: KotlinSingleIntentionActionFactory = object : KotlinSingleIntentionActionFactory() { - override fun createAction(diagnostic: Diagnostic): IntentionAction? { - val element = diagnostic.psiElement - return when (element) { - is KtProperty, is KtParameter -> ChangeVariableMutabilityFix(element as KtValVarKeywordOwner, true) - else -> null + val VAR_OVERRIDDEN_BY_VAL_FACTORY: QuickFixesPsiBasedFactory = + quickFixesPsiBasedFactory { psiElement: PsiElement -> + when (psiElement) { + is KtProperty, is KtParameter -> listOf(ChangeVariableMutabilityFix(psiElement as KtValVarKeywordOwner, true)) + else -> emptyList() } } - } val VAR_ANNOTATION_PARAMETER_FACTORY: KotlinSingleIntentionActionFactory = object : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): IntentionAction? { diff --git a/idea/testData/quickfix/variables/changeMutability/funParameter.kt b/idea/testData/quickfix/variables/changeMutability/funParameter.kt index a7304a11bed..23c0fa721c8 100644 --- a/idea/testData/quickfix/variables/changeMutability/funParameter.kt +++ b/idea/testData/quickfix/variables/changeMutability/funParameter.kt @@ -4,4 +4,5 @@ // ERROR: Val cannot be reassigned fun fun1(i: Int) { i = 2 -} \ No newline at end of file +} +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/variables/changeMutability/valOverrideVar.kt b/idea/testData/quickfix/variables/changeMutability/valOverrideVar.kt index a701f9af290..8d3806e7274 100644 --- a/idea/testData/quickfix/variables/changeMutability/valOverrideVar.kt +++ b/idea/testData/quickfix/variables/changeMutability/valOverrideVar.kt @@ -5,4 +5,5 @@ open class A { class B : A() { override val x: Int = 3; -} \ No newline at end of file +} +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/variables/changeMutability/valOverrideVar.kt.after b/idea/testData/quickfix/variables/changeMutability/valOverrideVar.kt.after index 59e2623f0a2..59f7eee5de8 100644 --- a/idea/testData/quickfix/variables/changeMutability/valOverrideVar.kt.after +++ b/idea/testData/quickfix/variables/changeMutability/valOverrideVar.kt.after @@ -5,4 +5,5 @@ open class A { class B : A() { override var x: Int = 3; -} \ No newline at end of file +} +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/variables/changeMutability/valOverrideVarConstructorParameter.kt b/idea/testData/quickfix/variables/changeMutability/valOverrideVarConstructorParameter.kt index 9fb43f04655..5385bf67d29 100644 --- a/idea/testData/quickfix/variables/changeMutability/valOverrideVarConstructorParameter.kt +++ b/idea/testData/quickfix/variables/changeMutability/valOverrideVarConstructorParameter.kt @@ -3,4 +3,5 @@ open class A { open var x = 42; } -class B(override val x: Int) : A() \ No newline at end of file +class B(override val x: Int) : A() +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/variables/changeMutability/valOverrideVarConstructorParameter.kt.after b/idea/testData/quickfix/variables/changeMutability/valOverrideVarConstructorParameter.kt.after index 177bbb302e0..0ab7e9d6500 100644 --- a/idea/testData/quickfix/variables/changeMutability/valOverrideVarConstructorParameter.kt.after +++ b/idea/testData/quickfix/variables/changeMutability/valOverrideVarConstructorParameter.kt.after @@ -3,4 +3,5 @@ open class A { open var x = 42; } -class B(override var x: Int) : A() \ No newline at end of file +class B(override var x: Int) : A() +/* FIR_COMPARISON */ \ No newline at end of file From a9f19c4a45439c012aebaee714dbdc53b0097d19 Mon Sep 17 00:00:00 2001 From: Mark Punzalan Date: Thu, 11 Feb 2021 06:31:10 +0000 Subject: [PATCH 013/368] FIR IDE: Move ChangeVariableMutabilityFix to idea-frontend-independent. --- .../KotlinBundleIndependent.properties | 6 +- .../quickfix/ChangeVariableMutabilityFix.kt | 86 +++++++++++ .../quickfix/KotlinPsiOnlyQuickFixAction.kt | 33 ++++ .../messages/KotlinBundle.properties | 3 - .../quickfix/ChangeVariableMutabilityFix.kt | 142 ++++-------------- .../kotlin/idea/quickfix/QuickFixRegistrar.kt | 10 +- 6 files changed, 158 insertions(+), 122 deletions(-) create mode 100644 idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt create mode 100644 idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/KotlinPsiOnlyQuickFixAction.kt diff --git a/idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties b/idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties index 7d2460d460b..4e223ee9b58 100644 --- a/idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties +++ b/idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties @@ -61,4 +61,8 @@ find.usages.type.super.type.qualifier=Super type qualifier find.usages.type.receiver=Receiver find.usages.type.delegate=Delegate find.usages.type.packageDirective=Package directive -find.usages.type.packageMemberAccess=Package member access \ No newline at end of file +find.usages.type.packageMemberAccess=Package member access + +and.delete.initializer=\ and delete initializer +change.to.val=Change to val +change.to.var=Change to var \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt new file mode 100644 index 00000000000..c03c529824a --- /dev/null +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt @@ -0,0 +1,86 @@ +/* + * Copyright 2010-2021 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.idea.quickfix + +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.idea.KotlinBundleIndependent +import org.jetbrains.kotlin.lexer.KtTokens +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType + +class ChangeVariableMutabilityFix( + element: KtValVarKeywordOwner, + private val makeVar: Boolean, + private val actionText: String? = null, + private val deleteInitializer: Boolean = false +) : KotlinPsiOnlyQuickFixAction(element) { + + override fun getText() = actionText + ?: (if (makeVar) KotlinBundleIndependent.message("change.to.var") else KotlinBundleIndependent.message("change.to.val")) + + if (deleteInitializer) KotlinBundleIndependent.message("and.delete.initializer") else "" + + override fun getFamilyName(): String = text + + override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean { + val element = element ?: return false + val valOrVar = element.valOrVarKeyword?.node?.elementType ?: return false + return (valOrVar == KtTokens.VAR_KEYWORD) != makeVar + } + + override fun invoke(project: Project, editor: Editor?, file: KtFile) { + val element = element ?: return + val factory = KtPsiFactory(project) + val newKeyword = if (makeVar) factory.createVarKeyword() else factory.createValKeyword() + element.valOrVarKeyword!!.replace(newKeyword) + if (deleteInitializer) { + (element as? KtProperty)?.initializer = null + } + if (makeVar) { + (element as? KtModifierListOwner)?.removeModifier(KtTokens.CONST_KEYWORD) + } + } + + companion object { + val VAL_WITH_SETTER_FACTORY: QuickFixesPsiBasedFactory = + quickFixesPsiBasedFactory { psiElement: KtPropertyAccessor -> + listOf(ChangeVariableMutabilityFix(psiElement.property, true)) + } + + val VAR_OVERRIDDEN_BY_VAL_FACTORY: QuickFixesPsiBasedFactory = + quickFixesPsiBasedFactory { psiElement: PsiElement -> + when (psiElement) { + is KtProperty, is KtParameter -> listOf(ChangeVariableMutabilityFix(psiElement as KtValVarKeywordOwner, true)) + else -> emptyList() + } + } + + val VAR_ANNOTATION_PARAMETER_FACTORY: QuickFixesPsiBasedFactory = + quickFixesPsiBasedFactory { psiElement: KtParameter -> + listOf(ChangeVariableMutabilityFix(psiElement, false)) + } + + val LATEINIT_VAL_FACTORY: QuickFixesPsiBasedFactory = + quickFixesPsiBasedFactory { psiElement: PsiElement -> + val property = psiElement.getStrictParentOfType() ?: return@quickFixesPsiBasedFactory emptyList() + if (property.valOrVarKeyword.text != "val") { + emptyList() + } else { + listOf(ChangeVariableMutabilityFix(property, makeVar = true)) + } + } + + val MUST_BE_INITIALIZED_FACTORY: QuickFixesPsiBasedFactory = + quickFixesPsiBasedFactory { psiElement: PsiElement -> + val property = psiElement as? KtProperty ?: return@quickFixesPsiBasedFactory emptyList() + val getter = property.getter ?: return@quickFixesPsiBasedFactory emptyList() + if (!getter.hasBody()) return@quickFixesPsiBasedFactory emptyList() + if (getter.hasBlockBody() && property.typeReference == null) return@quickFixesPsiBasedFactory emptyList() + listOf(ChangeVariableMutabilityFix(property, makeVar = false)) + } + } +} \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/KotlinPsiOnlyQuickFixAction.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/KotlinPsiOnlyQuickFixAction.kt new file mode 100644 index 00000000000..15538d25929 --- /dev/null +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/KotlinPsiOnlyQuickFixAction.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2019 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.idea.quickfix + +import com.intellij.codeInsight.FileModificationService +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile +import org.jetbrains.kotlin.psi.KtFile + +abstract class KotlinPsiOnlyQuickFixAction(element: T) : QuickFixActionBase(element) { + protected open fun isAvailable(project: Project, editor: Editor?, file: KtFile) = true + + override fun isAvailableImpl(project: Project, editor: Editor?, file: PsiFile): Boolean { + val ktFile = file as? KtFile ?: return false + return isAvailable(project, editor, ktFile) + } + + final override fun invoke(project: Project, editor: Editor?, file: PsiFile) { + val element = element ?: return + if (file is KtFile && FileModificationService.getInstance().prepareFileForWrite(element.containingFile)) { + invoke(project, editor, file) + } + } + + protected abstract operator fun invoke(project: Project, editor: Editor?, file: KtFile) + + override fun startInWriteAction() = true +} diff --git a/idea/resources-en/messages/KotlinBundle.properties b/idea/resources-en/messages/KotlinBundle.properties index 533ae28b198..1228cc0f613 100644 --- a/idea/resources-en/messages/KotlinBundle.properties +++ b/idea/resources-en/messages/KotlinBundle.properties @@ -1040,9 +1040,6 @@ replace.with.publishedapi.bridge.call=Replace with @PublishedApi bridge call replace.with.generated.publishedapi.bridge.call.0=Replace with generated @PublishedApi bridge call ''{0}'' convert.sealed.sub.class.to.object.fix.family.name=Convert sealed sub-class to object generate.identity.equals.fix.family.name=Generate equals \\& hashCode by identity -and.delete.initializer=\ and delete initializer -change.to.val=Change to val -change.to.var=Change to var change.type.of.0.to.1=Change type of {0} to ''{1}'' change.type.to.0=Change type to ''{0}'' base.property.0=base property {0} diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt index 44e3c7189b8..546c39a2a5f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt @@ -17,128 +17,44 @@ package org.jetbrains.kotlin.idea.quickfix import com.intellij.codeInsight.intention.IntentionAction -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.project.Project -import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1 import org.jetbrains.kotlin.diagnostics.Errors -import org.jetbrains.kotlin.idea.KotlinBundle +import org.jetbrains.kotlin.idea.KotlinBundleIndependent import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.CreatePropertyDelegateAccessorsActionFactory -import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.KtProperty +import org.jetbrains.kotlin.psi.KtValVarKeywordOwner import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.util.OperatorNameConventions -class ChangeVariableMutabilityFix( - element: KtValVarKeywordOwner, - private val makeVar: Boolean, - private val actionText: String? = null, - private val deleteInitializer: Boolean = false -) : KotlinQuickFixAction(element) { - - override fun getText() = actionText - ?: (if (makeVar) KotlinBundle.message("change.to.var") else KotlinBundle.message("change.to.val")) + - if (deleteInitializer) KotlinBundle.message("and.delete.initializer") else "" - - override fun getFamilyName(): String = text - - override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean { - val element = element ?: return false - val valOrVar = element.valOrVarKeyword?.node?.elementType ?: return false - return (valOrVar == KtTokens.VAR_KEYWORD) != makeVar - } - - override fun invoke(project: Project, editor: Editor?, file: KtFile) { - val element = element ?: return - val factory = KtPsiFactory(project) - val newKeyword = if (makeVar) factory.createVarKeyword() else factory.createValKeyword() - element.valOrVarKeyword!!.replace(newKeyword) - if (deleteInitializer) { - (element as? KtProperty)?.initializer = null - } - if (makeVar) { - (element as? KtModifierListOwner)?.removeModifier(KtTokens.CONST_KEYWORD) - } - } - - companion object { - val VAL_WITH_SETTER_FACTORY: KotlinSingleIntentionActionFactory = object : KotlinSingleIntentionActionFactory() { - override fun createAction(diagnostic: Diagnostic): IntentionAction? { - val accessor = diagnostic.psiElement as KtPropertyAccessor - return ChangeVariableMutabilityFix(accessor.property, true) - } - } - - class ReassignmentActionFactory(val factory: DiagnosticFactory1<*, DeclarationDescriptor>) : KotlinSingleIntentionActionFactory() { - override fun createAction(diagnostic: Diagnostic): IntentionAction? { - val propertyDescriptor = factory.cast(diagnostic).a - val declaration = - DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor) as? KtValVarKeywordOwner ?: return null - return ChangeVariableMutabilityFix(declaration, true) - } - } - - val VAL_REASSIGNMENT_FACTORY = ReassignmentActionFactory(Errors.VAL_REASSIGNMENT) - - val CAPTURED_VAL_INITIALIZATION_FACTORY = ReassignmentActionFactory(Errors.CAPTURED_VAL_INITIALIZATION) - - val CAPTURED_MEMBER_VAL_INITIALIZATION_FACTORY = ReassignmentActionFactory(Errors.CAPTURED_MEMBER_VAL_INITIALIZATION) - - val VAR_OVERRIDDEN_BY_VAL_FACTORY: QuickFixesPsiBasedFactory = - quickFixesPsiBasedFactory { psiElement: PsiElement -> - when (psiElement) { - is KtProperty, is KtParameter -> listOf(ChangeVariableMutabilityFix(psiElement as KtValVarKeywordOwner, true)) - else -> emptyList() - } - } - - val VAR_ANNOTATION_PARAMETER_FACTORY: KotlinSingleIntentionActionFactory = object : KotlinSingleIntentionActionFactory() { - override fun createAction(diagnostic: Diagnostic): IntentionAction? { - val element = diagnostic.psiElement as KtParameter - return ChangeVariableMutabilityFix(element, false) - } - } - - val LATEINIT_VAL_FACTORY = object : KotlinSingleIntentionActionFactory() { - override fun createAction(diagnostic: Diagnostic): IntentionAction? { - val lateinitElement = Errors.INAPPLICABLE_LATEINIT_MODIFIER.cast(diagnostic).psiElement - val property = lateinitElement.getStrictParentOfType() ?: return null - if (property.valOrVarKeyword.text != "val") return null - return ChangeVariableMutabilityFix(property, makeVar = true) - } - } - - val CONST_VAL_FACTORY = object : KotlinSingleIntentionActionFactory() { - override fun createAction(diagnostic: Diagnostic): IntentionAction? { - val (modifier, element) = Errors.WRONG_MODIFIER_TARGET.cast(diagnostic).run { a to psiElement } - if (modifier != KtTokens.CONST_KEYWORD) return null - val property = element.getStrictParentOfType() ?: return null - return ChangeVariableMutabilityFix(property, makeVar = false) - } - } - - val DELEGATED_PROPERTY_VAL_FACTORY = object : KotlinSingleIntentionActionFactory() { - override fun createAction(diagnostic: Diagnostic): IntentionAction? { - val element = Errors.DELEGATE_SPECIAL_FUNCTION_MISSING.cast(diagnostic).psiElement - val property = element.getStrictParentOfType() ?: return null - val info = CreatePropertyDelegateAccessorsActionFactory.extractFixData(property, diagnostic).singleOrNull() ?: return null - if (info.name != OperatorNameConventions.SET_VALUE.asString()) return null - return ChangeVariableMutabilityFix(property, makeVar = false, actionText = KotlinBundle.message("change.to.val")) - } - } - - val MUST_BE_INITIALIZED_FACTORY = object : KotlinSingleIntentionActionFactory() { - override fun createAction(diagnostic: Diagnostic): IntentionAction? { - val property = Errors.MUST_BE_INITIALIZED.cast(diagnostic).psiElement as? KtProperty ?: return null - val getter = property.getter ?: return null - if (!getter.hasBody()) return null - if (getter.hasBlockBody() && property.typeReference == null) return null - return ChangeVariableMutabilityFix(property, makeVar = false) - } - } +class ReassignmentActionFactory(val factory: DiagnosticFactory1<*, DeclarationDescriptor>) : KotlinSingleIntentionActionFactory() { + override fun createAction(diagnostic: Diagnostic): IntentionAction? { + val propertyDescriptor = factory.cast(diagnostic).a + val declaration = + DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor) as? KtValVarKeywordOwner ?: return null + return ChangeVariableMutabilityFix(declaration, true) } } + +// TODO: Move this to idea-fir-independent +object ConstValFactory : KotlinSingleIntentionActionFactory() { + override fun createAction(diagnostic: Diagnostic): IntentionAction? { + val (modifier, element) = Errors.WRONG_MODIFIER_TARGET.cast(diagnostic).run { a to psiElement } + if (modifier != KtTokens.CONST_KEYWORD) return null + val property = element.getStrictParentOfType() ?: return null + return ChangeVariableMutabilityFix(property, makeVar = false) + } +} + +object DelegatedPropertyValFactory : KotlinSingleIntentionActionFactory() { + override fun createAction(diagnostic: Diagnostic): IntentionAction? { + val element = Errors.DELEGATE_SPECIAL_FUNCTION_MISSING.cast(diagnostic).psiElement + val property = element.getStrictParentOfType() ?: return null + val info = CreatePropertyDelegateAccessorsActionFactory.extractFixData(property, diagnostic).singleOrNull() ?: return null + if (info.name != OperatorNameConventions.SET_VALUE.asString()) return null + return ChangeVariableMutabilityFix(property, makeVar = false, actionText = KotlinBundleIndependent.message("change.to.val")) + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index 184884ceaa7..bb41288f250 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -142,7 +142,7 @@ class QuickFixRegistrar : QuickFixContributor { removeModifierFactory ) REDUNDANT_MODIFIER_IN_GETTER.registerFactory(removeRedundantModifierFactory) - WRONG_MODIFIER_TARGET.registerFactory(removeModifierFactory, ChangeVariableMutabilityFix.CONST_VAL_FACTORY) + WRONG_MODIFIER_TARGET.registerFactory(removeModifierFactory, ConstValFactory) DEPRECATED_MODIFIER.registerFactory(ReplaceModifierFix) REDUNDANT_MODIFIER_FOR_TARGET.registerFactory(removeModifierFactory) WRONG_MODIFIER_CONTAINING_DECLARATION.registerFactory(removeModifierFactory) @@ -222,10 +222,10 @@ class QuickFixRegistrar : QuickFixContributor { VAL_WITH_SETTER.registerFactory(ChangeVariableMutabilityFix.VAL_WITH_SETTER_FACTORY) VAL_REASSIGNMENT.registerFactory( - ChangeVariableMutabilityFix.VAL_REASSIGNMENT_FACTORY, LiftAssignmentOutOfTryFix, AssignToPropertyFix + ReassignmentActionFactory(VAL_REASSIGNMENT), LiftAssignmentOutOfTryFix, AssignToPropertyFix ) - CAPTURED_VAL_INITIALIZATION.registerFactory(ChangeVariableMutabilityFix.CAPTURED_VAL_INITIALIZATION_FACTORY) - CAPTURED_MEMBER_VAL_INITIALIZATION.registerFactory(ChangeVariableMutabilityFix.CAPTURED_MEMBER_VAL_INITIALIZATION_FACTORY) + CAPTURED_VAL_INITIALIZATION.registerFactory(ReassignmentActionFactory(CAPTURED_VAL_INITIALIZATION)) + CAPTURED_MEMBER_VAL_INITIALIZATION.registerFactory(ReassignmentActionFactory(CAPTURED_MEMBER_VAL_INITIALIZATION)) VAR_OVERRIDDEN_BY_VAL.registerFactory(ChangeVariableMutabilityFix.VAR_OVERRIDDEN_BY_VAL_FACTORY) VAR_ANNOTATION_PARAMETER.registerFactory(ChangeVariableMutabilityFix.VAR_ANNOTATION_PARAMETER_FACTORY) @@ -418,7 +418,7 @@ class QuickFixRegistrar : QuickFixContributor { CreateDataClassPropertyFromDestructuringActionFactory ) - DELEGATE_SPECIAL_FUNCTION_MISSING.registerFactory(ChangeVariableMutabilityFix.DELEGATED_PROPERTY_VAL_FACTORY) + DELEGATE_SPECIAL_FUNCTION_MISSING.registerFactory(DelegatedPropertyValFactory) DELEGATE_SPECIAL_FUNCTION_MISSING.registerFactory(CreatePropertyDelegateAccessorsActionFactory) DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE.registerFactory(CreatePropertyDelegateAccessorsActionFactory) From c3c8991ab638f40c8601df47c425a9deac34381a Mon Sep 17 00:00:00 2001 From: Mark Punzalan Date: Thu, 11 Feb 2021 07:34:53 +0000 Subject: [PATCH 014/368] FIR IDE: Re-organize MainKtQuickFixRegistrar. --- .../kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt index b8ee27b79ff..34f90742c3b 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt @@ -10,14 +10,12 @@ import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixRegistrar import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesList import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesListBuilder import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic -import org.jetbrains.kotlin.idea.quickfix.ChangeVariableMutabilityFix.Companion.VAR_OVERRIDDEN_BY_VAL_FACTORY import org.jetbrains.kotlin.idea.quickfix.fixes.ChangeTypeQuickFix import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtModifierListOwner class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { private val modifiers = KtQuickFixesListBuilder.registerPsiQuickFix { - // RemoveModifierFix registerPsiQuickFix(RemoveModifierFix.createRemoveModifierFactory(isRedundant = true)) registerPsiQuickFix(RemoveModifierFix.createRemoveModifierFactory(isRedundant = false)) registerPsiQuickFix(RemoveModifierFix.createRemoveModifierFactory(isRedundant = false)) @@ -29,9 +27,6 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { isRedundant = true ) ) - - // ChangeVariableMutabilityFix - registerPsiQuickFix(VAR_OVERRIDDEN_BY_VAL_FACTORY) } private val overrides = KtQuickFixesListBuilder.registerPsiQuickFix { @@ -40,8 +35,13 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { registerApplicator(ChangeTypeQuickFix.changeVariableReturnTypeOnOverride) } + private val mutability = KtQuickFixesListBuilder.registerPsiQuickFix { + registerPsiQuickFix(ChangeVariableMutabilityFix.VAR_OVERRIDDEN_BY_VAL_FACTORY) + } + override val list: KtQuickFixesList = KtQuickFixesList.createCombined( modifiers, overrides, + mutability, ) } \ No newline at end of file From 4b62b2de0c0082de0a15787af506f82c48bae480 Mon Sep 17 00:00:00 2001 From: Yaroslav Chernyshev Date: Thu, 11 Feb 2021 10:58:47 +0300 Subject: [PATCH 015/368] Use IDEA ASM in `kotlin-gradle-plugin-integration-tests` module --- .../kotlin-gradle-plugin-integration-tests/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts index 48ba118ee31..1531f9f1247 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts @@ -45,7 +45,7 @@ dependencies { // Workaround for missing transitive import of the common(project `kotlin-test-common` // for `kotlin-test-jvm` into the IDE: testCompileOnly(project(":kotlin-test:kotlin-test-common")) { isTransitive = false } - testCompileOnly("org.jetbrains.intellij.deps:asm-all:9.0") + testCompileOnly(intellijDep()) { includeJars("asm-all", rootProject = rootProject) } } // Aapt2 from Android Gradle Plugin 3.2 and below does not handle long paths on Windows. From 80daf120e6a4841287efea861ac3ebd095172a7f Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 10 Feb 2021 12:28:41 +0100 Subject: [PATCH 016/368] Apply illegal-access=permit workaround for JDK 16+ Apparently, the openjdk commit that enabled JEP 396 (encapsulated JDK defaults) is effective since jdk-16+28: https://github.com/openjdk/jdk/commit/ed4c4ee7 --- .../org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt index e45d6fb20aa..4ba36cd27fd 100644 --- a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt +++ b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt @@ -376,7 +376,7 @@ object KotlinCompilerClient { "-D$JAVA_RMI_SERVER_HOSTNAME=$serverHostname") val javaVersion = System.getProperty("java.specification.version")?.toIntOrNull() val javaIllegalAccessWorkaround = - if (javaVersion != null && javaVersion >= 17) + if (javaVersion != null && javaVersion >= 16) listOf("--illegal-access=permit") else emptyList() val args = listOf( From f797ee78035f5a301b738dd6416219503554efe4 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Tue, 9 Feb 2021 12:58:53 +0300 Subject: [PATCH 017/368] Substitute captured types with inner intersection one (NewTypeSubstitutor) ^KT-44651 Fixed --- .../codegen/FirBlackBoxCodegenTestGenerated.java | 6 ++++++ .../inference/components/NewTypeSubstitutor.kt | 2 +- .../substituteIntersectionTypeInsideCapType.kt | 15 +++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/LightAnalysisModeTestGenerated.java | 5 +++++ 6 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 1da51faae4f..dc3a6dc19af 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -16666,6 +16666,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt"); } + @Test + @TestMetadata("substituteIntersectionTypeInsideCapType.kt") + public void testSubstituteIntersectionTypeInsideCapType() throws Exception { + runTest("compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt"); + } + @Test @TestMetadata("subtypingOfIntersectionIltInsideFlexible.kt") public void testSubtypingOfIntersectionIltInsideFlexible() throws Exception { diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt index 9a7aed50205..8a795862d30 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt @@ -105,7 +105,7 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker { val substitutedInnerType = substitute(innerType, keepAnnotation, runCapturedChecks = false) if (substitutedInnerType != null) { - if (innerType is StubType || substitutedInnerType is StubType) { + if (innerType is StubType || substitutedInnerType is StubType || innerType.constructor is IntersectionTypeConstructor) { return NewCapturedType( capturedType.captureStatus, NewCapturedTypeConstructor( diff --git a/compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt b/compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt new file mode 100644 index 00000000000..ae86b03e105 --- /dev/null +++ b/compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt @@ -0,0 +1,15 @@ +// TARGET_BACKEND: JVM +// TARGET_BACKEND: JVM_IR + +class X(val y: Any, val x: T) + +fun box(): String { + val num: Long = -10 + val num2: Int = 20 + val obj = if (true) + X(Any(), if (true) num else num2) + else + X(Any(), -25) + val f = obj.y + return "OK" +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 422a0c5d6cb..c82a52bc9ba 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -16666,6 +16666,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt"); } + @Test + @TestMetadata("substituteIntersectionTypeInsideCapType.kt") + public void testSubstituteIntersectionTypeInsideCapType() throws Exception { + runTest("compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt"); + } + @Test @TestMetadata("subtypingOfIntersectionIltInsideFlexible.kt") public void testSubtypingOfIntersectionIltInsideFlexible() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 87555c2b540..21a799582d4 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -16666,6 +16666,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt"); } + @Test + @TestMetadata("substituteIntersectionTypeInsideCapType.kt") + public void testSubstituteIntersectionTypeInsideCapType() throws Exception { + runTest("compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt"); + } + @Test @TestMetadata("subtypingOfIntersectionIltInsideFlexible.kt") public void testSubtypingOfIntersectionIltInsideFlexible() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 8c224ed249f..6150d21095b 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13855,6 +13855,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inference/specialCallsWithCallableReferences.kt"); } + @TestMetadata("substituteIntersectionTypeInsideCapType.kt") + public void testSubstituteIntersectionTypeInsideCapType() throws Exception { + runTest("compiler/testData/codegen/box/inference/substituteIntersectionTypeInsideCapType.kt"); + } + @TestMetadata("subtypingOfIntersectionIltInsideFlexible.kt") public void testSubtypingOfIntersectionIltInsideFlexible() throws Exception { runTest("compiler/testData/codegen/box/inference/subtypingOfIntersectionIltInsideFlexible.kt"); From 401f0ac583e0552f10471529df6969ef6b967a93 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 10 Feb 2021 21:00:35 +0100 Subject: [PATCH 018/368] Use TARGET_BACKEND instead of DONT_TARGET_EXACT_BACKEND in box against Java tests "// TARGET_BACKEND: JVM" more clearly says that the test is JVM-specific, rather than DONT_TARGET_EXACT_BACKEND which excludes all other backends. --- .../testData/codegen/box/annotations/divisionByZeroInJava.kt | 2 +- .../codegen/box/annotations/javaAnnotationArrayValueDefault.kt | 2 +- .../box/annotations/javaAnnotationArrayValueNoDefault.kt | 2 +- compiler/testData/codegen/box/annotations/javaAnnotationCall.kt | 2 +- .../testData/codegen/box/annotations/javaAnnotationDefault.kt | 2 +- .../annotations/javaNegativePropertyAsAnnotationParameter.kt | 2 +- .../box/annotations/javaPropertyAsAnnotationParameter.kt | 2 +- .../codegen/box/annotations/javaPropertyWithIntInitializer.kt | 2 +- .../box/annotations/kClassMapping/arrayClassParameter.kt | 2 +- .../annotations/kClassMapping/arrayClassParameterOnJavaClass.kt | 2 +- .../codegen/box/annotations/kClassMapping/classParameter.kt | 2 +- .../box/annotations/kClassMapping/classParameterOnJavaClass.kt | 2 +- .../box/annotations/kClassMapping/varargClassParameter.kt | 2 +- .../kClassMapping/varargClassParameterOnJavaClass.kt | 2 +- compiler/testData/codegen/box/annotations/retentionInJava.kt | 2 +- .../typeAnnotations/implicitReturnAgainstCompiled.kt | 1 - compiler/testData/codegen/box/callableReference/constructor.kt | 2 +- compiler/testData/codegen/box/callableReference/kt16412.kt | 2 +- .../testData/codegen/box/callableReference/publicFinalField.kt | 2 +- .../codegen/box/callableReference/publicMutableField.kt | 2 +- compiler/testData/codegen/box/callableReference/staticMethod.kt | 2 +- compiler/testData/codegen/box/constructor/genericConstructor.kt | 2 +- .../testData/codegen/box/constructor/secondaryConstructor.kt | 2 +- .../codegen/box/delegation/delegationAndInheritanceFromJava.kt | 2 +- compiler/testData/codegen/box/enum/nameConflict.kt | 2 +- compiler/testData/codegen/box/enum/simpleJavaEnum.kt | 2 +- .../testData/codegen/box/enum/simpleJavaEnumWithFunction.kt | 2 +- .../testData/codegen/box/enum/simpleJavaEnumWithStaticImport.kt | 2 +- compiler/testData/codegen/box/enum/simpleJavaInnerEnum.kt | 2 +- compiler/testData/codegen/box/enum/staticField.kt | 2 +- compiler/testData/codegen/box/enum/staticMethod.kt | 2 +- compiler/testData/codegen/box/functions/constructor.kt | 2 +- compiler/testData/codegen/box/functions/max.kt | 2 +- .../codegen/box/functions/referencesStaticInnerClassMethod.kt | 2 +- .../codegen/box/functions/referencesStaticInnerClassMethodL2.kt | 2 +- compiler/testData/codegen/box/functions/unrelatedUpperBounds.kt | 2 +- .../testData/codegen/box/ieee754/anyToReal_AgainstCompiled.kt | 2 +- .../codegen/box/ieee754/comparableTypeCast_AgainstCompiled.kt | 2 +- compiler/testData/codegen/box/ieee754/double.kt | 2 +- .../codegen/box/ieee754/explicitCompareCall_AgainstCompiled.kt | 2 +- .../codegen/box/ieee754/explicitEqualsCall_AgainstCompiled.kt | 2 +- compiler/testData/codegen/box/ieee754/float.kt | 2 +- .../testData/codegen/box/ieee754/generic_AgainstCompiled.kt | 2 +- .../codegen/box/ieee754/nullableAnyToReal_AgainstCompiled.kt | 2 +- compiler/testData/codegen/box/inline/kt19910.kt | 1 - compiler/testData/codegen/box/innerClass/kt3532.kt | 2 +- compiler/testData/codegen/box/innerClass/kt3812.kt | 2 +- compiler/testData/codegen/box/innerClass/kt4036.kt | 2 +- compiler/testData/codegen/box/interfaces/defaultMethod.kt | 2 +- .../testData/codegen/box/interfaces/inheritJavaInterface.kt | 2 +- .../multiplatform/annotationsViaActualTypeAliasFromBinary.kt | 2 +- .../testData/codegen/box/notNullAssertions/callAssertions.kt | 2 +- compiler/testData/codegen/box/notNullAssertions/delegation.kt | 2 +- .../codegen/box/notNullAssertions/doGenerateParamAssertions.kt | 2 +- .../testData/codegen/box/notNullAssertions/noCallAssertions.kt | 2 +- .../testData/codegen/box/notNullAssertions/rightElvisOperand.kt | 2 +- .../box/oldLanguageVersions/ieee754/explicitEqualsCallNull.kt | 2 +- compiler/testData/codegen/box/platformTypes/genericUnit.kt | 2 +- compiler/testData/codegen/box/platformTypes/kt14989.kt | 2 +- .../testData/codegen/box/platformTypes/specializedMapFull.kt | 2 +- .../testData/codegen/box/platformTypes/specializedMapPut.kt | 2 +- .../codegen/box/property/fieldAccessFromExtensionInTraitImpl.kt | 2 +- .../testData/codegen/box/property/fieldAccessViaSubclass.kt | 2 +- .../codegen/box/property/referenceToJavaFieldViaBridge.kt | 2 +- compiler/testData/codegen/box/recursiveRawTypes/kt16528.kt | 2 +- compiler/testData/codegen/box/recursiveRawTypes/kt16639.kt | 2 +- .../codegen/box/reflection/classLiterals/javaClassLiteral.kt | 2 +- .../testData/codegen/box/reflection/mapping/jClass2kClass.kt | 2 +- .../testData/codegen/box/reflection/mapping/javaConstructor.kt | 2 +- compiler/testData/codegen/box/reflection/mapping/javaFields.kt | 2 +- compiler/testData/codegen/box/reflection/mapping/javaMethods.kt | 2 +- .../codegen/box/reflection/properties/equalsHashCodeToString.kt | 2 +- .../testData/codegen/box/sam/adapters/bridgesForOverridden.kt | 2 +- .../codegen/box/sam/adapters/bridgesForOverriddenComplex.kt | 2 +- .../testData/codegen/box/sam/adapters/callAbstractAdapter.kt | 2 +- compiler/testData/codegen/box/sam/adapters/comparator.kt | 2 +- compiler/testData/codegen/box/sam/adapters/constructor.kt | 2 +- .../testData/codegen/box/sam/adapters/doubleLongParameters.kt | 2 +- compiler/testData/codegen/box/sam/adapters/fileFilter.kt | 2 +- compiler/testData/codegen/box/sam/adapters/genericSignature.kt | 2 +- compiler/testData/codegen/box/sam/adapters/implementAdapter.kt | 2 +- compiler/testData/codegen/box/sam/adapters/inheritedInKotlin.kt | 2 +- .../codegen/box/sam/adapters/inheritedOverriddenAdapter.kt | 2 +- compiler/testData/codegen/box/sam/adapters/inheritedSimple.kt | 2 +- compiler/testData/codegen/box/sam/adapters/localClass.kt | 2 +- .../testData/codegen/box/sam/adapters/localObjectConstructor.kt | 2 +- .../box/sam/adapters/localObjectConstructorWithFnValue.kt | 2 +- .../codegen/box/sam/adapters/nonLiteralAndLiteralRunnable.kt | 2 +- .../testData/codegen/box/sam/adapters/nonLiteralComparator.kt | 2 +- .../codegen/box/sam/adapters/nonLiteralInConstructor.kt | 2 +- compiler/testData/codegen/box/sam/adapters/nonLiteralNull.kt | 2 +- .../testData/codegen/box/sam/adapters/nonLiteralRunnable.kt | 2 +- .../box/sam/adapters/operators/augmentedAssignmentPure.kt | 2 +- .../adapters/operators/augmentedAssignmentViaSimpleBinary.kt | 2 +- compiler/testData/codegen/box/sam/adapters/operators/binary.kt | 2 +- .../testData/codegen/box/sam/adapters/operators/compareTo.kt | 2 +- .../testData/codegen/box/sam/adapters/operators/contains.kt | 2 +- compiler/testData/codegen/box/sam/adapters/operators/get.kt | 2 +- compiler/testData/codegen/box/sam/adapters/operators/invoke.kt | 2 +- .../codegen/box/sam/adapters/operators/legacyModOperator.kt | 2 +- .../testData/codegen/box/sam/adapters/operators/multiGetSet.kt | 2 +- .../testData/codegen/box/sam/adapters/operators/multiInvoke.kt | 2 +- compiler/testData/codegen/box/sam/adapters/operators/set.kt | 2 +- compiler/testData/codegen/box/sam/adapters/protectedFromBase.kt | 2 +- .../testData/codegen/box/sam/adapters/severalSamParameters.kt | 2 +- compiler/testData/codegen/box/sam/adapters/simplest.kt | 2 +- .../codegen/box/sam/adapters/superInSecondaryConstructor.kt | 2 +- compiler/testData/codegen/box/sam/adapters/superconstructor.kt | 2 +- .../codegen/box/sam/adapters/superconstructorWithClosure.kt | 2 +- .../testData/codegen/box/sam/adapters/typeParameterOfClass.kt | 2 +- .../testData/codegen/box/sam/adapters/typeParameterOfMethod.kt | 2 +- .../codegen/box/sam/adapters/typeParameterOfOuterClass.kt | 2 +- compiler/testData/codegen/box/sam/differentFqNames.kt | 2 +- compiler/testData/codegen/box/sam/kt11519.kt | 2 +- compiler/testData/codegen/box/sam/kt11519Constructor.kt | 2 +- compiler/testData/codegen/box/sam/kt11696.kt | 2 +- compiler/testData/codegen/box/sam/kt4753.kt | 2 +- compiler/testData/codegen/box/sam/kt4753_2.kt | 2 +- compiler/testData/codegen/box/sam/propertyReference.kt | 2 +- .../testData/codegen/box/sam/samConstructorGenericSignature.kt | 2 +- compiler/testData/codegen/box/sam/smartCastSamConversion.kt | 2 +- compiler/testData/codegen/box/specialBuiltins/charBuffer.kt | 2 +- compiler/testData/codegen/box/staticFun/classWithNestedEnum.kt | 2 +- .../testData/codegen/box/syntheticExtensions/fromTwoBases.kt | 2 +- compiler/testData/codegen/box/syntheticExtensions/getter.kt | 2 +- .../codegen/box/syntheticExtensions/implicitReceiver.kt | 2 +- .../codegen/box/syntheticExtensions/overrideOnlyGetter.kt | 2 +- compiler/testData/codegen/box/syntheticExtensions/plusPlus.kt | 2 +- compiler/testData/codegen/box/syntheticExtensions/protected.kt | 2 +- .../testData/codegen/box/syntheticExtensions/protectedSetter.kt | 2 +- compiler/testData/codegen/box/syntheticExtensions/setter.kt | 2 +- .../testData/codegen/box/syntheticExtensions/setterNonVoid1.kt | 2 +- .../testData/codegen/box/syntheticExtensions/setterNonVoid2.kt | 2 +- .../codegen/box/throws/delegationAndThrows_AgainstCompiled.kt | 1 - .../codegen/box/typealias/javaStaticMembersViaTypeAlias.kt | 2 +- compiler/testData/codegen/box/varargs/varargsOverride.kt | 2 +- compiler/testData/codegen/box/varargs/varargsOverride2.kt | 2 +- compiler/testData/codegen/box/varargs/varargsOverride3.kt | 2 +- compiler/testData/codegen/box/visibility/package/kt2781.kt | 2 +- .../testData/codegen/box/visibility/package/packageClass.kt | 2 +- compiler/testData/codegen/box/visibility/package/packageFun.kt | 2 +- .../testData/codegen/box/visibility/package/packageProperty.kt | 2 +- .../protectedAndPackage/overrideProtectedFunInPackage.kt | 2 +- .../box/visibility/protectedAndPackage/protectedAccessor.kt | 2 +- .../box/visibility/protectedAndPackage/protectedFunInPackage.kt | 2 +- .../protectedAndPackage/protectedPropertyInPackage.kt | 2 +- .../protectedPropertyInPackageFromCrossinline.kt | 2 +- .../box/visibility/protectedAndPackage/protectedStaticClass.kt | 2 +- .../box/visibility/protectedAndPackage/protectedSuperField.kt | 2 +- .../box/visibility/protectedAndPackage/protectedSuperMethod.kt | 2 +- .../box/visibility/protectedStatic/funCallInConstructor.kt | 2 +- .../codegen/box/visibility/protectedStatic/funClassObject.kt | 2 +- .../codegen/box/visibility/protectedStatic/funGenericClass.kt | 2 +- .../box/visibility/protectedStatic/funNestedStaticClass.kt | 2 +- .../box/visibility/protectedStatic/funNestedStaticClass2.kt | 2 +- .../visibility/protectedStatic/funNestedStaticGenericClass.kt | 2 +- .../box/visibility/protectedStatic/funNotDirectSuperClass.kt | 2 +- .../codegen/box/visibility/protectedStatic/funObject.kt | 2 +- .../codegen/box/visibility/protectedStatic/simpleClass.kt | 2 +- .../codegen/box/visibility/protectedStatic/simpleClass2.kt | 2 +- .../codegen/box/visibility/protectedStatic/simpleFun.kt | 2 +- .../codegen/box/visibility/protectedStatic/simpleProperty.kt | 2 +- 162 files changed, 159 insertions(+), 162 deletions(-) diff --git a/compiler/testData/codegen/box/annotations/divisionByZeroInJava.kt b/compiler/testData/codegen/box/annotations/divisionByZeroInJava.kt index bab5445979f..d78264e245f 100644 --- a/compiler/testData/codegen/box/annotations/divisionByZeroInJava.kt +++ b/compiler/testData/codegen/box/annotations/divisionByZeroInJava.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // USE_PSI_CLASS_FILES_READING // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueDefault.kt b/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueDefault.kt index 1b3953379ae..17b5a5bd452 100644 --- a/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueDefault.kt +++ b/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueDefault.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueNoDefault.kt b/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueNoDefault.kt index 5983dd2c952..8412a95d6b1 100644 --- a/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueNoDefault.kt +++ b/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueNoDefault.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: JavaAnn.java diff --git a/compiler/testData/codegen/box/annotations/javaAnnotationCall.kt b/compiler/testData/codegen/box/annotations/javaAnnotationCall.kt index 86a46e62036..620fcc14ad8 100644 --- a/compiler/testData/codegen/box/annotations/javaAnnotationCall.kt +++ b/compiler/testData/codegen/box/annotations/javaAnnotationCall.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: JavaAnn.java diff --git a/compiler/testData/codegen/box/annotations/javaAnnotationDefault.kt b/compiler/testData/codegen/box/annotations/javaAnnotationDefault.kt index 9adbf26a5f2..ae1bc8260d8 100644 --- a/compiler/testData/codegen/box/annotations/javaAnnotationDefault.kt +++ b/compiler/testData/codegen/box/annotations/javaAnnotationDefault.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: JavaAnn.java diff --git a/compiler/testData/codegen/box/annotations/javaNegativePropertyAsAnnotationParameter.kt b/compiler/testData/codegen/box/annotations/javaNegativePropertyAsAnnotationParameter.kt index 0d2a7683be9..bddcd66f575 100644 --- a/compiler/testData/codegen/box/annotations/javaNegativePropertyAsAnnotationParameter.kt +++ b/compiler/testData/codegen/box/annotations/javaNegativePropertyAsAnnotationParameter.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: Foo.java diff --git a/compiler/testData/codegen/box/annotations/javaPropertyAsAnnotationParameter.kt b/compiler/testData/codegen/box/annotations/javaPropertyAsAnnotationParameter.kt index e288aaa49fe..3331356ff42 100644 --- a/compiler/testData/codegen/box/annotations/javaPropertyAsAnnotationParameter.kt +++ b/compiler/testData/codegen/box/annotations/javaPropertyAsAnnotationParameter.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: Foo.java diff --git a/compiler/testData/codegen/box/annotations/javaPropertyWithIntInitializer.kt b/compiler/testData/codegen/box/annotations/javaPropertyWithIntInitializer.kt index 438640e634f..94c94183b80 100644 --- a/compiler/testData/codegen/box/annotations/javaPropertyWithIntInitializer.kt +++ b/compiler/testData/codegen/box/annotations/javaPropertyWithIntInitializer.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: Foo.java diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameter.kt b/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameter.kt index 02b740e9252..ce69c8df11b 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameter.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameter.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: JavaAnn.java diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameterOnJavaClass.kt b/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameterOnJavaClass.kt index 091ffcfe95e..480b5b7f321 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameterOnJavaClass.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameterOnJavaClass.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: JavaAnn.java diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/classParameter.kt b/compiler/testData/codegen/box/annotations/kClassMapping/classParameter.kt index 8c7f4b02986..e8d0dca4c84 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/classParameter.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/classParameter.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: JavaAnn.java diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/classParameterOnJavaClass.kt b/compiler/testData/codegen/box/annotations/kClassMapping/classParameterOnJavaClass.kt index ba7e9bfa0e0..639c7790d9a 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/classParameterOnJavaClass.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/classParameterOnJavaClass.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: JavaAnn.java diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameter.kt b/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameter.kt index d414b17ec10..ee81b20d4cf 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameter.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameter.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: JavaAnn.java diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameterOnJavaClass.kt b/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameterOnJavaClass.kt index e082122a78a..7b2deaac2ec 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameterOnJavaClass.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameterOnJavaClass.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: JavaAnn.java diff --git a/compiler/testData/codegen/box/annotations/retentionInJava.kt b/compiler/testData/codegen/box/annotations/retentionInJava.kt index 006f1d9d88e..5a7a0700caa 100644 --- a/compiler/testData/codegen/box/annotations/retentionInJava.kt +++ b/compiler/testData/codegen/box/annotations/retentionInJava.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Foo.java diff --git a/compiler/testData/codegen/box/annotations/typeAnnotations/implicitReturnAgainstCompiled.kt b/compiler/testData/codegen/box/annotations/typeAnnotations/implicitReturnAgainstCompiled.kt index 2da713e5688..3b11ad3d0ff 100644 --- a/compiler/testData/codegen/box/annotations/typeAnnotations/implicitReturnAgainstCompiled.kt +++ b/compiler/testData/codegen/box/annotations/typeAnnotations/implicitReturnAgainstCompiled.kt @@ -1,4 +1,3 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE // EMIT_JVM_TYPE_ANNOTATIONS // TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR diff --git a/compiler/testData/codegen/box/callableReference/constructor.kt b/compiler/testData/codegen/box/callableReference/constructor.kt index 555056a8232..8d9703bec2f 100644 --- a/compiler/testData/codegen/box/callableReference/constructor.kt +++ b/compiler/testData/codegen/box/callableReference/constructor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: A.java diff --git a/compiler/testData/codegen/box/callableReference/kt16412.kt b/compiler/testData/codegen/box/callableReference/kt16412.kt index a4bc421599b..2dbc5ab460a 100644 --- a/compiler/testData/codegen/box/callableReference/kt16412.kt +++ b/compiler/testData/codegen/box/callableReference/kt16412.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: MFunction.java diff --git a/compiler/testData/codegen/box/callableReference/publicFinalField.kt b/compiler/testData/codegen/box/callableReference/publicFinalField.kt index d2533488e0f..1820ef9209c 100644 --- a/compiler/testData/codegen/box/callableReference/publicFinalField.kt +++ b/compiler/testData/codegen/box/callableReference/publicFinalField.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: A.java diff --git a/compiler/testData/codegen/box/callableReference/publicMutableField.kt b/compiler/testData/codegen/box/callableReference/publicMutableField.kt index 4450f45de30..8e2672957ed 100644 --- a/compiler/testData/codegen/box/callableReference/publicMutableField.kt +++ b/compiler/testData/codegen/box/callableReference/publicMutableField.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: A.java diff --git a/compiler/testData/codegen/box/callableReference/staticMethod.kt b/compiler/testData/codegen/box/callableReference/staticMethod.kt index 882d183b121..b636c3bfe8e 100644 --- a/compiler/testData/codegen/box/callableReference/staticMethod.kt +++ b/compiler/testData/codegen/box/callableReference/staticMethod.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: A.java diff --git a/compiler/testData/codegen/box/constructor/genericConstructor.kt b/compiler/testData/codegen/box/constructor/genericConstructor.kt index d8d235d76cb..3c458a9aed8 100644 --- a/compiler/testData/codegen/box/constructor/genericConstructor.kt +++ b/compiler/testData/codegen/box/constructor/genericConstructor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/Foo.java diff --git a/compiler/testData/codegen/box/constructor/secondaryConstructor.kt b/compiler/testData/codegen/box/constructor/secondaryConstructor.kt index 3500cd59775..e1ade7fd0d1 100644 --- a/compiler/testData/codegen/box/constructor/secondaryConstructor.kt +++ b/compiler/testData/codegen/box/constructor/secondaryConstructor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/Foo.java diff --git a/compiler/testData/codegen/box/delegation/delegationAndInheritanceFromJava.kt b/compiler/testData/codegen/box/delegation/delegationAndInheritanceFromJava.kt index 349ed6dcfbf..2b361502877 100644 --- a/compiler/testData/codegen/box/delegation/delegationAndInheritanceFromJava.kt +++ b/compiler/testData/codegen/box/delegation/delegationAndInheritanceFromJava.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Foo.java diff --git a/compiler/testData/codegen/box/enum/nameConflict.kt b/compiler/testData/codegen/box/enum/nameConflict.kt index 3c7a5672cb8..e5f38ed00ea 100644 --- a/compiler/testData/codegen/box/enum/nameConflict.kt +++ b/compiler/testData/codegen/box/enum/nameConflict.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: C.java public enum C { diff --git a/compiler/testData/codegen/box/enum/simpleJavaEnum.kt b/compiler/testData/codegen/box/enum/simpleJavaEnum.kt index 38508c07f22..73e88ca9350 100644 --- a/compiler/testData/codegen/box/enum/simpleJavaEnum.kt +++ b/compiler/testData/codegen/box/enum/simpleJavaEnum.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/En.java diff --git a/compiler/testData/codegen/box/enum/simpleJavaEnumWithFunction.kt b/compiler/testData/codegen/box/enum/simpleJavaEnumWithFunction.kt index 6cf7e1ac3d9..83cfbb74c1b 100644 --- a/compiler/testData/codegen/box/enum/simpleJavaEnumWithFunction.kt +++ b/compiler/testData/codegen/box/enum/simpleJavaEnumWithFunction.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/En.java diff --git a/compiler/testData/codegen/box/enum/simpleJavaEnumWithStaticImport.kt b/compiler/testData/codegen/box/enum/simpleJavaEnumWithStaticImport.kt index 710b06c239d..149bbf464eb 100644 --- a/compiler/testData/codegen/box/enum/simpleJavaEnumWithStaticImport.kt +++ b/compiler/testData/codegen/box/enum/simpleJavaEnumWithStaticImport.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/En.java diff --git a/compiler/testData/codegen/box/enum/simpleJavaInnerEnum.kt b/compiler/testData/codegen/box/enum/simpleJavaInnerEnum.kt index 4deb559fafa..6c5182b1647 100644 --- a/compiler/testData/codegen/box/enum/simpleJavaInnerEnum.kt +++ b/compiler/testData/codegen/box/enum/simpleJavaInnerEnum.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/Foo.java diff --git a/compiler/testData/codegen/box/enum/staticField.kt b/compiler/testData/codegen/box/enum/staticField.kt index 8fae91ea795..b202614f0dc 100644 --- a/compiler/testData/codegen/box/enum/staticField.kt +++ b/compiler/testData/codegen/box/enum/staticField.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/E.java diff --git a/compiler/testData/codegen/box/enum/staticMethod.kt b/compiler/testData/codegen/box/enum/staticMethod.kt index 0be34082751..143ea4e8eed 100644 --- a/compiler/testData/codegen/box/enum/staticMethod.kt +++ b/compiler/testData/codegen/box/enum/staticMethod.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/En.java diff --git a/compiler/testData/codegen/box/functions/constructor.kt b/compiler/testData/codegen/box/functions/constructor.kt index eca0c465b3a..eaff2e392b8 100644 --- a/compiler/testData/codegen/box/functions/constructor.kt +++ b/compiler/testData/codegen/box/functions/constructor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: A.java diff --git a/compiler/testData/codegen/box/functions/max.kt b/compiler/testData/codegen/box/functions/max.kt index 1bf885dbfad..5191ace56a6 100644 --- a/compiler/testData/codegen/box/functions/max.kt +++ b/compiler/testData/codegen/box/functions/max.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Foo.java diff --git a/compiler/testData/codegen/box/functions/referencesStaticInnerClassMethod.kt b/compiler/testData/codegen/box/functions/referencesStaticInnerClassMethod.kt index ba9d1038ed1..3dfcd1e3e4c 100644 --- a/compiler/testData/codegen/box/functions/referencesStaticInnerClassMethod.kt +++ b/compiler/testData/codegen/box/functions/referencesStaticInnerClassMethod.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: R.java diff --git a/compiler/testData/codegen/box/functions/referencesStaticInnerClassMethodL2.kt b/compiler/testData/codegen/box/functions/referencesStaticInnerClassMethodL2.kt index 85396bbd10f..52ff72d2cbc 100644 --- a/compiler/testData/codegen/box/functions/referencesStaticInnerClassMethodL2.kt +++ b/compiler/testData/codegen/box/functions/referencesStaticInnerClassMethodL2.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: R.java diff --git a/compiler/testData/codegen/box/functions/unrelatedUpperBounds.kt b/compiler/testData/codegen/box/functions/unrelatedUpperBounds.kt index 7bb9978070a..0994efae4cb 100644 --- a/compiler/testData/codegen/box/functions/unrelatedUpperBounds.kt +++ b/compiler/testData/codegen/box/functions/unrelatedUpperBounds.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Foo.java diff --git a/compiler/testData/codegen/box/ieee754/anyToReal_AgainstCompiled.kt b/compiler/testData/codegen/box/ieee754/anyToReal_AgainstCompiled.kt index c2c25511ad4..29498970232 100644 --- a/compiler/testData/codegen/box/ieee754/anyToReal_AgainstCompiled.kt +++ b/compiler/testData/codegen/box/ieee754/anyToReal_AgainstCompiled.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/ieee754/comparableTypeCast_AgainstCompiled.kt b/compiler/testData/codegen/box/ieee754/comparableTypeCast_AgainstCompiled.kt index fe0f253a598..fc0e635ade9 100644 --- a/compiler/testData/codegen/box/ieee754/comparableTypeCast_AgainstCompiled.kt +++ b/compiler/testData/codegen/box/ieee754/comparableTypeCast_AgainstCompiled.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/ieee754/double.kt b/compiler/testData/codegen/box/ieee754/double.kt index 40879e5fbba..b0e818d50e4 100644 --- a/compiler/testData/codegen/box/ieee754/double.kt +++ b/compiler/testData/codegen/box/ieee754/double.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/ieee754/explicitCompareCall_AgainstCompiled.kt b/compiler/testData/codegen/box/ieee754/explicitCompareCall_AgainstCompiled.kt index 7927b025171..5803303a19d 100644 --- a/compiler/testData/codegen/box/ieee754/explicitCompareCall_AgainstCompiled.kt +++ b/compiler/testData/codegen/box/ieee754/explicitCompareCall_AgainstCompiled.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/ieee754/explicitEqualsCall_AgainstCompiled.kt b/compiler/testData/codegen/box/ieee754/explicitEqualsCall_AgainstCompiled.kt index 28caf58a0e3..2959e354339 100644 --- a/compiler/testData/codegen/box/ieee754/explicitEqualsCall_AgainstCompiled.kt +++ b/compiler/testData/codegen/box/ieee754/explicitEqualsCall_AgainstCompiled.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/ieee754/float.kt b/compiler/testData/codegen/box/ieee754/float.kt index 09992bd5da7..b42145f692b 100644 --- a/compiler/testData/codegen/box/ieee754/float.kt +++ b/compiler/testData/codegen/box/ieee754/float.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/ieee754/generic_AgainstCompiled.kt b/compiler/testData/codegen/box/ieee754/generic_AgainstCompiled.kt index fc18840a27e..0815ff498cc 100644 --- a/compiler/testData/codegen/box/ieee754/generic_AgainstCompiled.kt +++ b/compiler/testData/codegen/box/ieee754/generic_AgainstCompiled.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/ieee754/nullableAnyToReal_AgainstCompiled.kt b/compiler/testData/codegen/box/ieee754/nullableAnyToReal_AgainstCompiled.kt index 8ebcd13fe36..171d0da35a4 100644 --- a/compiler/testData/codegen/box/ieee754/nullableAnyToReal_AgainstCompiled.kt +++ b/compiler/testData/codegen/box/ieee754/nullableAnyToReal_AgainstCompiled.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/inline/kt19910.kt b/compiler/testData/codegen/box/inline/kt19910.kt index d61aadeb3d7..70c02be00a3 100644 --- a/compiler/testData/codegen/box/inline/kt19910.kt +++ b/compiler/testData/codegen/box/inline/kt19910.kt @@ -1,4 +1,3 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE // FULL_JDK // WITH_RUNTIME // TARGET_BACKEND: JVM diff --git a/compiler/testData/codegen/box/innerClass/kt3532.kt b/compiler/testData/codegen/box/innerClass/kt3532.kt index 15c49e03773..f1e501d3946 100644 --- a/compiler/testData/codegen/box/innerClass/kt3532.kt +++ b/compiler/testData/codegen/box/innerClass/kt3532.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Foo.java diff --git a/compiler/testData/codegen/box/innerClass/kt3812.kt b/compiler/testData/codegen/box/innerClass/kt3812.kt index 3406cfe907e..3cbba3c3789 100644 --- a/compiler/testData/codegen/box/innerClass/kt3812.kt +++ b/compiler/testData/codegen/box/innerClass/kt3812.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Foo.java diff --git a/compiler/testData/codegen/box/innerClass/kt4036.kt b/compiler/testData/codegen/box/innerClass/kt4036.kt index 9ef204bbff6..d377d47a000 100644 --- a/compiler/testData/codegen/box/innerClass/kt4036.kt +++ b/compiler/testData/codegen/box/innerClass/kt4036.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Foo.java diff --git a/compiler/testData/codegen/box/interfaces/defaultMethod.kt b/compiler/testData/codegen/box/interfaces/defaultMethod.kt index 7f672bebb01..b6c206a535f 100644 --- a/compiler/testData/codegen/box/interfaces/defaultMethod.kt +++ b/compiler/testData/codegen/box/interfaces/defaultMethod.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // JVM_TARGET: 1.8 // MODULE: lib diff --git a/compiler/testData/codegen/box/interfaces/inheritJavaInterface.kt b/compiler/testData/codegen/box/interfaces/inheritJavaInterface.kt index 93a3673c5e3..b6b9538a989 100644 --- a/compiler/testData/codegen/box/interfaces/inheritJavaInterface.kt +++ b/compiler/testData/codegen/box/interfaces/inheritJavaInterface.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: A.java diff --git a/compiler/testData/codegen/box/multiplatform/annotationsViaActualTypeAliasFromBinary.kt b/compiler/testData/codegen/box/multiplatform/annotationsViaActualTypeAliasFromBinary.kt index 242ff475aa6..095307c0718 100644 --- a/compiler/testData/codegen/box/multiplatform/annotationsViaActualTypeAliasFromBinary.kt +++ b/compiler/testData/codegen/box/multiplatform/annotationsViaActualTypeAliasFromBinary.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // !LANGUAGE: +MultiPlatformProjects // WITH_REFLECT diff --git a/compiler/testData/codegen/box/notNullAssertions/callAssertions.kt b/compiler/testData/codegen/box/notNullAssertions/callAssertions.kt index d89575fa449..e1525b5a4fd 100644 --- a/compiler/testData/codegen/box/notNullAssertions/callAssertions.kt +++ b/compiler/testData/codegen/box/notNullAssertions/callAssertions.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR // DISABLE_PARAM_ASSERTIONS diff --git a/compiler/testData/codegen/box/notNullAssertions/delegation.kt b/compiler/testData/codegen/box/notNullAssertions/delegation.kt index f92efb2944a..8bc81ef96b0 100644 --- a/compiler/testData/codegen/box/notNullAssertions/delegation.kt +++ b/compiler/testData/codegen/box/notNullAssertions/delegation.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR // MODULE: lib diff --git a/compiler/testData/codegen/box/notNullAssertions/doGenerateParamAssertions.kt b/compiler/testData/codegen/box/notNullAssertions/doGenerateParamAssertions.kt index 9dbadc6e9cb..1b3ee5f7e8d 100644 --- a/compiler/testData/codegen/box/notNullAssertions/doGenerateParamAssertions.kt +++ b/compiler/testData/codegen/box/notNullAssertions/doGenerateParamAssertions.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // DISABLE_CALL_ASSERTIONS // MODULE: lib // FILE: C.java diff --git a/compiler/testData/codegen/box/notNullAssertions/noCallAssertions.kt b/compiler/testData/codegen/box/notNullAssertions/noCallAssertions.kt index 14e450c29b2..7d2ea1dfa4b 100644 --- a/compiler/testData/codegen/box/notNullAssertions/noCallAssertions.kt +++ b/compiler/testData/codegen/box/notNullAssertions/noCallAssertions.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // DISABLE_PARAM_ASSERTIONS // DISABLE_CALL_ASSERTIONS diff --git a/compiler/testData/codegen/box/notNullAssertions/rightElvisOperand.kt b/compiler/testData/codegen/box/notNullAssertions/rightElvisOperand.kt index 00b6e5cad57..de09a20e275 100644 --- a/compiler/testData/codegen/box/notNullAssertions/rightElvisOperand.kt +++ b/compiler/testData/codegen/box/notNullAssertions/rightElvisOperand.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR // MODULE: lib // FILE: RightElvisOperand.java diff --git a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/explicitEqualsCallNull.kt b/compiler/testData/codegen/box/oldLanguageVersions/ieee754/explicitEqualsCallNull.kt index c5fc02efb8c..aa0dd3479bf 100644 --- a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/explicitEqualsCallNull.kt +++ b/compiler/testData/codegen/box/oldLanguageVersions/ieee754/explicitEqualsCallNull.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // !LANGUAGE: -ThrowNpeOnExplicitEqualsForBoxedNull // IGNORE_BACKEND: JVM_IR // ^ ThrowNpeOnExplicitEqualsForBoxedNull is introduced in 1.2. diff --git a/compiler/testData/codegen/box/platformTypes/genericUnit.kt b/compiler/testData/codegen/box/platformTypes/genericUnit.kt index 7ce17472580..8ce835cffba 100644 --- a/compiler/testData/codegen/box/platformTypes/genericUnit.kt +++ b/compiler/testData/codegen/box/platformTypes/genericUnit.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Foo.java diff --git a/compiler/testData/codegen/box/platformTypes/kt14989.kt b/compiler/testData/codegen/box/platformTypes/kt14989.kt index 40c6dae52a7..40ec8a80373 100644 --- a/compiler/testData/codegen/box/platformTypes/kt14989.kt +++ b/compiler/testData/codegen/box/platformTypes/kt14989.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM //WITH_RUNTIME // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/platformTypes/specializedMapFull.kt b/compiler/testData/codegen/box/platformTypes/specializedMapFull.kt index 0e4a274484e..0e5fc22c581 100644 --- a/compiler/testData/codegen/box/platformTypes/specializedMapFull.kt +++ b/compiler/testData/codegen/box/platformTypes/specializedMapFull.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR // MODULE: lib // FILE: AbstractSpecializedMap.java diff --git a/compiler/testData/codegen/box/platformTypes/specializedMapPut.kt b/compiler/testData/codegen/box/platformTypes/specializedMapPut.kt index e29959f2411..58a27076105 100644 --- a/compiler/testData/codegen/box/platformTypes/specializedMapPut.kt +++ b/compiler/testData/codegen/box/platformTypes/specializedMapPut.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR // MODULE: lib // FILE: A.java diff --git a/compiler/testData/codegen/box/property/fieldAccessFromExtensionInTraitImpl.kt b/compiler/testData/codegen/box/property/fieldAccessFromExtensionInTraitImpl.kt index 8b535611e97..caf22683ecf 100644 --- a/compiler/testData/codegen/box/property/fieldAccessFromExtensionInTraitImpl.kt +++ b/compiler/testData/codegen/box/property/fieldAccessFromExtensionInTraitImpl.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: D.java diff --git a/compiler/testData/codegen/box/property/fieldAccessViaSubclass.kt b/compiler/testData/codegen/box/property/fieldAccessViaSubclass.kt index 9cd9484087d..8088ebe7c04 100644 --- a/compiler/testData/codegen/box/property/fieldAccessViaSubclass.kt +++ b/compiler/testData/codegen/box/property/fieldAccessViaSubclass.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: D.java diff --git a/compiler/testData/codegen/box/property/referenceToJavaFieldViaBridge.kt b/compiler/testData/codegen/box/property/referenceToJavaFieldViaBridge.kt index f68ebb796aa..a317b22cd9a 100644 --- a/compiler/testData/codegen/box/property/referenceToJavaFieldViaBridge.kt +++ b/compiler/testData/codegen/box/property/referenceToJavaFieldViaBridge.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/D.java diff --git a/compiler/testData/codegen/box/recursiveRawTypes/kt16528.kt b/compiler/testData/codegen/box/recursiveRawTypes/kt16528.kt index fe76358c246..bd187b6d5e2 100644 --- a/compiler/testData/codegen/box/recursiveRawTypes/kt16528.kt +++ b/compiler/testData/codegen/box/recursiveRawTypes/kt16528.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaScriptParser.java public class JavaScriptParser { diff --git a/compiler/testData/codegen/box/recursiveRawTypes/kt16639.kt b/compiler/testData/codegen/box/recursiveRawTypes/kt16639.kt index 67fc49df7b8..771fa8e60de 100644 --- a/compiler/testData/codegen/box/recursiveRawTypes/kt16639.kt +++ b/compiler/testData/codegen/box/recursiveRawTypes/kt16639.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: Device.java diff --git a/compiler/testData/codegen/box/reflection/classLiterals/javaClassLiteral.kt b/compiler/testData/codegen/box/reflection/classLiterals/javaClassLiteral.kt index 514659455aa..836a7cdb531 100644 --- a/compiler/testData/codegen/box/reflection/classLiterals/javaClassLiteral.kt +++ b/compiler/testData/codegen/box/reflection/classLiterals/javaClassLiteral.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_REFLECT // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/reflection/mapping/jClass2kClass.kt b/compiler/testData/codegen/box/reflection/mapping/jClass2kClass.kt index 32b2d34705b..6db31bd6c13 100644 --- a/compiler/testData/codegen/box/reflection/mapping/jClass2kClass.kt +++ b/compiler/testData/codegen/box/reflection/mapping/jClass2kClass.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/reflection/mapping/javaConstructor.kt b/compiler/testData/codegen/box/reflection/mapping/javaConstructor.kt index 47c95361880..bb18df44566 100644 --- a/compiler/testData/codegen/box/reflection/mapping/javaConstructor.kt +++ b/compiler/testData/codegen/box/reflection/mapping/javaConstructor.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_REFLECT // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/reflection/mapping/javaFields.kt b/compiler/testData/codegen/box/reflection/mapping/javaFields.kt index 61fd5f5b490..f5eda2640d4 100644 --- a/compiler/testData/codegen/box/reflection/mapping/javaFields.kt +++ b/compiler/testData/codegen/box/reflection/mapping/javaFields.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_REFLECT // FULL_JDK // MODULE: lib diff --git a/compiler/testData/codegen/box/reflection/mapping/javaMethods.kt b/compiler/testData/codegen/box/reflection/mapping/javaMethods.kt index 4f0ab11574c..060443f7828 100644 --- a/compiler/testData/codegen/box/reflection/mapping/javaMethods.kt +++ b/compiler/testData/codegen/box/reflection/mapping/javaMethods.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_REFLECT // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/reflection/properties/equalsHashCodeToString.kt b/compiler/testData/codegen/box/reflection/properties/equalsHashCodeToString.kt index 2ccf9e635bd..23c063fa22e 100644 --- a/compiler/testData/codegen/box/reflection/properties/equalsHashCodeToString.kt +++ b/compiler/testData/codegen/box/reflection/properties/equalsHashCodeToString.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_REFLECT // MODULE: lib // FILE: test/J.java diff --git a/compiler/testData/codegen/box/sam/adapters/bridgesForOverridden.kt b/compiler/testData/codegen/box/sam/adapters/bridgesForOverridden.kt index f52b417924e..40027577dad 100644 --- a/compiler/testData/codegen/box/sam/adapters/bridgesForOverridden.kt +++ b/compiler/testData/codegen/box/sam/adapters/bridgesForOverridden.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/bridgesForOverriddenComplex.kt b/compiler/testData/codegen/box/sam/adapters/bridgesForOverriddenComplex.kt index 7840b3b5088..f53f9ed6d8d 100644 --- a/compiler/testData/codegen/box/sam/adapters/bridgesForOverriddenComplex.kt +++ b/compiler/testData/codegen/box/sam/adapters/bridgesForOverriddenComplex.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/callAbstractAdapter.kt b/compiler/testData/codegen/box/sam/adapters/callAbstractAdapter.kt index 4e3eae4dd3c..4335ac8c122 100644 --- a/compiler/testData/codegen/box/sam/adapters/callAbstractAdapter.kt +++ b/compiler/testData/codegen/box/sam/adapters/callAbstractAdapter.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaInterface.java diff --git a/compiler/testData/codegen/box/sam/adapters/comparator.kt b/compiler/testData/codegen/box/sam/adapters/comparator.kt index 0e653cbcc42..8f47618e7fb 100644 --- a/compiler/testData/codegen/box/sam/adapters/comparator.kt +++ b/compiler/testData/codegen/box/sam/adapters/comparator.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/constructor.kt b/compiler/testData/codegen/box/sam/adapters/constructor.kt index 89e05eb5674..19fd50f7251 100644 --- a/compiler/testData/codegen/box/sam/adapters/constructor.kt +++ b/compiler/testData/codegen/box/sam/adapters/constructor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/doubleLongParameters.kt b/compiler/testData/codegen/box/sam/adapters/doubleLongParameters.kt index 461f621903a..c744969e30b 100644 --- a/compiler/testData/codegen/box/sam/adapters/doubleLongParameters.kt +++ b/compiler/testData/codegen/box/sam/adapters/doubleLongParameters.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: GenericInterface.java diff --git a/compiler/testData/codegen/box/sam/adapters/fileFilter.kt b/compiler/testData/codegen/box/sam/adapters/fileFilter.kt index 03a5d374750..80f3b96ecd1 100644 --- a/compiler/testData/codegen/box/sam/adapters/fileFilter.kt +++ b/compiler/testData/codegen/box/sam/adapters/fileFilter.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/genericSignature.kt b/compiler/testData/codegen/box/sam/adapters/genericSignature.kt index 3cc49d4db5b..3f0d4f9b8c3 100644 --- a/compiler/testData/codegen/box/sam/adapters/genericSignature.kt +++ b/compiler/testData/codegen/box/sam/adapters/genericSignature.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/implementAdapter.kt b/compiler/testData/codegen/box/sam/adapters/implementAdapter.kt index 73fc3078f7a..9d6e02cf249 100644 --- a/compiler/testData/codegen/box/sam/adapters/implementAdapter.kt +++ b/compiler/testData/codegen/box/sam/adapters/implementAdapter.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: JavaInterface.java diff --git a/compiler/testData/codegen/box/sam/adapters/inheritedInKotlin.kt b/compiler/testData/codegen/box/sam/adapters/inheritedInKotlin.kt index ab4da28d97d..632e6e6f701 100644 --- a/compiler/testData/codegen/box/sam/adapters/inheritedInKotlin.kt +++ b/compiler/testData/codegen/box/sam/adapters/inheritedInKotlin.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/inheritedOverriddenAdapter.kt b/compiler/testData/codegen/box/sam/adapters/inheritedOverriddenAdapter.kt index 56464fa2950..e5450d3f2cc 100644 --- a/compiler/testData/codegen/box/sam/adapters/inheritedOverriddenAdapter.kt +++ b/compiler/testData/codegen/box/sam/adapters/inheritedOverriddenAdapter.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/sam/adapters/inheritedSimple.kt b/compiler/testData/codegen/box/sam/adapters/inheritedSimple.kt index 2bcba1ee0c1..99caf7f9160 100644 --- a/compiler/testData/codegen/box/sam/adapters/inheritedSimple.kt +++ b/compiler/testData/codegen/box/sam/adapters/inheritedSimple.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Sub.java diff --git a/compiler/testData/codegen/box/sam/adapters/localClass.kt b/compiler/testData/codegen/box/sam/adapters/localClass.kt index 953e14dcf40..f233e21831b 100644 --- a/compiler/testData/codegen/box/sam/adapters/localClass.kt +++ b/compiler/testData/codegen/box/sam/adapters/localClass.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/localObjectConstructor.kt b/compiler/testData/codegen/box/sam/adapters/localObjectConstructor.kt index 9114370e409..e976893ec24 100644 --- a/compiler/testData/codegen/box/sam/adapters/localObjectConstructor.kt +++ b/compiler/testData/codegen/box/sam/adapters/localObjectConstructor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/localObjectConstructorWithFnValue.kt b/compiler/testData/codegen/box/sam/adapters/localObjectConstructorWithFnValue.kt index 3d28d40f4e7..d441a629627 100644 --- a/compiler/testData/codegen/box/sam/adapters/localObjectConstructorWithFnValue.kt +++ b/compiler/testData/codegen/box/sam/adapters/localObjectConstructorWithFnValue.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/nonLiteralAndLiteralRunnable.kt b/compiler/testData/codegen/box/sam/adapters/nonLiteralAndLiteralRunnable.kt index 55d37c3f52e..95d042c8988 100644 --- a/compiler/testData/codegen/box/sam/adapters/nonLiteralAndLiteralRunnable.kt +++ b/compiler/testData/codegen/box/sam/adapters/nonLiteralAndLiteralRunnable.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/nonLiteralComparator.kt b/compiler/testData/codegen/box/sam/adapters/nonLiteralComparator.kt index a04e01a0b58..8ff1dff8c80 100644 --- a/compiler/testData/codegen/box/sam/adapters/nonLiteralComparator.kt +++ b/compiler/testData/codegen/box/sam/adapters/nonLiteralComparator.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/nonLiteralInConstructor.kt b/compiler/testData/codegen/box/sam/adapters/nonLiteralInConstructor.kt index 9cc2761137e..ad4928a7b61 100644 --- a/compiler/testData/codegen/box/sam/adapters/nonLiteralInConstructor.kt +++ b/compiler/testData/codegen/box/sam/adapters/nonLiteralInConstructor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/nonLiteralNull.kt b/compiler/testData/codegen/box/sam/adapters/nonLiteralNull.kt index 7e142c45ae0..ceed77bab4f 100644 --- a/compiler/testData/codegen/box/sam/adapters/nonLiteralNull.kt +++ b/compiler/testData/codegen/box/sam/adapters/nonLiteralNull.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/nonLiteralRunnable.kt b/compiler/testData/codegen/box/sam/adapters/nonLiteralRunnable.kt index ca3e5cd9c3b..43cf6df81ae 100644 --- a/compiler/testData/codegen/box/sam/adapters/nonLiteralRunnable.kt +++ b/compiler/testData/codegen/box/sam/adapters/nonLiteralRunnable.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/operators/augmentedAssignmentPure.kt b/compiler/testData/codegen/box/sam/adapters/operators/augmentedAssignmentPure.kt index 37dce51f6a2..b42c887420b 100644 --- a/compiler/testData/codegen/box/sam/adapters/operators/augmentedAssignmentPure.kt +++ b/compiler/testData/codegen/box/sam/adapters/operators/augmentedAssignmentPure.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.kt b/compiler/testData/codegen/box/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.kt index 79fbb2c8864..85768c6be50 100644 --- a/compiler/testData/codegen/box/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.kt +++ b/compiler/testData/codegen/box/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/operators/binary.kt b/compiler/testData/codegen/box/sam/adapters/operators/binary.kt index 0932680a095..b76e05d93bf 100644 --- a/compiler/testData/codegen/box/sam/adapters/operators/binary.kt +++ b/compiler/testData/codegen/box/sam/adapters/operators/binary.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/operators/compareTo.kt b/compiler/testData/codegen/box/sam/adapters/operators/compareTo.kt index 3f9ea336de2..8b008c7f4cd 100644 --- a/compiler/testData/codegen/box/sam/adapters/operators/compareTo.kt +++ b/compiler/testData/codegen/box/sam/adapters/operators/compareTo.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/operators/contains.kt b/compiler/testData/codegen/box/sam/adapters/operators/contains.kt index 679064770b6..d5b55f8bf27 100644 --- a/compiler/testData/codegen/box/sam/adapters/operators/contains.kt +++ b/compiler/testData/codegen/box/sam/adapters/operators/contains.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/operators/get.kt b/compiler/testData/codegen/box/sam/adapters/operators/get.kt index 64810e93907..c5bf0c81043 100644 --- a/compiler/testData/codegen/box/sam/adapters/operators/get.kt +++ b/compiler/testData/codegen/box/sam/adapters/operators/get.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/operators/invoke.kt b/compiler/testData/codegen/box/sam/adapters/operators/invoke.kt index 44eae363f6c..317202d342c 100644 --- a/compiler/testData/codegen/box/sam/adapters/operators/invoke.kt +++ b/compiler/testData/codegen/box/sam/adapters/operators/invoke.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/operators/legacyModOperator.kt b/compiler/testData/codegen/box/sam/adapters/operators/legacyModOperator.kt index aad574b9490..fdfc2ca8aba 100644 --- a/compiler/testData/codegen/box/sam/adapters/operators/legacyModOperator.kt +++ b/compiler/testData/codegen/box/sam/adapters/operators/legacyModOperator.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // !LANGUAGE: -ProhibitOperatorMod // IGNORE_BACKEND_FIR: JVM_IR // MODULE: lib diff --git a/compiler/testData/codegen/box/sam/adapters/operators/multiGetSet.kt b/compiler/testData/codegen/box/sam/adapters/operators/multiGetSet.kt index 17839dd61f9..26699b2700c 100644 --- a/compiler/testData/codegen/box/sam/adapters/operators/multiGetSet.kt +++ b/compiler/testData/codegen/box/sam/adapters/operators/multiGetSet.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/operators/multiInvoke.kt b/compiler/testData/codegen/box/sam/adapters/operators/multiInvoke.kt index 4143e115ef9..1636b05ee4a 100644 --- a/compiler/testData/codegen/box/sam/adapters/operators/multiInvoke.kt +++ b/compiler/testData/codegen/box/sam/adapters/operators/multiInvoke.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/operators/set.kt b/compiler/testData/codegen/box/sam/adapters/operators/set.kt index e95fb081911..86c261d6060 100644 --- a/compiler/testData/codegen/box/sam/adapters/operators/set.kt +++ b/compiler/testData/codegen/box/sam/adapters/operators/set.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/protectedFromBase.kt b/compiler/testData/codegen/box/sam/adapters/protectedFromBase.kt index ae88547cd4c..8b204b61842 100644 --- a/compiler/testData/codegen/box/sam/adapters/protectedFromBase.kt +++ b/compiler/testData/codegen/box/sam/adapters/protectedFromBase.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/severalSamParameters.kt b/compiler/testData/codegen/box/sam/adapters/severalSamParameters.kt index e0d29c290d5..bfd9ef21e22 100644 --- a/compiler/testData/codegen/box/sam/adapters/severalSamParameters.kt +++ b/compiler/testData/codegen/box/sam/adapters/severalSamParameters.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/simplest.kt b/compiler/testData/codegen/box/sam/adapters/simplest.kt index 3b03e954434..93fef8695b9 100644 --- a/compiler/testData/codegen/box/sam/adapters/simplest.kt +++ b/compiler/testData/codegen/box/sam/adapters/simplest.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/superInSecondaryConstructor.kt b/compiler/testData/codegen/box/sam/adapters/superInSecondaryConstructor.kt index f14d5830fac..390673b5f61 100644 --- a/compiler/testData/codegen/box/sam/adapters/superInSecondaryConstructor.kt +++ b/compiler/testData/codegen/box/sam/adapters/superInSecondaryConstructor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Supplier.java public interface Supplier { diff --git a/compiler/testData/codegen/box/sam/adapters/superconstructor.kt b/compiler/testData/codegen/box/sam/adapters/superconstructor.kt index a91ab9c5ad0..18e33a591e4 100644 --- a/compiler/testData/codegen/box/sam/adapters/superconstructor.kt +++ b/compiler/testData/codegen/box/sam/adapters/superconstructor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/superconstructorWithClosure.kt b/compiler/testData/codegen/box/sam/adapters/superconstructorWithClosure.kt index 4d48eba1c6e..a789ca1a68c 100644 --- a/compiler/testData/codegen/box/sam/adapters/superconstructorWithClosure.kt +++ b/compiler/testData/codegen/box/sam/adapters/superconstructorWithClosure.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/adapters/typeParameterOfClass.kt b/compiler/testData/codegen/box/sam/adapters/typeParameterOfClass.kt index 94d9d428586..a47027b2b58 100644 --- a/compiler/testData/codegen/box/sam/adapters/typeParameterOfClass.kt +++ b/compiler/testData/codegen/box/sam/adapters/typeParameterOfClass.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: WeirdComparator.java diff --git a/compiler/testData/codegen/box/sam/adapters/typeParameterOfMethod.kt b/compiler/testData/codegen/box/sam/adapters/typeParameterOfMethod.kt index 8fe16a73cca..69334fbcb64 100644 --- a/compiler/testData/codegen/box/sam/adapters/typeParameterOfMethod.kt +++ b/compiler/testData/codegen/box/sam/adapters/typeParameterOfMethod.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: WeirdComparator.java diff --git a/compiler/testData/codegen/box/sam/adapters/typeParameterOfOuterClass.kt b/compiler/testData/codegen/box/sam/adapters/typeParameterOfOuterClass.kt index 9f585880bc6..b71bb1fd329 100644 --- a/compiler/testData/codegen/box/sam/adapters/typeParameterOfOuterClass.kt +++ b/compiler/testData/codegen/box/sam/adapters/typeParameterOfOuterClass.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: WeirdComparator.java diff --git a/compiler/testData/codegen/box/sam/differentFqNames.kt b/compiler/testData/codegen/box/sam/differentFqNames.kt index 7275656809f..a75ec7c69a1 100644 --- a/compiler/testData/codegen/box/sam/differentFqNames.kt +++ b/compiler/testData/codegen/box/sam/differentFqNames.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib // FILE: Custom.java diff --git a/compiler/testData/codegen/box/sam/kt11519.kt b/compiler/testData/codegen/box/sam/kt11519.kt index d99b46ff331..767a30b21aa 100644 --- a/compiler/testData/codegen/box/sam/kt11519.kt +++ b/compiler/testData/codegen/box/sam/kt11519.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // SKIP_JDK6 // MODULE: lib // FILE: Custom.java diff --git a/compiler/testData/codegen/box/sam/kt11519Constructor.kt b/compiler/testData/codegen/box/sam/kt11519Constructor.kt index b95218669ed..05d1a47a2a7 100644 --- a/compiler/testData/codegen/box/sam/kt11519Constructor.kt +++ b/compiler/testData/codegen/box/sam/kt11519Constructor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // SKIP_JDK6 // MODULE: lib // FILE: Custom.java diff --git a/compiler/testData/codegen/box/sam/kt11696.kt b/compiler/testData/codegen/box/sam/kt11696.kt index 3559f916600..e4582355d9c 100644 --- a/compiler/testData/codegen/box/sam/kt11696.kt +++ b/compiler/testData/codegen/box/sam/kt11696.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/sam/kt4753.kt b/compiler/testData/codegen/box/sam/kt4753.kt index 5bbd44163d5..9c36dacf0d7 100644 --- a/compiler/testData/codegen/box/sam/kt4753.kt +++ b/compiler/testData/codegen/box/sam/kt4753.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Base.java diff --git a/compiler/testData/codegen/box/sam/kt4753_2.kt b/compiler/testData/codegen/box/sam/kt4753_2.kt index 1bd5047a377..ac11d3004cd 100644 --- a/compiler/testData/codegen/box/sam/kt4753_2.kt +++ b/compiler/testData/codegen/box/sam/kt4753_2.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: ParamBase.java diff --git a/compiler/testData/codegen/box/sam/propertyReference.kt b/compiler/testData/codegen/box/sam/propertyReference.kt index 815e979e639..46457055f89 100644 --- a/compiler/testData/codegen/box/sam/propertyReference.kt +++ b/compiler/testData/codegen/box/sam/propertyReference.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Base.java diff --git a/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt b/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt index 4c9ebf2da56..331393f18c7 100644 --- a/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt +++ b/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // SKIP_JDK6 // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/sam/smartCastSamConversion.kt b/compiler/testData/codegen/box/sam/smartCastSamConversion.kt index ae47f814af1..986f990c057 100644 --- a/compiler/testData/codegen/box/sam/smartCastSamConversion.kt +++ b/compiler/testData/codegen/box/sam/smartCastSamConversion.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JFoo.java public interface JFoo { diff --git a/compiler/testData/codegen/box/specialBuiltins/charBuffer.kt b/compiler/testData/codegen/box/specialBuiltins/charBuffer.kt index 62b84ccfb10..67b3655520c 100644 --- a/compiler/testData/codegen/box/specialBuiltins/charBuffer.kt +++ b/compiler/testData/codegen/box/specialBuiltins/charBuffer.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR // MODULE: lib // FILE: CharBuffer.java diff --git a/compiler/testData/codegen/box/staticFun/classWithNestedEnum.kt b/compiler/testData/codegen/box/staticFun/classWithNestedEnum.kt index 6bc026cda5a..d669fb5fa9a 100644 --- a/compiler/testData/codegen/box/staticFun/classWithNestedEnum.kt +++ b/compiler/testData/codegen/box/staticFun/classWithNestedEnum.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/JavaClass.java diff --git a/compiler/testData/codegen/box/syntheticExtensions/fromTwoBases.kt b/compiler/testData/codegen/box/syntheticExtensions/fromTwoBases.kt index 6b3e9685b13..5564fa6cef9 100644 --- a/compiler/testData/codegen/box/syntheticExtensions/fromTwoBases.kt +++ b/compiler/testData/codegen/box/syntheticExtensions/fromTwoBases.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: C.java diff --git a/compiler/testData/codegen/box/syntheticExtensions/getter.kt b/compiler/testData/codegen/box/syntheticExtensions/getter.kt index 8ff171d1ad5..f33111f48b9 100644 --- a/compiler/testData/codegen/box/syntheticExtensions/getter.kt +++ b/compiler/testData/codegen/box/syntheticExtensions/getter.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/syntheticExtensions/implicitReceiver.kt b/compiler/testData/codegen/box/syntheticExtensions/implicitReceiver.kt index 43fa48fbd87..d7860f29edc 100644 --- a/compiler/testData/codegen/box/syntheticExtensions/implicitReceiver.kt +++ b/compiler/testData/codegen/box/syntheticExtensions/implicitReceiver.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/syntheticExtensions/overrideOnlyGetter.kt b/compiler/testData/codegen/box/syntheticExtensions/overrideOnlyGetter.kt index 1f950690ccb..a73f837144f 100644 --- a/compiler/testData/codegen/box/syntheticExtensions/overrideOnlyGetter.kt +++ b/compiler/testData/codegen/box/syntheticExtensions/overrideOnlyGetter.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass2.java diff --git a/compiler/testData/codegen/box/syntheticExtensions/plusPlus.kt b/compiler/testData/codegen/box/syntheticExtensions/plusPlus.kt index 6641dcbbe1e..aecce6ca6de 100644 --- a/compiler/testData/codegen/box/syntheticExtensions/plusPlus.kt +++ b/compiler/testData/codegen/box/syntheticExtensions/plusPlus.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/syntheticExtensions/protected.kt b/compiler/testData/codegen/box/syntheticExtensions/protected.kt index 5c4431b90cf..e820465cc67 100644 --- a/compiler/testData/codegen/box/syntheticExtensions/protected.kt +++ b/compiler/testData/codegen/box/syntheticExtensions/protected.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/syntheticExtensions/protectedSetter.kt b/compiler/testData/codegen/box/syntheticExtensions/protectedSetter.kt index 28a038e9f0c..0269409e755 100644 --- a/compiler/testData/codegen/box/syntheticExtensions/protectedSetter.kt +++ b/compiler/testData/codegen/box/syntheticExtensions/protectedSetter.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/syntheticExtensions/setter.kt b/compiler/testData/codegen/box/syntheticExtensions/setter.kt index d1ac49da876..a32b3cda06f 100644 --- a/compiler/testData/codegen/box/syntheticExtensions/setter.kt +++ b/compiler/testData/codegen/box/syntheticExtensions/setter.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/syntheticExtensions/setterNonVoid1.kt b/compiler/testData/codegen/box/syntheticExtensions/setterNonVoid1.kt index 213a6fa9ee8..026430008da 100644 --- a/compiler/testData/codegen/box/syntheticExtensions/setterNonVoid1.kt +++ b/compiler/testData/codegen/box/syntheticExtensions/setterNonVoid1.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/syntheticExtensions/setterNonVoid2.kt b/compiler/testData/codegen/box/syntheticExtensions/setterNonVoid2.kt index 406d49a590e..756fb5d6d35 100644 --- a/compiler/testData/codegen/box/syntheticExtensions/setterNonVoid2.kt +++ b/compiler/testData/codegen/box/syntheticExtensions/setterNonVoid2.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/throws/delegationAndThrows_AgainstCompiled.kt b/compiler/testData/codegen/box/throws/delegationAndThrows_AgainstCompiled.kt index 1eb77a3d5aa..80104409b1d 100644 --- a/compiler/testData/codegen/box/throws/delegationAndThrows_AgainstCompiled.kt +++ b/compiler/testData/codegen/box/throws/delegationAndThrows_AgainstCompiled.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/typealias/javaStaticMembersViaTypeAlias.kt b/compiler/testData/codegen/box/typealias/javaStaticMembersViaTypeAlias.kt index a6ddbf38509..a2e19525c08 100644 --- a/compiler/testData/codegen/box/typealias/javaStaticMembersViaTypeAlias.kt +++ b/compiler/testData/codegen/box/typealias/javaStaticMembersViaTypeAlias.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: JTest.java public class JTest { diff --git a/compiler/testData/codegen/box/varargs/varargsOverride.kt b/compiler/testData/codegen/box/varargs/varargsOverride.kt index d7d2e7e597f..6e47dae1087 100644 --- a/compiler/testData/codegen/box/varargs/varargsOverride.kt +++ b/compiler/testData/codegen/box/varargs/varargsOverride.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: A.java diff --git a/compiler/testData/codegen/box/varargs/varargsOverride2.kt b/compiler/testData/codegen/box/varargs/varargsOverride2.kt index b2909813085..ee050b31278 100644 --- a/compiler/testData/codegen/box/varargs/varargsOverride2.kt +++ b/compiler/testData/codegen/box/varargs/varargsOverride2.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: A.java diff --git a/compiler/testData/codegen/box/varargs/varargsOverride3.kt b/compiler/testData/codegen/box/varargs/varargsOverride3.kt index 8a6bf4d028c..77175577048 100644 --- a/compiler/testData/codegen/box/varargs/varargsOverride3.kt +++ b/compiler/testData/codegen/box/varargs/varargsOverride3.kt @@ -1,5 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: A.java diff --git a/compiler/testData/codegen/box/visibility/package/kt2781.kt b/compiler/testData/codegen/box/visibility/package/kt2781.kt index ec34c6e66ca..5136839714c 100644 --- a/compiler/testData/codegen/box/visibility/package/kt2781.kt +++ b/compiler/testData/codegen/box/visibility/package/kt2781.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/visibility/package/packageClass.kt b/compiler/testData/codegen/box/visibility/package/packageClass.kt index 4b03690b936..c2913f48dae 100644 --- a/compiler/testData/codegen/box/visibility/package/packageClass.kt +++ b/compiler/testData/codegen/box/visibility/package/packageClass.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: protectedPack/J.java diff --git a/compiler/testData/codegen/box/visibility/package/packageFun.kt b/compiler/testData/codegen/box/visibility/package/packageFun.kt index 10412c05620..79bd620318e 100644 --- a/compiler/testData/codegen/box/visibility/package/packageFun.kt +++ b/compiler/testData/codegen/box/visibility/package/packageFun.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: protectedPack/J.java diff --git a/compiler/testData/codegen/box/visibility/package/packageProperty.kt b/compiler/testData/codegen/box/visibility/package/packageProperty.kt index ba65f653ce7..c81d8ed3bd9 100644 --- a/compiler/testData/codegen/box/visibility/package/packageProperty.kt +++ b/compiler/testData/codegen/box/visibility/package/packageProperty.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: protectedPack/J.java diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt b/compiler/testData/codegen/box/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt index 174cfff96cf..211906c0410 100644 --- a/compiler/testData/codegen/box/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt +++ b/compiler/testData/codegen/box/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: protectedPack/J.java diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedAccessor.kt b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedAccessor.kt index 79e9aa03726..d0b386101a1 100644 --- a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedAccessor.kt +++ b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedAccessor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: protectedPack/A.java package protectedPack; diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedFunInPackage.kt b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedFunInPackage.kt index 92a936309c8..d15684cd9e2 100644 --- a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedFunInPackage.kt +++ b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedFunInPackage.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: protectedPack/J.java diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackage.kt b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackage.kt index 6896423e4c7..459cba974c6 100644 --- a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackage.kt +++ b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackage.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: protectedPack/J.java diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt index a75780cbd8c..367205bd9a9 100644 --- a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt +++ b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: protectedPack/J.java diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedStaticClass.kt b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedStaticClass.kt index dc1df0a5e34..71d1a1cceca 100644 --- a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedStaticClass.kt +++ b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedStaticClass.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: protectedPack/J.java diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperField.kt b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperField.kt index bc06cce9e35..aa12ebd37af 100644 --- a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperField.kt +++ b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperField.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/Foo.java package test; diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperMethod.kt b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperMethod.kt index 3b85752789e..9f30f1a9716 100644 --- a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperMethod.kt +++ b/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperMethod.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: test/Foo.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funCallInConstructor.kt b/compiler/testData/codegen/box/visibility/protectedStatic/funCallInConstructor.kt index 99d915b7bdc..a3326d17208 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/funCallInConstructor.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/funCallInConstructor.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funClassObject.kt b/compiler/testData/codegen/box/visibility/protectedStatic/funClassObject.kt index 3faa4ead481..67cb00433a1 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/funClassObject.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/funClassObject.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funGenericClass.kt b/compiler/testData/codegen/box/visibility/protectedStatic/funGenericClass.kt index 51a0e30ad91..089a754dc62 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/funGenericClass.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/funGenericClass.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass.kt b/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass.kt index e0efe3bdd65..89fa4b7b515 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass2.kt b/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass2.kt index 32a9cdf90c7..13af1b980d5 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass2.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass2.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticGenericClass.kt b/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticGenericClass.kt index 5560c5be150..d630e77e5bf 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticGenericClass.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticGenericClass.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funNotDirectSuperClass.kt b/compiler/testData/codegen/box/visibility/protectedStatic/funNotDirectSuperClass.kt index 03135d378d7..ff660512762 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/funNotDirectSuperClass.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/funNotDirectSuperClass.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funObject.kt b/compiler/testData/codegen/box/visibility/protectedStatic/funObject.kt index 4b5dadf113c..88058dc636a 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/funObject.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/funObject.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: J.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/simpleClass.kt b/compiler/testData/codegen/box/visibility/protectedStatic/simpleClass.kt index 65ad32a8258..692b90693b3 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/simpleClass.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/simpleClass.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Base.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/simpleClass2.kt b/compiler/testData/codegen/box/visibility/protectedStatic/simpleClass2.kt index 772826f66eb..ae21dc4feee 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/simpleClass2.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/simpleClass2.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Base.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/simpleFun.kt b/compiler/testData/codegen/box/visibility/protectedStatic/simpleFun.kt index 6bb2c889f85..21d422e3b26 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/simpleFun.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/simpleFun.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Base.java diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/simpleProperty.kt b/compiler/testData/codegen/box/visibility/protectedStatic/simpleProperty.kt index 31d02054642..63f0ccdcc61 100644 --- a/compiler/testData/codegen/box/visibility/protectedStatic/simpleProperty.kt +++ b/compiler/testData/codegen/box/visibility/protectedStatic/simpleProperty.kt @@ -1,4 +1,4 @@ -// DONT_TARGET_EXACT_BACKEND: JS JS_IR JS_IR_ES6 WASM NATIVE +// TARGET_BACKEND: JVM // MODULE: lib // FILE: Base.java From 2d60fa787dcfb343aa0652e5dab22f7c77a94e19 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 10 Feb 2021 21:05:23 +0100 Subject: [PATCH 019/368] Remove codegen tests on old language and API versions --- .../FirBlackBoxCodegenTestGenerated.java | 2 +- ...FirBlackBoxInlineCodegenTestGenerated.java | 2 +- .../codegen/FirBytecodeTextTestGenerated.java | 2 +- ...rInArrayWithArrayVarUpdatedInLoopBody12.kt | 17 -- .../dataClassEqualsHashCodeToString.kt | 18 -- .../functions/bigArity/noBigFunctionTypes.kt | 24 -- .../ieee754/explicitEqualsCallNull.kt | 34 --- .../ieee754/nullableDoubleEquals10.kt | 27 --- .../ieee754/nullableDoubleNotEquals10.kt | 27 --- .../ieee754/nullableFloatEquals10.kt | 27 --- .../ieee754/nullableFloatNotEquals10.kt | 27 --- .../box/oldLanguageVersions/ieee754/when10.kt | 36 --- .../ieee754/whenNullableSmartCast10.kt | 29 --- ...ExtensionReceiverInPrivateOperator_lv11.kt | 17 -- ...bilityAssertionOnExtensionReceiver_lv11.kt | 22 -- ...bilityAssertionOnExtensionReceiver_lv11.kt | 17 -- ...ertionOnInlineFunExtensionReceiver_lv11.kt | 17 -- .../percentAsModOnBigIntegerWithoutRem.kt | 11 - .../primitives/equalsNull_lv11.kt | 39 --- .../accessorsForPrivateConstants.kt | 22 -- .../ieee754/nullableDoubleEquals10.kt | 29 --- .../ieee754/nullableDoubleNotEquals10.kt | 29 --- .../ieee754/nullableFloatEquals10.kt | 29 --- .../ieee754/nullableFloatNotEquals10.kt | 29 --- .../ieee754/smartCastsForDouble10.kt | 24 -- .../ieee754/smartCastsForFloat10.kt | 24 -- .../oldLanguageVersions/ieee754/when10.kt | 34 --- .../ieee754/whenNullableSmartCast10.kt | 33 --- .../noInlineJavaProtectedConstants.kt | 24 -- .../codegen/BlackBoxCodegenTestGenerated.java | 206 ---------------- .../codegen/BytecodeTextTestGenerated.java | 90 ------- .../IrBlackBoxCodegenTestGenerated.java | 2 +- .../codegen/IrBytecodeTextTestGenerated.java | 2 +- .../generators/GenerateJUnit5CompilerTests.kt | 10 +- .../LightAnalysisModeTestGenerated.java | 223 ------------------ .../generators/tests/GenerateJsTests.kt | 2 - .../IrJsCodegenBoxES6TestGenerated.java | 183 -------------- .../IrJsCodegenBoxTestGenerated.java | 183 -------------- .../semantics/JsCodegenBoxTestGenerated.java | 188 --------------- .../IrCodegenBoxWasmTestGenerated.java | 2 +- 40 files changed, 11 insertions(+), 1752 deletions(-) delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray/forInArrayWithArrayVarUpdatedInLoopBody12.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/dataClassEqualsHashCodeToString.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity/noBigFunctionTypes.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/ieee754/explicitEqualsCallNull.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatEquals10.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/ieee754/when10.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver_lv11.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnExtensionReceiver_lv11.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnInlineFunExtensionReceiver_lv11.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/operatorConventions/percentAsModOnBigIntegerWithoutRem.kt delete mode 100644 compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives/equalsNull_lv11.kt delete mode 100644 compiler/testData/codegen/bytecodeText/oldLanguageVersions/constProperty/accessorsForPrivateConstants.kt delete mode 100644 compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt delete mode 100644 compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt delete mode 100644 compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableFloatEquals10.kt delete mode 100644 compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt delete mode 100644 compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/smartCastsForDouble10.kt delete mode 100644 compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/smartCastsForFloat10.kt delete mode 100644 compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/when10.kt delete mode 100644 compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt delete mode 100644 compiler/testData/codegen/bytecodeText/oldLanguageVersions/noInlineJavaProtectedConstants.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index dc3a6dc19af..6574c9ef1dd 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -22,7 +22,7 @@ import java.util.regex.Pattern; public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenTest { @Test public void testAllFilesPresentInBox() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true, "oldLanguageVersions"); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } @Nested diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java index ba89e8032d5..64e8d4ad4a3 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java @@ -22,7 +22,7 @@ import java.util.regex.Pattern; public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxInlineCodegenTest { @Test public void testAllFilesPresentInBoxInline() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true, "oldLanguageVersions"); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } @Nested diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java index 57a684cefb8..8dc66fd9614 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java @@ -40,7 +40,7 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest { @Test public void testAllFilesPresentInBytecodeText() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true, "oldLanguageVersions"); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } @Test diff --git a/compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray/forInArrayWithArrayVarUpdatedInLoopBody12.kt b/compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray/forInArrayWithArrayVarUpdatedInLoopBody12.kt deleted file mode 100644 index 85da5fbe240..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray/forInArrayWithArrayVarUpdatedInLoopBody12.kt +++ /dev/null @@ -1,17 +0,0 @@ -// !LANGUAGE: -ProperForInArrayLoopRangeVariableAssignmentSemantic -// IGNORE_BACKEND: NATIVE -// IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND: JS_IR -// IGNORE_BACKEND: JS_IR_ES6 -// WITH_RUNTIME -// IGNORE_BACKEND: JS - -fun box(): String { - var xs = intArrayOf(1, 2, 3) - var sum = 0 - for (x in xs) { - sum = sum * 10 + x - xs = intArrayOf(4, 5) - } - return if (sum == 15) "OK" else "Fail: $sum" -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/dataClassEqualsHashCodeToString.kt b/compiler/testData/codegen/box/oldLanguageVersions/dataClassEqualsHashCodeToString.kt deleted file mode 100644 index f119ed303d2..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/dataClassEqualsHashCodeToString.kt +++ /dev/null @@ -1,18 +0,0 @@ -// DONT_TARGET_EXACT_BACKEND: WASM -// WASM_MUTE_REASON: IGNORED_IN_JS -// !LANGUAGE: -DataClassInheritance -// IGNORE_BACKEND: JS_IR -// IGNORE_BACKEND: JS_IR_ES6 -// IGNORE_BACKEND: JVM_IR - -data class Foo(val s: String) - -fun box(): String { - val f1 = Foo("OK") - val f2 = Foo("OK") - if (f1 != f2) return "Fail equals" - if (f1.hashCode() != f2.hashCode()) return "Fail hashCode" - if (f1.toString() != f2.toString() || f1.toString() != "Foo(s=OK)") return "Fail toString: $f1 $f2" - - return f1.s -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity/noBigFunctionTypes.kt b/compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity/noBigFunctionTypes.kt deleted file mode 100644 index 88ff5984d07..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity/noBigFunctionTypes.kt +++ /dev/null @@ -1,24 +0,0 @@ -// DONT_TARGET_EXACT_BACKEND: WASM -// WASM_MUTE_REASON: BIG_ARITY -// !LANGUAGE: -FunctionTypesWithBigArity - -// This test does not make sense for JVM because a diagnostic is reported when function types with big arity are not available -// (see diagnostics/tests/sourceCompatibility/noBigFunctionTypes.kt) -// IGNORE_BACKEND: JVM, JVM_IR - -class A - -fun foo( - p00: A, p01: A, p02: A, p03: A, p04: A, p05: A, p06: A, p07: A, p08: A, p09: A, - p10: A, p11: A, p12: A, p13: A, p14: A, p15: A, p16: A, p17: A, p18: A, p19: A, - p20: A, p21: A, p22: A, p23: A, p24: A, p25: A, p26: A, p27: A, p28: A, p29: A -): String = "OK" - -fun bar(x: Function30): String { - val a = A() - return x(a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a) -} - -fun box(): String { - return bar(::foo) -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/explicitEqualsCallNull.kt b/compiler/testData/codegen/box/oldLanguageVersions/ieee754/explicitEqualsCallNull.kt deleted file mode 100644 index aa0dd3479bf..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/explicitEqualsCallNull.kt +++ /dev/null @@ -1,34 +0,0 @@ -// TARGET_BACKEND: JVM -// !LANGUAGE: -ThrowNpeOnExplicitEqualsForBoxedNull -// IGNORE_BACKEND: JVM_IR -// ^ ThrowNpeOnExplicitEqualsForBoxedNull is introduced in 1.2. -// MODULE: lib -// FILE: JavaClass.java - -public class JavaClass { - - public Double minus0(){ - return -0.0; - } - - public Double plus0(){ - return 0.0; - } - - public Double null0(){ - return null; - } - -} - - -// MODULE: main(lib) -// FILE: b.kt - -fun box(): String { - val jClass = JavaClass() - - if (jClass.null0().equals(jClass.plus0())) return "fail 6" - if (jClass.minus0().equals(jClass.null0())) return "fail 7" - return "OK" -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt b/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt deleted file mode 100644 index e1a6605570b..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt +++ /dev/null @@ -1,27 +0,0 @@ -// !API_VERSION: 1.0 - -fun myEquals(a: Double?, b: Double?) = a == b - -fun myEquals1(a: Double?, b: Double) = a == b - -fun myEquals2(a: Double, b: Double?) = a == b - -fun myEquals0(a: Double, b: Double) = a == b - - -fun box(): String { - if (!myEquals(null, null)) return "fail 1" - if (myEquals(null, 0.0)) return "fail 2" - if (myEquals(0.0, null)) return "fail 3" - if (!myEquals(0.0, 0.0)) return "fail 4" - - if (myEquals1(null, 0.0)) return "fail 5" - if (!myEquals1(0.0, 0.0)) return "fail 6" - - if (myEquals2(0.0, null)) return "fail 7" - if (!myEquals2(0.0, 0.0)) return "fail 8" - - if (!myEquals0(0.0, 0.0)) return "fail 9" - - return "OK" -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt b/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt deleted file mode 100644 index bbe5a8ab196..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt +++ /dev/null @@ -1,27 +0,0 @@ -// !API_VERSION: 1.0 - -fun myNotEquals(a: Double?, b: Double?) = a != b - -fun myNotEquals1(a: Double?, b: Double) = a != b - -fun myNotEquals2(a: Double, b: Double?) = a != b - -fun myNotEquals0(a: Double, b: Double) = a != b - - -fun box(): String { - if (myNotEquals(null, null)) return "fail 1" - if (!myNotEquals(null, 0.0)) return "fail 2" - if (!myNotEquals(0.0, null)) return "fail 3" - if (myNotEquals(0.0, 0.0)) return "fail 4" - - if (!myNotEquals1(null, 0.0)) return "fail 5" - if (myNotEquals1(0.0, 0.0)) return "fail 6" - - if (!myNotEquals2(0.0, null)) return "fail 7" - if (myNotEquals2(0.0, 0.0)) return "fail 8" - - if (myNotEquals0(0.0, 0.0)) return "fail 9" - - return "OK" -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatEquals10.kt b/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatEquals10.kt deleted file mode 100644 index 24cd16fb594..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatEquals10.kt +++ /dev/null @@ -1,27 +0,0 @@ -// !API_VERSION: 1.0 - -fun myEquals(a: Float?, b: Float?) = a == b - -fun myEquals1(a: Float?, b: Float) = a == b - -fun myEquals2(a: Float, b: Float?) = a == b - -fun myEquals0(a: Float, b: Float) = a == b - - -fun box(): String { - if (!myEquals(null, null)) return "fail 1" - if (myEquals(null, 0.0F)) return "fail 2" - if (myEquals(0.0F, null)) return "fail 3" - if (!myEquals(0.0F, 0.0F)) return "fail 4" - - if (myEquals1(null, 0.0F)) return "fail 5" - if (!myEquals1(0.0F, 0.0F)) return "fail 6" - - if (myEquals2(0.0F, null)) return "fail 7" - if (!myEquals2(0.0F, 0.0F)) return "fail 8" - - if (!myEquals0(0.0F, 0.0F)) return "fail 9" - - return "OK" -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt b/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt deleted file mode 100644 index ce2657cbe19..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt +++ /dev/null @@ -1,27 +0,0 @@ -// !API_VERSION: 1.0 - -fun myNotEquals(a: Float?, b: Float?) = a != b - -fun myNotEquals1(a: Float?, b: Float) = a != b - -fun myNotEquals2(a: Float, b: Float?) = a != b - -fun myNotEquals0(a: Float, b: Float) = a != b - - -fun box(): String { - if (myNotEquals(null, null)) return "fail 1" - if (!myNotEquals(null, 0.0F)) return "fail 2" - if (!myNotEquals(0.0F, null)) return "fail 3" - if (myNotEquals(0.0F, 0.0F)) return "fail 4" - - if (!myNotEquals1(null, 0.0F)) return "fail 5" - if (myNotEquals1(0.0F, 0.0F)) return "fail 6" - - if (!myNotEquals2(0.0F, null)) return "fail 7" - if (myNotEquals2(0.0F, 0.0F)) return "fail 8" - - if (myNotEquals0(0.0F, 0.0F)) return "fail 9" - - return "OK" -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/when10.kt b/compiler/testData/codegen/box/oldLanguageVersions/ieee754/when10.kt deleted file mode 100644 index 240f4758409..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/when10.kt +++ /dev/null @@ -1,36 +0,0 @@ -// !LANGUAGE: -ProperIeee754Comparisons -// !API_VERSION: 1.0 -// IGNORE_BACKEND: NATIVE -// DONT_TARGET_EXACT_BACKEND: JS_IR -// DONT_TARGET_EXACT_BACKEND: JS_IR_ES6 - -fun box(): String { - val plusZero: Any = 0.0 - val minusZero: Any = -0.0 - val nullDouble: Double? = null - if (plusZero is Double) { - when (plusZero) { - nullDouble -> { - return "fail 1" - } - -0.0 -> { - return "fail 2" - } - else -> {} - } - - if (minusZero is Double) { - when (plusZero) { - nullDouble -> { - return "fail 3" - } - minusZero -> { - return "fail 4" - } - else -> {} - } - } - } - - return "OK" -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt b/compiler/testData/codegen/box/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt deleted file mode 100644 index 6db9a8bccea..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt +++ /dev/null @@ -1,29 +0,0 @@ -// !API_VERSION: 1.0 - -fun box(): String { - val nullValue: Any? = null - val nullDouble: Double? = null - val minusZero: Any = -0.0 - if (nullValue is Double?) { - when (nullValue) { - -0.0 -> { - return "fail 1" - } - nullDouble -> {} - else -> return "fail 2" - } - - if (minusZero is Double) { - when (nullValue) { - minusZero -> { - return "fail 3" - } - nullDouble -> { - } - else -> return "fail 4" - } - } - - } - return "OK" -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt b/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt deleted file mode 100644 index 7930d4caa95..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt +++ /dev/null @@ -1,17 +0,0 @@ -// !LANGUAGE: -NullabilityAssertionOnExtensionReceiver -// TARGET_BACKEND: JVM -// WITH_RUNTIME -// FILE: test.kt -private operator fun A.inc() = A() - -fun box(): String { - var aNull = A.n() - aNull++ - // NB no exception is thrown in language version 1.1 - return "OK" -} - -// FILE: A.java -public class A { - public static A n() { return null; } -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver_lv11.kt b/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver_lv11.kt deleted file mode 100644 index 32e4fb1942b..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver_lv11.kt +++ /dev/null @@ -1,22 +0,0 @@ -// !LANGUAGE: -NullabilityAssertionOnExtensionReceiver -// TARGET_BACKEND: JVM -// WITH_RUNTIME -// FILE: test.kt - -import kotlin.test.* - -operator fun A.inc() = A() - -fun box(): String { - assertFailsWith { - var aNull = A.n() - aNull++ - } - - return "OK" -} - -// FILE: A.java -public class A { - public static A n() { return null; } -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnExtensionReceiver_lv11.kt b/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnExtensionReceiver_lv11.kt deleted file mode 100644 index 8751d513e31..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnExtensionReceiver_lv11.kt +++ /dev/null @@ -1,17 +0,0 @@ -// !LANGUAGE: -NullabilityAssertionOnExtensionReceiver -// TARGET_BACKEND: JVM -// WITH_RUNTIME -// FILE: test.kt -import kotlin.test.* - -fun String.extension() {} - -fun box(): String { - assertFailsWith { J.s().extension() } - return "OK" -} - -// FILE: J.java -public class J { - public static String s() { return null; } -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnInlineFunExtensionReceiver_lv11.kt b/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnInlineFunExtensionReceiver_lv11.kt deleted file mode 100644 index 46f7045be64..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnInlineFunExtensionReceiver_lv11.kt +++ /dev/null @@ -1,17 +0,0 @@ -// !LANGUAGE: -NullabilityAssertionOnExtensionReceiver -// TARGET_BACKEND: JVM -// WITH_RUNTIME -// FILE: test.kt -import kotlin.test.* - -inline fun String.extension() {} - -fun box(): String { - J.s().extension() // NB no exception thrown - return "OK" -} - -// FILE: J.java -public class J { - public static String s() { return null; } -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/oldLanguageVersions/operatorConventions/percentAsModOnBigIntegerWithoutRem.kt b/compiler/testData/codegen/box/oldLanguageVersions/operatorConventions/percentAsModOnBigIntegerWithoutRem.kt deleted file mode 100644 index 5ee8a146904..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/operatorConventions/percentAsModOnBigIntegerWithoutRem.kt +++ /dev/null @@ -1,11 +0,0 @@ -// !LANGUAGE: -ProhibitOperatorMod -// !API_VERSION: 1.0 -// TARGET_BACKEND: JVM -// FULL_JDK - -import java.math.BigInteger - -fun box(): String { - val m = BigInteger.valueOf(-2) % BigInteger.valueOf(3) - return if (m != BigInteger.valueOf(1)) "Fail: BigInteger(-2) mod BigInteger(3) == $m" else "OK" -} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives/equalsNull_lv11.kt b/compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives/equalsNull_lv11.kt deleted file mode 100644 index a930ab8fe66..00000000000 --- a/compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives/equalsNull_lv11.kt +++ /dev/null @@ -1,39 +0,0 @@ -// !LANGUAGE: -ThrowNpeOnExplicitEqualsForBoxedNull -// TARGET_BACKEND: JVM -// WITH_RUNTIME -// FILE: test.kt -import kotlin.test.* - -fun box(): String { - assertEquals(J.BOOL_NULL.equals(null), true) - assertEquals(J.CHAR_NULL.equals(null), true) - assertEquals(J.BYTE_NULL.equals(null), true) - assertEquals(J.SHORT_NULL.equals(null), true) - assertEquals(J.INT_NULL.equals(null), true) - assertEquals(J.LONG_NULL.equals(null), true) - assertEquals(J.FLOAT_NULL.equals(null), true) - assertEquals(J.DOUBLE_NULL.equals(null), true) - - assertEquals(J.BOOL_NULL == null, true) - assertEquals(J.CHAR_NULL == null, true) - assertEquals(J.BYTE_NULL == null, true) - assertEquals(J.SHORT_NULL == null, true) - assertEquals(J.INT_NULL == null, true) - assertEquals(J.LONG_NULL == null, true) - assertEquals(J.FLOAT_NULL == null, true) - assertEquals(J.DOUBLE_NULL == null, true) - - return "OK" -} - -// FILE: J.java -public class J { - public static Boolean BOOL_NULL = null; - public static Character CHAR_NULL = null; - public static Byte BYTE_NULL = null; - public static Short SHORT_NULL = null; - public static Integer INT_NULL = null; - public static Long LONG_NULL = null; - public static Float FLOAT_NULL = null; - public static Double DOUBLE_NULL = null; -} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/constProperty/accessorsForPrivateConstants.kt b/compiler/testData/codegen/bytecodeText/oldLanguageVersions/constProperty/accessorsForPrivateConstants.kt deleted file mode 100644 index 67403ba71aa..00000000000 --- a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/constProperty/accessorsForPrivateConstants.kt +++ /dev/null @@ -1,22 +0,0 @@ -// !LANGUAGE: -InlineConstVals -// IGNORE_BACKEND: JVM_IR -// FILE: Foo.kt - -private const val OUTER_PRIVATE = 20 - -class Foo { - companion object { - private const val LOCAL_PRIVATE = 20 - } - - fun foo() { - // Access to the property use getstatic on the backed field - LOCAL_PRIVATE - // Access to the property requires an invokestatic - OUTER_PRIVATE - } -} - -// 1 INVOKESTATIC -// 1 PUTSTATIC -// 2 GETSTATIC diff --git a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt b/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt deleted file mode 100644 index c85ee6793b9..00000000000 --- a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt +++ /dev/null @@ -1,29 +0,0 @@ -// !API_VERSION: 1.0 - -fun myEquals(a: Double?, b: Double?) = a == b - -fun myEquals1(a: Double?, b: Double) = a == b - -fun myEquals2(a: Double, b: Double?) = a == b - -fun myEquals0(a: Double, b: Double) = a == b - - -fun box(): String { - if (!myEquals(null, null)) return "fail 1" - if (myEquals(null, 0.0)) return "fail 2" - if (myEquals(0.0, null)) return "fail 3" - if (!myEquals(0.0, 0.0)) return "fail 4" - - if (myEquals1(null, 0.0)) return "fail 5" - if (!myEquals1(0.0, 0.0)) return "fail 6" - - if (myEquals2(0.0, null)) return "fail 7" - if (!myEquals2(0.0, 0.0)) return "fail 8" - - if (!myEquals0(0.0, 0.0)) return "fail 9" - - return "OK" -} - -// 0 areEqual diff --git a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt b/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt deleted file mode 100644 index eccf8822717..00000000000 --- a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt +++ /dev/null @@ -1,29 +0,0 @@ -// !API_VERSION: 1.0 - -fun myNotEquals(a: Double?, b: Double?) = a != b - -fun myNotEquals1(a: Double?, b: Double) = a != b - -fun myNotEquals2(a: Double, b: Double?) = a != b - -fun myNotEquals0(a: Double, b: Double) = a != b - - -fun box(): String { - if (myNotEquals(null, null)) return "fail 1" - if (!myNotEquals(null, 0.0)) return "fail 2" - if (!myNotEquals(0.0, null)) return "fail 3" - if (myNotEquals(0.0, 0.0)) return "fail 4" - - if (!myNotEquals1(null, 0.0)) return "fail 5" - if (myNotEquals1(0.0, 0.0)) return "fail 6" - - if (!myNotEquals2(0.0, null)) return "fail 7" - if (myNotEquals2(0.0, 0.0)) return "fail 8" - - if (myNotEquals0(0.0, 0.0)) return "fail 9" - - return "OK" -} - -// 0 areEqual diff --git a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableFloatEquals10.kt b/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableFloatEquals10.kt deleted file mode 100644 index d362657b066..00000000000 --- a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableFloatEquals10.kt +++ /dev/null @@ -1,29 +0,0 @@ -// !API_VERSION: 1.0 - -fun myEquals(a: Float?, b: Float?) = a == b - -fun myEquals1(a: Float?, b: Float) = a == b - -fun myEquals2(a: Float, b: Float?) = a == b - -fun myEquals0(a: Float, b: Float) = a == b - - -fun box(): String { - if (!myEquals(null, null)) return "fail 1" - if (myEquals(null, 0.0F)) return "fail 2" - if (myEquals(0.0F, null)) return "fail 3" - if (!myEquals(0.0F, 0.0F)) return "fail 4" - - if (myEquals1(null, 0.0F)) return "fail 5" - if (!myEquals1(0.0F, 0.0F)) return "fail 6" - - if (myEquals2(0.0F, null)) return "fail 7" - if (!myEquals2(0.0F, 0.0F)) return "fail 8" - - if (!myEquals0(0.0F, 0.0F)) return "fail 9" - - return "OK" -} - -// 0 areEqual diff --git a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt b/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt deleted file mode 100644 index fa42ff1511c..00000000000 --- a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt +++ /dev/null @@ -1,29 +0,0 @@ -// !API_VERSION: 1.0 - -fun myNotEquals(a: Float?, b: Float?) = a != b - -fun myNotEquals1(a: Float?, b: Float) = a != b - -fun myNotEquals2(a: Float, b: Float?) = a != b - -fun myNotEquals0(a: Float, b: Float) = a != b - - -fun box(): String { - if (myNotEquals(null, null)) return "fail 1" - if (!myNotEquals(null, 0.0F)) return "fail 2" - if (!myNotEquals(0.0F, null)) return "fail 3" - if (myNotEquals(0.0F, 0.0F)) return "fail 4" - - if (!myNotEquals1(null, 0.0F)) return "fail 5" - if (myNotEquals1(0.0F, 0.0F)) return "fail 6" - - if (!myNotEquals2(0.0F, null)) return "fail 7" - if (myNotEquals2(0.0F, 0.0F)) return "fail 8" - - if (myNotEquals0(0.0F, 0.0F)) return "fail 9" - - return "OK" -} - -// 0 areEqual diff --git a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/smartCastsForDouble10.kt b/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/smartCastsForDouble10.kt deleted file mode 100644 index 75875819434..00000000000 --- a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/smartCastsForDouble10.kt +++ /dev/null @@ -1,24 +0,0 @@ -// !API_VERSION: 1.0 -// !LANGUAGE: -ProperIeee754Comparisons - -fun equals5(a: Any?, b: Any?) = if (a is Double && b is Double?) a == b else null!! - -fun equals6(a: Any?, b: Any?) = if (a is Double? && b is Double) a == b else null!! - -fun equals8(a: Any?, b: Any?) = if (a is Double? && b is Double?) a == b else null!! - - -fun box(): String { - if (!equals5(-0.0, 0.0)) return "fail 5" - if (!equals6(-0.0, 0.0)) return "fail 6" - - if (!equals8(-0.0, 0.0)) return "fail 8" - if (!equals8(null, null)) return "fail 9" - if (equals8(null, 0.0)) return "fail 10" - if (equals8(0.0, null)) return "fail 11" - - return "OK" -} - -// 3 areEqual \(Ljava/lang/Object;Ljava/lang/Object;\)Z -// 3 areEqual diff --git a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/smartCastsForFloat10.kt b/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/smartCastsForFloat10.kt deleted file mode 100644 index 7499ab00d36..00000000000 --- a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/smartCastsForFloat10.kt +++ /dev/null @@ -1,24 +0,0 @@ -// !API_VERSION: 1.0 -// !LANGUAGE: -ProperIeee754Comparisons - -fun equals5(a: Any?, b: Any?) = if (a is Float && b is Float?) a == b else null!! - -fun equals6(a: Any?, b: Any?) = if (a is Float? && b is Float) a == b else null!! - -fun equals8(a: Any?, b: Any?) = if (a is Float? && b is Float?) a == b else null!! - - -fun box(): String { - if (!equals5(-0.0F, 0.0F)) return "fail 5" - if (!equals6(-0.0F, 0.0F)) return "fail 6" - - if (!equals8(-0.0F, 0.0F)) return "fail 8" - if (!equals8(null, null)) return "fail 9" - if (equals8(null, 0.0F)) return "fail 10" - if (equals8(0.0F, null)) return "fail 11" - - return "OK" -} - -// 3 areEqual \(Ljava/lang/Object;Ljava/lang/Object;\)Z -// 3 areEqual diff --git a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/when10.kt b/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/when10.kt deleted file mode 100644 index ceb62e6dbe3..00000000000 --- a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/when10.kt +++ /dev/null @@ -1,34 +0,0 @@ -// !API_VERSION: 1.0 -// !LANGUAGE: -ProperIeee754Comparisons - -fun box(): String { - val plusZero: Any = 0.0 - val minusZero: Any = -0.0 - val nullDouble: Double? = null - if (plusZero is Double) { - when (plusZero) { - nullDouble -> { - return "fail 1" - } - -0.0 -> { - } - else -> return "fail 2" - } - - if (minusZero is Double) { - when (plusZero) { - nullDouble -> { - return "fail 3" - } - minusZero -> { - } - else -> return "fail 4" - } - } - } - - return "OK" -} - -// 4 areEqual \(Ljava/lang/Object;Ljava/lang/Object;\)Z -// 4 areEqual diff --git a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt b/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt deleted file mode 100644 index 2446ec3b043..00000000000 --- a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt +++ /dev/null @@ -1,33 +0,0 @@ -// !API_VERSION: 1.0 -// !LANGUAGE: -ProperIeee754Comparisons - -fun box(): String { - val nullValue: Any? = null - val nullDouble: Double? = null - val minusZero: Any = -0.0 - if (nullValue is Double?) { - when (nullValue) { - -0.0 -> { - return "fail 1" - } - nullDouble -> {} - else -> return "fail 2" - } - - if (minusZero is Double) { - when (nullValue) { - minusZero -> { - return "fail 3" - } - nullDouble -> { - } - else -> return "fail 4" - } - } - - } - return "OK" -} - -// 4 areEqual \(Ljava/lang/Object;Ljava/lang/Object;\)Z -// 4 areEqual diff --git a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/noInlineJavaProtectedConstants.kt b/compiler/testData/codegen/bytecodeText/oldLanguageVersions/noInlineJavaProtectedConstants.kt deleted file mode 100644 index 87bf497da50..00000000000 --- a/compiler/testData/codegen/bytecodeText/oldLanguageVersions/noInlineJavaProtectedConstants.kt +++ /dev/null @@ -1,24 +0,0 @@ -// !LANGUAGE: -InlineConstVals -// IGNORE_BACKEND: JVM_IR -// FILE: first/Foo.java - -package first; - -public class Foo { - protected static final int FOO = 42; -} - -// FILE: bar.kt - -package second - -import first.Foo - -class Bar : Foo() { - fun bar() = FOO -} - -// @second/BarKt.class -// 1 INVOKESTATIC -// 0 GETSTATIC -// 1 BIPUSH 42 diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index c82a52bc9ba..8884fc2aeb7 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -24927,212 +24927,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } - @Nested - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions") - @TestDataPath("$PROJECT_ROOT") - public class OldLanguageVersions { - @Test - public void testAllFilesPresentInOldLanguageVersions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("dataClassEqualsHashCodeToString.kt") - public void testDataClassEqualsHashCodeToString() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/dataClassEqualsHashCodeToString.kt"); - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/controlStructures") - @TestDataPath("$PROJECT_ROOT") - public class ControlStructures { - @Test - public void testAllFilesPresentInControlStructures() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/controlStructures"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray") - @TestDataPath("$PROJECT_ROOT") - public class ForInArray { - @Test - public void testAllFilesPresentInForInArray() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("forInArrayWithArrayVarUpdatedInLoopBody12.kt") - public void testForInArrayWithArrayVarUpdatedInLoopBody12() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray/forInArrayWithArrayVarUpdatedInLoopBody12.kt"); - } - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/functions") - @TestDataPath("$PROJECT_ROOT") - public class Functions { - @Test - public void testAllFilesPresentInFunctions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/functions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity") - @TestDataPath("$PROJECT_ROOT") - public class BigArity { - @Test - public void testAllFilesPresentInBigArity() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("noBigFunctionTypes.kt") - public void testNoBigFunctionTypes() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity/noBigFunctionTypes.kt"); - } - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/ieee754") - @TestDataPath("$PROJECT_ROOT") - public class Ieee754 { - @Test - public void testAllFilesPresentInIeee754() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("explicitEqualsCallNull.kt") - public void testExplicitEqualsCallNull() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/explicitEqualsCallNull.kt"); - } - - @Test - @TestMetadata("nullableDoubleEquals10.kt") - public void testNullableDoubleEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt"); - } - - @Test - @TestMetadata("nullableDoubleNotEquals10.kt") - public void testNullableDoubleNotEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt"); - } - - @Test - @TestMetadata("nullableFloatEquals10.kt") - public void testNullableFloatEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatEquals10.kt"); - } - - @Test - @TestMetadata("nullableFloatNotEquals10.kt") - public void testNullableFloatNotEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt"); - } - - @Test - @TestMetadata("when10.kt") - public void testWhen10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/when10.kt"); - } - - @Test - @TestMetadata("whenNullableSmartCast10.kt") - public void testWhenNullableSmartCast10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt"); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/javaInterop") - @TestDataPath("$PROJECT_ROOT") - public class JavaInterop { - @Test - public void testAllFilesPresentInJavaInterop() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions") - @TestDataPath("$PROJECT_ROOT") - public class NotNullAssertions { - @Test - public void testAllFilesPresentInNotNullAssertions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt") - public void testIncWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt"); - } - - @Test - @TestMetadata("incWithNullabilityAssertionOnExtensionReceiver_lv11.kt") - public void testIncWithNullabilityAssertionOnExtensionReceiver_lv11() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver_lv11.kt"); - } - - @Test - @TestMetadata("nullabilityAssertionOnExtensionReceiver_lv11.kt") - public void testNullabilityAssertionOnExtensionReceiver_lv11() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnExtensionReceiver_lv11.kt"); - } - - @Test - @TestMetadata("nullabilityAssertionOnInlineFunExtensionReceiver_lv11.kt") - public void testNullabilityAssertionOnInlineFunExtensionReceiver_lv11() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnInlineFunExtensionReceiver_lv11.kt"); - } - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions") - @TestDataPath("$PROJECT_ROOT") - public class OperatorConventions { - @Test - public void testAllFilesPresentInOperatorConventions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("percentAsModOnBigIntegerWithoutRem.kt") - public void testPercentAsModOnBigIntegerWithoutRem() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions/percentAsModOnBigIntegerWithoutRem.kt"); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/platformTypes") - @TestDataPath("$PROJECT_ROOT") - public class PlatformTypes { - @Test - public void testAllFilesPresentInPlatformTypes() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/platformTypes"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives") - @TestDataPath("$PROJECT_ROOT") - public class Primitives { - @Test - public void testAllFilesPresentInPrimitives() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("equalsNull_lv11.kt") - public void testEqualsNull_lv11() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives/equalsNull_lv11.kt"); - } - } - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/operatorConventions") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java index 43e6f54d190..2f284b56585 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java @@ -4507,96 +4507,6 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { } } - @Nested - @TestMetadata("compiler/testData/codegen/bytecodeText/oldLanguageVersions") - @TestDataPath("$PROJECT_ROOT") - public class OldLanguageVersions { - @Test - public void testAllFilesPresentInOldLanguageVersions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/oldLanguageVersions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("noInlineJavaProtectedConstants.kt") - public void testNoInlineJavaProtectedConstants() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/oldLanguageVersions/noInlineJavaProtectedConstants.kt"); - } - - @Nested - @TestMetadata("compiler/testData/codegen/bytecodeText/oldLanguageVersions/constProperty") - @TestDataPath("$PROJECT_ROOT") - public class ConstProperty { - @Test - @TestMetadata("accessorsForPrivateConstants.kt") - public void testAccessorsForPrivateConstants() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/oldLanguageVersions/constProperty/accessorsForPrivateConstants.kt"); - } - - @Test - public void testAllFilesPresentInConstProperty() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/oldLanguageVersions/constProperty"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754") - @TestDataPath("$PROJECT_ROOT") - public class Ieee754 { - @Test - public void testAllFilesPresentInIeee754() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("nullableDoubleEquals10.kt") - public void testNullableDoubleEquals10() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt"); - } - - @Test - @TestMetadata("nullableDoubleNotEquals10.kt") - public void testNullableDoubleNotEquals10() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt"); - } - - @Test - @TestMetadata("nullableFloatEquals10.kt") - public void testNullableFloatEquals10() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableFloatEquals10.kt"); - } - - @Test - @TestMetadata("nullableFloatNotEquals10.kt") - public void testNullableFloatNotEquals10() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt"); - } - - @Test - @TestMetadata("smartCastsForDouble10.kt") - public void testSmartCastsForDouble10() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/smartCastsForDouble10.kt"); - } - - @Test - @TestMetadata("smartCastsForFloat10.kt") - public void testSmartCastsForFloat10() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/smartCastsForFloat10.kt"); - } - - @Test - @TestMetadata("when10.kt") - public void testWhen10() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/when10.kt"); - } - - @Test - @TestMetadata("whenNullableSmartCast10.kt") - public void testWhenNullableSmartCast10() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt"); - } - } - } - @Nested @TestMetadata("compiler/testData/codegen/bytecodeText/optimizedDelegatedProperties") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 21a799582d4..3d26247b4ba 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -22,7 +22,7 @@ import java.util.regex.Pattern; public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTest { @Test public void testAllFilesPresentInBox() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true, "oldLanguageVersions"); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } @Nested diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java index de081a57448..db61e2845a4 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java @@ -40,7 +40,7 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { @Test public void testAllFilesPresentInBytecodeText() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true, "oldLanguageVersions"); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } @Test diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt index 15b26f7860a..5efc4bfc47c 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt @@ -65,7 +65,7 @@ fun generateJUnit5CompilerTests(args: Array) { } testClass { - model("codegen/box", excludeDirs = listOf("oldLanguageVersions")) + model("codegen/box") } testClass { @@ -85,7 +85,7 @@ fun generateJUnit5CompilerTests(args: Array) { } testClass { - model("codegen/bytecodeText", excludeDirs = listOf("oldLanguageVersions")) + model("codegen/bytecodeText") } testClass { @@ -124,11 +124,11 @@ fun generateJUnit5CompilerTests(args: Array) { testGroup(testsRoot = "compiler/fir/fir2ir/tests-gen", testDataRoot = "compiler/testData") { testClass { - model("codegen/box", excludeDirs = listOf("oldLanguageVersions")) + model("codegen/box") } testClass { - model("codegen/boxInline", excludeDirs = listOf("oldLanguageVersions")) + model("codegen/boxInline") } } @@ -152,7 +152,7 @@ fun generateJUnit5CompilerTests(args: Array) { } testClass { - model("codegen/bytecodeText", excludeDirs = listOf("oldLanguageVersions")) + model("codegen/bytecodeText") } } } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 6150d21095b..ca8036bff73 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -21178,229 +21178,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class OldLanguageVersions extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInOldLanguageVersions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("dataClassEqualsHashCodeToString.kt") - public void testDataClassEqualsHashCodeToString() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/dataClassEqualsHashCodeToString.kt"); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/controlStructures") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ControlStructures extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInControlStructures() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/controlStructures"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ForInArray extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInForInArray() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("forInArrayWithArrayVarUpdatedInLoopBody12.kt") - public void testForInArrayWithArrayVarUpdatedInLoopBody12() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray/forInArrayWithArrayVarUpdatedInLoopBody12.kt"); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/functions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Functions extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInFunctions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/functions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class BigArity extends AbstractLightAnalysisModeTest { - @TestMetadata("noBigFunctionTypes.kt") - public void ignoreNoBigFunctionTypes() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity/noBigFunctionTypes.kt"); - } - - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInBigArity() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/ieee754") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Ieee754 extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInIeee754() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("explicitEqualsCallNull.kt") - public void testExplicitEqualsCallNull() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/explicitEqualsCallNull.kt"); - } - - @TestMetadata("nullableDoubleEquals10.kt") - public void testNullableDoubleEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt"); - } - - @TestMetadata("nullableDoubleNotEquals10.kt") - public void testNullableDoubleNotEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt"); - } - - @TestMetadata("nullableFloatEquals10.kt") - public void testNullableFloatEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatEquals10.kt"); - } - - @TestMetadata("nullableFloatNotEquals10.kt") - public void testNullableFloatNotEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt"); - } - - @TestMetadata("when10.kt") - public void testWhen10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/when10.kt"); - } - - @TestMetadata("whenNullableSmartCast10.kt") - public void testWhenNullableSmartCast10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt"); - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/javaInterop") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class JavaInterop extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInJavaInterop() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NotNullAssertions extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInNotNullAssertions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt") - public void testIncWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt"); - } - - @TestMetadata("incWithNullabilityAssertionOnExtensionReceiver_lv11.kt") - public void testIncWithNullabilityAssertionOnExtensionReceiver_lv11() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver_lv11.kt"); - } - - @TestMetadata("nullabilityAssertionOnExtensionReceiver_lv11.kt") - public void testNullabilityAssertionOnExtensionReceiver_lv11() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnExtensionReceiver_lv11.kt"); - } - - @TestMetadata("nullabilityAssertionOnInlineFunExtensionReceiver_lv11.kt") - public void testNullabilityAssertionOnInlineFunExtensionReceiver_lv11() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/nullabilityAssertionOnInlineFunExtensionReceiver_lv11.kt"); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class OperatorConventions extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInOperatorConventions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("percentAsModOnBigIntegerWithoutRem.kt") - public void testPercentAsModOnBigIntegerWithoutRem() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions/percentAsModOnBigIntegerWithoutRem.kt"); - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/platformTypes") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class PlatformTypes extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInPlatformTypes() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/platformTypes"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Primitives extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInPrimitives() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("equalsNull_lv11.kt") - public void testEqualsNull_lv11() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives/equalsNull_lv11.kt"); - } - } - } - } - @TestMetadata("compiler/testData/codegen/box/operatorConventions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt index 30f955daf95..84438d9a968 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt @@ -103,8 +103,6 @@ fun main(args: Array) { // TODO: Support delegated properties "delegatedProperty", - "oldLanguageVersions", - "compileKotlinAgainstKotlin" ) ) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index f1413024a07..22e16155bb8 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -17078,189 +17078,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class OldLanguageVersions extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInOldLanguageVersions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - - @TestMetadata("dataClassEqualsHashCodeToString.kt") - public void testDataClassEqualsHashCodeToString() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/dataClassEqualsHashCodeToString.kt"); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/controlStructures") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ControlStructures extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInControlStructures() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/controlStructures"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ForInArray extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInForInArray() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - - @TestMetadata("forInArrayWithArrayVarUpdatedInLoopBody12.kt") - public void testForInArrayWithArrayVarUpdatedInLoopBody12() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray/forInArrayWithArrayVarUpdatedInLoopBody12.kt"); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/functions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Functions extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInFunctions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/functions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class BigArity extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInBigArity() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - - @TestMetadata("noBigFunctionTypes.kt") - public void testNoBigFunctionTypes() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity/noBigFunctionTypes.kt"); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/ieee754") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Ieee754 extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInIeee754() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - - @TestMetadata("nullableDoubleEquals10.kt") - public void testNullableDoubleEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt"); - } - - @TestMetadata("nullableDoubleNotEquals10.kt") - public void testNullableDoubleNotEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt"); - } - - @TestMetadata("nullableFloatEquals10.kt") - public void testNullableFloatEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatEquals10.kt"); - } - - @TestMetadata("nullableFloatNotEquals10.kt") - public void testNullableFloatNotEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt"); - } - - @TestMetadata("whenNullableSmartCast10.kt") - public void testWhenNullableSmartCast10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt"); - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/javaInterop") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class JavaInterop extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInJavaInterop() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NotNullAssertions extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInNotNullAssertions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class OperatorConventions extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInOperatorConventions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/platformTypes") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class PlatformTypes extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInPlatformTypes() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/platformTypes"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Primitives extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInPrimitives() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - } - } - @TestMetadata("compiler/testData/codegen/box/operatorConventions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 9ece45229a7..35a5b27b444 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -16563,189 +16563,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class OldLanguageVersions extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInOldLanguageVersions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - - @TestMetadata("dataClassEqualsHashCodeToString.kt") - public void testDataClassEqualsHashCodeToString() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/dataClassEqualsHashCodeToString.kt"); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/controlStructures") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ControlStructures extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInControlStructures() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/controlStructures"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ForInArray extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInForInArray() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - - @TestMetadata("forInArrayWithArrayVarUpdatedInLoopBody12.kt") - public void testForInArrayWithArrayVarUpdatedInLoopBody12() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray/forInArrayWithArrayVarUpdatedInLoopBody12.kt"); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/functions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Functions extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInFunctions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/functions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class BigArity extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInBigArity() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - - @TestMetadata("noBigFunctionTypes.kt") - public void testNoBigFunctionTypes() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity/noBigFunctionTypes.kt"); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/ieee754") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Ieee754 extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInIeee754() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - - @TestMetadata("nullableDoubleEquals10.kt") - public void testNullableDoubleEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt"); - } - - @TestMetadata("nullableDoubleNotEquals10.kt") - public void testNullableDoubleNotEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt"); - } - - @TestMetadata("nullableFloatEquals10.kt") - public void testNullableFloatEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatEquals10.kt"); - } - - @TestMetadata("nullableFloatNotEquals10.kt") - public void testNullableFloatNotEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt"); - } - - @TestMetadata("whenNullableSmartCast10.kt") - public void testWhenNullableSmartCast10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt"); - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/javaInterop") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class JavaInterop extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInJavaInterop() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NotNullAssertions extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInNotNullAssertions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class OperatorConventions extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInOperatorConventions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/platformTypes") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class PlatformTypes extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInPlatformTypes() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/platformTypes"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Primitives extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInPrimitives() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - } - } - @TestMetadata("compiler/testData/codegen/box/operatorConventions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 09b27b46438..19c1f9409d1 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -16628,194 +16628,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class OldLanguageVersions extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInOldLanguageVersions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - - @TestMetadata("dataClassEqualsHashCodeToString.kt") - public void testDataClassEqualsHashCodeToString() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/dataClassEqualsHashCodeToString.kt"); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/controlStructures") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ControlStructures extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInControlStructures() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/controlStructures"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ForInArray extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInForInArray() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - - @TestMetadata("forInArrayWithArrayVarUpdatedInLoopBody12.kt") - public void testForInArrayWithArrayVarUpdatedInLoopBody12() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/controlStructures/forInArray/forInArrayWithArrayVarUpdatedInLoopBody12.kt"); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/functions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Functions extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInFunctions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/functions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class BigArity extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInBigArity() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - - @TestMetadata("noBigFunctionTypes.kt") - public void testNoBigFunctionTypes() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/functions/bigArity/noBigFunctionTypes.kt"); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/ieee754") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Ieee754 extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInIeee754() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - - @TestMetadata("nullableDoubleEquals10.kt") - public void testNullableDoubleEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleEquals10.kt"); - } - - @TestMetadata("nullableDoubleNotEquals10.kt") - public void testNullableDoubleNotEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableDoubleNotEquals10.kt"); - } - - @TestMetadata("nullableFloatEquals10.kt") - public void testNullableFloatEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatEquals10.kt"); - } - - @TestMetadata("nullableFloatNotEquals10.kt") - public void testNullableFloatNotEquals10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/nullableFloatNotEquals10.kt"); - } - - @TestMetadata("when10.kt") - public void testWhen10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/when10.kt"); - } - - @TestMetadata("whenNullableSmartCast10.kt") - public void testWhenNullableSmartCast10() throws Exception { - runTest("compiler/testData/codegen/box/oldLanguageVersions/ieee754/whenNullableSmartCast10.kt"); - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/javaInterop") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class JavaInterop extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInJavaInterop() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/javaInterop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NotNullAssertions extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInNotNullAssertions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class OperatorConventions extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInOperatorConventions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/operatorConventions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/platformTypes") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class PlatformTypes extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInPlatformTypes() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/platformTypes"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - - @TestMetadata("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Primitives extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInPrimitives() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/oldLanguageVersions/platformTypes/primitives"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - } - } - @TestMetadata("compiler/testData/codegen/box/operatorConventions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 72c3b85e92f..e5f94e5ea75 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -27,7 +27,7 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } public void testAllFilesPresentInBox() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true, "toArray", "classLiteral", "reflection", "contracts", "platformTypes", "ranges/stepped/unsigned", "coroutines", "parametersMetadata", "finally", "deadCodeElimination", "controlStructures/tryCatchInExpressions", "delegatedProperty", "oldLanguageVersions", "compileKotlinAgainstKotlin"); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true, "toArray", "classLiteral", "reflection", "contracts", "platformTypes", "ranges/stepped/unsigned", "coroutines", "parametersMetadata", "finally", "deadCodeElimination", "controlStructures/tryCatchInExpressions", "delegatedProperty", "compileKotlinAgainstKotlin"); } @TestMetadata("compiler/testData/codegen/box/annotations") From 510b9e6f2ad4794acd2ccbf32df862b469defc70 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 10 Feb 2021 21:17:09 +0100 Subject: [PATCH 020/368] Move around some codegen box tests In tests merged from boxAgainstJava in 29b96aa1, some directories were named slightly differently compared to box, e.g. "property" vs "properties", "varargs" vs "vararg". This change renames these, moves some of the tests to more fitting directories, and also renames "visibility" to "javaVisibility" because it's about Java visibilities specifically. --- .../FirBlackBoxCodegenTestGenerated.java | 566 ++++++++---------- .../javaClassWithNestedEnum.kt} | 0 .../box/{innerClass => innerNested}/kt3532.kt | 0 .../box/{innerClass => innerNested}/kt3812.kt | 0 .../box/{innerClass => innerNested}/kt4036.kt | 0 .../package/kt2781.kt | 0 .../package/packageClass.kt | 0 .../package/packageFun.kt | 0 .../package/packageProperty.kt | 0 .../protectedAndPackage/kt42012.kt | 0 .../overrideProtectedFunInPackage.kt | 0 .../protectedAndPackage/protectedAccessor.kt | 0 .../protectedFunInPackage.kt | 0 .../protectedPropertyInPackage.kt | 0 ...otectedPropertyInPackageFromCrossinline.kt | 0 .../protectedStaticClass.kt | 0 .../protectedSuperField.kt | 0 .../protectedSuperMethod.kt | 0 .../protectedStatic/funCallInConstructor.kt | 0 .../protectedStatic/funClassObject.kt | 0 .../protectedStatic/funGenericClass.kt | 0 .../protectedStatic/funNestedStaticClass.kt | 0 .../protectedStatic/funNestedStaticClass2.kt | 0 .../funNestedStaticGenericClass.kt | 0 .../protectedStatic/funNotDirectSuperClass.kt | 0 .../protectedStatic/funObject.kt | 0 .../protectedStatic/simpleClass.kt | 0 .../protectedStatic/simpleClass2.kt | 0 .../protectedStatic/simpleFun.kt | 0 .../protectedStatic/simpleProperty.kt | 0 .../fieldAccessFromExtensionInTraitImpl.kt | 0 .../fieldAccessViaSubclass.kt | 0 .../referenceToJavaFieldViaBridge.kt | 0 .../codegen/box/{inline => sam}/kt19910.kt | 0 .../{interfaces => traits}/defaultMethod.kt | 0 .../inheritJavaInterface_AgainstCompiled.kt} | 0 .../{varargs => vararg}/varargsOverride.kt | 0 .../{varargs => vararg}/varargsOverride2.kt | 0 .../{varargs => vararg}/varargsOverride3.kt | 0 .../codegen/BlackBoxCodegenTestGenerated.java | 566 ++++++++---------- .../IrBlackBoxCodegenTestGenerated.java | 566 ++++++++---------- .../LightAnalysisModeTestGenerated.java | 538 +++++++---------- .../IrJsCodegenBoxES6TestGenerated.java | 182 ++---- .../IrJsCodegenBoxTestGenerated.java | 182 ++---- .../semantics/JsCodegenBoxTestGenerated.java | 182 ++---- .../IrCodegenBoxWasmTestGenerated.java | 182 ++---- 46 files changed, 1197 insertions(+), 1767 deletions(-) rename compiler/testData/codegen/box/{staticFun/classWithNestedEnum.kt => enum/javaClassWithNestedEnum.kt} (100%) rename compiler/testData/codegen/box/{innerClass => innerNested}/kt3532.kt (100%) rename compiler/testData/codegen/box/{innerClass => innerNested}/kt3812.kt (100%) rename compiler/testData/codegen/box/{innerClass => innerNested}/kt4036.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/package/kt2781.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/package/packageClass.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/package/packageFun.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/package/packageProperty.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedAndPackage/kt42012.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedAndPackage/overrideProtectedFunInPackage.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedAndPackage/protectedAccessor.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedAndPackage/protectedFunInPackage.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedAndPackage/protectedPropertyInPackage.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedAndPackage/protectedStaticClass.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedAndPackage/protectedSuperField.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedAndPackage/protectedSuperMethod.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/funCallInConstructor.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/funClassObject.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/funGenericClass.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/funNestedStaticClass.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/funNestedStaticClass2.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/funNestedStaticGenericClass.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/funNotDirectSuperClass.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/funObject.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/simpleClass.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/simpleClass2.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/simpleFun.kt (100%) rename compiler/testData/codegen/box/{visibility => javaVisibility}/protectedStatic/simpleProperty.kt (100%) rename compiler/testData/codegen/box/{property => properties}/fieldAccessFromExtensionInTraitImpl.kt (100%) rename compiler/testData/codegen/box/{property => properties}/fieldAccessViaSubclass.kt (100%) rename compiler/testData/codegen/box/{property => properties}/referenceToJavaFieldViaBridge.kt (100%) rename compiler/testData/codegen/box/{inline => sam}/kt19910.kt (100%) rename compiler/testData/codegen/box/{interfaces => traits}/defaultMethod.kt (100%) rename compiler/testData/codegen/box/{interfaces/inheritJavaInterface.kt => traits/inheritJavaInterface_AgainstCompiled.kt} (100%) rename compiler/testData/codegen/box/{varargs => vararg}/varargsOverride.kt (100%) rename compiler/testData/codegen/box/{varargs => vararg}/varargsOverride2.kt (100%) rename compiler/testData/codegen/box/{varargs => vararg}/varargsOverride3.kt (100%) diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 6574c9ef1dd..3ec06a446bc 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -13900,6 +13900,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt"); } + @Test + @TestMetadata("javaClassWithNestedEnum.kt") + public void testJavaClassWithNestedEnum() throws Exception { + runTest("compiler/testData/codegen/box/enum/javaClassWithNestedEnum.kt"); + } + @Test @TestMetadata("kt1119.kt") public void testKt1119() throws Exception { @@ -16773,22 +16779,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } - @Nested - @TestMetadata("compiler/testData/codegen/box/inline") - @TestDataPath("$PROJECT_ROOT") - public class Inline { - @Test - public void testAllFilesPresentInInline() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("kt19910.kt") - public void testKt19910() throws Exception { - runTest("compiler/testData/codegen/box/inline/kt19910.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @@ -19183,34 +19173,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } - @Nested - @TestMetadata("compiler/testData/codegen/box/innerClass") - @TestDataPath("$PROJECT_ROOT") - public class InnerClass { - @Test - public void testAllFilesPresentInInnerClass() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerClass"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("kt3532.kt") - public void testKt3532() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt3532.kt"); - } - - @Test - @TestMetadata("kt3812.kt") - public void testKt3812() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt3812.kt"); - } - - @Test - @TestMetadata("kt4036.kt") - public void testKt4036() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt4036.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/innerNested") @TestDataPath("$PROJECT_ROOT") @@ -19304,12 +19266,30 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/innerNested/kt3132.kt"); } + @Test + @TestMetadata("kt3532.kt") + public void testKt3532() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt3532.kt"); + } + + @Test + @TestMetadata("kt3812.kt") + public void testKt3812() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt3812.kt"); + } + @Test @TestMetadata("kt3927.kt") public void testKt3927() throws Exception { runTest("compiler/testData/codegen/box/innerNested/kt3927.kt"); } + @Test + @TestMetadata("kt4036.kt") + public void testKt4036() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt4036.kt"); + } + @Test @TestMetadata("kt5363.kt") public void testKt5363() throws Exception { @@ -19557,28 +19537,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } - @Nested - @TestMetadata("compiler/testData/codegen/box/interfaces") - @TestDataPath("$PROJECT_ROOT") - public class Interfaces { - @Test - public void testAllFilesPresentInInterfaces() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("defaultMethod.kt") - public void testDefaultMethod() throws Exception { - runTest("compiler/testData/codegen/box/interfaces/defaultMethod.kt"); - } - - @Test - @TestMetadata("inheritJavaInterface.kt") - public void testInheritJavaInterface() throws Exception { - runTest("compiler/testData/codegen/box/interfaces/inheritJavaInterface.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/intrinsics") @TestDataPath("$PROJECT_ROOT") @@ -20825,6 +20783,196 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility") + @TestDataPath("$PROJECT_ROOT") + public class JavaVisibility { + @Test + public void testAllFilesPresentInJavaVisibility() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility/package") + @TestDataPath("$PROJECT_ROOT") + public class Package { + @Test + public void testAllFilesPresentInPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt2781.kt") + public void testKt2781() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/kt2781.kt"); + } + + @Test + @TestMetadata("packageClass.kt") + public void testPackageClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageClass.kt"); + } + + @Test + @TestMetadata("packageFun.kt") + public void testPackageFun() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageFun.kt"); + } + + @Test + @TestMetadata("packageProperty.kt") + public void testPackageProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageProperty.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedAndPackage") + @TestDataPath("$PROJECT_ROOT") + public class ProtectedAndPackage { + @Test + public void testAllFilesPresentInProtectedAndPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt42012.kt") + public void testKt42012() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/kt42012.kt"); + } + + @Test + @TestMetadata("overrideProtectedFunInPackage.kt") + public void testOverrideProtectedFunInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/overrideProtectedFunInPackage.kt"); + } + + @Test + @TestMetadata("protectedAccessor.kt") + public void testProtectedAccessor() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedAccessor.kt"); + } + + @Test + @TestMetadata("protectedFunInPackage.kt") + public void testProtectedFunInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedFunInPackage.kt"); + } + + @Test + @TestMetadata("protectedPropertyInPackage.kt") + public void testProtectedPropertyInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackage.kt"); + } + + @Test + @TestMetadata("protectedPropertyInPackageFromCrossinline.kt") + public void testProtectedPropertyInPackageFromCrossinline() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt"); + } + + @Test + @TestMetadata("protectedStaticClass.kt") + public void testProtectedStaticClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedStaticClass.kt"); + } + + @Test + @TestMetadata("protectedSuperField.kt") + public void testProtectedSuperField() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperField.kt"); + } + + @Test + @TestMetadata("protectedSuperMethod.kt") + public void testProtectedSuperMethod() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperMethod.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedStatic") + @TestDataPath("$PROJECT_ROOT") + public class ProtectedStatic { + @Test + public void testAllFilesPresentInProtectedStatic() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("funCallInConstructor.kt") + public void testFunCallInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funCallInConstructor.kt"); + } + + @Test + @TestMetadata("funClassObject.kt") + public void testFunClassObject() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funClassObject.kt"); + } + + @Test + @TestMetadata("funGenericClass.kt") + public void testFunGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funGenericClass.kt"); + } + + @Test + @TestMetadata("funNestedStaticClass.kt") + public void testFunNestedStaticClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass.kt"); + } + + @Test + @TestMetadata("funNestedStaticClass2.kt") + public void testFunNestedStaticClass2() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass2.kt"); + } + + @Test + @TestMetadata("funNestedStaticGenericClass.kt") + public void testFunNestedStaticGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticGenericClass.kt"); + } + + @Test + @TestMetadata("funNotDirectSuperClass.kt") + public void testFunNotDirectSuperClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNotDirectSuperClass.kt"); + } + + @Test + @TestMetadata("funObject.kt") + public void testFunObject() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funObject.kt"); + } + + @Test + @TestMetadata("simpleClass.kt") + public void testSimpleClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass.kt"); + } + + @Test + @TestMetadata("simpleClass2.kt") + public void testSimpleClass2() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass2.kt"); + } + + @Test + @TestMetadata("simpleFun.kt") + public void testSimpleFun() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleFun.kt"); + } + + @Test + @TestMetadata("simpleProperty.kt") + public void testSimpleProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleProperty.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/jdk") @TestDataPath("$PROJECT_ROOT") @@ -26368,6 +26516,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/properties/field.kt"); } + @Test + @TestMetadata("fieldAccessFromExtensionInTraitImpl.kt") + public void testFieldAccessFromExtensionInTraitImpl() throws Exception { + runTest("compiler/testData/codegen/box/properties/fieldAccessFromExtensionInTraitImpl.kt"); + } + + @Test + @TestMetadata("fieldAccessViaSubclass.kt") + public void testFieldAccessViaSubclass() throws Exception { + runTest("compiler/testData/codegen/box/properties/fieldAccessViaSubclass.kt"); + } + @Test @TestMetadata("fieldInClass.kt") public void testFieldInClass() throws Exception { @@ -26710,6 +26870,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/properties/protectedJavaPropertyInCompanion.kt"); } + @Test + @TestMetadata("referenceToJavaFieldViaBridge.kt") + public void testReferenceToJavaFieldViaBridge() throws Exception { + runTest("compiler/testData/codegen/box/properties/referenceToJavaFieldViaBridge.kt"); + } + @Test @TestMetadata("sideEffectInTopLevelInitializerMultiModule.kt") public void testSideEffectInTopLevelInitializerMultiModule() throws Exception { @@ -27055,34 +27221,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } - @Nested - @TestMetadata("compiler/testData/codegen/box/property") - @TestDataPath("$PROJECT_ROOT") - public class Property { - @Test - public void testAllFilesPresentInProperty() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("fieldAccessFromExtensionInTraitImpl.kt") - public void testFieldAccessFromExtensionInTraitImpl() throws Exception { - runTest("compiler/testData/codegen/box/property/fieldAccessFromExtensionInTraitImpl.kt"); - } - - @Test - @TestMetadata("fieldAccessViaSubclass.kt") - public void testFieldAccessViaSubclass() throws Exception { - runTest("compiler/testData/codegen/box/property/fieldAccessViaSubclass.kt"); - } - - @Test - @TestMetadata("referenceToJavaFieldViaBridge.kt") - public void testReferenceToJavaFieldViaBridge() throws Exception { - runTest("compiler/testData/codegen/box/property/referenceToJavaFieldViaBridge.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/publishedApi") @TestDataPath("$PROJECT_ROOT") @@ -36282,6 +36420,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/sam/kt17091_4.kt"); } + @Test + @TestMetadata("kt19910.kt") + public void testKt19910() throws Exception { + runTest("compiler/testData/codegen/box/sam/kt19910.kt"); + } + @Test @TestMetadata("kt22906.kt") public void testKt22906() throws Exception { @@ -37469,22 +37613,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } - @Nested - @TestMetadata("compiler/testData/codegen/box/staticFun") - @TestDataPath("$PROJECT_ROOT") - public class StaticFun { - @Test - public void testAllFilesPresentInStaticFun() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/staticFun"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("classWithNestedEnum.kt") - public void testClassWithNestedEnum() throws Exception { - runTest("compiler/testData/codegen/box/staticFun/classWithNestedEnum.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/statics") @TestDataPath("$PROJECT_ROOT") @@ -38508,6 +38636,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/traits/defaultImplCall.kt"); } + @Test + @TestMetadata("defaultMethod.kt") + public void testDefaultMethod() throws Exception { + runTest("compiler/testData/codegen/box/traits/defaultMethod.kt"); + } + @Test @TestMetadata("diamondPropertyAccessors.kt") public void testDiamondPropertyAccessors() throws Exception { @@ -38544,6 +38678,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/traits/inheritJavaInterface.kt"); } + @Test + @TestMetadata("inheritJavaInterface_AgainstCompiled.kt") + public void testInheritJavaInterface_AgainstCompiled() throws Exception { + runTest("compiler/testData/codegen/box/traits/inheritJavaInterface_AgainstCompiled.kt"); + } + @Test @TestMetadata("inheritedFun.kt") public void testInheritedFun() throws Exception { @@ -39569,223 +39709,23 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT public void testVarargsAndFunctionLiterals() throws Exception { runTest("compiler/testData/codegen/box/vararg/varargsAndFunctionLiterals.kt"); } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/varargs") - @TestDataPath("$PROJECT_ROOT") - public class Varargs { - @Test - public void testAllFilesPresentInVarargs() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/varargs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } @Test @TestMetadata("varargsOverride.kt") public void testVarargsOverride() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride.kt"); + runTest("compiler/testData/codegen/box/vararg/varargsOverride.kt"); } @Test @TestMetadata("varargsOverride2.kt") public void testVarargsOverride2() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride2.kt"); + runTest("compiler/testData/codegen/box/vararg/varargsOverride2.kt"); } @Test @TestMetadata("varargsOverride3.kt") public void testVarargsOverride3() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride3.kt"); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility") - @TestDataPath("$PROJECT_ROOT") - public class Visibility { - @Test - public void testAllFilesPresentInVisibility() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility/package") - @TestDataPath("$PROJECT_ROOT") - public class Package { - @Test - public void testAllFilesPresentInPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("kt2781.kt") - public void testKt2781() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/kt2781.kt"); - } - - @Test - @TestMetadata("packageClass.kt") - public void testPackageClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageClass.kt"); - } - - @Test - @TestMetadata("packageFun.kt") - public void testPackageFun() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageFun.kt"); - } - - @Test - @TestMetadata("packageProperty.kt") - public void testPackageProperty() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageProperty.kt"); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility/protectedAndPackage") - @TestDataPath("$PROJECT_ROOT") - public class ProtectedAndPackage { - @Test - public void testAllFilesPresentInProtectedAndPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("kt42012.kt") - public void testKt42012() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt"); - } - - @Test - @TestMetadata("overrideProtectedFunInPackage.kt") - public void testOverrideProtectedFunInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt"); - } - - @Test - @TestMetadata("protectedAccessor.kt") - public void testProtectedAccessor() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedAccessor.kt"); - } - - @Test - @TestMetadata("protectedFunInPackage.kt") - public void testProtectedFunInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedFunInPackage.kt"); - } - - @Test - @TestMetadata("protectedPropertyInPackage.kt") - public void testProtectedPropertyInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackage.kt"); - } - - @Test - @TestMetadata("protectedPropertyInPackageFromCrossinline.kt") - public void testProtectedPropertyInPackageFromCrossinline() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt"); - } - - @Test - @TestMetadata("protectedStaticClass.kt") - public void testProtectedStaticClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedStaticClass.kt"); - } - - @Test - @TestMetadata("protectedSuperField.kt") - public void testProtectedSuperField() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperField.kt"); - } - - @Test - @TestMetadata("protectedSuperMethod.kt") - public void testProtectedSuperMethod() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperMethod.kt"); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility/protectedStatic") - @TestDataPath("$PROJECT_ROOT") - public class ProtectedStatic { - @Test - public void testAllFilesPresentInProtectedStatic() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("funCallInConstructor.kt") - public void testFunCallInConstructor() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funCallInConstructor.kt"); - } - - @Test - @TestMetadata("funClassObject.kt") - public void testFunClassObject() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funClassObject.kt"); - } - - @Test - @TestMetadata("funGenericClass.kt") - public void testFunGenericClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funGenericClass.kt"); - } - - @Test - @TestMetadata("funNestedStaticClass.kt") - public void testFunNestedStaticClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass.kt"); - } - - @Test - @TestMetadata("funNestedStaticClass2.kt") - public void testFunNestedStaticClass2() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass2.kt"); - } - - @Test - @TestMetadata("funNestedStaticGenericClass.kt") - public void testFunNestedStaticGenericClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticGenericClass.kt"); - } - - @Test - @TestMetadata("funNotDirectSuperClass.kt") - public void testFunNotDirectSuperClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNotDirectSuperClass.kt"); - } - - @Test - @TestMetadata("funObject.kt") - public void testFunObject() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funObject.kt"); - } - - @Test - @TestMetadata("simpleClass.kt") - public void testSimpleClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleClass.kt"); - } - - @Test - @TestMetadata("simpleClass2.kt") - public void testSimpleClass2() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleClass2.kt"); - } - - @Test - @TestMetadata("simpleFun.kt") - public void testSimpleFun() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleFun.kt"); - } - - @Test - @TestMetadata("simpleProperty.kt") - public void testSimpleProperty() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleProperty.kt"); - } + runTest("compiler/testData/codegen/box/vararg/varargsOverride3.kt"); } } diff --git a/compiler/testData/codegen/box/staticFun/classWithNestedEnum.kt b/compiler/testData/codegen/box/enum/javaClassWithNestedEnum.kt similarity index 100% rename from compiler/testData/codegen/box/staticFun/classWithNestedEnum.kt rename to compiler/testData/codegen/box/enum/javaClassWithNestedEnum.kt diff --git a/compiler/testData/codegen/box/innerClass/kt3532.kt b/compiler/testData/codegen/box/innerNested/kt3532.kt similarity index 100% rename from compiler/testData/codegen/box/innerClass/kt3532.kt rename to compiler/testData/codegen/box/innerNested/kt3532.kt diff --git a/compiler/testData/codegen/box/innerClass/kt3812.kt b/compiler/testData/codegen/box/innerNested/kt3812.kt similarity index 100% rename from compiler/testData/codegen/box/innerClass/kt3812.kt rename to compiler/testData/codegen/box/innerNested/kt3812.kt diff --git a/compiler/testData/codegen/box/innerClass/kt4036.kt b/compiler/testData/codegen/box/innerNested/kt4036.kt similarity index 100% rename from compiler/testData/codegen/box/innerClass/kt4036.kt rename to compiler/testData/codegen/box/innerNested/kt4036.kt diff --git a/compiler/testData/codegen/box/visibility/package/kt2781.kt b/compiler/testData/codegen/box/javaVisibility/package/kt2781.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/package/kt2781.kt rename to compiler/testData/codegen/box/javaVisibility/package/kt2781.kt diff --git a/compiler/testData/codegen/box/visibility/package/packageClass.kt b/compiler/testData/codegen/box/javaVisibility/package/packageClass.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/package/packageClass.kt rename to compiler/testData/codegen/box/javaVisibility/package/packageClass.kt diff --git a/compiler/testData/codegen/box/visibility/package/packageFun.kt b/compiler/testData/codegen/box/javaVisibility/package/packageFun.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/package/packageFun.kt rename to compiler/testData/codegen/box/javaVisibility/package/packageFun.kt diff --git a/compiler/testData/codegen/box/visibility/package/packageProperty.kt b/compiler/testData/codegen/box/javaVisibility/package/packageProperty.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/package/packageProperty.kt rename to compiler/testData/codegen/box/javaVisibility/package/packageProperty.kt diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt b/compiler/testData/codegen/box/javaVisibility/protectedAndPackage/kt42012.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt rename to compiler/testData/codegen/box/javaVisibility/protectedAndPackage/kt42012.kt diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt b/compiler/testData/codegen/box/javaVisibility/protectedAndPackage/overrideProtectedFunInPackage.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt rename to compiler/testData/codegen/box/javaVisibility/protectedAndPackage/overrideProtectedFunInPackage.kt diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedAccessor.kt b/compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedAccessor.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedAndPackage/protectedAccessor.kt rename to compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedAccessor.kt diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedFunInPackage.kt b/compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedFunInPackage.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedAndPackage/protectedFunInPackage.kt rename to compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedFunInPackage.kt diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackage.kt b/compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackage.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackage.kt rename to compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackage.kt diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt b/compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt rename to compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedStaticClass.kt b/compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedStaticClass.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedAndPackage/protectedStaticClass.kt rename to compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedStaticClass.kt diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperField.kt b/compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperField.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperField.kt rename to compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperField.kt diff --git a/compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperMethod.kt b/compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperMethod.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperMethod.kt rename to compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperMethod.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funCallInConstructor.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/funCallInConstructor.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/funCallInConstructor.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/funCallInConstructor.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funClassObject.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/funClassObject.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/funClassObject.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/funClassObject.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funGenericClass.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/funGenericClass.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/funGenericClass.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/funGenericClass.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass2.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass2.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass2.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass2.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticGenericClass.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticGenericClass.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticGenericClass.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticGenericClass.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funNotDirectSuperClass.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/funNotDirectSuperClass.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/funNotDirectSuperClass.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/funNotDirectSuperClass.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/funObject.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/funObject.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/funObject.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/funObject.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/simpleClass.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/simpleClass.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/simpleClass2.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass2.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/simpleClass2.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass2.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/simpleFun.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleFun.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/simpleFun.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleFun.kt diff --git a/compiler/testData/codegen/box/visibility/protectedStatic/simpleProperty.kt b/compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleProperty.kt similarity index 100% rename from compiler/testData/codegen/box/visibility/protectedStatic/simpleProperty.kt rename to compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleProperty.kt diff --git a/compiler/testData/codegen/box/property/fieldAccessFromExtensionInTraitImpl.kt b/compiler/testData/codegen/box/properties/fieldAccessFromExtensionInTraitImpl.kt similarity index 100% rename from compiler/testData/codegen/box/property/fieldAccessFromExtensionInTraitImpl.kt rename to compiler/testData/codegen/box/properties/fieldAccessFromExtensionInTraitImpl.kt diff --git a/compiler/testData/codegen/box/property/fieldAccessViaSubclass.kt b/compiler/testData/codegen/box/properties/fieldAccessViaSubclass.kt similarity index 100% rename from compiler/testData/codegen/box/property/fieldAccessViaSubclass.kt rename to compiler/testData/codegen/box/properties/fieldAccessViaSubclass.kt diff --git a/compiler/testData/codegen/box/property/referenceToJavaFieldViaBridge.kt b/compiler/testData/codegen/box/properties/referenceToJavaFieldViaBridge.kt similarity index 100% rename from compiler/testData/codegen/box/property/referenceToJavaFieldViaBridge.kt rename to compiler/testData/codegen/box/properties/referenceToJavaFieldViaBridge.kt diff --git a/compiler/testData/codegen/box/inline/kt19910.kt b/compiler/testData/codegen/box/sam/kt19910.kt similarity index 100% rename from compiler/testData/codegen/box/inline/kt19910.kt rename to compiler/testData/codegen/box/sam/kt19910.kt diff --git a/compiler/testData/codegen/box/interfaces/defaultMethod.kt b/compiler/testData/codegen/box/traits/defaultMethod.kt similarity index 100% rename from compiler/testData/codegen/box/interfaces/defaultMethod.kt rename to compiler/testData/codegen/box/traits/defaultMethod.kt diff --git a/compiler/testData/codegen/box/interfaces/inheritJavaInterface.kt b/compiler/testData/codegen/box/traits/inheritJavaInterface_AgainstCompiled.kt similarity index 100% rename from compiler/testData/codegen/box/interfaces/inheritJavaInterface.kt rename to compiler/testData/codegen/box/traits/inheritJavaInterface_AgainstCompiled.kt diff --git a/compiler/testData/codegen/box/varargs/varargsOverride.kt b/compiler/testData/codegen/box/vararg/varargsOverride.kt similarity index 100% rename from compiler/testData/codegen/box/varargs/varargsOverride.kt rename to compiler/testData/codegen/box/vararg/varargsOverride.kt diff --git a/compiler/testData/codegen/box/varargs/varargsOverride2.kt b/compiler/testData/codegen/box/vararg/varargsOverride2.kt similarity index 100% rename from compiler/testData/codegen/box/varargs/varargsOverride2.kt rename to compiler/testData/codegen/box/vararg/varargsOverride2.kt diff --git a/compiler/testData/codegen/box/varargs/varargsOverride3.kt b/compiler/testData/codegen/box/vararg/varargsOverride3.kt similarity index 100% rename from compiler/testData/codegen/box/varargs/varargsOverride3.kt rename to compiler/testData/codegen/box/vararg/varargsOverride3.kt diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 8884fc2aeb7..ae9e296f7eb 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -13900,6 +13900,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt"); } + @Test + @TestMetadata("javaClassWithNestedEnum.kt") + public void testJavaClassWithNestedEnum() throws Exception { + runTest("compiler/testData/codegen/box/enum/javaClassWithNestedEnum.kt"); + } + @Test @TestMetadata("kt1119.kt") public void testKt1119() throws Exception { @@ -16773,22 +16779,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } - @Nested - @TestMetadata("compiler/testData/codegen/box/inline") - @TestDataPath("$PROJECT_ROOT") - public class Inline { - @Test - public void testAllFilesPresentInInline() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("kt19910.kt") - public void testKt19910() throws Exception { - runTest("compiler/testData/codegen/box/inline/kt19910.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @@ -19183,34 +19173,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } - @Nested - @TestMetadata("compiler/testData/codegen/box/innerClass") - @TestDataPath("$PROJECT_ROOT") - public class InnerClass { - @Test - public void testAllFilesPresentInInnerClass() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerClass"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("kt3532.kt") - public void testKt3532() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt3532.kt"); - } - - @Test - @TestMetadata("kt3812.kt") - public void testKt3812() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt3812.kt"); - } - - @Test - @TestMetadata("kt4036.kt") - public void testKt4036() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt4036.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/innerNested") @TestDataPath("$PROJECT_ROOT") @@ -19304,12 +19266,30 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/innerNested/kt3132.kt"); } + @Test + @TestMetadata("kt3532.kt") + public void testKt3532() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt3532.kt"); + } + + @Test + @TestMetadata("kt3812.kt") + public void testKt3812() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt3812.kt"); + } + @Test @TestMetadata("kt3927.kt") public void testKt3927() throws Exception { runTest("compiler/testData/codegen/box/innerNested/kt3927.kt"); } + @Test + @TestMetadata("kt4036.kt") + public void testKt4036() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt4036.kt"); + } + @Test @TestMetadata("kt5363.kt") public void testKt5363() throws Exception { @@ -19557,28 +19537,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } - @Nested - @TestMetadata("compiler/testData/codegen/box/interfaces") - @TestDataPath("$PROJECT_ROOT") - public class Interfaces { - @Test - public void testAllFilesPresentInInterfaces() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("defaultMethod.kt") - public void testDefaultMethod() throws Exception { - runTest("compiler/testData/codegen/box/interfaces/defaultMethod.kt"); - } - - @Test - @TestMetadata("inheritJavaInterface.kt") - public void testInheritJavaInterface() throws Exception { - runTest("compiler/testData/codegen/box/interfaces/inheritJavaInterface.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/intrinsics") @TestDataPath("$PROJECT_ROOT") @@ -20825,6 +20783,196 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility") + @TestDataPath("$PROJECT_ROOT") + public class JavaVisibility { + @Test + public void testAllFilesPresentInJavaVisibility() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility/package") + @TestDataPath("$PROJECT_ROOT") + public class Package { + @Test + public void testAllFilesPresentInPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("kt2781.kt") + public void testKt2781() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/kt2781.kt"); + } + + @Test + @TestMetadata("packageClass.kt") + public void testPackageClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageClass.kt"); + } + + @Test + @TestMetadata("packageFun.kt") + public void testPackageFun() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageFun.kt"); + } + + @Test + @TestMetadata("packageProperty.kt") + public void testPackageProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageProperty.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedAndPackage") + @TestDataPath("$PROJECT_ROOT") + public class ProtectedAndPackage { + @Test + public void testAllFilesPresentInProtectedAndPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("kt42012.kt") + public void testKt42012() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/kt42012.kt"); + } + + @Test + @TestMetadata("overrideProtectedFunInPackage.kt") + public void testOverrideProtectedFunInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/overrideProtectedFunInPackage.kt"); + } + + @Test + @TestMetadata("protectedAccessor.kt") + public void testProtectedAccessor() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedAccessor.kt"); + } + + @Test + @TestMetadata("protectedFunInPackage.kt") + public void testProtectedFunInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedFunInPackage.kt"); + } + + @Test + @TestMetadata("protectedPropertyInPackage.kt") + public void testProtectedPropertyInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackage.kt"); + } + + @Test + @TestMetadata("protectedPropertyInPackageFromCrossinline.kt") + public void testProtectedPropertyInPackageFromCrossinline() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt"); + } + + @Test + @TestMetadata("protectedStaticClass.kt") + public void testProtectedStaticClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedStaticClass.kt"); + } + + @Test + @TestMetadata("protectedSuperField.kt") + public void testProtectedSuperField() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperField.kt"); + } + + @Test + @TestMetadata("protectedSuperMethod.kt") + public void testProtectedSuperMethod() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperMethod.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedStatic") + @TestDataPath("$PROJECT_ROOT") + public class ProtectedStatic { + @Test + public void testAllFilesPresentInProtectedStatic() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("funCallInConstructor.kt") + public void testFunCallInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funCallInConstructor.kt"); + } + + @Test + @TestMetadata("funClassObject.kt") + public void testFunClassObject() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funClassObject.kt"); + } + + @Test + @TestMetadata("funGenericClass.kt") + public void testFunGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funGenericClass.kt"); + } + + @Test + @TestMetadata("funNestedStaticClass.kt") + public void testFunNestedStaticClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass.kt"); + } + + @Test + @TestMetadata("funNestedStaticClass2.kt") + public void testFunNestedStaticClass2() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass2.kt"); + } + + @Test + @TestMetadata("funNestedStaticGenericClass.kt") + public void testFunNestedStaticGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticGenericClass.kt"); + } + + @Test + @TestMetadata("funNotDirectSuperClass.kt") + public void testFunNotDirectSuperClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNotDirectSuperClass.kt"); + } + + @Test + @TestMetadata("funObject.kt") + public void testFunObject() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funObject.kt"); + } + + @Test + @TestMetadata("simpleClass.kt") + public void testSimpleClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass.kt"); + } + + @Test + @TestMetadata("simpleClass2.kt") + public void testSimpleClass2() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass2.kt"); + } + + @Test + @TestMetadata("simpleFun.kt") + public void testSimpleFun() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleFun.kt"); + } + + @Test + @TestMetadata("simpleProperty.kt") + public void testSimpleProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleProperty.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/jdk") @TestDataPath("$PROJECT_ROOT") @@ -26368,6 +26516,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/properties/field.kt"); } + @Test + @TestMetadata("fieldAccessFromExtensionInTraitImpl.kt") + public void testFieldAccessFromExtensionInTraitImpl() throws Exception { + runTest("compiler/testData/codegen/box/properties/fieldAccessFromExtensionInTraitImpl.kt"); + } + + @Test + @TestMetadata("fieldAccessViaSubclass.kt") + public void testFieldAccessViaSubclass() throws Exception { + runTest("compiler/testData/codegen/box/properties/fieldAccessViaSubclass.kt"); + } + @Test @TestMetadata("fieldInClass.kt") public void testFieldInClass() throws Exception { @@ -26710,6 +26870,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/properties/protectedJavaPropertyInCompanion.kt"); } + @Test + @TestMetadata("referenceToJavaFieldViaBridge.kt") + public void testReferenceToJavaFieldViaBridge() throws Exception { + runTest("compiler/testData/codegen/box/properties/referenceToJavaFieldViaBridge.kt"); + } + @Test @TestMetadata("sideEffectInTopLevelInitializerMultiModule.kt") public void testSideEffectInTopLevelInitializerMultiModule() throws Exception { @@ -27055,34 +27221,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } - @Nested - @TestMetadata("compiler/testData/codegen/box/property") - @TestDataPath("$PROJECT_ROOT") - public class Property { - @Test - public void testAllFilesPresentInProperty() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("fieldAccessFromExtensionInTraitImpl.kt") - public void testFieldAccessFromExtensionInTraitImpl() throws Exception { - runTest("compiler/testData/codegen/box/property/fieldAccessFromExtensionInTraitImpl.kt"); - } - - @Test - @TestMetadata("fieldAccessViaSubclass.kt") - public void testFieldAccessViaSubclass() throws Exception { - runTest("compiler/testData/codegen/box/property/fieldAccessViaSubclass.kt"); - } - - @Test - @TestMetadata("referenceToJavaFieldViaBridge.kt") - public void testReferenceToJavaFieldViaBridge() throws Exception { - runTest("compiler/testData/codegen/box/property/referenceToJavaFieldViaBridge.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/publishedApi") @TestDataPath("$PROJECT_ROOT") @@ -36282,6 +36420,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/sam/kt17091_4.kt"); } + @Test + @TestMetadata("kt19910.kt") + public void testKt19910() throws Exception { + runTest("compiler/testData/codegen/box/sam/kt19910.kt"); + } + @Test @TestMetadata("kt22906.kt") public void testKt22906() throws Exception { @@ -37469,22 +37613,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } - @Nested - @TestMetadata("compiler/testData/codegen/box/staticFun") - @TestDataPath("$PROJECT_ROOT") - public class StaticFun { - @Test - public void testAllFilesPresentInStaticFun() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/staticFun"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("classWithNestedEnum.kt") - public void testClassWithNestedEnum() throws Exception { - runTest("compiler/testData/codegen/box/staticFun/classWithNestedEnum.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/statics") @TestDataPath("$PROJECT_ROOT") @@ -38508,6 +38636,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/traits/defaultImplCall.kt"); } + @Test + @TestMetadata("defaultMethod.kt") + public void testDefaultMethod() throws Exception { + runTest("compiler/testData/codegen/box/traits/defaultMethod.kt"); + } + @Test @TestMetadata("diamondPropertyAccessors.kt") public void testDiamondPropertyAccessors() throws Exception { @@ -38544,6 +38678,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/traits/inheritJavaInterface.kt"); } + @Test + @TestMetadata("inheritJavaInterface_AgainstCompiled.kt") + public void testInheritJavaInterface_AgainstCompiled() throws Exception { + runTest("compiler/testData/codegen/box/traits/inheritJavaInterface_AgainstCompiled.kt"); + } + @Test @TestMetadata("inheritedFun.kt") public void testInheritedFun() throws Exception { @@ -39569,223 +39709,23 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testVarargsAndFunctionLiterals() throws Exception { runTest("compiler/testData/codegen/box/vararg/varargsAndFunctionLiterals.kt"); } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/varargs") - @TestDataPath("$PROJECT_ROOT") - public class Varargs { - @Test - public void testAllFilesPresentInVarargs() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/varargs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } @Test @TestMetadata("varargsOverride.kt") public void testVarargsOverride() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride.kt"); + runTest("compiler/testData/codegen/box/vararg/varargsOverride.kt"); } @Test @TestMetadata("varargsOverride2.kt") public void testVarargsOverride2() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride2.kt"); + runTest("compiler/testData/codegen/box/vararg/varargsOverride2.kt"); } @Test @TestMetadata("varargsOverride3.kt") public void testVarargsOverride3() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride3.kt"); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility") - @TestDataPath("$PROJECT_ROOT") - public class Visibility { - @Test - public void testAllFilesPresentInVisibility() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility/package") - @TestDataPath("$PROJECT_ROOT") - public class Package { - @Test - public void testAllFilesPresentInPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("kt2781.kt") - public void testKt2781() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/kt2781.kt"); - } - - @Test - @TestMetadata("packageClass.kt") - public void testPackageClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageClass.kt"); - } - - @Test - @TestMetadata("packageFun.kt") - public void testPackageFun() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageFun.kt"); - } - - @Test - @TestMetadata("packageProperty.kt") - public void testPackageProperty() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageProperty.kt"); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility/protectedAndPackage") - @TestDataPath("$PROJECT_ROOT") - public class ProtectedAndPackage { - @Test - public void testAllFilesPresentInProtectedAndPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("kt42012.kt") - public void testKt42012() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt"); - } - - @Test - @TestMetadata("overrideProtectedFunInPackage.kt") - public void testOverrideProtectedFunInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt"); - } - - @Test - @TestMetadata("protectedAccessor.kt") - public void testProtectedAccessor() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedAccessor.kt"); - } - - @Test - @TestMetadata("protectedFunInPackage.kt") - public void testProtectedFunInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedFunInPackage.kt"); - } - - @Test - @TestMetadata("protectedPropertyInPackage.kt") - public void testProtectedPropertyInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackage.kt"); - } - - @Test - @TestMetadata("protectedPropertyInPackageFromCrossinline.kt") - public void testProtectedPropertyInPackageFromCrossinline() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt"); - } - - @Test - @TestMetadata("protectedStaticClass.kt") - public void testProtectedStaticClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedStaticClass.kt"); - } - - @Test - @TestMetadata("protectedSuperField.kt") - public void testProtectedSuperField() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperField.kt"); - } - - @Test - @TestMetadata("protectedSuperMethod.kt") - public void testProtectedSuperMethod() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperMethod.kt"); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility/protectedStatic") - @TestDataPath("$PROJECT_ROOT") - public class ProtectedStatic { - @Test - public void testAllFilesPresentInProtectedStatic() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("funCallInConstructor.kt") - public void testFunCallInConstructor() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funCallInConstructor.kt"); - } - - @Test - @TestMetadata("funClassObject.kt") - public void testFunClassObject() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funClassObject.kt"); - } - - @Test - @TestMetadata("funGenericClass.kt") - public void testFunGenericClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funGenericClass.kt"); - } - - @Test - @TestMetadata("funNestedStaticClass.kt") - public void testFunNestedStaticClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass.kt"); - } - - @Test - @TestMetadata("funNestedStaticClass2.kt") - public void testFunNestedStaticClass2() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass2.kt"); - } - - @Test - @TestMetadata("funNestedStaticGenericClass.kt") - public void testFunNestedStaticGenericClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticGenericClass.kt"); - } - - @Test - @TestMetadata("funNotDirectSuperClass.kt") - public void testFunNotDirectSuperClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNotDirectSuperClass.kt"); - } - - @Test - @TestMetadata("funObject.kt") - public void testFunObject() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funObject.kt"); - } - - @Test - @TestMetadata("simpleClass.kt") - public void testSimpleClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleClass.kt"); - } - - @Test - @TestMetadata("simpleClass2.kt") - public void testSimpleClass2() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleClass2.kt"); - } - - @Test - @TestMetadata("simpleFun.kt") - public void testSimpleFun() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleFun.kt"); - } - - @Test - @TestMetadata("simpleProperty.kt") - public void testSimpleProperty() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleProperty.kt"); - } + runTest("compiler/testData/codegen/box/vararg/varargsOverride3.kt"); } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 3d26247b4ba..cf4d445ac06 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -13900,6 +13900,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt"); } + @Test + @TestMetadata("javaClassWithNestedEnum.kt") + public void testJavaClassWithNestedEnum() throws Exception { + runTest("compiler/testData/codegen/box/enum/javaClassWithNestedEnum.kt"); + } + @Test @TestMetadata("kt1119.kt") public void testKt1119() throws Exception { @@ -16773,22 +16779,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } - @Nested - @TestMetadata("compiler/testData/codegen/box/inline") - @TestDataPath("$PROJECT_ROOT") - public class Inline { - @Test - public void testAllFilesPresentInInline() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("kt19910.kt") - public void testKt19910() throws Exception { - runTest("compiler/testData/codegen/box/inline/kt19910.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @@ -19183,34 +19173,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } - @Nested - @TestMetadata("compiler/testData/codegen/box/innerClass") - @TestDataPath("$PROJECT_ROOT") - public class InnerClass { - @Test - public void testAllFilesPresentInInnerClass() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerClass"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("kt3532.kt") - public void testKt3532() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt3532.kt"); - } - - @Test - @TestMetadata("kt3812.kt") - public void testKt3812() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt3812.kt"); - } - - @Test - @TestMetadata("kt4036.kt") - public void testKt4036() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt4036.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/innerNested") @TestDataPath("$PROJECT_ROOT") @@ -19304,12 +19266,30 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/innerNested/kt3132.kt"); } + @Test + @TestMetadata("kt3532.kt") + public void testKt3532() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt3532.kt"); + } + + @Test + @TestMetadata("kt3812.kt") + public void testKt3812() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt3812.kt"); + } + @Test @TestMetadata("kt3927.kt") public void testKt3927() throws Exception { runTest("compiler/testData/codegen/box/innerNested/kt3927.kt"); } + @Test + @TestMetadata("kt4036.kt") + public void testKt4036() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt4036.kt"); + } + @Test @TestMetadata("kt5363.kt") public void testKt5363() throws Exception { @@ -19557,28 +19537,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } - @Nested - @TestMetadata("compiler/testData/codegen/box/interfaces") - @TestDataPath("$PROJECT_ROOT") - public class Interfaces { - @Test - public void testAllFilesPresentInInterfaces() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("defaultMethod.kt") - public void testDefaultMethod() throws Exception { - runTest("compiler/testData/codegen/box/interfaces/defaultMethod.kt"); - } - - @Test - @TestMetadata("inheritJavaInterface.kt") - public void testInheritJavaInterface() throws Exception { - runTest("compiler/testData/codegen/box/interfaces/inheritJavaInterface.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/intrinsics") @TestDataPath("$PROJECT_ROOT") @@ -20825,6 +20783,196 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility") + @TestDataPath("$PROJECT_ROOT") + public class JavaVisibility { + @Test + public void testAllFilesPresentInJavaVisibility() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility/package") + @TestDataPath("$PROJECT_ROOT") + public class Package { + @Test + public void testAllFilesPresentInPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt2781.kt") + public void testKt2781() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/kt2781.kt"); + } + + @Test + @TestMetadata("packageClass.kt") + public void testPackageClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageClass.kt"); + } + + @Test + @TestMetadata("packageFun.kt") + public void testPackageFun() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageFun.kt"); + } + + @Test + @TestMetadata("packageProperty.kt") + public void testPackageProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageProperty.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedAndPackage") + @TestDataPath("$PROJECT_ROOT") + public class ProtectedAndPackage { + @Test + public void testAllFilesPresentInProtectedAndPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt42012.kt") + public void testKt42012() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/kt42012.kt"); + } + + @Test + @TestMetadata("overrideProtectedFunInPackage.kt") + public void testOverrideProtectedFunInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/overrideProtectedFunInPackage.kt"); + } + + @Test + @TestMetadata("protectedAccessor.kt") + public void testProtectedAccessor() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedAccessor.kt"); + } + + @Test + @TestMetadata("protectedFunInPackage.kt") + public void testProtectedFunInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedFunInPackage.kt"); + } + + @Test + @TestMetadata("protectedPropertyInPackage.kt") + public void testProtectedPropertyInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackage.kt"); + } + + @Test + @TestMetadata("protectedPropertyInPackageFromCrossinline.kt") + public void testProtectedPropertyInPackageFromCrossinline() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt"); + } + + @Test + @TestMetadata("protectedStaticClass.kt") + public void testProtectedStaticClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedStaticClass.kt"); + } + + @Test + @TestMetadata("protectedSuperField.kt") + public void testProtectedSuperField() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperField.kt"); + } + + @Test + @TestMetadata("protectedSuperMethod.kt") + public void testProtectedSuperMethod() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperMethod.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedStatic") + @TestDataPath("$PROJECT_ROOT") + public class ProtectedStatic { + @Test + public void testAllFilesPresentInProtectedStatic() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("funCallInConstructor.kt") + public void testFunCallInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funCallInConstructor.kt"); + } + + @Test + @TestMetadata("funClassObject.kt") + public void testFunClassObject() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funClassObject.kt"); + } + + @Test + @TestMetadata("funGenericClass.kt") + public void testFunGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funGenericClass.kt"); + } + + @Test + @TestMetadata("funNestedStaticClass.kt") + public void testFunNestedStaticClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass.kt"); + } + + @Test + @TestMetadata("funNestedStaticClass2.kt") + public void testFunNestedStaticClass2() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass2.kt"); + } + + @Test + @TestMetadata("funNestedStaticGenericClass.kt") + public void testFunNestedStaticGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticGenericClass.kt"); + } + + @Test + @TestMetadata("funNotDirectSuperClass.kt") + public void testFunNotDirectSuperClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNotDirectSuperClass.kt"); + } + + @Test + @TestMetadata("funObject.kt") + public void testFunObject() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funObject.kt"); + } + + @Test + @TestMetadata("simpleClass.kt") + public void testSimpleClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass.kt"); + } + + @Test + @TestMetadata("simpleClass2.kt") + public void testSimpleClass2() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass2.kt"); + } + + @Test + @TestMetadata("simpleFun.kt") + public void testSimpleFun() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleFun.kt"); + } + + @Test + @TestMetadata("simpleProperty.kt") + public void testSimpleProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleProperty.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/jdk") @TestDataPath("$PROJECT_ROOT") @@ -26368,6 +26516,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/properties/field.kt"); } + @Test + @TestMetadata("fieldAccessFromExtensionInTraitImpl.kt") + public void testFieldAccessFromExtensionInTraitImpl() throws Exception { + runTest("compiler/testData/codegen/box/properties/fieldAccessFromExtensionInTraitImpl.kt"); + } + + @Test + @TestMetadata("fieldAccessViaSubclass.kt") + public void testFieldAccessViaSubclass() throws Exception { + runTest("compiler/testData/codegen/box/properties/fieldAccessViaSubclass.kt"); + } + @Test @TestMetadata("fieldInClass.kt") public void testFieldInClass() throws Exception { @@ -26710,6 +26870,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/properties/protectedJavaPropertyInCompanion.kt"); } + @Test + @TestMetadata("referenceToJavaFieldViaBridge.kt") + public void testReferenceToJavaFieldViaBridge() throws Exception { + runTest("compiler/testData/codegen/box/properties/referenceToJavaFieldViaBridge.kt"); + } + @Test @TestMetadata("sideEffectInTopLevelInitializerMultiModule.kt") public void testSideEffectInTopLevelInitializerMultiModule() throws Exception { @@ -27055,34 +27221,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } - @Nested - @TestMetadata("compiler/testData/codegen/box/property") - @TestDataPath("$PROJECT_ROOT") - public class Property { - @Test - public void testAllFilesPresentInProperty() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("fieldAccessFromExtensionInTraitImpl.kt") - public void testFieldAccessFromExtensionInTraitImpl() throws Exception { - runTest("compiler/testData/codegen/box/property/fieldAccessFromExtensionInTraitImpl.kt"); - } - - @Test - @TestMetadata("fieldAccessViaSubclass.kt") - public void testFieldAccessViaSubclass() throws Exception { - runTest("compiler/testData/codegen/box/property/fieldAccessViaSubclass.kt"); - } - - @Test - @TestMetadata("referenceToJavaFieldViaBridge.kt") - public void testReferenceToJavaFieldViaBridge() throws Exception { - runTest("compiler/testData/codegen/box/property/referenceToJavaFieldViaBridge.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/publishedApi") @TestDataPath("$PROJECT_ROOT") @@ -36282,6 +36420,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/sam/kt17091_4.kt"); } + @Test + @TestMetadata("kt19910.kt") + public void testKt19910() throws Exception { + runTest("compiler/testData/codegen/box/sam/kt19910.kt"); + } + @Test @TestMetadata("kt22906.kt") public void testKt22906() throws Exception { @@ -37469,22 +37613,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } - @Nested - @TestMetadata("compiler/testData/codegen/box/staticFun") - @TestDataPath("$PROJECT_ROOT") - public class StaticFun { - @Test - public void testAllFilesPresentInStaticFun() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/staticFun"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("classWithNestedEnum.kt") - public void testClassWithNestedEnum() throws Exception { - runTest("compiler/testData/codegen/box/staticFun/classWithNestedEnum.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/statics") @TestDataPath("$PROJECT_ROOT") @@ -38508,6 +38636,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/traits/defaultImplCall.kt"); } + @Test + @TestMetadata("defaultMethod.kt") + public void testDefaultMethod() throws Exception { + runTest("compiler/testData/codegen/box/traits/defaultMethod.kt"); + } + @Test @TestMetadata("diamondPropertyAccessors.kt") public void testDiamondPropertyAccessors() throws Exception { @@ -38544,6 +38678,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/traits/inheritJavaInterface.kt"); } + @Test + @TestMetadata("inheritJavaInterface_AgainstCompiled.kt") + public void testInheritJavaInterface_AgainstCompiled() throws Exception { + runTest("compiler/testData/codegen/box/traits/inheritJavaInterface_AgainstCompiled.kt"); + } + @Test @TestMetadata("inheritedFun.kt") public void testInheritedFun() throws Exception { @@ -39569,223 +39709,23 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testVarargsAndFunctionLiterals() throws Exception { runTest("compiler/testData/codegen/box/vararg/varargsAndFunctionLiterals.kt"); } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/varargs") - @TestDataPath("$PROJECT_ROOT") - public class Varargs { - @Test - public void testAllFilesPresentInVarargs() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/varargs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } @Test @TestMetadata("varargsOverride.kt") public void testVarargsOverride() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride.kt"); + runTest("compiler/testData/codegen/box/vararg/varargsOverride.kt"); } @Test @TestMetadata("varargsOverride2.kt") public void testVarargsOverride2() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride2.kt"); + runTest("compiler/testData/codegen/box/vararg/varargsOverride2.kt"); } @Test @TestMetadata("varargsOverride3.kt") public void testVarargsOverride3() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride3.kt"); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility") - @TestDataPath("$PROJECT_ROOT") - public class Visibility { - @Test - public void testAllFilesPresentInVisibility() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility/package") - @TestDataPath("$PROJECT_ROOT") - public class Package { - @Test - public void testAllFilesPresentInPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("kt2781.kt") - public void testKt2781() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/kt2781.kt"); - } - - @Test - @TestMetadata("packageClass.kt") - public void testPackageClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageClass.kt"); - } - - @Test - @TestMetadata("packageFun.kt") - public void testPackageFun() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageFun.kt"); - } - - @Test - @TestMetadata("packageProperty.kt") - public void testPackageProperty() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageProperty.kt"); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility/protectedAndPackage") - @TestDataPath("$PROJECT_ROOT") - public class ProtectedAndPackage { - @Test - public void testAllFilesPresentInProtectedAndPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("kt42012.kt") - public void testKt42012() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt"); - } - - @Test - @TestMetadata("overrideProtectedFunInPackage.kt") - public void testOverrideProtectedFunInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt"); - } - - @Test - @TestMetadata("protectedAccessor.kt") - public void testProtectedAccessor() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedAccessor.kt"); - } - - @Test - @TestMetadata("protectedFunInPackage.kt") - public void testProtectedFunInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedFunInPackage.kt"); - } - - @Test - @TestMetadata("protectedPropertyInPackage.kt") - public void testProtectedPropertyInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackage.kt"); - } - - @Test - @TestMetadata("protectedPropertyInPackageFromCrossinline.kt") - public void testProtectedPropertyInPackageFromCrossinline() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt"); - } - - @Test - @TestMetadata("protectedStaticClass.kt") - public void testProtectedStaticClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedStaticClass.kt"); - } - - @Test - @TestMetadata("protectedSuperField.kt") - public void testProtectedSuperField() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperField.kt"); - } - - @Test - @TestMetadata("protectedSuperMethod.kt") - public void testProtectedSuperMethod() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperMethod.kt"); - } - } - - @Nested - @TestMetadata("compiler/testData/codegen/box/visibility/protectedStatic") - @TestDataPath("$PROJECT_ROOT") - public class ProtectedStatic { - @Test - public void testAllFilesPresentInProtectedStatic() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("funCallInConstructor.kt") - public void testFunCallInConstructor() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funCallInConstructor.kt"); - } - - @Test - @TestMetadata("funClassObject.kt") - public void testFunClassObject() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funClassObject.kt"); - } - - @Test - @TestMetadata("funGenericClass.kt") - public void testFunGenericClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funGenericClass.kt"); - } - - @Test - @TestMetadata("funNestedStaticClass.kt") - public void testFunNestedStaticClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass.kt"); - } - - @Test - @TestMetadata("funNestedStaticClass2.kt") - public void testFunNestedStaticClass2() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass2.kt"); - } - - @Test - @TestMetadata("funNestedStaticGenericClass.kt") - public void testFunNestedStaticGenericClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticGenericClass.kt"); - } - - @Test - @TestMetadata("funNotDirectSuperClass.kt") - public void testFunNotDirectSuperClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNotDirectSuperClass.kt"); - } - - @Test - @TestMetadata("funObject.kt") - public void testFunObject() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funObject.kt"); - } - - @Test - @TestMetadata("simpleClass.kt") - public void testSimpleClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleClass.kt"); - } - - @Test - @TestMetadata("simpleClass2.kt") - public void testSimpleClass2() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleClass2.kt"); - } - - @Test - @TestMetadata("simpleFun.kt") - public void testSimpleFun() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleFun.kt"); - } - - @Test - @TestMetadata("simpleProperty.kt") - public void testSimpleProperty() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleProperty.kt"); - } + runTest("compiler/testData/codegen/box/vararg/varargsOverride3.kt"); } } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index ca8036bff73..56cb38f9750 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -11438,6 +11438,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/enum/innerWithExistingClassObject.kt"); } + @TestMetadata("javaClassWithNestedEnum.kt") + public void testJavaClassWithNestedEnum() throws Exception { + runTest("compiler/testData/codegen/box/enum/javaClassWithNestedEnum.kt"); + } + @TestMetadata("kt1119.kt") public void testKt1119() throws Exception { runTest("compiler/testData/codegen/box/enum/kt1119.kt"); @@ -13949,24 +13954,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } - @TestMetadata("compiler/testData/codegen/box/inline") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Inline extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInInline() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("kt19910.kt") - public void testKt19910() throws Exception { - runTest("compiler/testData/codegen/box/inline/kt19910.kt"); - } - } - @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -16046,34 +16033,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } - @TestMetadata("compiler/testData/codegen/box/innerClass") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class InnerClass extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInInnerClass() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerClass"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("kt3532.kt") - public void testKt3532() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt3532.kt"); - } - - @TestMetadata("kt3812.kt") - public void testKt3812() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt3812.kt"); - } - - @TestMetadata("kt4036.kt") - public void testKt4036() throws Exception { - runTest("compiler/testData/codegen/box/innerClass/kt4036.kt"); - } - } - @TestMetadata("compiler/testData/codegen/box/innerNested") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -16156,11 +16115,26 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/innerNested/kt3132.kt"); } + @TestMetadata("kt3532.kt") + public void testKt3532() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt3532.kt"); + } + + @TestMetadata("kt3812.kt") + public void testKt3812() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt3812.kt"); + } + @TestMetadata("kt3927.kt") public void testKt3927() throws Exception { runTest("compiler/testData/codegen/box/innerNested/kt3927.kt"); } + @TestMetadata("kt4036.kt") + public void testKt4036() throws Exception { + runTest("compiler/testData/codegen/box/innerNested/kt4036.kt"); + } + @TestMetadata("kt5363.kt") public void testKt5363() throws Exception { runTest("compiler/testData/codegen/box/innerNested/kt5363.kt"); @@ -16381,29 +16355,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } - @TestMetadata("compiler/testData/codegen/box/interfaces") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Interfaces extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInInterfaces() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("defaultMethod.kt") - public void testDefaultMethod() throws Exception { - runTest("compiler/testData/codegen/box/interfaces/defaultMethod.kt"); - } - - @TestMetadata("inheritJavaInterface.kt") - public void testInheritJavaInterface() throws Exception { - runTest("compiler/testData/codegen/box/interfaces/inheritJavaInterface.kt"); - } - } - @TestMetadata("compiler/testData/codegen/box/intrinsics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -17517,6 +17468,183 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/javaVisibility") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaVisibility extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInJavaVisibility() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/package") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Package extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("kt2781.kt") + public void testKt2781() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/kt2781.kt"); + } + + @TestMetadata("packageClass.kt") + public void testPackageClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageClass.kt"); + } + + @TestMetadata("packageFun.kt") + public void testPackageFun() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageFun.kt"); + } + + @TestMetadata("packageProperty.kt") + public void testPackageProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/package/packageProperty.kt"); + } + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedAndPackage") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ProtectedAndPackage extends AbstractLightAnalysisModeTest { + @TestMetadata("kt42012.kt") + public void ignoreKt42012() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/kt42012.kt"); + } + + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInProtectedAndPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("overrideProtectedFunInPackage.kt") + public void testOverrideProtectedFunInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/overrideProtectedFunInPackage.kt"); + } + + @TestMetadata("protectedAccessor.kt") + public void testProtectedAccessor() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedAccessor.kt"); + } + + @TestMetadata("protectedFunInPackage.kt") + public void testProtectedFunInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedFunInPackage.kt"); + } + + @TestMetadata("protectedPropertyInPackage.kt") + public void testProtectedPropertyInPackage() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackage.kt"); + } + + @TestMetadata("protectedPropertyInPackageFromCrossinline.kt") + public void testProtectedPropertyInPackageFromCrossinline() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt"); + } + + @TestMetadata("protectedStaticClass.kt") + public void testProtectedStaticClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedStaticClass.kt"); + } + + @TestMetadata("protectedSuperField.kt") + public void testProtectedSuperField() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperField.kt"); + } + + @TestMetadata("protectedSuperMethod.kt") + public void testProtectedSuperMethod() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedAndPackage/protectedSuperMethod.kt"); + } + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedStatic") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ProtectedStatic extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInProtectedStatic() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("funCallInConstructor.kt") + public void testFunCallInConstructor() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funCallInConstructor.kt"); + } + + @TestMetadata("funClassObject.kt") + public void testFunClassObject() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funClassObject.kt"); + } + + @TestMetadata("funGenericClass.kt") + public void testFunGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funGenericClass.kt"); + } + + @TestMetadata("funNestedStaticClass.kt") + public void testFunNestedStaticClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass.kt"); + } + + @TestMetadata("funNestedStaticClass2.kt") + public void testFunNestedStaticClass2() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticClass2.kt"); + } + + @TestMetadata("funNestedStaticGenericClass.kt") + public void testFunNestedStaticGenericClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNestedStaticGenericClass.kt"); + } + + @TestMetadata("funNotDirectSuperClass.kt") + public void testFunNotDirectSuperClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funNotDirectSuperClass.kt"); + } + + @TestMetadata("funObject.kt") + public void testFunObject() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/funObject.kt"); + } + + @TestMetadata("simpleClass.kt") + public void testSimpleClass() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass.kt"); + } + + @TestMetadata("simpleClass2.kt") + public void testSimpleClass2() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleClass2.kt"); + } + + @TestMetadata("simpleFun.kt") + public void testSimpleFun() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleFun.kt"); + } + + @TestMetadata("simpleProperty.kt") + public void testSimpleProperty() throws Exception { + runTest("compiler/testData/codegen/box/javaVisibility/protectedStatic/simpleProperty.kt"); + } + } + } + @TestMetadata("compiler/testData/codegen/box/jdk") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -22454,6 +22582,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/properties/field.kt"); } + @TestMetadata("fieldAccessFromExtensionInTraitImpl.kt") + public void testFieldAccessFromExtensionInTraitImpl() throws Exception { + runTest("compiler/testData/codegen/box/properties/fieldAccessFromExtensionInTraitImpl.kt"); + } + + @TestMetadata("fieldAccessViaSubclass.kt") + public void testFieldAccessViaSubclass() throws Exception { + runTest("compiler/testData/codegen/box/properties/fieldAccessViaSubclass.kt"); + } + @TestMetadata("fieldInClass.kt") public void testFieldInClass() throws Exception { runTest("compiler/testData/codegen/box/properties/fieldInClass.kt"); @@ -22734,6 +22872,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/properties/protectedJavaPropertyInCompanion.kt"); } + @TestMetadata("referenceToJavaFieldViaBridge.kt") + public void testReferenceToJavaFieldViaBridge() throws Exception { + runTest("compiler/testData/codegen/box/properties/referenceToJavaFieldViaBridge.kt"); + } + @TestMetadata("substituteJavaSuperField.kt") public void testSubstituteJavaSuperField() throws Exception { runTest("compiler/testData/codegen/box/properties/substituteJavaSuperField.kt"); @@ -23040,34 +23183,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } - @TestMetadata("compiler/testData/codegen/box/property") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Property extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInProperty() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("fieldAccessFromExtensionInTraitImpl.kt") - public void testFieldAccessFromExtensionInTraitImpl() throws Exception { - runTest("compiler/testData/codegen/box/property/fieldAccessFromExtensionInTraitImpl.kt"); - } - - @TestMetadata("fieldAccessViaSubclass.kt") - public void testFieldAccessViaSubclass() throws Exception { - runTest("compiler/testData/codegen/box/property/fieldAccessViaSubclass.kt"); - } - - @TestMetadata("referenceToJavaFieldViaBridge.kt") - public void testReferenceToJavaFieldViaBridge() throws Exception { - runTest("compiler/testData/codegen/box/property/referenceToJavaFieldViaBridge.kt"); - } - } - @TestMetadata("compiler/testData/codegen/box/publishedApi") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -28909,6 +29024,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/sam/kt17091_4.kt"); } + @TestMetadata("kt19910.kt") + public void testKt19910() throws Exception { + runTest("compiler/testData/codegen/box/sam/kt19910.kt"); + } + @TestMetadata("kt22906.kt") public void testKt22906() throws Exception { runTest("compiler/testData/codegen/box/sam/kt22906.kt"); @@ -29945,24 +30065,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } - @TestMetadata("compiler/testData/codegen/box/staticFun") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class StaticFun extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInStaticFun() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/staticFun"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("classWithNestedEnum.kt") - public void testClassWithNestedEnum() throws Exception { - runTest("compiler/testData/codegen/box/staticFun/classWithNestedEnum.kt"); - } - } - @TestMetadata("compiler/testData/codegen/box/statics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -30876,6 +30978,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/traits/defaultImplCall.kt"); } + @TestMetadata("defaultMethod.kt") + public void testDefaultMethod() throws Exception { + runTest("compiler/testData/codegen/box/traits/defaultMethod.kt"); + } + @TestMetadata("diamondPropertyAccessors.kt") public void testDiamondPropertyAccessors() throws Exception { runTest("compiler/testData/codegen/box/traits/diamondPropertyAccessors.kt"); @@ -30906,6 +31013,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/traits/inheritJavaInterface.kt"); } + @TestMetadata("inheritJavaInterface_AgainstCompiled.kt") + public void testInheritJavaInterface_AgainstCompiled() throws Exception { + runTest("compiler/testData/codegen/box/traits/inheritJavaInterface_AgainstCompiled.kt"); + } + @TestMetadata("inheritedFun.kt") public void testInheritedFun() throws Exception { runTest("compiler/testData/codegen/box/traits/inheritedFun.kt"); @@ -31802,210 +31914,20 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes public void testVarargsAndFunctionLiterals() throws Exception { runTest("compiler/testData/codegen/box/vararg/varargsAndFunctionLiterals.kt"); } - } - - @TestMetadata("compiler/testData/codegen/box/varargs") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Varargs extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInVarargs() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/varargs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } @TestMetadata("varargsOverride.kt") public void testVarargsOverride() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride.kt"); + runTest("compiler/testData/codegen/box/vararg/varargsOverride.kt"); } @TestMetadata("varargsOverride2.kt") public void testVarargsOverride2() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride2.kt"); + runTest("compiler/testData/codegen/box/vararg/varargsOverride2.kt"); } @TestMetadata("varargsOverride3.kt") public void testVarargsOverride3() throws Exception { - runTest("compiler/testData/codegen/box/varargs/varargsOverride3.kt"); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Visibility extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInVisibility() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("compiler/testData/codegen/box/visibility/package") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Package extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("kt2781.kt") - public void testKt2781() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/kt2781.kt"); - } - - @TestMetadata("packageClass.kt") - public void testPackageClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageClass.kt"); - } - - @TestMetadata("packageFun.kt") - public void testPackageFun() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageFun.kt"); - } - - @TestMetadata("packageProperty.kt") - public void testPackageProperty() throws Exception { - runTest("compiler/testData/codegen/box/visibility/package/packageProperty.kt"); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility/protectedAndPackage") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProtectedAndPackage extends AbstractLightAnalysisModeTest { - @TestMetadata("kt42012.kt") - public void ignoreKt42012() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/kt42012.kt"); - } - - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInProtectedAndPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("overrideProtectedFunInPackage.kt") - public void testOverrideProtectedFunInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt"); - } - - @TestMetadata("protectedAccessor.kt") - public void testProtectedAccessor() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedAccessor.kt"); - } - - @TestMetadata("protectedFunInPackage.kt") - public void testProtectedFunInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedFunInPackage.kt"); - } - - @TestMetadata("protectedPropertyInPackage.kt") - public void testProtectedPropertyInPackage() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackage.kt"); - } - - @TestMetadata("protectedPropertyInPackageFromCrossinline.kt") - public void testProtectedPropertyInPackageFromCrossinline() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedPropertyInPackageFromCrossinline.kt"); - } - - @TestMetadata("protectedStaticClass.kt") - public void testProtectedStaticClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedStaticClass.kt"); - } - - @TestMetadata("protectedSuperField.kt") - public void testProtectedSuperField() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperField.kt"); - } - - @TestMetadata("protectedSuperMethod.kt") - public void testProtectedSuperMethod() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedAndPackage/protectedSuperMethod.kt"); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility/protectedStatic") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProtectedStatic extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInProtectedStatic() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("funCallInConstructor.kt") - public void testFunCallInConstructor() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funCallInConstructor.kt"); - } - - @TestMetadata("funClassObject.kt") - public void testFunClassObject() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funClassObject.kt"); - } - - @TestMetadata("funGenericClass.kt") - public void testFunGenericClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funGenericClass.kt"); - } - - @TestMetadata("funNestedStaticClass.kt") - public void testFunNestedStaticClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass.kt"); - } - - @TestMetadata("funNestedStaticClass2.kt") - public void testFunNestedStaticClass2() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticClass2.kt"); - } - - @TestMetadata("funNestedStaticGenericClass.kt") - public void testFunNestedStaticGenericClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNestedStaticGenericClass.kt"); - } - - @TestMetadata("funNotDirectSuperClass.kt") - public void testFunNotDirectSuperClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funNotDirectSuperClass.kt"); - } - - @TestMetadata("funObject.kt") - public void testFunObject() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/funObject.kt"); - } - - @TestMetadata("simpleClass.kt") - public void testSimpleClass() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleClass.kt"); - } - - @TestMetadata("simpleClass2.kt") - public void testSimpleClass2() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleClass2.kt"); - } - - @TestMetadata("simpleFun.kt") - public void testSimpleFun() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleFun.kt"); - } - - @TestMetadata("simpleProperty.kt") - public void testSimpleProperty() throws Exception { - runTest("compiler/testData/codegen/box/visibility/protectedStatic/simpleProperty.kt"); - } + runTest("compiler/testData/codegen/box/vararg/varargsOverride3.kt"); } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 22e16155bb8..52a8968ba1f 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -12229,19 +12229,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } - @TestMetadata("compiler/testData/codegen/box/inline") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Inline extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInInline() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -14126,19 +14113,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } - @TestMetadata("compiler/testData/codegen/box/innerClass") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class InnerClass extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInInnerClass() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerClass"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - @TestMetadata("compiler/testData/codegen/box/innerNested") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -14426,19 +14400,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } - @TestMetadata("compiler/testData/codegen/box/interfaces") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Interfaces extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInInterfaces() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - @TestMetadata("compiler/testData/codegen/box/intrinsics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -14967,6 +14928,58 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } + @TestMetadata("compiler/testData/codegen/box/javaVisibility") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaVisibility extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInJavaVisibility() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/package") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Package extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedAndPackage") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ProtectedAndPackage extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInProtectedAndPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedStatic") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ProtectedStatic extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInProtectedStatic() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + } + @TestMetadata("compiler/testData/codegen/box/jdk") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -18695,19 +18708,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } - @TestMetadata("compiler/testData/codegen/box/property") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Property extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInProperty() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - @TestMetadata("compiler/testData/codegen/box/publishedApi") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -25671,19 +25671,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } - @TestMetadata("compiler/testData/codegen/box/staticFun") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class StaticFun extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInStaticFun() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/staticFun"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - @TestMetadata("compiler/testData/codegen/box/statics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -27145,71 +27132,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } - @TestMetadata("compiler/testData/codegen/box/varargs") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Varargs extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInVarargs() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/varargs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Visibility extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInVisibility() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - - @TestMetadata("compiler/testData/codegen/box/visibility/package") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Package extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility/protectedAndPackage") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProtectedAndPackage extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInProtectedAndPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility/protectedStatic") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProtectedStatic extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInProtectedStatic() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - } - @TestMetadata("compiler/testData/codegen/box/when") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 35a5b27b444..0ef0133f9be 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -11714,19 +11714,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/inline") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Inline extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInInline() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -13611,19 +13598,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/innerClass") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class InnerClass extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInInnerClass() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerClass"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - @TestMetadata("compiler/testData/codegen/box/innerNested") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -13911,19 +13885,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/interfaces") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Interfaces extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInInterfaces() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - @TestMetadata("compiler/testData/codegen/box/intrinsics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -14452,6 +14413,58 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/javaVisibility") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaVisibility extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInJavaVisibility() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/package") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Package extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedAndPackage") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ProtectedAndPackage extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInProtectedAndPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedStatic") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ProtectedStatic extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInProtectedStatic() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + } + @TestMetadata("compiler/testData/codegen/box/jdk") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -18180,19 +18193,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/property") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Property extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInProperty() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - @TestMetadata("compiler/testData/codegen/box/publishedApi") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -25156,19 +25156,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/staticFun") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class StaticFun extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInStaticFun() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/staticFun"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - @TestMetadata("compiler/testData/codegen/box/statics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -26630,71 +26617,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/varargs") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Varargs extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInVarargs() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/varargs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Visibility extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInVisibility() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - - @TestMetadata("compiler/testData/codegen/box/visibility/package") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Package extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility/protectedAndPackage") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProtectedAndPackage extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInProtectedAndPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility/protectedStatic") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProtectedStatic extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInProtectedStatic() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - } - @TestMetadata("compiler/testData/codegen/box/when") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 19c1f9409d1..7ffcaac194e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -11779,19 +11779,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/inline") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Inline extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInInline() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inline"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -13676,19 +13663,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/innerClass") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class InnerClass extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInInnerClass() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerClass"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - @TestMetadata("compiler/testData/codegen/box/innerNested") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -13976,19 +13950,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/interfaces") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Interfaces extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInInterfaces() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/interfaces"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - @TestMetadata("compiler/testData/codegen/box/intrinsics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -14517,6 +14478,58 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/javaVisibility") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaVisibility extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInJavaVisibility() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/package") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Package extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedAndPackage") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ProtectedAndPackage extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInProtectedAndPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedStatic") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ProtectedStatic extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInProtectedStatic() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } + } + @TestMetadata("compiler/testData/codegen/box/jdk") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -18230,19 +18243,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/property") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Property extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInProperty() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/property"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - @TestMetadata("compiler/testData/codegen/box/publishedApi") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -25116,19 +25116,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/staticFun") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class StaticFun extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInStaticFun() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/staticFun"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - @TestMetadata("compiler/testData/codegen/box/statics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -26590,71 +26577,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/varargs") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Varargs extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInVarargs() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/varargs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Visibility extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInVisibility() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - - @TestMetadata("compiler/testData/codegen/box/visibility/package") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Package extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/package"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility/protectedAndPackage") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProtectedAndPackage extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInProtectedAndPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility/protectedStatic") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProtectedStatic extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInProtectedStatic() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - } - @TestMetadata("compiler/testData/codegen/box/when") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index e5f94e5ea75..38d21ec3cdd 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -6215,19 +6215,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } - @TestMetadata("compiler/testData/codegen/box/inline") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Inline extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInInline() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inline"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - } - @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -7747,19 +7734,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } - @TestMetadata("compiler/testData/codegen/box/innerClass") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class InnerClass extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInInnerClass() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/innerClass"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - } - @TestMetadata("compiler/testData/codegen/box/innerNested") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -8047,19 +8021,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } - @TestMetadata("compiler/testData/codegen/box/interfaces") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Interfaces extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInInterfaces() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/interfaces"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - } - @TestMetadata("compiler/testData/codegen/box/intrinsics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -8483,6 +8444,58 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } + @TestMetadata("compiler/testData/codegen/box/javaVisibility") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class JavaVisibility extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInJavaVisibility() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/package") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Package extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/package"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedAndPackage") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ProtectedAndPackage extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInProtectedAndPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedAndPackage"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/javaVisibility/protectedStatic") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ProtectedStatic extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInProtectedStatic() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaVisibility/protectedStatic"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + } + @TestMetadata("compiler/testData/codegen/box/jdk") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -11642,19 +11655,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } - @TestMetadata("compiler/testData/codegen/box/property") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Property extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInProperty() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/property"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - } - @TestMetadata("compiler/testData/codegen/box/publishedApi") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -13678,19 +13678,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } - @TestMetadata("compiler/testData/codegen/box/staticFun") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class StaticFun extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInStaticFun() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/staticFun"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - } - @TestMetadata("compiler/testData/codegen/box/statics") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -14899,71 +14886,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } - @TestMetadata("compiler/testData/codegen/box/varargs") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Varargs extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInVarargs() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/varargs"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Visibility extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInVisibility() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - - @TestMetadata("compiler/testData/codegen/box/visibility/package") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Package extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/package"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility/protectedAndPackage") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProtectedAndPackage extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInProtectedAndPackage() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedAndPackage"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - } - - @TestMetadata("compiler/testData/codegen/box/visibility/protectedStatic") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProtectedStatic extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInProtectedStatic() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/visibility/protectedStatic"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - } - } - @TestMetadata("compiler/testData/codegen/box/when") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 70f462781a96e9f697aec39e328a6ae85cfeab13 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Wed, 10 Feb 2021 14:34:08 -0800 Subject: [PATCH 021/368] FIR-IDE: add mappings for backing field diagnostics --- .../diagnostics/KtFirDataClassConverters.kt | 18 ++++++++++++++++ .../api/fir/diagnostics/KtFirDiagnostics.kt | 12 +++++++++++ .../fir/diagnostics/KtFirDiagnosticsImpl.kt | 21 +++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt index 7168f951a3e..88bf828900c 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -848,6 +848,24 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirErrors.BACKING_FIELD_IN_INTERFACE) { firDiagnostic -> + BackingFieldInInterfaceImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXTENSION_PROPERTY_WITH_BACKING_FIELD) { firDiagnostic -> + ExtensionPropertyWithBackingFieldImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.PROPERTY_INITIALIZER_NO_BACKING_FIELD) { firDiagnostic -> + PropertyInitializerNoBackingFieldImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } add(FirErrors.ABSTRACT_DELEGATED_PROPERTY) { firDiagnostic -> AbstractDelegatedPropertyImpl( firDiagnostic as FirPsiDiagnostic<*>, diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt index c14587e956d..bbadc0bd85f 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -602,6 +602,18 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { override val diagnosticClass get() = PropertyWithNoTypeNoInitializer::class } + abstract class BackingFieldInInterface : KtFirDiagnostic() { + override val diagnosticClass get() = BackingFieldInInterface::class + } + + abstract class ExtensionPropertyWithBackingField : KtFirDiagnostic() { + override val diagnosticClass get() = ExtensionPropertyWithBackingField::class + } + + abstract class PropertyInitializerNoBackingField : KtFirDiagnostic() { + override val diagnosticClass get() = PropertyInitializerNoBackingField::class + } + abstract class AbstractDelegatedProperty : KtFirDiagnostic() { override val diagnosticClass get() = AbstractDelegatedProperty::class } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index 7f4c57fb3fa..fe6670f3489 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -966,6 +966,27 @@ internal class PropertyWithNoTypeNoInitializerImpl( override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) } +internal class BackingFieldInInterfaceImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.BackingFieldInInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) +} + +internal class ExtensionPropertyWithBackingFieldImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExtensionPropertyWithBackingField(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) +} + +internal class PropertyInitializerNoBackingFieldImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.PropertyInitializerNoBackingField(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) +} + internal class AbstractDelegatedPropertyImpl( firDiagnostic: FirPsiDiagnostic<*>, override val token: ValidityToken, From 3d635b6a941f864d07016a9d66c1e431c475a645 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Thu, 11 Feb 2021 01:00:36 -0800 Subject: [PATCH 022/368] FIR: unwrap smartcast expression when extracting effects of contract --- .../returnsImplies/conditionLogic.fir.txt | 6 ++ .../contracts/ConeEffectExtractor.kt | 7 ++ .../analysis/smartcasts/neg/12.fir.kt | 2 +- .../analysis/smartcasts/pos/11.fir.kt | 8 +- .../analysis/smartcasts/pos/13.fir.kt | 2 +- .../analysis/smartcasts/pos/3.fir.kt | 20 ++--- .../analysis/smartcasts/pos/5.fir.kt | 30 +++---- .../analysis/smartcasts/pos/6.fir.kt | 90 +++++++++---------- 8 files changed, 89 insertions(+), 76 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/conditionLogic.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/conditionLogic.fir.txt index eac7a472ce7..3e45ef0de81 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/conditionLogic.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/conditionLogic.fir.txt @@ -11,6 +11,7 @@ FILE: conditionLogic.kt @R|kotlin/OptIn|(vararg((Q|kotlin/contracts/ExperimentalContracts|))) public final fun test2(x: R|kotlin/String?|): R|kotlin/Any?| [R|Contract description] < + Returns(NOT_NULL) -> x is kotlin/String && x != null > { [StubStatement] @@ -46,6 +47,7 @@ FILE: conditionLogic.kt @R|kotlin/OptIn|(vararg((Q|kotlin/contracts/ExperimentalContracts|))) public final fun test6(x: R|kotlin/Any?|): R|kotlin/Any?| [R|Contract description] < + Returns(TRUE) -> x is kotlin/String? && x != null > { [StubStatement] @@ -54,6 +56,7 @@ FILE: conditionLogic.kt @R|kotlin/OptIn|(vararg((Q|kotlin/contracts/ExperimentalContracts|))) public final fun test7(x: R|kotlin/Any?|): R|kotlin/Any?| [R|Contract description] < + Returns(TRUE) -> x is kotlin/String? && x != null || x is kotlin/Int > { [StubStatement] @@ -95,6 +98,7 @@ FILE: conditionLogic.kt @R|kotlin/OptIn|(vararg((Q|kotlin/contracts/ExperimentalContracts|))) public final fun test11(x: R|kotlin/Any?|): R|kotlin/Any?| [R|Contract description] < + Returns(TRUE) -> x is kotlin/Comparable<*> && x is kotlin/CharSequence > { [StubStatement] @@ -103,6 +107,7 @@ FILE: conditionLogic.kt @R|kotlin/OptIn|(vararg((Q|kotlin/contracts/ExperimentalContracts|))) public final fun test12(x: R|kotlin/Any?|): R|kotlin/Any?| [R|Contract description] < + Returns(TRUE) -> x is kotlin/Comparable<*> && x is kotlin/CharSequence || x is kotlin/Number > { [StubStatement] @@ -111,6 +116,7 @@ FILE: conditionLogic.kt @R|kotlin/OptIn|(vararg((Q|kotlin/contracts/ExperimentalContracts|))) public final fun test13(x: R|kotlin/Any?|): R|kotlin/Any?| [R|Contract description] < + Returns(TRUE) -> (!)x !is kotlin/Comparable<*> || x !is kotlin/CharSequence && (!x is kotlin/Number) > { [StubStatement] diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/contracts/ConeEffectExtractor.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/contracts/ConeEffectExtractor.kt index 9ba71745f86..23e5803301a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/contracts/ConeEffectExtractor.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/contracts/ConeEffectExtractor.kt @@ -109,6 +109,13 @@ class ConeEffectExtractor( return ConeIsNullPredicate(arg, isNegated) } + override fun visitExpressionWithSmartcast( + expressionWithSmartcast: FirExpressionWithSmartcast, + data: Nothing? + ): ConeContractDescriptionElement? { + return expressionWithSmartcast.originalExpression.accept(this, data) + } + override fun visitQualifiedAccessExpression( qualifiedAccessExpression: FirQualifiedAccessExpression, data: Nothing? diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/12.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/12.fir.kt index babfa6740a8..32a63789fe8 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/12.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/12.fir.kt @@ -31,5 +31,5 @@ fun case_1(value_1: Any?) { // TESTCASE NUMBER: 2 fun case_2(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?) { value_1.case_2(value_2, value_3, value_4) - println(value_1.toByte()) + println(value_1.toByte()) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/11.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/11.fir.kt index 0a357e3fa9f..fca29cd99e1 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/11.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/11.fir.kt @@ -51,8 +51,8 @@ class case_3 { fun case_3(value_1: Any?, value_2: Number?) { val o = case_3() contracts.case_3(value_1, value_2, o.prop_1, this.prop_1) - println(o.prop_1.plus(3)) - println(this.prop_1.plus(3)) + println(o.prop_1.plus(3)) + println(this.prop_1.plus(3)) } } @@ -62,8 +62,8 @@ class case_4 { fun case_4(value_1: Any?, value_2: Number?) { val o = case_4() if (contracts.case_4(value_1, value_2, o.prop_1, this.prop_1)) { - println(o.prop_1.plus(3)) - println(this.prop_1.plus(3)) + println(o.prop_1.plus(3)) + println(this.prop_1.plus(3)) } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/13.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/13.fir.kt index babfa6740a8..32a63789fe8 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/13.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/13.fir.kt @@ -31,5 +31,5 @@ fun case_1(value_1: Any?) { // TESTCASE NUMBER: 2 fun case_2(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?) { value_1.case_2(value_2, value_3, value_4) - println(value_1.toByte()) + println(value_1.toByte()) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/3.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/3.fir.kt index e67dd1005fc..6fb01fcd8bf 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/3.fir.kt @@ -102,9 +102,9 @@ class case_3_class { fun case_3(value_1: Any?, value_2: Number?) { val o = case_3_class() contracts.case_3(value_1, value_2, o.prop_1, this.prop_1) - println(value_1.dec()) + println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } } @@ -154,24 +154,24 @@ class case_6_class { fun case_6(value_1: Any?, value_2: Number?) { val o = case_6_class() if (contracts.case_6_1(value_1, value_2, o.prop_1, this.prop_1)) { - println(value_1.dec()) + println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (!contracts.case_6_2(value_1, value_2, o.prop_1, this.prop_1)) { - println(value_1.dec()) + println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (contracts.case_6_3(value_1, value_2, o.prop_1, this.prop_1) != null) { - println(value_1.dec()) + println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (contracts.case_6_4(value_1, value_2, o.prop_1, this.prop_1) == null) { - println(value_1.dec()) + println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/5.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/5.fir.kt index 22f5efe5c2f..c33ea8bc085 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/5.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/5.fir.kt @@ -85,41 +85,41 @@ import contracts.* // TESTCASE NUMBER: 1 fun case_1(value_1: Any?) { value_1.case_1() - println(value_1.length) + println(value_1.length) } // TESTCASE NUMBER: 2 fun case_2(value_1: Number?) { value_1.case_2() - println(value_1.inv()) + println(value_1.inv()) } // TESTCASE NUMBER: 3 fun case_3(value_1: Any?) { value_1.case_3() - println(value_1.inv()) + println(value_1.inv()) } // TESTCASE NUMBER: 4 fun case_4(value_1: Any?, value_2: Any?, value_3: Any?) { - when { value_1.case_4_1() -> println(value_1.length) } - when { !value_2.case_4_2() -> println(value_2.length) } - when { value_3.case_4_3() != null -> println(value_3.length) } - when { value_3.case_4_4() == null -> println(value_3.length) } + when { value_1.case_4_1() -> println(value_1.length) } + when { !value_2.case_4_2() -> println(value_2.length) } + when { value_3.case_4_3() != null -> println(value_3.length) } + when { value_3.case_4_4() == null -> println(value_3.length) } } // TESTCASE NUMBER: 5 fun case_5(value_1: Number?, value_2: Number?, value_3: Number?) { - if (value_1.case_5_1()) println(value_1.inv()) - if (!value_2.case_5_2()) println(value_2.inv()) - if (value_3.case_5_3() != null) println(value_3.inv()) - if (value_3.case_5_4() == null) println(value_3.inv()) + if (value_1.case_5_1()) println(value_1.inv()) + if (!value_2.case_5_2()) println(value_2.inv()) + if (value_3.case_5_3() != null) println(value_3.inv()) + if (value_3.case_5_4() == null) println(value_3.inv()) } // TESTCASE NUMBER: 6 fun case_6(value_1: Any?, value_2: Any?, value_3: Any?) { - if (value_1.case_6_1()) println(value_1.inv()) - if (!value_2.case_6_2()) println(value_2.inv()) - if (value_3.case_6_3() != null) println(value_3.inv()) - if (value_3.case_6_4() == null) println(value_3.inv()) + if (value_1.case_6_1()) println(value_1.inv()) + if (!value_2.case_6_2()) println(value_2.inv()) + if (value_3.case_6_3() != null) println(value_3.inv()) + if (value_3.case_6_4() == null) println(value_3.inv()) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/6.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/6.fir.kt index e34ca6410b2..3a15f23cfe1 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/6.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/pos/6.fir.kt @@ -109,56 +109,56 @@ import contracts.* // TESTCASE NUMBER: 1 fun case_1(value_1: Any?, value_2: Int?) { value_1.case_1(value_2) - println(value_1.length) - println(value_2.inv()) + println(value_1.length) + println(value_2.inv()) } // TESTCASE NUMBER: 2 fun case_2(value_1: Number?, value_2: Any?) { value_1.case_2(value_2) - println(value_1.inv()) - println(value_2.toByte()) + println(value_1.inv()) + println(value_2.toByte()) } // TESTCASE NUMBER: 3 fun case_3(value_1: Any?, value_2: String?) { value_1.case_3(value_2) - println(value_1.inv()) - println(value_2.length) + println(value_1.inv()) + println(value_2.length) } // TESTCASE NUMBER: 4 fun case_4(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?) { value_1.case_4(value_2, value_3, value_4) - println(value_2.inv()) - println(value_3.toByte()) - println(value_4.length) + println(value_2.inv()) + println(value_3.toByte()) + println(value_4.length) } // TESTCASE NUMBER: 5 fun case_5(value_1: Any?, value_2: Int?, value_3: Any?, value_4: Int?, value_5: Any?, value_6: Int?) { when { value_1.case_5_1(value_2) -> { - println(value_1.length) - println(value_2.inv()) + println(value_1.length) + println(value_2.inv()) } } when { !value_3.case_5_2(value_4) -> { - println(value_3.length) - println(value_4.inv()) + println(value_3.length) + println(value_4.inv()) } } when { value_5.case_5_3(value_6) != null -> { - println(value_5.length) - println(value_6.inv()) + println(value_5.length) + println(value_6.inv()) } } when { value_5.case_5_4(value_6) == null -> { - println(value_5.length) - println(value_6.inv()) + println(value_5.length) + println(value_6.inv()) } } } @@ -166,55 +166,55 @@ fun case_5(value_1: Any?, value_2: Int?, value_3: Any?, value_4: Int?, value_5: // TESTCASE NUMBER: 6 fun case_6(value_1: Number?, value_2: Any?, value_3: Number?, value_4: Any?, value_5: Number?, value_6: Any?) { if (value_1.case_6_1(value_2)) { - println(value_1.inv()) - println(value_2.toByte()) + println(value_1.inv()) + println(value_2.toByte()) } if (!value_3.case_6_2(value_4)) { - println(value_3.inv()) - println(value_4.toByte()) + println(value_3.inv()) + println(value_4.toByte()) } if (value_5.case_6_3(value_6) != null) { - println(value_5.inv()) - println(value_6.toByte()) + println(value_5.inv()) + println(value_6.toByte()) } if (value_5.case_6_4(value_6) == null) { - println(value_5.inv()) - println(value_6.toByte()) + println(value_5.inv()) + println(value_6.toByte()) } } // TESTCASE NUMBER: 7 fun case_7(value_1: Any?, value_2: String?, value_3: Any?, value_4: String?, value_5: Any?, value_6: String?) { if (value_1.case_7_1(value_2)) { - println(value_1.inv()) - println(value_2.length) + println(value_1.inv()) + println(value_2.length) } if (value_3.case_7_2(value_4)) { - println(value_3.inv()) - println(value_4.length) + println(value_3.inv()) + println(value_4.length) } if (value_5.case_7_3(value_6) != null) { - println(value_5.inv()) - println(value_6.length) + println(value_5.inv()) + println(value_6.length) } if (value_5.case_7_4(value_6) == null) { - println(value_5.inv()) - println(value_6.length) + println(value_5.inv()) + println(value_6.length) } } // TESTCASE NUMBER: 8 fun case_8(value_1: Any?, value_2: Number, value_3: Any?, value_4: String?, value_5: Any?, value_6: Number, value_7: Any?, value_8: String?) { - when { value_1.case_8_1(value_2, value_3, value_4) -> println(value_2.inv()) } - when { value_1.case_8_1(value_2, value_3, value_4) -> println(value_3.toByte()) } - when { value_1.case_8_1(value_2, value_3, value_4) -> println(value_4.length) } - when { !value_5.case_8_2(value_6, value_7, value_8) -> println(value_6.inv()) } - when { !value_5.case_8_2(value_6, value_7, value_8) -> println(value_7.toByte()) } - when { !value_5.case_8_2(value_6, value_7, value_8) -> println(value_8.length) } - when { value_5.case_8_3(value_6, value_7, value_8) != null -> println(value_6.inv()) } - when { value_5.case_8_3(value_6, value_7, value_8) != null -> println(value_7.toByte()) } - when { value_5.case_8_3(value_6, value_7, value_8) != null -> println(value_8.length) } - when { value_5.case_8_4(value_6, value_7, value_8) == null -> println(value_6.inv()) } - when { value_5.case_8_4(value_6, value_7, value_8) == null -> println(value_7.toByte()) } - when { value_5.case_8_4(value_6, value_7, value_8) == null -> println(value_8.length) } + when { value_1.case_8_1(value_2, value_3, value_4) -> println(value_2.inv()) } + when { value_1.case_8_1(value_2, value_3, value_4) -> println(value_3.toByte()) } + when { value_1.case_8_1(value_2, value_3, value_4) -> println(value_4.length) } + when { !value_5.case_8_2(value_6, value_7, value_8) -> println(value_6.inv()) } + when { !value_5.case_8_2(value_6, value_7, value_8) -> println(value_7.toByte()) } + when { !value_5.case_8_2(value_6, value_7, value_8) -> println(value_8.length) } + when { value_5.case_8_3(value_6, value_7, value_8) != null -> println(value_6.inv()) } + when { value_5.case_8_3(value_6, value_7, value_8) != null -> println(value_7.toByte()) } + when { value_5.case_8_3(value_6, value_7, value_8) != null -> println(value_8.length) } + when { value_5.case_8_4(value_6, value_7, value_8) == null -> println(value_6.inv()) } + when { value_5.case_8_4(value_6, value_7, value_8) == null -> println(value_7.toByte()) } + when { value_5.case_8_4(value_6, value_7, value_8) == null -> println(value_8.length) } } From 20f9787c700287d0e7aafe437d37bf309ea014e9 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Tue, 9 Feb 2021 15:58:30 -0800 Subject: [PATCH 023/368] FIR checker: report errors in contract description --- .../diagnostics/FirDiagnosticsList.kt | 6 ++++ .../fir/analysis/diagnostics/FirErrors.kt | 4 +++ .../declaration/FirContractChecker.kt | 36 +++++++++++++++++++ .../diagnostics/FirDefaultErrorMessages.kt | 4 +++ .../coneDiagnosticToFirDiagnostic.kt | 1 + .../fir/checkers/CommonDeclarationCheckers.kt | 1 + .../providers/impl/FirTypeResolverImpl.kt | 2 +- .../dsl/errors/accessToOuterThis.fir.kt | 8 ++--- .../dsl/errors/booleanComparisons.fir.kt | 4 +-- .../errors/callInContractDescription.fir.kt | 2 +- .../illegalConstructionInContractBlock.fir.kt | 20 +++++------ .../dsl/errors/illegalEqualsCondition.fir.kt | 8 ++--- .../errors/nestedConditionalEffects.fir.kt | 2 +- .../dsl/errors/recursiveContract.fir.kt | 8 ++--- .../dsl/errors/referenceToProperty.1.3.fir.kt | 2 +- .../dsl/errors/referenceToProperty.1.4.fir.kt | 2 +- .../dsl/errors/unlabeledReceiver.fir.kt | 2 +- .../contractBuilder/common/neg/12.fir.kt | 2 +- .../contractBuilder/common/neg/13.fir.kt | 2 +- .../contractBuilder/common/neg/17.fir.kt | 4 +-- .../contractBuilder/common/neg/2.fir.kt | 8 ++--- .../contractBuilder/common/neg/3.fir.kt | 12 +++---- .../contractBuilder/common/neg/4.fir.kt | 6 ++-- .../contractBuilder/common/neg/5.fir.kt | 14 ++++---- .../contractBuilder/common/neg/6.fir.kt | 14 ++++---- .../effects/common/neg/1.fir.kt | 12 +++---- .../effects/returns/neg/1.fir.kt | 8 ++--- .../effects/returns/neg/2.fir.kt | 8 ++--- .../effects/returns/neg/3.fir.kt | 2 +- .../effects/returns/neg/4.fir.kt | 6 ++-- .../effects/returns/neg/5.fir.kt | 2 +- .../effects/returns/neg/6.fir.kt | 14 ++++---- .../contractFunction/neg/2.fir.kt | 8 ++--- .../diagnostics/KtFirDataClassConverters.kt | 8 +++++ .../api/fir/diagnostics/KtFirDiagnostics.kt | 6 ++++ .../fir/diagnostics/KtFirDiagnosticsImpl.kt | 9 +++++ 36 files changed, 166 insertions(+), 91 deletions(-) create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirContractChecker.kt diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 1738edd5ae3..542e8bf46d3 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -381,6 +381,12 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val INVALID_IF_AS_EXPRESSION by error(PositioningStrategy.IF_EXPRESSION) } + group("Function contracts") { + val ERROR_IN_CONTRACT_DESCRIPTION by error { + parameter("reason") + } + } + group("Extended checkers") { val REDUNDANT_VISIBILITY_MODIFIER by warning(PositioningStrategy.VISIBILITY_MODIFIER) val REDUNDANT_MODALITY_MODIFIER by warning(PositioningStrategy.MODALITY_MODIFIER) diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 9d386bcdc7f..3d8f70a05e2 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtDestructuringDeclaration +import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.KtIfExpression @@ -239,6 +240,9 @@ object FirErrors { val NO_ELSE_IN_WHEN by error1>(SourceElementPositioningStrategies.WHEN_EXPRESSION) val INVALID_IF_AS_EXPRESSION by error0(SourceElementPositioningStrategies.IF_EXPRESSION) + // Function contracts + val ERROR_IN_CONTRACT_DESCRIPTION by error1() + // Extended checkers val REDUNDANT_VISIBILITY_MODIFIER by warning0(SourceElementPositioningStrategies.VISIBILITY_MODIFIER) val REDUNDANT_MODALITY_MODIFIER by warning0(SourceElementPositioningStrategies.MODALITY_MODIFIER) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirContractChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirContractChecker.kt new file mode 100644 index 00000000000..1b0c75b4052 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirContractChecker.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2021 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.fir.analysis.checkers.declaration + +import org.jetbrains.kotlin.fir.FirFakeSourceElementKind +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.contracts.FirResolvedContractDescription +import org.jetbrains.kotlin.fir.declarations.FirContractDescriptionOwner +import org.jetbrains.kotlin.fir.declarations.FirFunction + +object FirContractChecker : FirFunctionChecker() { + // TODO: The message should vary. Migrate this to [ConeEffectExtractor] when creating fine-grained errors. + private const val UNEXPECTED_CONSTRUCTION = "unexpected construction in contract description" + + override fun check(declaration: FirFunction<*>, context: CheckerContext, reporter: DiagnosticReporter) { + if (declaration !is FirContractDescriptionOwner || + declaration.contractDescription !is FirResolvedContractDescription + ) { + return + } + + // Any statements that [ConeEffectExtractor] cannot extract effects will be in `unresolvedEffects`. + for (statement in (declaration.contractDescription as FirResolvedContractDescription).unresolvedEffects) { + if (statement.source == null || statement.source!!.kind is FirFakeSourceElementKind) continue + + // TODO: report on fine-grained locations, e.g., ... implies unresolved => report on unresolved, not the entire statement. + // but, sometimes, it's just reported on `contract`... + reporter.report(FirErrors.ERROR_IN_CONTRACT_DESCRIPTION.on(statement.source!!, UNEXPECTED_CONSTRUCTION), context) + } + } +} diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index 6c4d88dc6c3..8cde51292cc 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -60,6 +60,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DESERIALIZATION_E import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.EMPTY_RANGE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ENUM_AS_SUPERTYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ERROR_FROM_JAVA_RESOLUTION +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ERROR_IN_CONTRACT_DESCRIPTION import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.EXPECTED_DECLARATION_WITH_BODY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.EXPECTED_DELEGATED_PROPERTY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.EXPECTED_PRIVATE_DECLARATION @@ -535,6 +536,9 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { map.put(NO_ELSE_IN_WHEN, "''when'' expression must be exhaustive, add necessary {0}", WHEN_MISSING_CASES) map.put(INVALID_IF_AS_EXPRESSION, "'if' must have both main and 'else' branches if used as an expression") + // Function contracts + map.put(ERROR_IN_CONTRACT_DESCRIPTION, "Error in contract description", TO_STRING) + // Extended checkers group map.put(REDUNDANT_VISIBILITY_MODIFIER, "Redundant visibility modifier") map.put(REDUNDANT_MODALITY_MODIFIER, "Redundant modality modifier") diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt index e0cd577497c..440c5992509 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt @@ -46,6 +46,7 @@ fun ConeDiagnostic.toFirDiagnostic(source: FirSourceElement): FirDiagnostic FirErrors.INSTANCE_ACCESS_BEFORE_SUPER_CALL.on(source, this.target) is ConeStubDiagnostic -> null is ConeIntermediateDiagnostic -> null + is ConeContractDescriptionError -> FirErrors.ERROR_IN_CONTRACT_DESCRIPTION.on(source, this.reason) else -> throw IllegalArgumentException("Unsupported diagnostic type: ${this.javaClass}") } diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt index d2ea9f0135d..b0483c84c70 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt @@ -27,6 +27,7 @@ object CommonDeclarationCheckers : DeclarationCheckers() { ) override val functionCheckers: Set = setOf( + FirContractChecker, FirFunctionNameChecker, ) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt index 3f87e66f80b..29f96da6c84 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt @@ -181,7 +181,7 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() { } is FirFunctionTypeRef -> createFunctionalType(typeRef) is FirDynamicTypeRef -> ConeKotlinErrorType(ConeIntermediateDiagnostic("Not supported: ${typeRef::class.simpleName}")) - else -> error("!") + else -> error(typeRef.render()) } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/accessToOuterThis.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/accessToOuterThis.fir.kt index dff2d7c2e5f..4220f63f9f1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/accessToOuterThis.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/accessToOuterThis.fir.kt @@ -10,19 +10,19 @@ class Foo { inner class Bar { fun good() { contract { - returns() implies (this@Bar != null) + returns() implies (this@Bar != null) } } fun badOuter() { contract { - returns() implies (this@Foo != null) + returns() implies (this@Foo != null) } } fun badInner() { contract { - returns() implies (this != null) + returns() implies (this != null) } } @@ -34,7 +34,7 @@ class Foo { fun A?.badWithReceiver() { contract { - returns() implies (this@Bar != null) + returns() implies (this@Bar != null) } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/booleanComparisons.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/booleanComparisons.fir.kt index b65f3ded19a..cd2a2e09d42 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/booleanComparisons.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/booleanComparisons.fir.kt @@ -7,7 +7,7 @@ import kotlin.contracts.* fun foo(b: Boolean): Boolean { contract { // pointless, can be reduced to just "b" - returns(true) implies (b == true) + returns(true) implies (b == true) } return b @@ -16,7 +16,7 @@ fun foo(b: Boolean): Boolean { fun bar(b: Boolean?): Boolean { contract { // not pointless, but not supported yet - returns(true) implies (b == true) + returns(true) implies (b == true) } if (b == null) throw java.lang.IllegalArgumentException("") return b diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/callInContractDescription.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/callInContractDescription.fir.kt index a4bf44632ad..caa02ce70b8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/callInContractDescription.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/callInContractDescription.fir.kt @@ -8,7 +8,7 @@ fun bar(x: Int): Boolean = x == 0 fun foo(x: Int): Boolean { contract { - returns(true) implies (bar(x)) + returns(true) implies (bar(x)) } return x == 0 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalConstructionInContractBlock.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalConstructionInContractBlock.fir.kt index 9d3d73dc753..c7be0627094 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalConstructionInContractBlock.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalConstructionInContractBlock.fir.kt @@ -6,26 +6,26 @@ import kotlin.contracts.* fun ifInContract(x: Any?, boolean: Boolean) { contract { - if (boolean) { + if (boolean) { returns() implies (x is String) } else { returns() implies (x is Int) - } + } } } fun whenInContract(x: Any?, boolean: Boolean) { contract { - when (boolean) { + when (boolean) { true -> returns() implies (x is String) else -> returns() implies (x is Int) - } + } } } fun forInContract(x: Any?) { contract { - for (i in 0..1) { + for (i in 0..1) { returns() implies (x is String) } } @@ -33,23 +33,23 @@ fun forInContract(x: Any?) { fun whileInContract(x: Any?) { contract { - while (false) { + while (false) { returns() implies (x is String) - } + } } } fun doWhileInContract(x: Any?) { contract { - do { + do { returns() implies (x is String) - } while (false) + } while (false) } } fun localValInContract(x: Any?) { contract { - val y: Int = 42 + val y: Int = 42 returns() implies (x is String) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalEqualsCondition.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalEqualsCondition.fir.kt index 7648c66f380..7b977263d48 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalEqualsCondition.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/illegalEqualsCondition.fir.kt @@ -6,25 +6,25 @@ import kotlin.contracts.* fun equalsWithVariables(x: Any?, y: Any?) { contract { - returns() implies (x == y) + returns() implies (x == y) } } fun identityEqualsWithVariables(x: Any?, y: Any?) { contract { - returns() implies (x === y) + returns() implies (x === y) } } fun equalConstants() { contract { - returns() implies (null == null) + returns() implies (null == null) } } fun get(): Int? = null fun equalNullWithCall() { contract { - returns() implies (get() == null) + returns() implies (get() == null) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/nestedConditionalEffects.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/nestedConditionalEffects.fir.kt index 355fe9efdea..4fe389bea2f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/nestedConditionalEffects.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/nestedConditionalEffects.fir.kt @@ -6,6 +6,6 @@ import kotlin.contracts.* fun foo(boolean: Boolean) { contract { - (returns() implies (boolean)) implies (!boolean) + (returns() implies (boolean)) implies (!boolean) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/recursiveContract.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/recursiveContract.fir.kt index 457ee97992e..18590fe4036 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/recursiveContract.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/recursiveContract.fir.kt @@ -5,21 +5,21 @@ import kotlin.contracts.* fun case_1(): Boolean { - contract { returns(null) implies case_1() } + contract { returns(null) implies case_1() } return true } fun case_2(): Boolean { - contract { returns(null) implies case_3() } + contract { returns(null) implies case_3() } return true } fun case_3(): Boolean { - contract { returns(null) implies case_2() } + contract { returns(null) implies case_2() } return true } fun case_4(): Boolean { - kotlin.contracts.contract { returns(null) implies case_1() } + kotlin.contracts.contract { returns(null) implies case_1() } return true } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.3.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.3.fir.kt index 19f33a80b18..3dc1ddea7c9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.3.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.3.fir.kt @@ -7,7 +7,7 @@ import kotlin.contracts.* class Foo(val x: Int?) { fun isXNull(): Boolean { contract { - returns(false) implies (x != null) + returns(false) implies (x != null) } return x != null } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.4.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.4.fir.kt index 50094ad12d5..e56ebeb0dc5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.4.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/referenceToProperty.1.4.fir.kt @@ -7,7 +7,7 @@ import kotlin.contracts.* class Foo(val x: Int?) { fun isXNull(): Boolean { contract { - returns(false) implies (x != null) + returns(false) implies (x != null) } return x != null } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/unlabeledReceiver.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/unlabeledReceiver.fir.kt index 51f0c4965ac..554bf1a62ba 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/unlabeledReceiver.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/unlabeledReceiver.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* fun Any?.foo(): Boolean { contract { - returns(true) implies (this != null) + returns(true) implies (this != null) } return this != null } \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.fir.kt index 38a941058c5..a578d91a6ff 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/12.fir.kt @@ -26,7 +26,7 @@ inline fun case_1(block: () -> Unit) { // TESTCASE NUMBER: 2 inline fun case_2(block: () -> Unit) { - contract { callsInPlaceEffectBuilder(block) } + contract { callsInPlaceEffectBuilder(block) } return block() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/13.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/13.fir.kt index 6cc718a58a6..352fdaa02f2 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/13.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/13.fir.kt @@ -5,6 +5,6 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun case_1(value_1: Any?, block: () -> Unit) { - contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) implies (value_1 != null) } + contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) implies (value_1 != null) } if (value_1 != null) block() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/17.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/17.fir.kt index 42dd1bf2ed6..4466ef32039 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/17.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/17.fir.kt @@ -5,7 +5,7 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun case_1(): Boolean { - contract { returns(null) implies throw Exception() } + contract { returns(null) implies throw Exception() } return true } @@ -17,6 +17,6 @@ fun case_2(): Boolean { // TESTCASE NUMBER: 3 fun case_3(): Boolean { - contract { returns(null) implies return return return false && throw throw throw throw Exception() } + contract { returns(null) implies return return return false && throw throw throw throw Exception() } return true } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/2.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/2.fir.kt index 9efcbf5bcec..78286353e03 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/2.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/2.fir.kt @@ -5,24 +5,24 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun case_1(value_1: Boolean): Boolean { - contract { returns(true) implies (value_1 == true) } + contract { returns(true) implies (value_1 == true) } return value_1 == true } // TESTCASE NUMBER: 2 fun case_2(value_1: Boolean): Boolean? { - contract { returnsNotNull() implies (value_1 != false) } + contract { returnsNotNull() implies (value_1 != false) } return if (value_1 != false) true else null } // TESTCASE NUMBER: 3 fun case_3(value_1: String): Boolean { - contract { returns(false) implies (value_1 != "") } + contract { returns(false) implies (value_1 != "") } return !(value_1 != "") } // TESTCASE NUMBER: 4 fun case_4(value_1: Int): Boolean? { - contract { returns(null) implies (value_1 == 0) } + contract { returns(null) implies (value_1 == 0) } return if (value_1 == 0) null else true } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/3.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/3.fir.kt index 65c0a09c7ae..051a6ccc3fc 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/3.fir.kt @@ -5,36 +5,36 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun case_1(value_1: Boolean?): Boolean { - contract { returns(true) implies (value_1 != null && value_1 == false) } + contract { returns(true) implies (value_1 != null && value_1 == false) } return value_1 != null && value_1 == false } // TESTCASE NUMBER: 2 fun case_2(value_1: Boolean, value_2: Boolean): Boolean? { - contract { returnsNotNull() implies (value_1 != false || value_2) } + contract { returnsNotNull() implies (value_1 != false || value_2) } return if (value_1 != false || value_2) true else null } // TESTCASE NUMBER: 3 fun case_3(value_1: String?, value_2: Boolean): Boolean { - contract { returns(false) implies (value_1 != null && value_2 != true) } + contract { returns(false) implies (value_1 != null && value_2 != true) } return !(value_1 != null && value_2 != true) } // TESTCASE NUMBER: 4 fun case_4(value_1: Nothing?, value_2: Boolean?): Boolean? { - contract { returns(null) implies (value_1 == null || value_2 != null || value_2 == false) } + contract { returns(null) implies (value_1 == null || value_2 != null || value_2 == false) } return if (value_1 == null || value_2 != null || value_2 == false) null else true } // TESTCASE NUMBER: 5 fun case_5(value_1: Any?, value_2: String?): Boolean? { - contract { returns(null) implies (value_1 != null && value_2 != null || value_2 == ".") } + contract { returns(null) implies (value_1 != null && value_2 != null || value_2 == ".") } return if (value_1 != null && value_2 != null || value_2 == ".") null else true } // TESTCASE NUMBER: 6 fun case_6(value_1: Boolean, value_2: Int?): Boolean? { - contract { returns(null) implies (value_2 == null && value_1 || value_2 == 0) } + contract { returns(null) implies (value_2 == null && value_1 || value_2 == 0) } return if (value_2 == null && value_1 || value_2 == 0) null else true } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/4.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/4.fir.kt index 0175bcc78ff..eaf488edb7e 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/4.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/4.fir.kt @@ -6,18 +6,18 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun case_1(): Boolean? { - contract { returnsNotNull() implies (null) } + contract { returnsNotNull() implies (null) } return true } // TESTCASE NUMBER: 2 fun case_2(): Boolean { - contract { returns(false) implies 0.000001 } + contract { returns(false) implies 0.000001 } return true } // TESTCASE NUMBER: 3 fun case_3(): Boolean? { - contract { returns(null) implies "" } + contract { returns(null) implies "" } return null } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/5.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/5.fir.kt index ab132e2761b..4474d9ed507 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/5.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/5.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun case_1(): Boolean { - contract { returns(true) implies (-10) } + contract { returns(true) implies (-10) } return true } @@ -18,7 +18,7 @@ fun case_2(): Boolean { // TESTCASE NUMBER: 3 fun case_3(): Boolean { - contract { returns(false) implies ("..." + "$value_1") } + contract { returns(false) implies ("..." + "$value_1") } return true } @@ -27,26 +27,26 @@ fun case_3(): Boolean { * ISSUES: KT-26386 */ fun case_4(): Boolean? { - contract { returns(null) implies case_4() } + contract { returns(null) implies case_4() } return null } // TESTCASE NUMBER: 5 fun case_5(): Boolean? { - contract { returns(null) implies listOf(0) } + contract { returns(null) implies listOf(0) } return null } // TESTCASE NUMBER: 6 fun case_6(value_1: Boolean): Boolean? { - contract { returns(null) implies contract { returns(null) implies (!value_1) } } + contract { returns(null) implies contract { returns(null) implies (!value_1) } } return null } // TESTCASE NUMBER: 7 fun case_7(): Int { contract { - callsInPlace(::case_7, InvocationKind.EXACTLY_ONCE) + callsInPlace(::case_7, InvocationKind.EXACTLY_ONCE) } return 1 } @@ -57,7 +57,7 @@ fun case_7(): Int { */ fun case_8(): () -> Unit { contract { - callsInPlace(case_8(), InvocationKind.EXACTLY_ONCE) + callsInPlace(case_8(), InvocationKind.EXACTLY_ONCE) } return {} } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/6.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/6.fir.kt index e2610ff368f..5a6cb3c5bb1 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/6.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/common/neg/6.fir.kt @@ -11,16 +11,16 @@ object case_1 { private const val value_3 = false fun case_1_1(): Boolean? { - contract { returnsNotNull() implies (value_1) } + contract { returnsNotNull() implies (value_1) } return if (value_1) true else null } fun case_1_2(): Boolean? { - contract { returns(null) implies (value_2) } + contract { returns(null) implies (value_2) } return if (value_2) null else true } fun case_1_3(): Boolean { - contract { returns(true) implies (value_3) } + contract { returns(true) implies (value_3) } return value_3 } } @@ -42,22 +42,22 @@ class case_2(value_5: Boolean, val value_1: Boolean) { } fun case_2_2(): Boolean? { - contract { returns(null) implies (value_1) } + contract { returns(null) implies (value_1) } return if (value_1) null else true } fun case_2_3(): Boolean { - contract { returns(true) implies (value_2) } + contract { returns(true) implies (value_2) } return value_2 } fun case_2_4(): Boolean { - contract { returns(false) implies (value_3) } + contract { returns(false) implies (value_3) } return !(value_3) } inline fun K.case_2_5(): Boolean? { - contract { returnsNotNull() implies (value_4) } + contract { returnsNotNull() implies (value_4) } return if (value_4) true else null } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/common/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/common/neg/1.fir.kt index 0847875e2eb..531de611468 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/common/neg/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/common/neg/1.fir.kt @@ -6,7 +6,7 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 inline fun case_1(block: () -> Unit) { contract { - { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }() + { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }() } return block() } @@ -14,7 +14,7 @@ inline fun case_1(block: () -> Unit) { // TESTCASE NUMBER: 2 fun case_2(x: Any?): Boolean { contract { - returns(true).apply { implies (x is Number) } // 'Returns' as result + returns(true).apply { implies (x is Number) } // 'Returns' as result } return x is Number } @@ -22,7 +22,7 @@ fun case_2(x: Any?): Boolean { // TESTCASE NUMBER: 3 fun case_3(x: Any?): Boolean { contract { - returns(true).also { it implies (x is Number) } // 'Returns' as result + returns(true).also { it implies (x is Number) } // 'Returns' as result } return x is Number } @@ -30,7 +30,7 @@ fun case_3(x: Any?): Boolean { // TESTCASE NUMBER: 4 fun case_4(x: Any?): Boolean { contract { - returns(true).let { it implies (x is Number) } // 'ConditionalEffect' as result + returns(true).let { it implies (x is Number) } // 'ConditionalEffect' as result } return x is Number } @@ -38,7 +38,7 @@ fun case_4(x: Any?): Boolean { // TESTCASE NUMBER: 5 fun case_5(x: Any?): Boolean { contract { - returns(true).run { implies (x is Number) } // 'ConditionalEffect' as result + returns(true).run { implies (x is Number) } // 'ConditionalEffect' as result } return x is Number } @@ -46,7 +46,7 @@ fun case_5(x: Any?): Boolean { // TESTCASE NUMBER: 6 fun case_6(x: Any?): Boolean { contract { - returns(true).takeIf { it implies (x is Number); false } // null, must be unrecognized effect + returns(true).takeIf { it implies (x is Number); false } // null, must be unrecognized effect } return x is Number } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/1.fir.kt index 0d613e0fb6d..f00e2896663 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/1.fir.kt @@ -4,24 +4,24 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun case_1(x: Any?): Boolean { - contract { returns(true) implies (x == -.15f) } + contract { returns(true) implies (x == -.15f) } return x !is Number } // TESTCASE NUMBER: 2 fun case_2(x: Any?): Boolean { - contract { returns(true) implies (x == "..." + ".") } + contract { returns(true) implies (x == "..." + ".") } return x !is Number } // TESTCASE NUMBER: 3 fun case_3(x: Int, y: Int): Boolean { - contract { returns(true) implies (x > y) } + contract { returns(true) implies (x > y) } return x > y } // TESTCASE NUMBER: 4 fun case_4(x: Any?, y: Any?): Boolean { - contract { returns(true) implies (x == y.toString()) } + contract { returns(true) implies (x == y.toString()) } return x !is Number } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/2.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/2.fir.kt index 94ac84aa1b2..38ceea84e7f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/2.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/2.fir.kt @@ -5,7 +5,7 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun Any?.case_1(): Boolean { contract { - returns(true) implies (this != null) + returns(true) implies (this != null) } return this != null } @@ -13,7 +13,7 @@ fun Any?.case_1(): Boolean { // TESTCASE NUMBER: 2 fun Any?.case_2(): Boolean { contract { - returnsNotNull() implies (this is Number?) + returnsNotNull() implies (this is Number?) } return this is Number? } @@ -21,7 +21,7 @@ fun Any?.case_2(): Boolean { // TESTCASE NUMBER: 3 fun T?.case_3(): Boolean { contract { - returnsNotNull() implies (this != null) + returnsNotNull() implies (this != null) } return this != null } @@ -29,7 +29,7 @@ fun T?.case_3(): Boolean { // TESTCASE NUMBER: 4 inline fun T.case_4(): Boolean { contract { - returns(null) implies (this is Int) + returns(null) implies (this is Int) } return this is Int } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/3.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/3.fir.kt index 97ee82bee80..c5dbf799439 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/3.fir.kt @@ -5,7 +5,7 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun case_1(x: Any?): Boolean { contract { - returns(true) implies (x === EmptyObject) // should be not allowed + returns(true) implies (x === EmptyObject) // should be not allowed } return x === EmptyObject } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/4.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/4.fir.kt index 3ef9b42003f..60a68a96487 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/4.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/4.fir.kt @@ -4,18 +4,18 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun case_1(x: Any?): Boolean { - contract { returns(true) implies (x == .15f) } + contract { returns(true) implies (x == .15f) } return x == .15f } // TESTCASE NUMBER: 2 fun case_2(x: Any?) { - contract { returns() implies (x == "...") } + contract { returns() implies (x == "...") } if (x != "...") throw Exception() } // TESTCASE NUMBER: 3 fun case_3(x: Any?): Boolean { - contract { returns(true) implies (x == '-') } + contract { returns(true) implies (x == '-') } return x == '-' } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/5.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/5.fir.kt index 04bb538c33b..c4dd4c9db1e 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/5.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/5.fir.kt @@ -4,6 +4,6 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun T.case_1(): Boolean? { - contract { returns(null) implies (!this@case_1) } + contract { returns(null) implies (!this@case_1) } return if (!this) null else true } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/6.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/6.fir.kt index 0f83224b627..c76aef1cda7 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/6.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractBuilder/effects/returns/neg/6.fir.kt @@ -4,42 +4,42 @@ import kotlin.contracts.* // TESTCASE NUMBER: 1 fun Boolean?.case_1(): Boolean { - contract { returns(true) implies (this@case_1 != null && this@case_1) } + contract { returns(true) implies (this@case_1 != null && this@case_1) } return this != null && this } // TESTCASE NUMBER: 2 fun T?.case_2(): Boolean { - contract { returns(true) implies (this@case_2 != null && this@case_2 !is Nothing && this@case_2) } + contract { returns(true) implies (this@case_2 != null && this@case_2 !is Nothing && this@case_2) } return this != null && this !is Nothing && this } // TESTCASE NUMBER: 3 fun T?.case_3() { - contract { returns() implies (this@case_3 == null || this@case_3 is Boolean? && !this@case_3) } + contract { returns() implies (this@case_3 == null || this@case_3 is Boolean? && !this@case_3) } if (!(this == null || this is Boolean? && !this)) throw Exception() } // TESTCASE NUMBER: 4 fun case_4(value_1: Boolean?): Boolean { - contract { returns(true) implies (value_1 != null && !value_1) } + contract { returns(true) implies (value_1 != null && !value_1) } return value_1 != null && !value_1 } // TESTCASE NUMBER: 5 fun Boolean.case_5(value_1: Any?): Boolean? { - contract { returnsNotNull() implies (value_1 is Boolean? && value_1 != null && value_1) } + contract { returnsNotNull() implies (value_1 is Boolean? && value_1 != null && value_1) } return if (value_1 is Boolean? && value_1 != null && value_1) true else null } // TESTCASE NUMBER: 6 fun Boolean?.case_6(): Boolean? { - contract { returnsNotNull() implies (this@case_6 != null && this@case_6) } + contract { returnsNotNull() implies (this@case_6 != null && this@case_6) } return if (this@case_6 != null && this@case_6) true else null } // TESTCASE NUMBER: 7 fun T.case_7(value_1: Any?): Boolean? { - contract { returnsNotNull() implies (value_1 is Boolean? && value_1 != null && value_1 && this@case_7 != null && this@case_7) } + contract { returnsNotNull() implies (value_1 is Boolean? && value_1 != null && value_1 && this@case_7 != null && this@case_7) } return if (value_1 is Boolean? && value_1 != null && value_1 && this@case_7 != null && this@case_7) true else null } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/2.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/2.fir.kt index 76c8939d1d7..779e59e9221 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/2.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/declarations/contractFunction/neg/2.fir.kt @@ -32,12 +32,12 @@ fun case_2() { class case_4 : ClassLevel3() { fun T.case_4_1(): Boolean { - contract { returns(false) implies (this@case_4 !is ClassLevel1) } + contract { returns(false) implies (this@case_4 !is ClassLevel1) } return this == null } fun T.case_4_2() { - contract { returns() implies (!this@case_4_2) } + contract { returns() implies (!this@case_4_2) } if (this) throw Exception() } @@ -60,12 +60,12 @@ class case_4 : ClassLevel3() { class case_5 : ClassLevel5() { inner class case_5_1 { fun K.case_5_1_1() { - contract { returns() implies (this@case_5_1 !is ClassLevel1 && this@case_5_1 != null || this@case_5 is ClassLevel1 && this@case_5_1_1 is Float) } + contract { returns() implies (this@case_5_1 !is ClassLevel1 && this@case_5_1 != null || this@case_5 is ClassLevel1 && this@case_5_1_1 is Float) } if (!(this@case_5_1 !is ClassLevel1 && this@case_5_1 != null || this@case_5 is ClassLevel1 && this is Float)) throw Exception() } fun case_5_1_2() { - contract { returns() implies (this@case_5_1 !is ClassLevel1 || this@case_5 is ClassLevel1 || this@case_5_1 == null) } + contract { returns() implies (this@case_5_1 !is ClassLevel1 || this@case_5 is ClassLevel1 || this@case_5_1 == null) } if (!(this@case_5_1 !is ClassLevel1 || this@case_5 is ClassLevel1 || this@case_5_1 == null)) throw Exception() } } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt index 88bf828900c..97feba597ca 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.psi import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtDestructuringDeclaration +import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.KtIfExpression @@ -1033,6 +1034,13 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirErrors.ERROR_IN_CONTRACT_DESCRIPTION) { firDiagnostic -> + ErrorInContractDescriptionImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } add(FirErrors.REDUNDANT_VISIBILITY_MODIFIER) { firDiagnostic -> RedundantVisibilityModifierImpl( firDiagnostic as FirPsiDiagnostic<*>, diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt index bbadc0bd85f..723cec5ae4b 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtDestructuringDeclaration +import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.KtIfExpression @@ -729,6 +730,11 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { override val diagnosticClass get() = InvalidIfAsExpression::class } + abstract class ErrorInContractDescription : KtFirDiagnostic() { + override val diagnosticClass get() = ErrorInContractDescription::class + abstract val reason: String + } + abstract class RedundantVisibilityModifier : KtFirDiagnostic() { override val diagnosticClass get() = RedundantVisibilityModifier::class } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index fe6670f3489..7a52c4f2f37 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtDestructuringDeclaration +import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.KtIfExpression @@ -1174,6 +1175,14 @@ internal class InvalidIfAsExpressionImpl( override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) } +internal class ErrorInContractDescriptionImpl( + override val reason: String, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ErrorInContractDescription(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) +} + internal class RedundantVisibilityModifierImpl( firDiagnostic: FirPsiDiagnostic<*>, override val token: ValidityToken, From abc44fa65885709b4eb5c9999968047bc03ba241 Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Thu, 11 Feb 2021 18:39:34 +0300 Subject: [PATCH 024/368] Increase -Xmx for Ant tests --- .../org/jetbrains/kotlin/integration/AbstractAntTaskTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java index 59b8f8a2675..afced777590 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/integration/AbstractAntTaskTest.java @@ -38,7 +38,7 @@ public abstract class AbstractAntTaskTest extends KotlinIntegrationTestBase { runJava( testDataDir, "build.log", - "-Xmx192m", + "-Xmx256m", "-Dkotlin.lib=" + KotlinIntegrationTestBase.getCompilerLib(), "-Dkotlin.runtime.jar=" + ForTestCompileRuntime.runtimeJarForTests().getAbsolutePath(), "-Dkotlin.reflect.jar=" + ForTestCompileRuntime.reflectJarForTests().getAbsolutePath(), From 7eb5fc77785cc85a3fd637d0061b4d6a29519755 Mon Sep 17 00:00:00 2001 From: Vyacheslav Karpukhin Date: Thu, 11 Feb 2021 23:16:59 +0100 Subject: [PATCH 025/368] AndroidDependencyResolver: fixed NPE --- .../android/internal/AndroidDependencyResolver.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt index d114a9cd983..e19cf57e322 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt @@ -126,11 +126,13 @@ object AndroidDependencyResolver { if (entry.key == "androidMain") { // this is a terrible hack, but looks like the only way, other than proper support via light-classes val task = project.tasks.findByName("processDebugResources") - getClassOrNull("com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask")?.let { linkAppClass -> - @Suppress("UNCHECKED_CAST") - val rClassOutputJar = - linkAppClass.getMethodOrNull("getRClassOutputJar")?.invoke(task) as Provider? - rClassOutputJar?.orNull?.asFile?.let { result += AndroidDependency("R.jar", it) } + if (task != null) { + getClassOrNull("com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask")?.let { linkAppClass -> + @Suppress("UNCHECKED_CAST") + val rClassOutputJar = + linkAppClass.getMethodOrNull("getRClassOutputJar")?.invoke(task) as Provider? + rClassOutputJar?.orNull?.asFile?.let { result += AndroidDependency("R.jar", it) } + } } } From f33cad54c5fc56b77d33f3fb8a0fa9462bb40bb5 Mon Sep 17 00:00:00 2001 From: Vyacheslav Karpukhin Date: Thu, 11 Feb 2021 23:17:37 +0100 Subject: [PATCH 026/368] AndroidDependencyResolver: fixed AAR import on modern AGP plugins --- .../android/internal/AndroidDependencyResolver.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt index e19cf57e322..17ef94c467f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt @@ -146,7 +146,7 @@ object AndroidDependencyResolver { compileClasspathConf: Configuration ): List { val viewConfig: (ArtifactView.ViewConfiguration) -> Unit = { config -> - config.attributes { it.attribute(AndroidArtifacts.ARTIFACT_TYPE, AndroidArtifacts.ArtifactType.JAR.type) } + config.attributes { it.attribute(AndroidArtifacts.ARTIFACT_TYPE, PROCESSED_JAR_ARTIFACT_TYPE.type) } config.isLenient = true } @@ -189,4 +189,11 @@ object AndroidDependencyResolver { result.addAll(configs.flatMap { it.dependencies }) doFindDependencies(implConfigs, configs.flatMap { it.extendsFrom }.filter { it !in implConfigs && visited.add(it) }, result) } + + private val PROCESSED_JAR_ARTIFACT_TYPE: AndroidArtifacts.ArtifactType = + try { + AndroidArtifacts.ArtifactType.valueOf("PROCESSED_JAR") + } catch (e: IllegalArgumentException) { + AndroidArtifacts.ArtifactType.JAR + } } \ No newline at end of file From e795c2c4079be9bb3e182308690ad8f64358816d Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Fri, 12 Feb 2021 09:35:06 +0100 Subject: [PATCH 027/368] Generate proper hashCode for fun interface wrappers #KT-44875 Fixed --- .../kotlin/backend/common/lower/SingleAbstractMethodLowering.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SingleAbstractMethodLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SingleAbstractMethodLowering.kt index ffa170a558b..742777cb1b0 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SingleAbstractMethodLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SingleAbstractMethodLowering.kt @@ -332,7 +332,7 @@ class SamEqualsHashCodeMethodsGenerator( overriddenSymbols = klass.superTypes.mapNotNull { it.getClass()?.functions?.singleOrNull(::isHashCode)?.symbol } - val hashCode = builtIns.anyClass.owner.functions.single(::isHashCode).symbol + val hashCode = context.irBuiltIns.functionClass.owner.functions.single(::isHashCode).symbol body = context.createIrBuilder(symbol).run { irExprBody( irCall(hashCode).also { From f3a8fcaea6e26239f012798a6ea8e4c9dfc8a0a5 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 11 Feb 2021 10:41:07 +0300 Subject: [PATCH 028/368] [FE] Make constructors of sealed classes `protected` instead of `internal` --- ...irOldFrontendDiagnosticsTestGenerated.java | 6 +++++ .../output.txt | 3 --- .../tests/dataClasses/sealedDataClass.txt | 2 +- .../foldRecursiveTypesToStarProjection.txt | 8 +++--- .../tests/inference/nothingType/kt32388.txt | 2 +- .../inlineClassDeclarationCheck.txt | 2 +- .../diagnostics/tests/javac/inners/Nested.txt | 4 +-- .../tests/modifiers/IllegalModifiers.txt | 2 +- .../tests/multimodule/redundantElseInWhen.txt | 2 +- .../extendExpectedClassWithAbstractMember.txt | 2 +- .../tests/multiplatform/sealedTypeAlias.txt | 2 +- .../multiplatform/sealedTypeAliasTopLevel.txt | 2 +- .../tests/sealed/DerivedTopLevel.txt | 2 +- .../diagnostics/tests/sealed/DoubleInner.txt | 2 +- .../tests/sealed/ExhaustiveOnRoot.txt | 4 +-- .../tests/sealed/ExhaustiveOnTree.txt | 10 +++---- .../tests/sealed/ExhaustiveOnTriangleStar.txt | 4 +-- .../tests/sealed/ExhaustiveWhen.txt | 2 +- .../sealed/ExhaustiveWhenDoubleInner.txt | 2 +- .../sealed/ExhaustiveWhenMultipleInner.txt | 2 +- .../tests/sealed/ExhaustiveWhenNegated.txt | 2 +- .../sealed/ExhaustiveWhenNegatedTwice.txt | 2 +- .../sealed/ExhaustiveWhenOnNestedSealed.txt | 4 +-- .../tests/sealed/ExhaustiveWhenOnNullable.txt | 2 +- .../ExhaustiveWhenWithAdditionalMember.txt | 2 +- .../tests/sealed/ExhaustiveWhenWithElse.txt | 2 +- .../tests/sealed/ExhaustiveWithFreedom.txt | 2 +- .../diagnostics/tests/sealed/Local.txt | 2 +- .../tests/sealed/MultipleFiles_enabled.txt | 2 +- .../diagnostics/tests/sealed/NestedSealed.txt | 6 ++--- .../NestedSealedWithoutRestrictions.txt | 2 +- .../tests/sealed/NeverConstructed.txt | 2 +- .../tests/sealed/NeverDerivedFromNested.txt | 2 +- .../diagnostics/tests/sealed/NeverFinal.txt | 2 +- .../diagnostics/tests/sealed/NeverOpen.txt | 2 +- .../tests/sealed/NonExhaustiveWhen.txt | 2 +- .../tests/sealed/NonExhaustiveWhenNegated.txt | 2 +- .../NonExhaustiveWhenWithAdditionalCase.txt | 2 +- .../sealed/NonExhaustiveWhenWithAnyCase.txt | 2 +- .../tests/sealed/NonPrivateConstructor.txt | 2 +- .../diagnostics/tests/sealed/NotFinal.txt | 2 +- .../tests/sealed/OperationWhen.txt | 2 +- .../tests/sealed/RedundantAbstract.txt | 2 +- .../diagnostics/tests/sealed/TreeWhen.txt | 2 +- .../tests/sealed/TreeWhenFunctional.txt | 2 +- .../tests/sealed/TreeWhenFunctionalNoIs.txt | 2 +- .../tests/sealed/WhenOnEmptySealed.txt | 2 +- .../tests/sealed/WithInterface.txt | 2 +- .../sealed/inheritorInDifferentModule.kt | 2 +- .../sealed/inheritorInDifferentModule.txt | 2 +- .../interfaces/simpleSealedInterface.txt | 2 +- .../diagnostics/tests/sealed/kt44316.txt | 2 +- .../diagnostics/tests/sealed/kt44861.fir.kt | 17 ++++++++++++ .../diagnostics/tests/sealed/kt44861.kt | 17 ++++++++++++ .../diagnostics/tests/sealed/kt44861.txt | 26 +++++++++++++++++++ .../smartCasts/fakeSmartCastOnEquality.txt | 2 +- .../tests/smartCasts/openInSealed.txt | 2 +- .../tests/tailRecOnVirtualMember.txt | 2 +- .../tests/tailRecOnVirtualMemberError.txt | 2 +- .../typeAliasConstructorWrongClass.kt | 4 +-- .../typeAliasConstructorWrongClass.txt | 2 +- .../valueClassDeclarationCheck.txt | 2 +- .../NonExhaustiveWarningForSealedClass.txt | 2 +- .../diagnostics/tests/when/RedundantElse.txt | 2 +- .../diagnostics/tests/when/TopLevelSealed.txt | 2 +- .../withSubjectVariable/smartcastToSealed.txt | 2 +- .../allCompatibility/specialization.txt | 2 +- .../inference/performance/kt41644.txt | 4 +-- .../inference/performance/kt42195.txt | 2 +- .../ir/irText/classes/sealedClasses.kt.txt | 2 +- .../ir/irText/classes/sealedClasses.txt | 8 +++--- .../multiplatform/expectedSealedClass.kt.txt | 4 +-- .../multiplatform/expectedSealedClass.txt | 6 ++--- ...enConstructorWithInlineClassParameters.txt | 2 +- .../compiledKotlin/class/SealedClass.txt | 2 +- .../test/runners/DiagnosticTestGenerated.java | 6 +++++ .../kotlin/resolve/DescriptorUtils.java | 2 +- .../decompiler/stubBuilder/Sealed/Sealed.txt | 2 +- .../quickfix/addDataModifier/sealed.kt | 1 + .../tools/kotlinp/testData/NestedClasses.txt | 2 +- 80 files changed, 167 insertions(+), 97 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/sealed/kt44861.fir.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/kt44861.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/kt44861.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 56b9c23c588..7bda4473beb 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -24397,6 +24397,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/sealed/kt44316.kt"); } + @Test + @TestMetadata("kt44861.kt") + public void testKt44861() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/kt44861.kt"); + } + @Test @TestMetadata("Local.kt") public void testLocal() throws Exception { diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/output.txt index b22e0dc8b0d..242942dc732 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/output.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/output.txt @@ -8,9 +8,6 @@ This mode is not recommended for production use, as no stability/compatibility guarantees are given on compiler or generated code. Use it at your own risk! -compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/main.kt:5:11: error: cannot access '': it is internal in 'Base' -class B : Base(), IBase - ^ compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/main.kt:5:11: error: inheritance of sealed classes or interfaces from different module is prohibited class B : Base(), IBase ^ diff --git a/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.txt b/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.txt index 843867f4337..77537adb9c0 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.txt +++ b/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.txt @@ -1,7 +1,7 @@ package public sealed data class My { - internal constructor My(/*0*/ x: kotlin.Int) + protected constructor My(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public final operator /*synthesized*/ fun component1(): kotlin.Int public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ...): My diff --git a/compiler/testData/diagnostics/tests/generics/starProjections/foldRecursiveTypesToStarProjection.txt b/compiler/testData/diagnostics/tests/generics/starProjections/foldRecursiveTypesToStarProjection.txt index 9e03553cdbf..53a8c5c4272 100644 --- a/compiler/testData/diagnostics/tests/generics/starProjections/foldRecursiveTypesToStarProjection.txt +++ b/compiler/testData/diagnostics/tests/generics/starProjections/foldRecursiveTypesToStarProjection.txt @@ -77,27 +77,27 @@ public object KT32183 { } public sealed class ProjectJob { - internal constructor ProjectJob() + protected constructor ProjectJob() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public sealed class Process, /*1*/ R : KT32183.ProjectJob.ProcessResources> : KT32183.ProjectJob { - internal constructor Process, /*1*/ R : KT32183.ProjectJob.ProcessResources>() + protected constructor Process, /*1*/ R : KT32183.ProjectJob.ProcessResources>() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } public sealed class ProcessExecutable> { - internal constructor ProcessExecutable>() + protected constructor ProcessExecutable>() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } public sealed class ProcessResources> { - internal constructor ProcessResources>() + protected constructor ProcessResources>() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/kt32388.txt b/compiler/testData/diagnostics/tests/inference/nothingType/kt32388.txt index 77f67644feb..0f07201d266 100644 --- a/compiler/testData/diagnostics/tests/inference/nothingType/kt32388.txt +++ b/compiler/testData/diagnostics/tests/inference/nothingType/kt32388.txt @@ -4,7 +4,7 @@ public fun Either.recover(/*0*/ f: (A) -> B): Either A.right(): Either public sealed class Either { - internal constructor Either() + protected constructor Either() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.txt b/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.txt index d5932702482..48484d908dd 100644 --- a/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.txt +++ b/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.txt @@ -174,7 +174,7 @@ public abstract inline class D2 { } public sealed inline class D3 { - internal constructor D3(/*0*/ x: kotlin.Int) + protected constructor D3(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/javac/inners/Nested.txt b/compiler/testData/diagnostics/tests/javac/inners/Nested.txt index 9b8503cf487..df678815f7a 100644 --- a/compiler/testData/diagnostics/tests/javac/inners/Nested.txt +++ b/compiler/testData/diagnostics/tests/javac/inners/Nested.txt @@ -21,13 +21,13 @@ package p { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public sealed class Sealed1 { - internal constructor Sealed1() + protected constructor Sealed1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public sealed class Sealed2 { - internal constructor Sealed2() + protected constructor Sealed2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt index 18f8bd789ee..3ecc2db5c1c 100644 --- a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt +++ b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt @@ -155,7 +155,7 @@ package illegal_modifiers { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public sealed inner class Inner { - internal constructor Inner() + protected constructor Inner() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/multimodule/redundantElseInWhen.txt b/compiler/testData/diagnostics/tests/multimodule/redundantElseInWhen.txt index 4fab4c6ad6e..83b0ccc371f 100644 --- a/compiler/testData/diagnostics/tests/multimodule/redundantElseInWhen.txt +++ b/compiler/testData/diagnostics/tests/multimodule/redundantElseInWhen.txt @@ -30,7 +30,7 @@ package test { } public sealed class S { - internal constructor S() + protected constructor S() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/extendExpectedClassWithAbstractMember.txt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/extendExpectedClassWithAbstractMember.txt index 8e6a3c4f8e7..390994b22a2 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/headerClass/extendExpectedClassWithAbstractMember.txt +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/extendExpectedClassWithAbstractMember.txt @@ -70,7 +70,7 @@ public expect interface BaseE { } public sealed class BaseEImpl : BaseE { - internal constructor BaseEImpl() + protected constructor BaseEImpl() public final fun bar(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public abstract expect override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/multiplatform/sealedTypeAlias.txt b/compiler/testData/diagnostics/tests/multiplatform/sealedTypeAlias.txt index 36e27006142..b0c1b8c7737 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/sealedTypeAlias.txt +++ b/compiler/testData/diagnostics/tests/multiplatform/sealedTypeAlias.txt @@ -23,7 +23,7 @@ public sealed expect class Presence { package public sealed class P { - internal constructor P() + protected constructor P() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/multiplatform/sealedTypeAliasTopLevel.txt b/compiler/testData/diagnostics/tests/multiplatform/sealedTypeAliasTopLevel.txt index 16eaf0abd1a..e2f8b900b62 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/sealedTypeAliasTopLevel.txt +++ b/compiler/testData/diagnostics/tests/multiplatform/sealedTypeAliasTopLevel.txt @@ -37,7 +37,7 @@ public actual object Online : P { } public sealed class P { - internal constructor P() + protected constructor P() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/DerivedTopLevel.txt b/compiler/testData/diagnostics/tests/sealed/DerivedTopLevel.txt index 7f1ab161a05..c8943bdb8d6 100644 --- a/compiler/testData/diagnostics/tests/sealed/DerivedTopLevel.txt +++ b/compiler/testData/diagnostics/tests/sealed/DerivedTopLevel.txt @@ -3,7 +3,7 @@ package public fun test(): kotlin.Unit public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/DoubleInner.txt b/compiler/testData/diagnostics/tests/sealed/DoubleInner.txt index 050d26bc834..5a52ffe2028 100644 --- a/compiler/testData/diagnostics/tests/sealed/DoubleInner.txt +++ b/compiler/testData/diagnostics/tests/sealed/DoubleInner.txt @@ -1,7 +1,7 @@ package public sealed class Sealed { - internal constructor Sealed(/*0*/ x: kotlin.Int) + protected constructor Sealed(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnRoot.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnRoot.txt index 425b7c75ed6..f15a8692714 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnRoot.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnRoot.txt @@ -5,7 +5,7 @@ public fun test2(/*0*/ x: Stmt): kotlin.String public fun test3(/*0*/ x: Expr): kotlin.String public sealed class Expr : Stmt { - internal constructor Expr() + protected constructor Expr() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String @@ -26,7 +26,7 @@ public final class ForStmt : Stmt { } public sealed class Stmt { - internal constructor Stmt() + protected constructor Stmt() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnTree.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnTree.txt index 2559c794d81..550617693cd 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnTree.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnTree.txt @@ -1,7 +1,7 @@ package public sealed class Base { - internal constructor Base() + protected constructor Base() public final fun bar(): kotlin.Int public final fun baz(): kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -11,7 +11,7 @@ public sealed class Base { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public sealed class A : Base { - internal constructor A() + protected constructor A() public final override /*1*/ /*fake_override*/ fun bar(): kotlin.Int public final override /*1*/ /*fake_override*/ fun baz(): kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -32,7 +32,7 @@ public sealed class Base { } public sealed class A2 : Base.A { - internal constructor A2() + protected constructor A2() public final override /*1*/ /*fake_override*/ fun bar(): kotlin.Int public final override /*1*/ /*fake_override*/ fun baz(): kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -44,7 +44,7 @@ public sealed class Base { } public sealed class B : Base { - internal constructor B() + protected constructor B() public final override /*1*/ /*fake_override*/ fun bar(): kotlin.Int public final override /*1*/ /*fake_override*/ fun baz(): kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -54,7 +54,7 @@ public sealed class Base { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public sealed class B1 : Base.B { - internal constructor B1() + protected constructor B1() public final override /*1*/ /*fake_override*/ fun bar(): kotlin.Int public final override /*1*/ /*fake_override*/ fun baz(): kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnTriangleStar.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnTriangleStar.txt index ed10fcf8de7..f5740263809 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnTriangleStar.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnTriangleStar.txt @@ -5,14 +5,14 @@ public fun test2(/*0*/ a: A): kotlin.Any public fun test3(/*0*/ a: A): kotlin.Any public sealed class A { - internal constructor A() + protected constructor A() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } public sealed class B : A { - internal constructor B() + protected constructor B() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhen.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhen.txt index 6052d5fbd87..65d4e9fdc00 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhen.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhen.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed(/*0*/ x: kotlin.Int) + protected constructor Sealed(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenDoubleInner.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenDoubleInner.txt index cd86b738170..646192acfe2 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenDoubleInner.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenDoubleInner.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed() + protected constructor Sealed() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenMultipleInner.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenMultipleInner.txt index 353be8f9350..ec253e484a0 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenMultipleInner.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenMultipleInner.txt @@ -6,7 +6,7 @@ public fun fooWithElse(/*0*/ s: Sealed): kotlin.Int public fun fooWithoutElse(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed() + protected constructor Sealed() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenNegated.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenNegated.txt index 6052d5fbd87..65d4e9fdc00 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenNegated.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenNegated.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed(/*0*/ x: kotlin.Int) + protected constructor Sealed(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenNegatedTwice.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenNegatedTwice.txt index 9822f3cd0f9..29c0361b454 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenNegatedTwice.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenNegatedTwice.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed(/*0*/ x: kotlin.Int) + protected constructor Sealed(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenOnNestedSealed.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenOnNestedSealed.txt index b352827f224..49814aa3f94 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenOnNestedSealed.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenOnNestedSealed.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed, /*1*/ nf: Sealed.NonFirst): kotlin.Int public sealed class Sealed { - internal constructor Sealed() + protected constructor Sealed() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String @@ -16,7 +16,7 @@ public sealed class Sealed { } public sealed class NonFirst { - internal constructor NonFirst() + protected constructor NonFirst() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenOnNullable.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenOnNullable.txt index 3e989e300bb..493d5324277 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenOnNullable.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenOnNullable.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed?): kotlin.Int public sealed class Sealed { - internal constructor Sealed(/*0*/ x: kotlin.Int) + protected constructor Sealed(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenWithAdditionalMember.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenWithAdditionalMember.txt index 5abe4e1702c..d7207cf4026 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenWithAdditionalMember.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenWithAdditionalMember.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed(/*0*/ x: kotlin.Int) + protected constructor Sealed(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenWithElse.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenWithElse.txt index 6052d5fbd87..65d4e9fdc00 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenWithElse.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenWithElse.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed(/*0*/ x: kotlin.Int) + protected constructor Sealed(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.txt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.txt index ca2a9591379..98acc061369 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.txt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.txt @@ -14,7 +14,7 @@ public final class B : Base { } public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/Local.txt b/compiler/testData/diagnostics/tests/sealed/Local.txt index bbb25c8a302..cf186acae6f 100644 --- a/compiler/testData/diagnostics/tests/sealed/Local.txt +++ b/compiler/testData/diagnostics/tests/sealed/Local.txt @@ -1,7 +1,7 @@ package public sealed class Sealed { - internal constructor Sealed() + protected constructor Sealed() public final val p: Sealed public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.txt b/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.txt index dcfabb459ad..08d57bd8c1f 100644 --- a/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.txt +++ b/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.txt @@ -20,7 +20,7 @@ package foo { } public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/NestedSealed.txt b/compiler/testData/diagnostics/tests/sealed/NestedSealed.txt index 10a7db9e368..86fda2408b0 100644 --- a/compiler/testData/diagnostics/tests/sealed/NestedSealed.txt +++ b/compiler/testData/diagnostics/tests/sealed/NestedSealed.txt @@ -5,13 +5,13 @@ public fun foo(/*0*/ b: Base): kotlin.Int public fun gav(/*0*/ b: Base?): kotlin.Int public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public sealed class A : Base { - internal constructor A() + protected constructor A() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String @@ -32,7 +32,7 @@ public sealed class Base { } public sealed class B : Base { - internal constructor B() + protected constructor B() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.txt b/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.txt index 319749dd71b..c7af0a0265a 100644 --- a/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.txt +++ b/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.txt @@ -38,7 +38,7 @@ package foo { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/NeverConstructed.txt b/compiler/testData/diagnostics/tests/sealed/NeverConstructed.txt index f210e874257..4da34c6bf43 100644 --- a/compiler/testData/diagnostics/tests/sealed/NeverConstructed.txt +++ b/compiler/testData/diagnostics/tests/sealed/NeverConstructed.txt @@ -1,7 +1,7 @@ package public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public final fun foo(): Base public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/NeverDerivedFromNested.txt b/compiler/testData/diagnostics/tests/sealed/NeverDerivedFromNested.txt index faaa729b10a..7d5b241b972 100644 --- a/compiler/testData/diagnostics/tests/sealed/NeverDerivedFromNested.txt +++ b/compiler/testData/diagnostics/tests/sealed/NeverDerivedFromNested.txt @@ -9,7 +9,7 @@ public final class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/NeverFinal.txt b/compiler/testData/diagnostics/tests/sealed/NeverFinal.txt index 4f963ec4c07..46eb741a0f0 100644 --- a/compiler/testData/diagnostics/tests/sealed/NeverFinal.txt +++ b/compiler/testData/diagnostics/tests/sealed/NeverFinal.txt @@ -1,7 +1,7 @@ package public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/NeverOpen.txt b/compiler/testData/diagnostics/tests/sealed/NeverOpen.txt index 4f963ec4c07..46eb741a0f0 100644 --- a/compiler/testData/diagnostics/tests/sealed/NeverOpen.txt +++ b/compiler/testData/diagnostics/tests/sealed/NeverOpen.txt @@ -1,7 +1,7 @@ package public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhen.txt b/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhen.txt index 6052d5fbd87..65d4e9fdc00 100644 --- a/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhen.txt +++ b/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhen.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed(/*0*/ x: kotlin.Int) + protected constructor Sealed(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenNegated.txt b/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenNegated.txt index 6052d5fbd87..65d4e9fdc00 100644 --- a/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenNegated.txt +++ b/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenNegated.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed(/*0*/ x: kotlin.Int) + protected constructor Sealed(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenWithAdditionalCase.txt b/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenWithAdditionalCase.txt index 33444b8be1b..062a84e7cb4 100644 --- a/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenWithAdditionalCase.txt +++ b/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenWithAdditionalCase.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed(/*0*/ x: kotlin.Int) + protected constructor Sealed(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenWithAnyCase.txt b/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenWithAnyCase.txt index fa27bc4811d..f5f1ba57a6d 100644 --- a/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenWithAnyCase.txt +++ b/compiler/testData/diagnostics/tests/sealed/NonExhaustiveWhenWithAnyCase.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed() + protected constructor Sealed() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.txt b/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.txt index 18a46c7808f..1d5b1a0cff8 100644 --- a/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.txt +++ b/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.txt @@ -3,7 +3,7 @@ package public sealed class Sealed { public constructor Sealed() protected constructor Sealed(/*0*/ x: kotlin.Int) - internal constructor Sealed(/*0*/ y: kotlin.Int, /*1*/ z: kotlin.Int) + protected constructor Sealed(/*0*/ y: kotlin.Int, /*1*/ z: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/NotFinal.txt b/compiler/testData/diagnostics/tests/sealed/NotFinal.txt index 23ce8ce7f29..5fb316f0061 100644 --- a/compiler/testData/diagnostics/tests/sealed/NotFinal.txt +++ b/compiler/testData/diagnostics/tests/sealed/NotFinal.txt @@ -3,7 +3,7 @@ package public fun doit(/*0*/ arg: T): T public sealed class Foo { - internal constructor Foo() + protected constructor Foo() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/OperationWhen.txt b/compiler/testData/diagnostics/tests/sealed/OperationWhen.txt index cebdb6ea323..b33e17253b1 100644 --- a/compiler/testData/diagnostics/tests/sealed/OperationWhen.txt +++ b/compiler/testData/diagnostics/tests/sealed/OperationWhen.txt @@ -3,7 +3,7 @@ package public fun priority(/*0*/ op: Operation): kotlin.Int public sealed class Operation { - internal constructor Operation(/*0*/ left: kotlin.Int, /*1*/ right: kotlin.Int) + protected constructor Operation(/*0*/ left: kotlin.Int, /*1*/ right: kotlin.Int) public final val left: kotlin.Int public final val right: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/sealed/RedundantAbstract.txt b/compiler/testData/diagnostics/tests/sealed/RedundantAbstract.txt index 4f963ec4c07..46eb741a0f0 100644 --- a/compiler/testData/diagnostics/tests/sealed/RedundantAbstract.txt +++ b/compiler/testData/diagnostics/tests/sealed/RedundantAbstract.txt @@ -1,7 +1,7 @@ package public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/TreeWhen.txt b/compiler/testData/diagnostics/tests/sealed/TreeWhen.txt index 0b16ddc38f4..02411f9ef20 100644 --- a/compiler/testData/diagnostics/tests/sealed/TreeWhen.txt +++ b/compiler/testData/diagnostics/tests/sealed/TreeWhen.txt @@ -1,7 +1,7 @@ package public sealed class Tree { - internal constructor Tree() + protected constructor Tree() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public final fun max(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/TreeWhenFunctional.txt b/compiler/testData/diagnostics/tests/sealed/TreeWhenFunctional.txt index 0b16ddc38f4..02411f9ef20 100644 --- a/compiler/testData/diagnostics/tests/sealed/TreeWhenFunctional.txt +++ b/compiler/testData/diagnostics/tests/sealed/TreeWhenFunctional.txt @@ -1,7 +1,7 @@ package public sealed class Tree { - internal constructor Tree() + protected constructor Tree() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public final fun max(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/TreeWhenFunctionalNoIs.txt b/compiler/testData/diagnostics/tests/sealed/TreeWhenFunctionalNoIs.txt index 64955fd0483..44fa55952bc 100644 --- a/compiler/testData/diagnostics/tests/sealed/TreeWhenFunctionalNoIs.txt +++ b/compiler/testData/diagnostics/tests/sealed/TreeWhenFunctionalNoIs.txt @@ -1,7 +1,7 @@ package public sealed class Tree { - internal constructor Tree() + protected constructor Tree() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public final fun max(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/sealed/WhenOnEmptySealed.txt b/compiler/testData/diagnostics/tests/sealed/WhenOnEmptySealed.txt index 50319d715ed..db360066c7f 100644 --- a/compiler/testData/diagnostics/tests/sealed/WhenOnEmptySealed.txt +++ b/compiler/testData/diagnostics/tests/sealed/WhenOnEmptySealed.txt @@ -3,7 +3,7 @@ package public fun foo(/*0*/ s: Sealed): kotlin.Int public sealed class Sealed { - internal constructor Sealed() + protected constructor Sealed() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/WithInterface.txt b/compiler/testData/diagnostics/tests/sealed/WithInterface.txt index 62bb5d50b1f..8b8ea324fdf 100644 --- a/compiler/testData/diagnostics/tests/sealed/WithInterface.txt +++ b/compiler/testData/diagnostics/tests/sealed/WithInterface.txt @@ -9,7 +9,7 @@ public interface Child : Parent { } public sealed class Page : Parent { - internal constructor Page() + protected constructor Page() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt b/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt index b1204703749..0942b62225f 100644 --- a/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt +++ b/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt @@ -14,4 +14,4 @@ class A : Base() package a -class B : Base() +class B : Base() diff --git a/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.txt b/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.txt index 334e5f75c20..f3a8eb1d81a 100644 --- a/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.txt +++ b/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.txt @@ -11,7 +11,7 @@ package a { } public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/interfaces/simpleSealedInterface.txt b/compiler/testData/diagnostics/tests/sealed/interfaces/simpleSealedInterface.txt index 1cc0a6b869a..dc7af7b2bc0 100644 --- a/compiler/testData/diagnostics/tests/sealed/interfaces/simpleSealedInterface.txt +++ b/compiler/testData/diagnostics/tests/sealed/interfaces/simpleSealedInterface.txt @@ -10,7 +10,7 @@ public interface A : Base { } public sealed class B : Base { - internal constructor B() + protected constructor B() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/kt44316.txt b/compiler/testData/diagnostics/tests/sealed/kt44316.txt index 6e077339484..a668f2115fb 100644 --- a/compiler/testData/diagnostics/tests/sealed/kt44316.txt +++ b/compiler/testData/diagnostics/tests/sealed/kt44316.txt @@ -1,7 +1,7 @@ package public sealed class Base { - internal constructor Base() + protected constructor Base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/sealed/kt44861.fir.kt b/compiler/testData/diagnostics/tests/sealed/kt44861.fir.kt new file mode 100644 index 00000000000..9e13166b1ce --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/kt44861.fir.kt @@ -0,0 +1,17 @@ +// ISSUE: KT-44861 +// DIAGNOSTICS: -UNUSED_VARIABLE + +sealed class Foo() { + class A : Foo() + class B : Foo() +} + +fun Foo(kind: String = "A"): Foo = when (kind) { + "A" -> Foo.A() + "B" -> Foo.B() + else -> throw Exception() +} + +fun main() { + val foo = Foo() +} diff --git a/compiler/testData/diagnostics/tests/sealed/kt44861.kt b/compiler/testData/diagnostics/tests/sealed/kt44861.kt new file mode 100644 index 00000000000..72198eaf079 --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/kt44861.kt @@ -0,0 +1,17 @@ +// ISSUE: KT-44861 +// DIAGNOSTICS: -UNUSED_VARIABLE + +sealed class Foo() { + class A : Foo() + class B : Foo() +} + +fun Foo(kind: String = "A"): Foo = when (kind) { + "A" -> Foo.A() + "B" -> Foo.B() + else -> throw Exception() +} + +fun main() { + val foo = Foo() +} diff --git a/compiler/testData/diagnostics/tests/sealed/kt44861.txt b/compiler/testData/diagnostics/tests/sealed/kt44861.txt new file mode 100644 index 00000000000..01283f193ca --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/kt44861.txt @@ -0,0 +1,26 @@ +package + +public fun Foo(/*0*/ kind: kotlin.String = ...): Foo +public fun main(): kotlin.Unit + +public sealed class Foo { + protected constructor Foo() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class A : Foo { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class B : Foo { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/tests/smartCasts/fakeSmartCastOnEquality.txt b/compiler/testData/diagnostics/tests/smartCasts/fakeSmartCastOnEquality.txt index 37cc7ceaaf3..3c13604bec0 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/fakeSmartCastOnEquality.txt +++ b/compiler/testData/diagnostics/tests/smartCasts/fakeSmartCastOnEquality.txt @@ -65,7 +65,7 @@ public open class OpenClass2 { } public sealed class Sealed { - internal constructor Sealed() + protected constructor Sealed() public final fun check(/*0*/ arg: Sealed.Sealed1): kotlin.Unit public open override /*1*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/smartCasts/openInSealed.txt b/compiler/testData/diagnostics/tests/smartCasts/openInSealed.txt index 050f6bbc035..fb117bcb527 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/openInSealed.txt +++ b/compiler/testData/diagnostics/tests/smartCasts/openInSealed.txt @@ -1,7 +1,7 @@ package public sealed class My { - internal constructor My(/*0*/ x: kotlin.Int?) + protected constructor My(/*0*/ x: kotlin.Int?) public open val x: kotlin.Int? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/tailRecOnVirtualMember.txt b/compiler/testData/diagnostics/tests/tailRecOnVirtualMember.txt index 1860f2bcccb..c1e5c96e5d9 100644 --- a/compiler/testData/diagnostics/tests/tailRecOnVirtualMember.txt +++ b/compiler/testData/diagnostics/tests/tailRecOnVirtualMember.txt @@ -51,7 +51,7 @@ public object D : A { } public sealed class E : A { - internal constructor E() + protected constructor E() internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit internal open override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit protected open override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/tailRecOnVirtualMemberError.txt b/compiler/testData/diagnostics/tests/tailRecOnVirtualMemberError.txt index 1860f2bcccb..c1e5c96e5d9 100644 --- a/compiler/testData/diagnostics/tests/tailRecOnVirtualMemberError.txt +++ b/compiler/testData/diagnostics/tests/tailRecOnVirtualMemberError.txt @@ -51,7 +51,7 @@ public object D : A { } public sealed class E : A { - internal constructor E() + protected constructor E() internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit internal open override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit protected open override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.kt index e0ea89e6131..cafaeda2aa2 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.kt @@ -17,8 +17,8 @@ val test3a = EnumClass()Test4() -val test4a = SealedClass() +val test4 = Test4() +val test4a = SealedClass() class Outer { inner class Inner diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.txt index 766cd3606c4..9abd398cf90 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.txt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.txt @@ -66,7 +66,7 @@ public final class Outer { } public sealed class SealedClass { - internal constructor SealedClass() + protected constructor SealedClass() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.txt b/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.txt index 432311e420f..3441adc1500 100644 --- a/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.txt +++ b/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.txt @@ -152,7 +152,7 @@ package kotlin { } public sealed value class D3 { - internal constructor D3(/*0*/ x: kotlin.Int) + protected constructor D3(/*0*/ x: kotlin.Int) public final val x: kotlin.Int public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.txt b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.txt index 7a7ce296cff..cbb2008f73a 100644 --- a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.txt +++ b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.txt @@ -26,7 +26,7 @@ public object Last : S { } public sealed class S { - internal constructor S() + protected constructor S() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/when/RedundantElse.txt b/compiler/testData/diagnostics/tests/when/RedundantElse.txt index 70da44887fa..95ad6de9dad 100644 --- a/compiler/testData/diagnostics/tests/when/RedundantElse.txt +++ b/compiler/testData/diagnostics/tests/when/RedundantElse.txt @@ -50,7 +50,7 @@ public final enum class MyEnum : kotlin.Enum { } public sealed class X { - internal constructor X() + protected constructor X() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/when/TopLevelSealed.txt b/compiler/testData/diagnostics/tests/when/TopLevelSealed.txt index 888bd637178..54f30dbde5a 100644 --- a/compiler/testData/diagnostics/tests/when/TopLevelSealed.txt +++ b/compiler/testData/diagnostics/tests/when/TopLevelSealed.txt @@ -3,7 +3,7 @@ package public fun test(/*0*/ a: A): kotlin.Unit public sealed class A { - internal constructor A() + protected constructor A() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/when/withSubjectVariable/smartcastToSealed.txt b/compiler/testData/diagnostics/tests/when/withSubjectVariable/smartcastToSealed.txt index deebd0be736..19381b112ee 100644 --- a/compiler/testData/diagnostics/tests/when/withSubjectVariable/smartcastToSealed.txt +++ b/compiler/testData/diagnostics/tests/when/withSubjectVariable/smartcastToSealed.txt @@ -4,7 +4,7 @@ public fun testSmartcastToSealedInSubjectInitializer1(/*0*/ x: kotlin.Any?): kot public fun testSmartcastToSealedInSubjectInitializer2(/*0*/ x: kotlin.Any?): kotlin.Unit public sealed class Either { - internal constructor Either() + protected constructor Either() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/allCompatibility/specialization.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/allCompatibility/specialization.txt index 64beffedaa0..514244d4f68 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/allCompatibility/specialization.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/allCompatibility/specialization.txt @@ -120,7 +120,7 @@ private final class Outer { } public sealed class SealedSpecialized : Foo { - internal constructor SealedSpecialized() + protected constructor SealedSpecialized() public open override /*1*/ /*fake_override*/ val kotlin.String.prop: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt41644.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt41644.txt index 46c0ad5c342..fe0c53963a4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt41644.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt41644.txt @@ -3,13 +3,13 @@ package public fun , /*2*/ B, /*3*/ DB : DataType, /*4*/ C, /*5*/ DC : DataType, /*6*/ D, /*7*/ DD : DataType, /*8*/ E, /*9*/ DE : DataType, /*10*/ F, /*11*/ DF : DataType, /*12*/ G, /*13*/ DG : DataType, /*14*/ H, /*15*/ DH : DataType> either8(/*0*/ firstName: kotlin.String, /*1*/ firstType: DA, /*2*/ secondName: kotlin.String, /*3*/ secondType: DB, /*4*/ thirdName: kotlin.String, /*5*/ thirdType: DC, /*6*/ fourthName: kotlin.String, /*7*/ fourthType: DD, /*8*/ fifthName: kotlin.String, /*9*/ fifthType: DE, /*10*/ sixthName: kotlin.String, /*11*/ sixthType: DF, /*12*/ seventhName: kotlin.String, /*13*/ seventhType: DG, /*14*/ eighthName: kotlin.String, /*15*/ eighthType: DH): DataType.NotNull.Partial> public sealed class DataType { - internal constructor DataType() + protected constructor DataType() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public sealed class NotNull : DataType { - internal constructor NotNull() + protected constructor NotNull() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt42195.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt42195.txt index f6134461709..6720fe7c2d1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt42195.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt42195.txt @@ -3,7 +3,7 @@ package public val tree: Tree.Inner public sealed class Tree { - internal constructor Tree() + protected constructor Tree() public abstract val children: kotlin.collections.Map> public abstract val value: TCommon public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/ir/irText/classes/sealedClasses.kt.txt b/compiler/testData/ir/irText/classes/sealedClasses.kt.txt index bd162164659..a902da26199 100644 --- a/compiler/testData/ir/irText/classes/sealedClasses.kt.txt +++ b/compiler/testData/ir/irText/classes/sealedClasses.kt.txt @@ -1,5 +1,5 @@ sealed class Expr { - internal constructor() /* primary */ { + protected constructor() /* primary */ { super/*Any*/() /* () */ diff --git a/compiler/testData/ir/irText/classes/sealedClasses.txt b/compiler/testData/ir/irText/classes/sealedClasses.txt index f8234fa55d8..b4d45345d9a 100644 --- a/compiler/testData/ir/irText/classes/sealedClasses.txt +++ b/compiler/testData/ir/irText/classes/sealedClasses.txt @@ -1,7 +1,7 @@ FILE fqName: fileName:/sealedClasses.kt CLASS CLASS name:Expr modality:SEALED visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Expr - CONSTRUCTOR visibility:internal <> () returnType:.Expr [primary] + CONSTRUCTOR visibility:protected <> () returnType:.Expr [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Expr modality:SEALED visibility:public superTypes:[kotlin.Any]' @@ -10,7 +10,7 @@ FILE fqName: fileName:/sealedClasses.kt CONSTRUCTOR visibility:public <> (number:kotlin.Double) returnType:.Expr.Const [primary] VALUE_PARAMETER name:number index:0 type:kotlin.Double BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'internal constructor () [primary] declared in .Expr' + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .Expr' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Const modality:FINAL visibility:public superTypes:[.Expr]' PROPERTY name:number visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:number type:kotlin.Double visibility:private [final] @@ -42,7 +42,7 @@ FILE fqName: fileName:/sealedClasses.kt VALUE_PARAMETER name:e1 index:0 type:.Expr VALUE_PARAMETER name:e2 index:1 type:.Expr BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'internal constructor () [primary] declared in .Expr' + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .Expr' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Sum modality:FINAL visibility:public superTypes:[.Expr]' PROPERTY name:e1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:e1 type:.Expr visibility:private [final] @@ -83,7 +83,7 @@ FILE fqName: fileName:/sealedClasses.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Expr.NotANumber CONSTRUCTOR visibility:private <> () returnType:.Expr.NotANumber [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'internal constructor () [primary] declared in .Expr' + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .Expr' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:NotANumber modality:FINAL visibility:public superTypes:[.Expr]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.kt.txt b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.kt.txt index 8e4b78d0641..17913f80757 100644 --- a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.kt.txt +++ b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.kt.txt @@ -1,5 +1,5 @@ expect sealed class Ops { - internal expect constructor() /* primary */ + protected expect constructor() /* primary */ } @@ -9,7 +9,7 @@ expect class Add : Ops { } sealed class Ops { - internal constructor() /* primary */ { + protected constructor() /* primary */ { super/*Any*/() /* () */ diff --git a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.txt b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.txt index 5d65736964f..6fc0053b071 100644 --- a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.txt +++ b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.txt @@ -1,7 +1,7 @@ FILE fqName: fileName:/expectedSealedClass.kt CLASS CLASS name:Ops modality:SEALED visibility:public [expect] superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Ops - CONSTRUCTOR visibility:internal <> () returnType:.Ops [primary,expect] + CONSTRUCTOR visibility:protected <> () returnType:.Ops [primary,expect] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -33,7 +33,7 @@ FILE fqName: fileName:/expectedSealedClass.kt $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Ops modality:SEALED visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Ops - CONSTRUCTOR visibility:internal <> () returnType:.Ops [primary] + CONSTRUCTOR visibility:protected <> () returnType:.Ops [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Ops modality:SEALED visibility:public superTypes:[kotlin.Any]' @@ -54,7 +54,7 @@ FILE fqName: fileName:/expectedSealedClass.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Add CONSTRUCTOR visibility:public <> () returnType:.Add [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'internal constructor () [primary] declared in .Ops' + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .Ops' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Add modality:FINAL visibility:public superTypes:[.Ops]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/HiddenConstructorWithInlineClassParameters.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/HiddenConstructorWithInlineClassParameters.txt index 50112e06d47..2bf9c168f9b 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/HiddenConstructorWithInlineClassParameters.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/HiddenConstructorWithInlineClassParameters.txt @@ -5,7 +5,7 @@ public final annotation class Ann : kotlin.Annotation { } public sealed class Sealed { - /*primary*/ @test.Ann internal constructor Sealed(/*0*/ @test.Ann z: test.Z) + /*primary*/ @test.Ann protected constructor Sealed(/*0*/ @test.Ann z: test.Z) public final val z: test.Z public final fun (): test.Z diff --git a/compiler/testData/loadJava/compiledKotlin/class/SealedClass.txt b/compiler/testData/loadJava/compiledKotlin/class/SealedClass.txt index af4e2a97b3e..a1a8bffe248 100644 --- a/compiler/testData/loadJava/compiledKotlin/class/SealedClass.txt +++ b/compiler/testData/loadJava/compiledKotlin/class/SealedClass.txt @@ -9,7 +9,7 @@ public final class Inheritor3 : test.SealedClass { } public sealed class SealedClass { - /*primary*/ internal constructor SealedClass() + /*primary*/ protected constructor SealedClass() public final class Inheritor1 : test.SealedClass { /*primary*/ public constructor Inheritor1() diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 9ab80c8a85b..f0355b8a1ec 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -24487,6 +24487,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/sealed/kt44316.kt"); } + @Test + @TestMetadata("kt44861.kt") + public void testKt44861() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/kt44861.kt"); + } + @Test @TestMetadata("Local.kt") public void testLocal() throws Exception { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java index 51f6c92f8f2..effc64e6849 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.java @@ -390,7 +390,7 @@ public class DescriptorUtils { } if (isSealedClass(classDescriptor)) { if (freedomForSealedInterfacesSupported) { - return DescriptorVisibilities.INTERNAL; + return DescriptorVisibilities.PROTECTED; } else { return DescriptorVisibilities.PRIVATE; } diff --git a/idea/testData/decompiler/stubBuilder/Sealed/Sealed.txt b/idea/testData/decompiler/stubBuilder/Sealed/Sealed.txt index 97af5678c57..ba85febe4fc 100644 --- a/idea/testData/decompiler/stubBuilder/Sealed/Sealed.txt +++ b/idea/testData/decompiler/stubBuilder/Sealed/Sealed.txt @@ -5,7 +5,7 @@ PsiJetFileStubImpl[package=test] CLASS[fqName=test.Sealed, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=Sealed, superNames=[]] MODIFIER_LIST[public sealed] PRIMARY_CONSTRUCTOR - MODIFIER_LIST[internal] + MODIFIER_LIST[protected] VALUE_PARAMETER_LIST CLASS_BODY CLASS[fqName=test.Sealed.Nested, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=false, name=Nested, superNames=[Sealed]] diff --git a/idea/testData/quickfix/addDataModifier/sealed.kt b/idea/testData/quickfix/addDataModifier/sealed.kt index 9ed02042cc2..5e413353fb7 100644 --- a/idea/testData/quickfix/addDataModifier/sealed.kt +++ b/idea/testData/quickfix/addDataModifier/sealed.kt @@ -5,6 +5,7 @@ // ACTION: Create member function 'Foo.component2' // ACTION: Enable a trailing comma by default in the formatter // ACTION: Put arguments on separate lines +// ERROR: Cannot access '': it is protected in 'Foo' // ERROR: Destructuring declaration initializer of type Foo must have a 'component1()' function // ERROR: Destructuring declaration initializer of type Foo must have a 'component2()' function // ERROR: Sealed types cannot be instantiated diff --git a/libraries/tools/kotlinp/testData/NestedClasses.txt b/libraries/tools/kotlinp/testData/NestedClasses.txt index 0e604d1bc9e..ac02ec4c155 100644 --- a/libraries/tools/kotlinp/testData/NestedClasses.txt +++ b/libraries/tools/kotlinp/testData/NestedClasses.txt @@ -55,7 +55,7 @@ public final enum class A.D.E : kotlin/Enum { public sealed class A.D.F : kotlin/Any { // signature: ()V - internal constructor() + protected constructor() // nested class: G From 7c61ddc72b754cf5d7615403555cb82b65e8ee47 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 11 Feb 2021 11:57:02 +0300 Subject: [PATCH 029/368] [FE] Allow declaring protected constructors in sealed classes #KT-44865 Fixed --- ...irOldFrontendDiagnosticsTestGenerated.java | 12 ++ .../jetbrains/kotlin/diagnostics/Errors.java | 1 + .../rendering/DefaultErrorMessages.java | 1 + .../kotlin/resolve/DeclarationsChecker.kt | 22 +++- .../tests/sealed/NonPrivateConstructor.kt | 4 +- .../protectedConstructors_disabled.fir.kt | 41 ++++++ .../sealed/protectedConstructors_disabled.kt | 41 ++++++ .../sealed/protectedConstructors_disabled.txt | 119 ++++++++++++++++++ .../protectedConstructors_enabled.fir.kt | 41 ++++++ .../sealed/protectedConstructors_enabled.kt | 41 ++++++ .../sealed/protectedConstructors_enabled.txt | 119 ++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 12 ++ .../kotlin/idea/quickfix/QuickFixRegistrar.kt | 1 + 13 files changed, 447 insertions(+), 8 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.txt create mode 100644 compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 7bda4473beb..2979176d3f9 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -24511,6 +24511,18 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/sealed/OperationWhen.kt"); } + @Test + @TestMetadata("protectedConstructors_disabled.kt") + public void testProtectedConstructors_disabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.kt"); + } + + @Test + @TestMetadata("protectedConstructors_enabled.kt") + public void testProtectedConstructors_enabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.kt"); + } + @Test @TestMetadata("RedundantAbstract.kt") public void testRedundantAbstract() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 6c449bc8fc9..57e046bbc90 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -346,6 +346,7 @@ public interface Errors { DiagnosticFactory0 NON_PRIVATE_CONSTRUCTOR_IN_ENUM = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 NON_PRIVATE_CONSTRUCTOR_IN_SEALED = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED = DiagnosticFactory0.create(ERROR); // Inline and value classes diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 6647df6c551..94e0885959a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -705,6 +705,7 @@ public class DefaultErrorMessages { MAP.put(NON_PRIVATE_CONSTRUCTOR_IN_ENUM, "Constructor must be private in enum class"); MAP.put(NON_PRIVATE_CONSTRUCTOR_IN_SEALED, "Constructor must be private in sealed class"); + MAP.put(NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED, "Constructor must be private or protected in sealed class"); MAP.put(INLINE_CLASS_NOT_TOP_LEVEL, "Inline classes cannot be local or inner"); MAP.put(INLINE_CLASS_NOT_FINAL, "Inline classes can be only final"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt index f7220cd0efe..39e42e8a342 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt @@ -289,12 +289,22 @@ class DeclarationsChecker( private fun checkConstructorVisibility(constructorDescriptor: ClassConstructorDescriptor, declaration: KtDeclaration) { val visibilityModifier = declaration.visibilityModifier() - if (visibilityModifier != null && visibilityModifier.node?.elementType != KtTokens.PRIVATE_KEYWORD) { - val classDescriptor = constructorDescriptor.containingDeclaration - if (classDescriptor.kind == ClassKind.ENUM_CLASS) { - trace.report(NON_PRIVATE_CONSTRUCTOR_IN_ENUM.on(visibilityModifier)) - } else if (classDescriptor.modality == Modality.SEALED) { - trace.report(NON_PRIVATE_CONSTRUCTOR_IN_SEALED.on(visibilityModifier)) + val visibilityKeyword = visibilityModifier?.node?.elementType ?: return + val classDescriptor = constructorDescriptor.containingDeclaration + + when { + classDescriptor.kind == ClassKind.ENUM_CLASS -> { + if (visibilityKeyword != KtTokens.PRIVATE_KEYWORD) { + trace.report(NON_PRIVATE_CONSTRUCTOR_IN_ENUM.on(visibilityModifier)) + } + } + classDescriptor.modality == Modality.SEALED -> { + val protectedIsAllowed = + languageVersionSettings.supportsFeature(LanguageFeature.AllowSealedInheritorsInDifferentFilesOfSamePackage) + if (!(visibilityKeyword == KtTokens.PRIVATE_KEYWORD || (protectedIsAllowed && visibilityKeyword == KtTokens.PROTECTED_KEYWORD))) { + val factory = if (protectedIsAllowed) NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED else NON_PRIVATE_CONSTRUCTOR_IN_SEALED + trace.report(factory.on(visibilityModifier)) + } } } } diff --git a/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.kt b/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.kt index 97fb24a6e2c..4cbc7791eb8 100644 --- a/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.kt +++ b/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.kt @@ -1,7 +1,7 @@ -sealed class Sealed protected constructor(val x: Int) { +sealed class Sealed protected constructor(val x: Int) { object FIRST : Sealed() - public constructor(): this(42) + public constructor(): this(42) constructor(y: Int, z: Int): this(y + z) } diff --git a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt new file mode 100644 index 00000000000..1cf4934b52c --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt @@ -0,0 +1,41 @@ +// LANGUAGE: -AllowSealedInheritorsInDifferentFilesOfSamePackage +// DIAGNOSTICS: -UNUSED_PARAMETER + +sealed class Case1(val x: Int) { + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case1(10) + class Inheritor2 : Case1("Hello") +} + +sealed class Case2 protected constructor(val x: Int) { + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case2(10) + class Inheritor2 : Case2("Hello") +} + +sealed class Case3 private constructor(val x: Int) { + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case3(10) // should OK + class Inheritor2 : Case3("Hello") +} + +class Case3Inheritor3 : Case3(20) // should be an error in 1.6 (?) + +sealed class Case4 { + protected constructor(x: Int) + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case4(10) + class Inheritor2 : Case4("Hello") +} + +sealed class Case5() { + private constructor(x: Int) : this() + protected constructor(x: Byte) : this() + internal constructor(x: Short) : this() + public constructor(x: Long) : this() + constructor(x: Double) : this() +} diff --git a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.kt b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.kt new file mode 100644 index 00000000000..441c2ade829 --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.kt @@ -0,0 +1,41 @@ +// LANGUAGE: -AllowSealedInheritorsInDifferentFilesOfSamePackage +// DIAGNOSTICS: -UNUSED_PARAMETER + +sealed class Case1(val x: Int) { + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case1(10) + class Inheritor2 : Case1("Hello") +} + +sealed class Case2 protected constructor(val x: Int) { + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case2(10) + class Inheritor2 : Case2("Hello") +} + +sealed class Case3 private constructor(val x: Int) { + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case3(10) // should OK + class Inheritor2 : Case3("Hello") +} + +class Case3Inheritor3 : Case3(20) // should be an error in 1.6 (?) + +sealed class Case4 { + protected constructor(x: Int) + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case4(10) + class Inheritor2 : Case4("Hello") +} + +sealed class Case5() { + private constructor(x: Int) : this() + protected constructor(x: Byte) : this() + internal constructor(x: Short) : this() + public constructor(x: Long) : this() + constructor(x: Double) : this() +} diff --git a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.txt b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.txt new file mode 100644 index 00000000000..fbfa35e07cc --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.txt @@ -0,0 +1,119 @@ +package + +public sealed class Case1 { + private constructor Case1(/*0*/ x: kotlin.Int) + protected constructor Case1(/*0*/ s: kotlin.String) + public final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Inheritor1 : Case1 { + public constructor Inheritor1() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class Inheritor2 : Case1 { + public constructor Inheritor2() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public sealed class Case2 { + protected constructor Case2(/*0*/ x: kotlin.Int) + protected constructor Case2(/*0*/ s: kotlin.String) + public final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Inheritor1 : Case2 { + public constructor Inheritor1() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class Inheritor2 : Case2 { + public constructor Inheritor2() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public sealed class Case3 { + private constructor Case3(/*0*/ x: kotlin.Int) + protected constructor Case3(/*0*/ s: kotlin.String) + public final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Inheritor1 : Case3 { + public constructor Inheritor1() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class Inheritor2 : Case3 { + public constructor Inheritor2() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public final class Case3Inheritor3 : Case3 { + public constructor Case3Inheritor3() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public sealed class Case4 { + protected constructor Case4(/*0*/ x: kotlin.Int) + protected constructor Case4(/*0*/ s: kotlin.String) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Inheritor1 : Case4 { + public constructor Inheritor1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class Inheritor2 : Case4 { + public constructor Inheritor2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public sealed class Case5 { + private constructor Case5() + protected constructor Case5(/*0*/ x: kotlin.Byte) + private constructor Case5(/*0*/ x: kotlin.Double) + private constructor Case5(/*0*/ x: kotlin.Int) + public constructor Case5(/*0*/ x: kotlin.Long) + internal constructor Case5(/*0*/ x: kotlin.Short) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + diff --git a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt new file mode 100644 index 00000000000..f8993d384b7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt @@ -0,0 +1,41 @@ +// LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage +// DIAGNOSTICS: -UNUSED_PARAMETER + +sealed class Case1(val x: Int) { + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case1(10) + class Inheritor2 : Case1("Hello") +} + +sealed class Case2 protected constructor(val x: Int) { // should be REDUNDANT_MODIFIER + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case2(10) + class Inheritor2 : Case2("Hello") +} + +sealed class Case3 private constructor(val x: Int) { + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case3(10) // should OK + class Inheritor2 : Case3("Hello") +} + +class Case3Inheritor3 : Case3(20) // should be an error in 1.6 (?) + +sealed class Case4 { + protected constructor(x: Int) + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case4(10) + class Inheritor2 : Case4("Hello") +} + +sealed class Case5() { + private constructor(x: Int) : this() + protected constructor(x: Byte) : this() + internal constructor(x: Short) : this() + public constructor(x: Long) : this() + constructor(x: Double) : this() +} diff --git a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.kt b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.kt new file mode 100644 index 00000000000..6cec7e5a60f --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.kt @@ -0,0 +1,41 @@ +// LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage +// DIAGNOSTICS: -UNUSED_PARAMETER + +sealed class Case1(val x: Int) { + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case1(10) + class Inheritor2 : Case1("Hello") +} + +sealed class Case2 protected constructor(val x: Int) { // should be REDUNDANT_MODIFIER + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case2(10) + class Inheritor2 : Case2("Hello") +} + +sealed class Case3 private constructor(val x: Int) { + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case3(10) // should OK + class Inheritor2 : Case3("Hello") +} + +class Case3Inheritor3 : Case3(20) // should be an error in 1.6 (?) + +sealed class Case4 { + protected constructor(x: Int) + protected constructor(s: String) : this(s.length) + + class Inheritor1 : Case4(10) + class Inheritor2 : Case4("Hello") +} + +sealed class Case5() { + private constructor(x: Int) : this() + protected constructor(x: Byte) : this() + internal constructor(x: Short) : this() + public constructor(x: Long) : this() + constructor(x: Double) : this() +} diff --git a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.txt b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.txt new file mode 100644 index 00000000000..14f18fc82ca --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.txt @@ -0,0 +1,119 @@ +package + +public sealed class Case1 { + protected constructor Case1(/*0*/ x: kotlin.Int) + protected constructor Case1(/*0*/ s: kotlin.String) + public final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Inheritor1 : Case1 { + public constructor Inheritor1() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class Inheritor2 : Case1 { + public constructor Inheritor2() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public sealed class Case2 { + protected constructor Case2(/*0*/ x: kotlin.Int) + protected constructor Case2(/*0*/ s: kotlin.String) + public final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Inheritor1 : Case2 { + public constructor Inheritor1() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class Inheritor2 : Case2 { + public constructor Inheritor2() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public sealed class Case3 { + private constructor Case3(/*0*/ x: kotlin.Int) + protected constructor Case3(/*0*/ s: kotlin.String) + public final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Inheritor1 : Case3 { + public constructor Inheritor1() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class Inheritor2 : Case3 { + public constructor Inheritor2() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public final class Case3Inheritor3 : Case3 { + public constructor Case3Inheritor3() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public sealed class Case4 { + protected constructor Case4(/*0*/ x: kotlin.Int) + protected constructor Case4(/*0*/ s: kotlin.String) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Inheritor1 : Case4 { + public constructor Inheritor1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class Inheritor2 : Case4 { + public constructor Inheritor2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public sealed class Case5 { + protected constructor Case5() + protected constructor Case5(/*0*/ x: kotlin.Byte) + protected constructor Case5(/*0*/ x: kotlin.Double) + private constructor Case5(/*0*/ x: kotlin.Int) + public constructor Case5(/*0*/ x: kotlin.Long) + internal constructor Case5(/*0*/ x: kotlin.Short) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index f0355b8a1ec..b41b5ab81ca 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -24601,6 +24601,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/sealed/OperationWhen.kt"); } + @Test + @TestMetadata("protectedConstructors_disabled.kt") + public void testProtectedConstructors_disabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.kt"); + } + + @Test + @TestMetadata("protectedConstructors_enabled.kt") + public void testProtectedConstructors_enabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.kt"); + } + @Test @TestMetadata("RedundantAbstract.kt") public void testRedundantAbstract() throws Exception { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index bb41288f250..0c4d532b0a1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -149,6 +149,7 @@ class QuickFixRegistrar : QuickFixContributor { REPEATED_MODIFIER.registerFactory(removeModifierFactory) NON_PRIVATE_CONSTRUCTOR_IN_ENUM.registerFactory(removeModifierFactory) NON_PRIVATE_CONSTRUCTOR_IN_SEALED.registerFactory(removeModifierFactory) + NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED.registerFactory(removeModifierFactory) TYPE_CANT_BE_USED_FOR_CONST_VAL.registerFactory(removeModifierFactory) DEPRECATED_BINARY_MOD.registerFactory(removeModifierFactory) DEPRECATED_BINARY_MOD.registerFactory(RenameModToRemFix.Factory) From 2d5b685535800c77c93b1ceda62b3c2c1a83202f Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 11 Feb 2021 13:20:03 +0300 Subject: [PATCH 030/368] [FIR] Fix processing constructors of sealed classes - Allow declaring protected constructors in sealed classes - Make default visibility of sealed class constructor `protected` KT-44861 KT-44865 --- ...denConstructorWithInlineClassParameters.txt | 2 +- .../loadCompiledKotlin/class/SealedClass.txt | 2 +- .../testData/resolve/constantValues.fir.txt | 2 +- .../diagnostics/incompatibleModifiers.fir.txt | 8 ++++---- .../diagnostics/redundantModifier.fir.txt | 2 +- .../sealedClassConstructorCall.fir.txt | 4 ++-- .../diagnostics/sealedClassConstructorCall.kt | 2 +- .../diagnostics/sealedSupertype.fir.txt | 4 ++-- .../negative/missingSealedInheritor.fir.txt | 2 +- .../exhaustiveness_sealedClass.fir.txt | 2 +- .../exhaustiveness_sealedObject.fir.txt | 2 +- .../exhaustiveness_sealedSubClass.fir.txt | 8 ++++---- .../classifierAccessFromCompanion.fir.txt | 2 +- .../RedundantVisibilityModifierChecker.fir.txt | 2 +- .../resolve/multifile/sealedStarImport.fir.txt | 2 +- .../recursiveCallOnWhenWithSealedClass.fir.txt | 2 +- .../testData/resolve/sealedClass.fir.txt | 2 +- .../resolve/smartcasts/kt37327.fir.txt | 2 +- .../lambdas/lambdaInWhenBranch.fir.txt | 2 +- .../types/bareWithSubjectTypeAlias.fir.txt | 2 +- .../diagnostics/FirDiagnosticsList.kt | 2 +- .../fir/analysis/diagnostics/FirErrors.kt | 2 +- .../FirConstructorAllowedChecker.kt | 14 ++++++++++---- .../diagnostics/FirDefaultErrorMessages.kt | 4 ++-- .../converter/DeclarationsConverter.kt | 4 +++- .../kotlin/fir/lightTree/fir/ClassWrapper.kt | 2 +- .../kotlin/fir/builder/RawFirBuilder.kt | 4 ++-- .../declarations/enums.lazyBodies.txt | 4 ++-- .../testData/rawBuilder/declarations/enums.txt | 4 ++-- .../declarations/enums2.lazyBodies.txt | 2 +- .../rawBuilder/declarations/enums2.txt | 2 +- .../ultraLightClasses/classModifiers.java | 6 +++--- .../tests/sealed/MultipleFiles_enabled.fir.kt | 2 +- .../tests/sealed/NonPrivateConstructor.fir.kt | 4 ++-- .../sealed/inheritorInDifferentModule.fir.kt | 2 +- .../diagnostics/tests/sealed/kt44861.fir.kt | 17 ----------------- .../diagnostics/tests/sealed/kt44861.kt | 1 + .../protectedConstructors_disabled.fir.kt | 18 +++++++++--------- .../protectedConstructors_enabled.fir.kt | 18 +++++++++--------- .../typeAliasConstructorWrongClass.fir.kt | 4 ++-- .../ir/irText/classes/sealedClasses.fir.kt.txt | 2 +- .../ir/irText/classes/sealedClasses.fir.txt | 8 ++++---- .../expectedSealedClass.fir.kt.txt | 4 ++-- .../multiplatform/expectedSealedClass.fir.txt | 6 +++--- .../diagnostics/KtFirDataClassConverters.kt | 4 ++-- .../api/fir/diagnostics/KtFirDiagnostics.kt | 4 ++-- .../fir/diagnostics/KtFirDiagnosticsImpl.kt | 4 ++-- 47 files changed, 98 insertions(+), 106 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/sealed/kt44861.fir.kt diff --git a/compiler/fir/analysis-tests/testData/loadCompiledKotlin/annotations/classMembers/HiddenConstructorWithInlineClassParameters.txt b/compiler/fir/analysis-tests/testData/loadCompiledKotlin/annotations/classMembers/HiddenConstructorWithInlineClassParameters.txt index 08dd7c55828..dcfdffe0060 100644 --- a/compiler/fir/analysis-tests/testData/loadCompiledKotlin/annotations/classMembers/HiddenConstructorWithInlineClassParameters.txt +++ b/compiler/fir/analysis-tests/testData/loadCompiledKotlin/annotations/classMembers/HiddenConstructorWithInlineClassParameters.txt @@ -12,7 +12,7 @@ public sealed class Sealed : R|kotlin/Any| { public final val z: R|test/Z| public get(): R|test/Z| - @R|test/Ann|() internal constructor(@R|test/Ann|() z: R|test/Z|): R|test/Sealed| + @R|test/Ann|() protected constructor(@R|test/Ann|() z: R|test/Z|): R|test/Sealed| } diff --git a/compiler/fir/analysis-tests/testData/loadCompiledKotlin/class/SealedClass.txt b/compiler/fir/analysis-tests/testData/loadCompiledKotlin/class/SealedClass.txt index 7eb9f3de23d..5a4cc58b80e 100644 --- a/compiler/fir/analysis-tests/testData/loadCompiledKotlin/class/SealedClass.txt +++ b/compiler/fir/analysis-tests/testData/loadCompiledKotlin/class/SealedClass.txt @@ -14,7 +14,7 @@ public sealed class SealedClass : R|kotlin/Any| { } - internal constructor(): R|test/SealedClass| + protected constructor(): R|test/SealedClass| } diff --git a/compiler/fir/analysis-tests/testData/resolve/constantValues.fir.txt b/compiler/fir/analysis-tests/testData/resolve/constantValues.fir.txt index 81bbe2a4f85..28d5dccf463 100644 --- a/compiler/fir/analysis-tests/testData/resolve/constantValues.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/constantValues.fir.txt @@ -44,7 +44,7 @@ FILE: constantValues.kt } public sealed class Value : R|kotlin/Any| { - private constructor(): R|KClassValue.Value| { + protected constructor(): R|KClassValue.Value| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.fir.txt index 823b6488df7..dde4466903e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.fir.txt @@ -30,13 +30,13 @@ FILE: incompatibleModifiers.kt } public final class F : R|kotlin/Any| { - private constructor(): R|F| { + protected constructor(): R|F| { super() } } public sealed class G : R|kotlin/Any| { - private constructor(): R|G| { + protected constructor(): R|G| { super() } @@ -57,7 +57,7 @@ FILE: incompatibleModifiers.kt } public sealed data class I : R|kotlin/Any| { - private constructor(i: R|kotlin/Int|): R|I| { + protected constructor(i: R|kotlin/Int|): R|I| { super() } @@ -126,7 +126,7 @@ FILE: incompatibleModifiers.kt } public sealed inner class Z : R|kotlin/Any| { - private constructor(): R|X.Z| { + protected constructor(): R|X.Z| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/redundantModifier.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/redundantModifier.fir.txt index d2716c234c6..aea1166c7a2 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/redundantModifier.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/redundantModifier.fir.txt @@ -6,7 +6,7 @@ FILE: redundantModifier.kt } public sealed class B : R|kotlin/Any| { - private constructor(): R|B| { + protected constructor(): R|B| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.fir.txt index 6f593d2a8fc..b6381cfa192 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.fir.txt @@ -1,9 +1,9 @@ FILE: sealedClassConstructorCall.kt public sealed class A : R|kotlin/Any| { - private constructor(): R|A| { + protected constructor(): R|A| { super() } } - public final val b: R|A| = R|/A.A|() + public final val b: R|A| = #() public get(): R|A| diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.kt index ae002614d51..f0f7d5dc473 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.kt @@ -1,3 +1,3 @@ sealed class A -val b = A() +val b = A() diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.fir.txt index 80e01f0bf6d..0ba1e44476e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.fir.txt @@ -1,6 +1,6 @@ FILE: sealedSupertype.kt public sealed class A : R|kotlin/Any| { - private constructor(): R|A| { + protected constructor(): R|A| { super() } @@ -22,7 +22,7 @@ FILE: sealedSupertype.kt } public sealed class P : R|kotlin/Any| { - private constructor(): R|P| { + protected constructor(): R|P| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/negative/missingSealedInheritor.fir.txt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/negative/missingSealedInheritor.fir.txt index 0d11593bd9b..6cb8362f9d3 100644 --- a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/negative/missingSealedInheritor.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/negative/missingSealedInheritor.fir.txt @@ -1,6 +1,6 @@ FILE: a.kt public sealed class Base : R|kotlin/Any| { - private constructor(): R|Base| { + protected constructor(): R|Base| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedClass.fir.txt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedClass.fir.txt index 723c1e4b13e..191f39b8b8b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedClass.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedClass.fir.txt @@ -1,6 +1,6 @@ FILE: exhaustiveness_sealedClass.kt public sealed class Base : R|kotlin/Any| { - private constructor(): R|Base| { + protected constructor(): R|Base| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedObject.fir.txt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedObject.fir.txt index ac004e4505b..e2c59d3190f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedObject.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedObject.fir.txt @@ -1,6 +1,6 @@ FILE: exhaustiveness_sealedObject.kt public sealed class A : R|kotlin/Any| { - private constructor(): R|A| { + protected constructor(): R|A| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.fir.txt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.fir.txt index db6cbd744a5..0eebe0a863e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.fir.txt @@ -1,12 +1,12 @@ FILE: exhaustiveness_sealedSubClass.kt public sealed class A : R|kotlin/Any| { - private constructor(): R|A| { + protected constructor(): R|A| { super() } } public sealed class B : R|A| { - private constructor(): R|B| { + protected constructor(): R|B| { super() } @@ -18,13 +18,13 @@ FILE: exhaustiveness_sealedSubClass.kt } public sealed class D : R|B| { - private constructor(): R|D| { + protected constructor(): R|D| { super() } } public sealed class E : R|B| { - private constructor(): R|E| { + protected constructor(): R|E| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/classifierAccessFromCompanion.fir.txt b/compiler/fir/analysis-tests/testData/resolve/expresssions/classifierAccessFromCompanion.fir.txt index 809328821d2..96ce52c79eb 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/classifierAccessFromCompanion.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/classifierAccessFromCompanion.fir.txt @@ -5,7 +5,7 @@ FILE: classifierAccessFromCompanion.kt } public sealed class Function : R|kotlin/Any| { - private constructor(): R|Factory.Function| { + protected constructor(): R|Factory.Function| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.fir.txt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.fir.txt index 3d9510284c9..d2c4e79b455 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.fir.txt @@ -111,7 +111,7 @@ FILE: RedundantVisibilityModifierChecker.kt } public sealed class G : R|kotlin/Any| { - private constructor(y: R|kotlin/Int|): R|G| { + protected constructor(y: R|kotlin/Int|): R|G| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/multifile/sealedStarImport.fir.txt b/compiler/fir/analysis-tests/testData/resolve/multifile/sealedStarImport.fir.txt index 5e81cbcc178..3122e0aca97 100644 --- a/compiler/fir/analysis-tests/testData/resolve/multifile/sealedStarImport.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/multifile/sealedStarImport.fir.txt @@ -1,6 +1,6 @@ FILE: test.kt public sealed class Test : R|kotlin/Any| { - private constructor(): R|test/Test| { + protected constructor(): R|test/Test| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.fir.txt b/compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.fir.txt index 35ec125e8b5..92b335ce9db 100644 --- a/compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/recursiveCallOnWhenWithSealedClass.fir.txt @@ -1,6 +1,6 @@ FILE: recursiveCallOnWhenWithSealedClass.kt public sealed class Maybe : R|kotlin/Any| { - private constructor(): R|Maybe| { + protected constructor(): R|Maybe| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/sealedClass.fir.txt b/compiler/fir/analysis-tests/testData/resolve/sealedClass.fir.txt index 0f0589d2813..6b8b7de1418 100644 --- a/compiler/fir/analysis-tests/testData/resolve/sealedClass.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/sealedClass.fir.txt @@ -1,6 +1,6 @@ FILE: sealedClass.kt public sealed class Foo : R|kotlin/Any| { - private constructor(value: R|kotlin/String|): R|Foo| { + protected constructor(value: R|kotlin/String|): R|Foo| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/kt37327.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/kt37327.fir.txt index 1aa8f2fa51e..dd498c79d99 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/kt37327.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/kt37327.fir.txt @@ -2,7 +2,7 @@ FILE: kt37327.kt public abstract interface Q : R|kotlin/Any| { } public sealed class A : R|Q| { - private constructor(): R|A| { + protected constructor(): R|A| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.fir.txt index 30d59e0510e..a589aac53c9 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.fir.txt @@ -1,6 +1,6 @@ FILE: lambdaInWhenBranch.kt private sealed class Sealed : R|kotlin/Any| { - private constructor(): R|Sealed| { + protected constructor(): R|Sealed| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.fir.txt b/compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.fir.txt index 8b9a7d06ea7..e0f12bbb40e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/types/bareWithSubjectTypeAlias.fir.txt @@ -1,6 +1,6 @@ FILE: bareWithSubjectTypeAlias.kt public sealed class A : R|kotlin/Any| { - private constructor(): R|A| { + protected constructor(): R|A| { super() } diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 542e8bf46d3..0295c7f5624 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -88,7 +88,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val CONSTRUCTOR_IN_OBJECT by error(PositioningStrategy.DECLARATION_SIGNATURE) val CONSTRUCTOR_IN_INTERFACE by error(PositioningStrategy.DECLARATION_SIGNATURE) val NON_PRIVATE_CONSTRUCTOR_IN_ENUM by error() - val NON_PRIVATE_CONSTRUCTOR_IN_SEALED by error() + val NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED by error() val CYCLIC_CONSTRUCTOR_DELEGATION_CALL by warning() val PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED by warning(PositioningStrategy.SECONDARY_CONSTRUCTOR_DELEGATION_CALL) val SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR by warning() diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 3d8f70a05e2..3c2f2f618f8 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -95,7 +95,7 @@ object FirErrors { val CONSTRUCTOR_IN_OBJECT by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) val CONSTRUCTOR_IN_INTERFACE by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) val NON_PRIVATE_CONSTRUCTOR_IN_ENUM by error0() - val NON_PRIVATE_CONSTRUCTOR_IN_SEALED by error0() + val NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED by error0() val CYCLIC_CONSTRUCTOR_DELEGATION_CALL by warning0() val PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED by warning0(SourceElementPositioningStrategies.SECONDARY_CONSTRUCTOR_DELEGATION_CALL) val SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR by warning0() diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorAllowedChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorAllowedChecker.kt index 28532e3cc63..3bf7cb9268f 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorAllowedChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorAllowedChecker.kt @@ -14,6 +14,8 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.lexer.KtModifierKeywordToken +import org.jetbrains.kotlin.lexer.KtTokens object FirConstructorAllowedChecker : FirConstructorChecker() { override fun check(declaration: FirConstructor, context: CheckerContext, reporter: DiagnosticReporter) { @@ -30,10 +32,14 @@ object FirConstructorAllowedChecker : FirConstructorChecker() { ClassKind.ENUM_CLASS -> if (declaration.visibility != Visibilities.Private) { reporter.reportOn(source, FirErrors.NON_PRIVATE_CONSTRUCTOR_IN_ENUM, context) } - ClassKind.CLASS -> if (containingClass is FirRegularClass && containingClass.modality == Modality.SEALED && - declaration.visibility != Visibilities.Private - ) { - reporter.reportOn(source, FirErrors.NON_PRIVATE_CONSTRUCTOR_IN_SEALED, context) + ClassKind.CLASS -> if (containingClass is FirRegularClass && containingClass.modality == Modality.SEALED) { + val modifierList = with(FirModifierList) { source.getModifierList() } ?: return + val hasIllegalModifier = modifierList.modifiers.any { + it.token != KtTokens.PROTECTED_KEYWORD && it.token != KtTokens.PRIVATE_KEYWORD + } + if (hasIllegalModifier) { + reporter.reportOn(source, FirErrors.NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED, context) + } } ClassKind.ANNOTATION_CLASS -> { // DO NOTHING diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index 8cde51292cc..e2bcc0e751c 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -101,7 +101,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NONE_APPLICABLE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_ABSTRACT_FUNCTION_WITH_NO_BODY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_MEMBER_FUNCTION_NO_BODY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_PRIVATE_CONSTRUCTOR_IN_ENUM -import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_PRIVATE_CONSTRUCTOR_IN_SEALED +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NOTHING_TO_OVERRIDE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NOT_AN_ANNOTATION_CLASS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NOT_A_LOOP_LABEL @@ -247,7 +247,7 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { map.put(CONSTRUCTOR_IN_OBJECT, "Constructors are not allowed for objects") map.put(CONSTRUCTOR_IN_INTERFACE, "An interface may not have a constructor") map.put(NON_PRIVATE_CONSTRUCTOR_IN_ENUM, "Constructor must be private in enum class") - map.put(NON_PRIVATE_CONSTRUCTOR_IN_SEALED, "Constructor must be private in sealed class") + map.put(NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED, "Constructor must be private or protected in sealed class") map.put(CYCLIC_CONSTRUCTOR_DELEGATION_CALL, "There's a cycle in the delegation calls chain") map.put(PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED, "Primary constructor call expected") map.put(SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR, "Supertype initialization is impossible without primary constructor") diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index e4acbaa0b71..2084418e5f4 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -740,7 +740,9 @@ class DeclarationsConverter( extractArgumentsFrom(classWrapper.superTypeCallEntry, stubMode) } - val explicitVisibility = if (primaryConstructor != null) modifiers.getVisibility() else null + val explicitVisibility = runIf(primaryConstructor != null) { + modifiers.getVisibility().takeUnless { it == Visibilities.Unknown } + } val status = FirDeclarationStatusImpl(explicitVisibility ?: defaultVisibility, Modality.FINAL).apply { isExpect = modifiers.hasExpect() || classWrapper.hasExpect() isActual = modifiers.hasActual() diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt index 4aac25e5468..c4263f86709 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ClassWrapper.kt @@ -64,7 +64,7 @@ class ClassWrapper( fun defaultConstructorVisibility(): Visibility { return when { isObject() || isEnum() || isEnumEntry() -> Visibilities.Private - isSealed() -> Visibilities.Private + isSealed() -> Visibilities.Protected else -> Visibilities.Unknown } } diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index e45a001a557..7b47a505f95 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -657,11 +657,11 @@ class RawFirBuilder( // See DescriptorUtils#getDefaultConstructorVisibility in core.descriptors fun defaultVisibility() = when { owner is KtObjectDeclaration || owner.hasModifier(ENUM_KEYWORD) || owner is KtEnumEntry -> Visibilities.Private - owner.hasModifier(SEALED_KEYWORD) -> Visibilities.Private + owner.hasModifier(SEALED_KEYWORD) -> Visibilities.Protected else -> Visibilities.Unknown } - val explicitVisibility = this?.visibility + val explicitVisibility = this?.visibility?.takeUnless { it == Visibilities.Unknown } val status = FirDeclarationStatusImpl(explicitVisibility ?: defaultVisibility(), Modality.FINAL).apply { isExpect = this@toFirConstructor?.hasExpectModifier() == true || owner.hasExpectModifier() isActual = this@toFirConstructor?.hasActualModifier() == true diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.lazyBodies.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.lazyBodies.txt index eaddd535657..f67532f6a24 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.lazyBodies.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.lazyBodies.txt @@ -15,7 +15,7 @@ FILE: enums.kt } public? final? enum class Planet : R|kotlin/Enum| { - public? constructor(m: Double, r: Double): R|Planet| { + private constructor(m: Double, r: Double): R|Planet| { super|>() } @@ -75,7 +75,7 @@ FILE: enums.kt } public? final? enum class PseudoInsn : R|kotlin/Enum| { - public? constructor(signature: String = String(()V)): R|PseudoInsn| { + private constructor(signature: String = String(()V)): R|PseudoInsn| { super|>() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.txt index fcad62ee318..c66710a551e 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.txt @@ -15,7 +15,7 @@ FILE: enums.kt } public? final? enum class Planet : R|kotlin/Enum| { - public? constructor(m: Double, r: Double): R|Planet| { + private constructor(m: Double, r: Double): R|Planet| { super|>() } @@ -81,7 +81,7 @@ FILE: enums.kt } public? final? enum class PseudoInsn : R|kotlin/Enum| { - public? constructor(signature: String = String(()V)): R|PseudoInsn| { + private constructor(signature: String = String(()V)): R|PseudoInsn| { super|>() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.lazyBodies.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.lazyBodies.txt index cc70152eafd..345d0dbdfda 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.lazyBodies.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.lazyBodies.txt @@ -14,7 +14,7 @@ FILE: enums2.kt } public? final? enum class SomeEnum : R|kotlin/Enum| { - public? constructor(x: Some): R|SomeEnum| { + private constructor(x: Some): R|SomeEnum| { super|>() } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.txt index 708f4462eee..a56c4c8077b 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.txt @@ -14,7 +14,7 @@ FILE: enums2.kt } public? final? enum class SomeEnum : R|kotlin/Enum| { - public? constructor(x: Some): R|SomeEnum| { + private constructor(x: Some): R|SomeEnum| { super|>() } diff --git a/compiler/testData/asJava/ultraLightClasses/classModifiers.java b/compiler/testData/asJava/ultraLightClasses/classModifiers.java index 4773eae1465..7f4697c5aed 100644 --- a/compiler/testData/asJava/ultraLightClasses/classModifiers.java +++ b/compiler/testData/asJava/ultraLightClasses/classModifiers.java @@ -38,7 +38,7 @@ final class TopLevelPrivate /* pkg.TopLevelPrivate*/ { } public abstract class Season /* pkg.Season*/ { - private Season();// .ctor() + protected Season();// .ctor() class Nested ... @@ -53,8 +53,8 @@ public static final class Nested /* pkg.Season.Nested*/ extends pkg.Season { public abstract class SealedWithArgs /* pkg.SealedWithArgs*/ { private final int a; - private SealedWithArgs(int);// .ctor(int) + protected SealedWithArgs(int);// .ctor(int) public final int getA();// getA() -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.fir.kt b/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.fir.kt index 455e7591dde..4dd5bed6c9c 100644 --- a/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.fir.kt @@ -37,4 +37,4 @@ package bar import foo.Base -class E : Base() +class E : Base() diff --git a/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.fir.kt b/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.fir.kt index e6e1f2e7bc5..5e21295629e 100644 --- a/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/NonPrivateConstructor.fir.kt @@ -1,7 +1,7 @@ -sealed class Sealed protected constructor(val x: Int) { +sealed class Sealed protected constructor(val x: Int) { object FIRST : Sealed() - public constructor(): this(42) + public constructor(): this(42) constructor(y: Int, z: Int): this(y + z) } diff --git a/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.fir.kt b/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.fir.kt index 28c559c7734..6f9e7f14705 100644 --- a/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.fir.kt @@ -14,4 +14,4 @@ class A : Base() package a -class B : Base() +class B : Base() diff --git a/compiler/testData/diagnostics/tests/sealed/kt44861.fir.kt b/compiler/testData/diagnostics/tests/sealed/kt44861.fir.kt deleted file mode 100644 index 9e13166b1ce..00000000000 --- a/compiler/testData/diagnostics/tests/sealed/kt44861.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ -// ISSUE: KT-44861 -// DIAGNOSTICS: -UNUSED_VARIABLE - -sealed class Foo() { - class A : Foo() - class B : Foo() -} - -fun Foo(kind: String = "A"): Foo = when (kind) { - "A" -> Foo.A() - "B" -> Foo.B() - else -> throw Exception() -} - -fun main() { - val foo = Foo() -} diff --git a/compiler/testData/diagnostics/tests/sealed/kt44861.kt b/compiler/testData/diagnostics/tests/sealed/kt44861.kt index 72198eaf079..24cae5790b2 100644 --- a/compiler/testData/diagnostics/tests/sealed/kt44861.kt +++ b/compiler/testData/diagnostics/tests/sealed/kt44861.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // ISSUE: KT-44861 // DIAGNOSTICS: -UNUSED_VARIABLE diff --git a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt index 1cf4934b52c..09d0542dfd5 100644 --- a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt @@ -2,21 +2,21 @@ // DIAGNOSTICS: -UNUSED_PARAMETER sealed class Case1(val x: Int) { - protected constructor(s: String) : this(s.length) + protected constructor(s: String) : this(s.length) class Inheritor1 : Case1(10) class Inheritor2 : Case1("Hello") } -sealed class Case2 protected constructor(val x: Int) { - protected constructor(s: String) : this(s.length) +sealed class Case2 protected constructor(val x: Int) { + protected constructor(s: String) : this(s.length) class Inheritor1 : Case2(10) class Inheritor2 : Case2("Hello") } sealed class Case3 private constructor(val x: Int) { - protected constructor(s: String) : this(s.length) + protected constructor(s: String) : this(s.length) class Inheritor1 : Case3(10) // should OK class Inheritor2 : Case3("Hello") @@ -25,8 +25,8 @@ sealed class Case3 private constructor(val x: Int) { class Case3Inheritor3 : Case3(20) // should be an error in 1.6 (?) sealed class Case4 { - protected constructor(x: Int) - protected constructor(s: String) : this(s.length) + protected constructor(x: Int) + protected constructor(s: String) : this(s.length) class Inheritor1 : Case4(10) class Inheritor2 : Case4("Hello") @@ -34,8 +34,8 @@ sealed class Case4 { sealed class Case5() { private constructor(x: Int) : this() - protected constructor(x: Byte) : this() - internal constructor(x: Short) : this() - public constructor(x: Long) : this() + protected constructor(x: Byte) : this() + internal constructor(x: Short) : this() + public constructor(x: Long) : this() constructor(x: Double) : this() } diff --git a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt index f8993d384b7..c601bf18f43 100644 --- a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt @@ -2,21 +2,21 @@ // DIAGNOSTICS: -UNUSED_PARAMETER sealed class Case1(val x: Int) { - protected constructor(s: String) : this(s.length) + protected constructor(s: String) : this(s.length) class Inheritor1 : Case1(10) class Inheritor2 : Case1("Hello") } -sealed class Case2 protected constructor(val x: Int) { // should be REDUNDANT_MODIFIER - protected constructor(s: String) : this(s.length) +sealed class Case2 protected constructor(val x: Int) { // should be REDUNDANT_MODIFIER + protected constructor(s: String) : this(s.length) class Inheritor1 : Case2(10) class Inheritor2 : Case2("Hello") } sealed class Case3 private constructor(val x: Int) { - protected constructor(s: String) : this(s.length) + protected constructor(s: String) : this(s.length) class Inheritor1 : Case3(10) // should OK class Inheritor2 : Case3("Hello") @@ -25,8 +25,8 @@ sealed class Case3 private constructor(val x: Int) { class Case3Inheritor3 : Case3(20) // should be an error in 1.6 (?) sealed class Case4 { - protected constructor(x: Int) - protected constructor(s: String) : this(s.length) + protected constructor(x: Int) + protected constructor(s: String) : this(s.length) class Inheritor1 : Case4(10) class Inheritor2 : Case4("Hello") @@ -34,8 +34,8 @@ sealed class Case4 { sealed class Case5() { private constructor(x: Int) : this() - protected constructor(x: Byte) : this() - internal constructor(x: Short) : this() - public constructor(x: Long) : this() + protected constructor(x: Byte) : this() + internal constructor(x: Short) : this() + public constructor(x: Long) : this() constructor(x: Double) : this() } diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.fir.kt index 66c2df6df98..10b76eeffe5 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.fir.kt @@ -17,8 +17,8 @@ val test3a = EnumClass() sealed class SealedClass typealias Test4 = SealedClass -val test4 = Test4() -val test4a = SealedClass() +val test4 = Test4() +val test4a = SealedClass() class Outer { inner class Inner diff --git a/compiler/testData/ir/irText/classes/sealedClasses.fir.kt.txt b/compiler/testData/ir/irText/classes/sealedClasses.fir.kt.txt index 2c148f51ccb..4bb99510fdf 100644 --- a/compiler/testData/ir/irText/classes/sealedClasses.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/sealedClasses.fir.kt.txt @@ -1,5 +1,5 @@ sealed class Expr { - private constructor() /* primary */ { + protected constructor() /* primary */ { super/*Any*/() /* () */ diff --git a/compiler/testData/ir/irText/classes/sealedClasses.fir.txt b/compiler/testData/ir/irText/classes/sealedClasses.fir.txt index 0fc219b4df4..5b19df65239 100644 --- a/compiler/testData/ir/irText/classes/sealedClasses.fir.txt +++ b/compiler/testData/ir/irText/classes/sealedClasses.fir.txt @@ -1,7 +1,7 @@ FILE fqName: fileName:/sealedClasses.kt CLASS CLASS name:Expr modality:SEALED visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Expr - CONSTRUCTOR visibility:private <> () returnType:.Expr [primary] + CONSTRUCTOR visibility:protected <> () returnType:.Expr [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Expr modality:SEALED visibility:public superTypes:[kotlin.Any]' @@ -10,7 +10,7 @@ FILE fqName: fileName:/sealedClasses.kt CONSTRUCTOR visibility:public <> (number:kotlin.Double) returnType:.Expr.Const [primary] VALUE_PARAMETER name:number index:0 type:kotlin.Double BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Expr' + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .Expr' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Const modality:FINAL visibility:public superTypes:[.Expr]' PROPERTY name:number visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:number type:kotlin.Double visibility:private [final] @@ -42,7 +42,7 @@ FILE fqName: fileName:/sealedClasses.kt VALUE_PARAMETER name:e1 index:0 type:.Expr VALUE_PARAMETER name:e2 index:1 type:.Expr BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Expr' + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .Expr' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Sum modality:FINAL visibility:public superTypes:[.Expr]' PROPERTY name:e1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:e1 type:.Expr visibility:private [final] @@ -83,7 +83,7 @@ FILE fqName: fileName:/sealedClasses.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Expr.NotANumber CONSTRUCTOR visibility:private <> () returnType:.Expr.NotANumber [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Expr' + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .Expr' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:NotANumber modality:FINAL visibility:public superTypes:[.Expr]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.kt.txt b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.kt.txt index c409b307440..28ca0eeb57d 100644 --- a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.kt.txt @@ -1,5 +1,5 @@ expect sealed class Ops { - private expect constructor() /* primary */ + protected expect constructor() /* primary */ } @@ -9,7 +9,7 @@ expect class Add : Ops { } sealed class Ops { - private constructor() /* primary */ { + protected constructor() /* primary */ { super/*Any*/() /* () */ diff --git a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt index 17cb0449919..9f4ae699881 100644 --- a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt +++ b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt @@ -1,7 +1,7 @@ FILE fqName: fileName:/expectedSealedClass.kt CLASS CLASS name:Ops modality:SEALED visibility:public [expect] superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Ops - CONSTRUCTOR visibility:private <> () returnType:.Ops [primary,expect] + CONSTRUCTOR visibility:protected <> () returnType:.Ops [primary,expect] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [expect,fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -33,7 +33,7 @@ FILE fqName: fileName:/expectedSealedClass.kt $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Ops modality:SEALED visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Ops - CONSTRUCTOR visibility:private <> () returnType:.Ops [primary] + CONSTRUCTOR visibility:protected <> () returnType:.Ops [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Ops modality:SEALED visibility:public superTypes:[kotlin.Any]' @@ -54,7 +54,7 @@ FILE fqName: fileName:/expectedSealedClass.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Add CONSTRUCTOR visibility:public <> () returnType:.Add [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Ops' + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .Ops' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Add modality:FINAL visibility:public superTypes:[.Ops]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt index 97feba597ca..31da6df9c5a 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -260,8 +260,8 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } - add(FirErrors.NON_PRIVATE_CONSTRUCTOR_IN_SEALED) { firDiagnostic -> - NonPrivateConstructorInSealedImpl( + add(FirErrors.NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED) { firDiagnostic -> + NonPrivateOrProtectedConstructorInSealedImpl( firDiagnostic as FirPsiDiagnostic<*>, token, ) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt index 723cec5ae4b..7a6b74440a1 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -190,8 +190,8 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { override val diagnosticClass get() = NonPrivateConstructorInEnum::class } - abstract class NonPrivateConstructorInSealed : KtFirDiagnostic() { - override val diagnosticClass get() = NonPrivateConstructorInSealed::class + abstract class NonPrivateOrProtectedConstructorInSealed : KtFirDiagnostic() { + override val diagnosticClass get() = NonPrivateOrProtectedConstructorInSealed::class } abstract class CyclicConstructorDelegationCall : KtFirDiagnostic() { diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index 7a52c4f2f37..cef054dea64 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -299,10 +299,10 @@ internal class NonPrivateConstructorInEnumImpl( override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) } -internal class NonPrivateConstructorInSealedImpl( +internal class NonPrivateOrProtectedConstructorInSealedImpl( firDiagnostic: FirPsiDiagnostic<*>, override val token: ValidityToken, -) : KtFirDiagnostic.NonPrivateConstructorInSealed(), KtAbstractFirDiagnostic { +) : KtFirDiagnostic.NonPrivateOrProtectedConstructorInSealed(), KtAbstractFirDiagnostic { override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) } From 0de251e50d8d5b111692e71f1f1a9674c06d355e Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Wed, 26 Aug 2020 11:38:50 +0300 Subject: [PATCH 031/368] Add `runTestInWriteCommand` flag to `AbstractImportTest` --- idea/tests/org/jetbrains/kotlin/AbstractImportsTest.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/idea/tests/org/jetbrains/kotlin/AbstractImportsTest.kt b/idea/tests/org/jetbrains/kotlin/AbstractImportsTest.kt index fa09e14be52..179350bc945 100644 --- a/idea/tests/org/jetbrains/kotlin/AbstractImportsTest.kt +++ b/idea/tests/org/jetbrains/kotlin/AbstractImportsTest.kt @@ -62,7 +62,11 @@ abstract class AbstractImportsTest : KotlinLightCodeInsightFixtureTestCase() { codeStyleSettings.PACKAGES_TO_USE_STAR_IMPORTS.addEntry(KotlinPackageEntry(it.trim(), true)) } - val log = project.executeWriteCommand("") { doTest(file) } + val log = if (runTestInWriteCommand) { + project.executeWriteCommand("") { doTest(file) } + } else { + doTest(file) + } KotlinTestUtils.assertEqualsToFile(File("$testPath.after"), myFixture.file.text) if (log != null) { @@ -86,4 +90,6 @@ abstract class AbstractImportsTest : KotlinLightCodeInsightFixtureTestCase() { protected open val nameCountToUseStarImportForMembersDefault: Int get() = 3 + + protected open val runTestInWriteCommand: Boolean = true } \ No newline at end of file From 68b5f2736e9bbc988c65b638ba37e03193f607e0 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Wed, 26 Aug 2020 16:51:48 +0300 Subject: [PATCH 032/368] FIR: Add fake root prefix for IDE resolution --- .../jetbrains/kotlin/fir/FirQualifiedNameResolver.kt | 12 ++++++++++++ .../providers/impl/FirQualifierResolverImpl.kt | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt index ee99dc3c589..879929932a0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt @@ -20,6 +20,8 @@ import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name +const val ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE = "_root_ide_package_" + class FirQualifiedNameResolver(private val components: BodyResolveComponents) { private val session = components.session private var qualifierStack = mutableListOf() @@ -66,6 +68,11 @@ class FirQualifiedNameResolver(private val components: BodyResolveComponents) { } val symbolProvider = session.symbolProvider var qualifierParts = qualifierStack.asReversed().map { it.name.asString() } + + val fakeRootIdePrefixIsPresent = qualifierParts.firstOrNull() == ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE + if (fakeRootIdePrefixIsPresent) { + qualifierParts = qualifierParts.drop(1) + } var resolved: PackageOrClass? do { resolved = resolveToPackageOrClass( @@ -78,6 +85,11 @@ class FirQualifiedNameResolver(private val components: BodyResolveComponents) { if (resolved != null) { qualifierPartsToDrop = qualifierParts.size - 1 + // we would need to drop fake package too + if (fakeRootIdePrefixIsPresent) { + qualifierPartsToDrop += 1 + } + return buildResolvedQualifier { this.source = source packageFqName = resolved.packageFqName diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirQualifierResolverImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirQualifierResolverImpl.kt index 747080b6ad7..71dd06d09b7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirQualifierResolverImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirQualifierResolverImpl.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.providers.impl import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.NoMutableState +import org.jetbrains.kotlin.fir.ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE import org.jetbrains.kotlin.fir.resolve.FirQualifierResolver import org.jetbrains.kotlin.fir.resolve.symbolProvider import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol @@ -29,6 +30,10 @@ class FirQualifierResolverImpl(val session: FirSession) : FirQualifierResolver() } override fun resolveSymbol(parts: List): FirClassifierSymbol<*>? { + if (parts.firstOrNull()?.name?.asString() == ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE) { + return resolveSymbol(parts.drop(1)) + } + val firProvider = session.symbolProvider if (parts.isNotEmpty()) { From 1479388bd59b164cfe58c32c63a1caea8b1c0a81 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Fri, 30 Oct 2020 17:14:39 +0300 Subject: [PATCH 033/368] FIR IDE: Refactor `AbstractFirShortenRefsTest` - Use `FIR_COMPARISON` directive - Move testing utils to `ideaFirTestUtils.kt` - Ignore `TopLevelFunctionImportWithLotsOfFqName.kt` test for now (it takes too long to execute) --- .../tests/org/jetbrains/kotlin/idea/ideaFirTestUtils.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/ideaFirTestUtils.kt b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/ideaFirTestUtils.kt index ec6e348fcd6..53ca25dcc2f 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/ideaFirTestUtils.kt +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/ideaFirTestUtils.kt @@ -17,6 +17,8 @@ import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSessionProvider import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.trackers.KotlinOutOfBlockModificationTrackerFactory +import org.jetbrains.kotlin.test.InTextDirectivesUtils +import java.io.File fun Throwable.shouldBeRethrown(): Boolean = when (this) { is DuplicatedFirSourceElementsException -> true From 108395fcfee0fc17e9f7cc16c2abccbc90d3c93c Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 1 Dec 2020 22:03:38 +0300 Subject: [PATCH 034/368] FIR: Fix bug with incorrect source element for qualifiers --- compiler/fir/resolve/build.gradle.kts | 3 ++- .../jetbrains/kotlin/fir/FirQualifiedNameResolver.kt | 10 +++++++++- .../idea/resolve/FirReferenceResolveTestGenerated.java | 5 +++++ .../idea/references/FirReferenceResolveHelper.kt | 2 ++ .../resolve/references/ExternalCompanionObject.Data.kt | 5 +++++ .../resolve/references/ExternalCompanionObject.kt | 5 +++++ .../idea/resolve/ReferenceResolveTestGenerated.java | 5 +++++ 7 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 idea/testData/resolve/references/ExternalCompanionObject.Data.kt create mode 100644 idea/testData/resolve/references/ExternalCompanionObject.kt diff --git a/compiler/fir/resolve/build.gradle.kts b/compiler/fir/resolve/build.gradle.kts index 16a0cb9f451..7c4bf38f27a 100644 --- a/compiler/fir/resolve/build.gradle.kts +++ b/compiler/fir/resolve/build.gradle.kts @@ -14,9 +14,10 @@ dependencies { api(project(":compiler:fir:tree")) api(kotlinxCollectionsImmutable()) implementation(project(":core:util.runtime")) + implementation(project(":compiler:psi")) compileOnly(project(":kotlin-reflect-api")) - compileOnly(intellijCoreDep()) { includeJars("guava", rootProject = rootProject) } + compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) } } sourceSets { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt index 879929932a0..9c9c0f7e46b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.resolve.typeForQualifier import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf const val ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE = "_root_ide_package_" @@ -91,7 +92,7 @@ class FirQualifiedNameResolver(private val components: BodyResolveComponents) { } return buildResolvedQualifier { - this.source = source + this.source = getWholeQualifierSource(source, qualifierPartsToDrop) packageFqName = resolved.packageFqName relativeClassFqName = resolved.relativeClassFqName symbol = resolved.classSymbol @@ -104,4 +105,11 @@ class FirQualifiedNameResolver(private val components: BodyResolveComponents) { return null } + private fun getWholeQualifierSource(qualifierStartSource: FirSourceElement?, stepsToWholeQualifier: Int): FirSourceElement? { + if (qualifierStartSource !is FirRealPsiSourceElement<*>) return qualifierStartSource + + val qualifierStart = qualifierStartSource.psi + val wholeQualifier = qualifierStart.parentsWithSelf.drop(stepsToWholeQualifier).first() + return wholeQualifier.toFirPsiSourceElement() + } } diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/resolve/FirReferenceResolveTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/resolve/FirReferenceResolveTestGenerated.java index 7cfd514a251..9b5670d96b6 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/resolve/FirReferenceResolveTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/resolve/FirReferenceResolveTestGenerated.java @@ -144,6 +144,11 @@ public class FirReferenceResolveTestGenerated extends AbstractFirReferenceResolv runTest("idea/testData/resolve/references/EnumValues.kt"); } + @TestMetadata("ExternalCompanionObject.kt") + public void testExternalCompanionObject() throws Exception { + runTest("idea/testData/resolve/references/ExternalCompanionObject.kt"); + } + @TestMetadata("FakeJavaLang1.kt") public void testFakeJavaLang1() throws Exception { runTest("idea/testData/resolve/references/FakeJavaLang1.kt"); diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt index 83693dea8f7..1887b75d494 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.references import com.intellij.psi.tree.TokenSet import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty import org.jetbrains.kotlin.fir.expressions.* @@ -121,6 +122,7 @@ internal object FirReferenceResolveHelper { else -> { qualified .collectDescendantsOfType() + .dropWhile { it.getReferencedName() == ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE } .joinToString(separator = ".") { it.getReferencedName() } .let(::FqName) } diff --git a/idea/testData/resolve/references/ExternalCompanionObject.Data.kt b/idea/testData/resolve/references/ExternalCompanionObject.Data.kt new file mode 100644 index 00000000000..fea28614468 --- /dev/null +++ b/idea/testData/resolve/references/ExternalCompanionObject.Data.kt @@ -0,0 +1,5 @@ +package dependency + +class C { + companion object +} \ No newline at end of file diff --git a/idea/testData/resolve/references/ExternalCompanionObject.kt b/idea/testData/resolve/references/ExternalCompanionObject.kt new file mode 100644 index 00000000000..c7740b22449 --- /dev/null +++ b/idea/testData/resolve/references/ExternalCompanionObject.kt @@ -0,0 +1,5 @@ +fun usage() { + dependency.C.Companion +} + +// REF: companion object of (dependency).C diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java index b5fcd41ad55..22c4ccf8944 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java @@ -144,6 +144,11 @@ public class ReferenceResolveTestGenerated extends AbstractReferenceResolveTest runTest("idea/testData/resolve/references/EnumValues.kt"); } + @TestMetadata("ExternalCompanionObject.kt") + public void testExternalCompanionObject() throws Exception { + runTest("idea/testData/resolve/references/ExternalCompanionObject.kt"); + } + @TestMetadata("FakeJavaLang1.kt") public void testFakeJavaLang1() throws Exception { runTest("idea/testData/resolve/references/FakeJavaLang1.kt"); From c1130f20106a0684f84973b3af8ee4494801b7f1 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Mon, 21 Dec 2020 15:22:12 +0300 Subject: [PATCH 035/368] FIR IDE: Add reference shortening service which works over FIR --- .../idea/frontend/api/KtAnalysisSession.kt | 3 + .../api/components/KtReferenceShortener.kt | 31 +++++++ .../frontend/api/fir/KtFirAnalysisSession.kt | 1 + .../fir/components/KtFirReferenceShortener.kt | 93 +++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt create mode 100644 idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt index a35b6d012d7..a7a001ef9b3 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt @@ -45,6 +45,7 @@ abstract class KtAnalysisSession(final override val token: ValidityToken) : Vali protected abstract val callResolver: KtCallResolver protected abstract val completionCandidateChecker: KtCompletionCandidateChecker protected abstract val symbolDeclarationOverridesProvider: KtSymbolDeclarationOverridesProvider + protected abstract val referenceShortener: KtReferenceShortener @Suppress("LeakingThis") @@ -177,4 +178,6 @@ abstract class KtAnalysisSession(final override val token: ValidityToken) : Vali fun KtReturnExpression.getReturnTargetSymbol(): KtCallableSymbol? = expressionHandlingComponent.getReturnExpressionTargetSymbol(this) + + fun collectPossibleReferenceShortenings(file: KtFile, from: Int, to: Int) = referenceShortener.collectShortenings(file, from, to) } diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt new file mode 100644 index 00000000000..2d6bea635e3 --- /dev/null +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2020 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.idea.frontend.api.components + +import com.intellij.openapi.application.ApplicationManager +import com.intellij.psi.SmartPsiElementPointer +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.KtUserType + +abstract class KtReferenceShortener : KtAnalysisSessionComponent() { + abstract fun collectShortenings(file: KtFile, from: Int, to: Int): ShortenCommand +} + +class ShortenCommand( + val targetFile: KtFile, + val importsToAdd: List, + val typesToShorten: List> +) { + fun invokeShortening() { + ApplicationManager.getApplication().assertWriteAccessAllowed() + + for (typePointer in typesToShorten) { + val type = typePointer.element ?: continue + type.deleteQualifier() + } + } +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtFirAnalysisSession.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtFirAnalysisSession.kt index 1a67d4f3829..4a9a1f25955 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtFirAnalysisSession.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtFirAnalysisSession.kt @@ -49,6 +49,7 @@ private constructor( override val completionCandidateChecker: KtCompletionCandidateChecker = KtFirCompletionCandidateChecker(this, token) override val symbolDeclarationOverridesProvider: KtSymbolDeclarationOverridesProvider = KtFirSymbolDeclarationOverridesProvider(this, token) + override val referenceShortener: KtReferenceShortener = KtFirReferenceShortener(this, token, firResolveState) override val expressionHandlingComponent: KtExpressionHandlingComponent = KtFirExpressionHandlingComponent(this, token) override val typeProvider: KtTypeProvider = KtFirTypeProvider(this, token) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt new file mode 100644 index 00000000000..e1911c44f7c --- /dev/null +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -0,0 +1,93 @@ +/* + * Copyright 2010-2020 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.idea.frontend.api.fir.components + +import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.declarations.FirFile +import org.jetbrains.kotlin.fir.psi +import org.jetbrains.kotlin.fir.scopes.FirScope +import org.jetbrains.kotlin.fir.scopes.processClassifiersByName +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag +import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol +import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.classId +import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid +import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirModuleResolveState +import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFir +import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFirOfType +import org.jetbrains.kotlin.idea.frontend.api.ValidityToken +import org.jetbrains.kotlin.idea.frontend.api.components.KtReferenceShortener +import org.jetbrains.kotlin.idea.frontend.api.components.ShortenCommand +import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.KtTypeReference +import org.jetbrains.kotlin.psi.KtUserType +import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer + +internal class KtFirReferenceShortener( + override val analysisSession: KtFirAnalysisSession, + override val token: ValidityToken, + override val firResolveState: FirModuleResolveState, +) : KtReferenceShortener(), KtFirAnalysisSessionComponent { + override fun collectShortenings(file: KtFile, from: Int, to: Int): ShortenCommand { + resolveFileToBodyResolve(file) + val firFile = file.getOrBuildFirOfType(firResolveState) + + val typesToShorten = mutableListOf() + + firFile.acceptChildren(object : FirVisitorVoid() { + override fun visitElement(element: FirElement) { + element.acceptChildren(this) + } + + override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) { + val targetTypeReference = resolvedTypeRef.psi as? KtTypeReference ?: return + val targetType = targetTypeReference.typeElement as? KtUserType ?: return + + if (targetType.qualifier == null) return + + val targetClassId = resolvedTypeRef.type.classId + val targetClassName = targetClassId?.shortClassName ?: return + + val positionScopes = findScopesAtPosition(targetTypeReference) ?: return + + val firstFoundClass = positionScopes.asSequence() + .mapNotNull { scope -> scope.findFirstClassifierByName(targetClassName) } + .mapNotNull { classifierSymbol -> classifierSymbol.toLookupTag() as? ConeClassLikeLookupTag } + .map { it.classId } + .firstOrNull() + + if (firstFoundClass == null) { + // this class should be imported + } + + if (firstFoundClass == targetClassId) { + typesToShorten.add(targetType) + } + } + }) + + return ShortenCommand(file, emptyList(), typesToShorten.map { it.createSmartPointer() }) + } + + private fun resolveFileToBodyResolve(file: KtFile) { + for (declaration in file.declarations) { + declaration.getOrBuildFir(firResolveState) // temporary hack, resolves declaration to BODY_RESOLVE stage + } + } + + @OptIn(ExperimentalStdlibApi::class) + private fun FirScope.findFirstClassifierByName(name: Name): FirClassifierSymbol<*>? = + buildList { processClassifiersByName(name, this::add) }.firstOrNull() + + private fun findScopesAtPosition(targetTypeReference: KtTypeReference): List? { + val towerDataContext = firResolveState.getTowerDataContextForElement(targetTypeReference) ?: return null + val availableScopes = towerDataContext.towerDataElements.mapNotNull { it.scope } + + return availableScopes.asReversed() + } +} \ No newline at end of file From b9d074051fa75be7e9c64a8505888c726b6c0c0f Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Mon, 21 Dec 2020 15:23:05 +0300 Subject: [PATCH 036/368] FIR IDE: Add separate tests for FIR reference shortening --- .../kotlin/generators/tests/GenerateTests.kt | 5 ++ .../shortenRefs/AbstractFirShortenRefsTest.kt | 53 +++++++++++++++++++ .../FirShortenRefsTestGenerated.java | 49 +++++++++++++++++ .../shortenRefsFir/types/ParameterType.kt | 6 +++ .../types/ParameterType.kt.after | 6 +++ 5 files changed, 119 insertions(+) create mode 100644 idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt create mode 100644 idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java create mode 100644 idea/testData/shortenRefsFir/types/ParameterType.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterType.kt.after diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index a258ba4f77e..4739fc48607 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -180,6 +180,7 @@ import org.jetbrains.kotlin.samWithReceiver.AbstractSamWithReceiverScriptTest import org.jetbrains.kotlin.samWithReceiver.AbstractSamWithReceiverTest import org.jetbrains.kotlin.search.AbstractAnnotatedMembersSearchTest import org.jetbrains.kotlin.search.AbstractInheritorsSearchTest +import org.jetbrains.kotlin.shortenRefs.AbstractFirShortenRefsTest import org.jetbrains.kotlin.shortenRefs.AbstractShortenRefsTest import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.tools.projectWizard.cli.AbstractProjectTemplateBuildFileGenerationTest @@ -1117,6 +1118,10 @@ fun main(args: Array) { val pattern = "^([\\w\\-_]+)\\.(kt|kts)$" model("intentions/specifyTypeExplicitly", pattern = pattern) } + + testClass { + model("shortenRefsFir", pattern = KT_WITHOUT_DOTS_IN_NAME, testMethod = "doTestWithMuting") + } } testGroup("idea/idea-fir/tests", "idea/idea-completion/testData") { diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt new file mode 100644 index 00000000000..ba9665c218a --- /dev/null +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2020 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.shortenRefs + +import com.intellij.openapi.application.ApplicationManager +import org.jetbrains.kotlin.AbstractImportsTest +import org.jetbrains.kotlin.idea.frontend.api.analyze +import org.jetbrains.kotlin.idea.util.application.executeWriteCommand +import org.jetbrains.kotlin.idea.util.application.runReadAction +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.test.uitls.IgnoreTests + +abstract class AbstractFirShortenRefsTest : AbstractImportsTest() { + override val captureExceptions: Boolean = false + + override fun doTest(file: KtFile): String? { + val selectionModel = myFixture.editor.selectionModel + if (!selectionModel.hasSelection()) error("No selection in input file") + + val (startOffset, endOffset) = runReadAction { selectionModel.selectionStart to selectionModel.selectionEnd } + + val shortenings = executeOnPooledThread { + runReadAction { + analyze(file) { + collectPossibleReferenceShortenings(file, startOffset, endOffset) + } + } + } + + project.executeWriteCommand("") { + shortenings.invokeShortening() + } + + selectionModel.removeSelection() + return null + } + + override val runTestInWriteCommand: Boolean = false + + protected fun doTestWithMuting(unused: String) { + IgnoreTests.runTestIfEnabledByFileDirective(testDataFile().toPath(), IgnoreTests.DIRECTIVES.FIR_COMPARISON, ".after") { + doTest(unused) + } + } + + override val nameCountToUseStarImportDefault: Int + get() = Integer.MAX_VALUE +} + +private fun executeOnPooledThread(action: () -> R): R = + ApplicationManager.getApplication().executeOnPooledThread { action() }.get() diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java new file mode 100644 index 00000000000..b075dfbe794 --- /dev/null +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -0,0 +1,49 @@ +/* + * Copyright 2010-2020 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.shortenRefs; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/shortenRefsFir") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestWithMuting, this, testDataFilePath); + } + + public void testAllFilesPresentInShortenRefsFir() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/shortenRefsFir"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("idea/testData/shortenRefsFir/types") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Types extends AbstractFirShortenRefsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestWithMuting, this, testDataFilePath); + } + + public void testAllFilesPresentInTypes() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/shortenRefsFir/types"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("ParameterType.kt") + public void testParameterType() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterType.kt"); + } + } +} diff --git a/idea/testData/shortenRefsFir/types/ParameterType.kt b/idea/testData/shortenRefsFir/types/ParameterType.kt new file mode 100644 index 00000000000..73512a538fa --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterType.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +class T + +fun foo(t: test.T) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterType.kt.after b/idea/testData/shortenRefsFir/types/ParameterType.kt.after new file mode 100644 index 00000000000..9a84264e1b8 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterType.kt.after @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +class T + +fun foo(t: T) {} From e744084c15b203f83c23cc1d4b4ad3373c458ee5 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Mon, 21 Dec 2020 18:08:21 +0300 Subject: [PATCH 037/368] FIR IDE: Enable types shortening for nested classes and nested types --- .../FirShortenRefsTestGenerated.java | 15 +++++ .../fir/components/KtFirReferenceShortener.kt | 57 +++++++++++++------ .../types/ParameterTypeFunctionalType.kt | 8 +++ .../ParameterTypeFunctionalType.kt.after | 8 +++ .../types/ParameterTypeGenericTypes.kt | 10 ++++ .../types/ParameterTypeGenericTypes.kt.after | 10 ++++ .../types/ParameterTypeNestedType.kt | 8 +++ .../types/ParameterTypeNestedType.kt.after | 8 +++ 8 files changed, 106 insertions(+), 18 deletions(-) create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeFunctionalType.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeFunctionalType.kt.after create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt.after create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index b075dfbe794..d5faf9eeaa3 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -45,5 +45,20 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { public void testParameterType() throws Exception { runTest("idea/testData/shortenRefsFir/types/ParameterType.kt"); } + + @TestMetadata("ParameterTypeFunctionalType.kt") + public void testParameterTypeFunctionalType() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeFunctionalType.kt"); + } + + @TestMetadata("ParameterTypeGenericTypes.kt") + public void testParameterTypeGenericTypes() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt"); + } + + @TestMetadata("ParameterTypeNestedType.kt") + public void testParameterTypeNestedType() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt"); + } } } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index e1911c44f7c..54da7a7b099 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.idea.frontend.api.ValidityToken import org.jetbrains.kotlin.idea.frontend.api.components.KtReferenceShortener import org.jetbrains.kotlin.idea.frontend.api.components.ShortenCommand import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession +import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtTypeReference @@ -45,28 +46,27 @@ internal class KtFirReferenceShortener( } override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) { - val targetTypeReference = resolvedTypeRef.psi as? KtTypeReference ?: return - val targetType = targetTypeReference.typeElement as? KtUserType ?: return + resolvedTypeRef.acceptChildren(this) - if (targetType.qualifier == null) return + val wholeTypeReference = resolvedTypeRef.psi as? KtTypeReference ?: return - val targetClassId = resolvedTypeRef.type.classId - val targetClassName = targetClassId?.shortClassName ?: return + val wholeTypeElement = wholeTypeReference.typeElement as? KtUserType ?: return + if (wholeTypeElement.qualifier == null) return - val positionScopes = findScopesAtPosition(targetTypeReference) ?: return + val wholeClassifierId = resolvedTypeRef.type.classId ?: return - val firstFoundClass = positionScopes.asSequence() - .mapNotNull { scope -> scope.findFirstClassifierByName(targetClassName) } - .mapNotNull { classifierSymbol -> classifierSymbol.toLookupTag() as? ConeClassLikeLookupTag } - .map { it.classId } - .firstOrNull() + val allClassIds = generateSequence(wholeClassifierId) { it.outerClassId } + val allTypeElements = generateSequence(wholeTypeElement) { it.qualifier } - if (firstFoundClass == null) { - // this class should be imported - } + val positionScopes = findScopesAtPosition(wholeTypeReference) ?: return - if (firstFoundClass == targetClassId) { - typesToShorten.add(targetType) + for ((classId, typeElement) in allClassIds.zip(allTypeElements)) { + val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName) + + if (firstFoundClass == classId) { + typesToShorten.add(typeElement) + break + } } } }) @@ -74,6 +74,18 @@ internal class KtFirReferenceShortener( return ShortenCommand(file, emptyList(), typesToShorten.map { it.createSmartPointer() }) } + private fun findFirstClassifierInScopesByName(positionScopes: List, targetClassName: Name): ClassId? { + for (scope in positionScopes) { + val classifierSymbol = scope.findFirstClassifierByName(targetClassName) ?: continue + val classifierLookupTag = classifierSymbol.toLookupTag() as? ConeClassLikeLookupTag ?: continue + + return classifierLookupTag.classId + } + + return null + } + + private fun resolveFileToBodyResolve(file: KtFile) { for (declaration in file.declarations) { declaration.getOrBuildFir(firResolveState) // temporary hack, resolves declaration to BODY_RESOLVE stage @@ -81,8 +93,17 @@ internal class KtFirReferenceShortener( } @OptIn(ExperimentalStdlibApi::class) - private fun FirScope.findFirstClassifierByName(name: Name): FirClassifierSymbol<*>? = - buildList { processClassifiersByName(name, this::add) }.firstOrNull() + private fun FirScope.findFirstClassifierByName(name: Name): FirClassifierSymbol<*>? { + var element: FirClassifierSymbol<*>? = null + + processClassifiersByName(name) { + if (element == null) { + element = it + } + } + + return element + } private fun findScopesAtPosition(targetTypeReference: KtTypeReference): List? { val towerDataContext = firResolveState.getTowerDataContextForElement(targetTypeReference) ?: return null diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeFunctionalType.kt b/idea/testData/shortenRefsFir/types/ParameterTypeFunctionalType.kt new file mode 100644 index 00000000000..28290a4d598 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeFunctionalType.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class T { + class TT +} + +fun foo(t: (test.T) -> test.T.TT) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeFunctionalType.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeFunctionalType.kt.after new file mode 100644 index 00000000000..58b796e34a4 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeFunctionalType.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class T { + class TT +} + +fun foo(t: (T) -> T.TT) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt b/idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt new file mode 100644 index 00000000000..ba8aced3d04 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +class T { + class TT +} + +class Generic + +fun foo(t: test.Generic) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt.after new file mode 100644 index 00000000000..16e0cd61bec --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt.after @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +class T { + class TT +} + +class Generic + +fun foo(t: Generic) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt b/idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt new file mode 100644 index 00000000000..ab3f2f7a321 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class T { + class TT +} + +fun foo(t: test.T.TT) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt.after new file mode 100644 index 00000000000..55547c490bc --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class T { + class TT +} + +fun foo(t: T.TT) {} From 8575ce32d4d9b114f27830f7945849d07c8c218d Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Mon, 21 Dec 2020 18:45:58 +0300 Subject: [PATCH 038/368] FIR IDE: Add more tests for type conflicts --- .../FirShortenRefsTestGenerated.java | 30 +++++++++++++++++++ ...arameterTypeImportedTypeWins.dependency.kt | 3 ++ .../types/ParameterTypeImportedTypeWins.kt | 8 +++++ .../ParameterTypeImportedTypeWins.kt.after | 8 +++++ ...terTypeStarImportedTypeLoses.dependency.kt | 3 ++ .../ParameterTypeStarImportedTypeLoses.kt | 8 +++++ ...arameterTypeStarImportedTypeLoses.kt.after | 8 +++++ ...rameterTypeTopLevelTypeLoses.dependency.kt | 3 ++ .../types/ParameterTypeTopLevelTypeLoses.kt | 8 +++++ .../ParameterTypeTopLevelTypeLoses.kt.after | 8 +++++ ...arameterTypeTopLevelTypeWins.dependency.kt | 3 ++ .../types/ParameterTypeTopLevelTypeWins.kt | 8 +++++ .../ParameterTypeTopLevelTypeWins.kt.after | 8 +++++ .../shortenRefsFir/types/VariableType.kt | 8 +++++ .../types/VariableType.kt.after | 8 +++++ .../VariableTypeConflictWithLocalType.kt | 10 +++++++ ...VariableTypeConflictWithLocalType.kt.after | 10 +++++++ 17 files changed, 142 insertions(+) create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.dependency.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.kt.after create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.dependency.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt.after create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.dependency.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.kt.after create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.dependency.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.kt.after create mode 100644 idea/testData/shortenRefsFir/types/VariableType.kt create mode 100644 idea/testData/shortenRefsFir/types/VariableType.kt.after create mode 100644 idea/testData/shortenRefsFir/types/VariableTypeConflictWithLocalType.kt create mode 100644 idea/testData/shortenRefsFir/types/VariableTypeConflictWithLocalType.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index d5faf9eeaa3..9d091b804e9 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -56,9 +56,39 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt"); } + @TestMetadata("ParameterTypeImportedTypeWins.kt") + public void testParameterTypeImportedTypeWins() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.kt"); + } + @TestMetadata("ParameterTypeNestedType.kt") public void testParameterTypeNestedType() throws Exception { runTest("idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt"); } + + @TestMetadata("ParameterTypeStarImportedTypeLoses.kt") + public void testParameterTypeStarImportedTypeLoses() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt"); + } + + @TestMetadata("ParameterTypeTopLevelTypeLoses.kt") + public void testParameterTypeTopLevelTypeLoses() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.kt"); + } + + @TestMetadata("ParameterTypeTopLevelTypeWins.kt") + public void testParameterTypeTopLevelTypeWins() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.kt"); + } + + @TestMetadata("VariableType.kt") + public void testVariableType() throws Exception { + runTest("idea/testData/shortenRefsFir/types/VariableType.kt"); + } + + @TestMetadata("VariableTypeConflictWithLocalType.kt") + public void testVariableTypeConflictWithLocalType() throws Exception { + runTest("idea/testData/shortenRefsFir/types/VariableTypeConflictWithLocalType.kt"); + } } } diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.dependency.kt b/idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.dependency.kt new file mode 100644 index 00000000000..fc6fb4fa1c8 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +class T \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.kt b/idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.kt new file mode 100644 index 00000000000..fef88d3c273 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.T + +class T + +fun foo(t: dependency.T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.kt.after new file mode 100644 index 00000000000..cc3c98b90a6 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.T + +class T + +fun foo(t: T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.dependency.kt b/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.dependency.kt new file mode 100644 index 00000000000..fc6fb4fa1c8 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +class T \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt b/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt new file mode 100644 index 00000000000..9ce3da4005b --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.* + +class T + +fun foo(t: dependency.T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt.after new file mode 100644 index 00000000000..bcab9592b0e --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.* + +class T + +fun foo(t: dependency.T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.dependency.kt b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.dependency.kt new file mode 100644 index 00000000000..fc6fb4fa1c8 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +class T \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.kt b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.kt new file mode 100644 index 00000000000..7191b444a4e --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.T + +class T + +fun foo(t: test.T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.kt.after new file mode 100644 index 00000000000..95f47a3ea80 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeLoses.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.T + +class T + +fun foo(t: test.T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.dependency.kt b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.dependency.kt new file mode 100644 index 00000000000..fc6fb4fa1c8 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +class T \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.kt b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.kt new file mode 100644 index 00000000000..afadcdce90a --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.* + +class T + +fun foo(t: test.T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.kt.after new file mode 100644 index 00000000000..77a9b2d7cb1 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.* + +class T + +fun foo(t: T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/VariableType.kt b/idea/testData/shortenRefsFir/types/VariableType.kt new file mode 100644 index 00000000000..7033b0dce7e --- /dev/null +++ b/idea/testData/shortenRefsFir/types/VariableType.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class T + +fun foo() { + var t: test.T +} diff --git a/idea/testData/shortenRefsFir/types/VariableType.kt.after b/idea/testData/shortenRefsFir/types/VariableType.kt.after new file mode 100644 index 00000000000..30597c424b5 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/VariableType.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class T + +fun foo() { + var t: T +} diff --git a/idea/testData/shortenRefsFir/types/VariableTypeConflictWithLocalType.kt b/idea/testData/shortenRefsFir/types/VariableTypeConflictWithLocalType.kt new file mode 100644 index 00000000000..ee40900144f --- /dev/null +++ b/idea/testData/shortenRefsFir/types/VariableTypeConflictWithLocalType.kt @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +class T + +fun foo() { + class T + + var t: test.T +} diff --git a/idea/testData/shortenRefsFir/types/VariableTypeConflictWithLocalType.kt.after b/idea/testData/shortenRefsFir/types/VariableTypeConflictWithLocalType.kt.after new file mode 100644 index 00000000000..38832f8df51 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/VariableTypeConflictWithLocalType.kt.after @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +class T + +fun foo() { + class T + + var t: test.T +} From 0609aa1e2e05f050aaaed5cb48924b90a6fcc78a Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Mon, 21 Dec 2020 20:00:09 +0300 Subject: [PATCH 039/368] FIR IDE: Refactor `KtFirReferenceShortener` --- .../fir/components/KtFirReferenceShortener.kt | 75 +++++++++++-------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 54da7a7b099..6fa60c8d2a1 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.idea.frontend.api.components.ShortenCommand import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtTypeReference import org.jetbrains.kotlin.psi.KtUserType @@ -39,37 +40,7 @@ internal class KtFirReferenceShortener( val firFile = file.getOrBuildFirOfType(firResolveState) val typesToShorten = mutableListOf() - - firFile.acceptChildren(object : FirVisitorVoid() { - override fun visitElement(element: FirElement) { - element.acceptChildren(this) - } - - override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) { - resolvedTypeRef.acceptChildren(this) - - val wholeTypeReference = resolvedTypeRef.psi as? KtTypeReference ?: return - - val wholeTypeElement = wholeTypeReference.typeElement as? KtUserType ?: return - if (wholeTypeElement.qualifier == null) return - - val wholeClassifierId = resolvedTypeRef.type.classId ?: return - - val allClassIds = generateSequence(wholeClassifierId) { it.outerClassId } - val allTypeElements = generateSequence(wholeTypeElement) { it.qualifier } - - val positionScopes = findScopesAtPosition(wholeTypeReference) ?: return - - for ((classId, typeElement) in allClassIds.zip(allTypeElements)) { - val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName) - - if (firstFoundClass == classId) { - typesToShorten.add(typeElement) - break - } - } - } - }) + firFile.acceptChildren(TypesCollectingVisitor(typesToShorten)) return ShortenCommand(file, emptyList(), typesToShorten.map { it.createSmartPointer() }) } @@ -105,10 +76,50 @@ internal class KtFirReferenceShortener( return element } - private fun findScopesAtPosition(targetTypeReference: KtTypeReference): List? { + private fun findScopesAtPosition(targetTypeReference: KtElement): List? { val towerDataContext = firResolveState.getTowerDataContextForElement(targetTypeReference) ?: return null val availableScopes = towerDataContext.towerDataElements.mapNotNull { it.scope } return availableScopes.asReversed() } + + private inner class TypesCollectingVisitor(private val collectedTypes: MutableList) : FirVisitorVoid() { + override fun visitElement(element: FirElement) { + element.acceptChildren(this) + } + + override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) { + processTypeRef(resolvedTypeRef) + + resolvedTypeRef.acceptChildren(this) + resolvedTypeRef.delegatedTypeRef?.accept(this) + } + + private fun processTypeRef(resolvedTypeRef: FirResolvedTypeRef) { + val wholeTypeReference = resolvedTypeRef.psi as? KtTypeReference ?: return + + val wholeClassifierId = resolvedTypeRef.type.classId ?: return + val wholeTypeElement = wholeTypeReference.typeElement as? KtUserType ?: return + + if (wholeTypeElement.qualifier == null) return + + val typeToShorten = findBiggestClassifierToShorten(wholeClassifierId, wholeTypeElement) ?: return + collectedTypes.add(typeToShorten) + } + + private fun findBiggestClassifierToShorten(wholeClassifierId: ClassId, wholeTypeElement: KtUserType): KtUserType? { + val allClassIds = generateSequence(wholeClassifierId) { it.outerClassId } + val allTypeElements = generateSequence(wholeTypeElement) { it.qualifier } + + val positionScopes = findScopesAtPosition(wholeTypeElement) ?: return null + + for ((classId, typeElement) in allClassIds.zip(allTypeElements)) { + val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName) + + if (firstFoundClass == classId) return typeElement + } + + return null + } + } } \ No newline at end of file From e34370554d2df167dc4b9790bfbccd764f9ec7cb Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 22 Dec 2020 15:34:21 +0300 Subject: [PATCH 040/368] FIR IDE: Add simple types importing Some tests are not passing --- .../FirShortenRefsTestGenerated.java | 20 +++++ .../api/components/KtReferenceShortener.kt | 19 +---- .../fir/components/KtFirReferenceShortener.kt | 78 +++++++++++++++---- .../api/fir/utils/shortenReferencesUtils.kt | 57 ++++++++++++++ ...flictingTopLevelClassNotUsed.dependency.kt | 3 + ...eterTypeConflictingTopLevelClassNotUsed.kt | 6 ++ ...peConflictingTopLevelClassNotUsed.kt.after | 8 ++ ...ConflictingTopLevelClassUsed.dependency.kt | 3 + ...rameterTypeConflictingTopLevelClassUsed.kt | 8 ++ ...rTypeConflictingTopLevelClassUsed.kt.after | 8 ++ ...arameterTypeNonImportedClass.dependency.kt | 3 + .../types/ParameterTypeNonImportedClass.kt | 4 + .../ParameterTypeNonImportedClass.kt.after | 6 ++ ...oNonImportedClassesConflict.dependency1.kt | 3 + ...oNonImportedClassesConflict.dependency2.kt | 3 + ...ameterTypeTwoNonImportedClassesConflict.kt | 4 + ...TypeTwoNonImportedClassesConflict.kt.after | 6 ++ 17 files changed, 205 insertions(+), 34 deletions(-) create mode 100644 idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/utils/shortenReferencesUtils.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.dependency.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.kt.after create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.dependency.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt.after create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.dependency.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt.after create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.dependency1.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.dependency2.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index 9d091b804e9..8c886c9a6bd 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -46,6 +46,16 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/types/ParameterType.kt"); } + @TestMetadata("ParameterTypeConflictingTopLevelClassNotUsed.kt") + public void testParameterTypeConflictingTopLevelClassNotUsed() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.kt"); + } + + @TestMetadata("ParameterTypeConflictingTopLevelClassUsed.kt") + public void testParameterTypeConflictingTopLevelClassUsed() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt"); + } + @TestMetadata("ParameterTypeFunctionalType.kt") public void testParameterTypeFunctionalType() throws Exception { runTest("idea/testData/shortenRefsFir/types/ParameterTypeFunctionalType.kt"); @@ -66,6 +76,11 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt"); } + @TestMetadata("ParameterTypeNonImportedClass.kt") + public void testParameterTypeNonImportedClass() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt"); + } + @TestMetadata("ParameterTypeStarImportedTypeLoses.kt") public void testParameterTypeStarImportedTypeLoses() throws Exception { runTest("idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt"); @@ -81,6 +96,11 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/types/ParameterTypeTopLevelTypeWins.kt"); } + @TestMetadata("ParameterTypeTwoNonImportedClassesConflict.kt") + public void testParameterTypeTwoNonImportedClassesConflict() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.kt"); + } + @TestMetadata("VariableType.kt") public void testVariableType() throws Exception { runTest("idea/testData/shortenRefsFir/types/VariableType.kt"); diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt index 2d6bea635e3..7e5ac143ef2 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt @@ -5,27 +5,12 @@ package org.jetbrains.kotlin.idea.frontend.api.components -import com.intellij.openapi.application.ApplicationManager -import com.intellij.psi.SmartPsiElementPointer -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.psi.KtUserType abstract class KtReferenceShortener : KtAnalysisSessionComponent() { abstract fun collectShortenings(file: KtFile, from: Int, to: Int): ShortenCommand } -class ShortenCommand( - val targetFile: KtFile, - val importsToAdd: List, - val typesToShorten: List> -) { - fun invokeShortening() { - ApplicationManager.getApplication().assertWriteAccessAllowed() - - for (typePointer in typesToShorten) { - val type = typePointer.element ?: continue - type.deleteQualifier() - } - } +interface ShortenCommand { + fun invokeShortening() } \ No newline at end of file diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 6fa60c8d2a1..4c7b0fd8c55 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -5,6 +5,9 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.project.Project +import com.intellij.psi.SmartPsiElementPointer import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.psi @@ -19,15 +22,14 @@ import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirModuleResolveState import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFir import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFirOfType import org.jetbrains.kotlin.idea.frontend.api.ValidityToken -import org.jetbrains.kotlin.idea.frontend.api.components.KtReferenceShortener import org.jetbrains.kotlin.idea.frontend.api.components.ShortenCommand +import org.jetbrains.kotlin.idea.frontend.api.components.KtReferenceShortener import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession +import org.jetbrains.kotlin.idea.frontend.api.fir.utils.addImportToFile import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.psi.KtElement -import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.psi.KtTypeReference -import org.jetbrains.kotlin.psi.KtUserType +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer internal class KtFirReferenceShortener( @@ -39,10 +41,12 @@ internal class KtFirReferenceShortener( resolveFileToBodyResolve(file) val firFile = file.getOrBuildFirOfType(firResolveState) + val typesToImport = mutableListOf() val typesToShorten = mutableListOf() - firFile.acceptChildren(TypesCollectingVisitor(typesToShorten)) - return ShortenCommand(file, emptyList(), typesToShorten.map { it.createSmartPointer() }) + firFile.acceptChildren(TypesCollectingVisitor(typesToImport, typesToShorten)) + + return ShortenCommandImpl(file, typesToImport, typesToShorten.map { it.createSmartPointer() }) } private fun findFirstClassifierInScopesByName(positionScopes: List, targetClassName: Name): ClassId? { @@ -56,14 +60,12 @@ internal class KtFirReferenceShortener( return null } - private fun resolveFileToBodyResolve(file: KtFile) { for (declaration in file.declarations) { declaration.getOrBuildFir(firResolveState) // temporary hack, resolves declaration to BODY_RESOLVE stage } } - @OptIn(ExperimentalStdlibApi::class) private fun FirScope.findFirstClassifierByName(name: Name): FirClassifierSymbol<*>? { var element: FirClassifierSymbol<*>? = null @@ -83,7 +85,10 @@ internal class KtFirReferenceShortener( return availableScopes.asReversed() } - private inner class TypesCollectingVisitor(private val collectedTypes: MutableList) : FirVisitorVoid() { + private inner class TypesCollectingVisitor( + private val typesToImport: MutableList, + private val typesToShorten: MutableList, + ) : FirVisitorVoid() { override fun visitElement(element: FirElement) { element.acceptChildren(this) } @@ -103,23 +108,62 @@ internal class KtFirReferenceShortener( if (wholeTypeElement.qualifier == null) return - val typeToShorten = findBiggestClassifierToShorten(wholeClassifierId, wholeTypeElement) ?: return - collectedTypes.add(typeToShorten) + collectTypeIfNeedsToBeShortened(wholeClassifierId, wholeTypeElement) } - private fun findBiggestClassifierToShorten(wholeClassifierId: ClassId, wholeTypeElement: KtUserType): KtUserType? { + private fun collectTypeIfNeedsToBeShortened(wholeClassifierId: ClassId, wholeTypeElement: KtUserType) { val allClassIds = generateSequence(wholeClassifierId) { it.outerClassId } val allTypeElements = generateSequence(wholeTypeElement) { it.qualifier } - val positionScopes = findScopesAtPosition(wholeTypeElement) ?: return null + val positionScopes = findScopesAtPosition(wholeTypeElement) ?: return for ((classId, typeElement) in allClassIds.zip(allTypeElements)) { val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName) - if (firstFoundClass == classId) return typeElement + if (firstFoundClass == classId) { + addTypeToShorten(typeElement) + return + } } - return null + // none class matched + val (mostTopLevelClassId, mostTopLevelTypeElement) = allClassIds.zip(allTypeElements).last() + val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) + + check(firstFoundClass != mostTopLevelClassId) { "This should not be true" } + + if (firstFoundClass == null) { + addTypeToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelTypeElement) + } + } + + private fun addTypeToShorten(typeElement: KtUserType) { + typesToShorten.add(typeElement) + } + + private fun addTypeToImportAndShorten(classFqName: FqName, mostTopLevelTypeElement: KtUserType) { + typesToImport.add(classFqName) + typesToShorten.add(mostTopLevelTypeElement) } } -} \ No newline at end of file +} + +private class ShortenCommandImpl( + val targetFile: KtFile, + val importsToAdd: List, + val typesToShorten: List> +) : ShortenCommand { + + override fun invokeShortening() { + ApplicationManager.getApplication().assertWriteAccessAllowed() + + for (nameToImport in importsToAdd) { + addImportToFile(targetFile.project, targetFile, nameToImport) + } + + for (typePointer in typesToShorten) { + val type = typePointer.element ?: continue + type.deleteQualifier() + } + } +} diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/utils/shortenReferencesUtils.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/utils/shortenReferencesUtils.kt new file mode 100644 index 00000000000..00d6a8af987 --- /dev/null +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/utils/shortenReferencesUtils.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2010-2021 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.idea.frontend.api.fir.utils + +import com.intellij.openapi.project.Project +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.KtCodeFragment +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.KtImportDirective +import org.jetbrains.kotlin.psi.KtPsiFactory +import org.jetbrains.kotlin.resolve.ImportPath + +private val SimpleImportPathComparator: Comparator = compareBy(ImportPath::toString) + +/** + * This is a partial copy from `org.jetbrains.kotlin.idea.util.ImportInsertHelperImpl.Companion.addImport`. + * + * We want it as a copy because we do not yet care about imports ordering, so we do not need a fancy comparator. + */ +internal fun addImportToFile( + project: Project, + file: KtFile, + fqName: FqName, + allUnder: Boolean = false, + alias: Name? = null +) { + val importPath = ImportPath(fqName, allUnder, alias) + + val psiFactory = KtPsiFactory(project) + if (file is KtCodeFragment) { + val newDirective = psiFactory.createImportDirective(importPath) + file.addImportsFromString(newDirective.text) + } + + val importList = file.importList + ?: error("Trying to insert import $fqName into a file ${file.name} of type ${file::class.java} with no import list.") + + val newDirective = psiFactory.createImportDirective(importPath) + val imports = importList.imports + if (imports.isEmpty()) { //TODO: strange hack + importList.add(psiFactory.createNewLine()) + importList.add(newDirective) + } else { + val insertAfter = imports + .lastOrNull { + val directivePath = it.importPath + + directivePath != null && SimpleImportPathComparator.compare(directivePath, importPath) <= 0 + } + + importList.addAfter(newDirective, insertAfter) + } +} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.dependency.kt b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.dependency.kt new file mode 100644 index 00000000000..9bf4a365e82 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +class Foo \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.kt b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.kt new file mode 100644 index 00000000000..58e135b0680 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +class Foo + +fun foo(p: dependency.Foo) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.kt.after new file mode 100644 index 00000000000..5a4271c299e --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassNotUsed.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.Foo + +class Foo + +fun foo(p: Foo) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.dependency.kt b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.dependency.kt new file mode 100644 index 00000000000..9bf4a365e82 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +class Foo \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt new file mode 100644 index 00000000000..db9b1eae096 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class Foo + +fun foo(p: dependency.Foo) {} + +fun bar(): Foo {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt.after new file mode 100644 index 00000000000..f6a6fd9a23f --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class Foo + +fun foo(p: dependency.Foo) {} + +fun bar(): Foo {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.dependency.kt b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.dependency.kt new file mode 100644 index 00000000000..fc6fb4fa1c8 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +class T \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt new file mode 100644 index 00000000000..0eab57c0d30 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt @@ -0,0 +1,4 @@ +// FIR_COMPARISON +package test + +fun foo(p: dependency.T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt.after new file mode 100644 index 00000000000..524ec1c07a6 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt.after @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +import dependency.T + +fun foo(p: T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.dependency1.kt b/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.dependency1.kt new file mode 100644 index 00000000000..e868126b897 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.dependency1.kt @@ -0,0 +1,3 @@ +package dependency1 + +class T \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.dependency2.kt b/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.dependency2.kt new file mode 100644 index 00000000000..83d8674a6c4 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.dependency2.kt @@ -0,0 +1,3 @@ +package dependency2 + +class T \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.kt b/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.kt new file mode 100644 index 00000000000..74c6e672a01 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.kt @@ -0,0 +1,4 @@ +// FIR_COMPARISON +package test + +fun foo(p1: dependency1.T, p2: dependency2.T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.kt.after new file mode 100644 index 00000000000..2a37419d864 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeTwoNonImportedClassesConflict.kt.after @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +import dependency1.T + +fun foo(p1: T, p2: dependency2.T) {} \ No newline at end of file From 08e271411f064d0983ffac8c96d24bfaa0937e81 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 22 Dec 2020 16:30:37 +0300 Subject: [PATCH 041/368] FIR IDE: Create fake scopes to avoid import duplicates --- .../FirShortenRefsTestGenerated.java | 15 +++++++ .../fir/components/KtFirReferenceShortener.kt | 40 ++++++++++++++++--- ...meterTypeImportedNestedClass.dependency.kt | 5 +++ .../types/ParameterTypeImportedNestedClass.kt | 6 +++ .../ParameterTypeImportedNestedClass.kt.after | 6 +++ ...terTypeNonImportedClassTwice.dependency.kt | 3 ++ .../ParameterTypeNonImportedClassTwice.kt | 4 ++ ...arameterTypeNonImportedClassTwice.kt.after | 6 +++ ...erTypeNotImportedNestedClass.dependency.kt | 5 +++ .../ParameterTypeNotImportedNestedClass.kt | 4 ++ ...rameterTypeNotImportedNestedClass.kt.after | 6 +++ 11 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.dependency.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.kt.after create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.dependency.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.kt.after create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.dependency.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index 8c886c9a6bd..728f2a8a6ff 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -66,6 +66,11 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt"); } + @TestMetadata("ParameterTypeImportedNestedClass.kt") + public void testParameterTypeImportedNestedClass() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.kt"); + } + @TestMetadata("ParameterTypeImportedTypeWins.kt") public void testParameterTypeImportedTypeWins() throws Exception { runTest("idea/testData/shortenRefsFir/types/ParameterTypeImportedTypeWins.kt"); @@ -81,6 +86,16 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt"); } + @TestMetadata("ParameterTypeNonImportedClassTwice.kt") + public void testParameterTypeNonImportedClassTwice() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.kt"); + } + + @TestMetadata("ParameterTypeNotImportedNestedClass.kt") + public void testParameterTypeNotImportedNestedClass() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.kt"); + } + @TestMetadata("ParameterTypeStarImportedTypeLoses.kt") public void testParameterTypeStarImportedTypeLoses() throws Exception { runTest("idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt"); diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 4c7b0fd8c55..17b2cfb1597 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -8,10 +8,14 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.Project import com.intellij.psi.SmartPsiElementPointer +import com.intellij.util.containers.addIfNotNull import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.declarations.FirFile +import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.psi +import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.scopes.FirScope +import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope import org.jetbrains.kotlin.fir.scopes.processClassifiersByName import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol @@ -21,9 +25,10 @@ import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirModuleResolveState import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFir import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFirOfType +import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFirSafe import org.jetbrains.kotlin.idea.frontend.api.ValidityToken -import org.jetbrains.kotlin.idea.frontend.api.components.ShortenCommand import org.jetbrains.kotlin.idea.frontend.api.components.KtReferenceShortener +import org.jetbrains.kotlin.idea.frontend.api.components.ShortenCommand import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession import org.jetbrains.kotlin.idea.frontend.api.fir.utils.addImportToFile import org.jetbrains.kotlin.name.ClassId @@ -31,6 +36,8 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer +import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector +import org.jetbrains.kotlin.resolve.ImportPath internal class KtFirReferenceShortener( override val analysisSession: KtFirAnalysisSession, @@ -78,11 +85,34 @@ internal class KtFirReferenceShortener( return element } - private fun findScopesAtPosition(targetTypeReference: KtElement): List? { + @OptIn(ExperimentalStdlibApi::class) + private fun findScopesAtPosition(targetTypeReference: KtElement, newImports: List): List? { val towerDataContext = firResolveState.getTowerDataContextForElement(targetTypeReference) ?: return null - val availableScopes = towerDataContext.towerDataElements.mapNotNull { it.scope } - return availableScopes.asReversed() + val result = buildList { + addAll(towerDataContext.nonLocalTowerDataElements.mapNotNull { it.scope }) + addIfNotNull(createFakeImportingScope(targetTypeReference.project, newImports)) + addAll(towerDataContext.localScopes) + } + + return result.asReversed() + } + + private fun createFakeImportingScope( + project: Project, + newImports: List + ): FirScope? { + if (newImports.isEmpty()) return null + + val psiFactory = KtPsiFactory(project) + + val resolvedNewImports = newImports + .map { psiFactory.createImportDirective(ImportPath(it, isAllUnder = false)) } + .mapNotNull { it.getOrBuildFirSafe(firResolveState) } + + if (resolvedNewImports.isEmpty()) return null + + return FirExplicitSimpleImportingScope(resolvedNewImports, firResolveState.rootModuleSession, ScopeSession()) } private inner class TypesCollectingVisitor( @@ -115,7 +145,7 @@ internal class KtFirReferenceShortener( val allClassIds = generateSequence(wholeClassifierId) { it.outerClassId } val allTypeElements = generateSequence(wholeTypeElement) { it.qualifier } - val positionScopes = findScopesAtPosition(wholeTypeElement) ?: return + val positionScopes = findScopesAtPosition(wholeTypeElement, typesToImport) ?: return for ((classId, typeElement) in allClassIds.zip(allTypeElements)) { val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName) diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.dependency.kt b/idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.dependency.kt new file mode 100644 index 00000000000..007010a3e40 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.dependency.kt @@ -0,0 +1,5 @@ +package dependency + +class T { + class TT +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.kt b/idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.kt new file mode 100644 index 00000000000..4723b94ce8c --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +import dependency.T.TT + +fun foo(p: dependency.T.TT) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.kt.after new file mode 100644 index 00000000000..714ea835288 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.kt.after @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +import dependency.T.TT + +fun foo(p: TT) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.dependency.kt b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.dependency.kt new file mode 100644 index 00000000000..fc6fb4fa1c8 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +class T \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.kt b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.kt new file mode 100644 index 00000000000..419caf2a149 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.kt @@ -0,0 +1,4 @@ +// FIR_COMPARISON +package test + +fun foo(p1: dependency.T, p2: dependency.T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.kt.after new file mode 100644 index 00000000000..6fb531cf533 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClassTwice.kt.after @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +import dependency.T + +fun foo(p1: T, p2: T) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.dependency.kt b/idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.dependency.kt new file mode 100644 index 00000000000..007010a3e40 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.dependency.kt @@ -0,0 +1,5 @@ +package dependency + +class T { + class TT +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.kt b/idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.kt new file mode 100644 index 00000000000..95ab1eda96b --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.kt @@ -0,0 +1,4 @@ +// FIR_COMPARISON +package test + +fun foo(p: dependency.T.TT) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.kt.after new file mode 100644 index 00000000000..4326c5a9f00 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.kt.after @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +import dependency.T + +fun foo(p: T.TT) {} \ No newline at end of file From 0b48416a1eeaf5c2c95716e109b7495da36a506b Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Wed, 23 Dec 2020 13:45:05 +0300 Subject: [PATCH 042/368] FIR IDE: Unwrap nullable types --- .../shortenRefs/FirShortenRefsTestGenerated.java | 5 +++++ .../api/fir/components/KtFirReferenceShortener.kt | 11 +++++++++-- .../shortenRefsFir/types/ParameterTypeNullableType.kt | 6 ++++++ .../types/ParameterTypeNullableType.kt.after | 6 ++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNullableType.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNullableType.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index 728f2a8a6ff..33a57420cff 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -96,6 +96,11 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/types/ParameterTypeNotImportedNestedClass.kt"); } + @TestMetadata("ParameterTypeNullableType.kt") + public void testParameterTypeNullableType() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeNullableType.kt"); + } + @TestMetadata("ParameterTypeStarImportedTypeLoses.kt") public void testParameterTypeStarImportedTypeLoses() throws Exception { runTest("idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt"); diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 17b2cfb1597..de77008cae5 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -53,7 +53,11 @@ internal class KtFirReferenceShortener( firFile.acceptChildren(TypesCollectingVisitor(typesToImport, typesToShorten)) - return ShortenCommandImpl(file, typesToImport, typesToShorten.map { it.createSmartPointer() }) + return ShortenCommandImpl( + file, + typesToImport.distinct(), + typesToShorten.distinct().map { it.createSmartPointer() } + ) } private fun findFirstClassifierInScopesByName(positionScopes: List, targetClassName: Name): ClassId? { @@ -134,7 +138,7 @@ internal class KtFirReferenceShortener( val wholeTypeReference = resolvedTypeRef.psi as? KtTypeReference ?: return val wholeClassifierId = resolvedTypeRef.type.classId ?: return - val wholeTypeElement = wholeTypeReference.typeElement as? KtUserType ?: return + val wholeTypeElement = wholeTypeReference.typeElement.unwrapNullable() as? KtUserType ?: return if (wholeTypeElement.qualifier == null) return @@ -197,3 +201,6 @@ private class ShortenCommandImpl( } } } + +private tailrec fun KtTypeElement?.unwrapNullable(): KtTypeElement? = + if (this is KtNullableType) this.innerType.unwrapNullable() else this diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNullableType.kt b/idea/testData/shortenRefsFir/types/ParameterTypeNullableType.kt new file mode 100644 index 00000000000..817a9e3732c --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNullableType.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +class T + +fun foo(t: test.T???) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNullableType.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeNullableType.kt.after new file mode 100644 index 00000000000..e1b4d75b9c9 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNullableType.kt.after @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +class T + +fun foo(t: T???) {} From f03ca5ea57e07eab6f5c0af6cedeff4cddf26b40 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Thu, 24 Dec 2020 20:08:23 +0300 Subject: [PATCH 043/368] FIR IDE: Add import in case when conflicting class comes from `*` import --- .../FirShortenRefsTestGenerated.java | 5 +++++ .../fir/components/KtFirReferenceShortener.kt | 22 +++++++++++++------ ...plicitImportBeatsStarImport.dependency1.kt | 3 +++ ...plicitImportBeatsStarImport.dependency2.kt | 3 +++ ...ameterTypeImplicitImportBeatsStarImport.kt | 6 +++++ ...TypeImplicitImportBeatsStarImport.kt.after | 7 ++++++ ...arameterTypeStarImportedTypeLoses.kt.after | 3 ++- 7 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.dependency1.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.dependency2.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index 33a57420cff..ed61781103a 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -66,6 +66,11 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/types/ParameterTypeGenericTypes.kt"); } + @TestMetadata("ParameterTypeImplicitImportBeatsStarImport.kt") + public void testParameterTypeImplicitImportBeatsStarImport() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.kt"); + } + @TestMetadata("ParameterTypeImportedNestedClass.kt") public void testParameterTypeImportedNestedClass() throws Exception { runTest("idea/testData/shortenRefsFir/types/ParameterTypeImportedNestedClass.kt"); diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index de77008cae5..86b85116b44 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -15,12 +15,15 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.psi import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.scopes.FirScope +import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractStarImportingScope import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope +import org.jetbrains.kotlin.fir.scopes.impl.FirPackageMemberScope import org.jetbrains.kotlin.fir.scopes.processClassifiersByName import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.classId +import org.jetbrains.kotlin.fir.types.lowerBoundIfFlexible import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirModuleResolveState import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFir @@ -60,12 +63,17 @@ internal class KtFirReferenceShortener( ) } - private fun findFirstClassifierInScopesByName(positionScopes: List, targetClassName: Name): ClassId? { + private data class AvailableClassifier(val classId: ClassId, val isFromStarOrPackageImport: Boolean) + + private fun findFirstClassifierInScopesByName(positionScopes: List, targetClassName: Name): AvailableClassifier? { for (scope in positionScopes) { val classifierSymbol = scope.findFirstClassifierByName(targetClassName) ?: continue val classifierLookupTag = classifierSymbol.toLookupTag() as? ConeClassLikeLookupTag ?: continue - return classifierLookupTag.classId + return AvailableClassifier( + classifierLookupTag.classId, + isFromStarOrPackageImport = scope is FirAbstractStarImportingScope || scope is FirPackageMemberScope + ) } return null @@ -137,7 +145,7 @@ internal class KtFirReferenceShortener( private fun processTypeRef(resolvedTypeRef: FirResolvedTypeRef) { val wholeTypeReference = resolvedTypeRef.psi as? KtTypeReference ?: return - val wholeClassifierId = resolvedTypeRef.type.classId ?: return + val wholeClassifierId = resolvedTypeRef.type.lowerBoundIfFlexible().classId ?: return val wholeTypeElement = wholeTypeReference.typeElement.unwrapNullable() as? KtUserType ?: return if (wholeTypeElement.qualifier == null) return @@ -152,7 +160,7 @@ internal class KtFirReferenceShortener( val positionScopes = findScopesAtPosition(wholeTypeElement, typesToImport) ?: return for ((classId, typeElement) in allClassIds.zip(allTypeElements)) { - val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName) + val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId if (firstFoundClass == classId) { addTypeToShorten(typeElement) @@ -162,11 +170,11 @@ internal class KtFirReferenceShortener( // none class matched val (mostTopLevelClassId, mostTopLevelTypeElement) = allClassIds.zip(allTypeElements).last() - val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) + val availableClassifier = findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) - check(firstFoundClass != mostTopLevelClassId) { "This should not be true" } + check(availableClassifier?.classId != mostTopLevelClassId) { "This should not be true" } - if (firstFoundClass == null) { + if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { addTypeToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelTypeElement) } } diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.dependency1.kt b/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.dependency1.kt new file mode 100644 index 00000000000..e868126b897 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.dependency1.kt @@ -0,0 +1,3 @@ +package dependency1 + +class T \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.dependency2.kt b/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.dependency2.kt new file mode 100644 index 00000000000..83d8674a6c4 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.dependency2.kt @@ -0,0 +1,3 @@ +package dependency2 + +class T \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.kt b/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.kt new file mode 100644 index 00000000000..1e419001dc4 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +import dependency1.* + +fun foo(t: dependency2.T) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.kt.after new file mode 100644 index 00000000000..31166417872 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeImplicitImportBeatsStarImport.kt.after @@ -0,0 +1,7 @@ +// FIR_COMPARISON +package test + +import dependency1.* +import dependency2.T + +fun foo(t: T) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt.after index bcab9592b0e..7b5abce0f79 100644 --- a/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt.after +++ b/idea/testData/shortenRefsFir/types/ParameterTypeStarImportedTypeLoses.kt.after @@ -2,7 +2,8 @@ package test import dependency.* +import dependency.T class T -fun foo(t: dependency.T) {} \ No newline at end of file +fun foo(t: T) {} \ No newline at end of file From 534f4a66ad622e2a845e9a728ab78a0be5791e84 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Fri, 25 Dec 2020 12:19:35 +0300 Subject: [PATCH 044/368] FIR IDE: Add simple shortening for qualified calls and properties --- .../FirShortenRefsTestGenerated.java | 58 ++++++++++ .../fir/components/KtFirReferenceShortener.kt | 102 +++++++++++++++--- .../shortenRefsFir/calls/classInSameFile.kt | 6 ++ .../calls/classInSameFile.kt.after | 6 ++ .../calls/functionInSameFile.kt | 8 ++ .../calls/functionInSameFile.kt.after | 8 ++ .../calls/functionInSameFile2.kt | 8 ++ .../calls/functionInSameFile2.kt.after | 8 ++ .../shortenRefsFir/calls/propertyChainCall.kt | 8 ++ .../calls/propertyChainCall.kt.after | 8 ++ .../calls/propertyInSameFile.kt | 8 ++ .../calls/propertyInSameFile.kt.after | 8 ++ .../calls/propertyInSameFile2.kt | 8 ++ .../calls/propertyInSameFile2.kt.after | 8 ++ .../shortenRefsFir/calls/rootPackage.kt | 8 ++ .../shortenRefsFir/calls/rootPackage.kt.after | 8 ++ .../rootPackageShortenFakeRootPackage.kt | 10 ++ ...rootPackageShortenFakeRootPackage.kt.after | 10 ++ .../calls/selfReferencingFunction.kt | 6 ++ .../calls/selfReferencingFunction.kt.after | 6 ++ 20 files changed, 288 insertions(+), 12 deletions(-) create mode 100644 idea/testData/shortenRefsFir/calls/classInSameFile.kt create mode 100644 idea/testData/shortenRefsFir/calls/classInSameFile.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/functionInSameFile.kt create mode 100644 idea/testData/shortenRefsFir/calls/functionInSameFile.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/functionInSameFile2.kt create mode 100644 idea/testData/shortenRefsFir/calls/functionInSameFile2.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/propertyChainCall.kt create mode 100644 idea/testData/shortenRefsFir/calls/propertyChainCall.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/propertyInSameFile.kt create mode 100644 idea/testData/shortenRefsFir/calls/propertyInSameFile.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/propertyInSameFile2.kt create mode 100644 idea/testData/shortenRefsFir/calls/propertyInSameFile2.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/rootPackage.kt create mode 100644 idea/testData/shortenRefsFir/calls/rootPackage.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt create mode 100644 idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/selfReferencingFunction.kt create mode 100644 idea/testData/shortenRefsFir/calls/selfReferencingFunction.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index ed61781103a..c6e8e608fb5 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -29,6 +29,64 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/shortenRefsFir"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } + @TestMetadata("idea/testData/shortenRefsFir/calls") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Calls extends AbstractFirShortenRefsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestWithMuting, this, testDataFilePath); + } + + public void testAllFilesPresentInCalls() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/shortenRefsFir/calls"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("classInSameFile.kt") + public void testClassInSameFile() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/classInSameFile.kt"); + } + + @TestMetadata("functionInSameFile.kt") + public void testFunctionInSameFile() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/functionInSameFile.kt"); + } + + @TestMetadata("functionInSameFile2.kt") + public void testFunctionInSameFile2() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/functionInSameFile2.kt"); + } + + @TestMetadata("propertyChainCall.kt") + public void testPropertyChainCall() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/propertyChainCall.kt"); + } + + @TestMetadata("propertyInSameFile.kt") + public void testPropertyInSameFile() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/propertyInSameFile.kt"); + } + + @TestMetadata("propertyInSameFile2.kt") + public void testPropertyInSameFile2() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/propertyInSameFile2.kt"); + } + + @TestMetadata("rootPackage.kt") + public void testRootPackage() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/rootPackage.kt"); + } + + @TestMetadata("rootPackageShortenFakeRootPackage.kt") + public void testRootPackageShortenFakeRootPackage() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt"); + } + + @TestMetadata("selfReferencingFunction.kt") + public void testSelfReferencingFunction() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/selfReferencingFunction.kt"); + } + } + @TestMetadata("idea/testData/shortenRefsFir/types") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 86b85116b44..5a58e7ac80a 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -12,7 +12,9 @@ import com.intellij.util.containers.addIfNotNull import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirResolvedImport +import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.psi +import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractStarImportingScope @@ -20,7 +22,10 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope import org.jetbrains.kotlin.fir.scopes.impl.FirPackageMemberScope import org.jetbrains.kotlin.fir.scopes.processClassifiersByName import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag +import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.classId import org.jetbrains.kotlin.fir.types.lowerBoundIfFlexible @@ -51,15 +56,19 @@ internal class KtFirReferenceShortener( resolveFileToBodyResolve(file) val firFile = file.getOrBuildFirOfType(firResolveState) - val typesToImport = mutableListOf() - val typesToShorten = mutableListOf() + val namesToImport = mutableListOf() - firFile.acceptChildren(TypesCollectingVisitor(typesToImport, typesToShorten)) + val typesToShorten = mutableListOf() + val callsToShorten = mutableListOf() + + firFile.acceptChildren(TypesCollectingVisitor(namesToImport, typesToShorten)) + firFile.acceptChildren(CallsCollectingVisitor(namesToImport, callsToShorten)) return ShortenCommandImpl( file, - typesToImport.distinct(), - typesToShorten.distinct().map { it.createSmartPointer() } + namesToImport.distinct(), + typesToShorten.distinct().map { it.createSmartPointer() }, + callsToShorten.distinct().map { it.createSmartPointer() } ) } @@ -79,6 +88,14 @@ internal class KtFirReferenceShortener( return null } + private fun findSingleFunctionInScopesByName(scopes: List, name: Name): FirNamedFunctionSymbol? { + return scopes.asSequence().mapNotNull { it.getSingleFunctionByName(name) }.singleOrNull() + } + + private fun findSinglePropertyInScopesByName(scopes: List, name: Name): FirVariableSymbol<*>? { + return scopes.asSequence().mapNotNull { it.getSinglePropertyByName(name) }.singleOrNull() + } + private fun resolveFileToBodyResolve(file: KtFile) { for (declaration in file.declarations) { declaration.getOrBuildFir(firResolveState) // temporary hack, resolves declaration to BODY_RESOLVE stage @@ -98,12 +115,20 @@ internal class KtFirReferenceShortener( } @OptIn(ExperimentalStdlibApi::class) - private fun findScopesAtPosition(targetTypeReference: KtElement, newImports: List): List? { - val towerDataContext = firResolveState.getTowerDataContextForElement(targetTypeReference) ?: return null + private fun FirScope.getSingleFunctionByName(name: Name): FirNamedFunctionSymbol? = + buildList { processFunctionsByName(name, this::add) }.singleOrNull() + + @OptIn(ExperimentalStdlibApi::class) + private fun FirScope.getSinglePropertyByName(name: Name): FirVariableSymbol<*>? = + buildList { processPropertiesByName(name, this::add) }.singleOrNull() + + @OptIn(ExperimentalStdlibApi::class) + private fun findScopesAtPosition(position: KtElement, newImports: List): List? { + val towerDataContext = firResolveState.getTowerDataContextForElement(position) ?: return null val result = buildList { addAll(towerDataContext.nonLocalTowerDataElements.mapNotNull { it.scope }) - addIfNotNull(createFakeImportingScope(targetTypeReference.project, newImports)) + addIfNotNull(createFakeImportingScope(position.project, newImports)) addAll(towerDataContext.localScopes) } @@ -128,7 +153,7 @@ internal class KtFirReferenceShortener( } private inner class TypesCollectingVisitor( - private val typesToImport: MutableList, + private val namesToImport: MutableList, private val typesToShorten: MutableList, ) : FirVisitorVoid() { override fun visitElement(element: FirElement) { @@ -157,7 +182,7 @@ internal class KtFirReferenceShortener( val allClassIds = generateSequence(wholeClassifierId) { it.outerClassId } val allTypeElements = generateSequence(wholeTypeElement) { it.qualifier } - val positionScopes = findScopesAtPosition(wholeTypeElement, typesToImport) ?: return + val positionScopes = findScopesAtPosition(wholeTypeElement, namesToImport) ?: return for ((classId, typeElement) in allClassIds.zip(allTypeElements)) { val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId @@ -184,16 +209,59 @@ internal class KtFirReferenceShortener( } private fun addTypeToImportAndShorten(classFqName: FqName, mostTopLevelTypeElement: KtUserType) { - typesToImport.add(classFqName) + namesToImport.add(classFqName) typesToShorten.add(mostTopLevelTypeElement) } } + + private inner class CallsCollectingVisitor( + private val namesToImport: List, + private val callsToShorten: MutableList + ) : FirVisitorVoid() { + override fun visitElement(element: FirElement) { + element.acceptChildren(this) + } + + override fun visitResolvedNamedReference(resolvedNamedReference: FirResolvedNamedReference) { + super.visitResolvedNamedReference(resolvedNamedReference) + + val referenceExpression = resolvedNamedReference.psi as? KtNameReferenceExpression + val qualifiedProperty = referenceExpression?.parent as? KtDotQualifiedExpression ?: return + + val propertyId = (resolvedNamedReference.resolvedSymbol as? FirCallableSymbol<*>)?.callableId ?: return + + val scopes = findScopesAtPosition(qualifiedProperty, namesToImport) ?: return + val singleAvailableProperty = findSinglePropertyInScopesByName(scopes, propertyId.callableName) + + if (singleAvailableProperty?.callableId == propertyId) { + callsToShorten.add(qualifiedProperty) + } + } + + override fun visitFunctionCall(functionCall: FirFunctionCall) { + super.visitFunctionCall(functionCall) + + val callExpression = functionCall.psi as? KtCallExpression ?: return + val qualifiedCallExpression = callExpression.parent as? KtDotQualifiedExpression ?: return + + val resolvedNamedReference = functionCall.calleeReference as? FirResolvedNamedReference ?: return + val callableId = (resolvedNamedReference.resolvedSymbol as? FirCallableSymbol<*>)?.callableId ?: return + + val scopes = findScopesAtPosition(callExpression, namesToImport) ?: return + val singleAvailableCallable = findSingleFunctionInScopesByName(scopes, callableId.callableName) + + if (singleAvailableCallable?.callableId == callableId) { + callsToShorten.add(qualifiedCallExpression) + } + } + } } private class ShortenCommandImpl( val targetFile: KtFile, val importsToAdd: List, - val typesToShorten: List> + val typesToShorten: List>, + val callsToShorten: List>, ) : ShortenCommand { override fun invokeShortening() { @@ -207,8 +275,18 @@ private class ShortenCommandImpl( val type = typePointer.element ?: continue type.deleteQualifier() } + + for (callPointer in callsToShorten) { + val call = callPointer.element ?: continue + call.deleteQualifier() + } } } private tailrec fun KtTypeElement?.unwrapNullable(): KtTypeElement? = if (this is KtNullableType) this.innerType.unwrapNullable() else this + +private fun KtDotQualifiedExpression.deleteQualifier(): KtExpression? { + val selectorExpression = selectorExpression ?: return null + return this.replace(selectorExpression) as KtExpression +} diff --git a/idea/testData/shortenRefsFir/calls/classInSameFile.kt b/idea/testData/shortenRefsFir/calls/classInSameFile.kt new file mode 100644 index 00000000000..9be1987c318 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/classInSameFile.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +class A + +fun usage(a: test.A) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/classInSameFile.kt.after b/idea/testData/shortenRefsFir/calls/classInSameFile.kt.after new file mode 100644 index 00000000000..4a99d953158 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/classInSameFile.kt.after @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +class A + +fun usage(a: A) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/functionInSameFile.kt b/idea/testData/shortenRefsFir/calls/functionInSameFile.kt new file mode 100644 index 00000000000..fc721b6c085 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/functionInSameFile.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +fun foo() {} + +fun usage() { + test.foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/functionInSameFile.kt.after b/idea/testData/shortenRefsFir/calls/functionInSameFile.kt.after new file mode 100644 index 00000000000..f21145d5ac7 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/functionInSameFile.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +fun foo() {} + +fun usage() { + foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/functionInSameFile2.kt b/idea/testData/shortenRefsFir/calls/functionInSameFile2.kt new file mode 100644 index 00000000000..1e6acd4d2c4 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/functionInSameFile2.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test.test2 + +fun foo() {} + +fun usage() { + test.test2.foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/functionInSameFile2.kt.after b/idea/testData/shortenRefsFir/calls/functionInSameFile2.kt.after new file mode 100644 index 00000000000..aae7e20d1a8 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/functionInSameFile2.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test.test2 + +fun foo() {} + +fun usage() { + foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/propertyChainCall.kt b/idea/testData/shortenRefsFir/calls/propertyChainCall.kt new file mode 100644 index 00000000000..ebc22d3f81b --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/propertyChainCall.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test.test2 + +val foo = 1 + +fun usage() { + test.test2.foo.toString() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/propertyChainCall.kt.after b/idea/testData/shortenRefsFir/calls/propertyChainCall.kt.after new file mode 100644 index 00000000000..8352463c79e --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/propertyChainCall.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test.test2 + +val foo = 1 + +fun usage() { + foo.toString() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/propertyInSameFile.kt b/idea/testData/shortenRefsFir/calls/propertyInSameFile.kt new file mode 100644 index 00000000000..9eeaa360f4d --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/propertyInSameFile.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +val foo = 1 + +fun usage() { + test.foo +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/propertyInSameFile.kt.after b/idea/testData/shortenRefsFir/calls/propertyInSameFile.kt.after new file mode 100644 index 00000000000..90db706f0a9 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/propertyInSameFile.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +val foo = 1 + +fun usage() { + foo +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/propertyInSameFile2.kt b/idea/testData/shortenRefsFir/calls/propertyInSameFile2.kt new file mode 100644 index 00000000000..a4fbcf6a2ee --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/propertyInSameFile2.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test.test2 + +val foo = 1 + +fun usage() { + test.test2.foo +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/propertyInSameFile2.kt.after b/idea/testData/shortenRefsFir/calls/propertyInSameFile2.kt.after new file mode 100644 index 00000000000..72a3725671e --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/propertyInSameFile2.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test.test2 + +val foo = 1 + +fun usage() { + foo +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/rootPackage.kt b/idea/testData/shortenRefsFir/calls/rootPackage.kt new file mode 100644 index 00000000000..9bf9fbad2e7 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/rootPackage.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +fun test() {} + +fun usage() { + _root_ide_package_.test.test() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/rootPackage.kt.after b/idea/testData/shortenRefsFir/calls/rootPackage.kt.after new file mode 100644 index 00000000000..f19272a0dec --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/rootPackage.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +fun test() {} + +fun usage() { + test() +} diff --git a/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt b/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt new file mode 100644 index 00000000000..82556f68718 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +fun test() {} + +fun usage() { + fun test() {} + + _root_ide_package_.test.test() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt.after b/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt.after new file mode 100644 index 00000000000..ea300498b7a --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt.after @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +fun test() {} + +fun usage() { + fun test() {} + + test.test() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/selfReferencingFunction.kt b/idea/testData/shortenRefsFir/calls/selfReferencingFunction.kt new file mode 100644 index 00000000000..d88f2ad5569 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/selfReferencingFunction.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test.test1 + +fun foo() { + test.test1.foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/selfReferencingFunction.kt.after b/idea/testData/shortenRefsFir/calls/selfReferencingFunction.kt.after new file mode 100644 index 00000000000..5ae090a7cff --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/selfReferencingFunction.kt.after @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test.test1 + +fun foo() { + foo() +} \ No newline at end of file From 0e271b72c785c80d4fb6fd745771f8583fad68fb Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Fri, 25 Dec 2020 13:50:18 +0300 Subject: [PATCH 045/368] FIR IDE: Do not try to shorten type without qualifier --- .../shortenRefs/FirShortenRefsTestGenerated.java | 5 +++++ .../api/fir/components/KtFirReferenceShortener.kt | 11 +++++++++-- ...ParameterTypeNestedTypeWithoutPackageNotShorten.kt | 8 ++++++++ ...terTypeNestedTypeWithoutPackageNotShorten.kt.after | 8 ++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNestedTypeWithoutPackageNotShorten.kt create mode 100644 idea/testData/shortenRefsFir/types/ParameterTypeNestedTypeWithoutPackageNotShorten.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index c6e8e608fb5..dfd16ca314a 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -144,6 +144,11 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/types/ParameterTypeNestedType.kt"); } + @TestMetadata("ParameterTypeNestedTypeWithoutPackageNotShorten.kt") + public void testParameterTypeNestedTypeWithoutPackageNotShorten() throws Exception { + runTest("idea/testData/shortenRefsFir/types/ParameterTypeNestedTypeWithoutPackageNotShorten.kt"); + } + @TestMetadata("ParameterTypeNonImportedClass.kt") public void testParameterTypeNonImportedClass() throws Exception { runTest("idea/testData/shortenRefsFir/types/ParameterTypeNonImportedClass.kt"); diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 5a58e7ac80a..c1520243ac8 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -185,6 +185,9 @@ internal class KtFirReferenceShortener( val positionScopes = findScopesAtPosition(wholeTypeElement, namesToImport) ?: return for ((classId, typeElement) in allClassIds.zip(allTypeElements)) { + // if qualifier is null, then this type have no package and thus cannot be shortened + if (typeElement.qualifier == null) return + val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId if (firstFoundClass == classId) { @@ -234,7 +237,7 @@ internal class KtFirReferenceShortener( val singleAvailableProperty = findSinglePropertyInScopesByName(scopes, propertyId.callableName) if (singleAvailableProperty?.callableId == propertyId) { - callsToShorten.add(qualifiedProperty) + addElementToShorten(qualifiedProperty) } } @@ -251,9 +254,13 @@ internal class KtFirReferenceShortener( val singleAvailableCallable = findSingleFunctionInScopesByName(scopes, callableId.callableName) if (singleAvailableCallable?.callableId == callableId) { - callsToShorten.add(qualifiedCallExpression) + addElementToShorten(qualifiedCallExpression) } } + + private fun addElementToShorten(element: KtDotQualifiedExpression) { + callsToShorten.add(element) + } } } diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNestedTypeWithoutPackageNotShorten.kt b/idea/testData/shortenRefsFir/types/ParameterTypeNestedTypeWithoutPackageNotShorten.kt new file mode 100644 index 00000000000..001e3180f67 --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNestedTypeWithoutPackageNotShorten.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class T { + class TT +} + +fun foo(t: T.TT) {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeNestedTypeWithoutPackageNotShorten.kt.after b/idea/testData/shortenRefsFir/types/ParameterTypeNestedTypeWithoutPackageNotShorten.kt.after new file mode 100644 index 00000000000..55547c490bc --- /dev/null +++ b/idea/testData/shortenRefsFir/types/ParameterTypeNestedTypeWithoutPackageNotShorten.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class T { + class TT +} + +fun foo(t: T.TT) {} From e265a78a33d5e5e1ae80a8ff71460f58ab7e4338 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Mon, 28 Dec 2020 13:22:03 +0300 Subject: [PATCH 046/368] FIR IDE: Implement shortening and import for type qualifiers --- .../FirShortenRefsTestGenerated.java | 38 ++++++++++++ .../fir/components/KtFirReferenceShortener.kt | 60 ++++++++++++++++++- .../AlreadyImportedNestedType.dependency.kt | 5 ++ .../quailfiers/AlreadyImportedNestedType.kt | 12 ++++ .../AlreadyImportedNestedType.kt.after | 12 ++++ .../quailfiers/NestedTypeInSameFile.kt | 10 ++++ .../quailfiers/NestedTypeInSameFile.kt.after | 10 ++++ .../NotImportedNestedType.dependency.kt | 5 ++ .../quailfiers/NotImportedNestedType.kt | 6 ++ .../quailfiers/NotImportedNestedType.kt.after | 8 +++ .../NotImportedTopLevelType.dependency.kt | 3 + .../quailfiers/NotImportedTopLevelType.kt | 6 ++ .../NotImportedTopLevelType.kt.after | 8 +++ .../quailfiers/TopLevelTypeInSameFile.kt | 8 +++ .../TopLevelTypeInSameFile.kt.after | 8 +++ 15 files changed, 196 insertions(+), 3 deletions(-) create mode 100644 idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.dependency.kt create mode 100644 idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.kt create mode 100644 idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.kt.after create mode 100644 idea/testData/shortenRefsFir/quailfiers/NestedTypeInSameFile.kt create mode 100644 idea/testData/shortenRefsFir/quailfiers/NestedTypeInSameFile.kt.after create mode 100644 idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.dependency.kt create mode 100644 idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.kt create mode 100644 idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.kt.after create mode 100644 idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.dependency.kt create mode 100644 idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.kt create mode 100644 idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.kt.after create mode 100644 idea/testData/shortenRefsFir/quailfiers/TopLevelTypeInSameFile.kt create mode 100644 idea/testData/shortenRefsFir/quailfiers/TopLevelTypeInSameFile.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index dfd16ca314a..26e6b191d34 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -87,6 +87,44 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { } } + @TestMetadata("idea/testData/shortenRefsFir/quailfiers") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Quailfiers extends AbstractFirShortenRefsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestWithMuting, this, testDataFilePath); + } + + public void testAllFilesPresentInQuailfiers() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/shortenRefsFir/quailfiers"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("AlreadyImportedNestedType.kt") + public void testAlreadyImportedNestedType() throws Exception { + runTest("idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.kt"); + } + + @TestMetadata("NestedTypeInSameFile.kt") + public void testNestedTypeInSameFile() throws Exception { + runTest("idea/testData/shortenRefsFir/quailfiers/NestedTypeInSameFile.kt"); + } + + @TestMetadata("NotImportedNestedType.kt") + public void testNotImportedNestedType() throws Exception { + runTest("idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.kt"); + } + + @TestMetadata("NotImportedTopLevelType.kt") + public void testNotImportedTopLevelType() throws Exception { + runTest("idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.kt"); + } + + @TestMetadata("TopLevelTypeInSameFile.kt") + public void testTopLevelTypeInSameFile() throws Exception { + runTest("idea/testData/shortenRefsFir/quailfiers/TopLevelTypeInSameFile.kt"); + } + } + @TestMetadata("idea/testData/shortenRefsFir/types") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index c1520243ac8..b5a691afe5f 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.expressions.FirFunctionCall +import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.psi import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.ScopeSession @@ -179,8 +180,8 @@ internal class KtFirReferenceShortener( } private fun collectTypeIfNeedsToBeShortened(wholeClassifierId: ClassId, wholeTypeElement: KtUserType) { - val allClassIds = generateSequence(wholeClassifierId) { it.outerClassId } - val allTypeElements = generateSequence(wholeTypeElement) { it.qualifier } + val allClassIds = wholeClassifierId.outerClassesWithSelf + val allTypeElements = wholeTypeElement.qualifiersWithSelf val positionScopes = findScopesAtPosition(wholeTypeElement, namesToImport) ?: return @@ -218,7 +219,7 @@ internal class KtFirReferenceShortener( } private inner class CallsCollectingVisitor( - private val namesToImport: List, + private val namesToImport: MutableList, private val callsToShorten: MutableList ) : FirVisitorVoid() { override fun visitElement(element: FirElement) { @@ -258,10 +259,63 @@ internal class KtFirReferenceShortener( } } + + override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) { + super.visitResolvedQualifier(resolvedQualifier) + + val wholeClassQualifier = resolvedQualifier.classId ?: return + val wholeQualifierElement = when (val qualifierPsi = resolvedQualifier.psi) { + is KtDotQualifiedExpression -> qualifierPsi + is KtNameReferenceExpression -> qualifierPsi.parent as? KtDotQualifiedExpression ?: return + else -> return + } + + collectQualifierIfNeedsToBeShortened(wholeClassQualifier, wholeQualifierElement) + } + + private fun collectQualifierIfNeedsToBeShortened(wholeClassQualifier: ClassId, wholeQualifierElement: KtDotQualifiedExpression) { + val positionScopes = findScopesAtPosition(wholeQualifierElement, namesToImport) ?: return + + val allClassIds = wholeClassQualifier.outerClassesWithSelf + val allQualifiers = wholeQualifierElement.qualifiersWithSelf + + for ((classId, qualifier) in allClassIds.zip(allQualifiers)) { + val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId + + if (firstFoundClass == classId) { + addElementToShorten(qualifier) + return + } + } + + val (mostTopLevelClassId, mostTopLevelQualifier) = allClassIds.zip(allQualifiers).last() + val availableClassifier = findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) + + check(availableClassifier?.classId != mostTopLevelClassId) { "This should not be true" } + + if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { + addElementToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelQualifier) + } + } + private fun addElementToShorten(element: KtDotQualifiedExpression) { callsToShorten.add(element) } + + private fun addElementToImportAndShorten(nameToImport: FqName, element: KtDotQualifiedExpression) { + namesToImport.add(nameToImport) + callsToShorten.add(element) + } } + + private val ClassId.outerClassesWithSelf: Sequence + get() = generateSequence(this) { it.outerClassId } + + private val KtUserType.qualifiersWithSelf: Sequence + get() = generateSequence(this) { it.qualifier } + + private val KtDotQualifiedExpression.qualifiersWithSelf: Sequence + get() = generateSequence(this) { it.receiverExpression as? KtDotQualifiedExpression } } private class ShortenCommandImpl( diff --git a/idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.dependency.kt b/idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.dependency.kt new file mode 100644 index 00000000000..007010a3e40 --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.dependency.kt @@ -0,0 +1,5 @@ +package dependency + +class T { + class TT +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.kt b/idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.kt new file mode 100644 index 00000000000..2f926b6c4ed --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.kt @@ -0,0 +1,12 @@ +// FIR_COMPARISON +package test + +import dependency.T +import dependency.T.TT + +fun usage() { + + dependency.T.TT + T.TT + +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.kt.after b/idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.kt.after new file mode 100644 index 00000000000..711037bf58a --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/AlreadyImportedNestedType.kt.after @@ -0,0 +1,12 @@ +// FIR_COMPARISON +package test + +import dependency.T +import dependency.T.TT + +fun usage() { + + TT + TT + +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/NestedTypeInSameFile.kt b/idea/testData/shortenRefsFir/quailfiers/NestedTypeInSameFile.kt new file mode 100644 index 00000000000..b9d3dfb2a62 --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/NestedTypeInSameFile.kt @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +class A { + class AA +} + +fun usage() { + test.A.AA +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/NestedTypeInSameFile.kt.after b/idea/testData/shortenRefsFir/quailfiers/NestedTypeInSameFile.kt.after new file mode 100644 index 00000000000..3c7751dfcb1 --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/NestedTypeInSameFile.kt.after @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +class A { + class AA +} + +fun usage() { + A.AA +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.dependency.kt b/idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.dependency.kt new file mode 100644 index 00000000000..007010a3e40 --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.dependency.kt @@ -0,0 +1,5 @@ +package dependency + +class T { + class TT +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.kt b/idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.kt new file mode 100644 index 00000000000..da8709a0004 --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +fun usage() { + dependency.T.TT +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.kt.after b/idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.kt.after new file mode 100644 index 00000000000..dc5146b7aca --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/NotImportedNestedType.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.T + +fun usage() { + T.TT +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.dependency.kt b/idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.dependency.kt new file mode 100644 index 00000000000..fc6fb4fa1c8 --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +class T \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.kt b/idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.kt new file mode 100644 index 00000000000..d8c9f92d525 --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +fun usage() { + dependency.T +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.kt.after b/idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.kt.after new file mode 100644 index 00000000000..9c1bfa1567c --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/NotImportedTopLevelType.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.T + +fun usage() { + T +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/TopLevelTypeInSameFile.kt b/idea/testData/shortenRefsFir/quailfiers/TopLevelTypeInSameFile.kt new file mode 100644 index 00000000000..da3f7bee2db --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/TopLevelTypeInSameFile.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class A + +fun usage() { + test.A +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/quailfiers/TopLevelTypeInSameFile.kt.after b/idea/testData/shortenRefsFir/quailfiers/TopLevelTypeInSameFile.kt.after new file mode 100644 index 00000000000..30eb3797e03 --- /dev/null +++ b/idea/testData/shortenRefsFir/quailfiers/TopLevelTypeInSameFile.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +class A + +fun usage() { + A +} \ No newline at end of file From d88fd5bd73a41d7e04b91c36bd6a746b591e41e6 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 29 Dec 2020 13:18:30 +0300 Subject: [PATCH 047/368] FIR IDE: More strictly navigate to parent `KtDotQualifiedExpression` --- .../shortenRefs/FirShortenRefsTestGenerated.java | 5 +++++ .../api/fir/components/KtFirReferenceShortener.kt | 11 ++++++++--- .../shortenRefsFir/calls/variableNotShortened.kt | 4 ++++ .../calls/variableNotShortened.kt.after | 4 ++++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 idea/testData/shortenRefsFir/calls/variableNotShortened.kt create mode 100644 idea/testData/shortenRefsFir/calls/variableNotShortened.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index 26e6b191d34..bc2474535e7 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -85,6 +85,11 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { public void testSelfReferencingFunction() throws Exception { runTest("idea/testData/shortenRefsFir/calls/selfReferencingFunction.kt"); } + + @TestMetadata("variableNotShortened.kt") + public void testVariableNotShortened() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/variableNotShortened.kt"); + } } @TestMetadata("idea/testData/shortenRefsFir/quailfiers") diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index b5a691afe5f..b67d28a0224 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -9,7 +9,9 @@ import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.Project import com.intellij.psi.SmartPsiElementPointer import com.intellij.util.containers.addIfNotNull +import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.expressions.FirFunctionCall @@ -230,7 +232,7 @@ internal class KtFirReferenceShortener( super.visitResolvedNamedReference(resolvedNamedReference) val referenceExpression = resolvedNamedReference.psi as? KtNameReferenceExpression - val qualifiedProperty = referenceExpression?.parent as? KtDotQualifiedExpression ?: return + val qualifiedProperty = referenceExpression?.getDotQualifiedExpressionForSelector() ?: return val propertyId = (resolvedNamedReference.resolvedSymbol as? FirCallableSymbol<*>)?.callableId ?: return @@ -246,7 +248,7 @@ internal class KtFirReferenceShortener( super.visitFunctionCall(functionCall) val callExpression = functionCall.psi as? KtCallExpression ?: return - val qualifiedCallExpression = callExpression.parent as? KtDotQualifiedExpression ?: return + val qualifiedCallExpression = callExpression.getDotQualifiedExpressionForSelector() ?: return val resolvedNamedReference = functionCall.calleeReference as? FirResolvedNamedReference ?: return val callableId = (resolvedNamedReference.resolvedSymbol as? FirCallableSymbol<*>)?.callableId ?: return @@ -266,7 +268,7 @@ internal class KtFirReferenceShortener( val wholeClassQualifier = resolvedQualifier.classId ?: return val wholeQualifierElement = when (val qualifierPsi = resolvedQualifier.psi) { is KtDotQualifiedExpression -> qualifierPsi - is KtNameReferenceExpression -> qualifierPsi.parent as? KtDotQualifiedExpression ?: return + is KtNameReferenceExpression -> qualifierPsi.getDotQualifiedExpressionForSelector() ?: return else -> return } @@ -344,6 +346,9 @@ private class ShortenCommandImpl( } } +private fun KtElement.getDotQualifiedExpressionForSelector(): KtDotQualifiedExpression? = + getQualifiedExpressionForSelector() as? KtDotQualifiedExpression + private tailrec fun KtTypeElement?.unwrapNullable(): KtTypeElement? = if (this is KtNullableType) this.innerType.unwrapNullable() else this diff --git a/idea/testData/shortenRefsFir/calls/variableNotShortened.kt b/idea/testData/shortenRefsFir/calls/variableNotShortened.kt new file mode 100644 index 00000000000..7b79ff6dbbe --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/variableNotShortened.kt @@ -0,0 +1,4 @@ +// FIR_COMPARISON +fun usage(c: Any) { + c.toString() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/variableNotShortened.kt.after b/idea/testData/shortenRefsFir/calls/variableNotShortened.kt.after new file mode 100644 index 00000000000..55993cd16ac --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/variableNotShortened.kt.after @@ -0,0 +1,4 @@ +// FIR_COMPARISON +fun usage(c: Any) { + c.toString() +} \ No newline at end of file From 51c59e5634328c43c4ab8d078b026685e5ebd4b5 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Wed, 30 Dec 2020 13:58:23 +0300 Subject: [PATCH 048/368] FIR IDE: Check function call before trying to drop the receiver --- .../FirShortenRefsTestGenerated.java | 20 +++++++++++++++++++ .../fir/components/KtFirReferenceShortener.kt | 18 ++++++++++++++--- ...plicitlyImportedFunctionFromLocalObject.kt | 12 +++++++++++ ...lyImportedFunctionFromLocalObject.kt.after | 12 +++++++++++ ...onOnCompanionObjectReceiverNotShortened.kt | 12 +++++++++++ ...mpanionObjectReceiverNotShortened.kt.after | 12 +++++++++++ ...ionFunctionOnObjectReceiverNotShortened.kt | 10 ++++++++++ ...ctionOnObjectReceiverNotShortened.kt.after | 10 ++++++++++ .../extenstionFunctionReceiverNotShortened.kt | 10 ++++++++++ ...stionFunctionReceiverNotShortened.kt.after | 10 ++++++++++ 10 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 idea/testData/shortenRefsFir/calls/explicitlyImportedFunctionFromLocalObject.kt create mode 100644 idea/testData/shortenRefsFir/calls/explicitlyImportedFunctionFromLocalObject.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/extenstionFunctionOnCompanionObjectReceiverNotShortened.kt create mode 100644 idea/testData/shortenRefsFir/calls/extenstionFunctionOnCompanionObjectReceiverNotShortened.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/extenstionFunctionOnObjectReceiverNotShortened.kt create mode 100644 idea/testData/shortenRefsFir/calls/extenstionFunctionOnObjectReceiverNotShortened.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/extenstionFunctionReceiverNotShortened.kt create mode 100644 idea/testData/shortenRefsFir/calls/extenstionFunctionReceiverNotShortened.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index bc2474535e7..e1e234f7941 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -46,6 +46,26 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/calls/classInSameFile.kt"); } + @TestMetadata("explicitlyImportedFunctionFromLocalObject.kt") + public void testExplicitlyImportedFunctionFromLocalObject() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/explicitlyImportedFunctionFromLocalObject.kt"); + } + + @TestMetadata("extenstionFunctionOnCompanionObjectReceiverNotShortened.kt") + public void testExtenstionFunctionOnCompanionObjectReceiverNotShortened() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/extenstionFunctionOnCompanionObjectReceiverNotShortened.kt"); + } + + @TestMetadata("extenstionFunctionOnObjectReceiverNotShortened.kt") + public void testExtenstionFunctionOnObjectReceiverNotShortened() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/extenstionFunctionOnObjectReceiverNotShortened.kt"); + } + + @TestMetadata("extenstionFunctionReceiverNotShortened.kt") + public void testExtenstionFunctionReceiverNotShortened() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/extenstionFunctionReceiverNotShortened.kt"); + } + @TestMetadata("functionInSameFile.kt") public void testFunctionInSameFile() throws Exception { runTest("idea/testData/shortenRefsFir/calls/functionInSameFile.kt"); diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index b67d28a0224..25e88f6fa24 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -11,11 +11,11 @@ import com.intellij.psi.SmartPsiElementPointer import com.intellij.util.containers.addIfNotNull import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirElement -import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.declarations.FirFile -import org.jetbrains.kotlin.fir.declarations.FirResolvedImport +import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClass +import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.psi import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.ScopeSession @@ -247,6 +247,8 @@ internal class KtFirReferenceShortener( override fun visitFunctionCall(functionCall: FirFunctionCall) { super.visitFunctionCall(functionCall) + if (!canBePossibleToDropReceiver(functionCall)) return + val callExpression = functionCall.psi as? KtCallExpression ?: return val qualifiedCallExpression = callExpression.getDotQualifiedExpressionForSelector() ?: return @@ -261,6 +263,16 @@ internal class KtFirReferenceShortener( } } + private fun canBePossibleToDropReceiver(functionCall: FirFunctionCall): Boolean { + // we can remove receiver only if it is a qualifier + val explicitReceiver = functionCall.explicitReceiver as? FirResolvedQualifier ?: return false + + // if there is no extension receiver necessary, then it can be removed + if (functionCall.extensionReceiver is FirNoReceiverExpression) return true + + val receiverType = explicitReceiver.typeRef.toRegularClass(firResolveState.rootModuleSession) ?: return true + return receiverType.classKind != ClassKind.OBJECT + } override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) { super.visitResolvedQualifier(resolvedQualifier) diff --git a/idea/testData/shortenRefsFir/calls/explicitlyImportedFunctionFromLocalObject.kt b/idea/testData/shortenRefsFir/calls/explicitlyImportedFunctionFromLocalObject.kt new file mode 100644 index 00000000000..4daebabe693 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/explicitlyImportedFunctionFromLocalObject.kt @@ -0,0 +1,12 @@ +// FIR_COMPARISON +package test + +import test.Obj.funFromObj + +object Obj { + fun funFromObj() {} +} + +fun usage() { + Obj.funFromObj() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/explicitlyImportedFunctionFromLocalObject.kt.after b/idea/testData/shortenRefsFir/calls/explicitlyImportedFunctionFromLocalObject.kt.after new file mode 100644 index 00000000000..4c45aa7a3b7 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/explicitlyImportedFunctionFromLocalObject.kt.after @@ -0,0 +1,12 @@ +// FIR_COMPARISON +package test + +import test.Obj.funFromObj + +object Obj { + fun funFromObj() {} +} + +fun usage() { + funFromObj() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/extenstionFunctionOnCompanionObjectReceiverNotShortened.kt b/idea/testData/shortenRefsFir/calls/extenstionFunctionOnCompanionObjectReceiverNotShortened.kt new file mode 100644 index 00000000000..6e42faf1623 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/extenstionFunctionOnCompanionObjectReceiverNotShortened.kt @@ -0,0 +1,12 @@ +// FIR_COMPARISON +package test + +class T { + companion object +} + +fun T.Companion.ext() {} + +fun usage() { + T.ext() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/extenstionFunctionOnCompanionObjectReceiverNotShortened.kt.after b/idea/testData/shortenRefsFir/calls/extenstionFunctionOnCompanionObjectReceiverNotShortened.kt.after new file mode 100644 index 00000000000..d0a9331bdbf --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/extenstionFunctionOnCompanionObjectReceiverNotShortened.kt.after @@ -0,0 +1,12 @@ +// FIR_COMPARISON +package test + +class T { + companion object +} + +fun T.Companion.ext() {} + +fun usage() { + T.ext() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/extenstionFunctionOnObjectReceiverNotShortened.kt b/idea/testData/shortenRefsFir/calls/extenstionFunctionOnObjectReceiverNotShortened.kt new file mode 100644 index 00000000000..c1b04717494 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/extenstionFunctionOnObjectReceiverNotShortened.kt @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +object T + +fun T.ext() {} + +fun usage() { + T.ext() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/extenstionFunctionOnObjectReceiverNotShortened.kt.after b/idea/testData/shortenRefsFir/calls/extenstionFunctionOnObjectReceiverNotShortened.kt.after new file mode 100644 index 00000000000..52fdbb62ddb --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/extenstionFunctionOnObjectReceiverNotShortened.kt.after @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +object T + +fun T.ext() {} + +fun usage() { + T.ext() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/extenstionFunctionReceiverNotShortened.kt b/idea/testData/shortenRefsFir/calls/extenstionFunctionReceiverNotShortened.kt new file mode 100644 index 00000000000..fbfb363c1b3 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/extenstionFunctionReceiverNotShortened.kt @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +class T + +fun T.ext() {} + +fun usage(t: T) { + t.ext() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/extenstionFunctionReceiverNotShortened.kt.after b/idea/testData/shortenRefsFir/calls/extenstionFunctionReceiverNotShortened.kt.after new file mode 100644 index 00000000000..1c3c4c8afbd --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/extenstionFunctionReceiverNotShortened.kt.after @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +class T + +fun T.ext() {} + +fun usage(t: T) { + t.ext() +} From 88e7d1e5eedf78a2f42315539faa43c8ced99196 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 19 Jan 2021 16:13:42 +0300 Subject: [PATCH 049/368] FIR: Attach candidate symbol to the `ErrorNamedReference` This allows to restore the referenced candidate in cases when there are no ambiguity Also, change rendering of named references to be more accurate, so the diagnostics tests pass: if reference is FirErrorNamedReference, it is more important than if it has a not-null `candidateSymbol` --- .../transformers/FirCallCompletionResultsWriterTransformer.kt | 1 + .../fir/references/builder/FirErrorNamedReferenceBuilder.kt | 2 ++ .../kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt | 2 +- compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt | 4 +--- .../kotlin/fir/tree/generator/ImplementationConfigurator.kt | 1 - 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index f1d4ede334e..c6ae1f159bc 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -633,6 +633,7 @@ class FirCallCompletionResultsWriterTransformer( buildErrorNamedReference { source = this@toResolvedReference.source diagnostic = this@toResolvedReference.diagnostic + candidateSymbol = this@toResolvedReference.candidateSymbol } } else { buildResolvedNamedReference { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirErrorNamedReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirErrorNamedReferenceBuilder.kt index 0b0df91dac8..87dae2541e1 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirErrorNamedReferenceBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirErrorNamedReferenceBuilder.kt @@ -23,11 +23,13 @@ import org.jetbrains.kotlin.name.Name @FirBuilderDsl class FirErrorNamedReferenceBuilder { var source: FirSourceElement? = null + var candidateSymbol: AbstractFirBasedSymbol<*>? = null lateinit var diagnostic: ConeDiagnostic fun build(): FirErrorNamedReference { return FirErrorNamedReferenceImpl( source, + candidateSymbol, diagnostic, ) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt index 77669cb1829..9d513fb9f7c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt @@ -19,10 +19,10 @@ import org.jetbrains.kotlin.fir.visitors.* internal class FirErrorNamedReferenceImpl( override val source: FirSourceElement?, + override val candidateSymbol: AbstractFirBasedSymbol<*>?, override val diagnostic: ConeDiagnostic, ) : FirErrorNamedReference() { override val name: Name = Name.special("<${diagnostic.reason}>") - override val candidateSymbol: AbstractFirBasedSymbol<*>? get() = null override fun acceptChildren(visitor: FirVisitor, data: D) {} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index 3d189b571e4..d65b634654f 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -969,10 +969,8 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM override fun visitNamedReference(namedReference: FirNamedReference) { val symbol = namedReference.candidateSymbol when { - symbol != null -> { - print("R?C|${symbol.render()}|") - } namedReference is FirErrorNamedReference -> print("<${namedReference.diagnostic.reason}>#") + symbol != null -> print("R?C|${symbol.render()}|") else -> print("${namedReference.name}#") } } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt index c705a4ce8af..ddede3e0d74 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt @@ -423,7 +423,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(errorNamedReference) { default("name", "Name.special(\"<\${diagnostic.reason}>\")") - defaultNull("candidateSymbol", withGetter = true) } impl(typeProjection, "FirTypePlaceholderProjection") { From ee98a76600a60d1e753c61b60f4ba27a2b24f179 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 19 Jan 2021 16:29:05 +0300 Subject: [PATCH 050/368] FIR IDE: Implement simple importing of the functions This is not a complete algorithm, but it already works in many cases Disable some tests that not yet work --- .../FirShortenRefsTestGenerated.java | 32 +++++++++- .../fir/components/KtFirReferenceShortener.kt | 59 +++++++++++++++---- .../calls/functionInSameFileAmbiguous.kt | 10 ++++ .../functionInSameFileAmbiguous.kt.after | 10 ++++ ...tedTopLevelFunctionAmbiguous.dependency.kt | 5 ++ .../notImportedTopLevelFunctionAmbiguous.kt | 6 ++ ...ImportedTopLevelFunctionAmbiguous.kt.after | 8 +++ ...unctionConflictsWithImported.dependency.kt | 3 + ...edTopLevelFunctionConflictsWithImported.kt | 8 +++ ...evelFunctionConflictsWithImported.kt.after | 8 +++ ...edTopLevelFunctionMissingArg.dependency.kt | 3 + .../notImportedTopLevelFunctionMissingArg.kt | 6 ++ ...mportedTopLevelFunctionMissingArg.kt.after | 8 +++ ...portedTopLevelFunctionNoArgs.dependency.kt | 3 + .../notImportedTopLevelFunctionNoArgs.kt | 6 ++ ...notImportedTopLevelFunctionNoArgs.kt.after | 8 +++ ...opLevelTypeConstructorNoArgs.dependency.kt | 3 + ...otImportedTopLevelTypeConstructorNoArgs.kt | 6 ++ ...rtedTopLevelTypeConstructorNoArgs.kt.after | 8 +++ .../rootPackageShortenFakeRootPackage.kt | 2 +- ...rameterTypeConflictingTopLevelClassUsed.kt | 2 +- 21 files changed, 191 insertions(+), 13 deletions(-) create mode 100644 idea/testData/shortenRefsFir/calls/functionInSameFileAmbiguous.kt create mode 100644 idea/testData/shortenRefsFir/calls/functionInSameFileAmbiguous.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.dependency.kt create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.kt create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.dependency.kt create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.kt create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.dependency.kt create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.kt create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.dependency.kt create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.kt create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.kt.after create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.dependency.kt create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.kt create mode 100644 idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.kt.after diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index e1e234f7941..e0c9819ff0a 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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. */ @@ -76,6 +76,36 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/calls/functionInSameFile2.kt"); } + @TestMetadata("functionInSameFileAmbiguous.kt") + public void testFunctionInSameFileAmbiguous() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/functionInSameFileAmbiguous.kt"); + } + + @TestMetadata("notImportedTopLevelFunctionAmbiguous.kt") + public void testNotImportedTopLevelFunctionAmbiguous() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.kt"); + } + + @TestMetadata("notImportedTopLevelFunctionConflictsWithImported.kt") + public void testNotImportedTopLevelFunctionConflictsWithImported() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.kt"); + } + + @TestMetadata("notImportedTopLevelFunctionMissingArg.kt") + public void testNotImportedTopLevelFunctionMissingArg() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.kt"); + } + + @TestMetadata("notImportedTopLevelFunctionNoArgs.kt") + public void testNotImportedTopLevelFunctionNoArgs() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.kt"); + } + + @TestMetadata("notImportedTopLevelTypeConstructorNoArgs.kt") + public void testNotImportedTopLevelTypeConstructorNoArgs() throws Exception { + runTest("idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.kt"); + } + @TestMetadata("propertyChainCall.kt") public void testPropertyChainCall() throws Exception { runTest("idea/testData/shortenRefsFir/calls/propertyChainCall.kt"); diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 25e88f6fa24..23ab798fed2 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -17,18 +17,20 @@ import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.psi +import org.jetbrains.kotlin.fir.references.FirErrorNamedReference +import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.ScopeSession +import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeAmbiguityError import org.jetbrains.kotlin.fir.scopes.FirScope +import org.jetbrains.kotlin.fir.scopes.getFunctions import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractStarImportingScope import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope import org.jetbrains.kotlin.fir.scopes.impl.FirPackageMemberScope import org.jetbrains.kotlin.fir.scopes.processClassifiersByName +import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag -import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.classId import org.jetbrains.kotlin.fir.types.lowerBoundIfFlexible @@ -91,8 +93,8 @@ internal class KtFirReferenceShortener( return null } - private fun findSingleFunctionInScopesByName(scopes: List, name: Name): FirNamedFunctionSymbol? { - return scopes.asSequence().mapNotNull { it.getSingleFunctionByName(name) }.singleOrNull() + private fun findFunctionsInScopes(scopes: List, name: Name): List { + return scopes.flatMap { it.getFunctions(name) } } private fun findSinglePropertyInScopesByName(scopes: List, name: Name): FirVariableSymbol<*>? { @@ -252,13 +254,16 @@ internal class KtFirReferenceShortener( val callExpression = functionCall.psi as? KtCallExpression ?: return val qualifiedCallExpression = callExpression.getDotQualifiedExpressionForSelector() ?: return - val resolvedNamedReference = functionCall.calleeReference as? FirResolvedNamedReference ?: return - val callableId = (resolvedNamedReference.resolvedSymbol as? FirCallableSymbol<*>)?.callableId ?: return + val calleeReference = functionCall.calleeReference + val callableId = findUnambiguousReferencedCallableId(calleeReference) ?: return val scopes = findScopesAtPosition(callExpression, namesToImport) ?: return - val singleAvailableCallable = findSingleFunctionInScopesByName(scopes, callableId.callableName) + val availableCallables = findFunctionsInScopes(scopes, callableId.callableName) - if (singleAvailableCallable?.callableId == callableId) { + if (availableCallables.isEmpty()) { + val additionalImport = callableId.asImportableFqName() ?: return + addElementToImportAndShorten(additionalImport, qualifiedCallExpression) + } else if (availableCallables.all { it.callableId == callableId }) { addElementToShorten(qualifiedCallExpression) } } @@ -274,6 +279,38 @@ internal class KtFirReferenceShortener( return receiverType.classKind != ClassKind.OBJECT } + private fun findUnambiguousReferencedCallableId(namedReference: FirNamedReference): CallableId? { + val unambiguousSymbol = when (namedReference) { + is FirResolvedNamedReference -> namedReference.resolvedSymbol + is FirErrorNamedReference -> { + val candidateSymbol = namedReference.candidateSymbol + if (candidateSymbol !is FirErrorFunctionSymbol) { + candidateSymbol + } else { + getSingleUnambiguousCandidate(namedReference) + } + } + else -> null + } + + return (unambiguousSymbol as? FirCallableSymbol<*>)?.callableId + } + + /** + * If [namedReference] is ambiguous and all candidates point to the callables with same callableId, + * returns the first candidate; otherwise returns null. + */ + private fun getSingleUnambiguousCandidate(namedReference: FirErrorNamedReference): FirCallableSymbol<*>? { + val coneAmbiguityError = namedReference.diagnostic as? ConeAmbiguityError ?: return null + + val candidates = coneAmbiguityError.candidates.map { it as FirCallableSymbol<*> } + require(candidates.isNotEmpty()) { "Cannot have zero candidates" } + + val distinctCandidates = candidates.distinctBy { it.callableId } + return distinctCandidates.singleOrNull() + ?: error("Expected all candidates to have same callableId, but got: ${distinctCandidates.map { it.callableId }}") + } + override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) { super.visitResolvedQualifier(resolvedQualifier) @@ -358,6 +395,8 @@ private class ShortenCommandImpl( } } +private fun CallableId.asImportableFqName(): FqName? = if (classId == null) packageName.child(callableName) else null + private fun KtElement.getDotQualifiedExpressionForSelector(): KtDotQualifiedExpression? = getQualifiedExpressionForSelector() as? KtDotQualifiedExpression diff --git a/idea/testData/shortenRefsFir/calls/functionInSameFileAmbiguous.kt b/idea/testData/shortenRefsFir/calls/functionInSameFileAmbiguous.kt new file mode 100644 index 00000000000..61bccdd046e --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/functionInSameFileAmbiguous.kt @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +fun foo(i: Int) {} + +fun foo(s: String) {} + +fun usage() { + test.foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/functionInSameFileAmbiguous.kt.after b/idea/testData/shortenRefsFir/calls/functionInSameFileAmbiguous.kt.after new file mode 100644 index 00000000000..2c25ff3226b --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/functionInSameFileAmbiguous.kt.after @@ -0,0 +1,10 @@ +// FIR_COMPARISON +package test + +fun foo(i: Int) {} + +fun foo(s: String) {} + +fun usage() { + foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.dependency.kt b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.dependency.kt new file mode 100644 index 00000000000..31d25cffa32 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.dependency.kt @@ -0,0 +1,5 @@ +package dependency + +fun foo(s: String) {} + +fun foo(i: Int) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.kt b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.kt new file mode 100644 index 00000000000..ab8b588a32d --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +fun usage() { + dependency.foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.kt.after b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.kt.after new file mode 100644 index 00000000000..26a25b648cd --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionAmbiguous.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.foo + +fun usage() { + foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.dependency.kt b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.dependency.kt new file mode 100644 index 00000000000..3888aa931c6 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +fun foo() {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.kt b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.kt new file mode 100644 index 00000000000..1f183d298a4 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.kt @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +fun foo() {} + +fun usage() { + dependency.foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.kt.after b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.kt.after new file mode 100644 index 00000000000..314619bef0c --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionConflictsWithImported.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +fun foo() {} + +fun usage() { + dependency.foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.dependency.kt b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.dependency.kt new file mode 100644 index 00000000000..47bcf393d6c --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +fun foo(a: Any) {} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.kt b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.kt new file mode 100644 index 00000000000..ab8b588a32d --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +fun usage() { + dependency.foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.kt.after b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.kt.after new file mode 100644 index 00000000000..26a25b648cd --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionMissingArg.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.foo + +fun usage() { + foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.dependency.kt b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.dependency.kt new file mode 100644 index 00000000000..cb273c2fb91 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +fun foo() {} diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.kt b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.kt new file mode 100644 index 00000000000..ab8b588a32d --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.kt @@ -0,0 +1,6 @@ +// FIR_COMPARISON +package test + +fun usage() { + dependency.foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.kt.after b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.kt.after new file mode 100644 index 00000000000..26a25b648cd --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelFunctionNoArgs.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.foo + +fun usage() { + foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.dependency.kt b/idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.dependency.kt new file mode 100644 index 00000000000..9bf4a365e82 --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.dependency.kt @@ -0,0 +1,3 @@ +package dependency + +class Foo \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.kt b/idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.kt new file mode 100644 index 00000000000..26c83e93c8e --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.kt @@ -0,0 +1,6 @@ +// FIR_IGNORE +package test + +fun usage() { + dependency.Foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.kt.after b/idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.kt.after new file mode 100644 index 00000000000..62e6e9b58db --- /dev/null +++ b/idea/testData/shortenRefsFir/calls/notImportedTopLevelTypeConstructorNoArgs.kt.after @@ -0,0 +1,8 @@ +// FIR_COMPARISON +package test + +import dependency.Foo + +fun usage() { + Foo() +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt b/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt index 82556f68718..d890c3ea23a 100644 --- a/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt +++ b/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IGNORE package test fun test() {} diff --git a/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt index db9b1eae096..c5412878b54 100644 --- a/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt +++ b/idea/testData/shortenRefsFir/types/ParameterTypeConflictingTopLevelClassUsed.kt @@ -1,4 +1,4 @@ -// FIR_COMPARISON +// FIR_IGNORE package test class Foo From 8020424b93248e385c0995f215354d51547411b6 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 19 Jan 2021 18:37:08 +0300 Subject: [PATCH 051/368] FIR IDE: Remove fake root prefix even when the element is not shortened --- .../FirShortenRefsTestGenerated.java | 23 +++++++--- .../fir/components/KtFirReferenceShortener.kt | 43 ++++++++++++++++--- .../rootPackageShortenFakeRootPackage.kt | 10 ----- .../rootPackageShortenFakeRootPackage.kt | 18 ++++++++ ...rootPackageShortenFakeRootPackage.kt.after | 8 ++++ 5 files changed, 82 insertions(+), 20 deletions(-) delete mode 100644 idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt create mode 100644 idea/testData/shortenRefsFir/fakeRootPackage/rootPackageShortenFakeRootPackage.kt rename idea/testData/shortenRefsFir/{calls => fakeRootPackage}/rootPackageShortenFakeRootPackage.kt.after (59%) diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java index e0c9819ff0a..f7579af856f 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/FirShortenRefsTestGenerated.java @@ -126,11 +126,6 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { runTest("idea/testData/shortenRefsFir/calls/rootPackage.kt"); } - @TestMetadata("rootPackageShortenFakeRootPackage.kt") - public void testRootPackageShortenFakeRootPackage() throws Exception { - runTest("idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt"); - } - @TestMetadata("selfReferencingFunction.kt") public void testSelfReferencingFunction() throws Exception { runTest("idea/testData/shortenRefsFir/calls/selfReferencingFunction.kt"); @@ -142,6 +137,24 @@ public class FirShortenRefsTestGenerated extends AbstractFirShortenRefsTest { } } + @TestMetadata("idea/testData/shortenRefsFir/fakeRootPackage") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FakeRootPackage extends AbstractFirShortenRefsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestWithMuting, this, testDataFilePath); + } + + public void testAllFilesPresentInFakeRootPackage() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/shortenRefsFir/fakeRootPackage"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("rootPackageShortenFakeRootPackage.kt") + public void testRootPackageShortenFakeRootPackage() throws Exception { + runTest("idea/testData/shortenRefsFir/fakeRootPackage/rootPackageShortenFakeRootPackage.kt"); + } + } + @TestMetadata("idea/testData/shortenRefsFir/quailfiers") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 23ab798fed2..40013c40c35 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -11,6 +11,7 @@ import com.intellij.psi.SmartPsiElementPointer import com.intellij.util.containers.addIfNotNull import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClass import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.expressions.FirFunctionCall @@ -209,6 +210,17 @@ internal class KtFirReferenceShortener( if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { addTypeToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelTypeElement) + } else { + addFakePackagePrefixToShortenIfPresent(mostTopLevelTypeElement) + } + } + + private fun addFakePackagePrefixToShortenIfPresent(typeElement: KtUserType) { + val deepestTypeWithQualifier = typeElement.qualifiersWithSelf.last().parent as? KtUserType + ?: error("Type element should have at least one qualifier, instead it was ${typeElement.text}") + + if (deepestTypeWithQualifier.hasFakeRootPrefix()) { + addTypeToShorten(deepestTypeWithQualifier) } } @@ -260,11 +272,17 @@ internal class KtFirReferenceShortener( val scopes = findScopesAtPosition(callExpression, namesToImport) ?: return val availableCallables = findFunctionsInScopes(scopes, callableId.callableName) - if (availableCallables.isEmpty()) { - val additionalImport = callableId.asImportableFqName() ?: return - addElementToImportAndShorten(additionalImport, qualifiedCallExpression) - } else if (availableCallables.all { it.callableId == callableId }) { - addElementToShorten(qualifiedCallExpression) + when { + availableCallables.isEmpty() -> { + val additionalImport = callableId.asImportableFqName() ?: return + addElementToImportAndShorten(additionalImport, qualifiedCallExpression) + } + availableCallables.all { it.callableId == callableId } -> { + addElementToShorten(qualifiedCallExpression) + } + else -> { + addFakePackagePrefixToShortenIfPresent(qualifiedCallExpression) + } } } @@ -346,6 +364,15 @@ internal class KtFirReferenceShortener( if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { addElementToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelQualifier) + } else { + addFakePackagePrefixToShortenIfPresent(mostTopLevelQualifier) + } + } + + private fun addFakePackagePrefixToShortenIfPresent(wholeQualifiedExpression: KtDotQualifiedExpression) { + val deepestQualifier = wholeQualifiedExpression.qualifiersWithSelf.last() + if (deepestQualifier.hasFakeRootPrefix()) { + addElementToShorten(deepestQualifier) } } @@ -395,6 +422,12 @@ private class ShortenCommandImpl( } } +private fun KtUserType.hasFakeRootPrefix(): Boolean = + qualifier?.referencedName == ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE + +private fun KtDotQualifiedExpression.hasFakeRootPrefix(): Boolean = + (receiverExpression as? KtNameReferenceExpression)?.getReferencedName() == ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE + private fun CallableId.asImportableFqName(): FqName? = if (classId == null) packageName.child(callableName) else null private fun KtElement.getDotQualifiedExpressionForSelector(): KtDotQualifiedExpression? = diff --git a/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt b/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt deleted file mode 100644 index d890c3ea23a..00000000000 --- a/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt +++ /dev/null @@ -1,10 +0,0 @@ -// FIR_IGNORE -package test - -fun test() {} - -fun usage() { - fun test() {} - - _root_ide_package_.test.test() -} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/fakeRootPackage/rootPackageShortenFakeRootPackage.kt b/idea/testData/shortenRefsFir/fakeRootPackage/rootPackageShortenFakeRootPackage.kt new file mode 100644 index 00000000000..58fa8373070 --- /dev/null +++ b/idea/testData/shortenRefsFir/fakeRootPackage/rootPackageShortenFakeRootPackage.kt @@ -0,0 +1,18 @@ +// FIR_COMPARISON +package test + +class Test + +fun test() {} + +fun usage() { + class Test + + fun test() {} + + + _root_ide_package_.test.test() + _root_ide_package_.test.Test + val t: _root_ide_package_.test.Test + +} \ No newline at end of file diff --git a/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt.after b/idea/testData/shortenRefsFir/fakeRootPackage/rootPackageShortenFakeRootPackage.kt.after similarity index 59% rename from idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt.after rename to idea/testData/shortenRefsFir/fakeRootPackage/rootPackageShortenFakeRootPackage.kt.after index ea300498b7a..6a5a5f26126 100644 --- a/idea/testData/shortenRefsFir/calls/rootPackageShortenFakeRootPackage.kt.after +++ b/idea/testData/shortenRefsFir/fakeRootPackage/rootPackageShortenFakeRootPackage.kt.after @@ -1,10 +1,18 @@ // FIR_COMPARISON package test +class Test + fun test() {} fun usage() { + class Test + fun test() {} + test.test() + test.Test + val t: test.Test + } \ No newline at end of file From c0a4301179b8bf041812aa632b3764a2ccc67d75 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Thu, 4 Feb 2021 15:01:38 +0300 Subject: [PATCH 052/368] FIR IDE: Enhance check messages in `KtFirReferenceShortener` --- .../api/fir/components/KtFirReferenceShortener.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 40013c40c35..a87f41cf98e 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -206,7 +206,9 @@ internal class KtFirReferenceShortener( val (mostTopLevelClassId, mostTopLevelTypeElement) = allClassIds.zip(allTypeElements).last() val availableClassifier = findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) - check(availableClassifier?.classId != mostTopLevelClassId) { "This should not be true" } + check(availableClassifier?.classId != mostTopLevelClassId) { + "If this condition were true, we would have exited from the loop on the last iteration. ClassId = $mostTopLevelClassId" + } if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { addTypeToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelTypeElement) @@ -360,7 +362,9 @@ internal class KtFirReferenceShortener( val (mostTopLevelClassId, mostTopLevelQualifier) = allClassIds.zip(allQualifiers).last() val availableClassifier = findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) - check(availableClassifier?.classId != mostTopLevelClassId) { "This should not be true" } + check(availableClassifier?.classId != mostTopLevelClassId) { + "If this condition were true, we would have exited from the loop on the last iteration. ClassId = $mostTopLevelClassId" + } if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { addElementToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelQualifier) From 798c4d24850c6e15e41e11d95f1b9fe0034f6ea8 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Thu, 4 Feb 2021 16:33:24 +0300 Subject: [PATCH 053/368] FIR IDE: Create `FirResolvedImport`s without fake PSI --- .../fir/components/KtFirReferenceShortener.kt | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index a87f41cf98e..9bf2b12ac56 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.project.Project import com.intellij.psi.SmartPsiElementPointer import com.intellij.util.containers.addIfNotNull import org.jetbrains.kotlin.descriptors.ClassKind @@ -14,6 +13,8 @@ import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClass import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.builder.buildImport +import org.jetbrains.kotlin.fir.declarations.builder.buildResolvedImport import org.jetbrains.kotlin.fir.expressions.FirFunctionCall import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression @@ -23,6 +24,8 @@ import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeAmbiguityError +import org.jetbrains.kotlin.fir.resolve.firSymbolProvider +import org.jetbrains.kotlin.fir.resolve.transformers.resolveToPackageOrClass import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.getFunctions import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractStarImportingScope @@ -39,7 +42,6 @@ import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirModuleResolveState import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFir import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFirOfType -import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFirSafe import org.jetbrains.kotlin.idea.frontend.api.ValidityToken import org.jetbrains.kotlin.idea.frontend.api.components.KtReferenceShortener import org.jetbrains.kotlin.idea.frontend.api.components.ShortenCommand @@ -51,7 +53,6 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector -import org.jetbrains.kotlin.resolve.ImportPath internal class KtFirReferenceShortener( override val analysisSession: KtFirAnalysisSession, @@ -134,30 +135,34 @@ internal class KtFirReferenceShortener( val result = buildList { addAll(towerDataContext.nonLocalTowerDataElements.mapNotNull { it.scope }) - addIfNotNull(createFakeImportingScope(position.project, newImports)) + addIfNotNull(createFakeImportingScope(newImports)) addAll(towerDataContext.localScopes) } return result.asReversed() } - private fun createFakeImportingScope( - project: Project, - newImports: List - ): FirScope? { - if (newImports.isEmpty()) return null - - val psiFactory = KtPsiFactory(project) - - val resolvedNewImports = newImports - .map { psiFactory.createImportDirective(ImportPath(it, isAllUnder = false)) } - .mapNotNull { it.getOrBuildFirSafe(firResolveState) } - + private fun createFakeImportingScope(newImports: List): FirScope? { + val resolvedNewImports = newImports.mapNotNull { createFakeResolvedImport(it) } if (resolvedNewImports.isEmpty()) return null return FirExplicitSimpleImportingScope(resolvedNewImports, firResolveState.rootModuleSession, ScopeSession()) } + private fun createFakeResolvedImport(fqNameToImport: FqName): FirResolvedImport? { + val packageOrClass = resolveToPackageOrClass(firResolveState.rootModuleSession.firSymbolProvider, fqNameToImport) ?: return null + + val delegateImport = buildImport { + importedFqName = fqNameToImport + isAllUnder = false + } + + return buildResolvedImport { + delegate = delegateImport + packageFqName = packageOrClass.packageFqName + } + } + private inner class TypesCollectingVisitor( private val namesToImport: MutableList, private val typesToShorten: MutableList, From 7478b8d18966ead91a988f8bcd0c65f81eac6ac1 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Fri, 5 Feb 2021 15:27:43 +0300 Subject: [PATCH 054/368] FIR IDE: Use single `TextRange` as selection instead of two ints --- .../kotlin/shortenRefs/AbstractFirShortenRefsTest.kt | 5 +++-- .../jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt | 4 +++- .../idea/frontend/api/components/KtReferenceShortener.kt | 3 ++- .../frontend/api/fir/components/KtFirReferenceShortener.kt | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt index ba9665c218a..10b99b09299 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/shortenRefs/AbstractFirShortenRefsTest.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.shortenRefs import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.AbstractImportsTest import org.jetbrains.kotlin.idea.frontend.api.analyze import org.jetbrains.kotlin.idea.util.application.executeWriteCommand @@ -19,12 +20,12 @@ abstract class AbstractFirShortenRefsTest : AbstractImportsTest() { val selectionModel = myFixture.editor.selectionModel if (!selectionModel.hasSelection()) error("No selection in input file") - val (startOffset, endOffset) = runReadAction { selectionModel.selectionStart to selectionModel.selectionEnd } + val selection = runReadAction { TextRange(selectionModel.selectionStart, selectionModel.selectionEnd) } val shortenings = executeOnPooledThread { runReadAction { analyze(file) { - collectPossibleReferenceShortenings(file, startOffset, endOffset) + collectPossibleReferenceShortenings(file, selection) } } } diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt index a7a001ef9b3..cf643ccf248 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.idea.frontend.api +import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement import org.jetbrains.kotlin.idea.frontend.api.calls.KtCall import org.jetbrains.kotlin.idea.frontend.api.components.* @@ -179,5 +180,6 @@ abstract class KtAnalysisSession(final override val token: ValidityToken) : Vali fun KtReturnExpression.getReturnTargetSymbol(): KtCallableSymbol? = expressionHandlingComponent.getReturnExpressionTargetSymbol(this) - fun collectPossibleReferenceShortenings(file: KtFile, from: Int, to: Int) = referenceShortener.collectShortenings(file, from, to) + fun collectPossibleReferenceShortenings(file: KtFile, selection: TextRange): ShortenCommand = + referenceShortener.collectShortenings(file, selection) } diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt index 7e5ac143ef2..311f50194c0 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt @@ -5,10 +5,11 @@ package org.jetbrains.kotlin.idea.frontend.api.components +import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.psi.KtFile abstract class KtReferenceShortener : KtAnalysisSessionComponent() { - abstract fun collectShortenings(file: KtFile, from: Int, to: Int): ShortenCommand + abstract fun collectShortenings(file: KtFile, selection: TextRange): ShortenCommand } interface ShortenCommand { diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 9bf2b12ac56..1c198f076ab 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.util.TextRange import com.intellij.psi.SmartPsiElementPointer import com.intellij.util.containers.addIfNotNull import org.jetbrains.kotlin.descriptors.ClassKind @@ -59,7 +60,7 @@ internal class KtFirReferenceShortener( override val token: ValidityToken, override val firResolveState: FirModuleResolveState, ) : KtReferenceShortener(), KtFirAnalysisSessionComponent { - override fun collectShortenings(file: KtFile, from: Int, to: Int): ShortenCommand { + override fun collectShortenings(file: KtFile, selection: TextRange): ShortenCommand { resolveFileToBodyResolve(file) val firFile = file.getOrBuildFirOfType(firResolveState) From 9a464ae9c40d7287279ae4885a18817245fe141c Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 9 Feb 2021 16:22:12 +0300 Subject: [PATCH 055/368] FIR IDE: Merge all collectors visitors to a single visitor --- .../fir/components/KtFirReferenceShortener.kt | 121 ++++++++---------- 1 file changed, 54 insertions(+), 67 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 1c198f076ab..d058cedab7a 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -64,19 +64,14 @@ internal class KtFirReferenceShortener( resolveFileToBodyResolve(file) val firFile = file.getOrBuildFirOfType(firResolveState) - val namesToImport = mutableListOf() - - val typesToShorten = mutableListOf() - val callsToShorten = mutableListOf() - - firFile.acceptChildren(TypesCollectingVisitor(namesToImport, typesToShorten)) - firFile.acceptChildren(CallsCollectingVisitor(namesToImport, callsToShorten)) + val collector = ElementsToShortenCollector() + firFile.acceptChildren(collector) return ShortenCommandImpl( file, - namesToImport.distinct(), - typesToShorten.distinct().map { it.createSmartPointer() }, - callsToShorten.distinct().map { it.createSmartPointer() } + collector.namesToImport.distinct(), + collector.typesToShorten.distinct().map { it.createSmartPointer() }, + collector.qualifiersToShorten.distinct().map { it.createSmartPointer() } ) } @@ -164,10 +159,11 @@ internal class KtFirReferenceShortener( } } - private inner class TypesCollectingVisitor( - private val namesToImport: MutableList, - private val typesToShorten: MutableList, - ) : FirVisitorVoid() { + private inner class ElementsToShortenCollector : FirVisitorVoid() { + val namesToImport: MutableList = mutableListOf() + val typesToShorten: MutableList = mutableListOf() + val qualifiersToShorten: MutableList = mutableListOf() + override fun visitElement(element: FirElement) { element.acceptChildren(this) } @@ -240,14 +236,47 @@ internal class KtFirReferenceShortener( namesToImport.add(classFqName) typesToShorten.add(mostTopLevelTypeElement) } - } - private inner class CallsCollectingVisitor( - private val namesToImport: MutableList, - private val callsToShorten: MutableList - ) : FirVisitorVoid() { - override fun visitElement(element: FirElement) { - element.acceptChildren(this) + override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) { + super.visitResolvedQualifier(resolvedQualifier) + + val wholeClassQualifier = resolvedQualifier.classId ?: return + val wholeQualifierElement = when (val qualifierPsi = resolvedQualifier.psi) { + is KtDotQualifiedExpression -> qualifierPsi + is KtNameReferenceExpression -> qualifierPsi.getDotQualifiedExpressionForSelector() ?: return + else -> return + } + + collectQualifierIfNeedsToBeShortened(wholeClassQualifier, wholeQualifierElement) + } + + private fun collectQualifierIfNeedsToBeShortened(wholeClassQualifier: ClassId, wholeQualifierElement: KtDotQualifiedExpression) { + val positionScopes = findScopesAtPosition(wholeQualifierElement, namesToImport) ?: return + + val allClassIds = wholeClassQualifier.outerClassesWithSelf + val allQualifiers = wholeQualifierElement.qualifiersWithSelf + + for ((classId, qualifier) in allClassIds.zip(allQualifiers)) { + val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId + + if (firstFoundClass == classId) { + addElementToShorten(qualifier) + return + } + } + + val (mostTopLevelClassId, mostTopLevelQualifier) = allClassIds.zip(allQualifiers).last() + val availableClassifier = findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) + + check(availableClassifier?.classId != mostTopLevelClassId) { + "If this condition were true, we would have exited from the loop on the last iteration. ClassId = $mostTopLevelClassId" + } + + if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { + addElementToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelQualifier) + } else { + addFakePackagePrefixToShortenIfPresent(mostTopLevelQualifier) + } } override fun visitResolvedNamedReference(resolvedNamedReference: FirResolvedNamedReference) { @@ -337,48 +366,6 @@ internal class KtFirReferenceShortener( ?: error("Expected all candidates to have same callableId, but got: ${distinctCandidates.map { it.callableId }}") } - override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) { - super.visitResolvedQualifier(resolvedQualifier) - - val wholeClassQualifier = resolvedQualifier.classId ?: return - val wholeQualifierElement = when (val qualifierPsi = resolvedQualifier.psi) { - is KtDotQualifiedExpression -> qualifierPsi - is KtNameReferenceExpression -> qualifierPsi.getDotQualifiedExpressionForSelector() ?: return - else -> return - } - - collectQualifierIfNeedsToBeShortened(wholeClassQualifier, wholeQualifierElement) - } - - private fun collectQualifierIfNeedsToBeShortened(wholeClassQualifier: ClassId, wholeQualifierElement: KtDotQualifiedExpression) { - val positionScopes = findScopesAtPosition(wholeQualifierElement, namesToImport) ?: return - - val allClassIds = wholeClassQualifier.outerClassesWithSelf - val allQualifiers = wholeQualifierElement.qualifiersWithSelf - - for ((classId, qualifier) in allClassIds.zip(allQualifiers)) { - val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId - - if (firstFoundClass == classId) { - addElementToShorten(qualifier) - return - } - } - - val (mostTopLevelClassId, mostTopLevelQualifier) = allClassIds.zip(allQualifiers).last() - val availableClassifier = findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) - - check(availableClassifier?.classId != mostTopLevelClassId) { - "If this condition were true, we would have exited from the loop on the last iteration. ClassId = $mostTopLevelClassId" - } - - if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { - addElementToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelQualifier) - } else { - addFakePackagePrefixToShortenIfPresent(mostTopLevelQualifier) - } - } - private fun addFakePackagePrefixToShortenIfPresent(wholeQualifiedExpression: KtDotQualifiedExpression) { val deepestQualifier = wholeQualifiedExpression.qualifiersWithSelf.last() if (deepestQualifier.hasFakeRootPrefix()) { @@ -387,12 +374,12 @@ internal class KtFirReferenceShortener( } private fun addElementToShorten(element: KtDotQualifiedExpression) { - callsToShorten.add(element) + qualifiersToShorten.add(element) } private fun addElementToImportAndShorten(nameToImport: FqName, element: KtDotQualifiedExpression) { namesToImport.add(nameToImport) - callsToShorten.add(element) + qualifiersToShorten.add(element) } } @@ -410,7 +397,7 @@ private class ShortenCommandImpl( val targetFile: KtFile, val importsToAdd: List, val typesToShorten: List>, - val callsToShorten: List>, + val qualifiersToShorten: List>, ) : ShortenCommand { override fun invokeShortening() { @@ -425,7 +412,7 @@ private class ShortenCommandImpl( type.deleteQualifier() } - for (callPointer in callsToShorten) { + for (callPointer in qualifiersToShorten) { val call = callPointer.element ?: continue call.deleteQualifier() } From c89380fc36913102df8aaa77993849101ebfa100 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 9 Feb 2021 16:51:23 +0300 Subject: [PATCH 056/368] FIR IDE: Refactor `ElementsToShortenCollector` --- .../fir/components/KtFirReferenceShortener.kt | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index d058cedab7a..4b1c33a9478 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -175,6 +175,24 @@ internal class KtFirReferenceShortener( resolvedTypeRef.delegatedTypeRef?.accept(this) } + override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) { + super.visitResolvedQualifier(resolvedQualifier) + + processTypeQualifier(resolvedQualifier) + } + + override fun visitResolvedNamedReference(resolvedNamedReference: FirResolvedNamedReference) { + super.visitResolvedNamedReference(resolvedNamedReference) + + processPropertyReference(resolvedNamedReference) + } + + override fun visitFunctionCall(functionCall: FirFunctionCall) { + super.visitFunctionCall(functionCall) + + processFunctionCall(functionCall) + } + private fun processTypeRef(resolvedTypeRef: FirResolvedTypeRef) { val wholeTypeReference = resolvedTypeRef.psi as? KtTypeReference ?: return @@ -237,9 +255,7 @@ internal class KtFirReferenceShortener( typesToShorten.add(mostTopLevelTypeElement) } - override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) { - super.visitResolvedQualifier(resolvedQualifier) - + private fun processTypeQualifier(resolvedQualifier: FirResolvedQualifier) { val wholeClassQualifier = resolvedQualifier.classId ?: return val wholeQualifierElement = when (val qualifierPsi = resolvedQualifier.psi) { is KtDotQualifiedExpression -> qualifierPsi @@ -279,9 +295,7 @@ internal class KtFirReferenceShortener( } } - override fun visitResolvedNamedReference(resolvedNamedReference: FirResolvedNamedReference) { - super.visitResolvedNamedReference(resolvedNamedReference) - + private fun processPropertyReference(resolvedNamedReference: FirResolvedNamedReference) { val referenceExpression = resolvedNamedReference.psi as? KtNameReferenceExpression val qualifiedProperty = referenceExpression?.getDotQualifiedExpressionForSelector() ?: return @@ -295,9 +309,7 @@ internal class KtFirReferenceShortener( } } - override fun visitFunctionCall(functionCall: FirFunctionCall) { - super.visitFunctionCall(functionCall) - + private fun processFunctionCall(functionCall: FirFunctionCall) { if (!canBePossibleToDropReceiver(functionCall)) return val callExpression = functionCall.psi as? KtCallExpression ?: return @@ -381,16 +393,16 @@ internal class KtFirReferenceShortener( namesToImport.add(nameToImport) qualifiersToShorten.add(element) } + + private val ClassId.outerClassesWithSelf: Sequence + get() = generateSequence(this) { it.outerClassId } + + private val KtUserType.qualifiersWithSelf: Sequence + get() = generateSequence(this) { it.qualifier } + + private val KtDotQualifiedExpression.qualifiersWithSelf: Sequence + get() = generateSequence(this) { it.receiverExpression as? KtDotQualifiedExpression } } - - private val ClassId.outerClassesWithSelf: Sequence - get() = generateSequence(this) { it.outerClassId } - - private val KtUserType.qualifiersWithSelf: Sequence - get() = generateSequence(this) { it.qualifier } - - private val KtDotQualifiedExpression.qualifiersWithSelf: Sequence - get() = generateSequence(this) { it.receiverExpression as? KtDotQualifiedExpression } } private class ShortenCommandImpl( From 09ba927680b243c4d227024cf153dad5bd8b8500 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 9 Feb 2021 17:31:22 +0300 Subject: [PATCH 057/368] FIR IDE: Decouple `ElementsToShortenCollector` from `KtFirReferenceShortener` --- .../fir/components/KtFirReferenceShortener.kt | 532 +++++++++--------- 1 file changed, 271 insertions(+), 261 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 4b1c33a9478..a64af5faa26 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -11,6 +11,7 @@ import com.intellij.psi.SmartPsiElementPointer import com.intellij.util.containers.addIfNotNull import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE import org.jetbrains.kotlin.fir.analysis.checkers.toRegularClass import org.jetbrains.kotlin.fir.declarations.* @@ -37,6 +38,7 @@ import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.classId import org.jetbrains.kotlin.fir.types.lowerBoundIfFlexible import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid @@ -60,11 +62,13 @@ internal class KtFirReferenceShortener( override val token: ValidityToken, override val firResolveState: FirModuleResolveState, ) : KtReferenceShortener(), KtFirAnalysisSessionComponent { + private val context = FirShorteningContext(firResolveState) + override fun collectShortenings(file: KtFile, selection: TextRange): ShortenCommand { resolveFileToBodyResolve(file) val firFile = file.getOrBuildFirOfType(firResolveState) - val collector = ElementsToShortenCollector() + val collector = ElementsToShortenCollector(context) firFile.acceptChildren(collector) return ShortenCommandImpl( @@ -75,9 +79,21 @@ internal class KtFirReferenceShortener( ) } - private data class AvailableClassifier(val classId: ClassId, val isFromStarOrPackageImport: Boolean) + private fun resolveFileToBodyResolve(file: KtFile) { + for (declaration in file.declarations) { + declaration.getOrBuildFir(firResolveState) // temporary hack, resolves declaration to BODY_RESOLVE stage + } + } +} - private fun findFirstClassifierInScopesByName(positionScopes: List, targetClassName: Name): AvailableClassifier? { +private data class AvailableClassifier(val classId: ClassId, val isFromStarOrPackageImport: Boolean) + +private class FirShorteningContext(val firResolveState: FirModuleResolveState) { + + private val firSession: FirSession + get() = firResolveState.rootModuleSession + + fun findFirstClassifierInScopesByName(positionScopes: List, targetClassName: Name): AvailableClassifier? { for (scope in positionScopes) { val classifierSymbol = scope.findFirstClassifierByName(targetClassName) ?: continue val classifierLookupTag = classifierSymbol.toLookupTag() as? ConeClassLikeLookupTag ?: continue @@ -91,20 +107,14 @@ internal class KtFirReferenceShortener( return null } - private fun findFunctionsInScopes(scopes: List, name: Name): List { + fun findFunctionsInScopes(scopes: List, name: Name): List { return scopes.flatMap { it.getFunctions(name) } } - private fun findSinglePropertyInScopesByName(scopes: List, name: Name): FirVariableSymbol<*>? { + fun findSinglePropertyInScopesByName(scopes: List, name: Name): FirVariableSymbol<*>? { return scopes.asSequence().mapNotNull { it.getSinglePropertyByName(name) }.singleOrNull() } - private fun resolveFileToBodyResolve(file: KtFile) { - for (declaration in file.declarations) { - declaration.getOrBuildFir(firResolveState) // temporary hack, resolves declaration to BODY_RESOLVE stage - } - } - private fun FirScope.findFirstClassifierByName(name: Name): FirClassifierSymbol<*>? { var element: FirClassifierSymbol<*>? = null @@ -117,16 +127,12 @@ internal class KtFirReferenceShortener( return element } - @OptIn(ExperimentalStdlibApi::class) - private fun FirScope.getSingleFunctionByName(name: Name): FirNamedFunctionSymbol? = - buildList { processFunctionsByName(name, this::add) }.singleOrNull() - @OptIn(ExperimentalStdlibApi::class) private fun FirScope.getSinglePropertyByName(name: Name): FirVariableSymbol<*>? = buildList { processPropertiesByName(name, this::add) }.singleOrNull() @OptIn(ExperimentalStdlibApi::class) - private fun findScopesAtPosition(position: KtElement, newImports: List): List? { + fun findScopesAtPosition(position: KtElement, newImports: List): List? { val towerDataContext = firResolveState.getTowerDataContextForElement(position) ?: return null val result = buildList { @@ -142,11 +148,11 @@ internal class KtFirReferenceShortener( val resolvedNewImports = newImports.mapNotNull { createFakeResolvedImport(it) } if (resolvedNewImports.isEmpty()) return null - return FirExplicitSimpleImportingScope(resolvedNewImports, firResolveState.rootModuleSession, ScopeSession()) + return FirExplicitSimpleImportingScope(resolvedNewImports, firSession, ScopeSession()) } private fun createFakeResolvedImport(fqNameToImport: FqName): FirResolvedImport? { - val packageOrClass = resolveToPackageOrClass(firResolveState.rootModuleSession.firSymbolProvider, fqNameToImport) ?: return null + val packageOrClass = resolveToPackageOrClass(firSession.firSymbolProvider, fqNameToImport) ?: return null val delegateImport = buildImport { importedFqName = fqNameToImport @@ -159,252 +165,256 @@ internal class KtFirReferenceShortener( } } - private inner class ElementsToShortenCollector : FirVisitorVoid() { - val namesToImport: MutableList = mutableListOf() - val typesToShorten: MutableList = mutableListOf() - val qualifiersToShorten: MutableList = mutableListOf() - - override fun visitElement(element: FirElement) { - element.acceptChildren(this) - } - - override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) { - processTypeRef(resolvedTypeRef) - - resolvedTypeRef.acceptChildren(this) - resolvedTypeRef.delegatedTypeRef?.accept(this) - } - - override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) { - super.visitResolvedQualifier(resolvedQualifier) - - processTypeQualifier(resolvedQualifier) - } - - override fun visitResolvedNamedReference(resolvedNamedReference: FirResolvedNamedReference) { - super.visitResolvedNamedReference(resolvedNamedReference) - - processPropertyReference(resolvedNamedReference) - } - - override fun visitFunctionCall(functionCall: FirFunctionCall) { - super.visitFunctionCall(functionCall) - - processFunctionCall(functionCall) - } - - private fun processTypeRef(resolvedTypeRef: FirResolvedTypeRef) { - val wholeTypeReference = resolvedTypeRef.psi as? KtTypeReference ?: return - - val wholeClassifierId = resolvedTypeRef.type.lowerBoundIfFlexible().classId ?: return - val wholeTypeElement = wholeTypeReference.typeElement.unwrapNullable() as? KtUserType ?: return - - if (wholeTypeElement.qualifier == null) return - - collectTypeIfNeedsToBeShortened(wholeClassifierId, wholeTypeElement) - } - - private fun collectTypeIfNeedsToBeShortened(wholeClassifierId: ClassId, wholeTypeElement: KtUserType) { - val allClassIds = wholeClassifierId.outerClassesWithSelf - val allTypeElements = wholeTypeElement.qualifiersWithSelf - - val positionScopes = findScopesAtPosition(wholeTypeElement, namesToImport) ?: return - - for ((classId, typeElement) in allClassIds.zip(allTypeElements)) { - // if qualifier is null, then this type have no package and thus cannot be shortened - if (typeElement.qualifier == null) return - - val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId - - if (firstFoundClass == classId) { - addTypeToShorten(typeElement) - return - } - } - - // none class matched - val (mostTopLevelClassId, mostTopLevelTypeElement) = allClassIds.zip(allTypeElements).last() - val availableClassifier = findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) - - check(availableClassifier?.classId != mostTopLevelClassId) { - "If this condition were true, we would have exited from the loop on the last iteration. ClassId = $mostTopLevelClassId" - } - - if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { - addTypeToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelTypeElement) - } else { - addFakePackagePrefixToShortenIfPresent(mostTopLevelTypeElement) - } - } - - private fun addFakePackagePrefixToShortenIfPresent(typeElement: KtUserType) { - val deepestTypeWithQualifier = typeElement.qualifiersWithSelf.last().parent as? KtUserType - ?: error("Type element should have at least one qualifier, instead it was ${typeElement.text}") - - if (deepestTypeWithQualifier.hasFakeRootPrefix()) { - addTypeToShorten(deepestTypeWithQualifier) - } - } - - private fun addTypeToShorten(typeElement: KtUserType) { - typesToShorten.add(typeElement) - } - - private fun addTypeToImportAndShorten(classFqName: FqName, mostTopLevelTypeElement: KtUserType) { - namesToImport.add(classFqName) - typesToShorten.add(mostTopLevelTypeElement) - } - - private fun processTypeQualifier(resolvedQualifier: FirResolvedQualifier) { - val wholeClassQualifier = resolvedQualifier.classId ?: return - val wholeQualifierElement = when (val qualifierPsi = resolvedQualifier.psi) { - is KtDotQualifiedExpression -> qualifierPsi - is KtNameReferenceExpression -> qualifierPsi.getDotQualifiedExpressionForSelector() ?: return - else -> return - } - - collectQualifierIfNeedsToBeShortened(wholeClassQualifier, wholeQualifierElement) - } - - private fun collectQualifierIfNeedsToBeShortened(wholeClassQualifier: ClassId, wholeQualifierElement: KtDotQualifiedExpression) { - val positionScopes = findScopesAtPosition(wholeQualifierElement, namesToImport) ?: return - - val allClassIds = wholeClassQualifier.outerClassesWithSelf - val allQualifiers = wholeQualifierElement.qualifiersWithSelf - - for ((classId, qualifier) in allClassIds.zip(allQualifiers)) { - val firstFoundClass = findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId - - if (firstFoundClass == classId) { - addElementToShorten(qualifier) - return - } - } - - val (mostTopLevelClassId, mostTopLevelQualifier) = allClassIds.zip(allQualifiers).last() - val availableClassifier = findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) - - check(availableClassifier?.classId != mostTopLevelClassId) { - "If this condition were true, we would have exited from the loop on the last iteration. ClassId = $mostTopLevelClassId" - } - - if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { - addElementToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelQualifier) - } else { - addFakePackagePrefixToShortenIfPresent(mostTopLevelQualifier) - } - } - - private fun processPropertyReference(resolvedNamedReference: FirResolvedNamedReference) { - val referenceExpression = resolvedNamedReference.psi as? KtNameReferenceExpression - val qualifiedProperty = referenceExpression?.getDotQualifiedExpressionForSelector() ?: return - - val propertyId = (resolvedNamedReference.resolvedSymbol as? FirCallableSymbol<*>)?.callableId ?: return - - val scopes = findScopesAtPosition(qualifiedProperty, namesToImport) ?: return - val singleAvailableProperty = findSinglePropertyInScopesByName(scopes, propertyId.callableName) - - if (singleAvailableProperty?.callableId == propertyId) { - addElementToShorten(qualifiedProperty) - } - } - - private fun processFunctionCall(functionCall: FirFunctionCall) { - if (!canBePossibleToDropReceiver(functionCall)) return - - val callExpression = functionCall.psi as? KtCallExpression ?: return - val qualifiedCallExpression = callExpression.getDotQualifiedExpressionForSelector() ?: return - - val calleeReference = functionCall.calleeReference - val callableId = findUnambiguousReferencedCallableId(calleeReference) ?: return - - val scopes = findScopesAtPosition(callExpression, namesToImport) ?: return - val availableCallables = findFunctionsInScopes(scopes, callableId.callableName) - - when { - availableCallables.isEmpty() -> { - val additionalImport = callableId.asImportableFqName() ?: return - addElementToImportAndShorten(additionalImport, qualifiedCallExpression) - } - availableCallables.all { it.callableId == callableId } -> { - addElementToShorten(qualifiedCallExpression) - } - else -> { - addFakePackagePrefixToShortenIfPresent(qualifiedCallExpression) - } - } - } - - private fun canBePossibleToDropReceiver(functionCall: FirFunctionCall): Boolean { - // we can remove receiver only if it is a qualifier - val explicitReceiver = functionCall.explicitReceiver as? FirResolvedQualifier ?: return false - - // if there is no extension receiver necessary, then it can be removed - if (functionCall.extensionReceiver is FirNoReceiverExpression) return true - - val receiverType = explicitReceiver.typeRef.toRegularClass(firResolveState.rootModuleSession) ?: return true - return receiverType.classKind != ClassKind.OBJECT - } - - private fun findUnambiguousReferencedCallableId(namedReference: FirNamedReference): CallableId? { - val unambiguousSymbol = when (namedReference) { - is FirResolvedNamedReference -> namedReference.resolvedSymbol - is FirErrorNamedReference -> { - val candidateSymbol = namedReference.candidateSymbol - if (candidateSymbol !is FirErrorFunctionSymbol) { - candidateSymbol - } else { - getSingleUnambiguousCandidate(namedReference) - } - } - else -> null - } - - return (unambiguousSymbol as? FirCallableSymbol<*>)?.callableId - } - - /** - * If [namedReference] is ambiguous and all candidates point to the callables with same callableId, - * returns the first candidate; otherwise returns null. - */ - private fun getSingleUnambiguousCandidate(namedReference: FirErrorNamedReference): FirCallableSymbol<*>? { - val coneAmbiguityError = namedReference.diagnostic as? ConeAmbiguityError ?: return null - - val candidates = coneAmbiguityError.candidates.map { it as FirCallableSymbol<*> } - require(candidates.isNotEmpty()) { "Cannot have zero candidates" } - - val distinctCandidates = candidates.distinctBy { it.callableId } - return distinctCandidates.singleOrNull() - ?: error("Expected all candidates to have same callableId, but got: ${distinctCandidates.map { it.callableId }}") - } - - private fun addFakePackagePrefixToShortenIfPresent(wholeQualifiedExpression: KtDotQualifiedExpression) { - val deepestQualifier = wholeQualifiedExpression.qualifiersWithSelf.last() - if (deepestQualifier.hasFakeRootPrefix()) { - addElementToShorten(deepestQualifier) - } - } - - private fun addElementToShorten(element: KtDotQualifiedExpression) { - qualifiersToShorten.add(element) - } - - private fun addElementToImportAndShorten(nameToImport: FqName, element: KtDotQualifiedExpression) { - namesToImport.add(nameToImport) - qualifiersToShorten.add(element) - } - - private val ClassId.outerClassesWithSelf: Sequence - get() = generateSequence(this) { it.outerClassId } - - private val KtUserType.qualifiersWithSelf: Sequence - get() = generateSequence(this) { it.qualifier } - - private val KtDotQualifiedExpression.qualifiersWithSelf: Sequence - get() = generateSequence(this) { it.receiverExpression as? KtDotQualifiedExpression } + fun getRegularClass(typeRef: FirTypeRef): FirRegularClass? { + return typeRef.toRegularClass(firSession) } } +private class ElementsToShortenCollector(private val shorteningContext: FirShorteningContext) : FirVisitorVoid() { + val namesToImport: MutableList = mutableListOf() + val typesToShorten: MutableList = mutableListOf() + val qualifiersToShorten: MutableList = mutableListOf() + + override fun visitElement(element: FirElement) { + element.acceptChildren(this) + } + + override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) { + processTypeRef(resolvedTypeRef) + + resolvedTypeRef.acceptChildren(this) + resolvedTypeRef.delegatedTypeRef?.accept(this) + } + + override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) { + super.visitResolvedQualifier(resolvedQualifier) + + processTypeQualifier(resolvedQualifier) + } + + override fun visitResolvedNamedReference(resolvedNamedReference: FirResolvedNamedReference) { + super.visitResolvedNamedReference(resolvedNamedReference) + + processPropertyReference(resolvedNamedReference) + } + + override fun visitFunctionCall(functionCall: FirFunctionCall) { + super.visitFunctionCall(functionCall) + + processFunctionCall(functionCall) + } + + private fun processTypeRef(resolvedTypeRef: FirResolvedTypeRef) { + val wholeTypeReference = resolvedTypeRef.psi as? KtTypeReference ?: return + + val wholeClassifierId = resolvedTypeRef.type.lowerBoundIfFlexible().classId ?: return + val wholeTypeElement = wholeTypeReference.typeElement.unwrapNullable() as? KtUserType ?: return + + if (wholeTypeElement.qualifier == null) return + + collectTypeIfNeedsToBeShortened(wholeClassifierId, wholeTypeElement) + } + + private fun collectTypeIfNeedsToBeShortened(wholeClassifierId: ClassId, wholeTypeElement: KtUserType) { + val allClassIds = wholeClassifierId.outerClassesWithSelf + val allTypeElements = wholeTypeElement.qualifiersWithSelf + + val positionScopes = shorteningContext.findScopesAtPosition(wholeTypeElement, namesToImport) ?: return + + for ((classId, typeElement) in allClassIds.zip(allTypeElements)) { + // if qualifier is null, then this type have no package and thus cannot be shortened + if (typeElement.qualifier == null) return + + val firstFoundClass = shorteningContext.findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId + + if (firstFoundClass == classId) { + addTypeToShorten(typeElement) + return + } + } + + // none class matched + val (mostTopLevelClassId, mostTopLevelTypeElement) = allClassIds.zip(allTypeElements).last() + val availableClassifier = shorteningContext.findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) + + check(availableClassifier?.classId != mostTopLevelClassId) { + "If this condition were true, we would have exited from the loop on the last iteration. ClassId = $mostTopLevelClassId" + } + + if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { + addTypeToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelTypeElement) + } else { + addFakePackagePrefixToShortenIfPresent(mostTopLevelTypeElement) + } + } + + private fun addFakePackagePrefixToShortenIfPresent(typeElement: KtUserType) { + val deepestTypeWithQualifier = typeElement.qualifiersWithSelf.last().parent as? KtUserType + ?: error("Type element should have at least one qualifier, instead it was ${typeElement.text}") + + if (deepestTypeWithQualifier.hasFakeRootPrefix()) { + addTypeToShorten(deepestTypeWithQualifier) + } + } + + private fun addTypeToShorten(typeElement: KtUserType) { + typesToShorten.add(typeElement) + } + + private fun addTypeToImportAndShorten(classFqName: FqName, mostTopLevelTypeElement: KtUserType) { + namesToImport.add(classFqName) + typesToShorten.add(mostTopLevelTypeElement) + } + + private fun processTypeQualifier(resolvedQualifier: FirResolvedQualifier) { + val wholeClassQualifier = resolvedQualifier.classId ?: return + val wholeQualifierElement = when (val qualifierPsi = resolvedQualifier.psi) { + is KtDotQualifiedExpression -> qualifierPsi + is KtNameReferenceExpression -> qualifierPsi.getDotQualifiedExpressionForSelector() ?: return + else -> return + } + + collectQualifierIfNeedsToBeShortened(wholeClassQualifier, wholeQualifierElement) + } + + private fun collectQualifierIfNeedsToBeShortened(wholeClassQualifier: ClassId, wholeQualifierElement: KtDotQualifiedExpression) { + val positionScopes = shorteningContext.findScopesAtPosition(wholeQualifierElement, namesToImport) ?: return + + val allClassIds = wholeClassQualifier.outerClassesWithSelf + val allQualifiers = wholeQualifierElement.qualifiersWithSelf + + for ((classId, qualifier) in allClassIds.zip(allQualifiers)) { + val firstFoundClass = shorteningContext.findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId + + if (firstFoundClass == classId) { + addElementToShorten(qualifier) + return + } + } + + val (mostTopLevelClassId, mostTopLevelQualifier) = allClassIds.zip(allQualifiers).last() + val availableClassifier = shorteningContext.findFirstClassifierInScopesByName(positionScopes, mostTopLevelClassId.shortClassName) + + check(availableClassifier?.classId != mostTopLevelClassId) { + "If this condition were true, we would have exited from the loop on the last iteration. ClassId = $mostTopLevelClassId" + } + + if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { + addElementToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelQualifier) + } else { + addFakePackagePrefixToShortenIfPresent(mostTopLevelQualifier) + } + } + + private fun processPropertyReference(resolvedNamedReference: FirResolvedNamedReference) { + val referenceExpression = resolvedNamedReference.psi as? KtNameReferenceExpression + val qualifiedProperty = referenceExpression?.getDotQualifiedExpressionForSelector() ?: return + + val propertyId = (resolvedNamedReference.resolvedSymbol as? FirCallableSymbol<*>)?.callableId ?: return + + val scopes = shorteningContext.findScopesAtPosition(qualifiedProperty, namesToImport) ?: return + val singleAvailableProperty = shorteningContext.findSinglePropertyInScopesByName(scopes, propertyId.callableName) + + if (singleAvailableProperty?.callableId == propertyId) { + addElementToShorten(qualifiedProperty) + } + } + + private fun processFunctionCall(functionCall: FirFunctionCall) { + if (!canBePossibleToDropReceiver(functionCall)) return + + val callExpression = functionCall.psi as? KtCallExpression ?: return + val qualifiedCallExpression = callExpression.getDotQualifiedExpressionForSelector() ?: return + + val calleeReference = functionCall.calleeReference + val callableId = findUnambiguousReferencedCallableId(calleeReference) ?: return + + val scopes = shorteningContext.findScopesAtPosition(callExpression, namesToImport) ?: return + val availableCallables = shorteningContext.findFunctionsInScopes(scopes, callableId.callableName) + + when { + availableCallables.isEmpty() -> { + val additionalImport = callableId.asImportableFqName() ?: return + addElementToImportAndShorten(additionalImport, qualifiedCallExpression) + } + availableCallables.all { it.callableId == callableId } -> { + addElementToShorten(qualifiedCallExpression) + } + else -> { + addFakePackagePrefixToShortenIfPresent(qualifiedCallExpression) + } + } + } + + private fun canBePossibleToDropReceiver(functionCall: FirFunctionCall): Boolean { + // we can remove receiver only if it is a qualifier + val explicitReceiver = functionCall.explicitReceiver as? FirResolvedQualifier ?: return false + + // if there is no extension receiver necessary, then it can be removed + if (functionCall.extensionReceiver is FirNoReceiverExpression) return true + + val receiverType = shorteningContext.getRegularClass(explicitReceiver.typeRef) ?: return true + return receiverType.classKind != ClassKind.OBJECT + } + + private fun findUnambiguousReferencedCallableId(namedReference: FirNamedReference): CallableId? { + val unambiguousSymbol = when (namedReference) { + is FirResolvedNamedReference -> namedReference.resolvedSymbol + is FirErrorNamedReference -> { + val candidateSymbol = namedReference.candidateSymbol + if (candidateSymbol !is FirErrorFunctionSymbol) { + candidateSymbol + } else { + getSingleUnambiguousCandidate(namedReference) + } + } + else -> null + } + + return (unambiguousSymbol as? FirCallableSymbol<*>)?.callableId + } + + /** + * If [namedReference] is ambiguous and all candidates point to the callables with same callableId, + * returns the first candidate; otherwise returns null. + */ + private fun getSingleUnambiguousCandidate(namedReference: FirErrorNamedReference): FirCallableSymbol<*>? { + val coneAmbiguityError = namedReference.diagnostic as? ConeAmbiguityError ?: return null + + val candidates = coneAmbiguityError.candidates.map { it as FirCallableSymbol<*> } + require(candidates.isNotEmpty()) { "Cannot have zero candidates" } + + val distinctCandidates = candidates.distinctBy { it.callableId } + return distinctCandidates.singleOrNull() + ?: error("Expected all candidates to have same callableId, but got: ${distinctCandidates.map { it.callableId }}") + } + + private fun addFakePackagePrefixToShortenIfPresent(wholeQualifiedExpression: KtDotQualifiedExpression) { + val deepestQualifier = wholeQualifiedExpression.qualifiersWithSelf.last() + if (deepestQualifier.hasFakeRootPrefix()) { + addElementToShorten(deepestQualifier) + } + } + + private fun addElementToShorten(element: KtDotQualifiedExpression) { + qualifiersToShorten.add(element) + } + + private fun addElementToImportAndShorten(nameToImport: FqName, element: KtDotQualifiedExpression) { + namesToImport.add(nameToImport) + qualifiersToShorten.add(element) + } + + private val ClassId.outerClassesWithSelf: Sequence + get() = generateSequence(this) { it.outerClassId } + + private val KtUserType.qualifiersWithSelf: Sequence + get() = generateSequence(this) { it.qualifier } + + private val KtDotQualifiedExpression.qualifiersWithSelf: Sequence + get() = generateSequence(this) { it.receiverExpression as? KtDotQualifiedExpression } +} + private class ShortenCommandImpl( val targetFile: KtFile, val importsToAdd: List, From d202b0feb2cab4cd7be7607c3187542df4fb817f Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 9 Feb 2021 18:44:03 +0300 Subject: [PATCH 058/368] FIR IDE: Refactor `addElementToShorten` functions --- .../fir/components/KtFirReferenceShortener.kt | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index a64af5faa26..ef0266f06b8 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -242,7 +242,7 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort } if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { - addTypeToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelTypeElement) + addTypeToShorten(mostTopLevelTypeElement, mostTopLevelClassId.asSingleFqName()) } else { addFakePackagePrefixToShortenIfPresent(mostTopLevelTypeElement) } @@ -257,12 +257,8 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort } } - private fun addTypeToShorten(typeElement: KtUserType) { - typesToShorten.add(typeElement) - } - - private fun addTypeToImportAndShorten(classFqName: FqName, mostTopLevelTypeElement: KtUserType) { - namesToImport.add(classFqName) + private fun addTypeToShorten(mostTopLevelTypeElement: KtUserType, classFqName: FqName? = null) { + namesToImport.addIfNotNull(classFqName) typesToShorten.add(mostTopLevelTypeElement) } @@ -300,7 +296,7 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort } if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { - addElementToImportAndShorten(mostTopLevelClassId.asSingleFqName(), mostTopLevelQualifier) + addElementToShorten(mostTopLevelQualifier, mostTopLevelClassId.asSingleFqName()) } else { addFakePackagePrefixToShortenIfPresent(mostTopLevelQualifier) } @@ -335,7 +331,7 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort when { availableCallables.isEmpty() -> { val additionalImport = callableId.asImportableFqName() ?: return - addElementToImportAndShorten(additionalImport, qualifiedCallExpression) + addElementToShorten(qualifiedCallExpression, additionalImport) } availableCallables.all { it.callableId == callableId } -> { addElementToShorten(qualifiedCallExpression) @@ -396,12 +392,8 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort } } - private fun addElementToShorten(element: KtDotQualifiedExpression) { - qualifiersToShorten.add(element) - } - - private fun addElementToImportAndShorten(nameToImport: FqName, element: KtDotQualifiedExpression) { - namesToImport.add(nameToImport) + private fun addElementToShorten(element: KtDotQualifiedExpression, nameToImport: FqName? = null) { + namesToImport.addIfNotNull(nameToImport) qualifiersToShorten.add(element) } From dee4f4345b295c6625a8f7789487ee6ce039fcab Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 9 Feb 2021 18:52:25 +0300 Subject: [PATCH 059/368] FIR IDE: Add `ElementToShorten` sealed classes --- .../fir/components/KtFirReferenceShortener.kt | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index ef0266f06b8..54dbd5180dc 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -170,6 +170,10 @@ private class FirShorteningContext(val firResolveState: FirModuleResolveState) { } } +private sealed class ElementToShorten +private class ShortenType(val element: KtUserType, val nameToImport: FqName? = null) : ElementToShorten() +private class ShortenQualifier(val element: KtDotQualifiedExpression, val nameToImport: FqName? = null) : ElementToShorten() + private class ElementsToShortenCollector(private val shorteningContext: FirShorteningContext) : FirVisitorVoid() { val namesToImport: MutableList = mutableListOf() val typesToShorten: MutableList = mutableListOf() @@ -228,7 +232,7 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort val firstFoundClass = shorteningContext.findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId if (firstFoundClass == classId) { - addTypeToShorten(typeElement) + addElementToShorten(ShortenType(typeElement)) return } } @@ -242,7 +246,7 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort } if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { - addTypeToShorten(mostTopLevelTypeElement, mostTopLevelClassId.asSingleFqName()) + addElementToShorten(ShortenType(mostTopLevelTypeElement, mostTopLevelClassId.asSingleFqName())) } else { addFakePackagePrefixToShortenIfPresent(mostTopLevelTypeElement) } @@ -253,15 +257,10 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort ?: error("Type element should have at least one qualifier, instead it was ${typeElement.text}") if (deepestTypeWithQualifier.hasFakeRootPrefix()) { - addTypeToShorten(deepestTypeWithQualifier) + addElementToShorten(ShortenType(deepestTypeWithQualifier)) } } - private fun addTypeToShorten(mostTopLevelTypeElement: KtUserType, classFqName: FqName? = null) { - namesToImport.addIfNotNull(classFqName) - typesToShorten.add(mostTopLevelTypeElement) - } - private fun processTypeQualifier(resolvedQualifier: FirResolvedQualifier) { val wholeClassQualifier = resolvedQualifier.classId ?: return val wholeQualifierElement = when (val qualifierPsi = resolvedQualifier.psi) { @@ -283,7 +282,7 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort val firstFoundClass = shorteningContext.findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId if (firstFoundClass == classId) { - addElementToShorten(qualifier) + addElementToShorten(ShortenQualifier(qualifier)) return } } @@ -296,7 +295,7 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort } if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { - addElementToShorten(mostTopLevelQualifier, mostTopLevelClassId.asSingleFqName()) + addElementToShorten(ShortenQualifier(mostTopLevelQualifier, mostTopLevelClassId.asSingleFqName())) } else { addFakePackagePrefixToShortenIfPresent(mostTopLevelQualifier) } @@ -312,7 +311,7 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort val singleAvailableProperty = shorteningContext.findSinglePropertyInScopesByName(scopes, propertyId.callableName) if (singleAvailableProperty?.callableId == propertyId) { - addElementToShorten(qualifiedProperty) + addElementToShorten(ShortenQualifier(qualifiedProperty)) } } @@ -331,10 +330,10 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort when { availableCallables.isEmpty() -> { val additionalImport = callableId.asImportableFqName() ?: return - addElementToShorten(qualifiedCallExpression, additionalImport) + addElementToShorten(ShortenQualifier(qualifiedCallExpression, additionalImport)) } availableCallables.all { it.callableId == callableId } -> { - addElementToShorten(qualifiedCallExpression) + addElementToShorten(ShortenQualifier(qualifiedCallExpression)) } else -> { addFakePackagePrefixToShortenIfPresent(qualifiedCallExpression) @@ -388,13 +387,21 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort private fun addFakePackagePrefixToShortenIfPresent(wholeQualifiedExpression: KtDotQualifiedExpression) { val deepestQualifier = wholeQualifiedExpression.qualifiersWithSelf.last() if (deepestQualifier.hasFakeRootPrefix()) { - addElementToShorten(deepestQualifier) + addElementToShorten(ShortenQualifier(deepestQualifier)) } } - private fun addElementToShorten(element: KtDotQualifiedExpression, nameToImport: FqName? = null) { - namesToImport.addIfNotNull(nameToImport) - qualifiersToShorten.add(element) + private fun addElementToShorten(element: ElementToShorten) { + when (element) { + is ShortenType -> { + namesToImport.addIfNotNull(element.nameToImport) + typesToShorten.add(element.element) + } + is ShortenQualifier -> { + namesToImport.addIfNotNull(element.nameToImport) + qualifiersToShorten.add(element.element) + } + } } private val ClassId.outerClassesWithSelf: Sequence From c3831baba2cda639b9ce7954d3bc86f785c9ec97 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 9 Feb 2021 19:23:18 +0300 Subject: [PATCH 060/368] FIR IDE: Refactor `ElementsToShortenCollector` to be more value-oriented --- .../fir/components/KtFirReferenceShortener.kt | 63 +++++++++---------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 54dbd5180dc..dcda7581ac0 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -216,24 +216,23 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort if (wholeTypeElement.qualifier == null) return - collectTypeIfNeedsToBeShortened(wholeClassifierId, wholeTypeElement) + findTypeToShorten(wholeClassifierId, wholeTypeElement)?.let(::addElementToShorten) } - private fun collectTypeIfNeedsToBeShortened(wholeClassifierId: ClassId, wholeTypeElement: KtUserType) { + private fun findTypeToShorten(wholeClassifierId: ClassId, wholeTypeElement: KtUserType): ShortenType? { val allClassIds = wholeClassifierId.outerClassesWithSelf val allTypeElements = wholeTypeElement.qualifiersWithSelf - val positionScopes = shorteningContext.findScopesAtPosition(wholeTypeElement, namesToImport) ?: return + val positionScopes = shorteningContext.findScopesAtPosition(wholeTypeElement, namesToImport) ?: return null for ((classId, typeElement) in allClassIds.zip(allTypeElements)) { // if qualifier is null, then this type have no package and thus cannot be shortened - if (typeElement.qualifier == null) return + if (typeElement.qualifier == null) return null val firstFoundClass = shorteningContext.findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId if (firstFoundClass == classId) { - addElementToShorten(ShortenType(typeElement)) - return + return ShortenType(typeElement) } } @@ -245,20 +244,18 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort "If this condition were true, we would have exited from the loop on the last iteration. ClassId = $mostTopLevelClassId" } - if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { - addElementToShorten(ShortenType(mostTopLevelTypeElement, mostTopLevelClassId.asSingleFqName())) + return if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { + ShortenType(mostTopLevelTypeElement, mostTopLevelClassId.asSingleFqName()) } else { - addFakePackagePrefixToShortenIfPresent(mostTopLevelTypeElement) + findFakePackageToShorten(mostTopLevelTypeElement) } } - private fun addFakePackagePrefixToShortenIfPresent(typeElement: KtUserType) { + private fun findFakePackageToShorten(typeElement: KtUserType): ShortenType? { val deepestTypeWithQualifier = typeElement.qualifiersWithSelf.last().parent as? KtUserType ?: error("Type element should have at least one qualifier, instead it was ${typeElement.text}") - if (deepestTypeWithQualifier.hasFakeRootPrefix()) { - addElementToShorten(ShortenType(deepestTypeWithQualifier)) - } + return if (deepestTypeWithQualifier.hasFakeRootPrefix()) ShortenType(deepestTypeWithQualifier) else null } private fun processTypeQualifier(resolvedQualifier: FirResolvedQualifier) { @@ -269,11 +266,14 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort else -> return } - collectQualifierIfNeedsToBeShortened(wholeClassQualifier, wholeQualifierElement) + findTypeQualifierToShorten(wholeClassQualifier, wholeQualifierElement)?.let(::addElementToShorten) } - private fun collectQualifierIfNeedsToBeShortened(wholeClassQualifier: ClassId, wholeQualifierElement: KtDotQualifiedExpression) { - val positionScopes = shorteningContext.findScopesAtPosition(wholeQualifierElement, namesToImport) ?: return + private fun findTypeQualifierToShorten( + wholeClassQualifier: ClassId, + wholeQualifierElement: KtDotQualifiedExpression + ): ShortenQualifier? { + val positionScopes = shorteningContext.findScopesAtPosition(wholeQualifierElement, namesToImport) ?: return null val allClassIds = wholeClassQualifier.outerClassesWithSelf val allQualifiers = wholeQualifierElement.qualifiersWithSelf @@ -282,8 +282,7 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort val firstFoundClass = shorteningContext.findFirstClassifierInScopesByName(positionScopes, classId.shortClassName)?.classId if (firstFoundClass == classId) { - addElementToShorten(ShortenQualifier(qualifier)) - return + return ShortenQualifier(qualifier) } } @@ -294,10 +293,10 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort "If this condition were true, we would have exited from the loop on the last iteration. ClassId = $mostTopLevelClassId" } - if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { - addElementToShorten(ShortenQualifier(mostTopLevelQualifier, mostTopLevelClassId.asSingleFqName())) + return if (availableClassifier == null || availableClassifier.isFromStarOrPackageImport) { + ShortenQualifier(mostTopLevelQualifier, mostTopLevelClassId.asSingleFqName()) } else { - addFakePackagePrefixToShortenIfPresent(mostTopLevelQualifier) + findFakePackageToShorten(mostTopLevelQualifier) } } @@ -327,18 +326,16 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort val scopes = shorteningContext.findScopesAtPosition(callExpression, namesToImport) ?: return val availableCallables = shorteningContext.findFunctionsInScopes(scopes, callableId.callableName) - when { + val callToShorten = when { availableCallables.isEmpty() -> { - val additionalImport = callableId.asImportableFqName() ?: return - addElementToShorten(ShortenQualifier(qualifiedCallExpression, additionalImport)) - } - availableCallables.all { it.callableId == callableId } -> { - addElementToShorten(ShortenQualifier(qualifiedCallExpression)) - } - else -> { - addFakePackagePrefixToShortenIfPresent(qualifiedCallExpression) + val additionalImport = callableId.asImportableFqName() + additionalImport?.let { ShortenQualifier(qualifiedCallExpression, it) } } + availableCallables.all { it.callableId == callableId } -> ShortenQualifier(qualifiedCallExpression) + else -> findFakePackageToShorten(qualifiedCallExpression) } + + callToShorten?.let(::addElementToShorten) } private fun canBePossibleToDropReceiver(functionCall: FirFunctionCall): Boolean { @@ -384,11 +381,9 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort ?: error("Expected all candidates to have same callableId, but got: ${distinctCandidates.map { it.callableId }}") } - private fun addFakePackagePrefixToShortenIfPresent(wholeQualifiedExpression: KtDotQualifiedExpression) { + private fun findFakePackageToShorten(wholeQualifiedExpression: KtDotQualifiedExpression): ShortenQualifier? { val deepestQualifier = wholeQualifiedExpression.qualifiersWithSelf.last() - if (deepestQualifier.hasFakeRootPrefix()) { - addElementToShorten(ShortenQualifier(deepestQualifier)) - } + return if (deepestQualifier.hasFakeRootPrefix()) ShortenQualifier(deepestQualifier) else null } private fun addElementToShorten(element: ElementToShorten) { From bc262303923452bf2b5fe881ea0146a42acb8ca8 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Wed, 10 Feb 2021 11:21:51 +0300 Subject: [PATCH 061/368] FIR IDE: Visit only the smallest acceptable declaration if possible --- .../fir/components/KtFirReferenceShortener.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index dcda7581ac0..d65cd5edbf2 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.util.TextRange import com.intellij.psi.SmartPsiElementPointer +import com.intellij.psi.util.parentsOfType import com.intellij.util.containers.addIfNotNull import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirElement @@ -44,7 +45,6 @@ import org.jetbrains.kotlin.fir.types.lowerBoundIfFlexible import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirModuleResolveState import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFir -import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFirOfType import org.jetbrains.kotlin.idea.frontend.api.ValidityToken import org.jetbrains.kotlin.idea.frontend.api.components.KtReferenceShortener import org.jetbrains.kotlin.idea.frontend.api.components.ShortenCommand @@ -65,11 +65,13 @@ internal class KtFirReferenceShortener( private val context = FirShorteningContext(firResolveState) override fun collectShortenings(file: KtFile, selection: TextRange): ShortenCommand { - resolveFileToBodyResolve(file) - val firFile = file.getOrBuildFirOfType(firResolveState) + val declarationToVisit = file.findSmallestDeclarationContainingSelection(selection) + ?: file.withDeclarationsResolvedToBodyResolve() + + val firDeclaration = declarationToVisit.getOrBuildFir(firResolveState) val collector = ElementsToShortenCollector(context) - firFile.acceptChildren(collector) + firDeclaration.accept(collector) return ShortenCommandImpl( file, @@ -79,13 +81,20 @@ internal class KtFirReferenceShortener( ) } - private fun resolveFileToBodyResolve(file: KtFile) { - for (declaration in file.declarations) { + private fun KtFile.withDeclarationsResolvedToBodyResolve(): KtFile { + for (declaration in declarations) { declaration.getOrBuildFir(firResolveState) // temporary hack, resolves declaration to BODY_RESOLVE stage } + + return this } } +private fun KtFile.findSmallestDeclarationContainingSelection(selection: TextRange): KtDeclaration? = + findElementAt(selection.startOffset) + ?.parentsOfType(withSelf = true) + ?.firstOrNull { selection in it.textRange } + private data class AvailableClassifier(val classId: ClassId, val isFromStarOrPackageImport: Boolean) private class FirShorteningContext(val firResolveState: FirModuleResolveState) { From d615b6b68274e5f488c971aad870c4e35e9f7542 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Thu, 11 Feb 2021 13:42:38 +0300 Subject: [PATCH 062/368] FIR IDE: `firSymbolProvider` -> `symbolProvider` fix --- .../frontend/api/fir/components/KtFirReferenceShortener.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index d65cd5edbf2..41dff03299d 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeAmbiguityError -import org.jetbrains.kotlin.fir.resolve.firSymbolProvider +import org.jetbrains.kotlin.fir.resolve.symbolProvider import org.jetbrains.kotlin.fir.resolve.transformers.resolveToPackageOrClass import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.getFunctions @@ -161,7 +161,7 @@ private class FirShorteningContext(val firResolveState: FirModuleResolveState) { } private fun createFakeResolvedImport(fqNameToImport: FqName): FirResolvedImport? { - val packageOrClass = resolveToPackageOrClass(firSession.firSymbolProvider, fqNameToImport) ?: return null + val packageOrClass = resolveToPackageOrClass(firSession.symbolProvider, fqNameToImport) ?: return null val delegateImport = buildImport { importedFqName = fqNameToImport From 7a4625b70b234a3574df3a02c64a40bf3f6d509b Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Fri, 12 Feb 2021 14:29:22 +0300 Subject: [PATCH 063/368] FIR IDE: Enable passing completion test --- .../testData/basic/common/extensions/ExtensionOnFQObject.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/idea/idea-completion/testData/basic/common/extensions/ExtensionOnFQObject.kt b/idea/idea-completion/testData/basic/common/extensions/ExtensionOnFQObject.kt index a98c6b71108..f8395bb7629 100644 --- a/idea/idea-completion/testData/basic/common/extensions/ExtensionOnFQObject.kt +++ b/idea/idea-completion/testData/basic/common/extensions/ExtensionOnFQObject.kt @@ -1,3 +1,4 @@ +// FIR_COMPARISON package foo object A From d696a488b51dcdaf65be41d8a27e2ea97f8b95c3 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 12 Feb 2021 11:00:41 +0300 Subject: [PATCH 064/368] [FIR] Report list of conflicting symbols in REDECLARATION and CONFLICTING_OVERLOADS --- .../generator/diagnostics/FirDiagnosticsList.kt | 4 ++-- .../kotlin/fir/analysis/diagnostics/FirErrors.kt | 4 ++-- .../checkers/declaration/FirConflictsChecker.kt | 16 +++++++++------- .../diagnostics/FirDefaultErrorMessages.kt | 4 ++-- .../diagnostics/FirDiagnosticRenderers.kt | 2 +- .../fir/diagnostics/KtFirDataClassConverters.kt | 8 ++++++-- .../api/fir/diagnostics/KtFirDiagnostics.kt | 4 ++-- .../api/fir/diagnostics/KtFirDiagnosticsImpl.kt | 4 ++-- 8 files changed, 26 insertions(+), 20 deletions(-) diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 0295c7f5624..97d3ce9e651 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -245,10 +245,10 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { group("Redeclarations") { val MANY_COMPANION_OBJECTS by error() val CONFLICTING_OVERLOADS by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) { - parameter("conflictingOverloads") // TODO use Collection instead of String + parameter>>("conflictingOverloads") } val REDECLARATION by error() { - parameter("conflictingDeclaration") // TODO use Collection instead of String + parameter>>("conflictingDeclarations") } val ANY_METHOD_IMPLEMENTED_IN_INTERFACE by error() } diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 3c2f2f618f8..43d304be839 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -178,8 +178,8 @@ object FirErrors { // Redeclarations val MANY_COMPANION_OBJECTS by error0() - val CONFLICTING_OVERLOADS by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) - val REDECLARATION by error1() + val CONFLICTING_OVERLOADS by error1>>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) + val REDECLARATION by error1>>() val ANY_METHOD_IMPLEMENTED_IN_INTERFACE by error0() // Invalid local declarations diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictsChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictsChecker.kt index 4613251a767..76b4cd225ee 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictsChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictsChecker.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration +import org.jetbrains.kotlin.fir.FirSymbolOwner import org.jetbrains.kotlin.fir.analysis.checkers.FirDeclarationInspector import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter @@ -13,6 +14,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol object FirConflictsChecker : FirBasicDeclarationChecker() { override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { @@ -24,22 +26,22 @@ object FirConflictsChecker : FirBasicDeclarationChecker() { else -> return } - inspector.functionDeclarations.forEachNonSingle { it, hint -> - reporter.reportOn(it.source, FirErrors.CONFLICTING_OVERLOADS, hint, context) + inspector.functionDeclarations.forEachNonSingle { it, symbols -> + reporter.reportOn(it.source, FirErrors.CONFLICTING_OVERLOADS, symbols, context) } - inspector.otherDeclarations.forEachNonSingle { it, hint -> - reporter.reportOn(it.source, FirErrors.REDECLARATION, hint, context) + inspector.otherDeclarations.forEachNonSingle { it, symbols -> + reporter.reportOn(it.source, FirErrors.REDECLARATION, symbols, context) } } - private fun Map>.forEachNonSingle(action: (FirDeclaration, String) -> Unit) { + private fun Map>.forEachNonSingle(action: (FirDeclaration, Collection>) -> Unit) { for (value in values) { if (value.size > 1) { - val hint = value.joinToString { that -> that.toString() } + val symbols = value.mapNotNull { (it as? FirSymbolOwner<*>)?.symbol } value.forEach { - action(it, hint) + action(it, symbols) } } } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index e2bcc0e751c..02a7a799985 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -402,8 +402,8 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { // Redeclarations map.put(MANY_COMPANION_OBJECTS, "Only one companion object is allowed per class") - map.put(CONFLICTING_OVERLOADS, "Conflicting overloads: {0}", TO_STRING) // * - map.put(REDECLARATION, "Conflicting declarations: {0}", TO_STRING) // * + map.put(CONFLICTING_OVERLOADS, "Conflicting overloads: {0}", SYMBOLS) // * + map.put(REDECLARATION, "Conflicting declarations: {0}", SYMBOLS) // * map.put(ANY_METHOD_IMPLEMENTED_IN_INTERFACE, "An interface may not implement a method of 'Any'") // & // Invalid local declarations diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDiagnosticRenderers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDiagnosticRenderers.kt index b0627cd5e12..4f8c8b6b190 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDiagnosticRenderers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDiagnosticRenderers.kt @@ -32,7 +32,7 @@ object FirDiagnosticRenderers { } val SYMBOLS = Renderer { symbols: Collection> -> - symbols.joinToString(prefix = "[", postfix = "]", separator = ",", limit = 3, truncated = "...") { symbol -> + symbols.joinToString(prefix = "[", postfix = "]", separator = ", ", limit = 3, truncated = "...") { symbol -> SYMBOL.render(symbol) } } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt index 31da6df9c5a..12e35474fc9 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -731,14 +731,18 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert } add(FirErrors.CONFLICTING_OVERLOADS) { firDiagnostic -> ConflictingOverloadsImpl( - firDiagnostic.a, + firDiagnostic.a.map { abstractFirBasedSymbol -> + firSymbolBuilder.buildSymbol(abstractFirBasedSymbol.fir as FirDeclaration) + }, firDiagnostic as FirPsiDiagnostic<*>, token, ) } add(FirErrors.REDECLARATION) { firDiagnostic -> RedeclarationImpl( - firDiagnostic.a, + firDiagnostic.a.map { abstractFirBasedSymbol -> + firSymbolBuilder.buildSymbol(abstractFirBasedSymbol.fir as FirDeclaration) + }, firDiagnostic as FirPsiDiagnostic<*>, token, ) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt index 7a6b74440a1..1a7aca65037 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -521,12 +521,12 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { abstract class ConflictingOverloads : KtFirDiagnostic() { override val diagnosticClass get() = ConflictingOverloads::class - abstract val conflictingOverloads: String + abstract val conflictingOverloads: List } abstract class Redeclaration : KtFirDiagnostic() { override val diagnosticClass get() = Redeclaration::class - abstract val conflictingDeclaration: String + abstract val conflictingDeclarations: List } abstract class AnyMethodImplementedInInterface : KtFirDiagnostic() { diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index cef054dea64..15b225a8cd3 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -830,7 +830,7 @@ internal class ManyCompanionObjectsImpl( } internal class ConflictingOverloadsImpl( - override val conflictingOverloads: String, + override val conflictingOverloads: List, firDiagnostic: FirPsiDiagnostic<*>, override val token: ValidityToken, ) : KtFirDiagnostic.ConflictingOverloads(), KtAbstractFirDiagnostic { @@ -838,7 +838,7 @@ internal class ConflictingOverloadsImpl( } internal class RedeclarationImpl( - override val conflictingDeclaration: String, + override val conflictingDeclarations: List, firDiagnostic: FirPsiDiagnostic<*>, override val token: ValidityToken, ) : KtFirDiagnostic.Redeclaration(), KtAbstractFirDiagnostic { From 0e31551797cfddcf04795ce7e62d69da70718e37 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 12 Feb 2021 12:04:32 +0300 Subject: [PATCH 065/368] [FIR] Generate `_` instead of `value` for unused setters in FIR builders --- .../fir/declarations/builder/FirConstructorBuilder.kt | 2 +- .../declarations/builder/FirPrimaryConstructorBuilder.kt | 2 +- .../fir/expressions/builder/FirAnnotationCallBuilder.kt | 2 +- .../expressions/builder/FirBinaryLogicExpressionBuilder.kt | 2 +- .../kotlin/fir/expressions/builder/FirBlockBuilder.kt | 2 +- .../fir/expressions/builder/FirBreakExpressionBuilder.kt | 2 +- .../builder/FirClassReferenceExpressionBuilder.kt | 2 +- .../expressions/builder/FirComparisonExpressionBuilder.kt | 2 +- .../fir/expressions/builder/FirComponentCallBuilder.kt | 2 +- .../fir/expressions/builder/FirContinueExpressionBuilder.kt | 2 +- .../fir/expressions/builder/FirElvisExpressionBuilder.kt | 2 +- .../expressions/builder/FirEqualityOperatorCallBuilder.kt | 2 +- .../fir/expressions/builder/FirErrorExpressionBuilder.kt | 2 +- .../expressions/builder/FirErrorResolvedQualifierBuilder.kt | 2 +- .../fir/expressions/builder/FirGetClassCallBuilder.kt | 2 +- .../fir/expressions/builder/FirImplicitInvokeCallBuilder.kt | 2 +- .../builder/FirLambdaArgumentExpressionBuilder.kt | 2 +- .../kotlin/fir/expressions/builder/FirLazyBlockBuilder.kt | 2 +- .../builder/FirNamedArgumentExpressionBuilder.kt | 2 +- .../fir/expressions/builder/FirResolvedQualifierBuilder.kt | 2 +- .../fir/expressions/builder/FirReturnExpressionBuilder.kt | 2 +- .../builder/FirSpreadArgumentExpressionBuilder.kt | 2 +- .../builder/FirStringConcatenationCallBuilder.kt | 2 +- .../expressions/builder/FirThisReceiverExpressionBuilder.kt | 6 +++--- .../fir/expressions/builder/FirThrowExpressionBuilder.kt | 2 +- .../fir/expressions/builder/FirTypeOperatorCallBuilder.kt | 2 +- .../expressions/builder/FirWhenSubjectExpressionBuilder.kt | 2 +- .../builder/FirWrappedDelegateExpressionBuilder.kt | 2 +- .../jetbrains/kotlin/fir/tree/generator/printer/builder.kt | 2 +- 29 files changed, 31 insertions(+), 31 deletions(-) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirConstructorBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirConstructorBuilder.kt index a1a8a10ff41..3e99df53279 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirConstructorBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirConstructorBuilder.kt @@ -78,7 +78,7 @@ open class FirConstructorBuilder : FirAbstractConstructorBuilder, FirAnnotationC @Deprecated("Modification of 'controlFlowGraphReference' has no impact for FirConstructorBuilder", level = DeprecationLevel.HIDDEN) override var controlFlowGraphReference: FirControlFlowGraphReference? get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPrimaryConstructorBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPrimaryConstructorBuilder.kt index ed98e933a6a..6645f7af9c6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPrimaryConstructorBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/builder/FirPrimaryConstructorBuilder.kt @@ -78,7 +78,7 @@ class FirPrimaryConstructorBuilder : FirAbstractConstructorBuilder, FirAnnotatio @Deprecated("Modification of 'controlFlowGraphReference' has no impact for FirPrimaryConstructorBuilder", level = DeprecationLevel.HIDDEN) override var controlFlowGraphReference: FirControlFlowGraphReference? get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt index 60cae8cad0b..cd88fdbb6f3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt @@ -52,7 +52,7 @@ class FirAnnotationCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, @Deprecated("Modification of 'typeRef' has no impact for FirAnnotationCallBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBinaryLogicExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBinaryLogicExpressionBuilder.kt index 6496c6bf568..8a9ca9467ae 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBinaryLogicExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBinaryLogicExpressionBuilder.kt @@ -46,7 +46,7 @@ class FirBinaryLogicExpressionBuilder : FirAnnotationContainerBuilder, FirExpres @Deprecated("Modification of 'typeRef' has no impact for FirBinaryLogicExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBlockBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBlockBuilder.kt index e1d69880ac2..0f42d8c2c41 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBlockBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBlockBuilder.kt @@ -41,7 +41,7 @@ class FirBlockBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder { @Deprecated("Modification of 'typeRef' has no impact for FirBlockBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBreakExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBreakExpressionBuilder.kt index 1e7895b5b1f..12773eef956 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBreakExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirBreakExpressionBuilder.kt @@ -45,7 +45,7 @@ class FirBreakExpressionBuilder : FirLoopJumpBuilder, FirAnnotationContainerBuil @Deprecated("Modification of 'typeRef' has no impact for FirBreakExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirClassReferenceExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirClassReferenceExpressionBuilder.kt index 1ed5e53d0b9..7647a3dceb4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirClassReferenceExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirClassReferenceExpressionBuilder.kt @@ -40,7 +40,7 @@ class FirClassReferenceExpressionBuilder : FirAnnotationContainerBuilder, FirExp @Deprecated("Modification of 'typeRef' has no impact for FirClassReferenceExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComparisonExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComparisonExpressionBuilder.kt index 5a50b91d37d..de72efc12e9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComparisonExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComparisonExpressionBuilder.kt @@ -44,7 +44,7 @@ class FirComparisonExpressionBuilder : FirAnnotationContainerBuilder, FirExpress @Deprecated("Modification of 'typeRef' has no impact for FirComparisonExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComponentCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComponentCallBuilder.kt index 7952af152a7..be9f371378d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComponentCallBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirComponentCallBuilder.kt @@ -61,7 +61,7 @@ class FirComponentCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, F @Deprecated("Modification of 'typeRef' has no impact for FirComponentCallBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirContinueExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirContinueExpressionBuilder.kt index 451d32a9621..70ead89e2b5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirContinueExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirContinueExpressionBuilder.kt @@ -45,7 +45,7 @@ class FirContinueExpressionBuilder : FirLoopJumpBuilder, FirAnnotationContainerB @Deprecated("Modification of 'typeRef' has no impact for FirContinueExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirElvisExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirElvisExpressionBuilder.kt index b4c002c4b64..13f524589ba 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirElvisExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirElvisExpressionBuilder.kt @@ -47,7 +47,7 @@ class FirElvisExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBu @Deprecated("Modification of 'typeRef' has no impact for FirElvisExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirEqualityOperatorCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirEqualityOperatorCallBuilder.kt index 1755ce2b27b..e08da49b7b9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirEqualityOperatorCallBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirEqualityOperatorCallBuilder.kt @@ -44,7 +44,7 @@ class FirEqualityOperatorCallBuilder : FirAnnotationContainerBuilder, FirExpress @Deprecated("Modification of 'typeRef' has no impact for FirEqualityOperatorCallBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorExpressionBuilder.kt index ee1a967baf8..bd2463f8a1b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorExpressionBuilder.kt @@ -40,7 +40,7 @@ class FirErrorExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBu @Deprecated("Modification of 'typeRef' has no impact for FirErrorExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorResolvedQualifierBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorResolvedQualifierBuilder.kt index 3ad2f4459d1..aebcd72156b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorResolvedQualifierBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirErrorResolvedQualifierBuilder.kt @@ -58,7 +58,7 @@ class FirErrorResolvedQualifierBuilder : FirAbstractResolvedQualifierBuilder, Fi @Deprecated("Modification of 'typeRef' has no impact for FirErrorResolvedQualifierBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirGetClassCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirGetClassCallBuilder.kt index 5bcda774442..33ee9d73421 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirGetClassCallBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirGetClassCallBuilder.kt @@ -43,7 +43,7 @@ class FirGetClassCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, Fi @Deprecated("Modification of 'typeRef' has no impact for FirGetClassCallBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirImplicitInvokeCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirImplicitInvokeCallBuilder.kt index 80d5a379b56..c90d11a44d2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirImplicitInvokeCallBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirImplicitInvokeCallBuilder.kt @@ -58,7 +58,7 @@ open class FirImplicitInvokeCallBuilder : FirAbstractFunctionCallBuilder, FirAnn @Deprecated("Modification of 'typeRef' has no impact for FirImplicitInvokeCallBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLambdaArgumentExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLambdaArgumentExpressionBuilder.kt index 471923b3f4e..ee075bff24a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLambdaArgumentExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLambdaArgumentExpressionBuilder.kt @@ -40,7 +40,7 @@ class FirLambdaArgumentExpressionBuilder : FirAnnotationContainerBuilder, FirExp @Deprecated("Modification of 'typeRef' has no impact for FirLambdaArgumentExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLazyBlockBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLazyBlockBuilder.kt index b36aa241393..9ae50a137f1 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLazyBlockBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLazyBlockBuilder.kt @@ -41,7 +41,7 @@ class FirLazyBlockBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder @Deprecated("Modification of 'typeRef' has no impact for FirLazyBlockBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirNamedArgumentExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirNamedArgumentExpressionBuilder.kt index 7b93f4e004d..74628687c00 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirNamedArgumentExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirNamedArgumentExpressionBuilder.kt @@ -45,7 +45,7 @@ class FirNamedArgumentExpressionBuilder : FirAnnotationContainerBuilder, FirExpr @Deprecated("Modification of 'typeRef' has no impact for FirNamedArgumentExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedQualifierBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedQualifierBuilder.kt index 524574e0954..c50035d9f2b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedQualifierBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirResolvedQualifierBuilder.kt @@ -55,7 +55,7 @@ class FirResolvedQualifierBuilder : FirAbstractResolvedQualifierBuilder, FirAnno @Deprecated("Modification of 'classId' has no impact for FirResolvedQualifierBuilder", level = DeprecationLevel.HIDDEN) override var classId: ClassId? get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirReturnExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirReturnExpressionBuilder.kt index 7582f8d96f4..4a02021d440 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirReturnExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirReturnExpressionBuilder.kt @@ -47,7 +47,7 @@ class FirReturnExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionB @Deprecated("Modification of 'typeRef' has no impact for FirReturnExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirSpreadArgumentExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirSpreadArgumentExpressionBuilder.kt index 6499c7df7d2..87f4eb85bc2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirSpreadArgumentExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirSpreadArgumentExpressionBuilder.kt @@ -40,7 +40,7 @@ class FirSpreadArgumentExpressionBuilder : FirAnnotationContainerBuilder, FirExp @Deprecated("Modification of 'typeRef' has no impact for FirSpreadArgumentExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirStringConcatenationCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirStringConcatenationCallBuilder.kt index 0f7cb3bfc87..f1c44632369 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirStringConcatenationCallBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirStringConcatenationCallBuilder.kt @@ -44,7 +44,7 @@ class FirStringConcatenationCallBuilder : FirCallBuilder, FirAnnotationContainer @Deprecated("Modification of 'typeRef' has no impact for FirStringConcatenationCallBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt index 6b48a999d7c..a52967a01c0 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThisReceiverExpressionBuilder.kt @@ -50,21 +50,21 @@ class FirThisReceiverExpressionBuilder : FirQualifiedAccessBuilder, FirAnnotatio @Deprecated("Modification of 'explicitReceiver' has no impact for FirThisReceiverExpressionBuilder", level = DeprecationLevel.HIDDEN) override var explicitReceiver: FirExpression? get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } @Deprecated("Modification of 'dispatchReceiver' has no impact for FirThisReceiverExpressionBuilder", level = DeprecationLevel.HIDDEN) override var dispatchReceiver: FirExpression get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } @Deprecated("Modification of 'extensionReceiver' has no impact for FirThisReceiverExpressionBuilder", level = DeprecationLevel.HIDDEN) override var extensionReceiver: FirExpression get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThrowExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThrowExpressionBuilder.kt index a90ca5efa56..8b4f938e51a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThrowExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirThrowExpressionBuilder.kt @@ -43,7 +43,7 @@ class FirThrowExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBu @Deprecated("Modification of 'typeRef' has no impact for FirThrowExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTypeOperatorCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTypeOperatorCallBuilder.kt index 2fa1a6fcbae..f40a5b989dc 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTypeOperatorCallBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirTypeOperatorCallBuilder.kt @@ -48,7 +48,7 @@ class FirTypeOperatorCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder @Deprecated("Modification of 'typeRef' has no impact for FirTypeOperatorCallBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenSubjectExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenSubjectExpressionBuilder.kt index 6b3c89e72f2..2e374927c00 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenSubjectExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWhenSubjectExpressionBuilder.kt @@ -41,7 +41,7 @@ class FirWhenSubjectExpressionBuilder : FirAnnotationContainerBuilder, FirExpres @Deprecated("Modification of 'typeRef' has no impact for FirWhenSubjectExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWrappedDelegateExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWrappedDelegateExpressionBuilder.kt index 5057fad5bdd..d5c11e7df39 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWrappedDelegateExpressionBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirWrappedDelegateExpressionBuilder.kt @@ -42,7 +42,7 @@ class FirWrappedDelegateExpressionBuilder : FirAnnotationContainerBuilder, FirEx @Deprecated("Modification of 'typeRef' has no impact for FirWrappedDelegateExpressionBuilder", level = DeprecationLevel.HIDDEN) override var typeRef: FirTypeRef get() = throw IllegalStateException() - set(value) { + set(_) { throw IllegalStateException() } } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt index 0469f8c03ad..3b2e3c5cac9 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/builder.kt @@ -154,7 +154,7 @@ private fun SmartPrinter.printFieldInBuilder(field: FieldWithDefault, builder: B println() withIndent { println("get() = throw IllegalStateException()") - println("set(value) {") + println("set(_) {") withIndent { println("throw IllegalStateException()") } From 0c4bca4bde2b6806155d51e21e38237b6a4efb52 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 12 Feb 2021 12:35:54 +0300 Subject: [PATCH 066/368] [FIR] Fix warnings in FIR modules and enable -Werror in them --- build.gradle.kts | 4 --- .../analysis/cfa/FirControlFlowAnalyzer.kt | 5 +++ .../declaration/FirOverrideChecker.kt | 1 + .../JvmBinaryAnnotationDeserializer.kt | 25 +++++++-------- ...CreateFreshTypeVariableSubstitutorStage.kt | 32 +++---------------- .../inference/FirBuilderInferenceSession.kt | 1 + .../fir/resolve/inference/InferenceUtils.kt | 11 ++----- .../FirDeclarationsResolveTransformer.kt | 10 +++--- compiler/fir/tree/build.gradle.kts | 6 ++++ .../kotlin/fir/caches/NullableMap.kt | 2 +- 10 files changed, 36 insertions(+), 61 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d0c3fccb66e..8f92d5e5e6f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -327,10 +327,6 @@ extra["tasksWithWarnings"] = listOf( ":kotlin-stdlib-jdk8:compileTestKotlin", ":compiler:cli:compileKotlin", ":compiler:frontend:compileKotlin", - ":compiler:fir:tree:compileKotlin", - ":compiler:fir:resolve:compileKotlin", - ":compiler:fir:checkers:compileKotlin", - ":compiler:fir:java:compileKotlin", ":kotlin-scripting-compiler:compileKotlin", ":plugins:uast-kotlin:compileKotlin", ":plugins:uast-kotlin:compileTestKotlin", diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt index 15a55601371..3ec3775b576 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt @@ -19,11 +19,14 @@ class FirControlFlowAnalyzer(session: FirSession) { private val cfaCheckers = session.checkersComponent.declarationCheckers.controlFlowAnalyserCheckers private val variableAssignmentCheckers = session.checkersComponent.declarationCheckers.variableAssignmentCfaBasedCheckers + // Currently declaration in analyzeXXX is not used, but it may be useful in future + @Suppress("UNUSED_PARAMETER") fun analyzeClassInitializer(klass: FirClass<*>, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) { if (graph.owner != null) return cfaCheckers.forEach { it.analyze(graph, reporter, context) } } + @Suppress("UNUSED_PARAMETER") fun analyzeFunction(function: FirFunction<*>, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) { if (graph.owner != null) return @@ -32,6 +35,7 @@ class FirControlFlowAnalyzer(session: FirSession) { runAssignmentCfaCheckers(graph, reporter, context) } + @Suppress("UNUSED_PARAMETER") fun analyzePropertyInitializer(property: FirProperty, graph: ControlFlowGraph, context: CheckerContext, reporter: DiagnosticReporter) { if (graph.owner != null) return @@ -39,6 +43,7 @@ class FirControlFlowAnalyzer(session: FirSession) { runAssignmentCfaCheckers(graph, reporter, context) } + @Suppress("UNUSED_PARAMETER") fun analyzePropertyAccessor( accessor: FirPropertyAccessor, graph: ControlFlowGraph, diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOverrideChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOverrideChecker.kt index 8302f1adc3a..401a0297724 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOverrideChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOverrideChecker.kt @@ -242,6 +242,7 @@ object FirOverrideChecker : FirRegularClassChecker() { } } + @Suppress("UNUSED_PARAMETER") // TODO: delete me after implementing body private fun DiagnosticReporter.reportNothingToOverride(declaration: FirMemberDeclaration, context: CheckerContext) { // TODO: not ready yet, e.g., Collections // reportOn(declaration.source, FirErrors.NOTHING_TO_OVERRIDE, declaration, context) diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/JvmBinaryAnnotationDeserializer.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/JvmBinaryAnnotationDeserializer.kt index f5be29cdc0a..d132752d9a5 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/JvmBinaryAnnotationDeserializer.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/JvmBinaryAnnotationDeserializer.kt @@ -11,8 +11,6 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.deserialization.AbstractAnnotationDeserializer import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.builder.buildAnnotationCall -import org.jetbrains.kotlin.fir.resolve.symbolProvider -import org.jetbrains.kotlin.fir.resolve.providers.impl.FirCompositeSymbolProvider import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass import org.jetbrains.kotlin.load.kotlin.MemberSignature @@ -52,7 +50,7 @@ class JvmBinaryAnnotationDeserializer( typeTable: TypeTable ): List { val signature = getCallableSignature(constructorProto, nameResolver, typeTable) ?: return emptyList() - return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature) + return findJvmBinaryClassAndLoadMemberAnnotations(signature) } override fun loadFunctionAnnotations( @@ -62,7 +60,7 @@ class JvmBinaryAnnotationDeserializer( typeTable: TypeTable ): List { val signature = getCallableSignature(functionProto, nameResolver, typeTable) ?: return emptyList() - return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature) + return findJvmBinaryClassAndLoadMemberAnnotations(signature) } override fun loadPropertyAnnotations( @@ -72,7 +70,7 @@ class JvmBinaryAnnotationDeserializer( typeTable: TypeTable ): List { val signature = getPropertySignature(propertyProto, nameResolver, typeTable, synthetic = true) ?: return emptyList() - return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature).map { + return findJvmBinaryClassAndLoadMemberAnnotations(signature).map { buildAnnotationCall { annotationTypeRef = it.annotationTypeRef argumentList = it.argumentList @@ -95,7 +93,7 @@ class JvmBinaryAnnotationDeserializer( if (signature.isDelegated) { return emptyList() } - return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature).map { + return findJvmBinaryClassAndLoadMemberAnnotations(signature).map { buildAnnotationCall { annotationTypeRef = it.annotationTypeRef argumentList = it.argumentList @@ -115,7 +113,7 @@ class JvmBinaryAnnotationDeserializer( if (!signature.isDelegated) { return emptyList() } - return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature).map { + return findJvmBinaryClassAndLoadMemberAnnotations(signature).map { buildAnnotationCall { annotationTypeRef = it.annotationTypeRef argumentList = it.argumentList @@ -133,7 +131,7 @@ class JvmBinaryAnnotationDeserializer( getterFlags: Int ): List { val signature = getCallableSignature(propertyProto, nameResolver, typeTable, CallableKind.PROPERTY_GETTER) ?: return emptyList() - return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature) + return findJvmBinaryClassAndLoadMemberAnnotations(signature) } override fun loadPropertySetterAnnotations( @@ -144,7 +142,7 @@ class JvmBinaryAnnotationDeserializer( setterFlags: Int ): List { val signature = getCallableSignature(propertyProto, nameResolver, typeTable, CallableKind.PROPERTY_SETTER) ?: return emptyList() - return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, signature) + return findJvmBinaryClassAndLoadMemberAnnotations(signature) } override fun loadValueParameterAnnotations( @@ -160,7 +158,7 @@ class JvmBinaryAnnotationDeserializer( val methodSignature = getCallableSignature(callableProto, nameResolver, typeTable, kind) ?: return emptyList() val index = parameterIndex + computeJvmParameterIndexShift(classProto, callableProto) val paramSignature = MemberSignature.fromMethodSignatureAndParameterIndex(methodSignature, index) - return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, paramSignature) + return findJvmBinaryClassAndLoadMemberAnnotations(paramSignature) } override fun loadExtensionReceiverParameterAnnotations( @@ -172,7 +170,7 @@ class JvmBinaryAnnotationDeserializer( ): List { val methodSignature = getCallableSignature(callableProto, nameResolver, typeTable, kind) ?: return emptyList() val paramSignature = MemberSignature.fromMethodSignatureAndParameterIndex(methodSignature, 0) - return findJvmBinaryClassAndLoadMemberAnnotations(containerSource, paramSignature) + return findJvmBinaryClassAndLoadMemberAnnotations(paramSignature) } private fun computeJvmParameterIndexShift(classProto: ProtoBuf.Class?, message: MessageLite): Int { @@ -255,7 +253,6 @@ class JvmBinaryAnnotationDeserializer( } private fun findJvmBinaryClassAndLoadMemberAnnotations( - containerSource: DeserializedContainerSource?, memberSignature: MemberSignature ): List { return annotationInfo.memberAnnotations[memberSignature] ?: emptyList() @@ -271,11 +268,11 @@ private fun FirSession.loadMemberAnnotations(kotlinBinaryClass: KotlinJvmBinaryC val annotationsLoader = AnnotationsLoader(this) kotlinBinaryClass.visitMembers(object : KotlinJvmBinaryClass.MemberVisitor { - override fun visitMethod(name: Name, desc: String): KotlinJvmBinaryClass.MethodAnnotationVisitor? { + override fun visitMethod(name: Name, desc: String): KotlinJvmBinaryClass.MethodAnnotationVisitor { return AnnotationVisitorForMethod(MemberSignature.fromMethodNameAndDesc(name.asString(), desc)) } - override fun visitField(name: Name, desc: String, initializer: Any?): KotlinJvmBinaryClass.AnnotationVisitor? { + override fun visitField(name: Name, desc: String, initializer: Any?): KotlinJvmBinaryClass.AnnotationVisitor { val signature = MemberSignature.fromFieldNameAndDesc(name.asString(), desc) if (initializer != null) { // TODO: load constant diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt index ae6f9936a89..d09517ee314 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.fir.resolve.calls -import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRefsOwner import org.jetbrains.kotlin.fir.renderWithType @@ -15,8 +14,8 @@ import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents import org.jetbrains.kotlin.fir.resolve.inference.model.ConeDeclaredUpperBoundConstraintPosition import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap +import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.fir.symbols.StandardClassIds -import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.FirTypePlaceholderProjection import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation @@ -32,7 +31,7 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() { } val csBuilder = candidate.system.getBuilder() val (substitutor, freshVariables) = - createToFreshVariableSubstitutorAndAddInitialConstraints(declaration, candidate, csBuilder, callInfo.session) + createToFreshVariableSubstitutorAndAddInitialConstraints(declaration, csBuilder) candidate.substitutor = substitutor candidate.freshVariables = freshVariables @@ -102,7 +101,7 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() { return symbol.fir.bounds.any { val type = it.coneType type is ConeFlexibleType || with(context) { - (type.typeConstructor() as? FirTypeParameterSymbol)?.fir?.shouldBeFlexible(context) ?: false + (type.typeConstructor() as? ConeTypeParameterLookupTag)?.symbol?.fir?.shouldBeFlexible(context) ?: false } } } @@ -111,9 +110,7 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() { private fun createToFreshVariableSubstitutorAndAddInitialConstraints( declaration: FirTypeParameterRefsOwner, - candidate: Candidate, - csBuilder: ConstraintSystemOperation, - session: FirSession + csBuilder: ConstraintSystemOperation ): Pair> { val typeParameters = declaration.typeParameters @@ -153,26 +150,5 @@ private fun createToFreshVariableSubstitutorAndAddInitialConstraints( } } -// if (candidateDescriptor is TypeAliasConstructorDescriptor) { -// val typeAliasDescriptor = candidateDescriptor.typeAliasDescriptor -// val originalTypes = typeAliasDescriptor.underlyingType.arguments.map { it.type } -// val originalTypeParameters = candidateDescriptor.underlyingConstructorDescriptor.typeParameters -// for (index in typeParameters.indices) { -// val typeParameter = typeParameters[index] -// val freshVariable = freshTypeVariables[index] -// val typeMapping = originalTypes.mapIndexedNotNull { i: Int, kotlinType: KotlinType -> -// if (kotlinType == typeParameter.defaultType) i else null -// } -// for (originalIndex in typeMapping) { -// // there can be null in case we already captured type parameter in outer class (in case of inner classes) -// // see test innerClassTypeAliasConstructor.kt -// val originalTypeParameter = originalTypeParameters.getOrNull(originalIndex) ?: continue -// val position = DeclaredUpperBoundConstraintPosition(originalTypeParameter) -// for (upperBound in originalTypeParameter.upperBounds) { -// freshVariable.addSubtypeConstraint(upperBound, position) -// } -// } -// } -// } return toFreshVariables to freshTypeVariables } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirBuilderInferenceSession.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirBuilderInferenceSession.kt index 2ac113e844a..24f1203dfa0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirBuilderInferenceSession.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirBuilderInferenceSession.kt @@ -92,6 +92,7 @@ class FirBuilderInferenceSession( return !skipCall(call) } + @Suppress("UNUSED_PARAMETER") private fun skipCall(call: T): Boolean where T : FirResolvable, T : FirStatement { // TODO: what is FIR analog? // if (descriptor is FakeCallableDescriptorForObject) return true diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt index ea7ebfaf344..e2f3f91a66d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt @@ -198,15 +198,8 @@ fun ConeKotlinType.isKClassType(): Boolean { return classId == StandardClassIds.KClass } -fun ConeKotlinType.receiverType(expectedTypeRef: FirTypeRef?, session: FirSession): ConeKotlinType? { - if (isBuiltinFunctionalType(session) && isExtensionFunctionType(session)) { - return (this.fullyExpandedType(session).typeArguments.first() as ConeKotlinTypeProjection).type - } - return null -} - fun ConeKotlinType.receiverType(session: FirSession): ConeKotlinType? { - if (isBuiltinFunctionalType(session)) { + if (isBuiltinFunctionalType(session) && isExtensionFunctionType(session)) { return (this.fullyExpandedType(session).typeArguments.first() as ConeKotlinTypeProjection).type } return null @@ -250,7 +243,7 @@ fun extractLambdaInfoFromFunctionalType( } if (!expectedType.isBuiltinFunctionalType(session)) return null - val receiverType = argument.receiverType ?: expectedType.receiverType(expectedTypeRef, session) + val receiverType = argument.receiverType ?: expectedType.receiverType(session) val returnType = argument.returnType ?: expectedType.returnType(session) ?: return null val parameters = extractLambdaParameters(expectedType, argument, expectedType.isExtensionFunctionType(session), session) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 93905dbcd98..cd46b7f931a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -112,9 +112,9 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor if (property.isLocal) { prepareSignatureForBodyResolve(property) - property.transformStatus(this, property.resolveStatus(property.status).mode()) - property.getter?.let { it.transformStatus(this, it.resolveStatus(it.status).mode()) } - property.setter?.let { it.transformStatus(this, it.resolveStatus(it.status).mode()) } + property.transformStatus(this, property.resolveStatus().mode()) + property.getter?.let { it.transformStatus(this, it.resolveStatus().mode()) } + property.setter?.let { it.transformStatus(this, it.resolveStatus().mode()) } return transformLocalVariable(property) } @@ -367,7 +367,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor } } - private fun FirDeclaration.resolveStatus(status: FirDeclarationStatus, containingClass: FirClass<*>? = null): FirDeclarationStatus { + private fun FirDeclaration.resolveStatus(containingClass: FirClass<*>? = null): FirDeclarationStatus { val containingDeclaration = context.containerIfAny return statusResolver.resolveStatus( this, @@ -528,7 +528,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor if (containingDeclaration != null && containingDeclaration !is FirClass<*>) { // For class members everything should be already prepared prepareSignatureForBodyResolve(simpleFunction) - simpleFunction.transformStatus(this, simpleFunction.resolveStatus(simpleFunction.status).mode()) + simpleFunction.transformStatus(this, simpleFunction.resolveStatus().mode()) } withFullBodyResolve { diff --git a/compiler/fir/tree/build.gradle.kts b/compiler/fir/tree/build.gradle.kts index 8a6b4d3d1e1..a261ca6eb99 100644 --- a/compiler/fir/tree/build.gradle.kts +++ b/compiler/fir/tree/build.gradle.kts @@ -50,6 +50,12 @@ val compileKotlin by tasks compileKotlin.dependsOn(generateTree) +tasks.withType> { + kotlinOptions { + freeCompilerArgs += "-Xinline-classes" + } +} + if (kotlinBuildProperties.isInJpsBuildIdeaSync) { apply(plugin = "idea") idea { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/caches/NullableMap.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/caches/NullableMap.kt index a94ccf03b4c..7dfbfb15654 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/caches/NullableMap.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/caches/NullableMap.kt @@ -33,4 +33,4 @@ internal inline class NullableMap(private val map: MutableMap Date: Fri, 12 Feb 2021 13:03:42 +0300 Subject: [PATCH 067/368] Enable -Werror in `:compiler:frontend` module --- build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8f92d5e5e6f..53c91650853 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -326,7 +326,6 @@ extra["tasksWithWarnings"] = listOf( ":kotlin-stdlib-jdk7:compileTestKotlin", ":kotlin-stdlib-jdk8:compileTestKotlin", ":compiler:cli:compileKotlin", - ":compiler:frontend:compileKotlin", ":kotlin-scripting-compiler:compileKotlin", ":plugins:uast-kotlin:compileKotlin", ":plugins:uast-kotlin:compileTestKotlin", From a719656118d0264b9e38a5249d49442356dd3e6a Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Fri, 12 Feb 2021 13:33:51 +0300 Subject: [PATCH 068/368] Fix extracted metadata for IDE erased when scopes conflict, KT-44845 The root cause was that extractors for different scopes used the same base directory, and each erased its contents. Using different base dirs fixes the issue. Issue #KT-44845 --- .../kotlin/gradle/HierarchicalMppIT.kt | 35 +++++++++++++++++++ .../plugin/sources/DefaultKotlinSourceSet.kt | 2 +- .../sources/SourceSetMetadataStorageForIde.kt | 3 ++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt index e9cc1e7e4ce..e1367280f85 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/HierarchicalMppIT.kt @@ -585,6 +585,41 @@ class HierarchicalMppIT : BaseGradleIT() { } } + @Test + fun testMixedScopesFilesExistKt44845() { + publishThirdPartyLib(withGranularMetadata = true) + + transformNativeTestProjectWithPluginDsl("my-lib-foo", gradleVersion, "hierarchical-mpp-published-modules").run { + gradleBuildScript().appendText( + """ + ${"\n"} + dependencies { + "jvmAndJsMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2") + "jvmAndJsMainCompileOnly"("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1") + } + """.trimIndent() + ) + + testDependencyTransformations { reports -> + val reportsForJvmAndJsMain = reports.filter { it.sourceSetName == "jvmAndJsMain" } + val thirdPartyLib = reportsForJvmAndJsMain.single { + it.scope == "api" && it.groupAndModule.startsWith("com.example") + } + val coroutinesCore = reportsForJvmAndJsMain.single { + it.scope == "implementation" && it.groupAndModule.contains("kotlinx-coroutines-core") + } + val serialization = reportsForJvmAndJsMain.single { + it.scope == "compileOnly" && it.groupAndModule.contains("kotlinx-serialization-json") + } + listOf(thirdPartyLib, coroutinesCore, serialization).forEach { report -> + assertTrue(report.newVisibleSourceSets.isNotEmpty(), "Expected visible source sets for $report") + assertTrue(report.useFiles.isNotEmpty(), "Expected non-empty useFiles for $report") + report.useFiles.forEach { assertTrue(it.isFile, "Expected $it to exist for $report") } + } + } + } + } + private fun Project.testDependencyTransformations( subproject: String? = null, check: CompiledProject.(reports: Iterable) -> Unit diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/DefaultKotlinSourceSet.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/DefaultKotlinSourceSet.kt index 51712cbfbd9..3009f2a36bb 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/DefaultKotlinSourceSet.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/DefaultKotlinSourceSet.kt @@ -156,7 +156,7 @@ class DefaultKotlinSourceSet( ?.associateBy { ModuleIds.fromComponent(project, it.dependency) } ?: emptyMap() - val baseDir = SourceSetMetadataStorageForIde.sourceSetStorage(project, this@DefaultKotlinSourceSet.name) + val baseDir = SourceSetMetadataStorageForIde.sourceSetStorageWithScope(project, this@DefaultKotlinSourceSet.name, scope) if (metadataDependencyResolutionByModule.values.any { it is MetadataDependencyResolution.ChooseVisibleSourceSets }) { if (baseDir.isDirectory) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/SourceSetMetadataStorageForIde.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/SourceSetMetadataStorageForIde.kt index 922ad99e095..a1380cd09c3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/SourceSetMetadataStorageForIde.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/sources/SourceSetMetadataStorageForIde.kt @@ -39,4 +39,7 @@ object SourceSetMetadataStorageForIde { } fun sourceSetStorage(project: Project, sourceSetName: String) = projectStorage(project).resolve(sourceSetName) + + internal fun sourceSetStorageWithScope(project: Project, sourceSetName: String, scope: KotlinDependencyScope) = + sourceSetStorage(project, sourceSetName).resolve(scope.scopeName) } \ No newline at end of file From 6c6d43c29ae7d0e9f6b830d1ed19e200d9d087b9 Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Fri, 12 Feb 2021 16:21:09 +0300 Subject: [PATCH 069/368] JS: add missing reachable nodes data --- js/js.translator/testData/box/export/exportAllFile.kt | 1 + js/js.translator/testData/box/export/exportNestedClass.kt | 1 + .../testData/box/export/overriddenChainNonExportIntermediate.kt | 1 + .../box/export/overriddenExternalMethodWithSameNameMethod.kt | 1 + .../export/overriddenExternalMethodWithSameStableNameMethod.kt | 1 + js/js.translator/testData/box/export/overridenMethod.kt | 1 + js/js.translator/testData/box/vararg/jsExternalVarargFun.kt | 1 + 7 files changed, 7 insertions(+) diff --git a/js/js.translator/testData/box/export/exportAllFile.kt b/js/js.translator/testData/box/export/exportAllFile.kt index bddf364de5a..c72cb73f3cb 100644 --- a/js/js.translator/testData/box/export/exportAllFile.kt +++ b/js/js.translator/testData/box/export/exportAllFile.kt @@ -1,3 +1,4 @@ +// EXPECTED_REACHABLE_NODES: 1252 // IGNORE_BACKEND: JS // RUN_PLAIN_BOX_FUNCTION // INFER_MAIN_MODULE diff --git a/js/js.translator/testData/box/export/exportNestedClass.kt b/js/js.translator/testData/box/export/exportNestedClass.kt index 5bb3a61cecc..007281d02ed 100644 --- a/js/js.translator/testData/box/export/exportNestedClass.kt +++ b/js/js.translator/testData/box/export/exportNestedClass.kt @@ -1,3 +1,4 @@ +// EXPECTED_REACHABLE_NODES: 1252 // IGNORE_BACKEND: JS // RUN_PLAIN_BOX_FUNCTION // INFER_MAIN_MODULE diff --git a/js/js.translator/testData/box/export/overriddenChainNonExportIntermediate.kt b/js/js.translator/testData/box/export/overriddenChainNonExportIntermediate.kt index b04e9fc2b5e..0673087184a 100644 --- a/js/js.translator/testData/box/export/overriddenChainNonExportIntermediate.kt +++ b/js/js.translator/testData/box/export/overriddenChainNonExportIntermediate.kt @@ -1,3 +1,4 @@ +// EXPECTED_REACHABLE_NODES: 1252 // IGNORE_BACKEND: JS // RUN_PLAIN_BOX_FUNCTION // INFER_MAIN_MODULE diff --git a/js/js.translator/testData/box/export/overriddenExternalMethodWithSameNameMethod.kt b/js/js.translator/testData/box/export/overriddenExternalMethodWithSameNameMethod.kt index bc9a6222260..3bc1159c01f 100644 --- a/js/js.translator/testData/box/export/overriddenExternalMethodWithSameNameMethod.kt +++ b/js/js.translator/testData/box/export/overriddenExternalMethodWithSameNameMethod.kt @@ -1,3 +1,4 @@ +// EXPECTED_REACHABLE_NODES: 1252 // IGNORE_BACKEND: JS // RUN_PLAIN_BOX_FUNCTION // INFER_MAIN_MODULE diff --git a/js/js.translator/testData/box/export/overriddenExternalMethodWithSameStableNameMethod.kt b/js/js.translator/testData/box/export/overriddenExternalMethodWithSameStableNameMethod.kt index 3bc6dcae649..d7e05d74bd7 100644 --- a/js/js.translator/testData/box/export/overriddenExternalMethodWithSameStableNameMethod.kt +++ b/js/js.translator/testData/box/export/overriddenExternalMethodWithSameStableNameMethod.kt @@ -1,3 +1,4 @@ +// EXPECTED_REACHABLE_NODES: 1252 // IGNORE_BACKEND: JS // RUN_PLAIN_BOX_FUNCTION // INFER_MAIN_MODULE diff --git a/js/js.translator/testData/box/export/overridenMethod.kt b/js/js.translator/testData/box/export/overridenMethod.kt index 8f9d5e4658b..a1b956ef1b1 100644 --- a/js/js.translator/testData/box/export/overridenMethod.kt +++ b/js/js.translator/testData/box/export/overridenMethod.kt @@ -1,3 +1,4 @@ +// EXPECTED_REACHABLE_NODES: 1274 abstract class Foo1 { abstract fun ok(): String } diff --git a/js/js.translator/testData/box/vararg/jsExternalVarargFun.kt b/js/js.translator/testData/box/vararg/jsExternalVarargFun.kt index ac5ab0cc284..dd93b013813 100644 --- a/js/js.translator/testData/box/vararg/jsExternalVarargFun.kt +++ b/js/js.translator/testData/box/vararg/jsExternalVarargFun.kt @@ -1,3 +1,4 @@ +// EXPECTED_REACHABLE_NODES: 1257 //KT-42357 // FILE: main.kt From 3ebeca585227a0164401aa18e5c2ccc2e8002aa6 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 5 Feb 2021 15:23:04 +0300 Subject: [PATCH 070/368] JVM_IR: use indy SAM conversions in jvmTarget 1.8+, fix bridges KT-44278 KT-26060 KT-42621 --- .../kotlin/codegen/state/GenerationState.kt | 7 +- .../FirBlackBoxCodegenTestGenerated.java | 100 +++- .../kotlin/backend/jvm/JvmSymbols.kt | 44 +- .../jvm/intrinsics/JvmInvokeDynamic.kt | 2 +- .../jvm/lower/FunctionReferenceLowering.kt | 502 ++++++++++++++---- .../backend/jvm/lower/TypeOperatorLowering.kt | 128 +++-- .../kotlin/ir/types/irTypePredicates.kt | 1 + .../ir/util/DeepCopyIrTreeWithSymbols.kt | 9 + .../annotations/annotatedLambda/samLambda.kt | 6 +- .../lambdas/lambdaSerializable.kt | 2 +- .../sam/simpleFunInterfaceConstructor.kt | 14 + .../specializedGenerics/covariantOverride.kt | 13 + .../covariantOverrideWithNNothing.kt | 20 + .../specializedGenerics/inheritedWithChar.kt | 15 + .../inheritedWithCharDiamond.kt | 18 + .../inheritedWithCharExplicitlyOverridden.kt | 16 + .../specializedGenerics/inheritedWithInt.kt | 17 + .../inheritedWithString.kt | 14 + .../specializedGenerics/inheritedWithUnit.kt | 22 + .../mixGenericAndIntArray.kt | 40 ++ .../mixGenericAndString.kt | 29 + .../mixGenericArrayAndArrayOfString.kt | 32 ++ .../mixPrimitiveAndBoxed.kt | 32 ++ .../voidReturnTypeAsGeneric.kt | 2 +- .../kt6691_lambdaInSamConstructor.kt | 4 +- .../box/sam/adapters/genericSignature.kt | 2 + compiler/testData/codegen/box/sam/kt11519.kt | 2 + .../codegen/box/sam/kt11519Constructor.kt | 2 + compiler/testData/codegen/box/sam/kt11696.kt | 2 + ...dSubstitutedTypeForCallableSamParameter.kt | 2 + .../box/sam/samConstructorGenericSignature.kt | 2 + ...mAdapterForJavaInterfaceWithNullability.kt | 1 + ...AdapterForJavaInterfaceWithNullability.txt | 36 +- .../codegen/bytecodeListing/sam/kt16650.kt | 1 + .../bytecodeListing/sam/kt16650_ir.txt | 28 +- .../sam/lambdaGenericFunInterface_ir.txt | 12 +- .../sam/lambdaGenericSamInterface_ir.txt | 24 +- .../sam/lambdaSpecializedFunInterface.kt | 1 + .../sam/lambdaSpecializedFunInterface_ir.txt | 13 +- .../sam/lambdaSpecializedSamInterface_ir.txt | 13 +- .../sam/samWrapperForNullInitialization.kt | 4 +- .../samWrapperForNullableInitialization.kt | 4 +- .../bytecodeText/sam/samWrapperOfLambda.kt | 2 +- .../codegen/BlackBoxCodegenTestGenerated.java | 100 +++- .../IrBlackBoxCodegenTestGenerated.java | 100 +++- .../LightAnalysisModeTestGenerated.java | 88 ++- .../IrJsCodegenBoxES6TestGenerated.java | 13 + .../IrJsCodegenBoxTestGenerated.java | 13 + .../semantics/JsCodegenBoxTestGenerated.java | 13 + .../IrCodegenBoxWasmTestGenerated.java | 13 + 50 files changed, 1293 insertions(+), 287 deletions(-) create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/simpleFunInterfaceConstructor.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverride.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharDiamond.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharExplicitlyOverridden.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithInt.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithString.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithUnit.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndIntArray.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndString.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericArrayAndArrayOfString.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixPrimitiveAndBoxed.kt rename compiler/testData/codegen/box/invokedynamic/sam/{ => specializedGenerics}/voidReturnTypeAsGeneric.kt (89%) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt index 92239187b51..f0869360e3a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt @@ -209,11 +209,12 @@ class GenerationState private constructor( val samConversionsScheme = run { val fromConfig = configuration.get(JVMConfigurationKeys.SAM_CONVERSIONS) - ?: JvmClosureGenerationScheme.DEFAULT - if (target >= fromConfig.minJvmTarget) + if (fromConfig != null && target >= fromConfig.minJvmTarget) fromConfig + else if (target < JvmTarget.JVM_1_8) + JvmClosureGenerationScheme.CLASS else - JvmClosureGenerationScheme.DEFAULT + JvmClosureGenerationScheme.INDY } val lambdasScheme = run { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 3ec06a446bc..09b3be63e37 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -19957,6 +19957,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionOnFunctionReference.kt"); } + @Test + @TestMetadata("simpleFunInterfaceConstructor.kt") + public void testSimpleFunInterfaceConstructor() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/simpleFunInterfaceConstructor.kt"); + } + @Test @TestMetadata("simpleIndyFunInterface.kt") public void testSimpleIndyFunInterface() throws Exception { @@ -19993,12 +19999,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/unboundFunctionReferenceEquality.kt"); } - @Test - @TestMetadata("voidReturnTypeAsGeneric.kt") - public void testVoidReturnTypeAsGeneric() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/voidReturnTypeAsGeneric.kt"); - } - @Nested @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @@ -20080,6 +20080,94 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/genericFunInterfaceWithInlineString.kt"); } } + + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics") + @TestDataPath("$PROJECT_ROOT") + public class SpecializedGenerics { + @Test + public void testAllFilesPresentInSpecializedGenerics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("covariantOverride.kt") + public void testCovariantOverride() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverride.kt"); + } + + @Test + @TestMetadata("covariantOverrideWithNNothing.kt") + public void testCovariantOverrideWithNNothing() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt"); + } + + @Test + @TestMetadata("inheritedWithChar.kt") + public void testInheritedWithChar() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt"); + } + + @Test + @TestMetadata("inheritedWithCharDiamond.kt") + public void testInheritedWithCharDiamond() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharDiamond.kt"); + } + + @Test + @TestMetadata("inheritedWithCharExplicitlyOverridden.kt") + public void testInheritedWithCharExplicitlyOverridden() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharExplicitlyOverridden.kt"); + } + + @Test + @TestMetadata("inheritedWithInt.kt") + public void testInheritedWithInt() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithInt.kt"); + } + + @Test + @TestMetadata("inheritedWithString.kt") + public void testInheritedWithString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithString.kt"); + } + + @Test + @TestMetadata("inheritedWithUnit.kt") + public void testInheritedWithUnit() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithUnit.kt"); + } + + @Test + @TestMetadata("mixGenericAndIntArray.kt") + public void testMixGenericAndIntArray() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndIntArray.kt"); + } + + @Test + @TestMetadata("mixGenericAndString.kt") + public void testMixGenericAndString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndString.kt"); + } + + @Test + @TestMetadata("mixGenericArrayAndArrayOfString.kt") + public void testMixGenericArrayAndArrayOfString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericArrayAndArrayOfString.kt"); + } + + @Test + @TestMetadata("mixPrimitiveAndBoxed.kt") + public void testMixPrimitiveAndBoxed() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixPrimitiveAndBoxed.kt"); + } + + @Test + @TestMetadata("voidReturnTypeAsGeneric.kt") + public void testVoidReturnTypeAsGeneric() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/voidReturnTypeAsGeneric.kt"); + } + } } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt index 185fdb02864..7bd0daf7d21 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmSymbols.kt @@ -545,19 +545,53 @@ class JvmSymbols( returnType = dst.defaultType }.symbol - val indySamConversionIntrinsic: IrSimpleFunctionSymbol = + val arrayOfAnyType = irBuiltIns.arrayClass.typeWith(irBuiltIns.anyType) + + // Intrinsic to represent closure creation using INVOKEDYNAMIC with LambdaMetafactory.{metafactory, altMetafactory} + // as a bootstrap method. + // fun ``( + // samMethodType, + // implMethodReference, + // instantiatedMethodType, + // vararg extraOverriddenMethodTypes + // ): SAM_TYPE + // where: + // `SAM_TYPE` is a single abstract method interface, which is implemented by a resulting closure; + // `samMethodType` is a method type (signature and return type) of a method to be implemented by a closure; + // `implMethodReference` is an actual implementation method (e.g., method for a lambda function); + // `instantiatedMethodType` is a specialized implementation method type; + // `extraOverriddenMethodTypes` is a possibly empty vararg of additional methods to be implemented by a closure. + // + // At this stage, "method types" are represented as IrRawFunctionReference nodes for the functions with corresponding signature. + // `` call rewriting selects a particular bootstrap method (`metafactory` or `altMetafactory`) + // and takes care about low-level detains of bootstrap method arguments representation. + // Note that `instantiatedMethodType` is a raw function reference to a "fake" specialized function (belonging to a "fake" specialized + // class) that doesn't exist in the bytecode and serves only the purpose of representing a corresponding method signature. + // + // Resulting closure produced by INVOKEDYNAMIC instruction has (approximately) the following shape: + // object : ${SAM_TYPE} { + // override fun ${samMethodName}(${instantiatedMethodType}) = ${implMethod}(...) + // // bridge fun ${samMethodName}(${bridgeMethodType}) = ${instantiatedMethod}(...) + // // for each 'bridgeMethodType' in [ ${samMethodType}, *${extraOverriddenMethodTypes} ] + // } + val indyLambdaMetafactoryIntrinsic: IrSimpleFunctionSymbol = irFactory.buildFun { - name = Name.special("") + name = Name.special("") origin = IrDeclarationOrigin.IR_BUILTINS_STUB }.apply { parent = kotlinJvmInternalPackage val samType = addTypeParameter("SAM_TYPE", irBuiltIns.anyType) - addValueParameter("method", irBuiltIns.anyNType) + addValueParameter("samMethodType", irBuiltIns.anyNType) + addValueParameter("implMethodReference", irBuiltIns.anyNType) + addValueParameter("instantiatedMethodType", irBuiltIns.anyNType) + addValueParameter { + name = Name.identifier("extraOverriddenMethodTypes") + type = arrayOfAnyType + varargElementType = irBuiltIns.anyType + } returnType = samType.defaultType }.symbol - val arrayOfAnyType = irBuiltIns.arrayClass.typeWith(irBuiltIns.anyType) - // Intrinsic to represent INVOKEDYNAMIC calls in IR. // fun ``( // dynamicCall: T, diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/JvmInvokeDynamic.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/JvmInvokeDynamic.kt index 5593a189ee2..f7c11bec877 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/JvmInvokeDynamic.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/intrinsics/JvmInvokeDynamic.kt @@ -136,9 +136,9 @@ object JvmInvokeDynamic : IntrinsicMethod() { ?: fail("Argument in ${irCall.symbol.owner.name} call is expected to be a raw function reference") val irOriginalFun = irRawFunRef.symbol.owner as? IrSimpleFunction ?: fail("IrSimpleFunction expected: ${irRawFunRef.symbol.owner.render()}") + val superType = irCall.getTypeArgument(0) as? IrSimpleType ?: fail("Type argument expected") - val patchedSuperType = replaceTypeArgumentsWithNullable(superType) val fakeClass = codegen.context.irFactory.buildClass { name = Name.special("") } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt index a640e7a7325..8df71804e22 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt @@ -25,13 +25,14 @@ import org.jetbrains.kotlin.ir.builders.declarations.* import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.* +import org.jetbrains.kotlin.ir.overrides.buildFakeOverrideMember import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol +import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.SpecialNames -import org.jetbrains.kotlin.utils.addIfNotNull internal val functionReferencePhase = makeIrFilePhase( ::FunctionReferenceLowering, @@ -92,20 +93,24 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) expression.statements.dropLast(1).forEach { it.transform(this, null) } reference.transformChildrenVoid(this) - if (shouldGenerateIndyLambdas && canUseIndySamConversion(reference, reference.type, true)) { - return wrapLambdaReferenceWithIndySamConversion(expression, reference) + if (shouldGenerateIndyLambdas) { + val lambdaMetafactoryArguments = getLambdaMetafactoryArgumentsOrNull(reference, reference.type, true) + if (lambdaMetafactoryArguments != null) { + return wrapLambdaReferenceWithIndySamConversion(expression, reference, lambdaMetafactoryArguments) + } } return FunctionReferenceBuilder(reference).build() } - private fun wrapLambdaReferenceWithIndySamConversion(expression: IrBlock, reference: IrFunctionReference): IrBlock { - expression.statements[expression.statements.size - 1] = wrapWithIndySamConversion(reference.type, reference) - val irLambda = reference.symbol.owner - // JDK LambdaMetafactory can't adapt '(...)V' to '(...)Lkotlin/Unit;'. - if (irLambda.returnType.isUnit()) { - irLambda.returnType = irLambda.returnType.makeNullable() - } + private fun wrapLambdaReferenceWithIndySamConversion( + expression: IrBlock, + reference: IrFunctionReference, + lambdaMetafactoryArguments: LambdaMetafactoryArguments + ): IrBlock { + val indySamConversion = wrapWithIndySamConversion(reference.type, lambdaMetafactoryArguments) + expression.statements[expression.statements.size - 1] = indySamConversion + expression.type = indySamConversion.type return expression } @@ -140,49 +145,389 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) reference.transformChildrenVoid() val samSuperType = expression.typeOperand - return if (shouldGenerateIndySamConversions && canUseIndySamConversion(reference, samSuperType, false)) { - wrapSamConversionArgumentWithIndySamConversion(expression) - } else { - FunctionReferenceBuilder(reference, samSuperType).build() + + if (shouldGenerateIndySamConversions) { + val lambdaMetafactoryArguments = getLambdaMetafactoryArgumentsOrNull(reference, samSuperType, false) + if (lambdaMetafactoryArguments != null) { + return wrapSamConversionArgumentWithIndySamConversion(expression, lambdaMetafactoryArguments) + } } + + return FunctionReferenceBuilder(reference, samSuperType).build() } - private fun canUseIndySamConversion(reference: IrFunctionReference, samSuperType: IrType, plainLambda: Boolean): Boolean { + private class LambdaMetafactoryArguments( + val samMethod: IrSimpleFunction, + val fakeInstanceMethod: IrSimpleFunction, + val implMethodReference: IrFunctionReference, + val extraOverriddenMethods: List + ) + + /** + * @see java.lang.invoke.LambdaMetafactory + */ + private fun getLambdaMetafactoryArgumentsOrNull( + reference: IrFunctionReference, + samType: IrType, + plainLambda: Boolean + ): LambdaMetafactoryArguments? { // Can't use JDK LambdaMetafactory for function references by default (because of 'equals'). // TODO special mode that would generate indy everywhere? if (reference.origin != IrStatementOrigin.LAMBDA) - return false + return null - // TODO wrap intrinsic function in lambda? - if (context.irIntrinsics.getIntrinsic(reference.symbol) != null) - return false + val samClass = samType.getClass() + ?: throw AssertionError("SAM type is not a class: ${samType.render()}") + val samMethod = samClass.getSingleAbstractMethod() + ?: throw AssertionError("SAM class has no single abstract method: ${samClass.render()}") - // Can't use JDK LambdaMetafactory for fun interface with suspend fun - if (samSuperType.getSingleAbstractMethod()?.isSuspend == true) - return false + // Can't use JDK LambdaMetafactory for fun interface with suspend fun. + if (samMethod.isSuspend) + return null - // Can't use JDK LambdaMetafactory if lambda signature contains an inline class mapped to a non-null reference type. - val target = reference.symbol.owner - if (target.extensionReceiverParameter?.run { type.isProhibitedTypeForIndySamConversion() } == true || - target.valueParameters.any { it.type.isProhibitedTypeForIndySamConversion() } || - target.returnType.isProhibitedTypeForIndySamConversion() - ) - return false + // Can't use JDK LambdaMetafactory for fun interfaces that require delegation to $DefaultImpls. + if (samClass.requiresDelegationToDefaultImpls()) + return null + val target = reference.symbol.owner as? IrSimpleFunction + ?: throw AssertionError("Simple function expected: ${reference.symbol.owner.render()}") + + // Can't use JDK LambdaMetafactory for annotated lambdas. + // JDK LambdaMetafactory doesn't copy annotations from implementation method to an instance method in a + // corresponding synthetic class, which doesn't look like a binary compatible change. + // TODO relaxed mode? + if (target.annotations.isNotEmpty()) + return null + + // Don't use JDK LambdaMetafactory for big arity lambdas. if (plainLambda) { var parametersCount = target.valueParameters.size if (target.extensionReceiverParameter != null) ++parametersCount if (parametersCount >= BuiltInFunctionArity.BIG_ARITY) - return false + return null } // Can't use indy-based SAM conversion inside inline fun (Ok in inline lambda). if (target.parents.any { it.isInlineFunction() || it.isCrossinlineLambda() }) - return false + return null - return true + // Do the hard work of matching Kotlin functional interface hierarchy against LambdaMetafactory constraints. + // Briefly: sometimes we have to force boxing on the primitive and inline class values, sometimes we have to keep them unboxed. + // If this results in conflicting requirements, we can't use INVOKEDYNAMIC with LambdaMetafactory for creating a closure. + return getLambdaMetafactoryArgsOrNullInner(reference, samMethod, samType, target) } + private fun IrClass.requiresDelegationToDefaultImpls(): Boolean { + for (irMemberFun in functions) { + if (irMemberFun.modality == Modality.ABSTRACT) + continue + val irImplFun = + if (irMemberFun.isFakeOverride) + irMemberFun.findInterfaceImplementation(context.state.jvmDefaultMode) + ?: continue + else + irMemberFun + if (irImplFun.origin == IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB) + continue + if (!irImplFun.isCompiledToJvmDefault(context.state.jvmDefaultMode)) + return true + } + return false + } + + private fun getLambdaMetafactoryArgsOrNullInner( + reference: IrFunctionReference, + samMethod: IrSimpleFunction, + samType: IrType, + implLambda: IrSimpleFunction + ): LambdaMetafactoryArguments? { + val nonFakeOverriddenFuns = samMethod.allOverridden().filterNot { it.isFakeOverride } + val relevantOverriddenFuns = if (samMethod.isFakeOverride) nonFakeOverriddenFuns else nonFakeOverriddenFuns + samMethod + + // Create a fake instance method as if it was defined in a class implementing SAM interface + // (such class would be eventually created by LambdaMetafactory at run-time). + val fakeClass = context.irFactory.buildClass { name = Name.special("") } + fakeClass.parent = context.ir.symbols.kotlinJvmInternalInvokeDynamicPackage + val fakeInstanceMethod = buildFakeOverrideMember(samType, samMethod, fakeClass) as IrSimpleFunction + (fakeInstanceMethod as IrFakeOverrideFunction).acquireSymbol(IrSimpleFunctionSymbolImpl()) + fakeInstanceMethod.overriddenSymbols = listOf(samMethod.symbol) + + // Compute signature adaptation constraints for a fake instance method signature against all relevant overrides. + // If at any step we encounter a conflict (e.g., one override requires boxing a parameter, and another requires + // to keep it unboxed), we can't adapt this signature and can't use LambdaMetafactory to create a closure. + // + // Note that those constraints are not checked precisely in JDK 1.8 (jdk1.8.0_231), but are checked more strictly + // in later JDK versions and in D8 (so if you see an exception from D8 in codegen test failures, corresponding code + // with INVOKEDYNAMIC would quite likely fail on JDK 9 and beyond). + // + // Example 1 (requires boxing): + // fun interface IFoo { + // fun foo(x: T) + // } + // val t = IFoo { println(it + 1) } + // Here IFoo::foo requires 'x' to be reference type (even though corresponding lambda accepts a primitive int). + // this + // + // Example 2 (no explicit override, boxing-unboxing conflict): + // fun interface IFooT { + // fun foo(x: T) + // } + // fun interface IFooInt { + // fun foo(x: Int) + // } + // fun interface IFooMix : IFooT, IFooInt + // val t = IFooMix { println(it + 1) } + // Here IFooT::foo requires 'x' to be of a reference type, and IFooInt::foo requires 'x' to be of a primitive type. + // LambdaMetafactory can't handle such case. + // + // Example 3 (explicit override, boxing-unboxing conflict): + // fun interface IFooT { + // fun foo(x: T) + // } + // fun interface IFooInt { + // fun foo(x: Int) + // } + // fun interface IFooMix : IFooT, IFooInt { + // override fun foo(x: Int) + // } + // val t = IFooMix { println(it + 1) } + // Here, even though we have an explicit 'override fun foo(x: Int)' in IFooMix, we don't generate a bridge for 'foo' in IFooMix. + // Thus, class for a lambda created by LambdaMetafactory should provide a bridge for 'foo'. + // Thus, 'x' should be of a reference type. + // On the other hand, it should also override IFooInt#foo, where 'x' should be a primitive type. + // LambdaMetafactory can't handle such case. + // + // TODO accept Example 3 if IFooMix is compiled with default interface methods + // Note that this is a conservative check; if we reject LambdaMetafactory-based closure generation scheme, compiler would still + // generate proper (although somewhat sub-optimal) code with explicit class for a corresponding SAM-converted lambda. + val signatureAdaptationConstraints = run { + var result = SignatureAdaptationConstraints(emptyMap(), null) + for (overriddenFun in relevantOverriddenFuns) { + val constraintsFromOverridden = computeSignatureAdaptationConstraints(fakeInstanceMethod, overriddenFun) + ?: return null + result = joinSignatureAdaptationConstraints(result, constraintsFromOverridden) + ?: return null + } + result + } + + // We should have bailed out before if we encountered any kind of type adaptation conflict. + // Still, check that we are fine - just in case. + if (signatureAdaptationConstraints.returnType == TypeAdaptationConstraint.CONFLICT || + signatureAdaptationConstraints.valueParameters.values.any { it == TypeAdaptationConstraint.CONFLICT } + ) + return null + + adaptFakeInstanceMethodSignature(fakeInstanceMethod, signatureAdaptationConstraints) + + adaptLambdaSignature(implLambda, fakeInstanceMethod, signatureAdaptationConstraints) + + if (samMethod.isFakeOverride && nonFakeOverriddenFuns.size == 1) { + return LambdaMetafactoryArguments(nonFakeOverriddenFuns.single(), fakeInstanceMethod, reference, listOf()) + } + return LambdaMetafactoryArguments(samMethod, fakeInstanceMethod, reference, nonFakeOverriddenFuns) + } + + private fun adaptLambdaSignature( + lambda: IrSimpleFunction, + fakeInstanceMethod: IrSimpleFunction, + constraints: SignatureAdaptationConstraints + ) { + val lambdaParameters = collectValueParameters(lambda) + val methodParameters = collectValueParameters(fakeInstanceMethod) + if (lambdaParameters.size != methodParameters.size) + throw AssertionError( + "Mismatching lambda and instance method parameters:\n" + + "lambda: ${lambda.render()}\n" + + " (${lambdaParameters.size} parameters)\n" + + "instance method: ${fakeInstanceMethod.render()}\n" + + " (${methodParameters.size} parameters)" + ) + for ((lambdaParameter, methodParameter) in lambdaParameters.zip(methodParameters)) { + // TODO box inline class parameters only? + val parameterConstraint = constraints.valueParameters[methodParameter] + if (parameterConstraint == TypeAdaptationConstraint.FORCE_BOXING) { + lambdaParameter.type = lambdaParameter.type.makeNullable() + } + } + if (constraints.returnType == TypeAdaptationConstraint.FORCE_BOXING) { + lambda.returnType = lambda.returnType.makeNullable() + } + } + + private fun adaptFakeInstanceMethodSignature(fakeInstanceMethod: IrSimpleFunction, constraints: SignatureAdaptationConstraints) { + for ((valueParameter, constraint) in constraints.valueParameters) { + if (valueParameter.parent != fakeInstanceMethod) + throw AssertionError( + "Unexpected value parameter: ${valueParameter.render()}; fakeInstanceMethod:\n" + + fakeInstanceMethod.dump() + ) + if (constraint == TypeAdaptationConstraint.FORCE_BOXING) { + valueParameter.type = valueParameter.type.makeNullable() + } + } + if (constraints.returnType == TypeAdaptationConstraint.FORCE_BOXING) { + fakeInstanceMethod.returnType = fakeInstanceMethod.returnType.makeNullable() + } + } + + private enum class TypeAdaptationConstraint { + FORCE_BOXING, + KEEP_UNBOXED, + CONFLICT + } + + private class SignatureAdaptationConstraints( + val valueParameters: Map, + val returnType: TypeAdaptationConstraint? + ) + + private fun computeSignatureAdaptationConstraints( + adapteeFun: IrSimpleFunction, + expectedFun: IrSimpleFunction + ): SignatureAdaptationConstraints? { + val returnTypeConstraint = computeReturnTypeAdaptationConstraint(adapteeFun, expectedFun) + if (returnTypeConstraint == TypeAdaptationConstraint.CONFLICT) + return null + + val valueParameterConstraints = HashMap() + val adapteeParameters = collectValueParameters(adapteeFun) + val expectedParameters = collectValueParameters(expectedFun) + if (adapteeParameters.size != expectedParameters.size) + throw AssertionError( + "Mismatching value parameters:\n" + + "adaptee: ${adapteeFun.render()}\n" + + " ${adapteeParameters.size} value parameters;\n" + + "expected: ${expectedFun.render()}\n" + + " ${expectedParameters.size} value parameters." + ) + for ((adapteeParameter, expectedParameter) in adapteeParameters.zip(expectedParameters)) { + val parameterConstraint = computeParameterTypeAdaptationConstraint(adapteeParameter.type, expectedParameter.type) + ?: continue + if (parameterConstraint == TypeAdaptationConstraint.CONFLICT) + return null + valueParameterConstraints[adapteeParameter] = parameterConstraint + } + + return SignatureAdaptationConstraints( + if (valueParameterConstraints.isEmpty()) emptyMap() else valueParameterConstraints, + returnTypeConstraint + ) + } + + private fun computeParameterTypeAdaptationConstraint(adapteeType: IrType, expectedType: IrType): TypeAdaptationConstraint? { + if (adapteeType !is IrSimpleType) + throw AssertionError("Simple type expected: ${adapteeType.render()}") + if (expectedType !is IrSimpleType) + throw AssertionError("Simple type expected: ${expectedType.render()}") + + // TODO what if adapteeType and/or expectedType are type parameters with JVM primitive type upper bounds? + + if (adapteeType.isNothing() || adapteeType.isNullableNothing()) + return TypeAdaptationConstraint.CONFLICT + + // ** JVM primitives ** + // All Kotlin types mapped to JVM primitive are final, + // and their supertypes are trivially mapped reference types. + if (adapteeType.isJvmPrimitiveType()) { + return if (expectedType.isJvmPrimitiveType()) + TypeAdaptationConstraint.KEEP_UNBOXED + else + TypeAdaptationConstraint.FORCE_BOXING + } + + // ** Inline classes ** + // All Kotlin inline classes are final, + // and their supertypes are trivially mapped to reference types. + val erasedAdapteeClass = getErasedClassForSignatureAdaptation(adapteeType) + if (erasedAdapteeClass.isInline) { + // Inline classes mapped to non-null reference types are a special case because they can't be boxed trivially. + // TODO consider adding a special type annotation to force boxing on an inline class type regardless of its underlying type. + val underlyingAdapteeType = getInlineClassUnderlyingType(erasedAdapteeClass) as? IrSimpleType + ?: throw AssertionError("Underlying type for inline class should be a simple type: ${erasedAdapteeClass.render()}") + if (!underlyingAdapteeType.hasQuestionMark && !underlyingAdapteeType.isJvmPrimitiveType()) { + return TypeAdaptationConstraint.CONFLICT + } + + val erasedExpectedClass = getErasedClassForSignatureAdaptation(expectedType) + return if (erasedExpectedClass.isInline) { + // LambdaMetafactory doesn't know about method mangling. + TypeAdaptationConstraint.CONFLICT + } else { + // Trying to pass inline class value as non-inline class value (Any or other supertype) + // => box it + TypeAdaptationConstraint.FORCE_BOXING + } + } + + // Other cases don't enforce type adaptation + return null + } + + private fun getErasedClassForSignatureAdaptation(irType: IrSimpleType): IrClass = + when (val classifier = irType.classifier.owner) { + is IrTypeParameter -> classifier.erasedUpperBound + is IrClass -> classifier + else -> + throw AssertionError("Unexpected classifier: ${classifier.render()}") + } + + private fun computeReturnTypeAdaptationConstraint( + adapteeFun: IrSimpleFunction, + expectedFun: IrSimpleFunction + ): TypeAdaptationConstraint? { + val adapteeReturnType = adapteeFun.returnType + if (adapteeReturnType.isUnit()) { + // Can't mix '()V' and '()Lkotlin.Unit;' or '()Ljava.lang.Object;' in supertype method signatures. + return if (expectedFun.returnType.isUnit()) + TypeAdaptationConstraint.KEEP_UNBOXED + else { + TypeAdaptationConstraint.FORCE_BOXING + } + } + + val expectedReturnType = expectedFun.returnType + return computeParameterTypeAdaptationConstraint(adapteeReturnType, expectedReturnType) + } + + private fun joinSignatureAdaptationConstraints( + sig1: SignatureAdaptationConstraints, + sig2: SignatureAdaptationConstraints + ): SignatureAdaptationConstraints? { + val newReturnTypeConstraint = composeTypeAdaptationConstraints(sig1.returnType, sig2.returnType) + if (newReturnTypeConstraint == TypeAdaptationConstraint.CONFLICT) + return null + + val newValueParameterConstraints = + when { + sig1.valueParameters.isEmpty() -> sig2.valueParameters + sig2.valueParameters.isEmpty() -> sig1.valueParameters + else -> { + val joined = HashMap() + joined.putAll(sig1.valueParameters) + for ((vp2, t2) in sig2.valueParameters.entries) { + val tx = composeTypeAdaptationConstraints(joined[vp2], t2) ?: continue + if (tx == TypeAdaptationConstraint.CONFLICT) + return null + joined[vp2] = tx + } + joined + } + } + + return SignatureAdaptationConstraints(newValueParameterConstraints, newReturnTypeConstraint) + } + + private fun composeTypeAdaptationConstraints(t1: TypeAdaptationConstraint?, t2: TypeAdaptationConstraint?): TypeAdaptationConstraint? = + when { + t1 == null -> t2 + t2 == null -> t1 + t1 == t2 -> t1 + else -> + TypeAdaptationConstraint.CONFLICT + } + + private fun IrDeclarationParent.isInlineFunction() = this is IrSimpleFunction && isInline && origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA @@ -192,42 +537,29 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) inlineLambdaToValueParameter[irFun]?.isCrossinline == true } - private fun IrType.isProhibitedTypeForIndySamConversion(): Boolean { - if (this !is IrSimpleType) return false - - val erasedClass = when (val classifier = classifier.owner) { - is IrTypeParameter -> classifier.erasedUpperBound - is IrClass -> classifier - else -> throw AssertionError("Unexpected classifier: ${classifier.render()}") - } - if (!erasedClass.isInline) return false - - val underlyingType = getInlineClassUnderlyingType(erasedClass) as? IrSimpleType - ?: throw AssertionError("Underlying type for inline class should be a simple type: ${erasedClass.render()}") - return !underlyingType.hasQuestionMark && !underlyingType.isJvmPrimitiveType() - } - private fun IrType.isJvmPrimitiveType() = isBoolean() || isChar() || isByte() || isShort() || isInt() || isLong() || isFloat() || isDouble() - private fun wrapSamConversionArgumentWithIndySamConversion(expression: IrTypeOperatorCall): IrExpression { + private fun wrapSamConversionArgumentWithIndySamConversion( + expression: IrTypeOperatorCall, + lambdaMetafactoryArguments: LambdaMetafactoryArguments + ): IrExpression { val samType = expression.typeOperand return when (val argument = expression.argument) { is IrFunctionReference -> { - wrapWithIndySamConversion(samType, argument) + wrapWithIndySamConversion(samType, lambdaMetafactoryArguments) } is IrBlock -> { - val last = argument.statements.last() - val functionReference = last as? IrFunctionReference - ?: throw AssertionError("Function reference expected: ${last.render()}") - argument.statements[argument.statements.size - 1] = wrapWithIndySamConversion(samType, functionReference) + val indySamConversion = wrapWithIndySamConversion(samType, lambdaMetafactoryArguments) + argument.statements[argument.statements.size - 1] = indySamConversion + argument.type = indySamConversion.type return argument } else -> throw AssertionError("Block or function reference expected: ${expression.render()}") } } - private val jvmIndySamConversionIntrinsic = context.ir.symbols.indySamConversionIntrinsic + private val jvmIndyLambdaMetafactoryIntrinsic = context.ir.symbols.indyLambdaMetafactoryIntrinsic private val specialNullabilityAnnotationsFqNames = setOf( @@ -235,59 +567,37 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) context.ir.symbols.enhancedNullabilityAnnotationFqName ) - private fun wrapWithIndySamConversion(samType: IrType, irFunRef: IrFunctionReference): IrCall { - patchSignatureForIndySamConversion(irFunRef.symbol.owner, samType) + private fun wrapWithIndySamConversion( + samType: IrType, + lambdaMetafactoryArguments: LambdaMetafactoryArguments + ): IrCall { val notNullSamType = samType.makeNotNull() .removeAnnotations { it.type.classFqName in specialNullabilityAnnotationsFqNames } return context.createJvmIrBuilder(currentScope!!.scope.scopeOwnerSymbol).run { - // We should produce the following expression: - // ``(method) - // where: - // - 'samType' is a substituted SAM type; - // - 'method' is a function reference to the actual method we are going to call - // (note that we need an IrFunctionReference here, so that further transformations would extract closure properly). - irCall(jvmIndySamConversionIntrinsic, notNullSamType).apply { + // See [org.jetbrains.kotlin.backend.jvm.JvmSymbols::indyLambdaMetafactoryIntrinsic]. + irCall(jvmIndyLambdaMetafactoryIntrinsic, notNullSamType).apply { putTypeArgument(0, notNullSamType) - putValueArgument(0, irFunRef) + putValueArgument(0, irRawFunctionRef(lambdaMetafactoryArguments.samMethod)) + putValueArgument(1, lambdaMetafactoryArguments.implMethodReference) + putValueArgument(2, irRawFunctionRef(lambdaMetafactoryArguments.fakeInstanceMethod)) + putValueArgument(3, irVarargOfRawFunctionRefs(lambdaMetafactoryArguments.extraOverriddenMethods)) } } } - private fun patchSignatureForIndySamConversion(irLambda: IrFunction, samType: IrType) { - if (irLambda.origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA) - throw AssertionError("Can't patch a signature of a non-lambda: ${irLambda.render()}") + private fun IrBuilderWithScope.irRawFunctionRef(irFun: IrFunction) = + irRawFunctionReferefence(context.irBuiltIns.anyType, irFun.symbol) - val samMethod = samType.getSingleAbstractMethod() - ?: throw AssertionError("SAM method not found:\n${samType.render()}") + private fun IrBuilderWithScope.irVarargOfRawFunctionRefs(irFuns: List) = + irVararg(context.irBuiltIns.anyType, irFuns.map { irRawFunctionRef(it) }) - val samMethodParameters = collectValueParameters(samMethod) - val irLambdaParameters = collectValueParameters(irLambda) - if (samMethodParameters.size != irLambdaParameters.size) { - throw AssertionError( - "SAM method and implementing lambda have mismatching value parameters " + - "(${samMethodParameters.size} != ${irLambdaParameters.size}:\n" + - "samMethod: ${samMethod.render()}\n" + - "lambda: ${irLambda.render()}" - ) + private fun collectValueParameters(irFun: IrFunction): List { + if (irFun.extensionReceiverParameter == null) + return irFun.valueParameters + return ArrayList().apply { + add(irFun.extensionReceiverParameter!!) + addAll(irFun.valueParameters) } - - for ((irLambdaParameter, samMethodParameter) in irLambdaParameters.zip(samMethodParameters)) { - irLambdaParameter.type = patchTypeForIndySamConversion(irLambdaParameter.type, samMethodParameter.type) - } - - irLambda.returnType = patchTypeForIndySamConversion(irLambda.returnType, samMethod.returnType) - } - - private fun collectValueParameters(irFunction: IrFunction): List = - ArrayList().apply { - addIfNotNull(irFunction.extensionReceiverParameter) - addAll(irFunction.valueParameters) - } - - private fun patchTypeForIndySamConversion(originalType: IrType, targetType: IrType): IrType { - if (originalType.isUnboxedInlineClassType() && !targetType.isUnboxedInlineClassType()) - return targetType - return originalType } private fun IrType.isUnboxedInlineClassType() = diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt index 04f6a0f3af8..bc52a44af97 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt @@ -15,7 +15,6 @@ import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.codegen.fileParent import org.jetbrains.kotlin.backend.jvm.ir.createJvmIrBuilder import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound -import org.jetbrains.kotlin.backend.jvm.ir.getSingleAbstractMethod import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.builders.* @@ -37,6 +36,8 @@ import org.jetbrains.kotlin.ir.visitors.acceptVoid import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.jetbrains.org.objectweb.asm.Handle import org.jetbrains.org.objectweb.asm.Opcodes +import org.jetbrains.org.objectweb.asm.commons.Method +import java.lang.invoke.LambdaMetafactory // After this pass runs there are only four kinds of IrTypeOperatorCalls left: // @@ -101,7 +102,7 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil builder.irAs(argument, type) } - private val indySamConversionIntrinsic = context.ir.symbols.indySamConversionIntrinsic + private val jvmIndyLambdaMetafactoryIntrinsic = context.ir.symbols.indyLambdaMetafactoryIntrinsic private val indyIntrinsic = context.ir.symbols.jvmIndyIntrinsic @@ -128,13 +129,17 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil putValueArgument(0, irRawFunctionReferefence(context.irBuiltIns.anyType, methodSymbol)) } + @Suppress("unused") private fun IrBuilderWithScope.jvmSubstitutedMethodType(ownerType: IrType, methodSymbol: IrFunctionSymbol) = irCall(substitutedMethodTypeIntrinsic, context.irBuiltIns.anyType).apply { putTypeArgument(0, ownerType) putValueArgument(0, irRawFunctionReferefence(context.irBuiltIns.anyType, methodSymbol)) } - private val lambdaMetafactoryHandle = + /** + * @see java.lang.invoke.LambdaMetafactory.metafactory + */ + private val jdkMetafactoryHandle = Handle( Opcodes.H_INVOKESTATIC, "java/lang/invoke/LambdaMetafactory", @@ -150,9 +155,26 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil false ) + /** + * @see java.lang.invoke.LambdaMetafactory.altMetafactory + */ + private val jdkAltMetafactoryHandle = + Handle( + Opcodes.H_INVOKESTATIC, + "java/lang/invoke/LambdaMetafactory", + "altMetafactory", + "(" + + "Ljava/lang/invoke/MethodHandles\$Lookup;" + + "Ljava/lang/String;" + + "Ljava/lang/invoke/MethodType;" + + "[Ljava/lang/Object;" + + ")Ljava/lang/invoke/CallSite;", + false + ) + override fun visitCall(expression: IrCall): IrExpression { return when (expression.symbol) { - indySamConversionIntrinsic -> updateIndySamConversionIntrinsicCall(expression) + jvmIndyLambdaMetafactoryIntrinsic -> rewriteIndyLambdaMetafactoryCall(expression) else -> super.visitCall(expression) } } @@ -160,46 +182,86 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil /** * @see FunctionReferenceLowering.wrapWithIndySamConversion */ - private fun updateIndySamConversionIntrinsicCall(call: IrCall): IrCall { + private fun rewriteIndyLambdaMetafactoryCall(call: IrCall): IrCall { fun fail(message: String): Nothing = throw AssertionError("$message, call:\n${call.dump()}") - // We expect: - // ``(method) - // where - // - 'samType' is a substituted SAM type; - // - 'method' is an IrFunctionReference to an actual method that should be called, - // with arguments captured by closure stored as function reference arguments. - // We replace it with JVM INVOKEDYNAMIC intrinsic. - val startOffset = call.startOffset val endOffset = call.endOffset val samType = call.getTypeArgument(0) as? IrSimpleType ?: fail("'samType' is expected to be a simple type") - val samMethod = samType.getSingleAbstractMethod() - ?: fail("'${samType.render()}' is not a SAM-type") - val irFunRef = call.getValueArgument(0) as? IrFunctionReference - ?: fail("'method' is expected to be 'IrFunctionReference'") - val funSymbol = irFunRef.symbol + val samMethodRef = call.getValueArgument(0) as? IrRawFunctionReference + ?: fail("'samMethodType' should be 'IrRawFunctionReference'") + val implFunRef = call.getValueArgument(1) as? IrFunctionReference + ?: fail("'implMethodReference' is expected to be 'IrFunctionReference'") + val implFunSymbol = implFunRef.symbol + val instanceMethodRef = call.getValueArgument(2) as? IrRawFunctionReference + ?: fail("'instantiatedMethodType' is expected to be 'IrRawFunctionReference'") - val dynamicCall = wrapClosureInDynamicCall(samType, samMethod, irFunRef) - - return context.createJvmIrBuilder( - funSymbol, // TODO actual symbol for outer scope - startOffset, endOffset - ).run { - val samMethodType = jvmOriginalMethodType(samMethod.symbol) - val irRawFunRef = irRawFunctionReferefence(irFunRef.type, funSymbol) - val instanceMethodType = jvmSubstitutedMethodType(samType, samMethod.symbol) - - jvmInvokeDynamic( - dynamicCall, - lambdaMetafactoryHandle, - listOf(samMethodType, irRawFunRef, instanceMethodType) - ) + val extraOverriddenMethods = run { + val extraOverriddenMethodVararg = call.getValueArgument(3) as? IrVararg + ?: fail("'extraOverriddenMethodTypes' is expected to be 'IrVararg'") + extraOverriddenMethodVararg.elements.map { + val ref = it as? IrRawFunctionReference + ?: fail("'extraOverriddenMethodTypes' elements are expected to be 'IrRawFunctionReference'") + ref.symbol.owner as? IrSimpleFunction + ?: fail("Extra overridden method is expected to be 'IrSimpleFunction': ${ref.symbol.owner.render()}") + } } + + val samMethod = samMethodRef.symbol.owner as? IrSimpleFunction + ?: fail("SAM method is expected to be 'IrSimpleFunction': ${samMethodRef.symbol.owner.render()}") + val instanceMethod = instanceMethodRef.symbol.owner as? IrSimpleFunction + ?: fail("Instance method is expected to be 'IrSimpleFunction': ${instanceMethodRef.symbol.owner.render()}") + + val dynamicCall = wrapClosureInDynamicCall(samType, samMethod, implFunRef) + + val requiredBridges = getOverriddenMethodsRequiringBridges(instanceMethod, samMethod, extraOverriddenMethods) + + return context.createJvmIrBuilder(implFunSymbol, startOffset, endOffset).run { + val samMethodType = jvmOriginalMethodType(samMethod.symbol) + val irRawFunRef = irRawFunctionReferefence(implFunRef.type, implFunSymbol) + val instanceMethodType = jvmOriginalMethodType(instanceMethodRef.symbol) + + if (requiredBridges.isNotEmpty()) { + val bridgeMethodTypes = requiredBridges.map { jvmOriginalMethodType(it.symbol) } + jvmInvokeDynamic( + dynamicCall, + jdkAltMetafactoryHandle, + listOf( + samMethodType, irRawFunRef, instanceMethodType, + irInt(LambdaMetafactory.FLAG_BRIDGES), + irInt(requiredBridges.size) + ) + bridgeMethodTypes + ) + } else { + jvmInvokeDynamic( + dynamicCall, + jdkMetafactoryHandle, + listOf(samMethodType, irRawFunRef, instanceMethodType) + ) + } + } + } + + private fun getOverriddenMethodsRequiringBridges( + instanceMethod: IrSimpleFunction, + samMethod: IrSimpleFunction, + extraOverriddenMethods: List + ): Collection { + val jvmInstanceMethod = context.methodSignatureMapper.mapAsmMethod(instanceMethod) + val jvmSamMethod = context.methodSignatureMapper.mapAsmMethod(samMethod) + + val signatureToNonFakeOverride = LinkedHashMap() + for (overridden in extraOverriddenMethods) { + val jvmOverriddenMethod = context.methodSignatureMapper.mapAsmMethod(overridden) + if (jvmOverriddenMethod != jvmInstanceMethod && jvmOverriddenMethod != jvmSamMethod) { + signatureToNonFakeOverride[jvmOverriddenMethod] = overridden + } + } + return signatureToNonFakeOverride.values } private fun wrapClosureInDynamicCall( diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt index 82829791295..ad70cbe9834 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt @@ -96,6 +96,7 @@ fun IrType.isArray(): Boolean = isNotNullClassType(IdSignatureValues.array) fun IrType.isNullableArray(): Boolean = isNullableClassType(IdSignatureValues.array) fun IrType.isCollection(): Boolean = isNotNullClassType(IdSignatureValues.collection) fun IrType.isNothing(): Boolean = isNotNullClassType(IdSignatureValues.nothing) +fun IrType.isNullableNothing(): Boolean = isNullableClassType(IdSignatureValues.nothing) fun IrType.isPrimitiveType(hasQuestionMark: Boolean = false): Boolean = (this is IrSimpleType && hasQuestionMark == this.hasQuestionMark) && diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt index 671a132170b..5f08ccf3df4 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt @@ -600,6 +600,15 @@ open class DeepCopyIrTreeWithSymbols( }.copyAttributes(expression) } + override fun visitRawFunctionReference(expression: IrRawFunctionReference): IrRawFunctionReference { + val symbol = symbolRemapper.getReferencedFunction(expression.symbol) + return IrRawFunctionReferenceImpl( + expression.startOffset, expression.endOffset, + expression.type.remapType(), + symbol + ).copyAttributes(expression) + } + override fun visitPropertyReference(expression: IrPropertyReference): IrPropertyReference = IrPropertyReferenceImpl( expression.startOffset, expression.endOffset, diff --git a/compiler/testData/codegen/box/annotations/annotatedLambda/samLambda.kt b/compiler/testData/codegen/box/annotations/annotatedLambda/samLambda.kt index 7d5fecf3740..77828ed619b 100644 --- a/compiler/testData/codegen/box/annotations/annotatedLambda/samLambda.kt +++ b/compiler/testData/codegen/box/annotations/annotatedLambda/samLambda.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM - +// SAM_CONVERSIONS: CLASS +// ^ test checks reflection for synthetic classes // WITH_RUNTIME // FILE: Test.java @@ -9,9 +10,10 @@ class Test { } } -// FILE: test.kt +// FILE: samLambda.kt import java.lang.reflect.Method + import kotlin.test.assertEquals @Target(AnnotationTarget.FUNCTION) diff --git a/compiler/testData/codegen/box/invokedynamic/lambdas/lambdaSerializable.kt b/compiler/testData/codegen/box/invokedynamic/lambdas/lambdaSerializable.kt index 9cf4a35003e..dad517e3d5c 100644 --- a/compiler/testData/codegen/box/invokedynamic/lambdas/lambdaSerializable.kt +++ b/compiler/testData/codegen/box/invokedynamic/lambdas/lambdaSerializable.kt @@ -8,6 +8,6 @@ fun lambdaIsSerializable(fn: () -> Unit) = fn is java.io.Serializable fun box(): String { if (lambdaIsSerializable {}) - return "Failed: indy lambdas are not serializable" + return "Failed: indy lambdas should not be serializable" return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/simpleFunInterfaceConstructor.kt b/compiler/testData/codegen/box/invokedynamic/sam/simpleFunInterfaceConstructor.kt new file mode 100644 index 00000000000..3cfb14ea8a4 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/simpleFunInterfaceConstructor.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface KRunnable { + fun run() +} + +var test = "Failed" + +fun box(): String { + KRunnable { test = "OK" }.run() + return test +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverride.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverride.kt new file mode 100644 index 00000000000..8589d7572d6 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverride.kt @@ -0,0 +1,13 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface IFooAny { + fun foo(x: Any): Any +} + +fun interface IFooStr : IFooAny { + override fun foo(x: Any): String +} + +fun box() = IFooStr { x: Any -> x.toString() }.foo("OK") \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt new file mode 100644 index 00000000000..c0d925020a0 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt @@ -0,0 +1,20 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface IFooNStr { + fun foo(x: Any): String? +} + +fun interface IFooNN : IFooNStr { + override fun foo(x: Any): Nothing? +} + +fun box(): String { + var r = "Failed" + IFooNN { + r = it.toString() + null + }.foo("OK") + return r +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt new file mode 100644 index 00000000000..aa997eb4743 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt @@ -0,0 +1,15 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// IGNORE_DEXING + +fun interface GenericToAny { + fun invoke(x: T): Any +} + +fun interface GenericCharToAny : GenericToAny + +fun withK(fn: GenericCharToAny) = fn.invoke('K').toString() + +fun box(): String = + withK { "O" + it } \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharDiamond.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharDiamond.kt new file mode 100644 index 00000000000..7422e8b3bb5 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharDiamond.kt @@ -0,0 +1,18 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface GenericToAny { + fun invoke(x: T): Any +} + +fun interface CharToAny { + fun invoke(x: Char): Any +} + +fun interface GenericCharToAny : GenericToAny, CharToAny + +fun withK(fn: GenericCharToAny) = fn.invoke('K').toString() + +fun box(): String = + withK { "O" + it } \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharExplicitlyOverridden.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharExplicitlyOverridden.kt new file mode 100644 index 00000000000..1e40c61d9c8 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharExplicitlyOverridden.kt @@ -0,0 +1,16 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface GenericToAny { + fun invoke(x: T): Any +} + +fun interface GenericCharToAny : GenericToAny { + override fun invoke(x: Char): Any +} + +fun withK(fn: GenericCharToAny) = fn.invoke('K').toString() + +fun box(): String = + withK { "O" + it } \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithInt.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithInt.kt new file mode 100644 index 00000000000..6ecf41feff3 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithInt.kt @@ -0,0 +1,17 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface GenericToAny { + fun invoke(x: T): Any +} + +fun interface GenericIntToAny : GenericToAny + +fun with4(fn: GenericIntToAny) = fn.invoke(4).toString() + +fun box(): String = + with4 { + if (it != 4) throw Exception() + "OK" + } \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithString.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithString.kt new file mode 100644 index 00000000000..c122aeadce9 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithString.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface GenericToAny { + fun invoke(x: T): Any +} + +fun interface GenericStringToAny : GenericToAny + +fun withK(fn: GenericStringToAny) = fn.invoke("K").toString() + +fun box(): String = + withK { "O" + it } \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithUnit.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithUnit.kt new file mode 100644 index 00000000000..22d0c781187 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithUnit.kt @@ -0,0 +1,22 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface IFoo { + fun foo(): T +} + +fun interface IFooUnit : IFoo { + override fun foo() +} + +fun fooT(iFoo: IFoo) = iFoo.foo() +fun fooUnit(iFooUnit: IFooUnit) { iFooUnit.foo() } + +var ok = "Failed" + +fun box(): String { + fooT { ok = "O" } + fooUnit { ok += "K" } + return ok +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndIntArray.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndIntArray.kt new file mode 100644 index 00000000000..99ff969a98d --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndIntArray.kt @@ -0,0 +1,40 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// WITH_RUNTIME + +fun interface IFooT { + fun foo(x: T): T +} + +fun interface IFooIntArray { + fun foo(x: IntArray): IntArray +} + +fun interface IFooMix0 : IFooT, IFooIntArray + +fun interface IFooMix1 : IFooT, IFooIntArray { + override fun foo(x: IntArray): IntArray +} + +fun box(): String { + var t0 = "Failed 0" + val f0 = IFooMix0 { + t0 = "O" + it[0].toChar() + it + } + f0.foo(intArrayOf('K'.toInt())) + if (t0 != "OK") + return "Failed: t0=$t0" + + var t1 = "Failed 1" + val f1 = IFooMix1 { + t1 = it[0].toChar() + "K" + it + } + f1.foo(intArrayOf('O'.toInt())) + if (t1 != "OK") + return "Failed: t1=$t1" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndString.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndString.kt new file mode 100644 index 00000000000..21ca535bfc8 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndString.kt @@ -0,0 +1,29 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface IFooT { + fun foo(x: T): T +} + +fun interface IFooStr { + fun foo(x: String): String +} + +fun interface IFooMix0 : IFooT, IFooStr + +fun interface IFooMix1 : IFooT, IFooStr { + override fun foo(x: String): String +} + +fun box(): String { + val f0 = IFooMix0 { "O" + it } + if (f0.foo("K") != "OK") + return "Failed: f0.foo(\"K\")=${f0.foo("K")}" + + val f1 = IFooMix1 { it + "K" } + if (f1.foo("O") != "OK") + return "Failed: f1.foo(\"O\")=${f1.foo("O")}" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericArrayAndArrayOfString.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericArrayAndArrayOfString.kt new file mode 100644 index 00000000000..1d05b5df422 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericArrayAndArrayOfString.kt @@ -0,0 +1,32 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// WITH_RUNTIME + +fun interface IFooT { + fun foo(x: Array): T +} + +fun interface IFooStr { + fun foo(x: Array): String +} + +fun interface IFooMix0 : IFooT, IFooStr + +fun interface IFooMix1 : IFooT, IFooStr { + override fun foo(x: Array): String +} + +fun box(): String { + val f0 = IFooMix0 { "O" + it[0] } + val t0 = f0.foo(arrayOf("K")) + if (t0 != "OK") + return "Failed: t0=$t0" + + val f1 = IFooMix1 { it[0] + "K" } + val t1 = f1.foo(arrayOf("O")) + if (t1 != "OK") + return "Failed: t1=$t1" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixPrimitiveAndBoxed.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixPrimitiveAndBoxed.kt new file mode 100644 index 00000000000..b1db5015f9a --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixPrimitiveAndBoxed.kt @@ -0,0 +1,32 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND: JVM +// IGNORE_LIGHT_ANALYSIS +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface IFooT { + fun foo(x: T): T +} + +fun interface IFooInt { + fun foo(x: Int): Int +} + +fun interface IFooMixed0 : IFooInt, IFooT + +fun interface IFooMixed1 : IFooInt, IFooT { + override fun foo(x: Int): Int +} + +fun box(): String { + val f0 = IFooMixed0 { it * 2 } + if (f0.foo(21) != 42) + return "Failed: f0.foo(21)=${f0.foo(21)}" + + val f1 = IFooMixed1 { it * 2 } + if (f1.foo(21) != 42) + return "Failed: f1.foo(21)=${f1.foo(21)}" + + return "OK" +} + diff --git a/compiler/testData/codegen/box/invokedynamic/sam/voidReturnTypeAsGeneric.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/voidReturnTypeAsGeneric.kt similarity index 89% rename from compiler/testData/codegen/box/invokedynamic/sam/voidReturnTypeAsGeneric.kt rename to compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/voidReturnTypeAsGeneric.kt index 6392915e1cc..73b1e97efd6 100644 --- a/compiler/testData/codegen/box/invokedynamic/sam/voidReturnTypeAsGeneric.kt +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/voidReturnTypeAsGeneric.kt @@ -1,6 +1,6 @@ // TARGET_BACKEND: JVM // JVM_TARGET: 1.8 -// LAMBDAS: INDY +// SAM_CONVERSIONS: INDY fun interface IFoo { fun foo(): T diff --git a/compiler/testData/codegen/box/reflection/enclosing/kt6691_lambdaInSamConstructor.kt b/compiler/testData/codegen/box/reflection/enclosing/kt6691_lambdaInSamConstructor.kt index 622554630a0..617c2c56555 100644 --- a/compiler/testData/codegen/box/reflection/enclosing/kt6691_lambdaInSamConstructor.kt +++ b/compiler/testData/codegen/box/reflection/enclosing/kt6691_lambdaInSamConstructor.kt @@ -1,4 +1,6 @@ // TARGET_BACKEND: JVM +// SAM_CONVERSIONS: CLASS +// ^ SAM-convertion classes created with LambdaMetafactory have 'enclosingMethod' and 'enclosingClass' // WITH_REFLECT package test @@ -17,7 +19,7 @@ fun box(): String { val javaClass = lambda.javaClass val enclosingMethod = javaClass.getEnclosingMethod() - if (enclosingMethod?.getName() != "run") return "method: $enclosingMethod" + if (enclosingMethod?.getName() != "run") return "enclosing method: $enclosingMethod" val enclosingClass = javaClass.getEnclosingClass()!!.getName() if (enclosingClass != "test.A\$prop\$1") return "enclosing class: $enclosingClass" diff --git a/compiler/testData/codegen/box/sam/adapters/genericSignature.kt b/compiler/testData/codegen/box/sam/adapters/genericSignature.kt index 3f0d4f9b8c3..5f5dacff672 100644 --- a/compiler/testData/codegen/box/sam/adapters/genericSignature.kt +++ b/compiler/testData/codegen/box/sam/adapters/genericSignature.kt @@ -1,4 +1,6 @@ // TARGET_BACKEND: JVM +// SAM_CONVERSIONS: CLASS +// ^ test checks reflection for synthetic classes // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/box/sam/kt11519.kt b/compiler/testData/codegen/box/sam/kt11519.kt index 767a30b21aa..4cf0692636d 100644 --- a/compiler/testData/codegen/box/sam/kt11519.kt +++ b/compiler/testData/codegen/box/sam/kt11519.kt @@ -1,5 +1,7 @@ // TARGET_BACKEND: JVM // SKIP_JDK6 +// SAM_CONVERSIONS: CLASS +// ^ test checks reflection for synthetic classes // MODULE: lib // FILE: Custom.java diff --git a/compiler/testData/codegen/box/sam/kt11519Constructor.kt b/compiler/testData/codegen/box/sam/kt11519Constructor.kt index 05d1a47a2a7..c57a48d4b62 100644 --- a/compiler/testData/codegen/box/sam/kt11519Constructor.kt +++ b/compiler/testData/codegen/box/sam/kt11519Constructor.kt @@ -1,5 +1,7 @@ // TARGET_BACKEND: JVM // SKIP_JDK6 +// SAM_CONVERSIONS: CLASS +// ^ test checks reflection for synthetic classes // MODULE: lib // FILE: Custom.java diff --git a/compiler/testData/codegen/box/sam/kt11696.kt b/compiler/testData/codegen/box/sam/kt11696.kt index e4582355d9c..e2ca195926f 100644 --- a/compiler/testData/codegen/box/sam/kt11696.kt +++ b/compiler/testData/codegen/box/sam/kt11696.kt @@ -1,6 +1,8 @@ // TARGET_BACKEND: JVM // IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME +// SAM_CONVERSIONS: CLASS +// ^ test checks reflection for synthetic classes // MODULE: lib // FILE: Promise.java import org.jetbrains.annotations.NotNull; diff --git a/compiler/testData/codegen/box/sam/recordSubstitutedTypeForCallableSamParameter.kt b/compiler/testData/codegen/box/sam/recordSubstitutedTypeForCallableSamParameter.kt index 56ae5eedccf..595ad2c364e 100644 --- a/compiler/testData/codegen/box/sam/recordSubstitutedTypeForCallableSamParameter.kt +++ b/compiler/testData/codegen/box/sam/recordSubstitutedTypeForCallableSamParameter.kt @@ -2,6 +2,8 @@ // WITH_REFLECT // FULL_JDK // TARGET_BACKEND: JVM +// SAM_CONVERSIONS: CLASS +// ^ SAM-convertion classes created with LambdaMetafactory have no generic signatures // FILE: Provider.java diff --git a/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt b/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt index 331393f18c7..177123f353c 100644 --- a/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt +++ b/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt @@ -2,6 +2,8 @@ // TARGET_BACKEND: JVM // SKIP_JDK6 // WITH_RUNTIME +// SAM_CONVERSIONS: CLASS +// ^ test checks reflection for synthetic classes // MODULE: lib // FILE: JavaClass.java diff --git a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.kt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.kt index 97199cbce74..20802d611b7 100644 --- a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.kt +++ b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.kt @@ -1,3 +1,4 @@ +// SAM_CONVERSIONS: CLASS // FILE: samAdapterForJavaInterfaceWithNullability.kt fun testNullable(s: String) = JNullable { s } fun testNotNull(s: String) = JNotNull { s } diff --git a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.txt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.txt index 6e13d1f0c1f..6fedbee2322 100644 --- a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.txt +++ b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.txt @@ -1,40 +1,10 @@ -@kotlin.Metadata -final class SamAdapterForJavaInterfaceWithNullabilityKt$testNoAnnotation$1 { - // source: 'samAdapterForJavaInterfaceWithNullability.kt' - enclosing method SamAdapterForJavaInterfaceWithNullabilityKt.testNoAnnotation(Ljava/lang/String;)LJNoAnnotation; - synthetic final field $s: java.lang.String - inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNoAnnotation$1 - method (p0: java.lang.String): void - public final method getString(): java.lang.String -} - -@kotlin.Metadata -final class SamAdapterForJavaInterfaceWithNullabilityKt$testNotNull$1 { - // source: 'samAdapterForJavaInterfaceWithNullability.kt' - enclosing method SamAdapterForJavaInterfaceWithNullabilityKt.testNotNull(Ljava/lang/String;)LJNotNull; - synthetic final field $s: java.lang.String - inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNotNull$1 - method (p0: java.lang.String): void - public final @org.jetbrains.annotations.NotNull method getNullableString(): java.lang.String -} - -@kotlin.Metadata -final class SamAdapterForJavaInterfaceWithNullabilityKt$testNullable$1 { - // source: 'samAdapterForJavaInterfaceWithNullability.kt' - enclosing method SamAdapterForJavaInterfaceWithNullabilityKt.testNullable(Ljava/lang/String;)LJNullable; - synthetic final field $s: java.lang.String - inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNullable$1 - method (p0: java.lang.String): void - public final @org.jetbrains.annotations.Nullable method getNullableString(): java.lang.String -} - @kotlin.Metadata public final class SamAdapterForJavaInterfaceWithNullabilityKt { // source: 'samAdapterForJavaInterfaceWithNullability.kt' - inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNoAnnotation$1 - inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNotNull$1 - inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNullable$1 + private final static method testNoAnnotation$lambda-2(p0: java.lang.String): java.lang.String public final static @org.jetbrains.annotations.NotNull method testNoAnnotation(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNoAnnotation + private final static method testNotNull$lambda-1(p0: java.lang.String): java.lang.String public final static @org.jetbrains.annotations.NotNull method testNotNull(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNotNull + private final static method testNullable$lambda-0(p0: java.lang.String): java.lang.String public final static @org.jetbrains.annotations.NotNull method testNullable(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNullable } diff --git a/compiler/testData/codegen/bytecodeListing/sam/kt16650.kt b/compiler/testData/codegen/bytecodeListing/sam/kt16650.kt index 3ae957c0fa2..8a0e7b6a313 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/kt16650.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/kt16650.kt @@ -1,3 +1,4 @@ +// SAM_CONVERSIONS: CLASS // WITH_SIGNATURES // FILE: t.kt fun main(x: DataStream) { diff --git a/compiler/testData/codegen/bytecodeListing/sam/kt16650_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/kt16650_ir.txt index 50b30869177..1b1bb19c3cc 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/kt16650_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/kt16650_ir.txt @@ -1,31 +1,7 @@ -@kotlin.Metadata -final class<Ljava/lang/Object;LKeySelector;> TKt$main$1 { - // source: 't.kt' - static method (): void - method (): void - public final method getKey(p0: java.lang.Integer): java.lang.Long - public synthetic bridge method getKey(p0: java.lang.Object): java.lang.Object - enclosing method TKt.main(LDataStream;)V - public final static field ;> INSTANCE: TKt$main$1 - inner (anonymous) class TKt$main$1 -} - -@kotlin.Metadata -final class<Ljava/lang/Object;LKeySelector;> TKt$main$2 { - // source: 't.kt' - static method (): void - method (): void - public final method getKey(p0: java.lang.Integer): java.lang.Long - public synthetic bridge method getKey(p0: java.lang.Object): java.lang.Object - enclosing method TKt.main(LDataStream;)V - public final static field ;> INSTANCE: TKt$main$2 - inner (anonymous) class TKt$main$2 -} - @kotlin.Metadata public final class TKt { // source: 't.kt' public final static <(LDataStream;)V> method main(@org.jetbrains.annotations.NotNull p0: DataStream): void - inner (anonymous) class TKt$main$1 - inner (anonymous) class TKt$main$2 + private final static method main$lambda-0(p0: java.lang.Integer): java.lang.Long + private final static method main$lambda-1(p0: java.lang.Integer): java.lang.Long } diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface_ir.txt index 58ebc83375c..06aebcc78e9 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface_ir.txt @@ -4,20 +4,10 @@ public interface<Ljava/lang/Object;> Sam { public abstract <()TT;> method get(): java.lang.Object } -@kotlin.Metadata -final class<Ljava/lang/Object;LSam;> TKt$genericSamGet$1 { - // source: 't.kt' - public final <()TT;> method get(): java.lang.Object - <(Lkotlin/jvm/functions/Function0<+TT;>;)V> method (p0: kotlin.jvm.functions.Function0): void - enclosing method TKt.genericSamGet(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; - synthetic final field ;> $f: kotlin.jvm.functions.Function0 - inner (anonymous) class TKt$genericSamGet$1 -} - @kotlin.Metadata public final class TKt { // source: 't.kt' public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + private final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet$lambda-0(p0: kotlin.jvm.functions.Function0): java.lang.Object public final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object - inner (anonymous) class TKt$genericSamGet$1 } diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface_ir.txt index 023cc600dfa..7c5f65a0533 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface_ir.txt @@ -1,28 +1,8 @@ -@kotlin.Metadata -final class<Ljava/lang/Object;LSam;> TKt$genericSam$1 { - // source: 't.kt' - public final <()TT;> method get(): java.lang.Object - <(Lkotlin/jvm/functions/Function0<+TT;>;)V> method (p0: kotlin.jvm.functions.Function0): void - enclosing method TKt.genericSam(Lkotlin/jvm/functions/Function0;)LSam; - synthetic final field ;> $f: kotlin.jvm.functions.Function0 - inner (anonymous) class TKt$genericSam$1 -} - -@kotlin.Metadata -final class<Ljava/lang/Object;LSam;> TKt$genericSamGet$1 { - // source: 't.kt' - public final <()TT;> method get(): java.lang.Object - <(Lkotlin/jvm/functions/Function0<+TT;>;)V> method (p0: kotlin.jvm.functions.Function0): void - enclosing method TKt.genericSamGet(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; - synthetic final field ;> $f: kotlin.jvm.functions.Function0 - inner (anonymous) class TKt$genericSamGet$1 -} - @kotlin.Metadata public final class TKt { // source: 't.kt' public final static @org.jetbrains.annotations.NotNull <(Lkotlin/jvm/functions/Function0<+TT;>;)LSam;> method genericSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): Sam + private final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSam$lambda-0(p0: kotlin.jvm.functions.Function0): java.lang.Object + private final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet$lambda-1(p0: kotlin.jvm.functions.Function0): java.lang.Object public final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object - inner (anonymous) class TKt$genericSam$1 - inner (anonymous) class TKt$genericSamGet$1 } diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt index 7e4453b74d6..7cb672329d5 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt @@ -1,3 +1,4 @@ + // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface_ir.txt index 8020d43de86..9d30b5549c0 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface_ir.txt @@ -4,21 +4,10 @@ public interface<Ljava/lang/Object;> Sam { public abstract <()TT;> method get(): java.lang.Object } -@kotlin.Metadata -final class<Ljava/lang/Object;LSam;> TKt$specializedSam$1 { - // source: 't.kt' - <(Lkotlin/jvm/functions/Function0;)V> method (p0: kotlin.jvm.functions.Function0): void - public synthetic bridge method get(): java.lang.Object - public final @org.jetbrains.annotations.NotNull method get(): java.lang.String - enclosing method TKt.specializedSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/String; - synthetic final field ;> $f: kotlin.jvm.functions.Function0 - inner (anonymous) class TKt$specializedSam$1 -} - @kotlin.Metadata public final class TKt { // source: 't.kt' + private final static <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam$lambda-0(p0: kotlin.jvm.functions.Function0): java.lang.String public final static @org.jetbrains.annotations.NotNull <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.String public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object - inner (anonymous) class TKt$specializedSam$1 } diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface_ir.txt index 9333ea1d30f..6274ccb7d0b 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface_ir.txt @@ -1,17 +1,6 @@ -@kotlin.Metadata -final class<Ljava/lang/Object;LSam;> TKt$specializedSam$1 { - // source: 't.kt' - <(Lkotlin/jvm/functions/Function0;)V> method (p0: kotlin.jvm.functions.Function0): void - public synthetic bridge method get(): java.lang.Object - public final method get(): java.lang.String - enclosing method TKt.specializedSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/String; - synthetic final field ;> $f: kotlin.jvm.functions.Function0 - inner (anonymous) class TKt$specializedSam$1 -} - @kotlin.Metadata public final class TKt { // source: 't.kt' + private final static <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam$lambda-0(p0: kotlin.jvm.functions.Function0): java.lang.String public final static <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.String - inner (anonymous) class TKt$specializedSam$1 } diff --git a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt index c369f8b779d..ed3a450e24b 100644 --- a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt +++ b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt @@ -16,9 +16,9 @@ fun test() { } // @TestKt.class: -// 1 NEW TestKt\$ +// 0 NEW TestKt\$ // 1 NEW kotlin/jvm/internal/Ref\$IntRef -// 2 NEW +// 1 NEW // 0 IFNONNULL // 0 IFNULL // 1 ACONST_NULL diff --git a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt index 757821e3886..719ef304308 100644 --- a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt +++ b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt @@ -16,16 +16,16 @@ fun test() { JFoo.foo2({}, runnable()) } -// 2 NEW - // JVM_TEMPLATES // @TestKt.class: +// 2 NEW // 0 IFNONNULL // 1 IFNULL // 1 ACONST_NULL // JVM_IR_TEMPLATES // @TestKt.class +// 1 NEW // 1 IFNONNULL // 0 IFNULL // 2 ACONST_NULL diff --git a/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt b/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt index f091753e2a0..75e0b5741f7 100644 --- a/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt +++ b/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt @@ -12,5 +12,5 @@ fun test() { } // Lambda inlined into run(), no wrapper class generated: -// 1 NEW +// 0 NEW // 0 INVOKEINTERFACE diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index ae9e296f7eb..fe03be4e4ec 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -19957,6 +19957,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionOnFunctionReference.kt"); } + @Test + @TestMetadata("simpleFunInterfaceConstructor.kt") + public void testSimpleFunInterfaceConstructor() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/simpleFunInterfaceConstructor.kt"); + } + @Test @TestMetadata("simpleIndyFunInterface.kt") public void testSimpleIndyFunInterface() throws Exception { @@ -19993,12 +19999,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/unboundFunctionReferenceEquality.kt"); } - @Test - @TestMetadata("voidReturnTypeAsGeneric.kt") - public void testVoidReturnTypeAsGeneric() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/voidReturnTypeAsGeneric.kt"); - } - @Nested @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @@ -20080,6 +20080,94 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/genericFunInterfaceWithInlineString.kt"); } } + + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics") + @TestDataPath("$PROJECT_ROOT") + public class SpecializedGenerics { + @Test + public void testAllFilesPresentInSpecializedGenerics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("covariantOverride.kt") + public void testCovariantOverride() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverride.kt"); + } + + @Test + @TestMetadata("covariantOverrideWithNNothing.kt") + public void testCovariantOverrideWithNNothing() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt"); + } + + @Test + @TestMetadata("inheritedWithChar.kt") + public void testInheritedWithChar() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt"); + } + + @Test + @TestMetadata("inheritedWithCharDiamond.kt") + public void testInheritedWithCharDiamond() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharDiamond.kt"); + } + + @Test + @TestMetadata("inheritedWithCharExplicitlyOverridden.kt") + public void testInheritedWithCharExplicitlyOverridden() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharExplicitlyOverridden.kt"); + } + + @Test + @TestMetadata("inheritedWithInt.kt") + public void testInheritedWithInt() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithInt.kt"); + } + + @Test + @TestMetadata("inheritedWithString.kt") + public void testInheritedWithString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithString.kt"); + } + + @Test + @TestMetadata("inheritedWithUnit.kt") + public void testInheritedWithUnit() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithUnit.kt"); + } + + @Test + @TestMetadata("mixGenericAndIntArray.kt") + public void testMixGenericAndIntArray() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndIntArray.kt"); + } + + @Test + @TestMetadata("mixGenericAndString.kt") + public void testMixGenericAndString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndString.kt"); + } + + @Test + @TestMetadata("mixGenericArrayAndArrayOfString.kt") + public void testMixGenericArrayAndArrayOfString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericArrayAndArrayOfString.kt"); + } + + @Test + @TestMetadata("mixPrimitiveAndBoxed.kt") + public void testMixPrimitiveAndBoxed() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixPrimitiveAndBoxed.kt"); + } + + @Test + @TestMetadata("voidReturnTypeAsGeneric.kt") + public void testVoidReturnTypeAsGeneric() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/voidReturnTypeAsGeneric.kt"); + } + } } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index cf4d445ac06..dc868d9b42d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -19957,6 +19957,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionOnFunctionReference.kt"); } + @Test + @TestMetadata("simpleFunInterfaceConstructor.kt") + public void testSimpleFunInterfaceConstructor() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/simpleFunInterfaceConstructor.kt"); + } + @Test @TestMetadata("simpleIndyFunInterface.kt") public void testSimpleIndyFunInterface() throws Exception { @@ -19993,12 +19999,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/unboundFunctionReferenceEquality.kt"); } - @Test - @TestMetadata("voidReturnTypeAsGeneric.kt") - public void testVoidReturnTypeAsGeneric() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/voidReturnTypeAsGeneric.kt"); - } - @Nested @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @@ -20080,6 +20080,94 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/genericFunInterfaceWithInlineString.kt"); } } + + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics") + @TestDataPath("$PROJECT_ROOT") + public class SpecializedGenerics { + @Test + public void testAllFilesPresentInSpecializedGenerics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("covariantOverride.kt") + public void testCovariantOverride() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverride.kt"); + } + + @Test + @TestMetadata("covariantOverrideWithNNothing.kt") + public void testCovariantOverrideWithNNothing() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt"); + } + + @Test + @TestMetadata("inheritedWithChar.kt") + public void testInheritedWithChar() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt"); + } + + @Test + @TestMetadata("inheritedWithCharDiamond.kt") + public void testInheritedWithCharDiamond() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharDiamond.kt"); + } + + @Test + @TestMetadata("inheritedWithCharExplicitlyOverridden.kt") + public void testInheritedWithCharExplicitlyOverridden() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharExplicitlyOverridden.kt"); + } + + @Test + @TestMetadata("inheritedWithInt.kt") + public void testInheritedWithInt() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithInt.kt"); + } + + @Test + @TestMetadata("inheritedWithString.kt") + public void testInheritedWithString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithString.kt"); + } + + @Test + @TestMetadata("inheritedWithUnit.kt") + public void testInheritedWithUnit() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithUnit.kt"); + } + + @Test + @TestMetadata("mixGenericAndIntArray.kt") + public void testMixGenericAndIntArray() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndIntArray.kt"); + } + + @Test + @TestMetadata("mixGenericAndString.kt") + public void testMixGenericAndString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndString.kt"); + } + + @Test + @TestMetadata("mixGenericArrayAndArrayOfString.kt") + public void testMixGenericArrayAndArrayOfString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericArrayAndArrayOfString.kt"); + } + + @Test + @TestMetadata("mixPrimitiveAndBoxed.kt") + public void testMixPrimitiveAndBoxed() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixPrimitiveAndBoxed.kt"); + } + + @Test + @TestMetadata("voidReturnTypeAsGeneric.kt") + public void testVoidReturnTypeAsGeneric() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/voidReturnTypeAsGeneric.kt"); + } + } } } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 56cb38f9750..f3e8c2b3486 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -16733,6 +16733,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionOnFunctionReference.kt"); } + @TestMetadata("simpleFunInterfaceConstructor.kt") + public void testSimpleFunInterfaceConstructor() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/simpleFunInterfaceConstructor.kt"); + } + @TestMetadata("simpleIndyFunInterface.kt") public void testSimpleIndyFunInterface() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/simpleIndyFunInterface.kt"); @@ -16758,11 +16763,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/unboundFunctionReferenceEquality.kt"); } - @TestMetadata("voidReturnTypeAsGeneric.kt") - public void testVoidReturnTypeAsGeneric() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/voidReturnTypeAsGeneric.kt"); - } - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -16835,6 +16835,84 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/genericFunInterfaceWithInlineString.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SpecializedGenerics extends AbstractLightAnalysisModeTest { + @TestMetadata("mixPrimitiveAndBoxed.kt") + public void ignoreMixPrimitiveAndBoxed() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixPrimitiveAndBoxed.kt"); + } + + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInSpecializedGenerics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("covariantOverride.kt") + public void testCovariantOverride() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverride.kt"); + } + + @TestMetadata("covariantOverrideWithNNothing.kt") + public void testCovariantOverrideWithNNothing() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt"); + } + + @TestMetadata("inheritedWithChar.kt") + public void testInheritedWithChar() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt"); + } + + @TestMetadata("inheritedWithCharDiamond.kt") + public void testInheritedWithCharDiamond() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharDiamond.kt"); + } + + @TestMetadata("inheritedWithCharExplicitlyOverridden.kt") + public void testInheritedWithCharExplicitlyOverridden() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithCharExplicitlyOverridden.kt"); + } + + @TestMetadata("inheritedWithInt.kt") + public void testInheritedWithInt() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithInt.kt"); + } + + @TestMetadata("inheritedWithString.kt") + public void testInheritedWithString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithString.kt"); + } + + @TestMetadata("inheritedWithUnit.kt") + public void testInheritedWithUnit() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithUnit.kt"); + } + + @TestMetadata("mixGenericAndIntArray.kt") + public void testMixGenericAndIntArray() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndIntArray.kt"); + } + + @TestMetadata("mixGenericAndString.kt") + public void testMixGenericAndString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericAndString.kt"); + } + + @TestMetadata("mixGenericArrayAndArrayOfString.kt") + public void testMixGenericArrayAndArrayOfString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericArrayAndArrayOfString.kt"); + } + + @TestMetadata("voidReturnTypeAsGeneric.kt") + public void testVoidReturnTypeAsGeneric() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/voidReturnTypeAsGeneric.kt"); + } + } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 52a8968ba1f..c21c768bbfd 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -14580,6 +14580,19 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } } + + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SpecializedGenerics extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInSpecializedGenerics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 0ef0133f9be..096a949eac2 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -14065,6 +14065,19 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } } + + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SpecializedGenerics extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInSpecializedGenerics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 7ffcaac194e..90693bc4ef8 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -14130,6 +14130,19 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } } + + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SpecializedGenerics extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInSpecializedGenerics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 38d21ec3cdd..b81237dbc68 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -8171,6 +8171,19 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } } + + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SpecializedGenerics extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInSpecializedGenerics() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } } } From 052f6929c9fca4ee44028d0d6f4b6f3b01b05b4f Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 5 Feb 2021 20:04:16 +0300 Subject: [PATCH 071/368] JVM_IR indy SAM conversions: update tests KT-44278 KT-26060 KT-42621 --- .../FirBlackBoxCodegenTestGenerated.java | 6 ++++ .../sam/covariantOverrideWithPrimitive.kt | 19 ++++++++++ ...AdapterForJavaInterfaceWithNullability.txt | 36 +++++++++++++++++-- ...pterForJavaInterfaceWithNullability_ir.txt | 10 ++++++ .../sam/samWrapperForNullInitialization.kt | 10 ++++++ .../bytecodeText/sam/samWrapperOfLambda.kt | 5 +++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++++ .../LightAnalysisModeTestGenerated.java | 5 +++ 9 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt create mode 100644 compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability_ir.txt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 09b3be63e37..f8ae7fa6650 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -19921,6 +19921,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/constructorReference.kt"); } + @Test + @TestMetadata("covariantOverrideWithPrimitive.kt") + public void testCovariantOverrideWithPrimitive() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt"); + } + @Test @TestMetadata("genericFunInterface.kt") public void testGenericFunInterface() throws Exception { diff --git a/compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt b/compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt new file mode 100644 index 00000000000..821d7df924f --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt @@ -0,0 +1,19 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface IFooAny { + fun foo(): Any +} + +fun interface IFooInt : IFooAny { + override fun foo(): Int +} + +fun box(): String { + val test = IFooInt { 42 } + if (test.foo() != 42) + return "Failed" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.txt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.txt index 6fedbee2322..6e13d1f0c1f 100644 --- a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.txt +++ b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.txt @@ -1,10 +1,40 @@ +@kotlin.Metadata +final class SamAdapterForJavaInterfaceWithNullabilityKt$testNoAnnotation$1 { + // source: 'samAdapterForJavaInterfaceWithNullability.kt' + enclosing method SamAdapterForJavaInterfaceWithNullabilityKt.testNoAnnotation(Ljava/lang/String;)LJNoAnnotation; + synthetic final field $s: java.lang.String + inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNoAnnotation$1 + method (p0: java.lang.String): void + public final method getString(): java.lang.String +} + +@kotlin.Metadata +final class SamAdapterForJavaInterfaceWithNullabilityKt$testNotNull$1 { + // source: 'samAdapterForJavaInterfaceWithNullability.kt' + enclosing method SamAdapterForJavaInterfaceWithNullabilityKt.testNotNull(Ljava/lang/String;)LJNotNull; + synthetic final field $s: java.lang.String + inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNotNull$1 + method (p0: java.lang.String): void + public final @org.jetbrains.annotations.NotNull method getNullableString(): java.lang.String +} + +@kotlin.Metadata +final class SamAdapterForJavaInterfaceWithNullabilityKt$testNullable$1 { + // source: 'samAdapterForJavaInterfaceWithNullability.kt' + enclosing method SamAdapterForJavaInterfaceWithNullabilityKt.testNullable(Ljava/lang/String;)LJNullable; + synthetic final field $s: java.lang.String + inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNullable$1 + method (p0: java.lang.String): void + public final @org.jetbrains.annotations.Nullable method getNullableString(): java.lang.String +} + @kotlin.Metadata public final class SamAdapterForJavaInterfaceWithNullabilityKt { // source: 'samAdapterForJavaInterfaceWithNullability.kt' - private final static method testNoAnnotation$lambda-2(p0: java.lang.String): java.lang.String + inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNoAnnotation$1 + inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNotNull$1 + inner (anonymous) class SamAdapterForJavaInterfaceWithNullabilityKt$testNullable$1 public final static @org.jetbrains.annotations.NotNull method testNoAnnotation(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNoAnnotation - private final static method testNotNull$lambda-1(p0: java.lang.String): java.lang.String public final static @org.jetbrains.annotations.NotNull method testNotNull(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNotNull - private final static method testNullable$lambda-0(p0: java.lang.String): java.lang.String public final static @org.jetbrains.annotations.NotNull method testNullable(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNullable } diff --git a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability_ir.txt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability_ir.txt new file mode 100644 index 00000000000..6fedbee2322 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability_ir.txt @@ -0,0 +1,10 @@ +@kotlin.Metadata +public final class SamAdapterForJavaInterfaceWithNullabilityKt { + // source: 'samAdapterForJavaInterfaceWithNullability.kt' + private final static method testNoAnnotation$lambda-2(p0: java.lang.String): java.lang.String + public final static @org.jetbrains.annotations.NotNull method testNoAnnotation(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNoAnnotation + private final static method testNotNull$lambda-1(p0: java.lang.String): java.lang.String + public final static @org.jetbrains.annotations.NotNull method testNotNull(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNotNull + private final static method testNullable$lambda-0(p0: java.lang.String): java.lang.String + public final static @org.jetbrains.annotations.NotNull method testNullable(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNullable +} diff --git a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt index ed3a450e24b..e15c32784e8 100644 --- a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt +++ b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt @@ -15,6 +15,16 @@ fun test() { JFoo.foo2({ i++ }, null) } +// JVM_TEMPLATES: +// @TestKt.class: +// 1 NEW TestKt\$ +// 1 NEW kotlin/jvm/internal/Ref\$IntRef +// 2 NEW +// 0 IFNONNULL +// 0 IFNULL +// 1 ACONST_NULL + +// JVM_IR_TEMPLATES: // @TestKt.class: // 0 NEW TestKt\$ // 1 NEW kotlin/jvm/internal/Ref\$IntRef diff --git a/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt b/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt index 75e0b5741f7..b82b5f40424 100644 --- a/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt +++ b/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt @@ -12,5 +12,10 @@ fun test() { } // Lambda inlined into run(), no wrapper class generated: +// JVM_TEMPLATES: +// 1 NEW +// 0 INVOKEINTERFACE + +// JVM_IR_TEMPLATES: // 0 NEW // 0 INVOKEINTERFACE diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index fe03be4e4ec..87ab19a4bd0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -19921,6 +19921,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/constructorReference.kt"); } + @Test + @TestMetadata("covariantOverrideWithPrimitive.kt") + public void testCovariantOverrideWithPrimitive() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt"); + } + @Test @TestMetadata("genericFunInterface.kt") public void testGenericFunInterface() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index dc868d9b42d..621b350cdf9 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -19921,6 +19921,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/constructorReference.kt"); } + @Test + @TestMetadata("covariantOverrideWithPrimitive.kt") + public void testCovariantOverrideWithPrimitive() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt"); + } + @Test @TestMetadata("genericFunInterface.kt") public void testGenericFunInterface() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index f3e8c2b3486..4e50a92496b 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -16703,6 +16703,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/constructorReference.kt"); } + @TestMetadata("covariantOverrideWithPrimitive.kt") + public void testCovariantOverrideWithPrimitive() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt"); + } + @TestMetadata("genericFunInterface.kt") public void testGenericFunInterface() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterface.kt"); From 7564c9bb8c31845446c02ef93ac018c89f698d58 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Mon, 8 Feb 2021 18:11:59 +0300 Subject: [PATCH 072/368] JVM SamWrapperClassesAreSynthetic language feature KT-44278 KT-26060 KT-42621 --- .../kotlin/codegen/SamWrapperCodegen.java | 4 +++- .../kotlin/codegen/state/GenerationState.kt | 6 +++--- .../backend/jvm/codegen/ClassCodegen.kt | 19 +++++++++++++++---- .../sam/callableRefGenericFunInterface.txt | 2 +- .../sam/callableRefGenericSamInterface.txt | 2 +- .../callableRefSpecializedFunInterface.txt | 2 +- .../callableRefSpecializedSamInterface.txt | 2 +- .../sam/genericFunInterface.txt | 2 +- .../sam/genericFunInterface_ir.txt | 2 +- .../sam/genericSamInterface.txt | 2 +- .../sam/reusedSamWrapperClasses.txt | 2 +- .../sam/samAdapterAndInlinedOne.txt | 4 ++-- .../sam/samAdapterAndInlinedOne_ir.txt | 4 ++-- .../sam/specializedFunInterface.txt | 2 +- .../sam/specializedFunInterface_ir.txt | 2 +- .../sam/specializedSamInterface.txt | 2 +- .../sam/wrapperInlinedFromAnotherClass.txt | 2 +- .../sam/wrapperInlinedFromAnotherClass_ir.txt | 2 +- .../kotlin/config/LanguageVersionSettings.kt | 1 + 19 files changed, 39 insertions(+), 25 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java index 9c204d64ffb..afea19b7fe3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.codegen.context.CodegenContext; import org.jetbrains.kotlin.codegen.context.FieldOwnerContext; import org.jetbrains.kotlin.codegen.state.GenerationState; import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper; +import org.jetbrains.kotlin.config.LanguageFeature; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl; import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil; @@ -79,7 +80,8 @@ public class SamWrapperCodegen { this.samType = samType; this.parentCodegen = parentCodegen; visibility = isInsideInline ? ACC_PUBLIC : NO_FLAG_PACKAGE_PRIVATE; - classFlags = visibility | ACC_FINAL | ACC_SUPER; + int synth = state.getLanguageVersionSettings().supportsFeature(LanguageFeature.SamWrapperClassesAreSynthetic) ? ACC_SYNTHETIC : 0; + classFlags = visibility | ACC_FINAL | ACC_SUPER | synth; } @NotNull diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt index f0869360e3a..04057ffd8f4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt @@ -211,10 +211,10 @@ class GenerationState private constructor( val fromConfig = configuration.get(JVMConfigurationKeys.SAM_CONVERSIONS) if (fromConfig != null && target >= fromConfig.minJvmTarget) fromConfig - else if (target < JvmTarget.JVM_1_8) - JvmClosureGenerationScheme.CLASS - else + else if (target >= JvmTarget.JVM_1_8 && languageVersionSettings.supportsFeature(LanguageFeature.SamWrapperClassesAreSynthetic)) JvmClosureGenerationScheme.INDY + else + JvmClosureGenerationScheme.CLASS } val lambdasScheme = run { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt index 01a5d8c4541..13bc92b485f 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt @@ -81,7 +81,7 @@ class ClassCodegen private constructor( defineClass( irClass.psiElement, state.classFileVersion, - irClass.flags, + irClass.getFlags(context.state.languageVersionSettings), signature.name, signature.javaGenericSignature, signature.superclassName, @@ -473,10 +473,11 @@ class ClassCodegen private constructor( } } -private val IrClass.flags: Int - get() = origin.flags or getVisibilityAccessFlagForClass() or +private fun IrClass.getFlags(languageVersionSettings: LanguageVersionSettings): Int = + origin.flags or + getVisibilityAccessFlagForClass() or (if (isAnnotatedWithDeprecated) Opcodes.ACC_DEPRECATED else 0) or - (if (hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME)) Opcodes.ACC_SYNTHETIC else 0) or + getSynthAccessFlag(languageVersionSettings) or when { isAnnotationClass -> Opcodes.ACC_ANNOTATION or Opcodes.ACC_INTERFACE or Opcodes.ACC_ABSTRACT isInterface -> Opcodes.ACC_INTERFACE or Opcodes.ACC_ABSTRACT @@ -485,6 +486,16 @@ private val IrClass.flags: Int else -> Opcodes.ACC_SUPER or modality.flags } +private fun IrClass.getSynthAccessFlag(languageVersionSettings: LanguageVersionSettings): Int { + if (hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME)) + return Opcodes.ACC_SYNTHETIC + if (origin == IrDeclarationOrigin.GENERATED_SAM_IMPLEMENTATION && + languageVersionSettings.supportsFeature(LanguageFeature.SamWrapperClassesAreSynthetic) + ) + return Opcodes.ACC_SYNTHETIC + return 0 +} + private fun IrField.computeFieldFlags(context: JvmBackendContext, languageVersionSettings: LanguageVersionSettings): Int = origin.flags or visibility.flags or (if (isDeprecatedCallable(context) || diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.txt index 43b745b330f..7eb0d2a7d5a 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.txt @@ -16,7 +16,7 @@ synthetic final class TKt$sam$Sam$0 { +synthetic final class TKt$sam$Sam$0 { // source: 't.kt' method (p0: kotlin.jvm.functions.Function0): void public method equals(p0: java.lang.Object): boolean diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.txt index 03ec0d56cf6..529b0266dc1 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.txt @@ -10,7 +10,7 @@ synthetic final class TKt$sam$Sam$0 { +synthetic final class TKt$sam$Sam$0 { // source: 't.kt' method (p0: kotlin.jvm.functions.Function0): void public synthetic final method get(): java.lang.Object diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.txt index ba3956bdcc3..b1dc7e49e7b 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.txt @@ -5,7 +5,7 @@ public interface<Ljava/lang/Object;> Sam { } @kotlin.Metadata -final class TKt$sam$Sam$0 { +synthetic final class TKt$sam$Sam$0 { // source: 't.kt' method (p0: kotlin.jvm.functions.Function0): void public method equals(p0: java.lang.Object): boolean diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.txt index 2102c82f6e1..fcb80dea923 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.txt @@ -1,5 +1,5 @@ @kotlin.Metadata -final class TKt$sam$Sam$0 { +synthetic final class TKt$sam$Sam$0 { // source: 't.kt' method (p0: kotlin.jvm.functions.Function0): void public synthetic final method get(): java.lang.Object diff --git a/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.txt index ddf6ef8d381..9f015803fa1 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.txt @@ -5,7 +5,7 @@ public interface<Ljava/lang/Object;> Sam { } @kotlin.Metadata -final class TKt$sam$Sam$0 { +synthetic final class TKt$sam$Sam$0 { // source: 't.kt' method (p0: kotlin.jvm.functions.Function0): void public method equals(p0: java.lang.Object): boolean diff --git a/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface_ir.txt index dd96882e1a7..e3ddc0db865 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface_ir.txt @@ -5,7 +5,7 @@ public interface<Ljava/lang/Object;> Sam { } @kotlin.Metadata -final class TKt$sam$Sam$0 { +synthetic final class TKt$sam$Sam$0 { // source: 't.kt' public final @org.jetbrains.annotations.NotNull <()Lkotlin/Function<*>;> method getFunctionDelegate(): kotlin.Function method (p0: kotlin.jvm.functions.Function0): void diff --git a/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.txt index efb77081001..730f7bff931 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.txt @@ -1,5 +1,5 @@ @kotlin.Metadata -final class TKt$sam$Sam$0 { +synthetic final class TKt$sam$Sam$0 { // source: 't.kt' method (p0: kotlin.jvm.functions.Function0): void public synthetic final method get(): java.lang.Object diff --git a/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.txt b/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.txt index 17ce13004a7..9a14226085a 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.txt @@ -1,5 +1,5 @@ @kotlin.Metadata -final class A$sam$java_lang_Runnable$0 { +synthetic final class A$sam$java_lang_Runnable$0 { // source: 'reusedSamWrapperClasses.kt' enclosing class A private synthetic final field function: kotlin.jvm.functions.Function0 diff --git a/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.txt b/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.txt index 70908a67f5f..0d97548945f 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.txt @@ -1,5 +1,5 @@ @kotlin.Metadata -public final class test/SamAdapterAndInlinedOneKt$sam$i$java_lang_Runnable$0 { +public synthetic final class test/SamAdapterAndInlinedOneKt$sam$i$java_lang_Runnable$0 { // source: 'samAdapterAndInlinedOne.kt' public method (p0: kotlin.jvm.functions.Function0): void public synthetic final method run(): void @@ -9,7 +9,7 @@ public final class test/SamAdapterAndInlinedOneKt$sam$i$java_lang_Runnabl } @kotlin.Metadata -final class test/SamAdapterAndInlinedOneKt$sam$java_lang_Runnable$0 { +synthetic final class test/SamAdapterAndInlinedOneKt$sam$java_lang_Runnable$0 { // source: 'samAdapterAndInlinedOne.kt' method (p0: kotlin.jvm.functions.Function0): void public synthetic final method run(): void diff --git a/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne_ir.txt index fd4941ff5d0..a0bfcdda134 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne_ir.txt @@ -1,5 +1,5 @@ @kotlin.Metadata -public final class test/SamAdapterAndInlinedOneKt$sam$i$java_lang_Runnable$0 { +public synthetic final class test/SamAdapterAndInlinedOneKt$sam$i$java_lang_Runnable$0 { // source: 'samAdapterAndInlinedOne.kt' public method (p0: kotlin.jvm.functions.Function0): void public synthetic final method run(): void @@ -9,7 +9,7 @@ public final class test/SamAdapterAndInlinedOneKt$sam$i$java_lang_Runnabl } @kotlin.Metadata -final class test/SamAdapterAndInlinedOneKt$sam$java_lang_Runnable$0 { +synthetic final class test/SamAdapterAndInlinedOneKt$sam$java_lang_Runnable$0 { // source: 'samAdapterAndInlinedOne.kt' method (p0: kotlin.jvm.functions.Function0): void public synthetic final method run(): void diff --git a/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.txt index 310988b9a98..951fd16be77 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.txt @@ -5,7 +5,7 @@ public interface<Ljava/lang/Object;> Sam { } @kotlin.Metadata -final class TKt$sam$Sam$0 { +synthetic final class TKt$sam$Sam$0 { // source: 't.kt' method (p0: kotlin.jvm.functions.Function0): void public method equals(p0: java.lang.Object): boolean diff --git a/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface_ir.txt index ba9f90c64b8..5ac07a34f51 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface_ir.txt @@ -5,7 +5,7 @@ public interface<Ljava/lang/Object;> Sam { } @kotlin.Metadata -final class TKt$sam$Sam$0 { +synthetic final class TKt$sam$Sam$0 { // source: 't.kt' public final @org.jetbrains.annotations.NotNull <()Lkotlin/Function<*>;> method getFunctionDelegate(): kotlin.Function method (p0: kotlin.jvm.functions.Function0): void diff --git a/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.txt b/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.txt index 3bb5239d280..1f0916f8e52 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.txt @@ -1,5 +1,5 @@ @kotlin.Metadata -final class TKt$sam$Sam$0 { +synthetic final class TKt$sam$Sam$0 { // source: 't.kt' method (p0: kotlin.jvm.functions.Function0): void public synthetic final method get(): java.lang.Object diff --git a/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass.txt b/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass.txt index 902a3dba8a5..5db6a593e54 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass.txt @@ -59,7 +59,7 @@ public final class B$runnable2$1 { } @kotlin.Metadata -public final class B$sam$i$java_lang_Runnable$0 { +public synthetic final class B$sam$i$java_lang_Runnable$0 { // source: 'wrapperInlinedFromAnotherClass.kt' enclosing class B private synthetic final field function: kotlin.jvm.functions.Function0 diff --git a/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass_ir.txt index a244633ffd7..a3cd023104b 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass_ir.txt @@ -59,7 +59,7 @@ public final class B$runnable2$1 { } @kotlin.Metadata -public final class B$sam$i$java_lang_Runnable$0 { +public synthetic final class B$sam$i$java_lang_Runnable$0 { // source: 'wrapperInlinedFromAnotherClass.kt' enclosing class B private synthetic final field function: kotlin.jvm.functions.Function0 diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 3d6720c65bd..1e4e72ddfac 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -199,6 +199,7 @@ enum class LanguageFeature( InlineClasses(sinceVersion = KOTLIN_1_3, defaultState = State.ENABLED_WITH_WARNING, kind = UNSTABLE_FEATURE), JvmInlineValueClasses(sinceVersion = KOTLIN_1_5, defaultState = State.ENABLED, kind = OTHER), SuspendFunctionsInFunInterfaces(sinceVersion = KOTLIN_1_5, defaultState = State.ENABLED, kind = OTHER), + SamWrapperClassesAreSynthetic(sinceVersion = KOTLIN_1_5, defaultState = State.ENABLED, kind = BUG_FIX) ; val presentableName: String From 3438d19c223c663aa001fc026e4a7e67840f2be3 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 9 Feb 2021 10:26:50 +0300 Subject: [PATCH 073/368] JVM_IR indy: use 'CLASS' mode in SAM bytecode listing tests KT-44278 KT-26060 KT-42621 --- .../config/JvmClosureGenerationScheme.kt | 6 ++-- .../sam/callableRefGenericFunInterface.kt | 1 + .../sam/callableRefGenericSamInterface.kt | 1 + .../sam/callableRefSpecializedFunInterface.kt | 1 + .../sam/callableRefSpecializedSamInterface.kt | 1 + .../sam/genericFunInterface.kt | 1 + .../sam/genericSamInterface.kt | 1 + .../codegen/bytecodeListing/sam/kt16650.kt | 2 +- .../bytecodeListing/sam/kt16650_ir.txt | 28 +++++++++++++++++-- .../sam/lambdaGenericFunInterface.kt | 1 + .../sam/lambdaGenericFunInterface_ir.txt | 12 +++++++- .../sam/lambdaGenericSamInterface.kt | 1 + .../sam/lambdaGenericSamInterface_ir.txt | 24 ++++++++++++++-- .../sam/lambdaSpecializedFunInterface.kt | 2 +- .../sam/lambdaSpecializedFunInterface_ir.txt | 13 ++++++++- .../sam/lambdaSpecializedSamInterface.kt | 1 + .../sam/lambdaSpecializedSamInterface_ir.txt | 13 ++++++++- .../sam/reusedSamWrapperClasses.kt | 1 + .../sam/samAdapterAndInlinedOne.kt | 1 + .../sam/specializedFunInterface.kt | 1 + .../sam/specializedSamInterface.kt | 1 + .../sam/wrapperInlinedFromAnotherClass.kt | 1 + 22 files changed, 103 insertions(+), 11 deletions(-) diff --git a/compiler/config.jvm/src/org/jetbrains/kotlin/config/JvmClosureGenerationScheme.kt b/compiler/config.jvm/src/org/jetbrains/kotlin/config/JvmClosureGenerationScheme.kt index 70d950979a5..a03ab246059 100644 --- a/compiler/config.jvm/src/org/jetbrains/kotlin/config/JvmClosureGenerationScheme.kt +++ b/compiler/config.jvm/src/org/jetbrains/kotlin/config/JvmClosureGenerationScheme.kt @@ -17,7 +17,9 @@ enum class JvmClosureGenerationScheme( val DEFAULT = CLASS @JvmStatic - fun fromString(string: String?) = - values().find { it.description == string } + fun fromString(string: String?): JvmClosureGenerationScheme? { + val lowerStr = string?.toLowerCase() ?: return null + return values().find { it.description == lowerStr } + } } } \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.kt index 5686fc2bcb1..a2d47698ac1 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericFunInterface.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.kt index 0e255f086a2..ba84bcee015 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefGenericSamInterface.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.kt index 163b33e639e..7f660ec5ac6 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedFunInterface.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.kt index d403207631f..40aa971bbd2 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/callableRefSpecializedSamInterface.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.kt index f41de2181c4..da1d072138c 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/genericFunInterface.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.kt index edbb878fe04..94cb400b9c0 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/genericSamInterface.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/kt16650.kt b/compiler/testData/codegen/bytecodeListing/sam/kt16650.kt index 8a0e7b6a313..1226b92332f 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/kt16650.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/kt16650.kt @@ -1,4 +1,4 @@ -// SAM_CONVERSIONS: CLASS +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt fun main(x: DataStream) { diff --git a/compiler/testData/codegen/bytecodeListing/sam/kt16650_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/kt16650_ir.txt index 1b1bb19c3cc..50b30869177 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/kt16650_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/kt16650_ir.txt @@ -1,7 +1,31 @@ +@kotlin.Metadata +final class<Ljava/lang/Object;LKeySelector;> TKt$main$1 { + // source: 't.kt' + static method (): void + method (): void + public final method getKey(p0: java.lang.Integer): java.lang.Long + public synthetic bridge method getKey(p0: java.lang.Object): java.lang.Object + enclosing method TKt.main(LDataStream;)V + public final static field ;> INSTANCE: TKt$main$1 + inner (anonymous) class TKt$main$1 +} + +@kotlin.Metadata +final class<Ljava/lang/Object;LKeySelector;> TKt$main$2 { + // source: 't.kt' + static method (): void + method (): void + public final method getKey(p0: java.lang.Integer): java.lang.Long + public synthetic bridge method getKey(p0: java.lang.Object): java.lang.Object + enclosing method TKt.main(LDataStream;)V + public final static field ;> INSTANCE: TKt$main$2 + inner (anonymous) class TKt$main$2 +} + @kotlin.Metadata public final class TKt { // source: 't.kt' public final static <(LDataStream;)V> method main(@org.jetbrains.annotations.NotNull p0: DataStream): void - private final static method main$lambda-0(p0: java.lang.Integer): java.lang.Long - private final static method main$lambda-1(p0: java.lang.Integer): java.lang.Long + inner (anonymous) class TKt$main$1 + inner (anonymous) class TKt$main$2 } diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.kt index e06a76011af..905fe074852 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface_ir.txt index 06aebcc78e9..58ebc83375c 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericFunInterface_ir.txt @@ -4,10 +4,20 @@ public interface<Ljava/lang/Object;> Sam { public abstract <()TT;> method get(): java.lang.Object } +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$genericSamGet$1 { + // source: 't.kt' + public final <()TT;> method get(): java.lang.Object + <(Lkotlin/jvm/functions/Function0<+TT;>;)V> method (p0: kotlin.jvm.functions.Function0): void + enclosing method TKt.genericSamGet(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + synthetic final field ;> $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$genericSamGet$1 +} + @kotlin.Metadata public final class TKt { // source: 't.kt' public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object - private final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet$lambda-0(p0: kotlin.jvm.functions.Function0): java.lang.Object public final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object + inner (anonymous) class TKt$genericSamGet$1 } diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.kt index 9720eeec38e..7b378b3679a 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface_ir.txt index 7c5f65a0533..023cc600dfa 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaGenericSamInterface_ir.txt @@ -1,8 +1,28 @@ +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$genericSam$1 { + // source: 't.kt' + public final <()TT;> method get(): java.lang.Object + <(Lkotlin/jvm/functions/Function0<+TT;>;)V> method (p0: kotlin.jvm.functions.Function0): void + enclosing method TKt.genericSam(Lkotlin/jvm/functions/Function0;)LSam; + synthetic final field ;> $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$genericSam$1 +} + +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$genericSamGet$1 { + // source: 't.kt' + public final <()TT;> method get(): java.lang.Object + <(Lkotlin/jvm/functions/Function0<+TT;>;)V> method (p0: kotlin.jvm.functions.Function0): void + enclosing method TKt.genericSamGet(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object; + synthetic final field ;> $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$genericSamGet$1 +} + @kotlin.Metadata public final class TKt { // source: 't.kt' public final static @org.jetbrains.annotations.NotNull <(Lkotlin/jvm/functions/Function0<+TT;>;)LSam;> method genericSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): Sam - private final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSam$lambda-0(p0: kotlin.jvm.functions.Function0): java.lang.Object - private final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet$lambda-1(p0: kotlin.jvm.functions.Function0): java.lang.Object public final static <(Lkotlin/jvm/functions/Function0<+TT;>;)TT;> method genericSamGet(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.Object + inner (anonymous) class TKt$genericSam$1 + inner (anonymous) class TKt$genericSamGet$1 } diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt index 7cb672329d5..1ef76184990 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface.kt @@ -1,4 +1,4 @@ - +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface_ir.txt index 9d30b5549c0..8020d43de86 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedFunInterface_ir.txt @@ -4,10 +4,21 @@ public interface<Ljava/lang/Object;> Sam { public abstract <()TT;> method get(): java.lang.Object } +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$specializedSam$1 { + // source: 't.kt' + <(Lkotlin/jvm/functions/Function0;)V> method (p0: kotlin.jvm.functions.Function0): void + public synthetic bridge method get(): java.lang.Object + public final @org.jetbrains.annotations.NotNull method get(): java.lang.String + enclosing method TKt.specializedSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/String; + synthetic final field ;> $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$specializedSam$1 +} + @kotlin.Metadata public final class TKt { // source: 't.kt' - private final static <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam$lambda-0(p0: kotlin.jvm.functions.Function0): java.lang.String public final static @org.jetbrains.annotations.NotNull <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.String public final static <(LSam;)TT;> method expectsSam(@org.jetbrains.annotations.NotNull p0: Sam): java.lang.Object + inner (anonymous) class TKt$specializedSam$1 } diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.kt index 185c15d0e83..16a96f79fb6 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface_ir.txt b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface_ir.txt index 6274ccb7d0b..9333ea1d30f 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/sam/lambdaSpecializedSamInterface_ir.txt @@ -1,6 +1,17 @@ +@kotlin.Metadata +final class<Ljava/lang/Object;LSam;> TKt$specializedSam$1 { + // source: 't.kt' + <(Lkotlin/jvm/functions/Function0;)V> method (p0: kotlin.jvm.functions.Function0): void + public synthetic bridge method get(): java.lang.Object + public final method get(): java.lang.String + enclosing method TKt.specializedSam(Lkotlin/jvm/functions/Function0;)Ljava/lang/String; + synthetic final field ;> $f: kotlin.jvm.functions.Function0 + inner (anonymous) class TKt$specializedSam$1 +} + @kotlin.Metadata public final class TKt { // source: 't.kt' - private final static <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam$lambda-0(p0: kotlin.jvm.functions.Function0): java.lang.String public final static <(Lkotlin/jvm/functions/Function0;)Ljava/lang/String;> method specializedSam(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): java.lang.String + inner (anonymous) class TKt$specializedSam$1 } diff --git a/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.kt b/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.kt index 9db99e321b9..536a27e6b15 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/reusedSamWrapperClasses.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_RUNTIME class A { diff --git a/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.kt b/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.kt index 5fb0edbf713..8aac7428cfe 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/samAdapterAndInlinedOne.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES package test diff --git a/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.kt index 150cd5d58d4..29fe54748b5 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedFunInterface.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.kt b/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.kt index 72ecaa94f56..47b7a58da68 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/specializedSamInterface.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // WITH_SIGNATURES // FILE: t.kt diff --git a/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass.kt b/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass.kt index dadc316c73e..77b7431c89a 100644 --- a/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass.kt +++ b/compiler/testData/codegen/bytecodeListing/sam/wrapperInlinedFromAnotherClass.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS class A { fun test1a() = B().runnable1() fun test1b() = B().runnable1() From 43b1711010dc0bfb524993141f7a074a0c50cfc2 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 9 Feb 2021 10:38:59 +0300 Subject: [PATCH 074/368] JVM_IR indy: extract LambdaMetafactoryArguments code to separate file KT-44278 KT-26060 KT-42621 --- .../jvm/lower/FunctionReferenceLowering.kt | 415 +---------------- .../jvm/lower/LambdaMetafactoryArguments.kt | 418 ++++++++++++++++++ 2 files changed, 429 insertions(+), 404 deletions(-) create mode 100644 compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/LambdaMetafactoryArguments.kt diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt index 8df71804e22..c44ca3b79e5 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt @@ -9,13 +9,11 @@ import org.jetbrains.kotlin.backend.common.FileLoweringPass import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext import org.jetbrains.kotlin.backend.common.ir.* import org.jetbrains.kotlin.backend.common.lower.SamEqualsHashCodeMethodsGenerator -import org.jetbrains.kotlin.backend.common.lower.parents import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.ir.* import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.InlineClassAbi -import org.jetbrains.kotlin.builtins.functions.BuiltInFunctionArity import org.jetbrains.kotlin.config.JvmClosureGenerationScheme import org.jetbrains.kotlin.descriptors.DescriptorVisibilities import org.jetbrains.kotlin.descriptors.Modality @@ -25,9 +23,7 @@ import org.jetbrains.kotlin.ir.builders.declarations.* import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.* -import org.jetbrains.kotlin.ir.overrides.buildFakeOverrideMember import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol -import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid @@ -46,7 +42,7 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) // function reference classes needed. private val ignoredFunctionReferences = mutableSetOf>() - private val inlineLambdaToValueParameter = HashMap() + private val crossinlineLambdas = HashSet() private val IrFunctionReference.isIgnored: Boolean get() = (!type.isFunctionOrKFunction() && !isSuspendFunctionReference()) || ignoredFunctionReferences.contains(this) @@ -68,7 +64,10 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) scope: IrDeclaration ) { ignoredFunctionReferences.add(argument) - inlineLambdaToValueParameter[argument.symbol.owner] = parameter + val argumentFun = argument.symbol.owner + if (parameter.isCrossinline && argumentFun is IrSimpleFunction) { + crossinlineLambdas.add(argumentFun) + } } }, null @@ -94,7 +93,9 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) reference.transformChildrenVoid(this) if (shouldGenerateIndyLambdas) { - val lambdaMetafactoryArguments = getLambdaMetafactoryArgumentsOrNull(reference, reference.type, true) + val lambdaMetafactoryArguments = + LambdaMetafactoryArgumentsBuilder(context, crossinlineLambdas) + .getLambdaMetafactoryArgumentsOrNull(reference, reference.type, true) if (lambdaMetafactoryArguments != null) { return wrapLambdaReferenceWithIndySamConversion(expression, reference, lambdaMetafactoryArguments) } @@ -147,7 +148,9 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) val samSuperType = expression.typeOperand if (shouldGenerateIndySamConversions) { - val lambdaMetafactoryArguments = getLambdaMetafactoryArgumentsOrNull(reference, samSuperType, false) + val lambdaMetafactoryArguments = + LambdaMetafactoryArgumentsBuilder(context, crossinlineLambdas) + .getLambdaMetafactoryArgumentsOrNull(reference, samSuperType, false) if (lambdaMetafactoryArguments != null) { return wrapSamConversionArgumentWithIndySamConversion(expression, lambdaMetafactoryArguments) } @@ -156,390 +159,6 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) return FunctionReferenceBuilder(reference, samSuperType).build() } - private class LambdaMetafactoryArguments( - val samMethod: IrSimpleFunction, - val fakeInstanceMethod: IrSimpleFunction, - val implMethodReference: IrFunctionReference, - val extraOverriddenMethods: List - ) - - /** - * @see java.lang.invoke.LambdaMetafactory - */ - private fun getLambdaMetafactoryArgumentsOrNull( - reference: IrFunctionReference, - samType: IrType, - plainLambda: Boolean - ): LambdaMetafactoryArguments? { - // Can't use JDK LambdaMetafactory for function references by default (because of 'equals'). - // TODO special mode that would generate indy everywhere? - if (reference.origin != IrStatementOrigin.LAMBDA) - return null - - val samClass = samType.getClass() - ?: throw AssertionError("SAM type is not a class: ${samType.render()}") - val samMethod = samClass.getSingleAbstractMethod() - ?: throw AssertionError("SAM class has no single abstract method: ${samClass.render()}") - - // Can't use JDK LambdaMetafactory for fun interface with suspend fun. - if (samMethod.isSuspend) - return null - - // Can't use JDK LambdaMetafactory for fun interfaces that require delegation to $DefaultImpls. - if (samClass.requiresDelegationToDefaultImpls()) - return null - - val target = reference.symbol.owner as? IrSimpleFunction - ?: throw AssertionError("Simple function expected: ${reference.symbol.owner.render()}") - - // Can't use JDK LambdaMetafactory for annotated lambdas. - // JDK LambdaMetafactory doesn't copy annotations from implementation method to an instance method in a - // corresponding synthetic class, which doesn't look like a binary compatible change. - // TODO relaxed mode? - if (target.annotations.isNotEmpty()) - return null - - // Don't use JDK LambdaMetafactory for big arity lambdas. - if (plainLambda) { - var parametersCount = target.valueParameters.size - if (target.extensionReceiverParameter != null) ++parametersCount - if (parametersCount >= BuiltInFunctionArity.BIG_ARITY) - return null - } - - // Can't use indy-based SAM conversion inside inline fun (Ok in inline lambda). - if (target.parents.any { it.isInlineFunction() || it.isCrossinlineLambda() }) - return null - - // Do the hard work of matching Kotlin functional interface hierarchy against LambdaMetafactory constraints. - // Briefly: sometimes we have to force boxing on the primitive and inline class values, sometimes we have to keep them unboxed. - // If this results in conflicting requirements, we can't use INVOKEDYNAMIC with LambdaMetafactory for creating a closure. - return getLambdaMetafactoryArgsOrNullInner(reference, samMethod, samType, target) - } - - private fun IrClass.requiresDelegationToDefaultImpls(): Boolean { - for (irMemberFun in functions) { - if (irMemberFun.modality == Modality.ABSTRACT) - continue - val irImplFun = - if (irMemberFun.isFakeOverride) - irMemberFun.findInterfaceImplementation(context.state.jvmDefaultMode) - ?: continue - else - irMemberFun - if (irImplFun.origin == IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB) - continue - if (!irImplFun.isCompiledToJvmDefault(context.state.jvmDefaultMode)) - return true - } - return false - } - - private fun getLambdaMetafactoryArgsOrNullInner( - reference: IrFunctionReference, - samMethod: IrSimpleFunction, - samType: IrType, - implLambda: IrSimpleFunction - ): LambdaMetafactoryArguments? { - val nonFakeOverriddenFuns = samMethod.allOverridden().filterNot { it.isFakeOverride } - val relevantOverriddenFuns = if (samMethod.isFakeOverride) nonFakeOverriddenFuns else nonFakeOverriddenFuns + samMethod - - // Create a fake instance method as if it was defined in a class implementing SAM interface - // (such class would be eventually created by LambdaMetafactory at run-time). - val fakeClass = context.irFactory.buildClass { name = Name.special("") } - fakeClass.parent = context.ir.symbols.kotlinJvmInternalInvokeDynamicPackage - val fakeInstanceMethod = buildFakeOverrideMember(samType, samMethod, fakeClass) as IrSimpleFunction - (fakeInstanceMethod as IrFakeOverrideFunction).acquireSymbol(IrSimpleFunctionSymbolImpl()) - fakeInstanceMethod.overriddenSymbols = listOf(samMethod.symbol) - - // Compute signature adaptation constraints for a fake instance method signature against all relevant overrides. - // If at any step we encounter a conflict (e.g., one override requires boxing a parameter, and another requires - // to keep it unboxed), we can't adapt this signature and can't use LambdaMetafactory to create a closure. - // - // Note that those constraints are not checked precisely in JDK 1.8 (jdk1.8.0_231), but are checked more strictly - // in later JDK versions and in D8 (so if you see an exception from D8 in codegen test failures, corresponding code - // with INVOKEDYNAMIC would quite likely fail on JDK 9 and beyond). - // - // Example 1 (requires boxing): - // fun interface IFoo { - // fun foo(x: T) - // } - // val t = IFoo { println(it + 1) } - // Here IFoo::foo requires 'x' to be reference type (even though corresponding lambda accepts a primitive int). - // this - // - // Example 2 (no explicit override, boxing-unboxing conflict): - // fun interface IFooT { - // fun foo(x: T) - // } - // fun interface IFooInt { - // fun foo(x: Int) - // } - // fun interface IFooMix : IFooT, IFooInt - // val t = IFooMix { println(it + 1) } - // Here IFooT::foo requires 'x' to be of a reference type, and IFooInt::foo requires 'x' to be of a primitive type. - // LambdaMetafactory can't handle such case. - // - // Example 3 (explicit override, boxing-unboxing conflict): - // fun interface IFooT { - // fun foo(x: T) - // } - // fun interface IFooInt { - // fun foo(x: Int) - // } - // fun interface IFooMix : IFooT, IFooInt { - // override fun foo(x: Int) - // } - // val t = IFooMix { println(it + 1) } - // Here, even though we have an explicit 'override fun foo(x: Int)' in IFooMix, we don't generate a bridge for 'foo' in IFooMix. - // Thus, class for a lambda created by LambdaMetafactory should provide a bridge for 'foo'. - // Thus, 'x' should be of a reference type. - // On the other hand, it should also override IFooInt#foo, where 'x' should be a primitive type. - // LambdaMetafactory can't handle such case. - // - // TODO accept Example 3 if IFooMix is compiled with default interface methods - // Note that this is a conservative check; if we reject LambdaMetafactory-based closure generation scheme, compiler would still - // generate proper (although somewhat sub-optimal) code with explicit class for a corresponding SAM-converted lambda. - val signatureAdaptationConstraints = run { - var result = SignatureAdaptationConstraints(emptyMap(), null) - for (overriddenFun in relevantOverriddenFuns) { - val constraintsFromOverridden = computeSignatureAdaptationConstraints(fakeInstanceMethod, overriddenFun) - ?: return null - result = joinSignatureAdaptationConstraints(result, constraintsFromOverridden) - ?: return null - } - result - } - - // We should have bailed out before if we encountered any kind of type adaptation conflict. - // Still, check that we are fine - just in case. - if (signatureAdaptationConstraints.returnType == TypeAdaptationConstraint.CONFLICT || - signatureAdaptationConstraints.valueParameters.values.any { it == TypeAdaptationConstraint.CONFLICT } - ) - return null - - adaptFakeInstanceMethodSignature(fakeInstanceMethod, signatureAdaptationConstraints) - - adaptLambdaSignature(implLambda, fakeInstanceMethod, signatureAdaptationConstraints) - - if (samMethod.isFakeOverride && nonFakeOverriddenFuns.size == 1) { - return LambdaMetafactoryArguments(nonFakeOverriddenFuns.single(), fakeInstanceMethod, reference, listOf()) - } - return LambdaMetafactoryArguments(samMethod, fakeInstanceMethod, reference, nonFakeOverriddenFuns) - } - - private fun adaptLambdaSignature( - lambda: IrSimpleFunction, - fakeInstanceMethod: IrSimpleFunction, - constraints: SignatureAdaptationConstraints - ) { - val lambdaParameters = collectValueParameters(lambda) - val methodParameters = collectValueParameters(fakeInstanceMethod) - if (lambdaParameters.size != methodParameters.size) - throw AssertionError( - "Mismatching lambda and instance method parameters:\n" + - "lambda: ${lambda.render()}\n" + - " (${lambdaParameters.size} parameters)\n" + - "instance method: ${fakeInstanceMethod.render()}\n" + - " (${methodParameters.size} parameters)" - ) - for ((lambdaParameter, methodParameter) in lambdaParameters.zip(methodParameters)) { - // TODO box inline class parameters only? - val parameterConstraint = constraints.valueParameters[methodParameter] - if (parameterConstraint == TypeAdaptationConstraint.FORCE_BOXING) { - lambdaParameter.type = lambdaParameter.type.makeNullable() - } - } - if (constraints.returnType == TypeAdaptationConstraint.FORCE_BOXING) { - lambda.returnType = lambda.returnType.makeNullable() - } - } - - private fun adaptFakeInstanceMethodSignature(fakeInstanceMethod: IrSimpleFunction, constraints: SignatureAdaptationConstraints) { - for ((valueParameter, constraint) in constraints.valueParameters) { - if (valueParameter.parent != fakeInstanceMethod) - throw AssertionError( - "Unexpected value parameter: ${valueParameter.render()}; fakeInstanceMethod:\n" + - fakeInstanceMethod.dump() - ) - if (constraint == TypeAdaptationConstraint.FORCE_BOXING) { - valueParameter.type = valueParameter.type.makeNullable() - } - } - if (constraints.returnType == TypeAdaptationConstraint.FORCE_BOXING) { - fakeInstanceMethod.returnType = fakeInstanceMethod.returnType.makeNullable() - } - } - - private enum class TypeAdaptationConstraint { - FORCE_BOXING, - KEEP_UNBOXED, - CONFLICT - } - - private class SignatureAdaptationConstraints( - val valueParameters: Map, - val returnType: TypeAdaptationConstraint? - ) - - private fun computeSignatureAdaptationConstraints( - adapteeFun: IrSimpleFunction, - expectedFun: IrSimpleFunction - ): SignatureAdaptationConstraints? { - val returnTypeConstraint = computeReturnTypeAdaptationConstraint(adapteeFun, expectedFun) - if (returnTypeConstraint == TypeAdaptationConstraint.CONFLICT) - return null - - val valueParameterConstraints = HashMap() - val adapteeParameters = collectValueParameters(adapteeFun) - val expectedParameters = collectValueParameters(expectedFun) - if (adapteeParameters.size != expectedParameters.size) - throw AssertionError( - "Mismatching value parameters:\n" + - "adaptee: ${adapteeFun.render()}\n" + - " ${adapteeParameters.size} value parameters;\n" + - "expected: ${expectedFun.render()}\n" + - " ${expectedParameters.size} value parameters." - ) - for ((adapteeParameter, expectedParameter) in adapteeParameters.zip(expectedParameters)) { - val parameterConstraint = computeParameterTypeAdaptationConstraint(adapteeParameter.type, expectedParameter.type) - ?: continue - if (parameterConstraint == TypeAdaptationConstraint.CONFLICT) - return null - valueParameterConstraints[adapteeParameter] = parameterConstraint - } - - return SignatureAdaptationConstraints( - if (valueParameterConstraints.isEmpty()) emptyMap() else valueParameterConstraints, - returnTypeConstraint - ) - } - - private fun computeParameterTypeAdaptationConstraint(adapteeType: IrType, expectedType: IrType): TypeAdaptationConstraint? { - if (adapteeType !is IrSimpleType) - throw AssertionError("Simple type expected: ${adapteeType.render()}") - if (expectedType !is IrSimpleType) - throw AssertionError("Simple type expected: ${expectedType.render()}") - - // TODO what if adapteeType and/or expectedType are type parameters with JVM primitive type upper bounds? - - if (adapteeType.isNothing() || adapteeType.isNullableNothing()) - return TypeAdaptationConstraint.CONFLICT - - // ** JVM primitives ** - // All Kotlin types mapped to JVM primitive are final, - // and their supertypes are trivially mapped reference types. - if (adapteeType.isJvmPrimitiveType()) { - return if (expectedType.isJvmPrimitiveType()) - TypeAdaptationConstraint.KEEP_UNBOXED - else - TypeAdaptationConstraint.FORCE_BOXING - } - - // ** Inline classes ** - // All Kotlin inline classes are final, - // and their supertypes are trivially mapped to reference types. - val erasedAdapteeClass = getErasedClassForSignatureAdaptation(adapteeType) - if (erasedAdapteeClass.isInline) { - // Inline classes mapped to non-null reference types are a special case because they can't be boxed trivially. - // TODO consider adding a special type annotation to force boxing on an inline class type regardless of its underlying type. - val underlyingAdapteeType = getInlineClassUnderlyingType(erasedAdapteeClass) as? IrSimpleType - ?: throw AssertionError("Underlying type for inline class should be a simple type: ${erasedAdapteeClass.render()}") - if (!underlyingAdapteeType.hasQuestionMark && !underlyingAdapteeType.isJvmPrimitiveType()) { - return TypeAdaptationConstraint.CONFLICT - } - - val erasedExpectedClass = getErasedClassForSignatureAdaptation(expectedType) - return if (erasedExpectedClass.isInline) { - // LambdaMetafactory doesn't know about method mangling. - TypeAdaptationConstraint.CONFLICT - } else { - // Trying to pass inline class value as non-inline class value (Any or other supertype) - // => box it - TypeAdaptationConstraint.FORCE_BOXING - } - } - - // Other cases don't enforce type adaptation - return null - } - - private fun getErasedClassForSignatureAdaptation(irType: IrSimpleType): IrClass = - when (val classifier = irType.classifier.owner) { - is IrTypeParameter -> classifier.erasedUpperBound - is IrClass -> classifier - else -> - throw AssertionError("Unexpected classifier: ${classifier.render()}") - } - - private fun computeReturnTypeAdaptationConstraint( - adapteeFun: IrSimpleFunction, - expectedFun: IrSimpleFunction - ): TypeAdaptationConstraint? { - val adapteeReturnType = adapteeFun.returnType - if (adapteeReturnType.isUnit()) { - // Can't mix '()V' and '()Lkotlin.Unit;' or '()Ljava.lang.Object;' in supertype method signatures. - return if (expectedFun.returnType.isUnit()) - TypeAdaptationConstraint.KEEP_UNBOXED - else { - TypeAdaptationConstraint.FORCE_BOXING - } - } - - val expectedReturnType = expectedFun.returnType - return computeParameterTypeAdaptationConstraint(adapteeReturnType, expectedReturnType) - } - - private fun joinSignatureAdaptationConstraints( - sig1: SignatureAdaptationConstraints, - sig2: SignatureAdaptationConstraints - ): SignatureAdaptationConstraints? { - val newReturnTypeConstraint = composeTypeAdaptationConstraints(sig1.returnType, sig2.returnType) - if (newReturnTypeConstraint == TypeAdaptationConstraint.CONFLICT) - return null - - val newValueParameterConstraints = - when { - sig1.valueParameters.isEmpty() -> sig2.valueParameters - sig2.valueParameters.isEmpty() -> sig1.valueParameters - else -> { - val joined = HashMap() - joined.putAll(sig1.valueParameters) - for ((vp2, t2) in sig2.valueParameters.entries) { - val tx = composeTypeAdaptationConstraints(joined[vp2], t2) ?: continue - if (tx == TypeAdaptationConstraint.CONFLICT) - return null - joined[vp2] = tx - } - joined - } - } - - return SignatureAdaptationConstraints(newValueParameterConstraints, newReturnTypeConstraint) - } - - private fun composeTypeAdaptationConstraints(t1: TypeAdaptationConstraint?, t2: TypeAdaptationConstraint?): TypeAdaptationConstraint? = - when { - t1 == null -> t2 - t2 == null -> t1 - t1 == t2 -> t1 - else -> - TypeAdaptationConstraint.CONFLICT - } - - - private fun IrDeclarationParent.isInlineFunction() = - this is IrSimpleFunction && isInline && origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA - - private fun IrDeclarationParent.isCrossinlineLambda(): Boolean { - val irFun = this as? IrSimpleFunction ?: return false - return origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA && - inlineLambdaToValueParameter[irFun]?.isCrossinline == true - } - - private fun IrType.isJvmPrimitiveType() = - isBoolean() || isChar() || isByte() || isShort() || isInt() || isLong() || isFloat() || isDouble() - private fun wrapSamConversionArgumentWithIndySamConversion( expression: IrTypeOperatorCall, lambdaMetafactoryArguments: LambdaMetafactoryArguments @@ -591,18 +210,6 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) private fun IrBuilderWithScope.irVarargOfRawFunctionRefs(irFuns: List) = irVararg(context.irBuiltIns.anyType, irFuns.map { irRawFunctionRef(it) }) - private fun collectValueParameters(irFun: IrFunction): List { - if (irFun.extensionReceiverParameter == null) - return irFun.valueParameters - return ArrayList().apply { - add(irFun.extensionReceiverParameter!!) - addAll(irFun.valueParameters) - } - } - - private fun IrType.isUnboxedInlineClassType() = - this is IrSimpleType && isInlined() && !hasQuestionMark - private inner class FunctionReferenceBuilder(val irFunctionReference: IrFunctionReference, val samSuperType: IrType? = null) { private val isLambda = irFunctionReference.origin.isLambda diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/LambdaMetafactoryArguments.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/LambdaMetafactoryArguments.kt new file mode 100644 index 00000000000..ba6396c3f79 --- /dev/null +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/LambdaMetafactoryArguments.kt @@ -0,0 +1,418 @@ +/* + * Copyright 2010-2021 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.backend.jvm.lower + +import org.jetbrains.kotlin.backend.common.ir.allOverridden +import org.jetbrains.kotlin.backend.common.lower.parents +import org.jetbrains.kotlin.backend.jvm.JvmBackendContext +import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound +import org.jetbrains.kotlin.backend.jvm.ir.getSingleAbstractMethod +import org.jetbrains.kotlin.backend.jvm.ir.isCompiledToJvmDefault +import org.jetbrains.kotlin.builtins.functions.BuiltInFunctionArity +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.ir.builders.declarations.buildClass +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.IrFunctionReference +import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.overrides.buildFakeOverrideMember +import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl +import org.jetbrains.kotlin.ir.types.* +import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.name.Name + +class LambdaMetafactoryArguments( + val samMethod: IrSimpleFunction, + val fakeInstanceMethod: IrSimpleFunction, + val implMethodReference: IrFunctionReference, + val extraOverriddenMethods: List +) + +class LambdaMetafactoryArgumentsBuilder( + private val context: JvmBackendContext, + private val crossinlineLambdas: Set +) { + /** + * @see java.lang.invoke.LambdaMetafactory + */ + fun getLambdaMetafactoryArgumentsOrNull( + reference: IrFunctionReference, + samType: IrType, + plainLambda: Boolean + ): LambdaMetafactoryArguments? { + // Can't use JDK LambdaMetafactory for function references by default (because of 'equals'). + // TODO special mode that would generate indy everywhere? + if (reference.origin != IrStatementOrigin.LAMBDA) + return null + + val samClass = samType.getClass() + ?: throw AssertionError("SAM type is not a class: ${samType.render()}") + val samMethod = samClass.getSingleAbstractMethod() + ?: throw AssertionError("SAM class has no single abstract method: ${samClass.render()}") + + // Can't use JDK LambdaMetafactory for fun interface with suspend fun. + if (samMethod.isSuspend) + return null + + // Can't use JDK LambdaMetafactory for fun interfaces that require delegation to $DefaultImpls. + if (samClass.requiresDelegationToDefaultImpls()) + return null + + val target = reference.symbol.owner as? IrSimpleFunction + ?: throw AssertionError("Simple function expected: ${reference.symbol.owner.render()}") + + // Can't use JDK LambdaMetafactory for annotated lambdas. + // JDK LambdaMetafactory doesn't copy annotations from implementation method to an instance method in a + // corresponding synthetic class, which doesn't look like a binary compatible change. + // TODO relaxed mode? + if (target.annotations.isNotEmpty()) + return null + + // Don't use JDK LambdaMetafactory for big arity lambdas. + if (plainLambda) { + var parametersCount = target.valueParameters.size + if (target.extensionReceiverParameter != null) ++parametersCount + if (parametersCount >= BuiltInFunctionArity.BIG_ARITY) + return null + } + + // Can't use indy-based SAM conversion inside inline fun (Ok in inline lambda). + if (target.parents.any { it.isInlineFunction() || it.isCrossinlineLambda() }) + return null + + // Do the hard work of matching Kotlin functional interface hierarchy against LambdaMetafactory constraints. + // Briefly: sometimes we have to force boxing on the primitive and inline class values, sometimes we have to keep them unboxed. + // If this results in conflicting requirements, we can't use INVOKEDYNAMIC with LambdaMetafactory for creating a closure. + return getLambdaMetafactoryArgsOrNullInner(reference, samMethod, samType, target) + } + + private fun IrClass.requiresDelegationToDefaultImpls(): Boolean { + for (irMemberFun in functions) { + if (irMemberFun.modality == Modality.ABSTRACT) + continue + val irImplFun = + if (irMemberFun.isFakeOverride) + irMemberFun.findInterfaceImplementation(context.state.jvmDefaultMode) + ?: continue + else + irMemberFun + if (irImplFun.origin == IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB) + continue + if (!irImplFun.isCompiledToJvmDefault(context.state.jvmDefaultMode)) + return true + } + return false + } + + private fun getLambdaMetafactoryArgsOrNullInner( + reference: IrFunctionReference, + samMethod: IrSimpleFunction, + samType: IrType, + implLambda: IrSimpleFunction + ): LambdaMetafactoryArguments? { + val nonFakeOverriddenFuns = samMethod.allOverridden().filterNot { it.isFakeOverride } + val relevantOverriddenFuns = if (samMethod.isFakeOverride) nonFakeOverriddenFuns else nonFakeOverriddenFuns + samMethod + + // Create a fake instance method as if it was defined in a class implementing SAM interface + // (such class would be eventually created by LambdaMetafactory at run-time). + val fakeClass = context.irFactory.buildClass { name = Name.special("") } + fakeClass.parent = context.ir.symbols.kotlinJvmInternalInvokeDynamicPackage + val fakeInstanceMethod = buildFakeOverrideMember(samType, samMethod, fakeClass) as IrSimpleFunction + (fakeInstanceMethod as IrFakeOverrideFunction).acquireSymbol(IrSimpleFunctionSymbolImpl()) + fakeInstanceMethod.overriddenSymbols = listOf(samMethod.symbol) + + // Compute signature adaptation constraints for a fake instance method signature against all relevant overrides. + // If at any step we encounter a conflict (e.g., one override requires boxing a parameter, and another requires + // to keep it unboxed), we can't adapt this signature and can't use LambdaMetafactory to create a closure. + // + // Note that those constraints are not checked precisely in JDK 1.8 (jdk1.8.0_231), but are checked more strictly + // in later JDK versions and in D8 (so if you see an exception from D8 in codegen test failures, corresponding code + // with INVOKEDYNAMIC would quite likely fail on JDK 9 and beyond). + // + // Example 1 (requires boxing): + // fun interface IFoo { + // fun foo(x: T) + // } + // val t = IFoo { println(it + 1) } + // Here IFoo::foo requires 'x' to be reference type (even though corresponding lambda accepts a primitive int). + // + // Example 2 (no explicit override, boxing-unboxing conflict): + // fun interface IFooT { + // fun foo(x: T) + // } + // fun interface IFooInt { + // fun foo(x: Int) + // } + // fun interface IFooMix : IFooT, IFooInt + // val t = IFooMix { println(it + 1) } + // Here IFooT::foo requires 'x' to be of a reference type, and IFooInt::foo requires 'x' to be of a primitive type. + // LambdaMetafactory can't handle such case. + // + // Example 3 (explicit override, boxing-unboxing conflict): + // fun interface IFooT { + // fun foo(x: T) + // } + // fun interface IFooInt { + // fun foo(x: Int) + // } + // fun interface IFooMix : IFooT, IFooInt { + // override fun foo(x: Int) + // } + // val t = IFooMix { println(it + 1) } + // Here, even though we have an explicit 'override fun foo(x: Int)' in IFooMix, we don't generate a bridge for 'foo' in IFooMix. + // Thus, class for a lambda created by LambdaMetafactory should provide a bridge for 'foo'. + // Thus, 'x' should be of a reference type. + // On the other hand, it should also override IFooInt#foo, where 'x' should be a primitive type. + // LambdaMetafactory can't handle such case. + // + // TODO accept Example 3 if IFooMix is compiled with default interface methods + // Note that this is a conservative check; if we reject LambdaMetafactory-based closure generation scheme, compiler would still + // generate proper (although somewhat sub-optimal) code with explicit class for a corresponding SAM-converted lambda. + val signatureAdaptationConstraints = run { + var result = SignatureAdaptationConstraints(emptyMap(), null) + for (overriddenFun in relevantOverriddenFuns) { + val constraintsFromOverridden = computeSignatureAdaptationConstraints(fakeInstanceMethod, overriddenFun) + ?: return null + result = joinSignatureAdaptationConstraints(result, constraintsFromOverridden) + ?: return null + } + result + } + + // We should have bailed out before if we encountered any kind of type adaptation conflict. + // Still, check that we are fine - just in case. + if (signatureAdaptationConstraints.returnType == TypeAdaptationConstraint.CONFLICT || + signatureAdaptationConstraints.valueParameters.values.any { it == TypeAdaptationConstraint.CONFLICT } + ) + return null + + adaptFakeInstanceMethodSignature(fakeInstanceMethod, signatureAdaptationConstraints) + + adaptLambdaSignature(implLambda, fakeInstanceMethod, signatureAdaptationConstraints) + + if (samMethod.isFakeOverride && nonFakeOverriddenFuns.size == 1) { + return LambdaMetafactoryArguments(nonFakeOverriddenFuns.single(), fakeInstanceMethod, reference, listOf()) + } + return LambdaMetafactoryArguments(samMethod, fakeInstanceMethod, reference, nonFakeOverriddenFuns) + } + + private fun adaptLambdaSignature( + lambda: IrSimpleFunction, + fakeInstanceMethod: IrSimpleFunction, + constraints: SignatureAdaptationConstraints + ) { + val lambdaParameters = collectValueParameters(lambda) + val methodParameters = collectValueParameters(fakeInstanceMethod) + if (lambdaParameters.size != methodParameters.size) + throw AssertionError( + "Mismatching lambda and instance method parameters:\n" + + "lambda: ${lambda.render()}\n" + + " (${lambdaParameters.size} parameters)\n" + + "instance method: ${fakeInstanceMethod.render()}\n" + + " (${methodParameters.size} parameters)" + ) + for ((lambdaParameter, methodParameter) in lambdaParameters.zip(methodParameters)) { + // TODO box inline class parameters only? + val parameterConstraint = constraints.valueParameters[methodParameter] + if (parameterConstraint == TypeAdaptationConstraint.FORCE_BOXING) { + lambdaParameter.type = lambdaParameter.type.makeNullable() + } + } + if (constraints.returnType == TypeAdaptationConstraint.FORCE_BOXING) { + lambda.returnType = lambda.returnType.makeNullable() + } + } + + private fun adaptFakeInstanceMethodSignature(fakeInstanceMethod: IrSimpleFunction, constraints: SignatureAdaptationConstraints) { + for ((valueParameter, constraint) in constraints.valueParameters) { + if (valueParameter.parent != fakeInstanceMethod) + throw AssertionError( + "Unexpected value parameter: ${valueParameter.render()}; fakeInstanceMethod:\n" + + fakeInstanceMethod.dump() + ) + if (constraint == TypeAdaptationConstraint.FORCE_BOXING) { + valueParameter.type = valueParameter.type.makeNullable() + } + } + if (constraints.returnType == TypeAdaptationConstraint.FORCE_BOXING) { + fakeInstanceMethod.returnType = fakeInstanceMethod.returnType.makeNullable() + } + } + + private enum class TypeAdaptationConstraint { + FORCE_BOXING, + KEEP_UNBOXED, + CONFLICT + } + + private class SignatureAdaptationConstraints( + val valueParameters: Map, + val returnType: TypeAdaptationConstraint? + ) + + private fun computeSignatureAdaptationConstraints( + adapteeFun: IrSimpleFunction, + expectedFun: IrSimpleFunction + ): SignatureAdaptationConstraints? { + val returnTypeConstraint = computeReturnTypeAdaptationConstraint(adapteeFun, expectedFun) + if (returnTypeConstraint == TypeAdaptationConstraint.CONFLICT) + return null + + val valueParameterConstraints = HashMap() + val adapteeParameters = collectValueParameters(adapteeFun) + val expectedParameters = collectValueParameters(expectedFun) + if (adapteeParameters.size != expectedParameters.size) + throw AssertionError( + "Mismatching value parameters:\n" + + "adaptee: ${adapteeFun.render()}\n" + + " ${adapteeParameters.size} value parameters;\n" + + "expected: ${expectedFun.render()}\n" + + " ${expectedParameters.size} value parameters." + ) + for ((adapteeParameter, expectedParameter) in adapteeParameters.zip(expectedParameters)) { + val parameterConstraint = computeParameterTypeAdaptationConstraint(adapteeParameter.type, expectedParameter.type) + ?: continue + if (parameterConstraint == TypeAdaptationConstraint.CONFLICT) + return null + valueParameterConstraints[adapteeParameter] = parameterConstraint + } + + return SignatureAdaptationConstraints( + if (valueParameterConstraints.isEmpty()) emptyMap() else valueParameterConstraints, + returnTypeConstraint + ) + } + + private fun computeParameterTypeAdaptationConstraint(adapteeType: IrType, expectedType: IrType): TypeAdaptationConstraint? { + if (adapteeType !is IrSimpleType) + throw AssertionError("Simple type expected: ${adapteeType.render()}") + if (expectedType !is IrSimpleType) + throw AssertionError("Simple type expected: ${expectedType.render()}") + + // TODO what if adapteeType and/or expectedType are type parameters with JVM primitive type upper bounds? + + if (adapteeType.isNothing() || adapteeType.isNullableNothing()) + return TypeAdaptationConstraint.CONFLICT + + // ** JVM primitives ** + // All Kotlin types mapped to JVM primitive are final, + // and their supertypes are trivially mapped reference types. + if (adapteeType.isJvmPrimitiveType()) { + return if (expectedType.isJvmPrimitiveType()) + TypeAdaptationConstraint.KEEP_UNBOXED + else + TypeAdaptationConstraint.FORCE_BOXING + } + + // ** Inline classes ** + // All Kotlin inline classes are final, + // and their supertypes are trivially mapped to reference types. + val erasedAdapteeClass = getErasedClassForSignatureAdaptation(adapteeType) + if (erasedAdapteeClass.isInline) { + // Inline classes mapped to non-null reference types are a special case because they can't be boxed trivially. + // TODO consider adding a special type annotation to force boxing on an inline class type regardless of its underlying type. + val underlyingAdapteeType = getInlineClassUnderlyingType(erasedAdapteeClass) as? IrSimpleType + ?: throw AssertionError("Underlying type for inline class should be a simple type: ${erasedAdapteeClass.render()}") + if (!underlyingAdapteeType.hasQuestionMark && !underlyingAdapteeType.isJvmPrimitiveType()) { + return TypeAdaptationConstraint.CONFLICT + } + + val erasedExpectedClass = getErasedClassForSignatureAdaptation(expectedType) + return if (erasedExpectedClass.isInline) { + // LambdaMetafactory doesn't know about method mangling. + TypeAdaptationConstraint.CONFLICT + } else { + // Trying to pass inline class value as non-inline class value (Any or other supertype) + // => box it + TypeAdaptationConstraint.FORCE_BOXING + } + } + + // Other cases don't enforce type adaptation + return null + } + + private fun getErasedClassForSignatureAdaptation(irType: IrSimpleType): IrClass = + when (val classifier = irType.classifier.owner) { + is IrTypeParameter -> classifier.erasedUpperBound + is IrClass -> classifier + else -> + throw AssertionError("Unexpected classifier: ${classifier.render()}") + } + + private fun computeReturnTypeAdaptationConstraint( + adapteeFun: IrSimpleFunction, + expectedFun: IrSimpleFunction + ): TypeAdaptationConstraint? { + val adapteeReturnType = adapteeFun.returnType + if (adapteeReturnType.isUnit()) { + // Can't mix '()V' and '()Lkotlin.Unit;' or '()Ljava.lang.Object;' in supertype method signatures. + return if (expectedFun.returnType.isUnit()) + TypeAdaptationConstraint.KEEP_UNBOXED + else { + TypeAdaptationConstraint.FORCE_BOXING + } + } + + val expectedReturnType = expectedFun.returnType + return computeParameterTypeAdaptationConstraint(adapteeReturnType, expectedReturnType) + } + + private fun joinSignatureAdaptationConstraints( + sig1: SignatureAdaptationConstraints, + sig2: SignatureAdaptationConstraints + ): SignatureAdaptationConstraints? { + val newReturnTypeConstraint = composeTypeAdaptationConstraints(sig1.returnType, sig2.returnType) + if (newReturnTypeConstraint == TypeAdaptationConstraint.CONFLICT) + return null + + val newValueParameterConstraints = + when { + sig1.valueParameters.isEmpty() -> sig2.valueParameters + sig2.valueParameters.isEmpty() -> sig1.valueParameters + else -> { + val joined = HashMap() + joined.putAll(sig1.valueParameters) + for ((vp2, t2) in sig2.valueParameters.entries) { + val tx = composeTypeAdaptationConstraints(joined[vp2], t2) ?: continue + if (tx == TypeAdaptationConstraint.CONFLICT) + return null + joined[vp2] = tx + } + joined + } + } + + return SignatureAdaptationConstraints(newValueParameterConstraints, newReturnTypeConstraint) + } + + private fun composeTypeAdaptationConstraints(t1: TypeAdaptationConstraint?, t2: TypeAdaptationConstraint?): TypeAdaptationConstraint? = + when { + t1 == null -> t2 + t2 == null -> t1 + t1 == t2 -> t1 + else -> + TypeAdaptationConstraint.CONFLICT + } + + + private fun IrDeclarationParent.isInlineFunction() = + this is IrSimpleFunction && isInline && origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA + + private fun IrDeclarationParent.isCrossinlineLambda(): Boolean = + this is IrSimpleFunction && this in crossinlineLambdas + + private fun IrType.isJvmPrimitiveType() = + isBoolean() || isChar() || isByte() || isShort() || isInt() || isLong() || isFloat() || isDouble() + + private fun collectValueParameters(irFun: IrFunction): List { + if (irFun.extensionReceiverParameter == null) + return irFun.valueParameters + return ArrayList().apply { + add(irFun.extensionReceiverParameter!!) + addAll(irFun.valueParameters) + } + } +} \ No newline at end of file From afeb7e18cd5f0b7ff7f4c23e6e9f2ed6fccf090c Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 10 Feb 2021 10:10:49 +0300 Subject: [PATCH 075/368] JVM_IR indy: fix non-null assertions on indy lambda parameters KT-44278 KT-26060 KT-42621 --- .../FirBlackBoxCodegenTestGenerated.java | 6 +++++ .../backend/jvm/codegen/ExpressionCodegen.kt | 9 ++++++- .../sam/nullabilityAssertions.kt | 26 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 +++++ .../IrBlackBoxCodegenTestGenerated.java | 6 +++++ .../LightAnalysisModeTestGenerated.java | 5 ++++ 6 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index f8ae7fa6650..ca07a2ff6b5 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -19939,6 +19939,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @Test + @TestMetadata("nullabilityAssertions.kt") + public void testNullabilityAssertions() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt"); + } + @Test @TestMetadata("possibleOverrideClash.kt") public void testPossibleOverrideClash() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 8137dd38511..55a879d4acd 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -275,7 +275,7 @@ class ExpressionCodegen( return if (inlinedInto != null || - (DescriptorVisibilities.isPrivate(irFunction.visibility) && !(irFunction is IrSimpleFunction && irFunction.isOperator)) || + (DescriptorVisibilities.isPrivate(irFunction.visibility) && !shouldGenerateNonNullAssertionsForPrivateFun(irFunction)) || irFunction.origin.isSynthetic || // TODO: refine this condition to not generate nullability assertions on parameters // corresponding to captured variables and anonymous object super constructor arguments @@ -310,6 +310,13 @@ class ExpressionCodegen( } } + // * Operator functions require non-null assertions on parameters even if they are private. + // * Local function for lambda survives at this stage if it was used in 'invokedynamic'-based code. + // Such functions require non-null assertions on parameters. + private fun shouldGenerateNonNullAssertionsForPrivateFun(irFunction: IrFunction) = + irFunction is IrSimpleFunction && irFunction.isOperator || + irFunction.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA + private fun generateNonNullAssertion(param: IrValueParameter) { val asmType = param.type.asmType if (!param.type.unboxInlineClass().isNullable() && !isPrimitive(asmType)) { diff --git a/compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt b/compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt new file mode 100644 index 00000000000..b2f0ad4784f --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt @@ -0,0 +1,26 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: nullabilityAssertions.kt +fun box(): String { + fun justSomeLocalFun() {} + + try { + A.bar {} + } catch (e: NullPointerException) { + return "OK" + } + + return "Should throw NullPointerException" +} + +// FILE: A.java +import org.jetbrains.annotations.NotNull; + +public interface A { + void foo(@NotNull String s); + + static void bar(A a) { + a.foo(null); + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 87ab19a4bd0..34067e8e477 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -19939,6 +19939,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @Test + @TestMetadata("nullabilityAssertions.kt") + public void testNullabilityAssertions() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt"); + } + @Test @TestMetadata("possibleOverrideClash.kt") public void testPossibleOverrideClash() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 621b350cdf9..05ecd8000c8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -19939,6 +19939,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @Test + @TestMetadata("nullabilityAssertions.kt") + public void testNullabilityAssertions() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt"); + } + @Test @TestMetadata("possibleOverrideClash.kt") public void testPossibleOverrideClash() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 4e50a92496b..e5101b1bdb2 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -16718,6 +16718,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @TestMetadata("nullabilityAssertions.kt") + public void testNullabilityAssertions() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt"); + } + @TestMetadata("possibleOverrideClash.kt") public void testPossibleOverrideClash() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/possibleOverrideClash.kt"); From 4ab242ed51a6bb7d7b8bccb28f7c93987a681fcf Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 10 Feb 2021 10:16:21 +0300 Subject: [PATCH 076/368] JVM_IR indy: minor: use toLowerCaseAsciiOnly for options KT-44278 KT-26060 KT-42621 --- .../org/jetbrains/kotlin/config/JvmClosureGenerationScheme.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/config.jvm/src/org/jetbrains/kotlin/config/JvmClosureGenerationScheme.kt b/compiler/config.jvm/src/org/jetbrains/kotlin/config/JvmClosureGenerationScheme.kt index a03ab246059..2bc87eea62a 100644 --- a/compiler/config.jvm/src/org/jetbrains/kotlin/config/JvmClosureGenerationScheme.kt +++ b/compiler/config.jvm/src/org/jetbrains/kotlin/config/JvmClosureGenerationScheme.kt @@ -5,6 +5,8 @@ package org.jetbrains.kotlin.config +import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly + enum class JvmClosureGenerationScheme( val description: String, val minJvmTarget: JvmTarget @@ -18,7 +20,7 @@ enum class JvmClosureGenerationScheme( @JvmStatic fun fromString(string: String?): JvmClosureGenerationScheme? { - val lowerStr = string?.toLowerCase() ?: return null + val lowerStr = string?.toLowerCaseAsciiOnly() ?: return null return values().find { it.description == lowerStr } } } From 5013344bc4e8f72b1aa3b34afa7809b9eabdd1c5 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 10 Feb 2021 15:25:47 +0300 Subject: [PATCH 077/368] JVM_IR nullability assertions test for indy lambdas KT-44278 KT-26060 KT-42621 --- .../FirBlackBoxCodegenTestGenerated.java | 6 +++++ .../lambdas/nullabilityAssertions.kt | 24 +++++++++++++++++++ .../sam/nullabilityAssertions.kt | 2 -- .../codegen/BlackBoxCodegenTestGenerated.java | 6 +++++ .../IrBlackBoxCodegenTestGenerated.java | 6 +++++ .../LightAnalysisModeTestGenerated.java | 5 ++++ 6 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/codegen/box/invokedynamic/lambdas/nullabilityAssertions.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index ca07a2ff6b5..b510296efee 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -19787,6 +19787,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/lambdas/nestedIndyLambdas.kt"); } + @Test + @TestMetadata("nullabilityAssertions.kt") + public void testNullabilityAssertions() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/lambdas/nullabilityAssertions.kt"); + } + @Test @TestMetadata("primitiveValueParameters.kt") public void testPrimitiveValueParameters() throws Exception { diff --git a/compiler/testData/codegen/box/invokedynamic/lambdas/nullabilityAssertions.kt b/compiler/testData/codegen/box/invokedynamic/lambdas/nullabilityAssertions.kt new file mode 100644 index 00000000000..aa4b937e701 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/lambdas/nullabilityAssertions.kt @@ -0,0 +1,24 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// LAMBDAS: INDY +// WITH_RUNTIME +// FILE: nullabilityAssertions.kt +fun box(): String { + val fn: (String) -> String = { it } + try { + J.test(fn) + } catch (e: NullPointerException) { + return "OK" + } + + return "Should throw NullPointerException" +} + +// FILE: J.java +import kotlin.jvm.functions.Function1; + +public class J { + public static void test(Function1 fn) { + fn.invoke(null); + } +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt b/compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt index b2f0ad4784f..9effb947012 100644 --- a/compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt +++ b/compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt @@ -3,8 +3,6 @@ // SAM_CONVERSIONS: INDY // FILE: nullabilityAssertions.kt fun box(): String { - fun justSomeLocalFun() {} - try { A.bar {} } catch (e: NullPointerException) { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 34067e8e477..eb2e084e999 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -19787,6 +19787,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/lambdas/nestedIndyLambdas.kt"); } + @Test + @TestMetadata("nullabilityAssertions.kt") + public void testNullabilityAssertions() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/lambdas/nullabilityAssertions.kt"); + } + @Test @TestMetadata("primitiveValueParameters.kt") public void testPrimitiveValueParameters() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 05ecd8000c8..36794d3d304 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -19787,6 +19787,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/lambdas/nestedIndyLambdas.kt"); } + @Test + @TestMetadata("nullabilityAssertions.kt") + public void testNullabilityAssertions() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/lambdas/nullabilityAssertions.kt"); + } + @Test @TestMetadata("primitiveValueParameters.kt") public void testPrimitiveValueParameters() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index e5101b1bdb2..a56ad4d5818 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -16577,6 +16577,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/lambdas/nestedIndyLambdas.kt"); } + @TestMetadata("nullabilityAssertions.kt") + public void testNullabilityAssertions() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/lambdas/nullabilityAssertions.kt"); + } + @TestMetadata("primitiveValueParameters.kt") public void testPrimitiveValueParameters() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/lambdas/primitiveValueParameters.kt"); From 6ba57abb8f4ffd993fe67e544e7a212a8345efa5 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 12 Feb 2021 14:35:24 +0300 Subject: [PATCH 078/368] JVM don't use indy by default for SAM conversions (wait for KT-44844) KT-44278 KT-26060 KT-42621 --- .../jetbrains/kotlin/codegen/state/GenerationState.kt | 9 ++++++--- .../samAdapterForJavaInterfaceWithNullability.kt | 2 +- .../samAdapterForJavaInterfaceWithNullability_ir.txt | 10 ---------- .../sam/samWrapperForNullInitialization.kt | 1 + .../sam/samWrapperForNullableInitialization.kt | 1 + .../codegen/bytecodeText/sam/samWrapperOfLambda.kt | 1 + 6 files changed, 10 insertions(+), 14 deletions(-) delete mode 100644 compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability_ir.txt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt index 04057ffd8f4..5a18ad4958e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt @@ -211,10 +211,13 @@ class GenerationState private constructor( val fromConfig = configuration.get(JVMConfigurationKeys.SAM_CONVERSIONS) if (fromConfig != null && target >= fromConfig.minJvmTarget) fromConfig - else if (target >= JvmTarget.JVM_1_8 && languageVersionSettings.supportsFeature(LanguageFeature.SamWrapperClassesAreSynthetic)) - JvmClosureGenerationScheme.INDY - else + else { + // TODO wait for KT-44844 (properly support 'invokedynamic' in JPS incremental compilation) + // Use JvmClosureGenerationScheme.INDY if + // JVM target is at least JVM_1_8 && + // SamWrapperClassesAreSynthetic language feature is supported JvmClosureGenerationScheme.CLASS + } } val lambdasScheme = run { diff --git a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.kt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.kt index 20802d611b7..43eac75c085 100644 --- a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.kt +++ b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability.kt @@ -1,4 +1,4 @@ -// SAM_CONVERSIONS: CLASS +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=CLASS // FILE: samAdapterForJavaInterfaceWithNullability.kt fun testNullable(s: String) = JNullable { s } fun testNotNull(s: String) = JNotNull { s } diff --git a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability_ir.txt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability_ir.txt deleted file mode 100644 index 6fedbee2322..00000000000 --- a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/samAdapterForJavaInterfaceWithNullability_ir.txt +++ /dev/null @@ -1,10 +0,0 @@ -@kotlin.Metadata -public final class SamAdapterForJavaInterfaceWithNullabilityKt { - // source: 'samAdapterForJavaInterfaceWithNullability.kt' - private final static method testNoAnnotation$lambda-2(p0: java.lang.String): java.lang.String - public final static @org.jetbrains.annotations.NotNull method testNoAnnotation(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNoAnnotation - private final static method testNotNull$lambda-1(p0: java.lang.String): java.lang.String - public final static @org.jetbrains.annotations.NotNull method testNotNull(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNotNull - private final static method testNullable$lambda-0(p0: java.lang.String): java.lang.String - public final static @org.jetbrains.annotations.NotNull method testNullable(@org.jetbrains.annotations.NotNull p0: java.lang.String): JNullable -} diff --git a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt index e15c32784e8..f4ef23b565f 100644 --- a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt +++ b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=INDY // FILE: JFoo.java import org.jetbrains.annotations.Nullable; diff --git a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt index 719ef304308..54a2d031fd8 100644 --- a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt +++ b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=INDY // FILE: JFoo.java import org.jetbrains.annotations.Nullable; diff --git a/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt b/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt index b82b5f40424..af8e1471482 100644 --- a/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt +++ b/compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt @@ -1,3 +1,4 @@ +// KOTLIN_CONFIGURATION_FLAGS: SAM_CONVERSIONS=INDY // FILE: JFoo.java public class JFoo { From d42cc219bfd4a4216cc7d25f40d314afb7d8f93d Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Fri, 12 Feb 2021 12:50:02 +0100 Subject: [PATCH 079/368] FIR IDE: fix collecting diagnostics for raanalysable non-toplevel declarations --- .../level/api/file/structure/FileStructure.kt | 32 +++++++++++++------ .../modifiers/removeIncompatibleModifier.kt | 3 +- .../removeIncompatibleModifier.kt.after | 3 +- .../modifiers/removeRedundantModifier1.kt | 2 ++ .../removeRedundantModifier1.kt.after | 2 ++ .../modifiers/removeRedundantModifier2.kt | 2 ++ .../removeRedundantModifier2.kt.after | 2 ++ .../modifiers/removeRedundantModifier3.kt | 2 ++ .../removeRedundantModifier3.kt.after | 2 ++ 9 files changed, 39 insertions(+), 11 deletions(-) diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructure.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructure.kt index 7ba5a4978de..fdcf235546d 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructure.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructure.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.file.structure +import com.intellij.psi.PsiElement import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic import org.jetbrains.kotlin.fir.declarations.FirFile @@ -17,10 +18,8 @@ import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyDeclarati import org.jetbrains.kotlin.idea.fir.low.level.api.providers.firIdeProvider import org.jetbrains.kotlin.idea.fir.low.level.api.util.findSourceNonLocalFirDeclaration import org.jetbrains.kotlin.idea.util.getElementTextInContext -import org.jetbrains.kotlin.psi.KtAnnotated -import org.jetbrains.kotlin.psi.KtDeclaration -import org.jetbrains.kotlin.psi.KtElement -import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType import java.util.concurrent.ConcurrentHashMap @@ -58,16 +57,31 @@ internal class FileStructure( @OptIn(ExperimentalStdlibApi::class) fun getAllDiagnosticsForFile(): Collection> { - val containersForStructureElement = buildList { - add(ktFile) - addAll(ktFile.declarations) - } - val structureElements = containersForStructureElement.map(::getStructureElementFor) + val structureElements = getAllStructureElements() return buildSet { structureElements.forEach { it.diagnostics.forEach { diagnostics -> addAll(diagnostics) } } } } + private fun getAllStructureElements(): Collection { + val structureElements = mutableSetOf(getStructureElementFor(ktFile)) + ktFile.accept(object : KtVisitorVoid() { + override fun visitElement(element: PsiElement) { + element.acceptChildren(this) + } + + override fun visitDeclaration(dcl: KtDeclaration) { + val structureElement = getStructureElementFor(dcl) + structureElements += structureElement + if (structureElement !is ReanalyzableStructureElement<*>) { + dcl.acceptChildren(this) + } + } + }) + + return structureElements + } + private fun createDeclarationStructure(declaration: KtDeclaration): FileStructureElement { val firDeclaration = declaration.findSourceNonLocalFirDeclaration( diff --git a/idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt b/idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt index 335c5cc6566..43d89342ac9 100644 --- a/idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt +++ b/idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt @@ -1,4 +1,5 @@ // "Remove 'public' modifier" "true" class Foo { public private fun bar() { } -} \ No newline at end of file +} +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt.after b/idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt.after index 3c58a6569a0..53d3d562378 100644 --- a/idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt.after +++ b/idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt.after @@ -1,4 +1,5 @@ // "Remove 'public' modifier" "true" class Foo { private fun bar() { } -} \ No newline at end of file +} +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/removeRedundantModifier1.kt b/idea/testData/quickfix/modifiers/removeRedundantModifier1.kt index acec3eb7ca5..7ba120a4a4f 100644 --- a/idea/testData/quickfix/modifiers/removeRedundantModifier1.kt +++ b/idea/testData/quickfix/modifiers/removeRedundantModifier1.kt @@ -6,3 +6,5 @@ abstract class B() { abstract class A() : B() { open abstract override fun foo() } + +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/removeRedundantModifier1.kt.after b/idea/testData/quickfix/modifiers/removeRedundantModifier1.kt.after index 38c63050707..0a9cd079d2d 100644 --- a/idea/testData/quickfix/modifiers/removeRedundantModifier1.kt.after +++ b/idea/testData/quickfix/modifiers/removeRedundantModifier1.kt.after @@ -6,3 +6,5 @@ abstract class B() { abstract class A() : B() { abstract override fun foo() } + +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/removeRedundantModifier2.kt b/idea/testData/quickfix/modifiers/removeRedundantModifier2.kt index 0e158cee4dc..2b1f305be5a 100644 --- a/idea/testData/quickfix/modifiers/removeRedundantModifier2.kt +++ b/idea/testData/quickfix/modifiers/removeRedundantModifier2.kt @@ -6,3 +6,5 @@ abstract class B() { abstract class A() : B() { abstract open override fun foo() } + +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/removeRedundantModifier2.kt.after b/idea/testData/quickfix/modifiers/removeRedundantModifier2.kt.after index 181b7b6aadc..d2793d1d8f0 100644 --- a/idea/testData/quickfix/modifiers/removeRedundantModifier2.kt.after +++ b/idea/testData/quickfix/modifiers/removeRedundantModifier2.kt.after @@ -6,3 +6,5 @@ abstract class B() { abstract class A() : B() { abstract override fun foo() } + +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/removeRedundantModifier3.kt b/idea/testData/quickfix/modifiers/removeRedundantModifier3.kt index 7db5121da51..015edbc3b51 100644 --- a/idea/testData/quickfix/modifiers/removeRedundantModifier3.kt +++ b/idea/testData/quickfix/modifiers/removeRedundantModifier3.kt @@ -6,3 +6,5 @@ abstract class B() { abstract class A() : B() { abstract override open fun foo() } + +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/modifiers/removeRedundantModifier3.kt.after b/idea/testData/quickfix/modifiers/removeRedundantModifier3.kt.after index 2f6b03af29c..ab85cc6330e 100644 --- a/idea/testData/quickfix/modifiers/removeRedundantModifier3.kt.after +++ b/idea/testData/quickfix/modifiers/removeRedundantModifier3.kt.after @@ -6,3 +6,5 @@ abstract class B() { abstract class A() : B() { abstract override fun foo() } + +/* FIR_COMPARISON */ \ No newline at end of file From 75f6780b908b5e5330051b5838960afb0791a432 Mon Sep 17 00:00:00 2001 From: Vyacheslav Karpukhin Date: Fri, 12 Feb 2021 15:59:45 +0100 Subject: [PATCH 080/368] AndroidDependencyResolver: Don't load android-related classes on class load --- .../android/internal/AndroidDependencyResolver.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt index 17ef94c467f..6d2f47df3a4 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/android/internal/AndroidDependencyResolver.kt @@ -145,8 +145,13 @@ object AndroidDependencyResolver { module: ModuleIdentifier, compileClasspathConf: Configuration ): List { + val processedJarArtifactType = try { + AndroidArtifacts.ArtifactType.valueOf("PROCESSED_JAR") + } catch (e: IllegalArgumentException) { + AndroidArtifacts.ArtifactType.JAR + } val viewConfig: (ArtifactView.ViewConfiguration) -> Unit = { config -> - config.attributes { it.attribute(AndroidArtifacts.ARTIFACT_TYPE, PROCESSED_JAR_ARTIFACT_TYPE.type) } + config.attributes { it.attribute(AndroidArtifacts.ARTIFACT_TYPE, processedJarArtifactType.type) } config.isLenient = true } @@ -189,11 +194,4 @@ object AndroidDependencyResolver { result.addAll(configs.flatMap { it.dependencies }) doFindDependencies(implConfigs, configs.flatMap { it.extendsFrom }.filter { it !in implConfigs && visited.add(it) }, result) } - - private val PROCESSED_JAR_ARTIFACT_TYPE: AndroidArtifacts.ArtifactType = - try { - AndroidArtifacts.ArtifactType.valueOf("PROCESSED_JAR") - } catch (e: IllegalArgumentException) { - AndroidArtifacts.ArtifactType.JAR - } } \ No newline at end of file From 6882cf820ec6bd8258ae83e93d7bbbdbeae4b5ff Mon Sep 17 00:00:00 2001 From: Tianyu Geng Date: Wed, 10 Feb 2021 14:29:43 -0800 Subject: [PATCH 081/368] FIR IDE: move RemoveModifierFix to ... idea-frontend-independent --- .../inspections/KotlinUniversalQuickFix.kt | 31 ------------------- .../KotlinBundleIndependent.properties | 7 ++++- .../inspections/KotlinUniversalQuickFix.kt | 20 ++++++++++++ .../KotlinCrossLanguageQuickFixAction.kt | 15 ++------- .../KotlinSingleIntentionActionFactory.kt | 15 ++------- .../kotlin/idea/quickfix/RemoveModifierFix.kt | 29 ++++++++++++++--- .../messages/KotlinBundle.properties | 1 - .../kotlin/idea/quickfix/AddModifierFix.kt | 23 ++------------ .../AddReifiedToTypeParameterOfFunctionFix.kt | 4 +-- .../kotlin/idea/util/quickfixUtil.kt | 1 - .../diagnosticBasedPostProcessing.kt | 1 - 11 files changed, 58 insertions(+), 89 deletions(-) delete mode 100644 idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/KotlinUniversalQuickFix.kt create mode 100644 idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/inspections/KotlinUniversalQuickFix.kt rename idea/{ => idea-frontend-independent}/src/org/jetbrains/kotlin/idea/quickfix/KotlinCrossLanguageQuickFixAction.kt (58%) rename idea/{ => idea-frontend-independent}/src/org/jetbrains/kotlin/idea/quickfix/KotlinSingleIntentionActionFactory.kt (68%) rename idea/{ => idea-frontend-independent}/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt (83%) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/KotlinUniversalQuickFix.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/KotlinUniversalQuickFix.kt deleted file mode 100644 index 9969201e98f..00000000000 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/inspections/KotlinUniversalQuickFix.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.idea.inspections - -import com.intellij.codeInsight.intention.IntentionAction -import com.intellij.codeInspection.LocalQuickFix -import com.intellij.codeInspection.ProblemDescriptor -import com.intellij.openapi.project.Project - -interface KotlinUniversalQuickFix : IntentionAction, LocalQuickFix { - @JvmDefault - override fun getName() = text - - override fun applyFix(project: Project, descriptor: ProblemDescriptor) { - invoke(project, null, descriptor.psiElement?.containingFile) - } -} \ No newline at end of file diff --git a/idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties b/idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties index 4e223ee9b58..57eb28b42d1 100644 --- a/idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties +++ b/idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties @@ -65,4 +65,9 @@ find.usages.type.packageMemberAccess=Package member access and.delete.initializer=\ and delete initializer change.to.val=Change to val -change.to.var=Change to var \ No newline at end of file +change.to.var=Change to var + +remove.redundant.0.modifier=Remove redundant ''{0}'' modifier +make.0.not.1=Make {0} not {1} +remove.0.modifier=Remove ''{0}'' modifier +remove.modifier=Remove modifier diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/inspections/KotlinUniversalQuickFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/inspections/KotlinUniversalQuickFix.kt new file mode 100644 index 00000000000..f825e6742b0 --- /dev/null +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/inspections/KotlinUniversalQuickFix.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2021 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.idea.inspections + +import com.intellij.codeInsight.intention.IntentionAction +import com.intellij.codeInspection.LocalQuickFix +import com.intellij.codeInspection.ProblemDescriptor +import com.intellij.openapi.project.Project + +interface KotlinUniversalQuickFix : IntentionAction, LocalQuickFix { + @JvmDefault + override fun getName() = text + + override fun applyFix(project: Project, descriptor: ProblemDescriptor) { + invoke(project, null, descriptor.psiElement?.containingFile) + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinCrossLanguageQuickFixAction.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/KotlinCrossLanguageQuickFixAction.kt similarity index 58% rename from idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinCrossLanguageQuickFixAction.kt rename to idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/KotlinCrossLanguageQuickFixAction.kt index 7e3f065422d..8adde90d147 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinCrossLanguageQuickFixAction.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/KotlinCrossLanguageQuickFixAction.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.idea.quickfix diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinSingleIntentionActionFactory.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/KotlinSingleIntentionActionFactory.kt similarity index 68% rename from idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinSingleIntentionActionFactory.kt rename to idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/KotlinSingleIntentionActionFactory.kt index 706baf8857c..a6b71395372 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/KotlinSingleIntentionActionFactory.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/KotlinSingleIntentionActionFactory.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.idea.quickfix diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt similarity index 83% rename from idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt rename to idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt index 20bae155702..da1ed5968b7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt @@ -9,8 +9,9 @@ import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile +import com.intellij.psi.PsiNameIdentifierOwner import com.intellij.psi.util.PsiTreeUtil -import org.jetbrains.kotlin.idea.KotlinBundle +import org.jetbrains.kotlin.idea.KotlinBundleIndependent import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* @@ -27,15 +28,15 @@ class RemoveModifierFix( val modifierText = modifier.value when { isRedundant -> - KotlinBundle.message("remove.redundant.0.modifier", modifierText) + KotlinBundleIndependent.message("remove.redundant.0.modifier", modifierText) modifier === KtTokens.ABSTRACT_KEYWORD || modifier === KtTokens.OPEN_KEYWORD -> - KotlinBundle.message("make.0.not.1", AddModifierFix.getElementName(element), modifierText) + KotlinBundleIndependent.message("make.0.not.1", getElementName(element), modifierText) else -> - KotlinBundle.message("remove.0.modifier", modifierText, modifier) + KotlinBundleIndependent.message("remove.0.modifier", modifierText, modifier) } } - override fun getFamilyName() = KotlinBundle.message("remove.modifier") + override fun getFamilyName() = KotlinBundleIndependent.message("remove.modifier") override fun getText() = text @@ -137,5 +138,23 @@ class RemoveModifierFix( listOf(RemoveModifierFix(funInterface, KtTokens.FUN_KEYWORD, isRedundant = false)) } } + + fun getElementName(modifierListOwner: KtModifierListOwner): String { + var name: String? = null + if (modifierListOwner is PsiNameIdentifierOwner) { + val nameIdentifier = modifierListOwner.nameIdentifier + if (nameIdentifier != null) { + name = nameIdentifier.text + } else if ((modifierListOwner as? KtObjectDeclaration)?.isCompanion() == true) { + name = "companion object" + } + } else if (modifierListOwner is KtPropertyAccessor) { + name = modifierListOwner.namePlaceholder.text + } + if (name == null) { + name = modifierListOwner.text + } + return "'$name'" + } } } diff --git a/idea/resources-en/messages/KotlinBundle.properties b/idea/resources-en/messages/KotlinBundle.properties index 1228cc0f613..5e6248339db 100644 --- a/idea/resources-en/messages/KotlinBundle.properties +++ b/idea/resources-en/messages/KotlinBundle.properties @@ -1104,7 +1104,6 @@ remove.from.annotation.argument=Remove @ from annotation argument remove.default.parameter.value=Remove default parameter value remove.final.upper.bound=Remove final upper bound remove.function.body=Remove function body -remove.redundant.0.modifier=Remove redundant ''{0}'' modifier make.0.not.1=Make {0} not {1} remove.0.modifier=Remove ''{0}'' modifier remove.modifier=Remove modifier diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt index 13f9422221e..b1eb3e62438 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt @@ -20,7 +20,6 @@ import com.intellij.codeInsight.intention.IntentionAction import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.PsiFile -import com.intellij.psi.PsiNameIdentifierOwner import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor @@ -43,14 +42,14 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.TypeUtils - open class AddModifierFix( +open class AddModifierFix( element: KtModifierListOwner, protected val modifier: KtModifierKeywordToken ) : KotlinCrossLanguageQuickFixAction(element), KotlinUniversalQuickFix { override fun getText(): String { val element = element ?: return "" if (modifier in modalityModifiers || modifier in VISIBILITY_MODIFIERS || modifier == CONST_KEYWORD) { - return KotlinBundle.message("fix.add.modifier.text", getElementName(element), modifier.value) + return KotlinBundle.message("fix.add.modifier.text", RemoveModifierFix.getElementName(element), modifier.value) } return KotlinBundle.message("fix.add.modifier.text.generic", modifier.value) } @@ -90,24 +89,6 @@ import org.jetbrains.kotlin.types.TypeUtils private val modalityModifiers = setOf(ABSTRACT_KEYWORD, OPEN_KEYWORD, FINAL_KEYWORD) - fun getElementName(modifierListOwner: KtModifierListOwner): String { - var name: String? = null - if (modifierListOwner is PsiNameIdentifierOwner) { - val nameIdentifier = modifierListOwner.nameIdentifier - if (nameIdentifier != null) { - name = nameIdentifier.text - } else if ((modifierListOwner as? KtObjectDeclaration)?.isCompanion() == true) { - name = "companion object" - } - } else if (modifierListOwner is KtPropertyAccessor) { - name = modifierListOwner.namePlaceholder.text - } - if (name == null) { - name = modifierListOwner.text - } - return "'$name'" - } - fun createFactory(modifier: KtModifierKeywordToken): KotlinSingleIntentionActionFactory { return createFactory(modifier, KtModifierListOwner::class.java) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddReifiedToTypeParameterOfFunctionFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddReifiedToTypeParameterOfFunctionFix.kt index e422a7e52a6..1e5efc6160d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddReifiedToTypeParameterOfFunctionFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddReifiedToTypeParameterOfFunctionFix.kt @@ -50,10 +50,10 @@ class AddReifiedToTypeParameterOfFunctionFix( ) : AddModifierFix(typeParameter, KtTokens.REIFIED_KEYWORD) { private val inlineFix = AddInlineToFunctionWithReifiedFix(function) - private val elementName = getElementName(function) + private val elementName = RemoveModifierFix.getElementName(function) override fun getText() = - element?.let { KotlinBundle.message("fix.make.type.parameter.reified", getElementName(it), elementName) } ?: "" + element?.let { KotlinBundle.message("fix.make.type.parameter.reified", RemoveModifierFix.getElementName(it), elementName) } ?: "" override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) { super.invokeImpl(project, editor, file) diff --git a/idea/src/org/jetbrains/kotlin/idea/util/quickfixUtil.kt b/idea/src/org/jetbrains/kotlin/idea/util/quickfixUtil.kt index 1a657ab6f02..03e0d0d7c95 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/quickfixUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/util/quickfixUtil.kt @@ -24,7 +24,6 @@ import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.project.languageVersionSettings import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory -import org.jetbrains.kotlin.idea.resolve.frontendService import org.jetbrains.kotlin.idea.resolve.getDataFlowValueFactory import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtPrimaryConstructor diff --git a/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/diagnosticBasedPostProcessing.kt b/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/diagnosticBasedPostProcessing.kt index 3d80bb185fd..6b532712d0d 100644 --- a/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/diagnosticBasedPostProcessing.kt +++ b/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/diagnosticBasedPostProcessing.kt @@ -13,7 +13,6 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.DiagnosticFactory import org.jetbrains.kotlin.idea.core.util.range import org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix -import org.jetbrains.kotlin.idea.quickfix.KotlinIntentionActionsFactory import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory import org.jetbrains.kotlin.idea.quickfix.QuickFixFactory import org.jetbrains.kotlin.idea.resolve.ResolutionFacade From bf9fa4c9da551133c5dd17c83d03f11ad9ce0fc5 Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Sat, 13 Feb 2021 21:25:46 +0100 Subject: [PATCH 082/368] Lightweight hashCode calc for LibraryInfo #EA-6040509 Fixed --- .../jetbrains/kotlin/idea/caches/project/IdeaModuleInfos.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/IdeaModuleInfos.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/IdeaModuleInfos.kt index 7ca053f60b5..09001b9c426 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/IdeaModuleInfos.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/IdeaModuleInfos.kt @@ -401,7 +401,11 @@ abstract class LibraryInfo(override val project: Project, val library: Library) return (other is LibraryInfo && library == other.library) } - override fun hashCode(): Int = 43 * library.hashCode() + private val lazyHashCode: Int by lazy { + 43 * library.hashCode() + } + + override fun hashCode(): Int = lazyHashCode } data class LibrarySourceInfo(override val project: Project, val library: Library, override val binariesModuleInfo: BinaryModuleInfo) : From 4a0437a50713fa5c50740e1c8301b6e9c7c31639 Mon Sep 17 00:00:00 2001 From: Andrey Zinovyev Date: Sun, 14 Feb 2021 10:38:38 +0300 Subject: [PATCH 083/368] [KAPT] Fix field type correction for delegates (#4107) #KT-37586 Fixes --- .../stubs/ClassFileToSourceStubConverter.kt | 20 ++++++++-- ...ileToSourceStubConverterTestGenerated.java | 5 +++ ...ileToSourceStubConverterTestGenerated.java | 5 +++ .../converter/delegateCorrectErrorTypes.kt | 13 +++++++ .../converter/delegateCorrectErrorTypes.txt | 38 +++++++++++++++++++ 5 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt create mode 100644 plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.txt diff --git a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt index 28d4c3a64c6..f3ac8071c8e 100644 --- a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt +++ b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt @@ -56,6 +56,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DelegatingBindingTrace import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall +import org.jetbrains.kotlin.resolve.calls.callUtil.getType import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument import org.jetbrains.kotlin.resolve.constants.* @@ -704,20 +705,31 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati return null } + fun typeFromAsm() = signatureParser.parseFieldSignature(field.signature, treeMaker.Type(type)) + // Enum type must be an identifier (Javac requirement) - val typeExpression = if (isEnum(field.access)) + val typeExpression = if (isEnum(field.access)) { treeMaker.SimpleName(treeMaker.getQualifiedName(type).substringAfterLast('.')) - else + } else if (descriptor is PropertyDescriptor && descriptor.isDelegated) { getNonErrorType( - (descriptor as? CallableDescriptor)?.returnType, RETURN_TYPE, + (origin.element as? KtProperty)?.delegateExpression?.getType(kaptContext.bindingContext), + RETURN_TYPE, + ktTypeProvider = { null }, + ifNonError = ::typeFromAsm + ) + } else { + getNonErrorType( + (descriptor as? CallableDescriptor)?.returnType, + RETURN_TYPE, ktTypeProvider = { val fieldOrigin = (kaptContext.origins[field]?.element as? KtCallableDeclaration) ?.takeIf { it !is KtFunction } fieldOrigin?.typeReference }, - ifNonError = { signatureParser.parseFieldSignature(field.signature, treeMaker.Type(type)) } + ifNonError = ::typeFromAsm ) + } lineMappings.registerField(containingClass, field) diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java index da291216b2b..e866010a85d 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java @@ -119,6 +119,11 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt"); } + @TestMetadata("delegateCorrectErrorTypes.kt") + public void testDelegateCorrectErrorTypes() throws Exception { + runTest("plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt"); + } + @TestMetadata("deprecated.kt") public void testDeprecated() throws Exception { runTest("plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt"); diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrClassFileToSourceStubConverterTestGenerated.java b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrClassFileToSourceStubConverterTestGenerated.java index 1273f9ded3e..e4b1d2135b6 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrClassFileToSourceStubConverterTestGenerated.java +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrClassFileToSourceStubConverterTestGenerated.java @@ -120,6 +120,11 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt"); } + @TestMetadata("delegateCorrectErrorTypes.kt") + public void testDelegateCorrectErrorTypes() throws Exception { + runTest("plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt"); + } + @TestMetadata("deprecated.kt") public void testDeprecated() throws Exception { runTest("plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt"); diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt b/plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt new file mode 100644 index 00000000000..bd6bd55143d --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.kt @@ -0,0 +1,13 @@ +// CORRECT_ERROR_TYPES + +@file:Suppress("UNRESOLVED_REFERENCE") + +package test + +class Delegate { + operator fun getValue(thisRef: Any, property: KProperty<*>): Any {return Any()} +} + +class Bar(delegate: Delegate) { + private val unknown: Unknown by delegate +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.txt b/plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.txt new file mode 100644 index 00000000000..f9a898802ce --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/testData/converter/delegateCorrectErrorTypes.txt @@ -0,0 +1,38 @@ +package test; + +import java.lang.System; + +@kotlin.Metadata() +public final class Bar { + private final test.Delegate unknown$delegate = null; + + public Bar(@org.jetbrains.annotations.NotNull() + test.Delegate delegate) { + super(); + } + + private final Unknown getUnknown() { + return null; + } +} + +//////////////////// + +package test; + +import java.lang.System; + +@kotlin.Metadata() +public final class Delegate { + + public Delegate() { + super(); + } + + @org.jetbrains.annotations.NotNull() + public final java.lang.Object getValue(@org.jetbrains.annotations.NotNull() + java.lang.Object thisRef, @org.jetbrains.annotations.NotNull() + KProperty property) { + return null; + } +} From cc51869a2abb590b7c830cece7a6bec94901fdfa Mon Sep 17 00:00:00 2001 From: Andrey Zinovyev Date: Sun, 14 Feb 2021 10:45:00 +0300 Subject: [PATCH 084/368] [KAPT] Take function argument names from original descriptor #KT-43804 Fixed --- .../stubs/ClassFileToSourceStubConverter.kt | 2 +- .../kotlin/kapt3/stubs/parseParameters.kt | 11 ++++-- ...ileToSourceStubConverterTestGenerated.java | 5 +++ ...ileToSourceStubConverterTestGenerated.java | 5 +++ .../testData/converter/dataClass.txt | 2 +- .../testData/converter/errorSuperclass.txt | 4 +-- .../errorSuperclassCorrectErrorTypes.txt | 12 +++---- .../testData/converter/inlineClasses.txt | 2 +- .../testData/converter/suspendArgName.kt | 18 ++++++++++ .../testData/converter/suspendArgName.txt | 35 +++++++++++++++++++ .../testData/converter/suspendErrorTypes.txt | 2 +- 11 files changed, 83 insertions(+), 15 deletions(-) create mode 100644 plugins/kapt3/kapt3-compiler/testData/converter/suspendArgName.kt create mode 100644 plugins/kapt3/kapt3-compiler/testData/converter/suspendArgName.txt diff --git a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt index f3ac8071c8e..3d363c91f3f 100644 --- a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt +++ b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt @@ -913,7 +913,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati val asmReturnType = Type.getReturnType(method.desc) val jcReturnType = if (isConstructor) null else treeMaker.Type(asmReturnType) - val parametersInfo = method.getParametersInfo(containingClass, isInner) + val parametersInfo = method.getParametersInfo(containingClass, isInner, descriptor) if (!checkIfValidTypeName(containingClass, asmReturnType) || parametersInfo.any { !checkIfValidTypeName(containingClass, it.type) } diff --git a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/parseParameters.kt b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/parseParameters.kt index 840a3a2e69a..41962be534e 100644 --- a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/parseParameters.kt +++ b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/parseParameters.kt @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.kapt3.stubs -import org.jetbrains.kotlin.codegen.AsmUtil +import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.kapt3.util.isAbstract import org.jetbrains.kotlin.kapt3.util.isEnum import org.jetbrains.kotlin.kapt3.util.isJvmOverloadsGenerated @@ -35,7 +35,11 @@ internal class ParameterInfo( val invisibleAnnotations: List? ) -internal fun MethodNode.getParametersInfo(containingClass: ClassNode, isInnerClassMember: Boolean): List { +internal fun MethodNode.getParametersInfo( + containingClass: ClassNode, + isInnerClassMember: Boolean, + originalDescriptor: CallableDescriptor +): List { val localVariables = this.localVariables ?: emptyList() val parameters = this.parameters ?: emptyList() val isStatic = isStatic(access) @@ -67,6 +71,7 @@ internal fun MethodNode.getParametersInfo(containingClass: ClassNode, isInnerCla // @JvmOverloads constructors and ordinary methods don't have "this" local variable name = name ?: localVariables.getOrNull(index + localVariableIndexOffset)?.name + ?: originalDescriptor.valueParameters.getOrNull(index)?.name?.identifier ?: "p${index - startParameterIndex}" // Property setters has bad parameter names @@ -80,4 +85,4 @@ internal fun MethodNode.getParametersInfo(containingClass: ClassNode, isInnerCla parameterInfos += ParameterInfo(0, name, type, visibleAnnotations, invisibleAnnotations) } return parameterInfos -} \ No newline at end of file +} diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java index e866010a85d..94d7b674154 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/ClassFileToSourceStubConverterTestGenerated.java @@ -474,6 +474,11 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi runTest("plugins/kapt3/kapt3-compiler/testData/converter/stripMetadata.kt"); } + @TestMetadata("suspendArgName.kt") + public void testSuspendArgName() throws Exception { + runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendArgName.kt"); + } + @TestMetadata("suspendErrorTypes.kt") public void testSuspendErrorTypes() throws Exception { runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.kt"); diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrClassFileToSourceStubConverterTestGenerated.java b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrClassFileToSourceStubConverterTestGenerated.java index e4b1d2135b6..9a7313aae9c 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrClassFileToSourceStubConverterTestGenerated.java +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/IrClassFileToSourceStubConverterTestGenerated.java @@ -475,6 +475,11 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla runTest("plugins/kapt3/kapt3-compiler/testData/converter/stripMetadata.kt"); } + @TestMetadata("suspendArgName.kt") + public void testSuspendArgName() throws Exception { + runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendArgName.kt"); + } + @TestMetadata("suspendErrorTypes.kt") public void testSuspendErrorTypes() throws Exception { runTest("plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.kt"); diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/dataClass.txt b/plugins/kapt3/kapt3-compiler/testData/converter/dataClass.txt index aef55aa0aa2..d5412d0b73d 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/dataClass.txt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/dataClass.txt @@ -17,7 +17,7 @@ public final class User { @java.lang.Override() public boolean equals(@org.jetbrains.annotations.Nullable() - java.lang.Object p0) { + java.lang.Object other) { return false; } diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.txt b/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.txt index 91968329e1b..e16b6a1b497 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.txt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclass.txt @@ -23,11 +23,11 @@ public final class ClassWithParent implements java.lang.CharSequence { } @java.lang.Override() - public final char charAt(int p0) { + public final char charAt(int index) { return '\u0000'; } - public abstract char get(int p0); + public abstract char get(int index); public abstract int getLength(); diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclassCorrectErrorTypes.txt b/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclassCorrectErrorTypes.txt index b75ff4d79f0..38a0b457230 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclassCorrectErrorTypes.txt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/errorSuperclassCorrectErrorTypes.txt @@ -10,32 +10,32 @@ public final class Child extends kotlin.collections.AbstractList continuation) { + return null; + } + + @org.jetbrains.annotations.NotNull() + public java.lang.String getTestNoSuspendInvalid(@org.jetbrains.annotations.NotNull() + java.lang.String p0_55085957) { + return null; + } + + @org.jetbrains.annotations.Nullable() + public java.lang.Object getTestInvalid(@org.jetbrains.annotations.NotNull() + java.lang.String p0_55085957, @org.jetbrains.annotations.NotNull() + kotlin.coroutines.Continuation continuation) { + return null; + } +} diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.txt b/plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.txt index 7a89cb4c587..9e928f7c0ea 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.txt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/suspendErrorTypes.txt @@ -9,7 +9,7 @@ public final class Foo { @org.jetbrains.annotations.Nullable() public final java.lang.Object a(@org.jetbrains.annotations.NotNull() - kotlin.coroutines.Continuation p0) { + kotlin.coroutines.Continuation continuation) { return null; } } From 19e59fe77071c23b4069fd0b0febb31236993723 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Thu, 15 Oct 2020 20:29:42 +0300 Subject: [PATCH 085/368] [Gradle, JS] Experimenting with making everything transient in npm --- .../targets/js/nodejs/NodeJsRootPlugin.kt | 6 +++- .../KotlinCompilationNpmResolution.kt | 2 ++ .../resolver/KotlinCompilationNpmResolver.kt | 35 +++++++++++++++++-- .../npm/resolver/KotlinProjectNpmResolver.kt | 1 - .../js/npm/resolver/KotlinRootNpmResolver.kt | 9 +++-- .../js/npm/tasks/KotlinPackageJsonTask.kt | 5 ++- 6 files changed, 47 insertions(+), 11 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt index a15250d244d..dd7f34baa09 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt @@ -7,9 +7,11 @@ package org.jetbrains.kotlin.gradle.targets.js.nodejs import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.Task import org.gradle.api.plugins.BasePlugin import org.jetbrains.kotlin.gradle.targets.js.MultiplePluginDeclarationDetector import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension.Companion.EXTENSION_NAME +import org.jetbrains.kotlin.gradle.targets.js.npm.resolver.PACKAGE_JSON_UMBRELLA_TASK_NAME import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin import org.jetbrains.kotlin.gradle.tasks.CleanDataTask @@ -34,7 +36,7 @@ open class NodeJsRootPlugin : Plugin { val rootClean = project.rootProject.tasks.named(BasePlugin.CLEAN_TASK_NAME) - tasks.register(KotlinNpmInstallTask.NAME, KotlinNpmInstallTask::class.java) { + registerTask(KotlinNpmInstallTask.NAME) { it.dependsOn(setupTask) it.group = TASKS_GROUP_NAME it.description = "Find, download and link NPM dependencies and projects" @@ -42,6 +44,8 @@ open class NodeJsRootPlugin : Plugin { it.mustRunAfter(rootClean) } + registerTask(PACKAGE_JSON_UMBRELLA_TASK_NAME) + YarnPlugin.apply(project) tasks.register("node" + CleanDataTask.NAME_SUFFIX, CleanDataTask::class.java) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt index 2bc6ed4557a..ecc968cd7c4 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt @@ -15,7 +15,9 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.PackageJson * Resolved [NpmProject] */ class KotlinCompilationNpmResolution( + @Transient val project: Project, + @Transient val npmProject: NpmProject, val internalDependencies: Collection, val internalCompositeDependencies: Collection, diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt index 6bde98e8725..8c56410ae00 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt @@ -43,16 +43,27 @@ import java.io.Serializable * See [KotlinNpmResolutionManager] for details about resolution process. */ internal class KotlinCompilationNpmResolver( + @Transient val projectResolver: KotlinProjectNpmResolver, + @Transient val compilation: KotlinJsCompilation ) { + @Transient val resolver = projectResolver.resolver + + @Transient val npmProject = compilation.npmProject + val nodeJs get() = resolver.nodeJs + val target get() = compilation.target + val project get() = target.project + + @Transient val packageJsonTaskHolder = KotlinPackageJsonTask.create(compilation) + @Transient val publicPackageJsonTaskHolder: TaskProvider = project.registerTask( npmProject.publicPackageJsonTaskName, @@ -71,6 +82,7 @@ internal class KotlinCompilationNpmResolver( } } + @Transient val plugins: List = projectResolver.resolver.plugins .flatMap { if (compilation.isMain()) { @@ -168,6 +180,12 @@ internal class KotlinCompilationNpmResolver( val artifact: ResolvedArtifact ) + data class FileExternalGradleDependency( + val dependencyName: String, + val dependencyVersion: String, + val file: File + ) + data class CompositeDependency( val dependency: ResolvedDependency, val includedBuild: IncludedBuild @@ -317,15 +335,26 @@ internal class KotlinCompilationNpmResolver( inner class PackageJsonProducer( val internalDependencies: Collection, val internalCompositeDependencies: Collection, + @Transient val externalGradleDependencies: Collection, val externalNpmDependencies: Collection, val fileCollectionDependencies: Collection ) { + val fileExternalGradleDependencies by lazy { + externalGradleDependencies.map { + FileExternalGradleDependency( + it.dependency.moduleName, + it.dependency.moduleVersion, + it.artifact.file + ) + } + } + val inputs: PackageJsonProducerInputs get() = PackageJsonProducerInputs( internalDependencies.map { it.npmProject.name }, internalCompositeDependencies.flatMap { it.getPackages() }, - externalGradleDependencies.map { it.artifact.file }, + fileExternalGradleDependencies.map { it.file }, externalNpmDependencies.map { it.uniqueRepresentation() }, fileCollectionDependencies.map { it.files }.flatMap { it.files } ) @@ -335,8 +364,8 @@ internal class KotlinCompilationNpmResolver( it.getResolutionOrResolveIfForced() ?: error("Unresolved dependent npm package: ${this@KotlinCompilationNpmResolver} -> $it") } - val importedExternalGradleDependencies = externalGradleDependencies.mapNotNull { - resolver.gradleNodeModules.get(it.dependency.moduleName, it.dependency.moduleVersion, it.artifact.file) + val importedExternalGradleDependencies = fileExternalGradleDependencies.mapNotNull { + resolver.gradleNodeModules.get(it.dependencyName, it.dependencyVersion, it.file) } + fileCollectionDependencies.flatMap { dependency -> dependency.files // Gradle can hash with FileHasher only files and only existed files diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt index 699f363a05d..20dfe39366f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt @@ -45,7 +45,6 @@ internal class KotlinProjectNpmResolver( init { addContainerListeners() - project.whenEvaluated { val nodeJs = resolver.nodeJs project.tasks.implementing(RequiresNpmDependencies::class) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt index b60ab8edefc..7caf2838bea 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt @@ -49,25 +49,24 @@ internal class KotlinRootNpmResolver internal constructor( val gradleNodeModules = GradleNodeModulesCache(nodeJs) val compositeNodeModules = CompositeNodeModulesCache(nodeJs) - val packageJsonUmbrella = rootProject.registerTask(PACKAGE_JSON_UMBRELLA_TASK_NAME, Task::class.java) {} - val projectResolvers = mutableMapOf() + val projectResolvers = mutableMapOf() fun alreadyResolvedMessage(action: String) = "Cannot $action. NodeJS projects already resolved." @Synchronized fun addProject(target: Project) { check(state == State.CONFIGURING) { alreadyResolvedMessage("add new project: $target") } - projectResolvers[target] = KotlinProjectNpmResolver(target, this) + projectResolvers[target.path] = KotlinProjectNpmResolver(target, this) } - operator fun get(project: Project) = projectResolvers[project] ?: error("$project is not configured for JS usage") + operator fun get(projectPath: String) = projectResolvers[projectPath] ?: error("$projectPath is not configured for JS usage") val compilations: Collection get() = projectResolvers.values.flatMap { it.compilationResolvers.map { it.compilation } } fun findDependentResolver(src: Project, target: Project): List? { // todo: proper finding using KotlinTargetComponent.findUsageContext - val targetResolver = this[target] + val targetResolver = this[target.path] val mainCompilations = targetResolver.compilationResolvers.filter { it.compilation.isMain() } return if (mainCompilations.isNotEmpty()) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt index 4a029745fc5..606d69337c1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt @@ -33,8 +33,11 @@ open class KotlinPackageJsonTask : DefaultTask() { @Transient private lateinit var compilation: KotlinJsCompilation + @Input + val projectPath = project.path + private val compilationResolver - get() = nodeJs.npmResolutionManager.resolver[project][compilation] + get() = nodeJs.npmResolutionManager.resolver[projectPath][compilation] private val producer: KotlinCompilationNpmResolver.PackageJsonProducer get() = compilationResolver.packageJsonProducer From 60da9281a2ca3f48d0d993c4ff144a13c984a9a2 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Fri, 16 Oct 2020 14:46:07 +0300 Subject: [PATCH 086/368] [Gradle, JS] Next step of configurstion cache --- .../gradle/internal/ProcessedFilesCache.kt | 55 +++++++------------ .../js/npm/AbstractNodeModulesCache.kt | 16 ++++-- .../js/npm/CompositeNodeModuleBuilder.kt | 10 +--- .../js/npm/CompositeNodeModulesCache.kt | 2 +- .../targets/js/npm/GradleNodeModuleBuilder.kt | 14 +++-- .../targets/js/npm/GradleNodeModulesCache.kt | 9 ++- .../resolver/KotlinCompilationNpmResolver.kt | 20 +++++-- 7 files changed, 64 insertions(+), 62 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/ProcessedFilesCache.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/ProcessedFilesCache.kt index f039f0d7f59..d45053abca8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/ProcessedFilesCache.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/ProcessedFilesCache.kt @@ -9,9 +9,7 @@ import com.google.gson.GsonBuilder import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonToken import com.google.gson.stream.JsonWriter -import org.gradle.api.Project -import org.gradle.api.internal.project.ProjectInternal -import org.gradle.internal.hash.FileHasher +import org.gradle.api.logging.Logger import java.io.File /** @@ -24,14 +22,15 @@ import java.io.File * * @param version When updating logic in `compute`, `version` should be increased to invalidate cache */ +// CHECK internal open class ProcessedFilesCache( - val project: Project, + val logger: Logger, +// val hasher: FileHasher, + val projectDir: File, val targetDir: File, stateFileName: String, val version: String ) : AutoCloseable { - private val hasher = (project as ProjectInternal).services.get(FileHasher::class.java) - private val gson = GsonBuilder().setPrettyPrinting().create() private fun readFrom(json: JsonReader): State? { val result = State() @@ -72,7 +71,7 @@ internal open class ProcessedFilesCache( json.name("items") json.obj { byHash.forEach { - json.name(it.key.contents.toHex()) + json.name(it.key.toHex()) json.obj { json.name("src").value(it.value.src) json.name("target") @@ -96,26 +95,12 @@ internal open class ProcessedFilesCache( endObject() } - fun ByteArray.toHex(): String { - val result = CharArray(size * 2) { ' ' } - var i = 0 - forEach { - val n = it.toInt() - result[i++] = Character.forDigit(n shr 4 and 0xF, 16) - result[i++] = Character.forDigit(n and 0xF, 16) - } - return String(result) + fun Int.toHex(): String { + return toString(16) } - private fun decodeHexString(hexString: String): ByteArray { - check(hexString.length % 2 == 0) - val bytes = ByteArray(hexString.length / 2) - var i = 0 - var o = 0 - while (i < hexString.length) { - bytes[o++] = hexToByte(hexString[i++], hexString[i++]) - } - return bytes + private fun decodeHexString(hexString: String): Int { + return Integer.parseInt(hexString, 16) } private fun hexToByte(a: Char, b: Char): Byte = ((a.toDigit() shl 4) + b.toDigit()).toByte() @@ -140,13 +125,13 @@ internal open class ProcessedFilesCache( } private class State { - val byHash = mutableMapOf() + val byHash = mutableMapOf() val byTarget = mutableMapOf() - operator fun get(elementHash: ByteArray) = byHash[ByteArrayWrapper(elementHash)] + operator fun get(elementHash: Int) = byHash[elementHash] - operator fun set(elementHash: ByteArray, element: Element) { - byHash[ByteArrayWrapper(elementHash)] = element + operator fun set(elementHash: Int, element: Element) { + byHash[elementHash] = element val target = element.target if (target != null) { byTarget[target] = element @@ -175,9 +160,9 @@ internal open class ProcessedFilesCache( state = (if (stateFile.exists()) { try { - gson.newJsonReader(stateFile.reader()).use { readFrom(it) } + GsonBuilder().setPrettyPrinting().create().newJsonReader(stateFile.reader()).use { readFrom(it) } } catch (e: Throwable) { - project.logger.warn("Cannot read $stateFile", e) + logger.warn("Cannot read $stateFile", e) if (targetDir.exists()) { targetDir.deleteRecursively() } @@ -195,19 +180,19 @@ internal open class ProcessedFilesCache( file: File, compute: () -> File? ): String? { - val hash = hasher.hash(file).toByteArray() + val hash = file.hashCode() val old = state[hash] if (old != null) { if (checkTarget(old.target)) return old.target - else project.logger.warn("Cannot find ${File(targetDir.relativeTo(project.projectDir), old.target!!)}, rebuilding") + else logger.warn("Cannot find ${File(targetDir.relativeTo(projectDir), old.target!!)}, rebuilding") } val key = compute()?.relativeTo(targetDir)?.toString() val existedTarget = state.byTarget[key] if (key != null && existedTarget != null) { if (!File(existedTarget.src).exists()) { - project.logger.warn("Removing cache for removed source `${existedTarget.src}`") + logger.warn("Removing cache for removed source `${existedTarget.src}`") state.remove(existedTarget) } } @@ -223,7 +208,7 @@ internal open class ProcessedFilesCache( override fun close() { stateFile.parentFile.mkdirs() - gson.newJsonWriter(stateFile.writer()).use { + GsonBuilder().setPrettyPrinting().create().newJsonWriter(stateFile.writer()).use { state.writeTo(it) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/AbstractNodeModulesCache.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/AbstractNodeModulesCache.kt index d599aa7b047..712905f6a73 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/AbstractNodeModulesCache.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/AbstractNodeModulesCache.kt @@ -6,8 +6,8 @@ package org.jetbrains.kotlin.gradle.targets.js.npm import com.google.gson.GsonBuilder -import org.gradle.api.Project -import org.gradle.api.artifacts.ResolvedDependency +import org.gradle.api.internal.project.ProjectInternal +import org.gradle.internal.hash.FileHasher import org.jetbrains.kotlin.gradle.internal.ProcessedFilesCache import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import java.io.File @@ -15,14 +15,20 @@ import java.io.File /** * Cache for storing already created [GradleNodeModule]s */ -internal abstract class AbstractNodeModulesCache(val nodeJs: NodeJsRootExtension) : AutoCloseable { +internal abstract class AbstractNodeModulesCache(nodeJs: NodeJsRootExtension) : AutoCloseable { companion object { const val STATE_FILE_NAME = ".visited" } - val project: Project get() = nodeJs.rootProject internal val dir = nodeJs.nodeModulesGradleCacheDir - private val cache = ProcessedFilesCache(project, dir, STATE_FILE_NAME, "9") + private val cache = ProcessedFilesCache( + nodeJs.rootProject.logger, +// (nodeJs.rootProject as ProjectInternal).services.get(FileHasher::class.java), + nodeJs.rootProject.projectDir, + dir, + STATE_FILE_NAME, + "9" + ) @Synchronized fun get( diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/CompositeNodeModuleBuilder.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/CompositeNodeModuleBuilder.kt index ab2067a4261..5ddecea9b26 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/CompositeNodeModuleBuilder.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/CompositeNodeModuleBuilder.kt @@ -5,17 +5,14 @@ package org.jetbrains.kotlin.gradle.targets.js.npm -import org.gradle.api.Project -import org.gradle.api.artifacts.ResolvedDependency import java.io.File /** * Creates fake NodeJS module directory from given composite [dependency]. */ internal class CompositeNodeModuleBuilder( - val project: Project, val srcDir: File, - val cache: CompositeNodeModulesCache + val cacheDir: File ) { var srcPackageJsonFile: File = srcDir @@ -29,15 +26,14 @@ internal class CompositeNodeModuleBuilder( // yarn requires semver packageJson.version = fixSemver(packageJson.version) - val container = cache.dir - val importedPackageDir = importedPackageDir(container, packageJson.name, packageJson.version) + val importedPackageDir = importedPackageDir(cacheDir, packageJson.name, packageJson.version) packageJson.main = srcDir.parentFile.resolve(packageJson.main!!) .relativeToOrNull(importedPackageDir) ?.path ?: throw IllegalStateException("Unable to link composite builds for Kotlin/JS which have different roots") - return makeNodeModule(container, packageJson) + return makeNodeModule(cacheDir, packageJson) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/CompositeNodeModulesCache.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/CompositeNodeModulesCache.kt index f95681dd59a..e03b844b2c6 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/CompositeNodeModulesCache.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/CompositeNodeModulesCache.kt @@ -17,7 +17,7 @@ internal class CompositeNodeModulesCache(nodeJs: NodeJsRootExtension) : Abstract version: String, file: File ): File? { - val module = CompositeNodeModuleBuilder(project, file, this) + val module = CompositeNodeModuleBuilder(file, dir) return module.rebuild() } } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt index 2fa2385c8d5..14fac9f9a86 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt @@ -5,7 +5,8 @@ package org.jetbrains.kotlin.gradle.targets.js.npm -import org.gradle.api.Project +import org.gradle.api.file.ArchiveOperations +import org.gradle.api.file.FileSystemOperations import org.jetbrains.kotlin.gradle.targets.js.JS import org.jetbrains.kotlin.gradle.targets.js.JS_MAP import org.jetbrains.kotlin.gradle.targets.js.META_JS @@ -16,11 +17,12 @@ import java.io.File * Creates fake NodeJS module directory from given gradle [dependency]. */ internal class GradleNodeModuleBuilder( - val project: Project, + val fs: FileSystemOperations, + val archiveOperations: ArchiveOperations, val moduleName: String, val moduleVersion: String, val srcFiles: Collection, - val cache: GradleNodeModulesCache + val cacheDir: File ) { private var srcPackageJsonFile: File? = null private val files = mutableListOf() @@ -29,7 +31,7 @@ internal class GradleNodeModuleBuilder( srcFiles.forEach { srcFile -> when { isKotlinJsRuntimeFile(srcFile) -> files.add(srcFile) - srcFile.isCompatibleArchive -> project.zipTree(srcFile).forEach { innerFile -> + srcFile.isCompatibleArchive -> archiveOperations.zipTree(srcFile).forEach { innerFile -> when { innerFile.name == NpmProject.PACKAGE_JSON -> srcPackageJsonFile = innerFile isKotlinJsRuntimeFile(innerFile) -> files.add(innerFile) @@ -61,8 +63,8 @@ internal class GradleNodeModuleBuilder( val actualFiles = files.filterNot { it.name.endsWith(".$META_JS") } - return makeNodeModule(cache.dir, packageJson) { nodeModule -> - project.copy { copy -> + return makeNodeModule(cacheDir, packageJson) { nodeModule -> + fs.copy { copy -> copy.from(actualFiles) copy.into(nodeModule) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt index 410e19df075..9f350db323f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt @@ -5,7 +5,9 @@ package org.jetbrains.kotlin.gradle.targets.js.npm -import org.gradle.api.artifacts.ResolvedDependency +import org.gradle.api.file.ArchiveOperations +import org.gradle.api.file.FileSystemOperations +import org.gradle.api.internal.project.ProjectInternal import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import java.io.File @@ -13,12 +15,15 @@ import java.io.File * Cache for storing already created [GradleNodeModule]s */ internal class GradleNodeModulesCache(nodeJs: NodeJsRootExtension) : AbstractNodeModulesCache(nodeJs) { + private val fs = (nodeJs.rootProject as ProjectInternal).services.get(FileSystemOperations::class.java) + private val archiveOperations = (nodeJs.rootProject as ProjectInternal).services.get(ArchiveOperations::class.java) + override fun buildImportedPackage( name: String, version: String, file: File ): File? { - val module = GradleNodeModuleBuilder(project, name, version, listOf(file), this) + val module = GradleNodeModuleBuilder(fs, archiveOperations, name, version, listOf(file), dir) module.visitArtifacts() return module.rebuild() } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt index 8c56410ae00..b3c3c495a51 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt @@ -51,6 +51,14 @@ internal class KotlinCompilationNpmResolver( @Transient val resolver = projectResolver.resolver + private val gradleNodeModules by lazy { + resolver.gradleNodeModules + } + + private val compositeNodeModules by lazy { + resolver.compositeNodeModules + } + @Transient val npmProject = compilation.npmProject @@ -365,13 +373,13 @@ internal class KotlinCompilationNpmResolver( ?: error("Unresolved dependent npm package: ${this@KotlinCompilationNpmResolver} -> $it") } val importedExternalGradleDependencies = fileExternalGradleDependencies.mapNotNull { - resolver.gradleNodeModules.get(it.dependencyName, it.dependencyVersion, it.file) + gradleNodeModules.get(it.dependencyName, it.dependencyVersion, it.file) } + fileCollectionDependencies.flatMap { dependency -> dependency.files // Gradle can hash with FileHasher only files and only existed files .filter { it.isFile } .map { file -> - resolver.gradleNodeModules.get( + gradleNodeModules.get( file.name, dependency.version ?: "0.0.1", file @@ -382,7 +390,7 @@ internal class KotlinCompilationNpmResolver( val compositeDependencies = internalCompositeDependencies.flatMap { dependency -> dependency.getPackages() .map { file -> - resolver.compositeNodeModules.get( + compositeNodeModules.get( dependency.dependency.moduleName, dependency.dependency.moduleVersion, file @@ -391,10 +399,10 @@ internal class KotlinCompilationNpmResolver( } .filterNotNull() - val toolsNpmDependencies = nodeJs.taskRequirements - .getCompilationNpmRequirements(compilation) +// val toolsNpmDependencies = nodeJs.taskRequirements +// .getCompilationNpmRequirements(compilation) - val allNpmDependencies = externalNpmDependencies + toolsNpmDependencies + val allNpmDependencies = externalNpmDependencies/* + toolsNpmDependencies*/ val packageJson = packageJson( npmProject, From cd0dfd6fa9cf4ba8a3546461b8f71c0c30c84988 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Fri, 16 Oct 2020 15:53:22 +0300 Subject: [PATCH 087/368] [Gradle, JS] Use transient for compilation npm resolver --- .../gradle/targets/js/npm/PackageJson.kt | 17 ++++----- .../targets/js/npm/PublicPackageJsonTask.kt | 36 +++++++++---------- .../KotlinCompilationNpmResolution.kt | 11 ++++-- .../resolver/KotlinCompilationNpmResolver.kt | 32 +++++++++++++---- 4 files changed, 60 insertions(+), 36 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJson.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJson.kt index a5ef81c16cd..757784b23fe 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJson.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJson.kt @@ -125,17 +125,18 @@ fun fromSrcPackageJson(packageJson: File?): PackageJson? = } fun packageJson( - npmProject: NpmProject, + name: String, + version: String, + main: String, npmDependencies: Collection ): PackageJson { - val compilation = npmProject.compilation val packageJson = PackageJson( - npmProject.name, - fixSemver(compilation.target.project.version.toString()) + name, + fixSemver(version) ) - packageJson.main = npmProject.main + packageJson.main = main val dependencies = mutableMapOf() @@ -154,9 +155,9 @@ fun packageJson( } } - compilation.packageJsonHandlers.forEach { - it(packageJson) - } +// compilation.packageJsonHandlers.forEach { +// it(packageJson) +// } return packageJson } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt index 83a3e636651..5ad8535bfe1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt @@ -70,24 +70,24 @@ constructor( fun resolve() { val compilation = npmProject.compilation - packageJson(npmProject, realExternalDependencies).let { packageJson -> - packageJson.main = "${npmProject.name}.js" - - if (compilation is KotlinJsIrCompilation) { - packageJson.types = "${npmProject.name}.d.ts" - } - - packageJson.apply { - listOf( - dependencies, - devDependencies, - peerDependencies, - optionalDependencies - ).forEach { it.processDependencies() } - } - - packageJson.saveTo(this@PublicPackageJsonTask.packageJsonFile) - } +// packageJson(npmProject, realExternalDependencies).let { packageJson -> +// packageJson.main = "${npmProject.name}.js" +// +// if (compilation is KotlinJsIrCompilation) { +// packageJson.types = "${npmProject.name}.d.ts" +// } +// +// packageJson.apply { +// listOf( +// dependencies, +// devDependencies, +// peerDependencies, +// optionalDependencies +// ).forEach { it.processDependencies() } +// } +// +// packageJson.saveTo(this@PublicPackageJsonTask.packageJsonFile) +// } } private fun MutableMap.processDependencies() { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt index ecc968cd7c4..430f5883ac1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt @@ -16,12 +16,17 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.PackageJson */ class KotlinCompilationNpmResolution( @Transient - val project: Project, + private val _project: Project?, @Transient - val npmProject: NpmProject, + private val _npmProject: NpmProject?, val internalDependencies: Collection, val internalCompositeDependencies: Collection, val externalGradleDependencies: Collection, val externalNpmDependencies: Collection, val packageJson: PackageJson -) \ No newline at end of file +) { + val project + get() = _project!! + val npmProject + get() = _npmProject!! +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt index b3c3c495a51..1121e87b082 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt @@ -62,6 +62,22 @@ internal class KotlinCompilationNpmResolver( @Transient val npmProject = compilation.npmProject + val npmName by lazy { + npmProject.name + } + + val npmVersion by lazy { + project.version.toString() + } + + val npmMain by lazy { + npmProject.main + } + + val prePackageJsonFile by lazy { + npmProject.prePackageJsonFile + } + val nodeJs get() = resolver.nodeJs val target get() = compilation.target @@ -405,7 +421,9 @@ internal class KotlinCompilationNpmResolver( val allNpmDependencies = externalNpmDependencies/* + toolsNpmDependencies*/ val packageJson = packageJson( - npmProject, + npmName, + npmVersion, + npmMain, allNpmDependencies ) @@ -421,17 +439,17 @@ internal class KotlinCompilationNpmResolver( packageJson.dependencies[it.name] = fileVersion(it.path) } - compilation.packageJsonHandlers.forEach { - it(packageJson) - } +// compilation.packageJsonHandlers.forEach { +// it(packageJson) +// } if (!skipWriting) { - packageJson.saveTo(npmProject.prePackageJsonFile) + packageJson.saveTo(prePackageJsonFile) } return KotlinCompilationNpmResolution( - project, - npmProject, + if (compilation != null) project else null, + if (compilation != null) npmProject else null, resolvedInternalDependencies, compositeDependencies, importedExternalGradleDependencies, From b9aa577f84f7fd10221c4ce563538e4c570b6644 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Fri, 16 Oct 2020 18:21:21 +0300 Subject: [PATCH 088/368] [Gradle, JS] KotlinPackageJson configuration cache works --- .../targets/js/nodejs/TasksRequirements.kt | 16 ++++++----- .../js/npm/NpmDependencyDeclaration.kt | 27 +++++++++++++++++++ .../gradle/targets/js/npm/PackageJson.kt | 16 +++++------ .../targets/js/npm/PublicPackageJsonTask.kt | 22 ++++----------- .../KotlinCompilationNpmResolution.kt | 19 +++++++++---- .../resolver/KotlinCompilationNpmResolver.kt | 12 ++++++--- .../js/npm/tasks/KotlinPackageJsonTask.kt | 8 ++++-- 7 files changed, 78 insertions(+), 42 deletions(-) create mode 100644 libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependencyDeclaration.kt diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt index 83367097f07..7339324692e 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt @@ -5,20 +5,22 @@ package org.jetbrains.kotlin.gradle.targets.js.nodejs -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation import org.jetbrains.kotlin.gradle.targets.js.RequiredKotlinJsDependency import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency +import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependencyDeclaration import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies +import org.jetbrains.kotlin.gradle.targets.js.npm.toDeclaration class TasksRequirements { + @Transient private val _byTask = mutableMapOf>() - private val byCompilation = mutableMapOf>() + private val byCompilation = mutableMapOf>() val byTask: Map> get() = _byTask - fun getCompilationNpmRequirements(compilation: KotlinJsCompilation): Set = - byCompilation[compilation] + internal fun getCompilationNpmRequirements(compilationName: String): Set = + byCompilation[compilationName] ?: setOf() fun addTaskRequirements(task: RequiresNpmDependencies) { @@ -32,11 +34,11 @@ class TasksRequirements { .filterIsInstance() .toMutableSet() - val compilation = task.compilation + val compilation = task.compilation.name if (compilation in byCompilation) { - byCompilation[compilation]!!.addAll(requiredNpmDependencies) + byCompilation[compilation]!!.addAll(requiredNpmDependencies.map { it.toDeclaration() }) } else { - byCompilation[compilation] = requiredNpmDependencies + byCompilation[compilation] = requiredNpmDependencies.map { it.toDeclaration() }.toMutableSet() } } } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependencyDeclaration.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependencyDeclaration.kt new file mode 100644 index 00000000000..f01d90edc15 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependencyDeclaration.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2020 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.gradle.targets.js.npm + +import org.gradle.api.tasks.Input + +data class NpmDependencyDeclaration( + @Input + val scope: NpmDependency.Scope, + @Input + val name: String, + @Input + val version: String, + @Input + val generateExternals: Boolean +) + +internal fun NpmDependency.toDeclaration(): NpmDependencyDeclaration = + NpmDependencyDeclaration( + scope = this.scope, + name = this.name, + version = this.version, + generateExternals = this.generateExternals + ) \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJson.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJson.kt index 757784b23fe..5807b96f2b8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJson.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJson.kt @@ -124,11 +124,11 @@ fun fromSrcPackageJson(packageJson: File?): PackageJson? = Gson().fromJson(it, PackageJson::class.java) } -fun packageJson( +internal fun packageJson( name: String, version: String, main: String, - npmDependencies: Collection + npmDependencies: Collection ): PackageJson { val packageJson = PackageJson( @@ -141,17 +141,17 @@ fun packageJson( val dependencies = mutableMapOf() npmDependencies.forEach { - val module = it.key + val module = it.name dependencies[module] = chooseVersion(module, dependencies[module], it.version) } npmDependencies.forEach { - val dependency = dependencies.getValue(it.key) + val dependency = dependencies.getValue(it.name) when (it.scope) { - NpmDependency.Scope.NORMAL -> packageJson.dependencies[it.key] = dependency - NpmDependency.Scope.DEV -> packageJson.devDependencies[it.key] = dependency - NpmDependency.Scope.OPTIONAL -> packageJson.optionalDependencies[it.key] = dependency - NpmDependency.Scope.PEER -> packageJson.peerDependencies[it.key] = dependency + NpmDependency.Scope.NORMAL -> packageJson.dependencies[it.name] = dependency + NpmDependency.Scope.DEV -> packageJson.devDependencies[it.name] = dependency + NpmDependency.Scope.OPTIONAL -> packageJson.optionalDependencies[it.name] = dependency + NpmDependency.Scope.PEER -> packageJson.peerDependencies[it.name] = dependency } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt index 5ad8535bfe1..c568f79e504 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt @@ -11,7 +11,6 @@ import org.gradle.api.tasks.Nested import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.TaskAction import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation -import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrCompilation import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject.Companion.PACKAGE_JSON import org.jetbrains.kotlin.gradle.utils.disableTaskOnConfigurationCacheBuild import org.jetbrains.kotlin.gradle.utils.property @@ -43,19 +42,17 @@ constructor( }.customFields @get:Nested - internal val externalDependencies: Collection + internal val externalDependencies: Collection get() = compilationResolution.externalNpmDependencies .map { - NestedNpmDependency( + NpmDependencyDeclaration( scope = it.scope, name = it.name, - version = it.version + version = it.version, + generateExternals = it.generateExternals ) } - private val realExternalDependencies: Collection - get() = compilationResolution.externalNpmDependencies - private val publicPackageJsonTaskName = npmProject.publicPackageJsonTaskName @get:OutputFile @@ -101,13 +98,4 @@ constructor( companion object { const val NAME = "publicPackageJson" } -} - -internal data class NestedNpmDependency( - @Input - val scope: NpmDependency.Scope, - @Input - val name: String, - @Input - val version: String -) \ No newline at end of file +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt index 430f5883ac1..881aaa72be3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt @@ -6,10 +6,7 @@ package org.jetbrains.kotlin.gradle.targets.js.npm.resolved import org.gradle.api.Project -import org.jetbrains.kotlin.gradle.targets.js.npm.GradleNodeModule -import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency -import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject -import org.jetbrains.kotlin.gradle.targets.js.npm.PackageJson +import org.jetbrains.kotlin.gradle.targets.js.npm.* /** * Resolved [NpmProject] @@ -22,11 +19,23 @@ class KotlinCompilationNpmResolution( val internalDependencies: Collection, val internalCompositeDependencies: Collection, val externalGradleDependencies: Collection, - val externalNpmDependencies: Collection, + private val _externalNpmDependencies: Collection, val packageJson: PackageJson ) { val project get() = _project!! val npmProject get() = _npmProject!! + + val externalNpmDependencies + get() = _externalNpmDependencies + .map { + NpmDependency( + project = project, + name = it.name, + version = it.version, + scope = it.scope, + generateExternals = it.generateExternals + ) + } } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt index 1121e87b082..dff0a5a262c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt @@ -62,6 +62,8 @@ internal class KotlinCompilationNpmResolver( @Transient val npmProject = compilation.npmProject + val compilationName = compilation.name + val npmName by lazy { npmProject.name } @@ -80,6 +82,10 @@ internal class KotlinCompilationNpmResolver( val nodeJs get() = resolver.nodeJs + val taskRequirements by lazy { + nodeJs.taskRequirements + } + val target get() = compilation.target val project get() = target.project @@ -415,10 +421,10 @@ internal class KotlinCompilationNpmResolver( } .filterNotNull() -// val toolsNpmDependencies = nodeJs.taskRequirements -// .getCompilationNpmRequirements(compilation) + val toolsNpmDependencies = taskRequirements + .getCompilationNpmRequirements(compilationName) - val allNpmDependencies = externalNpmDependencies/* + toolsNpmDependencies*/ + val allNpmDependencies = externalNpmDependencies.map { it.toDeclaration() } + toolsNpmDependencies val packageJson = packageJson( npmName, diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt index 606d69337c1..02d2a638cb4 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt @@ -33,6 +33,10 @@ open class KotlinPackageJsonTask : DefaultTask() { @Transient private lateinit var compilation: KotlinJsCompilation + private val compilationName by lazy { + compilation.name + } + @Input val projectPath = project.path @@ -60,8 +64,8 @@ open class KotlinPackageJsonTask : DefaultTask() { @get:Input internal val toolsNpmDependencies: List by lazy { nodeJs.taskRequirements - .getCompilationNpmRequirements(compilation) - .map { it.uniqueRepresentation() } + .getCompilationNpmRequirements(compilationName) + .map { it.toString() } } @get:Nested From e6bfe9a70246035cbe372a256ddb35d48030eba6 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Thu, 10 Dec 2020 16:44:36 +0300 Subject: [PATCH 089/368] [Gradle, JS] Npm dependencies as transient, and store only declarations --- .../kotlin/gradle/targets/js/npm/NpmDependency.kt | 3 --- .../gradle/targets/js/npm/NpmDependencyDeclaration.kt | 3 +++ .../js/npm/resolver/KotlinCompilationNpmResolver.kt | 11 +++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependency.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependency.kt index 7c9c0a15ee8..37f1dc0bfd1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependency.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependency.kt @@ -111,9 +111,6 @@ data class NpmDependency( } override fun getReason(): String? = reason - - fun uniqueRepresentation() = - "$scope $key:$version, $generateExternals" } internal fun directoryNpmDependency( diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependencyDeclaration.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependencyDeclaration.kt index f01d90edc15..bfc64d2ed38 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependencyDeclaration.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependencyDeclaration.kt @@ -18,6 +18,9 @@ data class NpmDependencyDeclaration( val generateExternals: Boolean ) +fun NpmDependencyDeclaration.uniqueRepresentation() = + "$scope $name:$version, $generateExternals" + internal fun NpmDependency.toDeclaration(): NpmDependencyDeclaration = NpmDependencyDeclaration( scope = this.scope, diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt index dff0a5a262c..a3694c270c3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt @@ -367,9 +367,16 @@ internal class KotlinCompilationNpmResolver( val internalCompositeDependencies: Collection, @Transient val externalGradleDependencies: Collection, + @Transient val externalNpmDependencies: Collection, val fileCollectionDependencies: Collection ) { + val externalNpmDependencyDeclarations by lazy { + externalNpmDependencies.map { + it.toDeclaration() + } + } + val fileExternalGradleDependencies by lazy { externalGradleDependencies.map { FileExternalGradleDependency( @@ -385,7 +392,7 @@ internal class KotlinCompilationNpmResolver( internalDependencies.map { it.npmProject.name }, internalCompositeDependencies.flatMap { it.getPackages() }, fileExternalGradleDependencies.map { it.file }, - externalNpmDependencies.map { it.uniqueRepresentation() }, + externalNpmDependencyDeclarations.map { it.uniqueRepresentation() }, fileCollectionDependencies.map { it.files }.flatMap { it.files } ) @@ -424,7 +431,7 @@ internal class KotlinCompilationNpmResolver( val toolsNpmDependencies = taskRequirements .getCompilationNpmRequirements(compilationName) - val allNpmDependencies = externalNpmDependencies.map { it.toDeclaration() } + toolsNpmDependencies + val allNpmDependencies = externalNpmDependencyDeclarations + toolsNpmDependencies val packageJson = packageJson( npmName, From a41d3e5b043cff7f4a4da798000cb25f414ad277 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Fri, 11 Dec 2020 13:56:43 +0300 Subject: [PATCH 090/368] [Gradle, JS] Webpack task with conf cache (w/o install of dependencies) --- .../jetbrains/kotlin/gradle/internal/exec.kt | 17 ++++---- .../kotlin/gradle/internal/progress.kt | 8 ++-- .../js/MultiplePluginDeclarationDetector.kt | 6 +-- .../dukat/DukatCompilationResolverPlugin.kt | 3 +- .../gradle/targets/js/dukat/DukatExecutor.kt | 5 ++- .../gradle/targets/js/dukat/DukatRunner.kt | 5 ++- .../gradle/targets/js/dukat/DukatTask.kt | 2 +- .../targets/js/dukat/IntegratedDukatTask.kt | 2 +- .../gradle/targets/js/ir/KotlinJsIrLink.kt | 5 ++- .../gradle/targets/js/npm/NpmProject.kt | 12 +++--- .../resolver/KotlinCompilationNpmResolver.kt | 5 ++- .../gradle/targets/js/testing/KotlinJsTest.kt | 5 ++- .../targets/js/testing/karma/KotlinKarma.kt | 5 ++- .../targets/js/webpack/KotlinWebpack.kt | 40 +++++++++++++------ .../targets/js/webpack/KotlinWebpackRunner.kt | 6 ++- .../gradle/targets/js/yarn/YarnBasics.kt | 3 +- 16 files changed, 76 insertions(+), 53 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/exec.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/exec.kt index c2cc1834c84..c4331952ef5 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/exec.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/exec.kt @@ -9,6 +9,7 @@ import jetbrains.buildServer.messages.serviceMessages.ServiceMessageParserCallba import org.gradle.api.Project import org.gradle.api.internal.project.ProjectInternal import org.gradle.internal.logging.progress.ProgressLogger +import org.gradle.internal.service.ServiceRegistry import org.gradle.process.ExecResult import org.gradle.process.internal.ExecAction import org.gradle.process.internal.ExecActionFactory @@ -18,15 +19,13 @@ import java.io.PipedInputStream import java.io.PipedOutputStream import kotlin.concurrent.thread -internal fun Project.execWithProgress(description: String, readStdErr: Boolean = false, body: (ExecAction) -> Unit): ExecResult { - this as ProjectInternal - +internal fun ServiceRegistry.execWithProgress(description: String, readStdErr: Boolean = false, body: (ExecAction) -> Unit): ExecResult { val stderr = ByteArrayOutputStream() val stdout = StringBuilder() val stdInPipe = PipedInputStream() - val exec = services.get(ExecActionFactory::class.java).newExecAction() + val exec = get(ExecActionFactory::class.java).newExecAction() body(exec) - return project!!.operation(description) { + return operation(description) { progress(description) exec.standardOutput = PipedOutputStream(stdInPipe) val outputReaderThread = thread(name = "output reader for [$description]") { @@ -69,14 +68,12 @@ internal fun Project.execWithProgress(description: String, readStdErr: Boolean = } } -internal fun Project.execWithErrorLogger( +internal fun ServiceRegistry.execWithErrorLogger( description: String, body: (ExecAction, ProgressLogger) -> Pair ): ExecResult { - this as ProjectInternal - - val exec = services.get(ExecActionFactory::class.java).newExecAction() - return project!!.operation(description) { + val exec = get(ExecActionFactory::class.java).newExecAction() + return operation(description) { progress(description) val (standardClient, errorClient) = body(exec, this) exec.isIgnoreExitValue = true diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/progress.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/progress.kt index ff8922ff82d..4ac7e865e94 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/progress.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/progress.kt @@ -5,18 +5,16 @@ package org.jetbrains.kotlin.gradle.internal -import org.gradle.api.Project -import org.gradle.api.internal.project.ProjectInternal import org.gradle.internal.logging.events.ProgressStartEvent import org.gradle.internal.logging.progress.ProgressLogger +import org.gradle.internal.service.ServiceRegistry -fun Project.operation( +fun ServiceRegistry.operation( description: String, initialStatus: String? = null, body: ProgressLogger.() -> T ): T { - val services = (project as ProjectInternal).services - val progressFactory = services.get(org.gradle.internal.logging.progress.ProgressLoggerFactory::class.java) + val progressFactory = get(org.gradle.internal.logging.progress.ProgressLoggerFactory::class.java) val operation = progressFactory.newOperation(ProgressStartEvent.BUILD_OP_CATEGORY) operation.start(description, initialStatus) try { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/MultiplePluginDeclarationDetector.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/MultiplePluginDeclarationDetector.kt index 61e9776aeb0..6f5ac1944c1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/MultiplePluginDeclarationDetector.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/MultiplePluginDeclarationDetector.kt @@ -40,9 +40,9 @@ private constructor() { val detector = MultiplePluginDeclarationDetector() instance = detector - gradle.buildFinished { - instance = null - } +// gradle.buildFinished { +// instance = null +// } return detector } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt index 00c8e6f723f..04f67aff4fb 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.gradle.targets.js.dukat import org.gradle.api.artifacts.FileCollectionDependency +import org.gradle.api.internal.project.ProjectInternal import org.jetbrains.kotlin.gradle.plugin.mpp.disambiguateName import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget @@ -103,7 +104,7 @@ internal class DukatCompilationResolverPlugin( packageJsonIsUpdated, operation = compilation.name + " > " + DukatExecutor.OPERATION, compareInputs = true - ).execute() + ).execute((project as ProjectInternal).services) } companion object { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatExecutor.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatExecutor.kt index 0984b51efd4..d3ab9381a63 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatExecutor.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatExecutor.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.gradle.targets.js.dukat +import org.gradle.internal.service.ServiceRegistry import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject @@ -30,7 +31,7 @@ class DukatExecutor( val shouldSkip: Boolean get() = inputsFile.isFile && prevVersion == version && !packageJsonIsUpdated - fun execute() { + fun execute(services: ServiceRegistry) { if (typeDefinitions.isEmpty()) { npmProject.externalsDirRoot.deleteRecursively() return @@ -53,7 +54,7 @@ class DukatExecutor( externalsOutputFormat, npmProject.externalsDir, operation = operation - ).execute() + ).execute(services) inputsFile.writeText(inputs) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatRunner.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatRunner.kt index 1aadba36a46..9b6bcc42820 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatRunner.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatRunner.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.gradle.targets.js.dukat +import org.gradle.internal.service.ServiceRegistry import org.jetbrains.kotlin.gradle.internal.execWithProgress import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject @@ -19,8 +20,8 @@ class DukatRunner( val jsInteropJvmEngine: String? = null, val operation: String = "Generating Kotlin/JS external declarations" ) { - fun execute() { - compilation.target.project.execWithProgress(operation) { exec -> + fun execute(services: ServiceRegistry) { + services.execWithProgress(operation) { exec -> val args = mutableListOf() if (externalsOutputFormat == ExternalsOutputFormat.BINARY) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt index aaa61a9cbb6..6992ac7b00d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt @@ -100,7 +100,7 @@ abstract class DukatTask( qualifiedPackageName, null, operation - ).execute() + ).execute(services) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/IntegratedDukatTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/IntegratedDukatTask.kt index 5c003724c87..51a7dcca1b8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/IntegratedDukatTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/IntegratedDukatTask.kt @@ -39,6 +39,6 @@ constructor( @TaskAction override fun run() { - executor.execute() + executor.execute(services) } } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrLink.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrLink.kt index 3024c8c6510..a3b4fd5ff09 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrLink.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrLink.kt @@ -37,13 +37,14 @@ open class KotlinJsIrLink : Kotlin2JsCompile() { @get:SkipWhenEmpty @get:InputDirectory @get:PathSensitive(PathSensitivity.RELATIVE) - internal val entryModule: File - get() = File( + internal val entryModule: File by lazy { + File( (taskData.compilation as KotlinJsIrCompilation) .output .classesDirs .asPath ) + } override fun skipCondition(inputs: IncrementalTaskInputs): Boolean { return !inputs.isIncremental && !entryModule.exists() diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt index fef595b5e93..229d93e83ae 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt @@ -25,11 +25,13 @@ val KotlinJsCompilation.npmProject: NpmProject * More info can be obtained from [KotlinCompilationNpmResolution], which is available after project resolution (after [KotlinNpmInstallTask] execution). */ open class NpmProject(@Transient val compilation: KotlinJsCompilation) { - val name: String - get() = buildNpmProjectName() + val name: String by lazy { + buildNpmProjectName() + } - val nodeJs - get() = NodeJsRootPlugin.apply(project.rootProject) + val nodeJs by lazy { + NodeJsRootPlugin.apply(project.rootProject) + } val dir: File get() = nodeJs.projectPackagesDir.resolve(name) @@ -90,7 +92,7 @@ open class NpmProject(@Transient val compilation: KotlinJsCompilation) { * Require [request] nodejs module and return canonical path to it's main js file. */ fun require(request: String): String { - nodeJs.npmResolutionManager.requireAlreadyInstalled(project) +// nodeJs.npmResolutionManager.requireAlreadyInstalled(project) return modules.require(request) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt index a3694c270c3..1eb613de7b6 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt @@ -91,7 +91,8 @@ internal class KotlinCompilationNpmResolver( val project get() = target.project @Transient - val packageJsonTaskHolder = KotlinPackageJsonTask.create(compilation) + val packageJsonTaskHolder: TaskProvider? = + KotlinPackageJsonTask.create(compilation) @Transient val publicPackageJsonTaskHolder: TaskProvider = @@ -150,7 +151,7 @@ internal class KotlinCompilationNpmResolver( @Synchronized fun getResolutionOrResolveIfForced(): KotlinCompilationNpmResolution? { if (resolution != null) return resolution - if (packageJsonTaskHolder.get().state.upToDate) return resolve(skipWriting = true) + if (packageJsonTaskHolder == null || packageJsonTaskHolder.get().state.upToDate) return resolve(skipWriting = true) if (resolver.forceFullResolve && resolution == null) { // need to force all NPM tasks to be configured in IDEA import project.tasks.implementing(RequiresNpmDependencies::class).all {} diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt index e0dbc69a9bc..f6212ed6b8b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt @@ -112,7 +112,10 @@ constructor( } fun useKarma() = useKarma {} - fun useKarma(body: KotlinKarma.() -> Unit) = use(KotlinKarma(compilation), body) + fun useKarma(body: KotlinKarma.() -> Unit) = use( + KotlinKarma(compilation, services), + body + ) fun useKarma(fn: Closure<*>) { useKarma { ConfigureUtil.configure(fn, this) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt index dd8248b7f81..a885c945358 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt @@ -10,6 +10,7 @@ import jetbrains.buildServer.messages.serviceMessages.BaseTestSuiteMessage import org.gradle.api.Project import org.gradle.api.internal.tasks.testing.TestResultProcessor import org.gradle.internal.logging.progress.ProgressLogger +import org.gradle.internal.service.ServiceRegistry import org.gradle.process.ProcessForkOptions import org.gradle.process.internal.ExecHandle import org.jetbrains.kotlin.gradle.internal.LogType @@ -35,7 +36,7 @@ import org.jetbrains.kotlin.gradle.utils.property import org.slf4j.Logger import java.io.File -class KotlinKarma(override val compilation: KotlinJsCompilation) : +class KotlinKarma(override val compilation: KotlinJsCompilation, private val services: ServiceRegistry) : KotlinJsTestFramework { private val project: Project = compilation.target.project private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) @@ -404,7 +405,7 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : lateinit var progressLogger: ProgressLogger override fun wrapExecute(body: () -> Unit) { - project.operation("Running and building tests with karma and webpack") { + services.operation("Running and building tests with karma and webpack") { progressLogger = this body() } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt index 1184549834d..c4a6f29f646 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt @@ -10,6 +10,7 @@ import org.gradle.api.Incubating import org.gradle.api.file.FileCollection import org.gradle.api.file.RegularFileProperty import org.gradle.api.internal.file.FileResolver +import org.gradle.api.internal.project.ProjectInternal import org.gradle.api.plugins.BasePluginConvention import org.gradle.api.provider.Provider import org.gradle.api.tasks.* @@ -44,9 +45,11 @@ constructor( init { // TODO: temporary workaround for configuration cache enabled builds - disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() } +// disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() } } + private val npmProject = compilation.npmProject + @get:Inject open val fileResolver: FileResolver get() = injected @@ -97,7 +100,7 @@ constructor( @get:OutputFile open val configFile: File by lazy { - compilation.npmProject.dir.resolve("webpack.config.js") + npmProject.dir.resolve("webpack.config.js") } @Input @@ -137,21 +140,30 @@ constructor( open val outputFile: File get() = destinationDirectory.resolve(outputFileName) - open val configDirectory: File? - @Optional @InputDirectory get() = project.projectDir.resolve("webpack.config.d").takeIf { it.isDirectory } + private val projectDir = project.projectDir + + @get:Optional + @get:InputDirectory + open val configDirectory: File? by lazy { + projectDir.resolve("webpack.config.d").takeIf { it.isDirectory } + } @Input var report: Boolean = false + private val projectReportsDir = project.reportsDir + open val reportDir: File @Internal get() = reportDirProvider.get() - @OutputDirectory - open val reportDirProvider: Provider = entryProperty - .map { it.asFile.nameWithoutExtension } - .map { - project.reportsDir.resolve("webpack").resolve(it) - } + @get:OutputDirectory + open val reportDirProvider: Provider by lazy { + entryProperty + .map { it.asFile.nameWithoutExtension } + .map { + projectReportsDir.resolve("webpack").resolve(it) + } + } open val evaluatedConfigFile: File @Internal get() = evaluatedConfigFileProvider.get() @@ -217,7 +229,8 @@ constructor( .forEach { it(config) } return KotlinWebpackRunner( - compilation.npmProject, + npmProject, + logger, configFile, execHandleFactory, bin, @@ -237,7 +250,8 @@ constructor( @TaskAction fun doExecute() { - nodeJs.npmResolutionManager.checkRequiredDependencies(this) + println(services.get(org.gradle.internal.logging.progress.ProgressLoggerFactory::class.java)) +// nodeJs.npmResolutionManager?.checkRequiredDependencies(this) val runner = createRunner() @@ -258,7 +272,7 @@ constructor( progressReporter = true, progressReporterPathFilter = nodeJs.rootPackageDir.absolutePath ) - ).execute() + ).execute(services) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackRunner.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackRunner.kt index d39cccd7ccb..0a6dac7c6fa 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackRunner.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpackRunner.kt @@ -5,7 +5,9 @@ package org.jetbrains.kotlin.gradle.targets.js.webpack +import org.gradle.api.logging.Logger import org.gradle.internal.logging.progress.ProgressLogger +import org.gradle.internal.service.ServiceRegistry import org.gradle.process.ExecSpec import org.gradle.process.internal.ExecHandle import org.gradle.process.internal.ExecHandleFactory @@ -18,6 +20,7 @@ import java.io.File internal data class KotlinWebpackRunner( val npmProject: NpmProject, + val logger: Logger, val configFile: File, val execHandleFactory: ExecHandleFactory, val tool: String, @@ -25,7 +28,7 @@ internal data class KotlinWebpackRunner( val nodeArgs: List, val config: KotlinWebpackConfig ) { - fun execute() = npmProject.project.execWithErrorLogger("webpack") { execAction, progressLogger -> + fun execute(services: ServiceRegistry) = services.execWithErrorLogger("webpack") { execAction, progressLogger -> configureExec( execAction, progressLogger @@ -47,7 +50,6 @@ internal data class KotlinWebpackRunner( clientType: LogType, progressLogger: ProgressLogger? ): TeamCityMessageCommonClient { - val logger = npmProject.project.logger return TeamCityMessageCommonClient(clientType, logger) .apply { if (progressLogger != null) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnBasics.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnBasics.kt index 705932b213c..b34d8ca1280 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnBasics.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnBasics.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.gradle.targets.js.yarn import org.gradle.api.Project +import org.gradle.api.internal.project.ProjectInternal import org.jetbrains.kotlin.gradle.internal.execWithProgress import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin import org.jetbrains.kotlin.gradle.targets.js.npm.NpmApi @@ -32,7 +33,7 @@ abstract class YarnBasics : NpmApi { val nodeJs = NodeJsRootPlugin.apply(project) val yarnPlugin = YarnPlugin.apply(project) - project.execWithProgress(description) { exec -> + (project as ProjectInternal).services.execWithProgress(description) { exec -> exec.executable = nodeJs.requireConfigured().nodeExecutable exec.args = listOf(yarnPlugin.requireConfigured().home.resolve("bin/yarn.js").absolutePath) + args + From 8c79baa9985c2aa8d80c4bda3b495750c411486c Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Mon, 14 Dec 2020 15:55:26 +0300 Subject: [PATCH 091/368] [Gradle, JS] Partially rootPackageJson and kotlinNpmInstall with conf cache --- .../dukat/DukatCompilationResolverPlugin.kt | 2 +- .../gradle/targets/js/dukat/DukatTask.kt | 2 +- .../targets/js/nodejs/NodeJsRootExtension.kt | 5 ++-- .../js/npm/KotlinNpmResolutionManager.kt | 28 +++++++++---------- .../targets/js/npm/PublicPackageJsonTask.kt | 2 +- .../resolved/KotlinProjectNpmResolution.kt | 15 +++++----- .../npm/resolved/KotlinRootNpmResolution.kt | 4 +-- .../npm/resolver/KotlinProjectNpmResolver.kt | 13 +++++---- .../js/npm/resolver/KotlinRootNpmResolver.kt | 4 +-- .../js/npm/tasks/KotlinNpmInstallTask.kt | 2 +- .../js/npm/tasks/KotlinPackageJsonTask.kt | 2 +- .../js/npm/tasks/RootPackageJsonTask.kt | 2 +- 12 files changed, 42 insertions(+), 39 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt index 04f67aff4fb..bfabb774b3c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt @@ -86,7 +86,7 @@ internal class DukatCompilationResolverPlugin( packageJsonIsUpdated: Boolean, resolution: KotlinRootNpmResolution ) { - val externalNpmDependencies = resolution[project][compilation].externalNpmDependencies + val externalNpmDependencies = resolution[project.path][compilation].externalNpmDependencies val target = compilation.target val externalsOutputFormat = compilation.externalsOutputFormat diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt index 6992ac7b00d..8e8a301cce1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt @@ -44,7 +44,7 @@ abstract class DukatTask( @get:Internal @delegate:Transient val dts by lazy { - val resolvedCompilation = nodeJs.npmResolutionManager.requireInstalled()[project][compilation] + val resolvedCompilation = nodeJs.npmResolutionManager.requireInstalled()[project.path][compilation] val dtsResolver = DtsResolver(resolvedCompilation.npmProject) dtsResolver.getAllDts( resolvedCompilation.externalNpmDependencies, diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt index 9add2d34d71..40d24af42df 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt @@ -63,8 +63,8 @@ open class NodeJsRootExtension(@Transient val rootProject: Project) : Configurat val packageJsonUmbrellaTaskProvider: TaskProvider get() = rootProject.tasks.named(PACKAGE_JSON_UMBRELLA_TASK_NAME) - val rootPackageJsonTaskProvider: TaskProvider - get() = rootProject.tasks.withType(RootPackageJsonTask::class.java).named(RootPackageJsonTask.NAME) + val rootPackageJsonTaskProvider: TaskProvider? + get() = rootProject?.tasks?.withType(RootPackageJsonTask::class.java)?.named(RootPackageJsonTask.NAME) val rootPackageDir: File by lazy { rootProject.buildDir.resolve("js") @@ -121,7 +121,6 @@ open class NodeJsRootExtension(@Transient val rootProject: Project) : Configurat val versions = NpmVersions() - @Transient internal val npmResolutionManager = KotlinNpmResolutionManager(this) companion object { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt index 14d3852c199..9bded47c85b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt @@ -106,7 +106,7 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension companion object { fun npmProjectsByProjectResolutions( - resolutions: Map + resolutions: Map ): List { return resolutions .values @@ -150,7 +150,7 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension } internal fun requireAlreadyInstalled(project: Project, reason: String = ""): KotlinProjectNpmResolution = - installIfNeeded(reason = reason)[project] + installIfNeeded(reason = reason)[project.path] internal val packageJsonFiles: Collection get() = state.npmProjects.map { it.packageJsonFile } @@ -178,7 +178,7 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension when (state1) { is ResolutionState.Prepared -> alreadyResolved(state1.preparedInstallation) is ResolutionState.Configuring -> { - val upToDate = nodeJsSettings.rootPackageJsonTaskProvider.get().state.upToDate + val upToDate = nodeJsSettings.rootPackageJsonTaskProvider?.get()?.state?.upToDate ?: true if (requireUpToDateReason != null && !upToDate) { error("NPM dependencies should be resolved $requireUpToDateReason") } @@ -196,7 +196,7 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension } internal fun getNpmDependencyResolvedCompilation(npmDependency: NpmDependency): KotlinCompilationNpmResolution? { - val project = npmDependency.project + val project = npmDependency.project.path val resolvedProject = if (forceFullResolve) { @@ -222,15 +222,15 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension internal fun checkRequiredDependencies(task: T) where T : RequiresNpmDependencies, T : Task { - val project = task.project - val requestedTaskDependencies = requireAlreadyInstalled(project, "before $task execution").taskRequirements - val targetRequired = requestedTaskDependencies[task]?.toSet() ?: setOf() - - task.requiredNpmDependencies.forEach { - check(it in targetRequired) { - "${it.createDependency(project)} required by $task was not found resolved at the time of nodejs package manager call. " + - "This may be caused by changing $task configuration after npm dependencies resolution." - } - } +// val project = task.project +// val requestedTaskDependencies = requireAlreadyInstalled(project, "before $task execution").taskRequirements +// val targetRequired = requestedTaskDependencies[task]?.toSet() ?: setOf() +// +// task.requiredNpmDependencies.forEach { +// check(it in targetRequired) { +// "${it.createDependency(project)} required by $task was not found resolved at the time of nodejs package manager call. " + +// "This may be caused by changing $task configuration after npm dependencies resolution." +// } +// } } } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt index c568f79e504..5dc14a85fdd 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt @@ -27,7 +27,7 @@ constructor( private val nodeJs = npmProject.nodeJs private val compilationResolution - get() = nodeJs.npmResolutionManager.requireInstalled()[project][npmProject.compilation] + get() = nodeJs.npmResolutionManager.requireInstalled()[project.path][npmProject.compilation] init { // TODO: temporary workaround for configuration cache enabled builds diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt index 34e8d5cf99f..dd5eb518a49 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt @@ -16,11 +16,11 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies * Info about NPM projects inside particular gradle [project]. */ class KotlinProjectNpmResolution( - val project: Project, + val project: String, val npmProjects: List, - val taskRequirements: Map> + val taskRequirements: Map>? ) { - val npmProjectsByNpmDependency: Map = + val npmProjectsByNpmDependency: Map by lazy { mutableMapOf().also { result -> npmProjects.forEach { npmPackage -> npmPackage.externalNpmDependencies.forEach { npmDependency -> @@ -28,15 +28,16 @@ class KotlinProjectNpmResolution( } } } + } - val byCompilation by lazy { npmProjects.associateBy { it.npmProject.compilation } } + val byCompilation by lazy { npmProjects.associateBy { it.npmProject.compilation.name } } operator fun get(compilation: KotlinJsCompilation): KotlinCompilationNpmResolution { - check(compilation.target.project == project) - return byCompilation.getValue(compilation) + check(compilation.target.project.path == project) + return byCompilation.getValue(compilation.name) } companion object { - fun empty(project: Project) = KotlinProjectNpmResolution(project, listOf(), mapOf()) + fun empty(project: String) = KotlinProjectNpmResolution(project, listOf(), mapOf()) } } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinRootNpmResolution.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinRootNpmResolution.kt index 32f61828d30..2bfb3e4c3d5 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinRootNpmResolution.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinRootNpmResolution.kt @@ -9,7 +9,7 @@ import org.gradle.api.Project internal class KotlinRootNpmResolution( val rootProject: Project, - internal val projects: Map + internal val projects: Map ) { - operator fun get(project: Project) = projects[project] ?: KotlinProjectNpmResolution.empty(project) + operator fun get(project: String) = projects[project] ?: KotlinProjectNpmResolution.empty(project) } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt index 20dfe39366f..a71c8e7edaf 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt @@ -25,16 +25,19 @@ import kotlin.reflect.KClass * See [KotlinNpmResolutionManager] for details about resolution process. */ internal class KotlinProjectNpmResolver( + @Transient val project: Project, val resolver: KotlinRootNpmResolver ) { override fun toString(): String = "ProjectNpmResolver($project)" - private val byCompilation = mutableMapOf() + private val projectPath by lazy { project.path } + + private val byCompilation = mutableMapOf() operator fun get(compilation: KotlinJsCompilation): KotlinCompilationNpmResolver { check(compilation.target.project == project) - return byCompilation[compilation] ?: error("$compilation was not registered in $this") + return byCompilation[compilation.name] ?: error("$compilation was not registered in $this") } private var closed = false @@ -103,7 +106,7 @@ internal class KotlinProjectNpmResolver( private fun addCompilation(compilation: KotlinJsCompilation) { check(!closed) { resolver.alreadyResolvedMessage("add compilation $compilation") } - byCompilation[compilation] = KotlinCompilationNpmResolver(this, compilation) + byCompilation[compilation.name] = KotlinCompilationNpmResolver(this, compilation) } fun close(): KotlinProjectNpmResolution { @@ -111,9 +114,9 @@ internal class KotlinProjectNpmResolver( closed = true return KotlinProjectNpmResolution( - project, + projectPath, byCompilation.values.mapNotNull { it.close() }, - resolver.nodeJs.taskRequirements.byTask + resolver.nodeJs.taskRequirements?.byTask ) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt index 7caf2838bea..df23d27cc99 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt @@ -124,8 +124,8 @@ internal class KotlinRootNpmResolver internal constructor( } } - open inner class Installation(val projectResolutions: Map) { - operator fun get(project: Project) = + open inner class Installation(val projectResolutions: Map) { + operator fun get(project: String) = projectResolutions[project] ?: KotlinProjectNpmResolution.empty(project) internal fun install( diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt index e22c0632703..596b93f6eef 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt @@ -30,7 +30,7 @@ open class KotlinNpmInstallTask : DefaultTask() { init { // TODO: temporary workaround for configuration cache enabled builds - disableTaskOnConfigurationCacheBuild { resolutionManager.toString() } +// disableTaskOnConfigurationCacheBuild { resolutionManager.toString() } } @Input diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt index 02d2a638cb4..17471c9e3e3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt @@ -107,7 +107,7 @@ open class KotlinPackageJsonTask : DefaultTask() { task.inputs.file(packageJsonTask.map { it.packageJson }) } - nodeJs.rootPackageJsonTaskProvider.configure { it.mustRunAfter(packageJsonTask) } + nodeJs.rootPackageJsonTaskProvider?.configure { it.mustRunAfter(packageJsonTask) } compilation.compileKotlinTaskProvider.dependsOn(npmInstallTask) compilation.compileKotlinTaskProvider.dependsOn(packageJsonTask) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt index 4752a92f68c..233075a0e3f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt @@ -31,7 +31,7 @@ open class RootPackageJsonTask : DefaultTask() { init { // TODO: temporary workaround for configuration cache enabled builds - disableTaskOnConfigurationCacheBuild { resolutionManager.toString() } +// disableTaskOnConfigurationCacheBuild { resolutionManager.toString() } } @get:OutputFile From 4566b7c6e5ce815866eaa53b99c7c2492b1484cb Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Thu, 17 Dec 2020 19:08:30 +0300 Subject: [PATCH 092/368] [Gradle, JS] rootPackageJson and kotlinNpmInstall cache-friendly --- .../gradle/targets/js/dukat/DukatTask.kt | 5 +- .../targets/js/nodejs/NodeJsRootExtension.kt | 4 +- .../js/npm/KotlinNpmResolutionManager.kt | 41 +++++++++------ .../kotlin/gradle/targets/js/npm/NpmApi.kt | 16 ++++-- .../gradle/targets/js/npm/NpmDependency.kt | 8 +-- .../js/npm/PackageJsonUpToDateCheck.kt | 9 ++-- .../targets/js/npm/PublicPackageJsonTask.kt | 5 +- .../KotlinCompilationNpmResolution.kt | 7 +-- .../npm/resolved/KotlinRootNpmResolution.kt | 2 +- .../resolver/KotlinCompilationNpmResolver.kt | 3 +- .../js/npm/resolver/KotlinRootNpmResolver.kt | 38 ++++++++++---- .../js/npm/tasks/KotlinNpmInstallTask.kt | 9 ++-- .../js/npm/tasks/KotlinPackageJsonTask.kt | 4 +- .../js/npm/tasks/RootPackageJsonTask.kt | 2 +- .../targets/js/webpack/KotlinWebpack.kt | 1 - .../kotlin/gradle/targets/js/yarn/Yarn.kt | 31 ++++++++--- .../gradle/targets/js/yarn/YarnBasics.kt | 17 +++--- .../YarnImportedPackagesVersionResolver.kt | 5 +- .../targets/js/yarn/YarnRootExtension.kt | 5 +- .../gradle/targets/js/yarn/YarnSimple.kt | 39 +++++++++----- .../gradle/targets/js/yarn/YarnWorkspaces.kt | 52 +++++++++++++------ 21 files changed, 203 insertions(+), 100 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt index 8e8a301cce1..6fba6c1d5a3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt @@ -44,7 +44,10 @@ abstract class DukatTask( @get:Internal @delegate:Transient val dts by lazy { - val resolvedCompilation = nodeJs.npmResolutionManager.requireInstalled()[project.path][compilation] + val resolvedCompilation = nodeJs.npmResolutionManager.requireInstalled( + services, + logger + )[project.path][compilation] val dtsResolver = DtsResolver(resolvedCompilation.npmProject) dtsResolver.getAllDts( resolvedCompilation.externalNpmDependencies, diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt index 40d24af42df..f2e39b2e1e3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt @@ -57,8 +57,8 @@ open class NodeJsRootExtension(@Transient val rootProject: Project) : Configurat val nodeJsSetupTaskProvider: TaskProvider get() = rootProject.tasks.withType(NodeJsSetupTask::class.java).named(NodeJsSetupTask.NAME) - val npmInstallTaskProvider: TaskProvider - get() = rootProject.tasks.withType(KotlinNpmInstallTask::class.java).named(KotlinNpmInstallTask.NAME) + val npmInstallTaskProvider: TaskProvider? + get() = rootProject?.tasks?.withType(KotlinNpmInstallTask::class.java)?.named(KotlinNpmInstallTask.NAME) val packageJsonUmbrellaTaskProvider: TaskProvider get() = rootProject.tasks.named(PACKAGE_JSON_UMBRELLA_TASK_NAME) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt index 9bded47c85b..83c879f4066 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt @@ -6,8 +6,10 @@ package org.jetbrains.kotlin.gradle.targets.js.npm import org.gradle.api.Incubating -import org.gradle.api.Project import org.gradle.api.Task +import org.gradle.api.internal.project.ProjectInternal +import org.gradle.api.logging.Logger +import org.gradle.internal.service.ServiceRegistry import org.jetbrains.kotlin.gradle.internal.isInIdeaSync import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinCompilationNpmResolution @@ -116,7 +118,10 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension } @Incubating - internal fun requireInstalled() = installIfNeeded(reason = "") + internal fun requireInstalled( + services: ServiceRegistry, + logger: Logger + ) = installIfNeeded(reason = "", services = services, logger = logger) internal fun requireConfiguringState(): KotlinRootNpmResolver = (this.state as? ResolutionState.Configuring ?: error("NPM Dependencies already resolved and installed")).resolver @@ -124,23 +129,25 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension internal fun isConfiguringState(): Boolean = this.state is ResolutionState.Configuring - internal fun prepare() = prepareIfNeeded(requireNotPrepared = true) + internal fun prepare(logger: Logger) = prepareIfNeeded(requireNotPrepared = true, logger = logger) internal fun installIfNeeded( reason: String? = "", - args: List = emptyList() + args: List = emptyList(), + services: ServiceRegistry, + logger: Logger ): KotlinRootNpmResolution { synchronized(this) { if (state is ResolutionState.Installed) { return (state as ResolutionState.Installed).resolved } - val installUpToDate = nodeJsSettings.npmInstallTaskProvider.get().state.upToDate + val installUpToDate = nodeJsSettings.npmInstallTaskProvider?.get()?.state?.upToDate ?: false val forceUpToDate = installUpToDate && !forceFullResolve - val installation = prepareIfNeeded(requireUpToDateReason = reason) + val installation = prepareIfNeeded(requireUpToDateReason = reason, logger = logger) val resolution = installation - .install(forceUpToDate, args) + .install(forceUpToDate, args, services, logger) state = ResolutionState.Installed(resolution) installation.closePlugins(resolution) @@ -149,8 +156,8 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension } } - internal fun requireAlreadyInstalled(project: Project, reason: String = ""): KotlinProjectNpmResolution = - installIfNeeded(reason = reason)[project.path] +// internal fun requireAlreadyInstalled(project: Project, reason: String = ""): KotlinProjectNpmResolution = +// installIfNeeded(reason = reason)[project.path] internal val packageJsonFiles: Collection get() = state.npmProjects.map { it.packageJsonFile } @@ -162,7 +169,8 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension */ private fun prepareIfNeeded( requireUpToDateReason: String? = null, - requireNotPrepared: Boolean = false + requireNotPrepared: Boolean = false, + logger: Logger ): KotlinRootNpmResolver.Installation { fun alreadyResolved(installation: KotlinRootNpmResolver.Installation): KotlinRootNpmResolver.Installation { if (requireNotPrepared) error("Project already prepared") @@ -183,7 +191,7 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension error("NPM dependencies should be resolved $requireUpToDateReason") } - state1.resolver.prepareInstallation().also { + state1.resolver.prepareInstallation(logger).also { this.state = ResolutionState.Prepared(it) } } @@ -196,23 +204,26 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension } internal fun getNpmDependencyResolvedCompilation(npmDependency: NpmDependency): KotlinCompilationNpmResolution? { - val project = npmDependency.project.path + val project = npmDependency.project!! + val projectPath = project.path + val services = (project as ProjectInternal).services + val logger = project.logger val resolvedProject = if (forceFullResolve) { - installIfNeeded(reason = null)[project] + installIfNeeded(reason = null, services = services, logger = logger)[projectPath] } else { // may return null only during npm resolution // (it can be called since NpmDependency added to configuration that // requires resolve to build package.json, in this case we should just skip this call) val state0 = state when (state0) { - is ResolutionState.Prepared -> state0.preparedInstallation[project] + is ResolutionState.Prepared -> state0.preparedInstallation[projectPath] is ResolutionState.Configuring -> { return null //error("Cannot use NpmDependency before :kotlinNpmInstall task execution") } - is ResolutionState.Installed -> state0.resolved[project] + is ResolutionState.Installed -> state0.resolved[projectPath] } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmApi.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmApi.kt index 5f448cec8b0..bf7e3a649b2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmApi.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmApi.kt @@ -6,6 +6,9 @@ package org.jetbrains.kotlin.gradle.targets.js.npm import org.gradle.api.Project +import org.gradle.api.logging.Logger +import org.gradle.internal.service.ServiceRegistry +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinCompilationNpmResolution import java.io.File @@ -17,16 +20,23 @@ interface NpmApi { fun resolveProject(resolvedNpmProject: KotlinCompilationNpmResolution) - fun preparedFiles(project: Project): Collection + fun preparedFiles(nodeJs: NodeJsRootExtension): Collection fun prepareRootProject( - rootProject: Project, + rootProject: Project?, + nodeJs: NodeJsRootExtension, + rootProjectName: String, + rootProjectVersion: String, + logger: Logger, subProjects: Collection, resolutions: Map ) fun resolveRootProject( - rootProject: Project, + services: ServiceRegistry, + logger: Logger, + nodeJs: NodeJsRootExtension, + yarnHome: File, npmProjects: Collection, skipExecution: Boolean, cliArgs: List diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependency.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependency.kt index 37f1dc0bfd1..c0321e89437 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependency.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmDependency.kt @@ -22,7 +22,7 @@ import java.io.File data class NpmDependency( @Transient - internal val project: Project, + internal val project: Project?, private val name: String, private val version: String, val scope: Scope = Scope.NORMAL, @@ -82,7 +82,7 @@ data class NpmDependency( // (it can be called since NpmDependency added to configuration that // requires resolve to build package.json, in this case we should just skip this call) private fun resolveProject(): KotlinCompilationNpmResolution? { - val nodeJs = NodeJsRootPlugin.apply(project.rootProject) + val nodeJs = NodeJsRootPlugin.apply(project!!.rootProject) return nodeJs.npmResolutionManager.getNpmDependencyResolvedCompilation(this) } @@ -90,7 +90,7 @@ data class NpmDependency( override fun toString() = "$key: $version" - override fun getFiles(): FileCollection = project.files(resolve(true)) + override fun getFiles(): FileCollection = project!!.files(resolve(true)) override fun getName() = name @@ -100,7 +100,7 @@ data class NpmDependency( override fun contentEquals(dependency: Dependency) = this == dependency - override fun getTargetComponentId() = DefaultLibraryBinaryIdentifier(project.path, key, "npm") + override fun getTargetComponentId() = DefaultLibraryBinaryIdentifier(project!!.path, key, "npm") override fun copy(): Dependency = this.copy(name = name) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJsonUpToDateCheck.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJsonUpToDateCheck.kt index 5797199620d..25a1e3e6149 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJsonUpToDateCheck.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PackageJsonUpToDateCheck.kt @@ -8,13 +8,12 @@ package org.jetbrains.kotlin.gradle.targets.js.npm import org.gradle.api.Project import org.gradle.api.internal.project.ProjectInternal import org.gradle.internal.hash.FileHasher +import org.gradle.internal.service.ServiceRegistry import org.jetbrains.kotlin.daemon.common.toHexString import org.jetbrains.kotlin.gradle.internal.ensureParentDirsCreated import java.io.File -class PackageJsonUpToDateCheck(val npmProject: NpmProject) { - val project: Project - get() = npmProject.project +class PackageJsonUpToDateCheck(val services: ServiceRegistry, val npmProject: NpmProject) { private val NpmProject.packageJsonHashFile: File get() = dir.resolve("package.json.hash") @@ -24,10 +23,10 @@ class PackageJsonUpToDateCheck(val npmProject: NpmProject) { if (packageJsonHashFile.exists()) packageJsonHashFile.readText() else null } - private val packageJsonFile = npmProject.prePackageJsonFile + private val packageJsonFile = npmProject.packageJsonFile private val hash by lazy { - val hasher = (project as ProjectInternal).services.get(FileHasher::class.java) + val hasher = services.get(FileHasher::class.java) hasher.hash(packageJsonFile).toByteArray().toHexString() } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt index 5dc14a85fdd..66f89858a39 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt @@ -27,7 +27,10 @@ constructor( private val nodeJs = npmProject.nodeJs private val compilationResolution - get() = nodeJs.npmResolutionManager.requireInstalled()[project.path][npmProject.compilation] + get() = nodeJs.npmResolutionManager.requireInstalled( + services, + logger + )[project.path][npmProject.compilation] init { // TODO: temporary workaround for configuration cache enabled builds diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt index 881aaa72be3..3e7cb76e907 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt @@ -14,8 +14,7 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.* class KotlinCompilationNpmResolution( @Transient private val _project: Project?, - @Transient - private val _npmProject: NpmProject?, + val npmProject: NpmProject, val internalDependencies: Collection, val internalCompositeDependencies: Collection, val externalGradleDependencies: Collection, @@ -24,14 +23,12 @@ class KotlinCompilationNpmResolution( ) { val project get() = _project!! - val npmProject - get() = _npmProject!! val externalNpmDependencies get() = _externalNpmDependencies .map { NpmDependency( - project = project, + project = _project, name = it.name, version = it.version, scope = it.scope, diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinRootNpmResolution.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinRootNpmResolution.kt index 2bfb3e4c3d5..970d7c0f456 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinRootNpmResolution.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinRootNpmResolution.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.gradle.targets.js.npm.resolved import org.gradle.api.Project internal class KotlinRootNpmResolution( - val rootProject: Project, + val rootProject: Project?, internal val projects: Map ) { operator fun get(project: String) = projects[project] ?: KotlinProjectNpmResolution.empty(project) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt index 1eb613de7b6..ca01e9fd36b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt @@ -59,7 +59,6 @@ internal class KotlinCompilationNpmResolver( resolver.compositeNodeModules } - @Transient val npmProject = compilation.npmProject val compilationName = compilation.name @@ -463,7 +462,7 @@ internal class KotlinCompilationNpmResolver( return KotlinCompilationNpmResolution( if (compilation != null) project else null, - if (compilation != null) npmProject else null, + npmProject, resolvedInternalDependencies, compositeDependencies, importedExternalGradleDependencies, diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt index df23d27cc99..27a35745130 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinRootNpmResolver.kt @@ -6,7 +6,8 @@ package org.jetbrains.kotlin.gradle.targets.js.npm.resolver import org.gradle.api.Project -import org.gradle.api.Task +import org.gradle.api.logging.Logger +import org.gradle.internal.service.ServiceRegistry import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation import org.jetbrains.kotlin.gradle.plugin.mpp.isMain import org.jetbrains.kotlin.gradle.targets.js.dukat.DukatRootResolverPlugin @@ -22,7 +23,6 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinProjectNpmResol import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinRootNpmResolution import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin import org.jetbrains.kotlin.gradle.targets.js.yarn.toVersionString -import org.jetbrains.kotlin.gradle.tasks.registerTask /** * See [KotlinNpmResolutionManager] for details about resolution process. @@ -34,6 +34,14 @@ internal class KotlinRootNpmResolver internal constructor( val rootProject: Project get() = nodeJs.rootProject + val rootProjectName by lazy { + rootProject.name + } + + val rootProjectVersion by lazy { + rootProject.version.toString() + } + val plugins = mutableListOf().also { it.add(DukatRootResolverPlugin(this)) } @@ -51,6 +59,10 @@ internal class KotlinRootNpmResolver internal constructor( val compositeNodeModules = CompositeNodeModulesCache(nodeJs) val projectResolvers = mutableMapOf() + val yarn by lazy { + YarnPlugin.apply(rootProject) + } + fun alreadyResolvedMessage(action: String) = "Cannot $action. NodeJS projects already resolved." @Synchronized @@ -95,7 +107,7 @@ internal class KotlinRootNpmResolver internal constructor( /** * Don't use directly, use [KotlinNpmResolutionManager.installIfNeeded] instead. */ - internal fun prepareInstallation(): Installation { + internal fun prepareInstallation(logger: Logger): Installation { synchronized(this@KotlinRootNpmResolver) { check(state == State.CONFIGURING) { "Projects must be configuring" @@ -109,14 +121,15 @@ internal class KotlinRootNpmResolver internal constructor( gradleNodeModules.close() - val yarn = YarnPlugin.apply(rootProject) - nodeJs.packageManager.prepareRootProject( rootProject, + nodeJs, + rootProjectName, + rootProjectVersion, + logger, allNpmPackages, yarn.resolutions - .associate { it.path to it.toVersionString() } - ) + .associate { it.path to it.toVersionString() }) return Installation( projectResolutions @@ -130,7 +143,9 @@ internal class KotlinRootNpmResolver internal constructor( internal fun install( forceUpToDate: Boolean, - args: List + args: List, + services: ServiceRegistry, + logger: Logger ): KotlinRootNpmResolution { synchronized(this@KotlinRootNpmResolver) { check(state == State.PROJECTS_CLOSED) { @@ -147,12 +162,15 @@ internal class KotlinRootNpmResolver internal constructor( // we should call it even kotlinNpmInstall task is up-to-date (skipPackageManager is true) // because our upToDateChecks saves state for next execution val upToDateChecks = allNpmPackages.map { - PackageJsonUpToDateCheck(it.npmProject) + PackageJsonUpToDateCheck(services, it.npmProject) } val upToDate = forceUpToDate || upToDateChecks.all { it.upToDate } nodeJs.packageManager.resolveRootProject( - nodeJs.rootProject, + services, + logger, + nodeJs, + yarn.requireConfigured().home, allNpmPackages, upToDate, args diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt index 596b93f6eef..cba0bf1e356 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt @@ -11,7 +11,6 @@ import org.gradle.api.tasks.InputFiles import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.TaskAction import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin -import org.jetbrains.kotlin.gradle.utils.disableTaskOnConfigurationCacheBuild import java.io.File open class KotlinNpmInstallTask : DefaultTask() { @@ -44,7 +43,7 @@ open class KotlinNpmInstallTask : DefaultTask() { @get:InputFiles val preparedFiles: Collection by lazy { - nodeJs.packageManager.preparedFiles(project) + nodeJs.packageManager.preparedFiles(nodeJs) } // avoid using node_modules as output directory, as it is significantly slows down build @@ -58,7 +57,11 @@ open class KotlinNpmInstallTask : DefaultTask() { @TaskAction fun resolve() { - resolutionManager.installIfNeeded(args = args) + resolutionManager.installIfNeeded( + args = args, + services = services, + logger = logger + ) } companion object { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt index 17471c9e3e3..054c0a7ae0d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt @@ -107,9 +107,9 @@ open class KotlinPackageJsonTask : DefaultTask() { task.inputs.file(packageJsonTask.map { it.packageJson }) } - nodeJs.rootPackageJsonTaskProvider?.configure { it.mustRunAfter(packageJsonTask) } + nodeJs.rootPackageJsonTaskProvider!!.configure { it.mustRunAfter(packageJsonTask) } - compilation.compileKotlinTaskProvider.dependsOn(npmInstallTask) + compilation.compileKotlinTaskProvider.dependsOn(npmInstallTask!!) compilation.compileKotlinTaskProvider.dependsOn(packageJsonTask) return packageJsonTask diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt index 233075a0e3f..d3eccdd8f7d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt @@ -40,7 +40,7 @@ open class RootPackageJsonTask : DefaultTask() { @TaskAction fun resolve() { - resolutionManager.prepare() + resolutionManager.prepare(logger) } companion object { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt index c4a6f29f646..8bbaf8adac2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt @@ -250,7 +250,6 @@ constructor( @TaskAction fun doExecute() { - println(services.get(org.gradle.internal.logging.progress.ProgressLoggerFactory::class.java)) // nodeJs.npmResolutionManager?.checkRequiredDependencies(this) val runner = createRunner() diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/Yarn.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/Yarn.kt index 7d86b8fc623..dfd94628fd8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/Yarn.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/Yarn.kt @@ -6,6 +6,9 @@ package org.jetbrains.kotlin.gradle.targets.js.yarn import org.gradle.api.Project +import org.gradle.api.logging.Logger +import org.gradle.internal.service.ServiceRegistry +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.targets.js.npm.NpmApi import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinCompilationNpmResolution @@ -25,29 +28,43 @@ class Yarn : NpmApi { override fun resolveProject(resolvedNpmProject: KotlinCompilationNpmResolution) = getDelegate(resolvedNpmProject.project).resolveProject(resolvedNpmProject) - override fun preparedFiles(project: Project): Collection = - getDelegate(project).preparedFiles(project) + override fun preparedFiles(nodeJs: NodeJsRootExtension): Collection = + yarnWorkspaces.preparedFiles(nodeJs) override fun prepareRootProject( - rootProject: Project, + rootProject: Project?, + nodeJs: NodeJsRootExtension, + rootProjectName: String, + rootProjectVersion: String, + logger: Logger, subProjects: Collection, resolutions: Map - ) = getDelegate(rootProject.project) + ) = yarnWorkspaces .prepareRootProject( rootProject, + nodeJs, + rootProjectName, + rootProjectVersion, + logger, subProjects, resolutions ) override fun resolveRootProject( - rootProject: Project, + services: ServiceRegistry, + logger: Logger, + nodeJs: NodeJsRootExtension, + yarnHome: File, npmProjects: Collection, skipExecution: Boolean, cliArgs: List ) { - getDelegate(rootProject.project) + yarnWorkspaces .resolveRootProject( - rootProject, + services, + logger, + nodeJs, + yarnHome, npmProjects, skipExecution, cliArgs diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnBasics.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnBasics.kt index b34d8ca1280..7d2697df6be 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnBasics.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnBasics.kt @@ -7,7 +7,10 @@ package org.jetbrains.kotlin.gradle.targets.js.yarn import org.gradle.api.Project import org.gradle.api.internal.project.ProjectInternal +import org.gradle.api.logging.Logger +import org.gradle.internal.service.ServiceRegistry import org.jetbrains.kotlin.gradle.internal.execWithProgress +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin import org.jetbrains.kotlin.gradle.targets.js.npm.NpmApi import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency @@ -25,19 +28,19 @@ abstract class YarnBasics : NpmApi { } fun yarnExec( - project: Project, + services: ServiceRegistry, + logger: Logger, + nodeJs: NodeJsRootExtension, + yarnHome: File, dir: File, description: String, args: List ) { - val nodeJs = NodeJsRootPlugin.apply(project) - val yarnPlugin = YarnPlugin.apply(project) - - (project as ProjectInternal).services.execWithProgress(description) { exec -> + services.execWithProgress(description) { exec -> exec.executable = nodeJs.requireConfigured().nodeExecutable - exec.args = listOf(yarnPlugin.requireConfigured().home.resolve("bin/yarn.js").absolutePath) + + exec.args = listOf(yarnHome.resolve("bin/yarn.js").absolutePath) + args + - if (project.logger.isDebugEnabled) "--verbose" else "" + if (logger.isDebugEnabled) "--verbose" else "" exec.workingDir = dir } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnImportedPackagesVersionResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnImportedPackagesVersionResolver.kt index e92d5a3dbea..61e0229789f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnImportedPackagesVersionResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnImportedPackagesVersionResolver.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle.targets.js.yarn import com.google.gson.Gson import org.gradle.api.Project +import org.gradle.api.logging.Logger import org.jetbrains.kotlin.gradle.targets.js.npm.GradleNodeModule import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject import org.jetbrains.kotlin.gradle.targets.js.npm.PackageJson @@ -15,7 +16,7 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinCompilationNpmR import java.io.File class YarnImportedPackagesVersionResolver( - private val rootProject: Project, + private val logger: Logger, private val npmProjects: Collection, private val nodeJsWorldDir: File ) { @@ -53,7 +54,7 @@ class YarnImportedPackagesVersionResolver( modules.groupBy { it.name }.forEach { (name, versions) -> val selected: GradleNodeModule = if (versions.size > 1) { val sorted = versions.sortedBy { it.semver } - rootProject.logger.warn( + logger.warn( "There are multiple versions of \"$name\" used in nodejs build: ${sorted.joinToString(", ") { it.version }}. " + "Only latest version will be used." ) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootExtension.kt index fa6c33e3471..f44a3d4ab5a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnRootExtension.kt @@ -17,7 +17,10 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.resolver.implementing import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.RootPackageJsonTask import org.jetbrains.kotlin.gradle.tasks.internal.CleanableStore -open class YarnRootExtension(val project: Project) : ConfigurationPhaseAware() { +open class YarnRootExtension( + @Transient + val project: Project +) : ConfigurationPhaseAware() { init { check(project == project.rootProject) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnSimple.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnSimple.kt index 5a2f15b0a6b..85c121aef6a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnSimple.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnSimple.kt @@ -6,6 +6,11 @@ package org.jetbrains.kotlin.gradle.targets.js.yarn import org.gradle.api.Project +import org.gradle.api.internal.project.ProjectInternal +import org.gradle.api.logging.Logger +import org.gradle.internal.service.ServiceRegistry +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin import org.jetbrains.kotlin.gradle.targets.js.npm.NpmApi import org.jetbrains.kotlin.gradle.targets.js.npm.PackageJsonUpToDateCheck import org.jetbrains.kotlin.gradle.targets.js.npm.resolved.KotlinCompilationNpmResolution @@ -17,28 +22,38 @@ class YarnSimple : YarnBasics() { val project = resolvedNpmProject.project - PackageJsonUpToDateCheck(resolvedNpmProject.npmProject).updateIfNeeded { - yarnExec( - project, - resolvedNpmProject.npmProject.dir, - NpmApi.resolveOperationDescription("yarn for ${project.path}"), - emptyList() - ) - yarnLockReadTransitiveDependencies(resolvedNpmProject.npmProject.dir, resolvedNpmProject.externalNpmDependencies) - } +// PackageJsonUpToDateCheck(resolvedNpmProject.npmProject).updateIfNeeded { +// yarnExec( +// (project as ProjectInternal).services, +// project.logger, +// NodeJsRootPlugin.apply(project), +// YarnPlugin.apply(project).requireConfigured().home, +// resolvedNpmProject.npmProject.dir, +// NpmApi.resolveOperationDescription("yarn for ${project.path}"), +// emptyList() +// ) +// yarnLockReadTransitiveDependencies(resolvedNpmProject.npmProject.dir, resolvedNpmProject.externalNpmDependencies) +// } } - override fun preparedFiles(project: Project): Collection = + override fun preparedFiles(nodeJs: NodeJsRootExtension): Collection = emptyList() override fun prepareRootProject( - rootProject: Project, + rootProject: Project?, + nodeJs: NodeJsRootExtension, + rootProjectName: String, + rootProjectVersion: String, + logger: Logger, subProjects: Collection, resolutions: Map ) = Unit override fun resolveRootProject( - rootProject: Project, + services: ServiceRegistry, + logger: Logger, + nodeJs: NodeJsRootExtension, + yarnHome: File, npmProjects: Collection, skipExecution: Boolean, cliArgs: List diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnWorkspaces.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnWorkspaces.kt index fc6c0a57dda..7da3e68c2e0 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnWorkspaces.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/yarn/YarnWorkspaces.kt @@ -6,6 +6,9 @@ package org.jetbrains.kotlin.gradle.targets.js.yarn import org.gradle.api.Project +import org.gradle.api.logging.Logger +import org.gradle.internal.service.ServiceRegistry +import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin import org.jetbrains.kotlin.gradle.targets.js.npm.NpmApi import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject @@ -16,37 +19,49 @@ import java.io.File class YarnWorkspaces : YarnBasics() { override fun resolveProject(resolvedNpmProject: KotlinCompilationNpmResolution) = Unit - override fun preparedFiles(project: Project): Collection { + override fun preparedFiles(nodeJs: NodeJsRootExtension): Collection { return listOf( - NodeJsRootPlugin.apply(project.rootProject) + nodeJs .rootPackageDir .resolve(NpmProject.PACKAGE_JSON) ) } override fun prepareRootProject( - rootProject: Project, + rootProject: Project?, + nodeJs: NodeJsRootExtension, + rootProjectName: String, + rootProjectVersion: String, + logger: Logger, subProjects: Collection, resolutions: Map ) { - check(rootProject == rootProject.rootProject) - setup(rootProject) +// check(rootProject == rootProject.rootProject) + rootProject?.let { setup(it) } return prepareRootPackageJson( - rootProject, + nodeJs, + rootProjectName, + rootProjectVersion, + logger, subProjects, resolutions ) } private fun prepareRootPackageJson( - rootProject: Project, + nodeJs: NodeJsRootExtension, + rootProjectName: String, + rootProjectVersion: String, + logger: Logger, npmProjects: Collection, resolutions: Map ) { - val rootPackageJsonFile = preparedFiles(rootProject).single() + val rootPackageJsonFile = preparedFiles(nodeJs).single() saveRootProjectWorkspacesPackageJson( - rootProject, + rootProjectName, + rootProjectVersion, + logger, npmProjects, resolutions, rootPackageJsonFile @@ -54,16 +69,21 @@ class YarnWorkspaces : YarnBasics() { } override fun resolveRootProject( - rootProject: Project, + services: ServiceRegistry, + logger: Logger, + nodeJs: NodeJsRootExtension, + yarnHome: File, npmProjects: Collection, skipExecution: Boolean, cliArgs: List ) { - val nodeJs = NodeJsRootPlugin.apply(rootProject) val nodeJsWorldDir = nodeJs.rootPackageDir yarnExec( - rootProject, + services, + logger, + nodeJs, + yarnHome, nodeJsWorldDir, NpmApi.resolveOperationDescription("yarn"), cliArgs @@ -74,18 +94,20 @@ class YarnWorkspaces : YarnBasics() { } private fun saveRootProjectWorkspacesPackageJson( - rootProject: Project, + rootProjectName: String, + rootProjectVersion: String, + logger: Logger, npmProjects: Collection, resolutions: Map, rootPackageJsonFile: File ) { val nodeJsWorldDir = rootPackageJsonFile.parentFile - val rootPackageJson = PackageJson(rootProject.name, rootProject.version.toString()) + val rootPackageJson = PackageJson(rootProjectName, rootProjectVersion) rootPackageJson.private = true val npmProjectWorkspaces = npmProjects.map { it.npmProject.dir.relativeTo(nodeJsWorldDir).path } val importedProjectWorkspaces = - YarnImportedPackagesVersionResolver(rootProject, npmProjects, nodeJsWorldDir).resolveAndUpdatePackages() + YarnImportedPackagesVersionResolver(logger, npmProjects, nodeJsWorldDir).resolveAndUpdatePackages() rootPackageJson.workspaces = npmProjectWorkspaces + importedProjectWorkspaces rootPackageJson.resolutions = resolutions From 521b722c098a221b46aa3932c5c61a569b11c53f Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Fri, 18 Dec 2020 14:10:11 +0300 Subject: [PATCH 093/368] [Gradle, JS] Compilation to compilationName --- .../dukat/DukatCompilationResolverPlugin.kt | 18 ++++++--- .../gradle/targets/js/dukat/DukatTask.kt | 38 +++++++++++-------- .../gradle/targets/js/npm/NpmProject.kt | 2 + .../targets/js/npm/PublicPackageJsonTask.kt | 32 +++++++++------- .../resolved/KotlinProjectNpmResolution.kt | 8 ++-- 5 files changed, 60 insertions(+), 38 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt index bfabb774b3c..5784a37fc39 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt @@ -26,6 +26,16 @@ internal class DukatCompilationResolverPlugin( val nodeJs get() = resolver.nodeJs val npmProject get() = resolver.npmProject val compilation get() = npmProject.compilation + val compilationName by lazy { + compilation.name + } + val legacyTargetReuseIrTask by lazy { + val target = compilation.target + target is KotlinJsTarget && (target.irTarget != null && externalsOutputFormat == ExternalsOutputFormat.SOURCE) + } + val externalsOutputFormat by lazy { + compilation.externalsOutputFormat + } val integratedTaskName = npmProject.compilation.disambiguateName("generateExternalsIntegrated") val separateTaskName = npmProject.compilation.disambiguateName("generateExternals") @@ -86,12 +96,10 @@ internal class DukatCompilationResolverPlugin( packageJsonIsUpdated: Boolean, resolution: KotlinRootNpmResolution ) { - val externalNpmDependencies = resolution[project.path][compilation].externalNpmDependencies + val externalNpmDependencies = resolution[project.path][compilationName].externalNpmDependencies + + - val target = compilation.target - val externalsOutputFormat = compilation.externalsOutputFormat - val legacyTargetReuseIrTask = - target is KotlinJsTarget && (target.irTarget != null && externalsOutputFormat == ExternalsOutputFormat.SOURCE) if (legacyTargetReuseIrTask) { return } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt index 6fba6c1d5a3..b4a85cb5999 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt @@ -11,7 +11,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation import org.jetbrains.kotlin.gradle.targets.js.RequiredKotlinJsDependency import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies -import org.jetbrains.kotlin.gradle.utils.disableTaskOnConfigurationCacheBuild import java.io.File abstract class DukatTask( @@ -20,11 +19,17 @@ abstract class DukatTask( override val compilation: KotlinJsCompilation ) : DefaultTask(), RequiresNpmDependencies { @get:Internal + @Transient protected val nodeJs = NodeJsRootPlugin.apply(project.rootProject) + @get:Internal + val compilationName by lazy { + compilation.name + } + init { // TODO: temporary workaround for configuration cache enabled builds - disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() } +// disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() } } @get:Internal @@ -41,19 +46,22 @@ abstract class DukatTask( @Input var externalsOutputFormat: ExternalsOutputFormat = ExternalsOutputFormat.SOURCE + private val compilationResolution + get() = + nodeJs.npmResolutionManager.requireInstalled( + services, + logger + )[project.path][compilationName] + @get:Internal - @delegate:Transient - val dts by lazy { - val resolvedCompilation = nodeJs.npmResolutionManager.requireInstalled( - services, - logger - )[project.path][compilation] - val dtsResolver = DtsResolver(resolvedCompilation.npmProject) - dtsResolver.getAllDts( - resolvedCompilation.externalNpmDependencies, - considerGeneratingFlag - ) - } + val dts: List + get() { + val dtsResolver = DtsResolver(compilationResolution.npmProject) + return dtsResolver.getAllDts( + compilationResolution.externalNpmDependencies, + considerGeneratingFlag + ) + } /** * Package name for the generated file (by default filename.d.ts renamed to filename.d.kt) @@ -87,7 +95,7 @@ abstract class DukatTask( @TaskAction open fun run() { - nodeJs.npmResolutionManager.checkRequiredDependencies(this) +// nodeJs.npmResolutionManager.checkRequiredDependencies(this) destinationDir.deleteRecursively() diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt index 229d93e83ae..8b5d9554b37 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt @@ -25,6 +25,8 @@ val KotlinJsCompilation.npmProject: NpmProject * More info can be obtained from [KotlinCompilationNpmResolution], which is available after project resolution (after [KotlinNpmInstallTask] execution). */ open class NpmProject(@Transient val compilation: KotlinJsCompilation) { + val compilationName = compilation.name + val name: String by lazy { buildNpmProjectName() } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt index 66f89858a39..c9998df5026 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt @@ -26,27 +26,30 @@ constructor( private val npmProject = compilation.npmProject private val nodeJs = npmProject.nodeJs - private val compilationResolution - get() = nodeJs.npmResolutionManager.requireInstalled( + private val compilationName = compilation.name + + private val compilationResolution by lazy { + nodeJs.npmResolutionManager.requireInstalled( services, logger - )[project.path][npmProject.compilation] + )[project.path][compilationName] + } init { // TODO: temporary workaround for configuration cache enabled builds - disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() } +// disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() } } - @get:Input - val packageJsonCustomFields: Map - get() = PackageJson(fakePackageJsonValue, fakePackageJsonValue) - .apply { - compilation.packageJsonHandlers.forEach { it() } - }.customFields +// @get:Input +// val packageJsonCustomFields: Map +// get() = PackageJson(fakePackageJsonValue, fakePackageJsonValue) +// .apply { +// compilation.packageJsonHandlers.forEach { it() } +// }.customFields @get:Nested - internal val externalDependencies: Collection - get() = compilationResolution.externalNpmDependencies + internal val externalDependencies: Collection by lazy { + compilationResolution.externalNpmDependencies .map { NpmDependencyDeclaration( scope = it.scope, @@ -55,6 +58,7 @@ constructor( generateExternals = it.generateExternals ) } + } private val publicPackageJsonTaskName = npmProject.publicPackageJsonTaskName @@ -68,8 +72,8 @@ constructor( @TaskAction fun resolve() { - val compilation = npmProject.compilation - +// val compilation = npmProject.compilation +// // packageJson(npmProject, realExternalDependencies).let { packageJson -> // packageJson.main = "${npmProject.name}.js" // diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt index dd5eb518a49..dd4ec78a944 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt @@ -30,11 +30,11 @@ class KotlinProjectNpmResolution( } } - val byCompilation by lazy { npmProjects.associateBy { it.npmProject.compilation.name } } + val byCompilation by lazy { npmProjects.associateBy { it.npmProject.compilationName } } - operator fun get(compilation: KotlinJsCompilation): KotlinCompilationNpmResolution { - check(compilation.target.project.path == project) - return byCompilation.getValue(compilation.name) + operator fun get(compilationName: String): KotlinCompilationNpmResolution { +// check(compilation.target.project.path == project) + return byCompilation.getValue(compilationName) } companion object { From 65faf2047222d2b4b26204304bea1f598e5dcc44 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Tue, 19 Jan 2021 18:09:26 +0300 Subject: [PATCH 094/368] [Gradle, JS] Make PublicPackageJsonTask cc-compatible --- .../dukat/DukatCompilationResolverPlugin.kt | 2 +- .../js/npm/AbstractNodeModulesCache.kt | 2 + .../targets/js/npm/PublicPackageJsonTask.kt | 85 ++++++++++--------- .../npm/plugins/CompilationResolverPlugin.kt | 3 +- .../resolver/KotlinCompilationNpmResolver.kt | 18 ++-- 5 files changed, 63 insertions(+), 47 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt index 5784a37fc39..8f00905fef7 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt @@ -85,7 +85,7 @@ internal class DukatCompilationResolverPlugin( internalCompositeDependencies: Set, externalGradleDependencies: Set, externalNpmDependencies: Set, - fileCollectionDependencies: Set + fileCollectionDependencies: Set ) { if (nodeJs.experimental.discoverTypes) { // todo: discoverTypes diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/AbstractNodeModulesCache.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/AbstractNodeModulesCache.kt index 712905f6a73..4639a5834ba 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/AbstractNodeModulesCache.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/AbstractNodeModulesCache.kt @@ -53,6 +53,8 @@ internal abstract class AbstractNodeModulesCache(nodeJs: NodeJsRootExtension) : } } +// Synchronized as tasks from configuration cache run in parallel and every task has it's own modules cache +@Synchronized fun makeNodeModule( container: File, packageJson: PackageJson, diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt index c9998df5026..b11fb9f8b51 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt @@ -11,8 +11,10 @@ import org.gradle.api.tasks.Nested import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.TaskAction import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation +import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrCompilation import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject.Companion.PACKAGE_JSON import org.jetbrains.kotlin.gradle.utils.disableTaskOnConfigurationCacheBuild +import org.jetbrains.kotlin.gradle.utils.getValue import org.jetbrains.kotlin.gradle.utils.property import java.io.File import javax.inject.Inject @@ -27,29 +29,32 @@ constructor( private val nodeJs = npmProject.nodeJs private val compilationName = compilation.name + private val projectPath = project.path + + private val compilationResolution + get() = nodeJs.npmResolutionManager.requireInstalled( + services, + logger + )[projectPath][compilationName] - private val compilationResolution by lazy { - nodeJs.npmResolutionManager.requireInstalled( - services, - logger - )[project.path][compilationName] - } init { // TODO: temporary workaround for configuration cache enabled builds // disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() } } -// @get:Input -// val packageJsonCustomFields: Map -// get() = PackageJson(fakePackageJsonValue, fakePackageJsonValue) -// .apply { -// compilation.packageJsonHandlers.forEach { it() } -// }.customFields + // TODO: is map contains only serializable values? + @get:Input + val packageJsonCustomFields: Map by lazy { + PackageJson(fakePackageJsonValue, fakePackageJsonValue) + .apply { + compilation.packageJsonHandlers.forEach { it() } + }.customFields + } @get:Nested - internal val externalDependencies: Collection by lazy { - compilationResolution.externalNpmDependencies + internal val externalDependencies: Collection + get() = compilationResolution.externalNpmDependencies .map { NpmDependencyDeclaration( scope = it.scope, @@ -58,40 +63,44 @@ constructor( generateExternals = it.generateExternals ) } + + private val publicPackageJsonTaskName by lazy { + npmProject.publicPackageJsonTaskName } - private val publicPackageJsonTaskName = npmProject.publicPackageJsonTaskName - - @get:OutputFile - var packageJsonFile: File by property { + private val defaultPackageJsonFile by lazy { project.buildDir .resolve("tmp") .resolve(publicPackageJsonTaskName) .resolve(PACKAGE_JSON) } + @get:OutputFile + var packageJsonFile: File by property { defaultPackageJsonFile } + + private val isJrIrCompilation = compilation is KotlinJsIrCompilation + private val projectVersion = project.version.toString() + @TaskAction fun resolve() { -// val compilation = npmProject.compilation -// -// packageJson(npmProject, realExternalDependencies).let { packageJson -> -// packageJson.main = "${npmProject.name}.js" -// -// if (compilation is KotlinJsIrCompilation) { -// packageJson.types = "${npmProject.name}.d.ts" -// } -// -// packageJson.apply { -// listOf( -// dependencies, -// devDependencies, -// peerDependencies, -// optionalDependencies -// ).forEach { it.processDependencies() } -// } -// -// packageJson.saveTo(this@PublicPackageJsonTask.packageJsonFile) -// } + packageJson(npmProject.name, projectVersion, npmProject.main, externalDependencies).let { packageJson -> + packageJson.main = "${npmProject.name}.js" + + if (isJrIrCompilation) { + packageJson.types = "${npmProject.name}.d.ts" + } + + packageJson.apply { + listOf( + dependencies, + devDependencies, + peerDependencies, + optionalDependencies + ).forEach { it.processDependencies() } + } + + packageJson.saveTo(this@PublicPackageJsonTask.packageJsonFile) + } } private fun MutableMap.processDependencies() { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/plugins/CompilationResolverPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/plugins/CompilationResolverPlugin.kt index 00f2aafa9aa..c1ba9e0f77b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/plugins/CompilationResolverPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/plugins/CompilationResolverPlugin.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.gradle.targets.js.npm.plugins -import org.gradle.api.artifacts.FileCollectionDependency import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency import org.jetbrains.kotlin.gradle.targets.js.npm.resolver.KotlinCompilationNpmResolver @@ -15,6 +14,6 @@ internal interface CompilationResolverPlugin { internalCompositeDependencies: Set, externalGradleDependencies: Set, externalNpmDependencies: Set, - fileCollectionDependencies: Set + fileCollectionDependencies: Set ) } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt index ca01e9fd36b..c6650cd2338 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt @@ -11,6 +11,7 @@ import org.gradle.api.artifacts.ResolvedArtifact import org.gradle.api.artifacts.ResolvedDependency import org.gradle.api.artifacts.component.ProjectComponentIdentifier import org.gradle.api.attributes.Usage +import org.gradle.api.file.FileCollection import org.gradle.api.initialization.IncludedBuild import org.gradle.api.internal.artifacts.DefaultProjectComponentIdentifier import org.gradle.api.tasks.Input @@ -210,6 +211,11 @@ internal class KotlinCompilationNpmResolver( val artifact: ResolvedArtifact ) + data class FileCollectionExternalGradleDependency( + val fileCollection: FileCollection, + val dependencyVersion: String? + ) + data class FileExternalGradleDependency( val dependencyName: String, val dependencyVersion: String, @@ -226,7 +232,7 @@ internal class KotlinCompilationNpmResolver( private val internalCompositeDependencies = mutableSetOf() private val externalGradleDependencies = mutableSetOf() private val externalNpmDependencies = mutableSetOf() - private val fileCollectionDependencies = mutableSetOf() + private val fileCollectionDependencies = mutableSetOf() fun visit(configuration: Configuration) { configuration.resolvedConfiguration.firstLevelModuleDependencies.forEach { @@ -236,7 +242,7 @@ internal class KotlinCompilationNpmResolver( configuration.allDependencies.forEach { dependency -> when (dependency) { is NpmDependency -> externalNpmDependencies.add(dependency) - is FileCollectionDependency -> fileCollectionDependencies.add(dependency) + is FileCollectionDependency -> fileCollectionDependencies.add(FileCollectionExternalGradleDependency(dependency.files, dependency.version)) } } @@ -369,7 +375,7 @@ internal class KotlinCompilationNpmResolver( val externalGradleDependencies: Collection, @Transient val externalNpmDependencies: Collection, - val fileCollectionDependencies: Collection + val fileCollectionDependencies: Collection ) { val externalNpmDependencyDeclarations by lazy { externalNpmDependencies.map { @@ -393,7 +399,7 @@ internal class KotlinCompilationNpmResolver( internalCompositeDependencies.flatMap { it.getPackages() }, fileExternalGradleDependencies.map { it.file }, externalNpmDependencyDeclarations.map { it.uniqueRepresentation() }, - fileCollectionDependencies.map { it.files }.flatMap { it.files } + fileCollectionDependencies.map{ it.fileCollection }.flatMap { it.files } ) fun createPackageJson(skipWriting: Boolean): KotlinCompilationNpmResolution { @@ -404,13 +410,13 @@ internal class KotlinCompilationNpmResolver( val importedExternalGradleDependencies = fileExternalGradleDependencies.mapNotNull { gradleNodeModules.get(it.dependencyName, it.dependencyVersion, it.file) } + fileCollectionDependencies.flatMap { dependency -> - dependency.files + dependency.fileCollection.files // Gradle can hash with FileHasher only files and only existed files .filter { it.isFile } .map { file -> gradleNodeModules.get( file.name, - dependency.version ?: "0.0.1", + dependency.dependencyVersion ?: "0.0.1", file ) } From da80d53796b65cae3454bc09fdd1fc076d1a1aa1 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Wed, 20 Jan 2021 12:54:51 +0300 Subject: [PATCH 095/368] [Gradle, JS] Make KotlinWebpack cc-compatible --- .../targets/js/nodejs/NodeJsRootExtension.kt | 3 +- .../targets/js/nodejs/TasksRequirements.kt | 1 - .../js/npm/KotlinNpmResolutionManager.kt | 31 +++++++++---------- .../resolved/KotlinProjectNpmResolution.kt | 2 +- .../gradle/targets/js/testing/KotlinJsTest.kt | 4 ++- .../targets/js/webpack/KotlinWebpack.kt | 23 +++++++++----- 6 files changed, 36 insertions(+), 28 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt index f2e39b2e1e3..742fd24630a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootExtension.kt @@ -51,8 +51,7 @@ open class NodeJsRootExtension(@Transient val rootProject: Project) : Configurat val experimental = Experimental() - @Transient - val taskRequirements = TasksRequirements() + val taskRequirements: TasksRequirements = TasksRequirements() val nodeJsSetupTaskProvider: TaskProvider get() = rootProject.tasks.withType(NodeJsSetupTask::class.java).named(NodeJsSetupTask.NAME) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt index 7339324692e..5679b63de25 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies import org.jetbrains.kotlin.gradle.targets.js.npm.toDeclaration class TasksRequirements { - @Transient private val _byTask = mutableMapOf>() private val byCompilation = mutableMapOf>() diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt index 83c879f4066..c598f1df086 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.gradle.targets.js.npm import org.gradle.api.Incubating +import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.internal.project.ProjectInternal import org.gradle.api.logging.Logger @@ -120,8 +121,9 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension @Incubating internal fun requireInstalled( services: ServiceRegistry, - logger: Logger - ) = installIfNeeded(reason = "", services = services, logger = logger) + logger: Logger, + reason: String = "" + ) = installIfNeeded(reason = reason, services = services, logger = logger) internal fun requireConfiguringState(): KotlinRootNpmResolver = (this.state as? ResolutionState.Configuring ?: error("NPM Dependencies already resolved and installed")).resolver @@ -156,9 +158,6 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension } } -// internal fun requireAlreadyInstalled(project: Project, reason: String = ""): KotlinProjectNpmResolution = -// installIfNeeded(reason = reason)[project.path] - internal val packageJsonFiles: Collection get() = state.npmProjects.map { it.packageJsonFile } @@ -230,18 +229,18 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension return resolvedProject.npmProjectsByNpmDependency[npmDependency] ?: error("NPM project resolved without $this") } - internal fun checkRequiredDependencies(task: T) + internal fun checkRequiredDependencies(task: T, services: ServiceRegistry, logger: Logger, projectPath: String) where T : RequiresNpmDependencies, T : Task { -// val project = task.project -// val requestedTaskDependencies = requireAlreadyInstalled(project, "before $task execution").taskRequirements -// val targetRequired = requestedTaskDependencies[task]?.toSet() ?: setOf() -// -// task.requiredNpmDependencies.forEach { -// check(it in targetRequired) { -// "${it.createDependency(project)} required by $task was not found resolved at the time of nodejs package manager call. " + -// "This may be caused by changing $task configuration after npm dependencies resolution." -// } -// } + val project = task.project + val requestedTaskDependencies = requireInstalled(services, logger, "before $task execution")[projectPath].taskRequirements + val targetRequired = requestedTaskDependencies[task]?.toSet() ?: setOf() + + task.requiredNpmDependencies.forEach { + check(it in targetRequired) { + "${it.createDependency(project)} required by $task was not found resolved at the time of nodejs package manager call. " + + "This may be caused by changing $task configuration after npm dependencies resolution." + } + } } } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt index dd4ec78a944..4c28940dcf1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies class KotlinProjectNpmResolution( val project: String, val npmProjects: List, - val taskRequirements: Map>? + val taskRequirements: Map> ) { val npmProjectsByNpmDependency: Map by lazy { mutableMapOf().also { result -> diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt index f6212ed6b8b..aac6d775761 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt @@ -35,6 +35,8 @@ constructor( RequiresNpmDependencies { private val nodeJs get() = NodeJsRootPlugin.apply(project.rootProject) + private val projectPath = project.path + @get:Internal var testFramework: KotlinJsTestFramework? = null set(value) { @@ -134,7 +136,7 @@ constructor( } override fun executeTests() { - nodeJs.npmResolutionManager.checkRequiredDependencies(this) + nodeJs.npmResolutionManager.checkRequiredDependencies(task = this, services = services, logger = logger, projectPath = projectPath) super.executeTests() } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt index 8bbaf8adac2..c2bb17b3cfc 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt @@ -10,7 +10,6 @@ import org.gradle.api.Incubating import org.gradle.api.file.FileCollection import org.gradle.api.file.RegularFileProperty import org.gradle.api.internal.file.FileResolver -import org.gradle.api.internal.project.ProjectInternal import org.gradle.api.plugins.BasePluginConvention import org.gradle.api.provider.Provider import org.gradle.api.tasks.* @@ -50,6 +49,8 @@ constructor( private val npmProject = compilation.npmProject + private val projectPath = project.path + @get:Inject open val fileResolver: FileResolver get() = injected @@ -106,6 +107,9 @@ constructor( @Input var saveEvaluatedConfigFile: Boolean = true + @Transient + private val baseConventions: BasePluginConvention? = project.convention.plugins["base"] as BasePluginConvention? + @Nested val output: KotlinWebpackOutput = KotlinWebpackOutput( library = baseConventions?.archivesBaseName, @@ -118,22 +122,27 @@ constructor( val outputPath: File get() = destinationDirectory - private val baseConventions: BasePluginConvention? - get() = project.convention.plugins["base"] as BasePluginConvention? - @get:Internal internal var _destinationDirectory: File? = null + private val defaultDestinationDirectory by lazy { + project.buildDir.resolve(baseConventions!!.distsDirName) + } + @get:Internal var destinationDirectory: File - get() = _destinationDirectory ?: project.buildDir.resolve(baseConventions!!.distsDirName) + get() = _destinationDirectory ?: defaultDestinationDirectory set(value) { _destinationDirectory = value } + private val defaultOutputFileName by lazy { + baseConventions?.archivesBaseName + ".js" + } + @get:Internal var outputFileName: String by property { - baseConventions?.archivesBaseName + ".js" + defaultOutputFileName } @get:OutputFile @@ -250,7 +259,7 @@ constructor( @TaskAction fun doExecute() { -// nodeJs.npmResolutionManager?.checkRequiredDependencies(this) + nodeJs.npmResolutionManager.checkRequiredDependencies(task = this, services = services, logger = logger, projectPath = projectPath) val runner = createRunner() From daa9c81bcb144a5d9f6d3eaf02c0b6920dc51fb5 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Wed, 20 Jan 2021 17:31:36 +0300 Subject: [PATCH 096/368] [Gradle, JS] Make KotlinJsDce, Dukat, KotlinPackageJson cc-compatible --- .../kotlin/gradle/targets/js/dukat/DukatTask.kt | 5 +++-- .../gradle/targets/js/dukat/IntegratedDukatTask.kt | 12 ++++++------ .../gradle/targets/js/nodejs/TasksRequirements.kt | 6 +++--- .../targets/js/npm/KotlinNpmResolutionManager.kt | 5 ++--- .../kotlin/gradle/targets/js/npm/NpmProject.kt | 5 +++-- .../gradle/targets/js/npm/RequiresNpmDependencies.kt | 4 ++++ .../js/npm/resolved/KotlinProjectNpmResolution.kt | 6 +----- .../js/npm/resolver/KotlinProjectNpmResolver.kt | 6 +++++- .../targets/js/npm/tasks/KotlinPackageJsonTask.kt | 2 +- .../kotlin/gradle/targets/js/testing/KotlinJsTest.kt | 4 ++-- .../gradle/targets/js/testing/karma/KotlinKarma.kt | 4 +++- .../gradle/targets/js/testing/mocha/KotlinMocha.kt | 4 +++- .../org/jetbrains/kotlin/gradle/tasks/KotlinJsDce.kt | 11 ++++++----- 13 files changed, 42 insertions(+), 32 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt index b4a85cb5999..5d90a36dda1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt @@ -19,7 +19,6 @@ abstract class DukatTask( override val compilation: KotlinJsCompilation ) : DefaultTask(), RequiresNpmDependencies { @get:Internal - @Transient protected val nodeJs = NodeJsRootPlugin.apply(project.rootProject) @get:Internal @@ -46,12 +45,14 @@ abstract class DukatTask( @Input var externalsOutputFormat: ExternalsOutputFormat = ExternalsOutputFormat.SOURCE + private val projectPath = project.path + private val compilationResolution get() = nodeJs.npmResolutionManager.requireInstalled( services, logger - )[project.path][compilationName] + )[projectPath][compilationName] @get:Internal val dts: List diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/IntegratedDukatTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/IntegratedDukatTask.kt index 51a7dcca1b8..d2a43c09ab0 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/IntegratedDukatTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/IntegratedDukatTask.kt @@ -20,22 +20,22 @@ constructor( override val considerGeneratingFlag: Boolean = true + private val npmProject = compilation.npmProject + @get:OutputDirectory override val destinationDir: File by lazy { - compilation.npmProject.externalsDir + npmProject.externalsDir } - @delegate:Transient - private val executor by lazy { - DukatExecutor( + private val executor + get() = DukatExecutor( nodeJs, dts, externalsOutputFormat, - compilation.npmProject, + npmProject, true, compareInputs = false ) - } @TaskAction override fun run() { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt index 5679b63de25..b6f0565bf57 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt @@ -12,10 +12,10 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies import org.jetbrains.kotlin.gradle.targets.js.npm.toDeclaration class TasksRequirements { - private val _byTask = mutableMapOf>() + private val _byTask = mutableMapOf>() private val byCompilation = mutableMapOf>() - val byTask: Map> + val byTask: Map> get() = _byTask internal fun getCompilationNpmRequirements(compilationName: String): Set = @@ -25,7 +25,7 @@ class TasksRequirements { fun addTaskRequirements(task: RequiresNpmDependencies) { val requirements = task.requiredNpmDependencies - _byTask[task] = requirements + _byTask[task.getPath()] = requirements val requiredNpmDependencies = requirements .asSequence() diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt index c598f1df086..017742a38cb 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/KotlinNpmResolutionManager.kt @@ -232,13 +232,12 @@ class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension internal fun checkRequiredDependencies(task: T, services: ServiceRegistry, logger: Logger, projectPath: String) where T : RequiresNpmDependencies, T : Task { - val project = task.project val requestedTaskDependencies = requireInstalled(services, logger, "before $task execution")[projectPath].taskRequirements - val targetRequired = requestedTaskDependencies[task]?.toSet() ?: setOf() + val targetRequired = requestedTaskDependencies[task.path]?.toSet() ?: setOf() task.requiredNpmDependencies.forEach { check(it in targetRequired) { - "${it.createDependency(project)} required by $task was not found resolved at the time of nodejs package manager call. " + + "${it.createDependency(task.project)} required by $task was not found resolved at the time of nodejs package manager call. " + "This may be caused by changing $task configuration after npm dependencies resolution." } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt index 8b5d9554b37..121b3c87609 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt @@ -65,8 +65,9 @@ open class NpmProject(@Transient val compilation: KotlinJsCompilation) { val main: String get() = "$DIST_FOLDER/$name.js" - val externalsDirRoot: File - get() = project.buildDir.resolve("externals").resolve(name) + val externalsDirRoot by lazy { + project.buildDir.resolve("externals").resolve(name) + } val externalsDir: File get() = externalsDirRoot.resolve("src") diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/RequiresNpmDependencies.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/RequiresNpmDependencies.kt index 7eec39179fd..031b1b56da2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/RequiresNpmDependencies.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/RequiresNpmDependencies.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.gradle.targets.js.npm +import org.gradle.api.tasks.Internal import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation import org.jetbrains.kotlin.gradle.targets.js.RequiredKotlinJsDependency @@ -12,4 +13,7 @@ interface RequiresNpmDependencies { val compilation: KotlinJsCompilation val nodeModulesRequired: Boolean val requiredNpmDependencies: Set + + @Internal + fun getPath(): String } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt index 4c28940dcf1..6b4856d4292 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinProjectNpmResolution.kt @@ -5,12 +5,8 @@ package org.jetbrains.kotlin.gradle.targets.js.npm.resolved -import org.gradle.api.Project -import org.gradle.api.file.FileCollection -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation import org.jetbrains.kotlin.gradle.targets.js.RequiredKotlinJsDependency import org.jetbrains.kotlin.gradle.targets.js.npm.NpmDependency -import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies /** * Info about NPM projects inside particular gradle [project]. @@ -18,7 +14,7 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies class KotlinProjectNpmResolution( val project: String, val npmProjects: List, - val taskRequirements: Map> + val taskRequirements: Map> ) { val npmProjectsByNpmDependency: Map by lazy { mutableMapOf().also { result -> diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt index a71c8e7edaf..f8b1d36165a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt @@ -40,6 +40,10 @@ internal class KotlinProjectNpmResolver( return byCompilation[compilation.name] ?: error("$compilation was not registered in $this") } + operator fun get(compilationName: String): KotlinCompilationNpmResolver { + return byCompilation[compilationName] ?: error("$compilationName was not registered in $this") + } + private var closed = false val compilationResolvers: Collection @@ -116,7 +120,7 @@ internal class KotlinProjectNpmResolver( return KotlinProjectNpmResolution( projectPath, byCompilation.values.mapNotNull { it.close() }, - resolver.nodeJs.taskRequirements?.byTask + resolver.nodeJs.taskRequirements.byTask ) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt index 054c0a7ae0d..015fec9f52d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt @@ -41,7 +41,7 @@ open class KotlinPackageJsonTask : DefaultTask() { val projectPath = project.path private val compilationResolver - get() = nodeJs.npmResolutionManager.resolver[projectPath][compilation] + get() = nodeJs.npmResolutionManager.resolver[projectPath][compilationName] private val producer: KotlinCompilationNpmResolver.PackageJsonProducer get() = compilationResolver.packageJsonProducer diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt index aac6d775761..a3a349a404b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt @@ -106,7 +106,7 @@ constructor( } fun useMocha() = useMocha {} - fun useMocha(body: KotlinMocha.() -> Unit) = use(KotlinMocha(compilation), body) + fun useMocha(body: KotlinMocha.() -> Unit) = use(KotlinMocha(compilation, path), body) fun useMocha(fn: Closure<*>) { useMocha { ConfigureUtil.configure(fn, this) @@ -115,7 +115,7 @@ constructor( fun useKarma() = useKarma {} fun useKarma(body: KotlinKarma.() -> Unit) = use( - KotlinKarma(compilation, services), + KotlinKarma(compilation, services, path), body ) fun useKarma(fn: Closure<*>) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt index a885c945358..de650c15281 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.gradle.utils.property import org.slf4j.Logger import java.io.File -class KotlinKarma(override val compilation: KotlinJsCompilation, private val services: ServiceRegistry) : +class KotlinKarma(override val compilation: KotlinJsCompilation, private val services: ServiceRegistry, private val basePath: String) : KotlinJsTestFramework { private val project: Project = compilation.target.project private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) @@ -56,6 +56,8 @@ class KotlinKarma(override val compilation: KotlinJsCompilation, private val ser override val requiredNpmDependencies: Set get() = requiredDependencies + webpackConfig.getRequiredDependencies(versions) + override fun getPath() = "$basePath:kotlinKarma" + override val settingsState: String get() = "KotlinKarma($config)" diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt index bd64118cd64..a7ce5bc181e 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTestFramework import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinTestRunnerCliArgs import java.io.File -class KotlinMocha(override val compilation: KotlinJsCompilation) : +class KotlinMocha(override val compilation: KotlinJsCompilation, private val basePath: String) : KotlinJsTestFramework { private val project: Project = compilation.target.project private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) @@ -37,6 +37,8 @@ class KotlinMocha(override val compilation: KotlinJsCompilation) : versions.sourceMapSupport ) + override fun getPath() = "$basePath:kotlinMocha" + // https://mochajs.org/#-timeout-ms-t-ms var timeout: String = DEFAULT_TIMEOUT diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinJsDce.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinJsDce.kt index b9d50a20f16..63cfef92e24 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinJsDce.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinJsDce.kt @@ -19,10 +19,7 @@ package org.jetbrains.kotlin.gradle.tasks import org.gradle.api.Project import org.gradle.api.file.FileCollection import org.gradle.api.file.FileTree -import org.gradle.api.tasks.CacheableTask -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.Internal -import org.gradle.api.tasks.TaskAction +import org.gradle.api.tasks.* import org.jetbrains.kotlin.cli.common.arguments.K2JSDceArguments import org.jetbrains.kotlin.cli.js.dce.K2JSDce import org.jetbrains.kotlin.compilerRunner.runToolInSeparateProcess @@ -74,6 +71,10 @@ open class KotlinJsDce : AbstractKotlinCompileTool(), KotlinJs @Input var jvmArgs = mutableListOf() + private val buildDir by lazy { + project.buildDir + } + @TaskAction fun performDce() { val inputFiles = (listOf(source) + classpath @@ -94,7 +95,7 @@ open class KotlinJsDce : AbstractKotlinCompileTool(), KotlinJs K2JSDce::class.java.name, computedCompilerClasspath, log, - project.buildDir, + buildDir, jvmArgs ) throwGradleExceptionIfError(exitCode) From 15f6bb9506ccc50ea568014136046a5097bb9abb Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Wed, 20 Jan 2021 23:23:38 +0300 Subject: [PATCH 097/368] [Gradle, JS] Make NodeJsSetup cc-compatible --- .../targets/js/nodejs/NodeJsRootPlugin.kt | 4 + .../targets/js/nodejs/NodeJsSetupTask.kt | 88 +++++++++++-------- 2 files changed, 53 insertions(+), 39 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt index dd7f34baa09..d073d87681b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsRootPlugin.kt @@ -32,6 +32,10 @@ open class NodeJsRootPlugin : Plugin { val setupTask = registerTask(NodeJsSetupTask.NAME) { it.group = TASKS_GROUP_NAME it.description = "Download and install a local node/npm version" + it.configuration = provider { + this.project.configurations.detachedConfiguration(this.project.dependencies.create(it.ivyDependency)) + .also { conf -> conf.isTransitive = false } + } } val rootClean = project.rootProject.tasks.named(BasePlugin.CLEAN_TASK_NAME) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt index f7c2f1e6bbe..ad30d9578df 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt @@ -1,10 +1,11 @@ package org.jetbrains.kotlin.gradle.targets.js.nodejs import org.gradle.api.DefaultTask -import org.gradle.api.tasks.CacheableTask -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.OutputDirectory -import org.gradle.api.tasks.TaskAction +import org.gradle.api.artifacts.Configuration +import org.gradle.api.file.ArchiveOperations +import org.gradle.api.file.FileSystemOperations +import org.gradle.api.provider.Provider +import org.gradle.api.tasks.* import org.jetbrains.kotlin.gradle.logging.kotlinInfo import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService import org.jetbrains.kotlin.statistics.metrics.NumericalMetrics @@ -15,6 +16,8 @@ import java.net.URI open class NodeJsSetupTask : DefaultTask() { private val settings = NodeJsRootPlugin.apply(project.rootProject) private val env by lazy { settings.requireConfigured() } + private val fs = services.get(FileSystemOperations::class.java) + private val archives = services.get(ArchiveOperations::class.java) val ivyDependency: String @Input get() = env.ivyDependency @@ -22,6 +25,41 @@ open class NodeJsSetupTask : DefaultTask() { val destination: File @OutputDirectory get() = env.nodeDir + @Transient + @get:Internal + internal lateinit var configuration: Provider + + private val _nodeJsDist by lazy { + configuration.get().files.single() + } + + @Suppress("unused") // as it called by Gradle before task execution and used to resolve artifact + @get:Classpath + val nodeJsDist: File + get() { + @Suppress("UnstableApiUsage", "DEPRECATION") + val repo = project.repositories.ivy { repo -> + repo.name = "Node Distributions at ${settings.nodeDownloadBaseUrl}" + repo.url = URI(settings.nodeDownloadBaseUrl) + + repo.patternLayout { + it.artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]") + it.ivy("v[revision]/ivy.xml") + } + repo.metadataSources { it.artifact() } + repo.content { it.includeModule("org.nodejs", "node") } + } + val startDownloadTime = System.currentTimeMillis() + val dist = _nodeJsDist + val downloadDuration = System.currentTimeMillis() - startDownloadTime + if (downloadDuration > 0) { + KotlinBuildStatsService.getInstance() + ?.report(NumericalMetrics.ARTIFACTS_DOWNLOAD_SPEED, dist.length() * 1000 / downloadDuration) + } + project.repositories.remove(repo) + return dist + } + init { @Suppress("LeakingThis") onlyIf { @@ -32,37 +70,9 @@ open class NodeJsSetupTask : DefaultTask() { @Suppress("unused") @TaskAction fun exec() { - @Suppress("UnstableApiUsage", "DEPRECATION") - val repo = project.repositories.ivy { repo -> - repo.name = "Node Distributions at ${settings.nodeDownloadBaseUrl}" - repo.url = URI(settings.nodeDownloadBaseUrl) + logger.kotlinInfo("Using node distribution from '$_nodeJsDist'") - repo.patternLayout { - it.artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]") - it.ivy("v[revision]/ivy.xml") - } - repo.metadataSources { it.artifact() } - repo.content { it.includeModule("org.nodejs", "node") } - } - - val dep = this.project.dependencies.create(ivyDependency) - val conf = this.project.configurations.detachedConfiguration(dep) - conf.isTransitive = false - - val startDownloadTime = System.currentTimeMillis() - val result = conf.resolve().single() - - val downloadDuration = System.currentTimeMillis() - startDownloadTime - if (downloadDuration > 0) { - KotlinBuildStatsService.getInstance() - ?.report(NumericalMetrics.ARTIFACTS_DOWNLOAD_SPEED, result.length() * 1000 / downloadDuration) - } - - project.repositories.remove(repo) - - project.logger.kotlinInfo("Using node distribution from '$result'") - - unpackNodeArchive(result, destination.parentFile) // parent because archive contains name already + unpackNodeArchive(_nodeJsDist, destination.parentFile) // parent because archive contains name already if (!env.isWindows) { File(env.nodeExecutable).setExecutable(true) @@ -70,16 +80,16 @@ open class NodeJsSetupTask : DefaultTask() { } private fun unpackNodeArchive(archive: File, destination: File) { - project.logger.kotlinInfo("Unpacking $archive to $destination") + logger.kotlinInfo("Unpacking $archive to $destination") when { - archive.name.endsWith("zip") -> project.copy { - it.from(project.zipTree(archive)) + archive.name.endsWith("zip") -> fs.copy { + it.from(archives.zipTree(archive)) it.into(destination) } else -> { - project.copy { - it.from(project.tarTree(archive)) + fs.copy { + it.from(archives.tarTree(archive)) it.into(destination) } } From 6eac5e1907f12a90267e5c7b9983db0007d57da2 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Fri, 22 Jan 2021 14:27:21 +0300 Subject: [PATCH 098/368] [Gradle, JS] Tasks that uses ArchiveOperations compatible w/ Gradle < 6.6 --- .../kotlin/gradle/DukatIntegrationIT.kt | 3 +++ .../kotlin/gradle/Kotlin2JsGradlePluginIT.kt | 3 +++ .../gradle/KotlinJsLibraryGradlePluginIT.kt | 3 +++ .../kotlin/gradle/tasks/CleanDataTaskIT.kt | 2 +- .../targets/js/nodejs/NodeJsSetupTask.kt | 21 ++++++++++++++++--- .../targets/js/npm/GradleNodeModuleBuilder.kt | 19 ++++++++++++----- .../targets/js/npm/GradleNodeModulesCache.kt | 14 ++++++++++--- 7 files changed, 53 insertions(+), 12 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/DukatIntegrationIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/DukatIntegrationIT.kt index 5e2e9fbdca2..59a2b9a47c4 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/DukatIntegrationIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/DukatIntegrationIT.kt @@ -12,6 +12,9 @@ import org.junit.Test import kotlin.test.assertTrue class DukatIntegrationIT : BaseGradleIT() { + override val defaultGradleVersion: GradleVersionRequired + get() = GradleVersionRequired.AtLeast("6.0") + @Test fun testSeparateDukatKotlinDslRootDependencies() { testSeparateDukat( diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt index 50b73a400da..5512c45d39b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt @@ -305,6 +305,9 @@ abstract class AbstractKotlin2JsGradlePluginIT(val irBackend: Boolean) : BaseGra jsCompilerType = if (irBackend) KotlinJsCompilerType.IR else KotlinJsCompilerType.LEGACY ) + override val defaultGradleVersion: GradleVersionRequired + get() = GradleVersionRequired.AtLeast("6.0") + protected fun CompiledProject.checkIrCompilationMessage() { if (irBackend) { assertContains(USING_JS_IR_BACKEND_MESSAGE) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt index 1c79a8937ea..73bde5e1908 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt @@ -16,6 +16,9 @@ class KotlinJsIrLibraryGradlePluginIT : BaseGradleIT() { jsCompilerType = KotlinJsCompilerType.IR ) + override val defaultGradleVersion: GradleVersionRequired + get() = GradleVersionRequired.AtLeast("6.0") + @Test fun testSimpleJsBinaryLibrary() { val project = Project("simple-js-library") diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/CleanDataTaskIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/CleanDataTaskIT.kt index cf6b7805d3b..05af6fc01d7 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/CleanDataTaskIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/CleanDataTaskIT.kt @@ -14,7 +14,7 @@ import org.junit.Test class CleanDataTaskIT : BaseGradleIT() { override val defaultGradleVersion: GradleVersionRequired - get() = GradleVersionRequired.AtLeast("5.5.1") + get() = GradleVersionRequired.AtLeast("6.0") @Test fun testDownloadedFolderDeletion() { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt index ad30d9578df..df84e6c418b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt @@ -17,7 +17,12 @@ open class NodeJsSetupTask : DefaultTask() { private val settings = NodeJsRootPlugin.apply(project.rootProject) private val env by lazy { settings.requireConfigured() } private val fs = services.get(FileSystemOperations::class.java) - private val archives = services.get(ArchiveOperations::class.java) + private val archives: Any? = try { + services.get(ArchiveOperations::class.java) + } catch (e: NoClassDefFoundError) { + // Gradle version < 6.6 + null + } val ivyDependency: String @Input get() = env.ivyDependency @@ -84,12 +89,22 @@ open class NodeJsSetupTask : DefaultTask() { when { archive.name.endsWith("zip") -> fs.copy { - it.from(archives.zipTree(archive)) + val from = if (archives != null) { + (archives as ArchiveOperations).zipTree(archive) + } else { + project.zipTree(archive) + } + it.from(from) it.into(destination) } else -> { fs.copy { - it.from(archives.tarTree(archive)) + val from = if (archives != null) { + (archives as ArchiveOperations).tarTree(archive) + } else { + project.tarTree(archive) + } + it.from(from) it.into(destination) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt index 14fac9f9a86..0b22455f22b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.gradle.targets.js.npm +import org.gradle.api.Project import org.gradle.api.file.ArchiveOperations import org.gradle.api.file.FileSystemOperations import org.jetbrains.kotlin.gradle.targets.js.JS @@ -17,8 +18,9 @@ import java.io.File * Creates fake NodeJS module directory from given gradle [dependency]. */ internal class GradleNodeModuleBuilder( + val project: Project, val fs: FileSystemOperations, - val archiveOperations: ArchiveOperations, + val archiveOperations: Any?, val moduleName: String, val moduleVersion: String, val srcFiles: Collection, @@ -31,10 +33,17 @@ internal class GradleNodeModuleBuilder( srcFiles.forEach { srcFile -> when { isKotlinJsRuntimeFile(srcFile) -> files.add(srcFile) - srcFile.isCompatibleArchive -> archiveOperations.zipTree(srcFile).forEach { innerFile -> - when { - innerFile.name == NpmProject.PACKAGE_JSON -> srcPackageJsonFile = innerFile - isKotlinJsRuntimeFile(innerFile) -> files.add(innerFile) + srcFile.isCompatibleArchive -> { + val archiveFiles = if (archiveOperations != null) { + (archiveOperations as ArchiveOperations).zipTree(srcFile) + } else { + project.zipTree(srcFile) + } + archiveFiles.forEach { innerFile -> + when { + innerFile.name == NpmProject.PACKAGE_JSON -> srcPackageJsonFile = innerFile + isKotlinJsRuntimeFile(innerFile) -> files.add(innerFile) + } } } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt index 9f350db323f..935dd970fef 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt @@ -15,15 +15,23 @@ import java.io.File * Cache for storing already created [GradleNodeModule]s */ internal class GradleNodeModulesCache(nodeJs: NodeJsRootExtension) : AbstractNodeModulesCache(nodeJs) { - private val fs = (nodeJs.rootProject as ProjectInternal).services.get(FileSystemOperations::class.java) - private val archiveOperations = (nodeJs.rootProject as ProjectInternal).services.get(ArchiveOperations::class.java) + @Transient + private val project = nodeJs.rootProject + + private val fs = (project as ProjectInternal).services.get(FileSystemOperations::class.java) + private val archiveOperations: Any? = try { + (project as ProjectInternal).services.get(ArchiveOperations::class.java) + } catch (e: NoClassDefFoundError) { + // Gradle version < 6.6 + null + } override fun buildImportedPackage( name: String, version: String, file: File ): File? { - val module = GradleNodeModuleBuilder(fs, archiveOperations, name, version, listOf(file), dir) + val module = GradleNodeModuleBuilder(project, fs, archiveOperations, name, version, listOf(file), dir) module.visitArtifacts() return module.rebuild() } From 0e29a9df6c702d91831544c5cc71b1cd3f8bd482 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Mon, 25 Jan 2021 18:29:21 +0300 Subject: [PATCH 099/368] [Gradle, JS] Use target disambiguation classifier for compilation name --- .../jetbrains/kotlin/gradle/plugin/KotlinCompilation.kt | 3 +++ .../targets/js/dukat/DukatCompilationResolverPlugin.kt | 2 +- .../jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt | 4 ++-- .../kotlin/gradle/targets/js/nodejs/TasksRequirements.kt | 2 +- .../jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt | 2 +- .../kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt | 2 +- .../js/npm/resolved/KotlinCompilationNpmResolution.kt | 1 - .../js/npm/resolver/KotlinCompilationNpmResolver.kt | 5 ++--- .../targets/js/npm/resolver/KotlinProjectNpmResolver.kt | 4 ++-- .../gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt | 8 ++++---- 10 files changed, 17 insertions(+), 16 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinCompilation.kt b/libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinCompilation.kt index b08bf567239..db408e7ab8f 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinCompilation.kt +++ b/libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinCompilation.kt @@ -82,6 +82,9 @@ interface KotlinCompilation : Named, HasAttributes, get() = super.relatedConfigurationNames + compileDependencyConfigurationName val moduleName: String + + val disambiguatedName + get() = target.disambiguationClassifier + name } interface KotlinCompilationToRunnableFiles : KotlinCompilation { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt index 8f00905fef7..4516a9adbec 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatCompilationResolverPlugin.kt @@ -27,7 +27,7 @@ internal class DukatCompilationResolverPlugin( val npmProject get() = resolver.npmProject val compilation get() = npmProject.compilation val compilationName by lazy { - compilation.name + compilation.disambiguatedName } val legacyTargetReuseIrTask by lazy { val target = compilation.target diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt index 5d90a36dda1..92246974ab6 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt @@ -23,7 +23,7 @@ abstract class DukatTask( @get:Internal val compilationName by lazy { - compilation.name + compilation.disambiguatedName } init { @@ -96,7 +96,7 @@ abstract class DukatTask( @TaskAction open fun run() { -// nodeJs.npmResolutionManager.checkRequiredDependencies(this) + nodeJs.npmResolutionManager.checkRequiredDependencies(this, services, logger, projectPath) destinationDir.deleteRecursively() diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt index b6f0565bf57..ef303010425 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/TasksRequirements.kt @@ -33,7 +33,7 @@ class TasksRequirements { .filterIsInstance() .toMutableSet() - val compilation = task.compilation.name + val compilation = task.compilation.disambiguatedName if (compilation in byCompilation) { byCompilation[compilation]!!.addAll(requiredNpmDependencies.map { it.toDeclaration() }) } else { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt index 121b3c87609..708960b130c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/NpmProject.kt @@ -25,7 +25,7 @@ val KotlinJsCompilation.npmProject: NpmProject * More info can be obtained from [KotlinCompilationNpmResolution], which is available after project resolution (after [KotlinNpmInstallTask] execution). */ open class NpmProject(@Transient val compilation: KotlinJsCompilation) { - val compilationName = compilation.name + val compilationName = compilation.disambiguatedName val name: String by lazy { buildNpmProjectName() diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt index b11fb9f8b51..173f28c028f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt @@ -28,7 +28,7 @@ constructor( private val npmProject = compilation.npmProject private val nodeJs = npmProject.nodeJs - private val compilationName = compilation.name + private val compilationName = compilation.disambiguatedName private val projectPath = project.path private val compilationResolution diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt index 3e7cb76e907..8dad68be62e 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolved/KotlinCompilationNpmResolution.kt @@ -15,7 +15,6 @@ class KotlinCompilationNpmResolution( @Transient private val _project: Project?, val npmProject: NpmProject, - val internalDependencies: Collection, val internalCompositeDependencies: Collection, val externalGradleDependencies: Collection, private val _externalNpmDependencies: Collection, diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt index c6650cd2338..07994a77913 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinCompilationNpmResolver.kt @@ -62,7 +62,7 @@ internal class KotlinCompilationNpmResolver( val npmProject = compilation.npmProject - val compilationName = compilation.name + val compilationDisambiguatedName = compilation.disambiguatedName val npmName by lazy { npmProject.name @@ -435,7 +435,7 @@ internal class KotlinCompilationNpmResolver( .filterNotNull() val toolsNpmDependencies = taskRequirements - .getCompilationNpmRequirements(compilationName) + .getCompilationNpmRequirements(compilationDisambiguatedName) val allNpmDependencies = externalNpmDependencyDeclarations + toolsNpmDependencies @@ -469,7 +469,6 @@ internal class KotlinCompilationNpmResolver( return KotlinCompilationNpmResolution( if (compilation != null) project else null, npmProject, - resolvedInternalDependencies, compositeDependencies, importedExternalGradleDependencies, allNpmDependencies, diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt index f8b1d36165a..d4dcfe2f532 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/resolver/KotlinProjectNpmResolver.kt @@ -37,7 +37,7 @@ internal class KotlinProjectNpmResolver( operator fun get(compilation: KotlinJsCompilation): KotlinCompilationNpmResolver { check(compilation.target.project == project) - return byCompilation[compilation.name] ?: error("$compilation was not registered in $this") + return byCompilation[compilation.disambiguatedName] ?: error("$compilation was not registered in $this") } operator fun get(compilationName: String): KotlinCompilationNpmResolver { @@ -110,7 +110,7 @@ internal class KotlinProjectNpmResolver( private fun addCompilation(compilation: KotlinJsCompilation) { check(!closed) { resolver.alreadyResolvedMessage("add compilation $compilation") } - byCompilation[compilation.name] = KotlinCompilationNpmResolver(this, compilation) + byCompilation[compilation.disambiguatedName] = KotlinCompilationNpmResolver(this, compilation) } fun close(): KotlinProjectNpmResolution { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt index 015fec9f52d..2e90802f755 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinPackageJsonTask.kt @@ -33,15 +33,15 @@ open class KotlinPackageJsonTask : DefaultTask() { @Transient private lateinit var compilation: KotlinJsCompilation - private val compilationName by lazy { - compilation.name + private val compilationDisambiguatedName by lazy { + compilation.disambiguatedName } @Input val projectPath = project.path private val compilationResolver - get() = nodeJs.npmResolutionManager.resolver[projectPath][compilationName] + get() = nodeJs.npmResolutionManager.resolver[projectPath][compilationDisambiguatedName] private val producer: KotlinCompilationNpmResolver.PackageJsonProducer get() = compilationResolver.packageJsonProducer @@ -64,7 +64,7 @@ open class KotlinPackageJsonTask : DefaultTask() { @get:Input internal val toolsNpmDependencies: List by lazy { nodeJs.taskRequirements - .getCompilationNpmRequirements(compilationName) + .getCompilationNpmRequirements(compilationDisambiguatedName) .map { it.toString() } } From c7421e2bea2e87f15c684196fa4eaa7ac58e0221 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Wed, 27 Jan 2021 08:42:54 +0300 Subject: [PATCH 100/368] [Gradle, JS] Use FileSystemOperations only when it's available FileSystemOperations is available since Gradle 6.0. ArchiveOperations usage is also refactored. Integration tests Gradle version requirements are reverted. --- .../kotlin/gradle/DukatIntegrationIT.kt | 3 -- .../kotlin/gradle/Kotlin2JsGradlePluginIT.kt | 3 -- .../gradle/KotlinJsLibraryGradlePluginIT.kt | 3 -- .../kotlin/gradle/tasks/CleanDataTaskIT.kt | 2 +- .../targets/js/nodejs/NodeJsSetupTask.kt | 27 +++-------- .../targets/js/npm/GradleNodeModuleBuilder.kt | 16 ++----- .../targets/js/npm/GradleNodeModulesCache.kt | 16 ++----- .../kotlin/gradle/utils/compatibiltiy.kt | 48 ++++++++++++++++++- 8 files changed, 64 insertions(+), 54 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/DukatIntegrationIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/DukatIntegrationIT.kt index 59a2b9a47c4..5e2e9fbdca2 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/DukatIntegrationIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/DukatIntegrationIT.kt @@ -12,9 +12,6 @@ import org.junit.Test import kotlin.test.assertTrue class DukatIntegrationIT : BaseGradleIT() { - override val defaultGradleVersion: GradleVersionRequired - get() = GradleVersionRequired.AtLeast("6.0") - @Test fun testSeparateDukatKotlinDslRootDependencies() { testSeparateDukat( diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt index 5512c45d39b..50b73a400da 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt @@ -305,9 +305,6 @@ abstract class AbstractKotlin2JsGradlePluginIT(val irBackend: Boolean) : BaseGra jsCompilerType = if (irBackend) KotlinJsCompilerType.IR else KotlinJsCompilerType.LEGACY ) - override val defaultGradleVersion: GradleVersionRequired - get() = GradleVersionRequired.AtLeast("6.0") - protected fun CompiledProject.checkIrCompilationMessage() { if (irBackend) { assertContains(USING_JS_IR_BACKEND_MESSAGE) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt index 73bde5e1908..1c79a8937ea 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinJsLibraryGradlePluginIT.kt @@ -16,9 +16,6 @@ class KotlinJsIrLibraryGradlePluginIT : BaseGradleIT() { jsCompilerType = KotlinJsCompilerType.IR ) - override val defaultGradleVersion: GradleVersionRequired - get() = GradleVersionRequired.AtLeast("6.0") - @Test fun testSimpleJsBinaryLibrary() { val project = Project("simple-js-library") diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/CleanDataTaskIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/CleanDataTaskIT.kt index 05af6fc01d7..cf6b7805d3b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/CleanDataTaskIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/tasks/CleanDataTaskIT.kt @@ -14,7 +14,7 @@ import org.junit.Test class CleanDataTaskIT : BaseGradleIT() { override val defaultGradleVersion: GradleVersionRequired - get() = GradleVersionRequired.AtLeast("6.0") + get() = GradleVersionRequired.AtLeast("5.5.1") @Test fun testDownloadedFolderDeletion() { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt index df84e6c418b..dfef4441c04 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsSetupTask.kt @@ -2,12 +2,12 @@ package org.jetbrains.kotlin.gradle.targets.js.nodejs import org.gradle.api.DefaultTask import org.gradle.api.artifacts.Configuration -import org.gradle.api.file.ArchiveOperations -import org.gradle.api.file.FileSystemOperations import org.gradle.api.provider.Provider import org.gradle.api.tasks.* import org.jetbrains.kotlin.gradle.logging.kotlinInfo import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService +import org.jetbrains.kotlin.gradle.utils.ArchiveOperationsCompat +import org.jetbrains.kotlin.gradle.utils.FileSystemOperationsCompat import org.jetbrains.kotlin.statistics.metrics.NumericalMetrics import java.io.File import java.net.URI @@ -16,13 +16,8 @@ import java.net.URI open class NodeJsSetupTask : DefaultTask() { private val settings = NodeJsRootPlugin.apply(project.rootProject) private val env by lazy { settings.requireConfigured() } - private val fs = services.get(FileSystemOperations::class.java) - private val archives: Any? = try { - services.get(ArchiveOperations::class.java) - } catch (e: NoClassDefFoundError) { - // Gradle version < 6.6 - null - } + private val fs = FileSystemOperationsCompat(project) + private val archiveOperations = ArchiveOperationsCompat(project) val ivyDependency: String @Input get() = env.ivyDependency @@ -89,22 +84,12 @@ open class NodeJsSetupTask : DefaultTask() { when { archive.name.endsWith("zip") -> fs.copy { - val from = if (archives != null) { - (archives as ArchiveOperations).zipTree(archive) - } else { - project.zipTree(archive) - } - it.from(from) + it.from(archiveOperations.zipTree(archive)) it.into(destination) } else -> { fs.copy { - val from = if (archives != null) { - (archives as ArchiveOperations).tarTree(archive) - } else { - project.tarTree(archive) - } - it.from(from) + it.from(archiveOperations.tarTree(archive)) it.into(destination) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt index 0b22455f22b..2f7d458f9c7 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModuleBuilder.kt @@ -6,21 +6,20 @@ package org.jetbrains.kotlin.gradle.targets.js.npm import org.gradle.api.Project -import org.gradle.api.file.ArchiveOperations -import org.gradle.api.file.FileSystemOperations import org.jetbrains.kotlin.gradle.targets.js.JS import org.jetbrains.kotlin.gradle.targets.js.JS_MAP import org.jetbrains.kotlin.gradle.targets.js.META_JS import org.jetbrains.kotlin.gradle.targets.js.ir.KLIB_TYPE +import org.jetbrains.kotlin.gradle.utils.ArchiveOperationsCompat +import org.jetbrains.kotlin.gradle.utils.FileSystemOperationsCompat import java.io.File /** * Creates fake NodeJS module directory from given gradle [dependency]. */ internal class GradleNodeModuleBuilder( - val project: Project, - val fs: FileSystemOperations, - val archiveOperations: Any?, + val fs: FileSystemOperationsCompat, + val archiveOperations: ArchiveOperationsCompat, val moduleName: String, val moduleVersion: String, val srcFiles: Collection, @@ -34,12 +33,7 @@ internal class GradleNodeModuleBuilder( when { isKotlinJsRuntimeFile(srcFile) -> files.add(srcFile) srcFile.isCompatibleArchive -> { - val archiveFiles = if (archiveOperations != null) { - (archiveOperations as ArchiveOperations).zipTree(srcFile) - } else { - project.zipTree(srcFile) - } - archiveFiles.forEach { innerFile -> + archiveOperations.zipTree(srcFile).forEach { innerFile -> when { innerFile.name == NpmProject.PACKAGE_JSON -> srcPackageJsonFile = innerFile isKotlinJsRuntimeFile(innerFile) -> files.add(innerFile) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt index 935dd970fef..4ff5713ac95 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/GradleNodeModulesCache.kt @@ -5,10 +5,9 @@ package org.jetbrains.kotlin.gradle.targets.js.npm -import org.gradle.api.file.ArchiveOperations -import org.gradle.api.file.FileSystemOperations -import org.gradle.api.internal.project.ProjectInternal import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension +import org.jetbrains.kotlin.gradle.utils.ArchiveOperationsCompat +import org.jetbrains.kotlin.gradle.utils.FileSystemOperationsCompat import java.io.File /** @@ -18,20 +17,15 @@ internal class GradleNodeModulesCache(nodeJs: NodeJsRootExtension) : AbstractNod @Transient private val project = nodeJs.rootProject - private val fs = (project as ProjectInternal).services.get(FileSystemOperations::class.java) - private val archiveOperations: Any? = try { - (project as ProjectInternal).services.get(ArchiveOperations::class.java) - } catch (e: NoClassDefFoundError) { - // Gradle version < 6.6 - null - } + private val fs = FileSystemOperationsCompat(project) + private val archiveOperations = ArchiveOperationsCompat(project) override fun buildImportedPackage( name: String, version: String, file: File ): File? { - val module = GradleNodeModuleBuilder(project, fs, archiveOperations, name, version, listOf(file), dir) + val module = GradleNodeModuleBuilder(fs, archiveOperations, name, version, listOf(file), dir) module.visitArtifacts() return module.rebuild() } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/compatibiltiy.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/compatibiltiy.kt index 271611db2a4..e5c3b7c8a5a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/compatibiltiy.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/compatibiltiy.kt @@ -17,9 +17,16 @@ package org.jetbrains.kotlin.gradle.utils import org.gradle.api.GradleException +import org.gradle.api.Project import org.gradle.api.Task +import org.gradle.api.file.ArchiveOperations +import org.gradle.api.file.CopySpec +import org.gradle.api.file.FileSystemOperations +import org.gradle.api.file.FileTree +import org.gradle.api.internal.project.ProjectInternal import org.gradle.api.tasks.TaskInputs import org.gradle.api.tasks.TaskOutputs +import org.gradle.api.tasks.WorkResult import org.gradle.api.tasks.bundling.AbstractArchiveTask import org.gradle.util.GradleVersion import java.io.File @@ -64,4 +71,43 @@ internal fun checkGradleCompatibility( } internal val AbstractArchiveTask.archivePathCompatible: File - get() = archiveFile.get().asFile \ No newline at end of file + get() = archiveFile.get().asFile + +internal class ArchiveOperationsCompat(@Transient private val project: Project) { + private val archiveOperations: Any? = try { + (project as ProjectInternal).services.get(ArchiveOperations::class.java) + } catch (e: NoClassDefFoundError) { + // Gradle version < 6.6 + null + } + + fun zipTree(obj: Any): FileTree { + return when (archiveOperations) { + is ArchiveOperations -> archiveOperations.zipTree(obj) + else -> project.zipTree(obj) + } + } + + fun tarTree(obj: Any): FileTree { + return when (archiveOperations) { + is ArchiveOperations -> archiveOperations.tarTree(obj) + else -> project.tarTree(obj) + } + } +} + +internal class FileSystemOperationsCompat(@Transient private val project: Project) { + private val fileSystemOperations: Any? = try { + (project as ProjectInternal).services.get(FileSystemOperations::class.java) + } catch (e: NoClassDefFoundError) { + // Gradle version < 6.0 + null + } + + fun copy(action: (CopySpec) -> Unit): WorkResult? { + return when (fileSystemOperations) { + is FileSystemOperations -> fileSystemOperations.copy(action) + else -> project.copy(action) + } + } +} \ No newline at end of file From 432c6486d558330abd27a335fb71b0b21a69acf3 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Wed, 27 Jan 2021 10:18:08 +0300 Subject: [PATCH 101/368] [Gradle] Make KotlinTest, KotlinTestReport partially cc-compatible --- .../gradle/targets/js/testing/KotlinJsTest.kt | 35 +++++--- .../targets/js/testing/karma/KotlinKarma.kt | 20 +++-- .../targets/js/testing/mocha/KotlinMocha.kt | 11 ++- .../kotlin/gradle/tasks/KotlinTest.kt | 6 +- .../testing/internal/KotlinTestReport.kt | 81 ++++++++++++------- 5 files changed, 96 insertions(+), 57 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt index a3a349a404b..4502ccf7422 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/KotlinJsTest.kt @@ -29,11 +29,14 @@ import javax.inject.Inject open class KotlinJsTest @Inject constructor( - @Internal override var compilation: KotlinJsCompilation + @Transient + @Internal + override var compilation: KotlinJsCompilation ) : KotlinTest(), RequiresNpmDependencies { - private val nodeJs get() = NodeJsRootPlugin.apply(project.rootProject) + private val nodeJs= NodeJsRootPlugin.apply(project.rootProject) + private val npmProject = compilation.npmProject private val projectPath = project.path @@ -69,22 +72,30 @@ constructor( var debug: Boolean = false @Suppress("unused") - val runtimeClasspath: FileCollection - @InputFiles get() = compilation.runtimeDependencyFiles + @get:InputFiles + val runtimeClasspath: FileCollection by lazy { + compilation.runtimeDependencyFiles + } @Suppress("unused") - internal val compilationOutputs: FileCollection - @InputFiles get() = compilation.output.allOutputs + @get:InputFiles + internal val compilationOutputs: FileCollection by lazy { + compilation.output.allOutputs + } @Suppress("unused") - val compilationId: String - @Input get() = compilation.let { + @get:Input + val compilationId: String by lazy { + compilation.let { val target = it.target target.project.path + "@" + target.name + ":" + it.compilationName } + } - val nodeModulesToLoad: List - @Internal get() = listOf("./" + compilation.npmProject.main) + @get:Internal + val nodeModulesToLoad: List by lazy { + listOf("./" + compilation.npmProject.main) + } override val nodeModulesRequired: Boolean @Internal get() = testFramework!!.nodeModulesRequired @@ -115,7 +126,7 @@ constructor( fun useKarma() = useKarma {} fun useKarma(body: KotlinKarma.() -> Unit) = use( - KotlinKarma(compilation, services, path), + KotlinKarma(compilation, { services }, path), body ) fun useKarma(fn: Closure<*>) { @@ -142,7 +153,7 @@ constructor( override fun createTestExecutionSpec(): TCServiceMessagesTestExecutionSpec { val forkOptions = DefaultProcessForkOptions(fileResolver) - forkOptions.workingDir = compilation.npmProject.dir + forkOptions.workingDir = npmProject.dir forkOptions.executable = nodeJs.requireConfigured().nodeExecutable val nodeJsArgs = mutableListOf() diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt index de650c15281..1f42f106096 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt @@ -36,9 +36,15 @@ import org.jetbrains.kotlin.gradle.utils.property import org.slf4j.Logger import java.io.File -class KotlinKarma(override val compilation: KotlinJsCompilation, private val services: ServiceRegistry, private val basePath: String) : +class KotlinKarma( + @Transient override val compilation: KotlinJsCompilation, + private val services: () -> ServiceRegistry, + private val basePath: String +) : KotlinJsTestFramework { + @Transient private val project: Project = compilation.target.project + private val npmProject = compilation.npmProject private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) private val versions = nodeJs.versions @@ -49,9 +55,11 @@ class KotlinKarma(override val compilation: KotlinJsCompilation, private val ser private val envJsCollector = mutableMapOf() private val confJsWriters = mutableListOf<(Appendable) -> Unit>() private var sourceMaps = false + private val defaultConfigDirectory = project.projectDir.resolve("karma.config.d") private var configDirectory: File by property { - project.projectDir.resolve("karma.config.d") + defaultConfigDirectory } + private val isTeamCity = project.hasProperty(TC_PROJECT_PROPERTY) override val requiredNpmDependencies: Set get() = requiredDependencies + webpackConfig.getRequiredDependencies(versions) @@ -277,8 +285,6 @@ class KotlinKarma(override val compilation: KotlinJsCompilation, private val ser file: String, debug: Boolean ): File { - val npmProject = compilation.npmProject - val adapterJs = npmProject.dir.resolve("adapter-browser.js") adapterJs.printWriter().use { writer -> val karmaRunner = npmProject.require("kotlin-test-js-runner/kotlin-test-karma-runner.js") @@ -301,8 +307,6 @@ class KotlinKarma(override val compilation: KotlinJsCompilation, private val ser nodeJsArgs: MutableList, debug: Boolean ): TCServiceMessagesTestExecutionSpec { - val npmProject = compilation.npmProject - val file = task.nodeModulesToLoad .map { npmProject.require(it) } .single() @@ -341,7 +345,7 @@ class KotlinKarma(override val compilation: KotlinJsCompilation, private val ser prependSuiteName = true, stackTraceParser = ::parseNodeJsStackTraceAsJvm, ignoreOutOfRootNodes = true, - escapeTCMessagesInLog = project.hasProperty(TC_PROJECT_PROPERTY) + escapeTCMessagesInLog = isTeamCity ) config.basePath = npmProject.nodeModulesDir.absolutePath @@ -407,7 +411,7 @@ class KotlinKarma(override val compilation: KotlinJsCompilation, private val ser lateinit var progressLogger: ProgressLogger override fun wrapExecute(body: () -> Unit) { - services.operation("Running and building tests with karma and webpack") { + services().operation("Running and building tests with karma and webpack") { progressLogger = this body() } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt index a7ce5bc181e..3d53107cb6a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt @@ -21,11 +21,14 @@ import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTestFramework import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinTestRunnerCliArgs import java.io.File -class KotlinMocha(override val compilation: KotlinJsCompilation, private val basePath: String) : +class KotlinMocha(@Transient override val compilation: KotlinJsCompilation, private val basePath: String) : KotlinJsTestFramework { + @Transient private val project: Project = compilation.target.project + private val npmProject = compilation.npmProject private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) private val versions = nodeJs.versions + private val isTeamCity = project.hasProperty(TC_PROJECT_PROPERTY) override val settingsState: String get() = "mocha" @@ -54,11 +57,9 @@ class KotlinMocha(override val compilation: KotlinJsCompilation, private val bas prependSuiteName = true, stackTraceParser = ::parseNodeJsStackTraceAsJvm, ignoreOutOfRootNodes = true, - escapeTCMessagesInLog = project.hasProperty(TC_PROJECT_PROPERTY) + escapeTCMessagesInLog = isTeamCity ) - val npmProject = compilation.npmProject - val cliArgs = KotlinTestRunnerCliArgs( include = task.includePatterns, exclude = task.excludePatterns @@ -105,8 +106,6 @@ class KotlinMocha(override val compilation: KotlinJsCompilation, private val bas private fun createAdapterJs( file: String ): File { - val npmProject = compilation.npmProject - val adapterJs = npmProject.dir.resolve(ADAPTER_NODEJS) adapterJs.printWriter().use { writer -> val adapter = npmProject.require("kotlin-test-js-runner/kotlin-test-nodejs-runner.js") diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinTest.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinTest.kt index 6c11c5f9aaa..3416e661a84 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/KotlinTest.kt @@ -58,11 +58,15 @@ abstract class KotlinTest : AbstractTestTask() { runListeners.add(listener) } + private val ignoreTcsmOverflow by lazy { + PropertiesProvider(project).ignoreTcsmOverflow + } + override fun createTestExecuter() = TCServiceMessagesTestExecutor( execHandleFactory, buildOperationExecutor, runListeners, - PropertiesProvider(project).ignoreTcsmOverflow, + ignoreTcsmOverflow, ignoreRunFailures ) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/testing/internal/KotlinTestReport.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/testing/internal/KotlinTestReport.kt index aa4473bb25e..72bbccd2ba8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/testing/internal/KotlinTestReport.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/testing/internal/KotlinTestReport.kt @@ -41,18 +41,24 @@ import java.net.URI * event if child tasks will be executed. */ open class KotlinTestReport : TestReport() { + @Transient @Internal val testTasks = mutableListOf() + @Transient private var parent: KotlinTestReport? = null + // TODO: used in task action when the task is aggregate report, non compatible with configuration cache @Internal val children = mutableListOf>() + @Transient private val projectProperties = PropertiesProvider(project) - val overrideReporting: Boolean - @Input get() = projectProperties.individualTaskReports == null + @get:Input + val overrideReporting: Boolean by lazy { + projectProperties.individualTaskReports == null + } @Input var checkFailedTests: Boolean = false @@ -60,28 +66,14 @@ open class KotlinTestReport : TestReport() { @Input var ignoreFailures: Boolean = false - private var hasOwnFailedTests = false + private val hasOwnFailedTests + get() = failedTestsListener.hasOwnFailedTests ?: false private val hasFailedTests: Boolean get() = hasOwnFailedTests || children.any { it.get().hasFailedTests } - private val ownSuppressedRunningFailures = mutableListOf>() + private val suppressedRunningFailureListeners: MutableSet = mutableSetOf() - private val failedTestsListener = object : TestListener { - override fun beforeTest(testDescriptor: TestDescriptor) { - } - - override fun afterSuite(suite: TestDescriptor, result: TestResult) { - } - - override fun beforeSuite(suite: TestDescriptor) { - } - - override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) { - if (result.failedTestCount > 0) { - hasOwnFailedTests = true - } - } - } + private val failedTestsListener = FailedTestListener() fun addChild(childProvider: TaskProvider) { val child = childProvider.get() @@ -108,11 +100,11 @@ open class KotlinTestReport : TestReport() { testTasks.add(task) task.addTestListener(failedTestsListener) - if (task is KotlinTest) task.addRunListener(object : KotlinTestRunnerListener { - override fun runningFailure(failure: Error) { - ownSuppressedRunningFailures.add(task to failure) - } - }) + if (task is KotlinTest) { + val listener = SuppressedTestRunningFailureListener(task.path) + task.addRunListener(listener) + suppressedRunningFailureListeners.add(listener) + } reportOn(task) addToParents(task) @@ -163,11 +155,11 @@ open class KotlinTestReport : TestReport() { } private fun checkSuppressedRunningFailures() { - val allSuppressedRunningFailures = mutableListOf>() + val allSuppressedRunningFailures = mutableListOf>() fun visitSuppressedRunningFailures(report: KotlinTestReport) { - report.ownSuppressedRunningFailures.forEach { - allSuppressedRunningFailures.add(it) + report.suppressedRunningFailureListeners.filter { it.failure != null }.forEach { + allSuppressedRunningFailures.add(it.taskPath to it.failure!!) } report.children.forEach { @@ -181,8 +173,8 @@ open class KotlinTestReport : TestReport() { val allErrors = mutableListOf() val msg = buildString { appendln("Failed to execute all tests:") - allSuppressedRunningFailures.groupBy { it.first }.forEach { test, errors -> - append(test.path) + allSuppressedRunningFailures.groupBy { it.first }.forEach { path, errors -> + append(path) append(": ") var first = true errors.forEach { (_, error) -> @@ -251,4 +243,33 @@ open class KotlinTestReport : TestReport() { task.reports.junitXml.isEnabled = false } + + private class SuppressedTestRunningFailureListener(val taskPath: String) : KotlinTestRunnerListener { + @Transient + var failure: Error? = null + + override fun runningFailure(failure: Error) { + this.failure = failure + } + } + + private class FailedTestListener : TestListener { + @Transient + var hasOwnFailedTests: Boolean? = false + + override fun beforeTest(testDescriptor: TestDescriptor) { + } + + override fun afterSuite(suite: TestDescriptor, result: TestResult) { + } + + override fun beforeSuite(suite: TestDescriptor) { + } + + override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) { + if (result.failedTestCount > 0) { + hasOwnFailedTests = true + } + } + } } From a6bf9bf51b58c9bce20a2b3ccd51c5af707e23cc Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Tue, 9 Feb 2021 13:57:35 +0300 Subject: [PATCH 102/368] [Gradle, JS] Remove workaround for configuration cache enabled builds It's removed as those tasks now support Gradle configuration cache --- .../gradle/targets/js/dukat/DukatTask.kt | 5 ----- .../targets/js/npm/PublicPackageJsonTask.kt | 7 ------- .../js/npm/tasks/KotlinNpmInstallTask.kt | 5 ----- .../js/npm/tasks/RootPackageJsonTask.kt | 6 ------ .../targets/js/webpack/KotlinWebpack.kt | 6 ------ .../kotlin/gradle/utils/configurationCache.kt | 19 +------------------ 6 files changed, 1 insertion(+), 47 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt index 92246974ab6..e24f3fb4b40 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/dukat/DukatTask.kt @@ -26,11 +26,6 @@ abstract class DukatTask( compilation.disambiguatedName } - init { - // TODO: temporary workaround for configuration cache enabled builds -// disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() } - } - @get:Internal override val nodeModulesRequired: Boolean get() = true diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt index 173f28c028f..bb1a4e8663c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/PublicPackageJsonTask.kt @@ -13,8 +13,6 @@ import org.gradle.api.tasks.TaskAction import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrCompilation import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject.Companion.PACKAGE_JSON -import org.jetbrains.kotlin.gradle.utils.disableTaskOnConfigurationCacheBuild -import org.jetbrains.kotlin.gradle.utils.getValue import org.jetbrains.kotlin.gradle.utils.property import java.io.File import javax.inject.Inject @@ -38,11 +36,6 @@ constructor( )[projectPath][compilationName] - init { - // TODO: temporary workaround for configuration cache enabled builds -// disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() } - } - // TODO: is map contains only serializable values? @get:Input val packageJsonCustomFields: Map by lazy { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt index cba0bf1e356..81a790b3aa5 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/KotlinNpmInstallTask.kt @@ -27,11 +27,6 @@ open class KotlinNpmInstallTask : DefaultTask() { private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) private val resolutionManager get() = nodeJs.npmResolutionManager - init { - // TODO: temporary workaround for configuration cache enabled builds -// disableTaskOnConfigurationCacheBuild { resolutionManager.toString() } - } - @Input val args: MutableList = mutableListOf() diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt index d3eccdd8f7d..7da9c63954a 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/npm/tasks/RootPackageJsonTask.kt @@ -10,7 +10,6 @@ import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.TaskAction import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject -import org.jetbrains.kotlin.gradle.utils.disableTaskOnConfigurationCacheBuild import java.io.File open class RootPackageJsonTask : DefaultTask() { @@ -29,11 +28,6 @@ open class RootPackageJsonTask : DefaultTask() { private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) private val resolutionManager get() = nodeJs.npmResolutionManager - init { - // TODO: temporary workaround for configuration cache enabled builds -// disableTaskOnConfigurationCacheBuild { resolutionManager.toString() } - } - @get:OutputFile val rootPackageJson: File get() = nodeJs.rootPackageDir.resolve(NpmProject.PACKAGE_JSON) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt index c2bb17b3cfc..a99621e696f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/webpack/KotlinWebpack.kt @@ -25,7 +25,6 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.RequiresNpmDependencies import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.Mode import org.jetbrains.kotlin.gradle.testing.internal.reportsDir -import org.jetbrains.kotlin.gradle.utils.disableTaskOnConfigurationCacheBuild import org.jetbrains.kotlin.gradle.utils.injected import org.jetbrains.kotlin.gradle.utils.newFileProperty import org.jetbrains.kotlin.gradle.utils.property @@ -42,11 +41,6 @@ constructor( private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) private val versions = nodeJs.versions - init { - // TODO: temporary workaround for configuration cache enabled builds -// disableTaskOnConfigurationCacheBuild { nodeJs.npmResolutionManager.toString() } - } - private val npmProject = compilation.npmProject private val projectPath = project.path diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/configurationCache.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/configurationCache.kt index 1a435028f97..022c1a9d4e9 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/configurationCache.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/utils/configurationCache.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.gradle.utils -import org.gradle.api.Task import org.gradle.api.invocation.Gradle internal fun isConfigurationCacheAvailable(gradle: Gradle) = @@ -14,20 +13,4 @@ internal fun isConfigurationCacheAvailable(gradle: Gradle) = startParameters.javaClass.getMethod("isConfigurationCache").invoke(startParameters) as? Boolean } catch (_: Exception) { null - } ?: false - -internal fun Task.disableTaskOnConfigurationCacheBuild(transientFieldAccessor: () -> Unit) { - if (isConfigurationCacheAvailable(project.gradle)) { - onlyIf { - logger.warn("Configuration cache is not yet fully supported: use it at your own risk.") - try { - // transientFieldAccessor() will throw an exception after loading task from configuration cache - transientFieldAccessor() - true - } catch (e: Exception) { - logger.warn("Task cannot be executed because of corrupted state after loading from configuration cache.") - false - } - } - } -} \ No newline at end of file + } ?: false \ No newline at end of file From 2b0ad7024219d2b84ce647f73391679efd11f950 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Tue, 9 Feb 2021 17:41:53 +0300 Subject: [PATCH 103/368] [Gradle, JS] Add integration test for js plugin configuration cache #KT-42911 Fixed --- .../kotlin/gradle/ConfigurationCacheIT.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/ConfigurationCacheIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/ConfigurationCacheIT.kt index fa18ab1ffd5..fbb71a1344f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/ConfigurationCacheIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/ConfigurationCacheIT.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle import org.jetbrains.kotlin.gradle.util.findFileByName import org.jetbrains.kotlin.gradle.util.createTempDir +import org.jetbrains.kotlin.gradle.util.modify import org.junit.Test import java.io.File import java.net.URI @@ -68,6 +69,22 @@ class ConfigurationCacheIT : AbstractConfigurationCacheIT() { fun testInstantExecutionForJs() = with(Project("instantExecutionToJs")) { testConfigurationCacheOf("assemble", executedTaskNames = asList(":compileKotlin2Js")) } + + @Test + fun testConfigurationCacheJsPlugin() = with(Project("kotlin-js-browser-project")) { + setupWorkingDir() + gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl) + gradleSettingsScript().modify(::transformBuildScriptWithPluginsDsl) + testConfigurationCacheOf( + ":app:build", executedTaskNames = asList( + ":app:packageJson", + ":app:publicPackageJson", + ":app:compileKotlinJs", + ":app:processDceKotlinJs", + ":app:browserProductionWebpack", + ) + ) + } } abstract class AbstractConfigurationCacheIT : BaseGradleIT() { From 240fdfa7a85415a89516f3430cfebe81e64ebeac Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Fri, 12 Feb 2021 14:24:55 +0300 Subject: [PATCH 104/368] [Gradle] Support multiple failures in KotlinTestReport back again --- .../testing/internal/KotlinTestReport.kt | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/testing/internal/KotlinTestReport.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/testing/internal/KotlinTestReport.kt index 72bbccd2ba8..23e592e4837 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/testing/internal/KotlinTestReport.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/testing/internal/KotlinTestReport.kt @@ -48,7 +48,7 @@ open class KotlinTestReport : TestReport() { @Transient private var parent: KotlinTestReport? = null - // TODO: used in task action when the task is aggregate report, non compatible with configuration cache + // TODO: this field is used in task action when the task is aggregate report, which makes it incompatible with configuration cache @Internal val children = mutableListOf>() @@ -158,8 +158,10 @@ open class KotlinTestReport : TestReport() { val allSuppressedRunningFailures = mutableListOf>() fun visitSuppressedRunningFailures(report: KotlinTestReport) { - report.suppressedRunningFailureListeners.filter { it.failure != null }.forEach { - allSuppressedRunningFailures.add(it.taskPath to it.failure!!) + report.suppressedRunningFailureListeners.forEach { listener -> + listener.failures.forEach { failure -> + allSuppressedRunningFailures.add(listener.taskPath to failure) + } } report.children.forEach { @@ -246,10 +248,19 @@ open class KotlinTestReport : TestReport() { private class SuppressedTestRunningFailureListener(val taskPath: String) : KotlinTestRunnerListener { @Transient - var failure: Error? = null + private var failuresMutable: MutableList? = mutableListOf() + + val failures: List + get() = failuresMutable ?: emptyList() override fun runningFailure(failure: Error) { - this.failure = failure + var failures = failuresMutable + if (failures == null) { + // it is possible after deserialization + failures = mutableListOf() + failuresMutable = failures + } + failures.add(failure) } } From 1cceec36427025304807bfdcb66389c702b87472 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Fri, 12 Feb 2021 14:28:53 +0300 Subject: [PATCH 105/368] [Gradle, JS] Postpone TeamCity project property read using 'by lazy' Replace direct Gradle property access to provider usage. See https://docs.gradle.org/6.8.2/userguide/configuration_cache.html#config_cache:requirements:undeclared_gradle_prop_read --- .../kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt | 4 +++- .../kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt | 4 +++- .../kotlin/gradle/targets/native/tasks/KotlinNativeTest.kt | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt index 1f42f106096..aca60c1255c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt @@ -59,7 +59,9 @@ class KotlinKarma( private var configDirectory: File by property { defaultConfigDirectory } - private val isTeamCity = project.hasProperty(TC_PROJECT_PROPERTY) + private val isTeamCity by lazy { + project.providers.gradleProperty(TC_PROJECT_PROPERTY).forUseAtConfigurationTime().isPresent + } override val requiredNpmDependencies: Set get() = requiredDependencies + webpackConfig.getRequiredDependencies(versions) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt index 3d53107cb6a..58a355982f3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt @@ -28,7 +28,9 @@ class KotlinMocha(@Transient override val compilation: KotlinJsCompilation, priv private val npmProject = compilation.npmProject private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) private val versions = nodeJs.versions - private val isTeamCity = project.hasProperty(TC_PROJECT_PROPERTY) + private val isTeamCity by lazy { + project.providers.gradleProperty(TC_PROJECT_PROPERTY).forUseAtConfigurationTime().isPresent + } override val settingsState: String get() = "mocha" diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTest.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTest.kt index 9a237dc0be8..8f05af8113d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTest.kt @@ -114,7 +114,7 @@ abstract class KotlinNativeTest : KotlinTest() { prependSuiteName = targetName != null, treatFailedTestOutputAsStacktrace = false, stackTraceParser = ::parseKotlinNativeStackTraceAsJvm, - escapeTCMessagesInLog = project.hasProperty(TC_PROJECT_PROPERTY) + escapeTCMessagesInLog = project.providers.gradleProperty(TC_PROJECT_PROPERTY).forUseAtConfigurationTime().isPresent ) // The KotlinTest expects that the exit code is zero even if some tests failed. From ba969410c24d00fa61ec7f963622507b4ea70308 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Sun, 14 Feb 2021 03:15:41 +0300 Subject: [PATCH 106/368] [Gradle, JS] Make MultiplePluginDeclarationDetector compatible w/ conf cache --- .../plugin/BuildFinishedListenerService.kt | 36 +++++++++++++++++++ .../js/MultiplePluginDeclarationDetector.kt | 13 ++++--- 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/BuildFinishedListenerService.kt diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/BuildFinishedListenerService.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/BuildFinishedListenerService.kt new file mode 100644 index 00000000000..51dc6db6162 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/BuildFinishedListenerService.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2021 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.gradle.plugin + +import org.gradle.api.invocation.Gradle +import org.gradle.api.services.BuildService +import org.gradle.api.services.BuildServiceParameters + +abstract class BuildFinishedListenerService : BuildService, AutoCloseable { + private val actionsOnClose = mutableListOf<() -> Unit>() + + fun onClose(action: () -> Unit) { + actionsOnClose.add(action) + } + + override fun close() { + for (action in actionsOnClose) { + action() + } + actionsOnClose.clear() + } + + companion object { + fun getInstance(gradle: Gradle): BuildFinishedListenerService { + // Use class loader hashcode in case there are multiple class loaders in the same build + return gradle.sharedServices + .registerIfAbsent( + "build-finished-listener_${BuildFinishedListenerService::class.java.classLoader.hashCode()}", + BuildFinishedListenerService::class.java + ) {}.get() + } + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/MultiplePluginDeclarationDetector.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/MultiplePluginDeclarationDetector.kt index 6f5ac1944c1..fe80845628b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/MultiplePluginDeclarationDetector.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/MultiplePluginDeclarationDetector.kt @@ -7,8 +7,10 @@ package org.jetbrains.kotlin.gradle.targets.js import org.gradle.api.Project import org.gradle.api.invocation.Gradle +import org.jetbrains.kotlin.gradle.plugin.BuildFinishedListenerService import org.jetbrains.kotlin.gradle.plugin.KotlinPluginInMultipleProjectsHolder import org.jetbrains.kotlin.gradle.plugin.MULTIPLE_KOTLIN_PLUGINS_LOADED_WARNING +import org.jetbrains.kotlin.gradle.utils.isConfigurationCacheAvailable internal class MultiplePluginDeclarationDetector private constructor() { @@ -40,9 +42,12 @@ private constructor() { val detector = MultiplePluginDeclarationDetector() instance = detector -// gradle.buildFinished { -// instance = null -// } + + if (isConfigurationCacheAvailable(gradle)) { + BuildFinishedListenerService.getInstance(gradle).onClose { instance = null } + } else { + gradle.buildFinished { instance = null } + } return detector } @@ -51,4 +56,4 @@ private constructor() { getInstance(project.gradle).detect(project) } } -} \ No newline at end of file +} From cbdcd8f2bcc7b0c33508e5c2683267610093d04d Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Tue, 8 Dec 2020 13:51:48 +0300 Subject: [PATCH 107/368] [Gradle, K/N] Add consumable configuration with K/N frameworks --- .../targets/native/KotlinNativeTarget.kt | 4 +++ .../native/KotlinNativeTargetConfigurator.kt | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt index 680598acec1..aa0ad9edd13 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt @@ -129,6 +129,10 @@ open class KotlinNativeTarget @Inject constructor( "org.jetbrains.kotlin.native.target", String::class.java ) + val konanBuildTypeAttribute = Attribute.of( + "org.jetbrains.kotlin.native.type", + String::class.java + ) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt index 2c9c5d79472..41921def23c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt @@ -138,8 +138,41 @@ open class KotlinNativeTargetConfigurator( tasks.named(binary.compilation.target.artifactsTaskName).configure { it.dependsOn(result) } tasks.maybeCreate(LifecycleBasePlugin.ASSEMBLE_TASK_NAME).dependsOn(result) } + + if (binary is Framework) { + val configuration = configurations.create(configurationName(binary.target.name, binary.buildType.name.toLowerCase()) + binary.baseName) { + it.isCanBeConsumed = true + it.isCanBeResolved = false + } + with(configuration) { + usesPlatformOf(binary.target) + project.afterEvaluate { + val linkArtifact = project.artifacts.add(name, binary.outputFile) { artifact -> + artifact.name = name + artifact.extension = "framework" + artifact.type = "binary" + artifact.classifier = "framework" + artifact.builtBy(result) + } + project.extensions.getByType(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet::class.java) + .addCandidate(linkArtifact) + artifacts.add(linkArtifact) + attributes.attribute( + ArtifactAttributes.ARTIFACT_FORMAT, + NativeArtifactFormat.FRAMEWORK + ) + attributes.attribute( + KotlinNativeTarget.konanBuildTypeAttribute, + binary.buildType.name + ) + } + } + } } + private fun configurationName(name: String, type: String): String = + listOf(name, type, "frameworks").joinToString("") { it.capitalize() }.decapitalize() + private fun Project.createRunTask(binary: Executable) { val taskName = binary.runTaskName ?: return registerTask(taskName) { exec -> @@ -399,6 +432,7 @@ open class KotlinNativeTargetConfigurator( object NativeArtifactFormat { const val KLIB = "org.jetbrains.kotlin.klib" + const val FRAMEWORK = "org.jetbrains.kotlin.framework" } companion object { From d844296629a3ecab103104b4e1753f3ac4f20399 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Wed, 30 Dec 2020 13:44:40 +0300 Subject: [PATCH 108/368] [Gradle, K/N] Add user-defined variant attributes to framework artifact --- .../targets/native/KotlinNativeTargetConfigurator.kt | 10 ++++++++++ .../kotlin/gradle/targets/native/NativeBinaries.kt | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt index 41921def23c..973010503b0 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt @@ -165,6 +165,16 @@ open class KotlinNativeTargetConfigurator( KotlinNativeTarget.konanBuildTypeAttribute, binary.buildType.name ) + // capture type parameter T + fun copyAttribute(key: Attribute, from: AttributeContainer, to: AttributeContainer) { + to.attribute(key, from.getAttribute(key)!!) + } + binary.target.getAttributes().keySet().forEach { + copyAttribute(it, binary.target.getAttributes(), this.attributes) + } + binary.attributes.keySet().forEach { + copyAttribute(it, binary.attributes, this.attributes) + } } } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt index eda05f6daf8..ce521fc7eab 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt @@ -11,6 +11,9 @@ import org.gradle.api.Action import org.gradle.api.Named import org.gradle.api.Project import org.gradle.api.artifacts.Dependency +import org.gradle.api.attributes.Attribute +import org.gradle.api.attributes.AttributeContainer +import org.gradle.api.attributes.HasAttributes import org.gradle.api.provider.Provider import org.gradle.api.tasks.AbstractExecTask import org.gradle.api.tasks.TaskProvider @@ -229,7 +232,11 @@ class Framework( baseName: String, buildType: NativeBuildType, compilation: KotlinNativeCompilation -) : AbstractNativeLibrary(name, baseName, buildType, compilation) { +) : AbstractNativeLibrary(name, baseName, buildType, compilation), HasAttributes { + + private val attributeContainer = HierarchyAttributeContainer(parent = null) + + override fun getAttributes() = attributeContainer override val outputKind: NativeOutputKind get() = NativeOutputKind.FRAMEWORK From 604dda839a8e95f5860b7c728b3507fc60b579f7 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Mon, 18 Jan 2021 18:55:09 +0300 Subject: [PATCH 109/368] [Gradle, K/N] Generate fat framework tasks and consumable configurations --- .../native/KotlinNativeTargetConfigurator.kt | 121 ++++++++++++------ 1 file changed, 85 insertions(+), 36 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt index 973010503b0..505d924d93b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt @@ -8,6 +8,9 @@ package org.jetbrains.kotlin.gradle.plugin import org.gradle.api.DefaultTask import org.gradle.api.Project +import org.gradle.api.Task +import org.gradle.api.UnknownDomainObjectException +import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.ConfigurationContainer import org.gradle.api.artifacts.Dependency import org.gradle.api.attributes.Attribute @@ -140,48 +143,94 @@ open class KotlinNativeTargetConfigurator( } if (binary is Framework) { - val configuration = configurations.create(configurationName(binary.target.name, binary.buildType.name.toLowerCase()) + binary.baseName) { + createFrameworkArtifact(binary, result) + } + } + + private fun Project.createFrameworkArtifact( + binary: Framework, + linkTask: TaskProvider + ) { + fun Configuration.configureConfiguration(fat: Boolean, taskProvider: TaskProvider) { + usesPlatformOf(binary.target) + project.afterEvaluate { + val task = taskProvider.get() + val artifactFile = when (task) { + is FatFrameworkTask -> task.fatFrameworkDir + else -> binary.outputFile + } + val linkArtifact = project.artifacts.add(name, artifactFile) { artifact -> + artifact.name = name + artifact.extension = "framework" + artifact.type = "binary" + artifact.classifier = "framework" + artifact.builtBy(task) + } + project.extensions.getByType(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet::class.java) + .addCandidate(linkArtifact) + artifacts.add(linkArtifact) + attributes.attribute( + org.gradle.api.internal.artifacts.ArtifactAttributes.ARTIFACT_FORMAT, + org.jetbrains.kotlin.gradle.plugin.KotlinNativeTargetConfigurator.NativeArtifactFormat.FRAMEWORK + ) + attributes.attribute( + org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget.konanBuildTypeAttribute, + binary.buildType.name + ) + // capture type parameter T + fun copyAttribute(key: Attribute, from: AttributeContainer, to: AttributeContainer) { + to.attribute(key, from.getAttribute(key)!!) + } + binary.target.getAttributes().keySet().forEach { + copyAttribute(it, binary.target.getAttributes(), this.attributes) + } + if (fat) { + attributes.attribute(KotlinNativeTarget.konanTargetAttribute, "fat") + // else is already set to real konan target + } + binary.attributes.keySet().forEach { + copyAttribute(it, binary.attributes, this.attributes) + } + } + } + + configurations.create(frameworkConfigurationName(binary.target.name, binary.buildType.name.toLowerCase()) + binary.baseName) { + it.isCanBeConsumed = true + it.isCanBeResolved = false + it.configureConfiguration(false, linkTask) + } + + val fatFrameworkConfigurationName = frameworkConfigurationName(binary.baseName, binary.buildType.name.toLowerCase() + "Fat") + val fatFrameworkTaskName = "link${fatFrameworkConfigurationName.capitalize()}" + + val fatFrameworkTask = try { + tasks.named(fatFrameworkTaskName, FatFrameworkTask::class.java) + } catch (e: UnknownDomainObjectException) { + tasks.register(fatFrameworkTaskName, FatFrameworkTask::class.java) { + it.baseName = binary.baseName + it.destinationDir = it.destinationDir.resolve(binary.buildType.name.toLowerCase()) + } + } + + fatFrameworkTask.configure { + try { + it.from(binary) + } catch (e: Exception) { + logger.warn("Cannot add binary ${binary.name} dependency to fat framework", e) + } + } + + if (configurations.findByName(fatFrameworkConfigurationName) == null) { + configurations.create(fatFrameworkConfigurationName) { it.isCanBeConsumed = true it.isCanBeResolved = false - } - with(configuration) { - usesPlatformOf(binary.target) - project.afterEvaluate { - val linkArtifact = project.artifacts.add(name, binary.outputFile) { artifact -> - artifact.name = name - artifact.extension = "framework" - artifact.type = "binary" - artifact.classifier = "framework" - artifact.builtBy(result) - } - project.extensions.getByType(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet::class.java) - .addCandidate(linkArtifact) - artifacts.add(linkArtifact) - attributes.attribute( - ArtifactAttributes.ARTIFACT_FORMAT, - NativeArtifactFormat.FRAMEWORK - ) - attributes.attribute( - KotlinNativeTarget.konanBuildTypeAttribute, - binary.buildType.name - ) - // capture type parameter T - fun copyAttribute(key: Attribute, from: AttributeContainer, to: AttributeContainer) { - to.attribute(key, from.getAttribute(key)!!) - } - binary.target.getAttributes().keySet().forEach { - copyAttribute(it, binary.target.getAttributes(), this.attributes) - } - binary.attributes.keySet().forEach { - copyAttribute(it, binary.attributes, this.attributes) - } - } + it.configureConfiguration(true, fatFrameworkTask) } } } - private fun configurationName(name: String, type: String): String = - listOf(name, type, "frameworks").joinToString("") { it.capitalize() }.decapitalize() + private fun frameworkConfigurationName(name: String, type: String): String = + listOf(name, type, "framework").joinToString("") { it.capitalize() }.decapitalize() private fun Project.createRunTask(binary: Executable) { val taskName = binary.runTaskName ?: return From a6cdfeafede31350a9dae919af53a7445fbe4070 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Tue, 2 Feb 2021 11:20:58 +0300 Subject: [PATCH 110/368] [Gradle, K/N] Consumable frameworks review fixes --- .../targets/native/KotlinNativeTarget.kt | 4 +- .../native/KotlinNativeTargetConfigurator.kt | 48 ++++++++++--------- .../gradle/targets/native/NativeBinaries.kt | 10 +++- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt index aa0ad9edd13..0ec743272be 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTarget.kt @@ -129,8 +129,8 @@ open class KotlinNativeTarget @Inject constructor( "org.jetbrains.kotlin.native.target", String::class.java ) - val konanBuildTypeAttribute = Attribute.of( - "org.jetbrains.kotlin.native.type", + val kotlinNativeBuildTypeAttribute = Attribute.of( + "org.jetbrains.kotlin.native.build.type", String::class.java ) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt index 505d924d93b..c14063e42ef 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/KotlinNativeTargetConfigurator.kt @@ -38,6 +38,7 @@ import org.jetbrains.kotlin.gradle.tasks.* import org.jetbrains.kotlin.gradle.testing.internal.configureConventions import org.jetbrains.kotlin.gradle.testing.internal.kotlinTestRegistry import org.jetbrains.kotlin.gradle.testing.testTaskName +import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName import org.jetbrains.kotlin.konan.target.HostManager import org.jetbrains.kotlin.konan.target.KonanTarget import java.io.File @@ -151,8 +152,7 @@ open class KotlinNativeTargetConfigurator( binary: Framework, linkTask: TaskProvider ) { - fun Configuration.configureConfiguration(fat: Boolean, taskProvider: TaskProvider) { - usesPlatformOf(binary.target) + fun Configuration.configureConfiguration(taskProvider: TaskProvider) { project.afterEvaluate { val task = taskProvider.get() val artifactFile = when (task) { @@ -169,38 +169,38 @@ open class KotlinNativeTargetConfigurator( project.extensions.getByType(org.gradle.api.internal.plugins.DefaultArtifactPublicationSet::class.java) .addCandidate(linkArtifact) artifacts.add(linkArtifact) + attributes.attribute(KotlinPlatformType.attribute, binary.target.platformType) attributes.attribute( - org.gradle.api.internal.artifacts.ArtifactAttributes.ARTIFACT_FORMAT, - org.jetbrains.kotlin.gradle.plugin.KotlinNativeTargetConfigurator.NativeArtifactFormat.FRAMEWORK + ArtifactAttributes.ARTIFACT_FORMAT, + NativeArtifactFormat.FRAMEWORK ) attributes.attribute( - org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget.konanBuildTypeAttribute, + KotlinNativeTarget.kotlinNativeBuildTypeAttribute, binary.buildType.name ) + if (attributes.getAttribute(Framework.frameworkTargets) == null) { + attributes.attribute( + Framework.frameworkTargets, + setOf(binary.target.konanTarget.name) + ) + } // capture type parameter T fun copyAttribute(key: Attribute, from: AttributeContainer, to: AttributeContainer) { to.attribute(key, from.getAttribute(key)!!) } - binary.target.getAttributes().keySet().forEach { - copyAttribute(it, binary.target.getAttributes(), this.attributes) - } - if (fat) { - attributes.attribute(KotlinNativeTarget.konanTargetAttribute, "fat") - // else is already set to real konan target - } - binary.attributes.keySet().forEach { + binary.attributes.keySet().filter { it != KotlinNativeTarget.konanTargetAttribute }.forEach { copyAttribute(it, binary.attributes, this.attributes) } } } - configurations.create(frameworkConfigurationName(binary.target.name, binary.buildType.name.toLowerCase()) + binary.baseName) { + configurations.create(lowerCamelCaseName(binary.name, binary.target.name)) { it.isCanBeConsumed = true it.isCanBeResolved = false - it.configureConfiguration(false, linkTask) + it.configureConfiguration(linkTask) } - val fatFrameworkConfigurationName = frameworkConfigurationName(binary.baseName, binary.buildType.name.toLowerCase() + "Fat") + val fatFrameworkConfigurationName = lowerCamelCaseName(binary.name, binary.target.konanTarget.family.name.toLowerCase(), "fat") val fatFrameworkTaskName = "link${fatFrameworkConfigurationName.capitalize()}" val fatFrameworkTask = try { @@ -220,17 +220,19 @@ open class KotlinNativeTargetConfigurator( } } - if (configurations.findByName(fatFrameworkConfigurationName) == null) { - configurations.create(fatFrameworkConfigurationName) { + // maybeCreate is not used as it does not provide way to configure once + val fatConfiguration = + configurations.findByName(fatFrameworkConfigurationName) ?: configurations.create(fatFrameworkConfigurationName) { it.isCanBeConsumed = true it.isCanBeResolved = false - it.configureConfiguration(true, fatFrameworkTask) + it.configureConfiguration(fatFrameworkTask) } - } - } - private fun frameworkConfigurationName(name: String, type: String): String = - listOf(name, type, "framework").joinToString("") { it.capitalize() }.decapitalize() + fatConfiguration.attributes.attribute( + Framework.frameworkTargets, + (fatConfiguration.attributes.getAttribute(Framework.frameworkTargets) ?: setOf()) + binary.target.konanTarget.name + ) + } private fun Project.createRunTask(binary: Executable) { val taskName = binary.runTaskName ?: return diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt index ce521fc7eab..8e74ce3d2dd 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt @@ -12,7 +12,6 @@ import org.gradle.api.Named import org.gradle.api.Project import org.gradle.api.artifacts.Dependency import org.gradle.api.attributes.Attribute -import org.gradle.api.attributes.AttributeContainer import org.gradle.api.attributes.HasAttributes import org.gradle.api.provider.Provider import org.gradle.api.tasks.AbstractExecTask @@ -234,7 +233,7 @@ class Framework( compilation: KotlinNativeCompilation ) : AbstractNativeLibrary(name, baseName, buildType, compilation), HasAttributes { - private val attributeContainer = HierarchyAttributeContainer(parent = null) + private val attributeContainer = HierarchyAttributeContainer(parent = compilation.attributes) override fun getAttributes() = attributeContainer @@ -281,6 +280,13 @@ class Framework( /** Embed placeholder LLVM IR data as a marker. */ MARKER, } + + companion object { + val frameworkTargets = Attribute.of( + "org.jetbrains.kotlin.native.framework.targets", + Set::class.java + ) + } } From cbeb0310994cc32355d3047c3cffb16e055e3b07 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Tue, 2 Feb 2021 13:29:21 +0300 Subject: [PATCH 111/368] [Gradle, K/N] Move NativeBinaryTypes from kotlin-gradle-plugin to kotlin-gradle-plugin-api --- .../kotlin-gradle-plugin-api/build.gradle.kts | 3 ++- .../gradle/plugin/mpp}/NativeBinaryTypes.kt | 17 ++++++++++++++++- .../tools/kotlin-gradle-plugin/build.gradle.kts | 1 - .../gradle/targets/native/NativeBinaries.kt | 11 ----------- .../targets/native/tasks/KotlinNativeTasks.kt | 8 ++++---- 5 files changed, 22 insertions(+), 18 deletions(-) rename libraries/tools/{kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native => kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp}/NativeBinaryTypes.kt (83%) diff --git a/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts index da346772e8b..fe436db8a7f 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts @@ -11,7 +11,8 @@ publish() standardPublicJars() dependencies { - compile(kotlinStdlib()) + implementation(kotlinStdlib()) + implementation(project(":native:kotlin-native-utils")) compileOnly(gradleApi()) compileOnly("com.android.tools.build:gradle:0.4.2") diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaryTypes.kt b/libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/NativeBinaryTypes.kt similarity index 83% rename from libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaryTypes.kt rename to libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/NativeBinaryTypes.kt index 35ccc4371cc..9f3577aa4f4 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaryTypes.kt +++ b/libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/NativeBinaryTypes.kt @@ -1,8 +1,12 @@ +/* + * Copyright 2010-2021 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("PackageDirectoryMismatch") // Old package for compatibility package org.jetbrains.kotlin.gradle.plugin.mpp import org.gradle.api.Named -import org.jetbrains.kotlin.gradle.plugin.mpp.Framework.BitcodeEmbeddingMode import org.jetbrains.kotlin.konan.target.Architecture.ARM32 import org.jetbrains.kotlin.konan.target.Architecture.ARM64 import org.jetbrains.kotlin.konan.target.CompilerOutputKind @@ -71,4 +75,15 @@ enum class NativeOutputKind( }; open fun availableFor(target: KonanTarget) = true +} + +enum class BitcodeEmbeddingMode { + /** Don't embed LLVM IR bitcode. */ + DISABLE, + + /** Embed LLVM IR bitcode as data. */ + BITCODE, + + /** Embed placeholder LLVM IR data as a marker. */ + MARKER, } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts index ee19fadd8d2..dda3080ad94 100644 --- a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts @@ -42,7 +42,6 @@ dependencies { compile(kotlinStdlib()) compile(project(":kotlin-util-klib")) - compileOnly(project(":native:kotlin-native-utils")) compileOnly(project(":kotlin-reflect-api")) compileOnly(project(":kotlin-android-extensions")) compileOnly(project(":kotlin-build-common")) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt index 8e74ce3d2dd..bb4099b0c8b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt @@ -270,17 +270,6 @@ class Framework( */ var isStatic = false - enum class BitcodeEmbeddingMode { - /** Don't embed LLVM IR bitcode. */ - DISABLE, - - /** Embed LLVM IR bitcode as data. */ - BITCODE, - - /** Embed placeholder LLVM IR data as a marker. */ - MARKER, - } - companion object { val frameworkTargets = Attribute.of( "org.jetbrains.kotlin.native.framework.targets", diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTasks.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTasks.kt index 236c44d860e..3dd402f4ad8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTasks.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTasks.kt @@ -578,8 +578,8 @@ open class KotlinNativeLink : AbstractKotlinNativeCompile = mutableListOf().apply { @@ -590,8 +590,8 @@ open class KotlinNativeLink : AbstractKotlinNativeCompile add("-Xembed-bitcode-marker") - Framework.BitcodeEmbeddingMode.BITCODE -> add("-Xembed-bitcode") + BitcodeEmbeddingMode.MARKER -> add("-Xembed-bitcode-marker") + BitcodeEmbeddingMode.BITCODE -> add("-Xembed-bitcode") else -> { /* Do nothing. */ } } From 383b9834a167cab453a24837c0f1000ee18404c6 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Sun, 14 Feb 2021 11:51:18 +0300 Subject: [PATCH 112/368] [Gradle, K/N] Make BitcodeEmbeddingMode move backward compatible --- .../kotlin/gradle/targets/native/NativeBinaries.kt | 14 ++++++++++---- .../targets/native/tasks/KotlinNativeTasks.kt | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt index bb4099b0c8b..b5f36979ed8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeBinaries.kt @@ -244,12 +244,12 @@ class Framework( /** * Embed bitcode for the framework or not. See [BitcodeEmbeddingMode]. */ - var embedBitcode: BitcodeEmbeddingMode = buildType.embedBitcode(konanTarget) + var embedBitcode: org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode = buildType.embedBitcode(konanTarget) /** * Enable or disable embedding bitcode for the framework. See [BitcodeEmbeddingMode]. */ - fun embedBitcode(mode: BitcodeEmbeddingMode) { + fun embedBitcode(mode: org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode) { embedBitcode = mode } @@ -263,15 +263,21 @@ class Framework( * marker - Embed placeholder LLVM IR data as a marker. * Has the same effect as the -Xembed-bitcode-marker command line option. */ - fun embedBitcode(mode: String) = embedBitcode(BitcodeEmbeddingMode.valueOf(mode.toUpperCase())) + fun embedBitcode(mode: String) = embedBitcode(org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode.valueOf(mode.toUpperCase())) /** * Specifies if the framework is linked as a static library (false by default). */ var isStatic = false + object BitcodeEmbeddingMode { + val DISABLE = org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode.DISABLE + val BITCODE = org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode.BITCODE + val MARKER = org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode.MARKER + } + companion object { - val frameworkTargets = Attribute.of( + val frameworkTargets: Attribute> = Attribute.of( "org.jetbrains.kotlin.native.framework.targets", Set::class.java ) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTasks.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTasks.kt index 3dd402f4ad8..ef913351019 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTasks.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTasks.kt @@ -590,8 +590,8 @@ open class KotlinNativeLink : AbstractKotlinNativeCompile add("-Xembed-bitcode-marker") - BitcodeEmbeddingMode.BITCODE -> add("-Xembed-bitcode") + Framework.BitcodeEmbeddingMode.MARKER -> add("-Xembed-bitcode-marker") + Framework.BitcodeEmbeddingMode.BITCODE -> add("-Xembed-bitcode") else -> { /* Do nothing. */ } } From c7427a751a985f33a96d445f6807940e53aa0ad9 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Mon, 8 Feb 2021 21:09:00 +0300 Subject: [PATCH 113/368] [Gradle, K/N] Add integration tests for framework artifacts #KT-43556 Fixed --- .../kotlin/gradle/native/GeneralNativeIT.kt | 83 +++++++++++++++++++ .../frameworks/build.gradle.kts | 5 ++ 2 files changed, 88 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt index bbf0dea1eba..a3a0697038e 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt @@ -205,6 +205,89 @@ class GeneralNativeIT : BaseGradleIT() { } } + @Test + fun testCanProvideNativeFrameworkArtifact() = with( + transformNativeTestProjectWithPluginDsl("frameworks", directoryPrefix = "native-binaries") + ) { + Assume.assumeTrue(HostManager.hostIsMac) + + gradleBuildScript().appendText( + """ + val frameworkTargets = Attribute.of( + "org.jetbrains.kotlin.native.framework.targets", + Set::class.java + ) + val kotlinNativeBuildTypeAttribute = Attribute.of( + "org.jetbrains.kotlin.native.build.type", + String::class.java + ) + + fun validateConfiguration(conf: Configuration, targets: Set, expectedBuildType: String) { + if (conf.artifacts.files.count() != 1 || conf.artifacts.files.singleFile.name != "main.framework") { + throw IllegalStateException("No single artifact with proper name \"main.framework\"") + } + val confTargets = conf.attributes.getAttribute(frameworkTargets)!! + val buildType = conf.attributes.getAttribute(kotlinNativeBuildTypeAttribute)!! + if (confTargets.size != targets.size || !confTargets.containsAll(targets)) { + throw IllegalStateException("Framework has incorrect attributes. Expected targets: \"${'$'}targets\", actual: \"${'$'}confTargets\"") + } + if (buildType != expectedBuildType) { + throw IllegalStateException("Framework has incorrect attributes. Expected build type: \"${'$'}expectedBuildType\", actual: \"${'$'}buildType\"") + } + } + + tasks.register("validateThinArtifacts") { + doLast { + val targets = listOf("ios" to "ios_arm64", "iosSim" to "ios_x64") + val buildTypes = listOf("release", "debug") + targets.forEach { (name, target) -> + buildTypes.forEach { buildType -> + val conf = project.configurations.getByName("main${'$'}{buildType.capitalize()}Framework${'$'}{name.capitalize()}") + validateConfiguration(conf, setOf(target), buildType.toUpperCase()) + } + } + } + } + + tasks.register("validateFatArtifacts") { + doLast { + val buildTypes = listOf("release", "debug") + buildTypes.forEach { buildType -> + val conf = project.configurations.getByName("main${'$'}{buildType.capitalize()}FrameworkIosFat") + validateConfiguration(conf, setOf("ios_x64", "ios_arm64"), buildType.toUpperCase()) + } + } + } + + tasks.register("validateCustomAttributesSetting") { + doLast { + val conf = project.configurations.getByName("customReleaseFrameworkIos") + val attr1Value = conf.attributes.getAttribute(disambiguation1Attribute) + if (attr1Value != "someValue") { + throw IllegalStateException("myDisambiguation1Attribute has incorrect value. Expected: \"someValue\", actual: \"${'$'}attr1Value\"") + } + val attr2Value = conf.attributes.getAttribute(disambiguation2Attribute) + if (attr2Value != "someValue2") { + throw IllegalStateException("myDisambiguation2Attribute has incorrect value. Expected: \"someValue2\", actual: \"${'$'}attr2Value\"") + } + } + } + """.trimIndent() + ) + + build(":validateThinArtifacts") { + assertSuccessful() + } + + build(":validateFatArtifacts") { + assertSuccessful() + } + + build(":validateCustomAttributesSetting") { + assertSuccessful() + } + } + @Test fun testCanProduceNativeFrameworks() = with( transformNativeTestProjectWithPluginDsl("frameworks", directoryPrefix = "native-binaries") diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/frameworks/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/frameworks/build.gradle.kts index 207f06cd23b..22657626b9f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/frameworks/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-binaries/frameworks/build.gradle.kts @@ -7,6 +7,9 @@ repositories { jcenter() } +val disambiguation1Attribute = Attribute.of("myDisambiguation1Attribute", String::class.java) +val disambiguation2Attribute = Attribute.of("myDisambiguation2Attribute", String::class.java) + kotlin { sourceSets["commonMain"].apply { dependencies { @@ -16,6 +19,7 @@ kotlin { } iosArm64("ios") { + attributes.attribute(disambiguation1Attribute, "someValue") binaries { framework("main") { export(project(":exported")) @@ -25,6 +29,7 @@ kotlin { linkerOpts = mutableListOf("-L.") freeCompilerArgs = mutableListOf("-Xtime") isStatic = true + attributes.attribute(disambiguation2Attribute, "someValue2") } } } From ef458b20e133135baed1f9689088f372407d300a Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Sun, 14 Feb 2021 11:51:50 +0300 Subject: [PATCH 114/368] [Gradle] Replace deprecated dependencies configurations in buildscript --- .../build.gradle.kts | 43 ++++++++++--------- .../kotlin-gradle-plugin/build.gradle.kts | 26 +++++------ 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts index 1531f9f1247..e8d6c910297 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts @@ -14,33 +14,34 @@ pill { val kotlinGradlePluginTest = project(":kotlin-gradle-plugin").sourceSets.getByName("test") dependencies { - testCompile(project(":kotlin-gradle-plugin")) - testCompile(kotlinGradlePluginTest.output) - testCompile(project(":kotlin-gradle-subplugin-example")) - testCompile(project(":kotlin-allopen")) - testCompile(project(":kotlin-noarg")) - testCompile(project(":kotlin-sam-with-receiver")) - testCompile(project(":kotlin-test:kotlin-test-jvm")) - testCompile(project(":native:kotlin-native-utils")) + testImplementation(project(":kotlin-gradle-plugin")) + testImplementation(kotlinGradlePluginTest.output) + testImplementation(project(":kotlin-gradle-subplugin-example")) + testImplementation(project(":kotlin-allopen")) + testImplementation(project(":kotlin-noarg")) + testImplementation(project(":kotlin-sam-with-receiver")) + testImplementation(project(":kotlin-test:kotlin-test-jvm")) + testImplementation(project(":native:kotlin-native-utils")) - testCompile(projectRuntimeJar(":kotlin-compiler-embeddable")) - testCompile(intellijCoreDep()) { includeJars("jdom") } + testImplementation(projectRuntimeJar(":kotlin-compiler-embeddable")) + testImplementation(intellijCoreDep()) { includeJars("jdom") } // testCompileOnly dependency on non-shaded artifacts is needed for IDE support - // testRuntime on shaded artifact is needed for running tests with shaded compiler + // testRuntimeOnly on shaded artifact is needed for running tests with shaded compiler testCompileOnly(project(path = ":kotlin-gradle-plugin-test-utils-embeddable", configuration = "compile")) - testRuntime(projectRuntimeJar(":kotlin-gradle-plugin-test-utils-embeddable")) + testRuntimeOnly(projectRuntimeJar(":kotlin-gradle-plugin-test-utils-embeddable")) - testCompile(project(path = ":examples:annotation-processor-example")) - testCompile(kotlinStdlib("jdk8")) - testCompile(project(":kotlin-reflect")) - testCompile(project(":kotlin-android-extensions")) - testCompile(project(":kotlin-parcelize-compiler")) - testCompile(commonDep("org.jetbrains.intellij.deps", "trove4j")) + testImplementation(project(path = ":examples:annotation-processor-example")) + testImplementation(kotlinStdlib("jdk8")) + testImplementation(project(":kotlin-reflect")) + testImplementation(project(":kotlin-android-extensions")) + testImplementation(project(":kotlin-parcelize-compiler")) + testImplementation(commonDep("org.jetbrains.intellij.deps", "trove4j")) - testCompile(gradleApi()) + testImplementation(gradleApi()) + testImplementation("com.google.code.gson:gson:${rootProject.extra["versions.jar.gson"]}") - testRuntime(projectRuntimeJar(":kotlin-android-extensions")) - testRuntime(project(":compiler:tests-mutes")) + testRuntimeOnly(projectRuntimeJar(":kotlin-android-extensions")) + testRuntimeOnly(project(":compiler:tests-mutes")) // Workaround for missing transitive import of the common(project `kotlin-test-common` // for `kotlin-test-jvm` into the IDE: diff --git a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts index dda3080ad94..d0f46edc9ee 100644 --- a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts @@ -34,14 +34,14 @@ pill { } dependencies { - compile(project(":kotlin-gradle-plugin-api")) - compile(project(":kotlin-gradle-plugin-model")) + api(project(":kotlin-gradle-plugin-api")) + api(project(":kotlin-gradle-plugin-model")) compileOnly(project(":compiler")) compileOnly(project(":compiler:incremental-compilation-impl")) compileOnly(project(":daemon-common")) - compile(kotlinStdlib()) - compile(project(":kotlin-util-klib")) + implementation(kotlinStdlib()) + implementation(project(":kotlin-util-klib")) compileOnly(project(":kotlin-reflect-api")) compileOnly(project(":kotlin-android-extensions")) compileOnly(project(":kotlin-build-common")) @@ -54,8 +54,8 @@ dependencies { compileOnly(project(":kotlin-gradle-build-metrics")) embedded(project(":kotlin-gradle-build-metrics")) - compile("com.google.code.gson:gson:${rootProject.extra["versions.jar.gson"]}") - compile("de.undercouch:gradle-download-task:4.0.2") + implementation("com.google.code.gson:gson:${rootProject.extra["versions.jar.gson"]}") + implementation("de.undercouch:gradle-download-task:4.0.2") implementation("com.github.gundy:semver4j:0.16.4:nodeps") { exclude(group = "*") } @@ -89,15 +89,15 @@ dependencies { because("Functional tests are using APIs from Android. Latest Version is used to avoid NoClassDefFoundError") } - testCompile(intellijDep()) { includeJars("junit", "serviceMessages", rootProject = rootProject) } + testImplementation(intellijDep()) { includeJars("junit", "serviceMessages", rootProject = rootProject) } testCompileOnly(project(":compiler")) - testCompile(projectTests(":kotlin-build-common")) - testCompile(project(":kotlin-android-extensions")) - testCompile(project(":kotlin-compiler-runner")) - testCompile(project(":kotlin-test::kotlin-test-junit")) - testCompile("junit:junit:4.12") - testCompile(project(":kotlin-gradle-statistics")) + testImplementation(projectTests(":kotlin-build-common")) + testImplementation(project(":kotlin-android-extensions")) + testImplementation(project(":kotlin-compiler-runner")) + testImplementation(project(":kotlin-test::kotlin-test-junit")) + testImplementation("junit:junit:4.12") + testImplementation(project(":kotlin-gradle-statistics")) testCompileOnly(project(":kotlin-reflect-api")) testCompileOnly(project(":kotlin-annotation-processing")) testCompileOnly(project(":kotlin-annotation-processing-gradle")) From 683bd0ed3840a56cd428da6c6787f8e623391ec7 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Mon, 25 Jan 2021 22:29:50 +0300 Subject: [PATCH 115/368] [Gradle, JVM] Don't create deprecated compile/runtime configurations Gradle also removes these configurations in 7.0. See gradle/gradle@2cb45cdbd0756b718a17918abd1773e816f40551 #KT-44462 Fixed --- .../gradle/VariantAwareDependenciesIT.kt | 10 ++--- .../gradle/plugin/KotlinTargetConfigurator.kt | 43 ++++++++++--------- .../gradle/targets/jvm/KotlinJvmTarget.kt | 12 +++--- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt index 5bbe3b09eeb..e3a903fd6f2 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt @@ -165,9 +165,9 @@ class VariantAwareDependenciesIT : BaseGradleIT() { "\n" + """ dependencies { jvm6Implementation project(':${innerJvmProject.projectName}') - jvm6TestRuntime project(':${innerJvmProject.projectName}') + jvm6TestRuntimeOnly project(':${innerJvmProject.projectName}') nodeJsImplementation project(':${innerJsProject.projectName}') - nodeJsTestRuntime project(':${innerJsProject.projectName}') + nodeJsTestRuntimeOnly project(':${innerJsProject.projectName}') } """.trimIndent() ) @@ -184,12 +184,8 @@ class VariantAwareDependenciesIT : BaseGradleIT() { with(outerProject) { embedProject(innerProject) - gradleBuildScript().appendText( - "\nconfigurations['jvm6TestRuntime'].canBeConsumed = true" - ) - gradleBuildScript(innerProject.projectName).appendText( - "\ndependencies { testImplementation project(path: ':', configuration: 'jvm6TestRuntime') }" + "\ndependencies { testImplementation project(path: ':', configuration: 'jvm6RuntimeElements') }" ) testResolveAllConfigurations(innerProject.projectName) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt index 4373f0ac20d..5a77f3dded5 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinTargetConfigurator.kt @@ -171,7 +171,7 @@ abstract class AbstractKotlinTargetConfigurator val mainCompilation = target.compilations.maybeCreate(KotlinCompilation.MAIN_COMPILATION_NAME) - val compileConfiguration = configurations.maybeCreate(mainCompilation.deprecatedCompileConfigurationName) + val compileConfiguration = configurations.findByName(mainCompilation.deprecatedCompileConfigurationName) val implementationConfiguration = configurations.maybeCreate(mainCompilation.implementationConfigurationName) val runtimeOnlyConfiguration = configurations.maybeCreate(mainCompilation.runtimeOnlyConfigurationName) @@ -184,8 +184,8 @@ abstract class AbstractKotlinTargetConfigurator attributes.attribute(USAGE_ATTRIBUTE, KotlinUsages.producerApiUsage(target)) extendsFrom(configurations.maybeCreate(mainCompilation.apiConfigurationName)) if (mainCompilation is KotlinCompilationToRunnableFiles) { - val runtimeConfiguration = configurations.maybeCreate(mainCompilation.deprecatedRuntimeConfigurationName) - extendsFrom(runtimeConfiguration) + val runtimeConfiguration = configurations.findByName(mainCompilation.deprecatedRuntimeConfigurationName) + runtimeConfiguration?.let { extendsFrom(it) } } usesPlatformOf(target) setupAsPublicConfigurationIfSupported(target) @@ -198,8 +198,9 @@ abstract class AbstractKotlinTargetConfigurator isCanBeConsumed = true isCanBeResolved = false attributes.attribute(USAGE_ATTRIBUTE, KotlinUsages.producerRuntimeUsage(target)) - val runtimeConfiguration = configurations.maybeCreate(mainCompilation.deprecatedRuntimeConfigurationName) - extendsFrom(implementationConfiguration, runtimeOnlyConfiguration, runtimeConfiguration) + val runtimeConfiguration = configurations.findByName(mainCompilation.deprecatedRuntimeConfigurationName) + extendsFrom(implementationConfiguration, runtimeOnlyConfiguration) + runtimeConfiguration?.let { extendsFrom(it) } usesPlatformOf(target) setupAsPublicConfigurationIfSupported(target) } @@ -210,18 +211,18 @@ abstract class AbstractKotlinTargetConfigurator if (createTestCompilation) { val testCompilation = target.compilations.getByName(KotlinCompilation.TEST_COMPILATION_NAME) - val compileTestsConfiguration = configurations.maybeCreate(testCompilation.deprecatedCompileConfigurationName) + val compileTestsConfiguration = configurations.findByName(testCompilation.deprecatedCompileConfigurationName) val testImplementationConfiguration = configurations.maybeCreate(testCompilation.implementationConfigurationName) val testRuntimeOnlyConfiguration = configurations.maybeCreate(testCompilation.runtimeOnlyConfigurationName) - compileTestsConfiguration.extendsFrom(compileConfiguration) + compileConfiguration?.let { compileTestsConfiguration?.extendsFrom(it) } testImplementationConfiguration.extendsFrom(implementationConfiguration) testRuntimeOnlyConfiguration.extendsFrom(runtimeOnlyConfiguration) if (mainCompilation is KotlinCompilationToRunnableFiles && testCompilation is KotlinCompilationToRunnableFiles) { - val runtimeConfiguration = configurations.maybeCreate(mainCompilation.deprecatedRuntimeConfigurationName) - val testRuntimeConfiguration = configurations.maybeCreate(testCompilation.deprecatedRuntimeConfigurationName) - testRuntimeConfiguration.extendsFrom(runtimeConfiguration) + val runtimeConfiguration = configurations.findByName(mainCompilation.deprecatedRuntimeConfigurationName) + val testRuntimeConfiguration = configurations.findByName(testCompilation.deprecatedRuntimeConfigurationName) + runtimeConfiguration?.let { testRuntimeConfiguration?.extendsFrom(it) } } } } @@ -248,8 +249,8 @@ abstract class AbstractKotlinTargetConfigurator if (createTestCompilation) { val testCompilation = target.compilations.getByName(KotlinCompilation.TEST_COMPILATION_NAME) if (testCompilation is KotlinCompilationToRunnableFiles) { - addDependsOnTaskInOtherProjects(project, buildNeeded, true, testCompilation.deprecatedRuntimeConfigurationName) - addDependsOnTaskInOtherProjects(project, buildDependent, false, testCompilation.deprecatedRuntimeConfigurationName) + addDependsOnTaskInOtherProjects(project, buildNeeded, true, testCompilation.runtimeDependencyConfigurationName) + addDependsOnTaskInOtherProjects(project, buildDependent, false, testCompilation.runtimeDependencyConfigurationName) } } } @@ -271,7 +272,7 @@ abstract class AbstractKotlinTargetConfigurator val target = compilation.target val configurations = target.project.configurations - val compileConfiguration = configurations.maybeCreate(compilation.deprecatedCompileConfigurationName).apply { + val compileConfiguration = configurations.findByName(compilation.deprecatedCompileConfigurationName)?.apply { isCanBeConsumed = false setupAsLocalTargetSpecificConfigurationIfSupported(target) isVisible = false @@ -280,7 +281,7 @@ abstract class AbstractKotlinTargetConfigurator } val apiConfiguration = configurations.maybeCreate(compilation.apiConfigurationName).apply { - extendsFrom(compileConfiguration) + compileConfiguration?.let { extendsFrom(it) } isVisible = false isCanBeConsumed = false isCanBeResolved = false @@ -288,7 +289,8 @@ abstract class AbstractKotlinTargetConfigurator } val implementationConfiguration = configurations.maybeCreate(compilation.implementationConfigurationName).apply { - extendsFrom(compileConfiguration, apiConfiguration) + extendsFrom(apiConfiguration) + compileConfiguration?.let { extendsFrom(it) } isVisible = false isCanBeConsumed = false isCanBeResolved = false @@ -313,10 +315,10 @@ abstract class AbstractKotlinTargetConfigurator } if (compilation is KotlinCompilationToRunnableFiles) { - val runtimeConfiguration = configurations.maybeCreate(compilation.deprecatedRuntimeConfigurationName).apply { + val runtimeConfiguration = configurations.findByName(compilation.deprecatedRuntimeConfigurationName)?.apply { isCanBeConsumed = false setupAsLocalTargetSpecificConfigurationIfSupported(target) - extendsFrom(compileConfiguration) + compileConfiguration?.let { extendsFrom(it) } isVisible = false isCanBeResolved = true // Needed for IDE import description = @@ -331,7 +333,8 @@ abstract class AbstractKotlinTargetConfigurator } val runtimeClasspathConfiguration = configurations.maybeCreate(compilation.runtimeDependencyConfigurationName).apply { - extendsFrom(runtimeOnlyConfiguration, runtimeConfiguration, implementationConfiguration) + extendsFrom(runtimeOnlyConfiguration, implementationConfiguration) + runtimeConfiguration?.let { extendsFrom(it) } usesPlatformOf(target) isVisible = false isCanBeConsumed = false @@ -411,9 +414,9 @@ abstract class KotlinOnlyTargetConfigurator) { - val runtimeConfiguration = project.configurations.getByName(mainCompilation.deprecatedRuntimeConfigurationName) + val runtimeConfiguration = project.configurations.findByName(mainCompilation.deprecatedRuntimeConfigurationName) val runtimeElementsConfiguration = project.configurations.getByName(target.runtimeElementsConfigurationName) - addJarIfNoArtifactsPresent(runtimeConfiguration, jarArtifact) + runtimeConfiguration?.let { addJarIfNoArtifactsPresent(runtimeConfiguration, jarArtifact) } addJarIfNoArtifactsPresent(runtimeElementsConfiguration, jarArtifact) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/jvm/KotlinJvmTarget.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/jvm/KotlinJvmTarget.kt index 79cfe2dec29..67383ff6eb2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/jvm/KotlinJvmTarget.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/jvm/KotlinJvmTarget.kt @@ -131,20 +131,20 @@ open class KotlinJvmTarget @Inject constructor( ) { // Make sure Kotlin compilation dependencies appear in the Java source set classpaths: - listOf( + listOfNotNull( compilation.apiConfigurationName, compilation.implementationConfigurationName, compilation.compileOnlyConfigurationName, - compilation.deprecatedCompileConfigurationName + compilation.deprecatedCompileConfigurationName.takeIf { project.configurations.findByName(it) != null } ).forEach { configurationName -> project.addExtendsFromRelation(javaSourceSet.compileClasspathConfigurationName, configurationName) } - listOf( + listOfNotNull( compilation.apiConfigurationName, compilation.implementationConfigurationName, compilation.runtimeOnlyConfigurationName, - compilation.deprecatedRuntimeConfigurationName + compilation.deprecatedRuntimeConfigurationName.takeIf { project.configurations.findByName(it) != null } ).forEach { configurationName -> project.addExtendsFromRelation(javaSourceSet.runtimeClasspathConfigurationName, configurationName) } @@ -152,7 +152,7 @@ open class KotlinJvmTarget @Inject constructor( // Add the Java source set dependencies to the Kotlin compilation compile & runtime configurations: listOfNotNull( - javaSourceSet.compileConfigurationName, + javaSourceSet.compileConfigurationName.takeIf { project.configurations.findByName(it) != null }, javaSourceSet.compileOnlyConfigurationName, javaSourceSet.apiConfigurationName.takeIf { project.configurations.findByName(it) != null }, javaSourceSet.implementationConfigurationName @@ -161,7 +161,7 @@ open class KotlinJvmTarget @Inject constructor( } listOfNotNull( - javaSourceSet.runtimeConfigurationName, + javaSourceSet.runtimeConfigurationName.takeIf { project.configurations.findByName(it) != null }, javaSourceSet.runtimeOnlyConfigurationName, javaSourceSet.apiConfigurationName.takeIf { project.configurations.findByName(it) != null }, javaSourceSet.implementationConfigurationName From b463a0fa5886eca15871ac5e8c4ebd1b1259c763 Mon Sep 17 00:00:00 2001 From: Alexander Likhachev Date: Mon, 15 Feb 2021 09:58:51 +0300 Subject: [PATCH 116/368] [Gradle] Use property provider for configuration time only if available --- .../kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt | 7 ++++++- .../kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt | 7 ++++++- .../kotlin/gradle/targets/native/tasks/KotlinNativeTest.kt | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt index aca60c1255c..068bc7c8e51 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.gradle.targets.js.testing.* import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig import org.jetbrains.kotlin.gradle.tasks.KotlinTest import org.jetbrains.kotlin.gradle.testing.internal.reportsDir +import org.jetbrains.kotlin.gradle.utils.isConfigurationCacheAvailable import org.jetbrains.kotlin.gradle.utils.property import org.slf4j.Logger import java.io.File @@ -60,7 +61,11 @@ class KotlinKarma( defaultConfigDirectory } private val isTeamCity by lazy { - project.providers.gradleProperty(TC_PROJECT_PROPERTY).forUseAtConfigurationTime().isPresent + if (isConfigurationCacheAvailable(project.gradle)) { + project.providers.gradleProperty(TC_PROJECT_PROPERTY).forUseAtConfigurationTime().isPresent + } else { + project.hasProperty(TC_PROJECT_PROPERTY) + } } override val requiredNpmDependencies: Set diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt index 58a355982f3..052f0b73bf2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/mocha/KotlinMocha.kt @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.gradle.targets.js.npm.npmProject import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTestFramework import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinTestRunnerCliArgs +import org.jetbrains.kotlin.gradle.utils.isConfigurationCacheAvailable import java.io.File class KotlinMocha(@Transient override val compilation: KotlinJsCompilation, private val basePath: String) : @@ -29,7 +30,11 @@ class KotlinMocha(@Transient override val compilation: KotlinJsCompilation, priv private val nodeJs = NodeJsRootPlugin.apply(project.rootProject) private val versions = nodeJs.versions private val isTeamCity by lazy { - project.providers.gradleProperty(TC_PROJECT_PROPERTY).forUseAtConfigurationTime().isPresent + if (isConfigurationCacheAvailable(project.gradle)) { + project.providers.gradleProperty(TC_PROJECT_PROPERTY).forUseAtConfigurationTime().isPresent + } else { + project.hasProperty(TC_PROJECT_PROPERTY) + } } override val settingsState: String diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTest.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTest.kt index 8f05af8113d..f13a5924831 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/tasks/KotlinNativeTest.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesTestExecuto import org.jetbrains.kotlin.gradle.plugin.mpp.isAtLeast import org.jetbrains.kotlin.gradle.targets.native.internal.parseKotlinNativeStackTraceAsJvm import org.jetbrains.kotlin.gradle.tasks.KotlinTest +import org.jetbrains.kotlin.gradle.utils.isConfigurationCacheAvailable import org.jetbrains.kotlin.konan.CompilerVersion import java.io.File import java.util.concurrent.Callable @@ -114,7 +115,11 @@ abstract class KotlinNativeTest : KotlinTest() { prependSuiteName = targetName != null, treatFailedTestOutputAsStacktrace = false, stackTraceParser = ::parseKotlinNativeStackTraceAsJvm, - escapeTCMessagesInLog = project.providers.gradleProperty(TC_PROJECT_PROPERTY).forUseAtConfigurationTime().isPresent + escapeTCMessagesInLog = if (isConfigurationCacheAvailable(project.gradle)) { + project.providers.gradleProperty(TC_PROJECT_PROPERTY).forUseAtConfigurationTime().isPresent + } else { + project.hasProperty(TC_PROJECT_PROPERTY) + } ) // The KotlinTest expects that the exit code is zero even if some tests failed. From dae1f4c05d20f46030e9b8b3d31b466a15d3459e Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Fri, 12 Feb 2021 13:06:55 +0300 Subject: [PATCH 117/368] Remove redundant extension receiver substitution during lambda's completion --- .../calls/tower/ResolvedAtomCompleter.kt | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt index d43f8c8a041..5a9b75285ff 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/ResolvedAtomCompleter.kt @@ -324,24 +324,6 @@ class ResolvedAtomCompleter( ) trace.recordType(ktArgumentExpression, substitutedFunctionalType) - - // Mainly this is needed for builder-like inference, when we have type `SomeType.() -> Unit` and now we want to update those K, V - val receiver = functionDescriptor.extensionReceiverParameter - if (receiver != null) { - require(receiver is ReceiverParameterDescriptorImpl) { - "Extension receiver for anonymous function ($receiver) should be ReceiverParameterDescriptorImpl" - } - - val valueType = receiver.value.type.unwrap() - val newValueType = resultSubstitutor.safeSubstitute(valueType) - - if (valueType !== newValueType) { - val newReceiverValue = receiver.value.replaceType(newValueType) - functionDescriptor.setExtensionReceiverParameter( - ReceiverParameterDescriptorImpl(receiver.containingDeclaration, newReceiverValue, receiver.annotations) - ) - } - } } private fun NewTypeSubstitutor.toOldSubstitution(): TypeSubstitution = object : TypeSubstitution() { From 6f64fd2fecfd12ac3bbc1e9086ffb3792eaa44dd Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Fri, 12 Feb 2021 13:58:27 +0300 Subject: [PATCH 118/368] Propagate inference session into declaration analyzers It prevents missing inference session for local declaration (local functions, local classes or objects) ^KT-44801 Fixed --- .../FirBlackBoxCodegenTestGenerated.java | 6 +++ .../kotlin/resolve/BodiesResolveContext.java | 4 ++ .../kotlin/resolve/BodyResolver.java | 42 +++++++++++-------- .../kotlin/resolve/LazyTopDownAnalyzer.kt | 6 ++- .../resolve/TopDownAnalysisContext.java | 21 ++++++++++ .../expressions/ExpressionTypingServices.java | 15 ++++--- .../expressions/FunctionsTypingVisitor.kt | 2 +- .../expressions/LocalClassifierAnalyzer.kt | 3 +- ...nferenceSessionIntoDeclarationAnalyzers.kt | 34 +++++++++++++++ .../lambdaParameterTypeInElvis.fir.kt | 14 ------- .../inference/lambdaParameterTypeInElvis.kt | 1 + .../codegen/BlackBoxCodegenTestGenerated.java | 6 +++ .../IrBlackBoxCodegenTestGenerated.java | 6 +++ .../LightAnalysisModeTestGenerated.java | 5 +++ .../idea/project/ResolveElementCache.kt | 7 +++- .../IrJsCodegenBoxES6TestGenerated.java | 5 +++ .../IrJsCodegenBoxTestGenerated.java | 5 +++ .../semantics/JsCodegenBoxTestGenerated.java | 5 +++ .../IrCodegenBoxWasmTestGenerated.java | 5 +++ 19 files changed, 150 insertions(+), 42 deletions(-) create mode 100644 compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt delete mode 100644 compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index b510296efee..31f405e06f1 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -16723,6 +16723,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inference/builderInference/lackOfNullCheckOnNullableInsideBuild.kt"); } + @Test + @TestMetadata("propagateInferenceSessionIntoDeclarationAnalyzers.kt") + public void testPropagateInferenceSessionIntoDeclarationAnalyzers() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt"); + } + @Test @TestMetadata("specialCallsWithCallableReferences.kt") public void testSpecialCallsWithCallableReferences() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodiesResolveContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodiesResolveContext.java index 1a148c41237..411116791b8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodiesResolveContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodiesResolveContext.java @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.scopes.LexicalScope; +import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext; import java.util.Collection; import java.util.Map; @@ -58,4 +59,7 @@ public interface BodiesResolveContext { @NotNull TopDownAnalysisMode getTopDownAnalysisMode(); + + @Nullable + ExpressionTypingContext getLocalContext(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java index e204e3c0b48..fcc9a8a3208 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java @@ -47,6 +47,7 @@ import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil; import org.jetbrains.kotlin.resolve.multiplatform.ExpectedActualResolver; import org.jetbrains.kotlin.resolve.scopes.*; import org.jetbrains.kotlin.types.*; +import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext; import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices; import org.jetbrains.kotlin.types.expressions.PreliminaryDeclarationVisitor; import org.jetbrains.kotlin.types.expressions.ValueParameterResolver; @@ -134,7 +135,7 @@ public class BodyResolver { for (Map.Entry entry : c.getSecondaryConstructors().entrySet()) { LexicalScope declaringScope = c.getDeclaringScope(entry.getKey()); assert declaringScope != null : "Declaring scope should be registered before body resolve"; - resolveSecondaryConstructorBody(c.getOuterDataFlowInfo(), trace, entry.getKey(), entry.getValue(), declaringScope); + resolveSecondaryConstructorBody(c.getOuterDataFlowInfo(), trace, entry.getKey(), entry.getValue(), declaringScope, c.getLocalContext()); } if (c.getSecondaryConstructors().isEmpty()) return; Set visitedConstructors = new HashSet<>(); @@ -148,18 +149,22 @@ public class BodyResolver { @NotNull BindingTrace trace, @NotNull KtSecondaryConstructor constructor, @NotNull ClassConstructorDescriptor descriptor, - @NotNull LexicalScope declaringScope + @NotNull LexicalScope declaringScope, + @Nullable ExpressionTypingContext localContext ) { ForceResolveUtil.forceResolveAllContents(descriptor.getAnnotations()); - resolveFunctionBody(outerDataFlowInfo, trace, constructor, descriptor, declaringScope, - headerInnerScope -> resolveSecondaryConstructorDelegationCall( - outerDataFlowInfo, trace, headerInnerScope, constructor, descriptor - ), - scope -> new LexicalScopeImpl( - scope, descriptor, scope.isOwnerDescriptorAccessibleByLabel(), scope.getImplicitReceiver(), - LexicalScopeKind.CONSTRUCTOR_HEADER - )); + resolveFunctionBody( + outerDataFlowInfo, trace, constructor, descriptor, declaringScope, + headerInnerScope -> resolveSecondaryConstructorDelegationCall( + outerDataFlowInfo, trace, headerInnerScope, constructor, descriptor + ), + scope -> new LexicalScopeImpl( + scope, descriptor, scope.isOwnerDescriptorAccessibleByLabel(), scope.getImplicitReceiver(), + LexicalScopeKind.CONSTRUCTOR_HEADER + ), + localContext + ); } @Nullable @@ -835,7 +840,7 @@ public class BodyResolver { if (getterDescriptor != null) { if (getter != null) { LexicalScope accessorScope = makeScopeForPropertyAccessor(c, getter, propertyDescriptor); - resolveFunctionBody(c.getOuterDataFlowInfo(), fieldAccessTrackingTrace, getter, getterDescriptor, accessorScope); + resolveFunctionBody(c.getOuterDataFlowInfo(), fieldAccessTrackingTrace, getter, getterDescriptor, accessorScope, c.getLocalContext()); } if (getter != null || forceResolveAnnotations) { @@ -849,7 +854,7 @@ public class BodyResolver { if (setterDescriptor != null) { if (setter != null) { LexicalScope accessorScope = makeScopeForPropertyAccessor(c, setter, propertyDescriptor); - resolveFunctionBody(c.getOuterDataFlowInfo(), fieldAccessTrackingTrace, setter, setterDescriptor, accessorScope); + resolveFunctionBody(c.getOuterDataFlowInfo(), fieldAccessTrackingTrace, setter, setterDescriptor, accessorScope, c.getLocalContext()); } if (setter != null || forceResolveAnnotations) { @@ -921,7 +926,7 @@ public class BodyResolver { bodyResolveCache.resolveFunctionBody(declaration).addOwnDataTo(trace, true); } else { - resolveFunctionBody(c.getOuterDataFlowInfo(), trace, declaration, entry.getValue(), scope); + resolveFunctionBody(c.getOuterDataFlowInfo(), trace, declaration, entry.getValue(), scope, c.getLocalContext()); } } } @@ -931,11 +936,12 @@ public class BodyResolver { @NotNull BindingTrace trace, @NotNull KtDeclarationWithBody function, @NotNull FunctionDescriptor functionDescriptor, - @NotNull LexicalScope declaringScope + @NotNull LexicalScope declaringScope, + @Nullable ExpressionTypingContext localContext ) { computeDeferredType(functionDescriptor.getReturnType()); - resolveFunctionBody(outerDataFlowInfo, trace, function, functionDescriptor, declaringScope, null, null); + resolveFunctionBody(outerDataFlowInfo, trace, function, functionDescriptor, declaringScope, null, null, localContext); assert functionDescriptor.getReturnType() != null; } @@ -948,7 +954,8 @@ public class BodyResolver { @NotNull LexicalScope scope, @Nullable Function1 beforeBlockBody, // Creates wrapper scope for header resolution if necessary (see resolveSecondaryConstructorBody) - @Nullable Function1 headerScopeFactory + @Nullable Function1 headerScopeFactory, + @Nullable ExpressionTypingContext localContext ) { ProgressManager.checkCanceled(); @@ -989,7 +996,8 @@ public class BodyResolver { if (function.hasBody()) { expressionTypingServices.checkFunctionReturnType( - innerScope, function, functionDescriptor, dataFlowInfo != null ? dataFlowInfo : outerDataFlowInfo, null, trace); + innerScope, function, functionDescriptor, dataFlowInfo != null ? dataFlowInfo : outerDataFlowInfo, null, trace, localContext + ); } assert functionDescriptor.getReturnType() != null; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt index 78169c3b760..01be3bc3ce9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt @@ -33,6 +33,7 @@ import org.jetbrains.kotlin.resolve.checkers.checkClassifierUsages import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver import org.jetbrains.kotlin.resolve.lazy.* import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor +import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext import java.util.* class LazyTopDownAnalyzer( @@ -57,9 +58,10 @@ class LazyTopDownAnalyzer( fun analyzeDeclarations( topDownAnalysisMode: TopDownAnalysisMode, declarations: Collection, - outerDataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY + outerDataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY, + localContext: ExpressionTypingContext? = null ): TopDownAnalysisContext { - val c = TopDownAnalysisContext(topDownAnalysisMode, outerDataFlowInfo, declarationScopeProvider) + val c = TopDownAnalysisContext(topDownAnalysisMode, outerDataFlowInfo, declarationScopeProvider, localContext) val topLevelFqNames = HashMultimap.create() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TopDownAnalysisContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TopDownAnalysisContext.java index e792e46db9c..0bcdb09617f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TopDownAnalysisContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TopDownAnalysisContext.java @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.lazy.DeclarationScopeProvider; import org.jetbrains.kotlin.resolve.scopes.LexicalScope; +import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext; import java.io.PrintStream; import java.util.*; @@ -49,6 +50,7 @@ public class TopDownAnalysisContext implements BodiesResolveContext { private final TopDownAnalysisMode topDownAnalysisMode; private final DeclarationScopeProvider declarationScopeProvider; + private final ExpressionTypingContext localContext; private StringBuilder debugOutput; @@ -60,6 +62,25 @@ public class TopDownAnalysisContext implements BodiesResolveContext { this.topDownAnalysisMode = topDownAnalysisMode; this.outerDataFlowInfo = outerDataFlowInfo; this.declarationScopeProvider = declarationScopeProvider; + this.localContext = null; + } + + public TopDownAnalysisContext( + @NotNull TopDownAnalysisMode topDownAnalysisMode, + @NotNull DataFlowInfo outerDataFlowInfo, + @NotNull DeclarationScopeProvider declarationScopeProvider, + @Nullable ExpressionTypingContext localContext + ) { + this.topDownAnalysisMode = topDownAnalysisMode; + this.outerDataFlowInfo = outerDataFlowInfo; + this.declarationScopeProvider = declarationScopeProvider; + this.localContext = localContext; + } + + @Override + @Nullable + public ExpressionTypingContext getLocalContext() { + return localContext; } @Override diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java index 907a1a3cca8..79244aeadaa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java @@ -145,7 +145,8 @@ public class ExpressionTypingServices { @NotNull FunctionDescriptor functionDescriptor, @NotNull DataFlowInfo dataFlowInfo, @Nullable KotlinType expectedReturnType, - BindingTrace trace + BindingTrace trace, + @Nullable ExpressionTypingContext localContext ) { if (expectedReturnType == null) { expectedReturnType = functionDescriptor.getReturnType(); @@ -153,11 +154,15 @@ public class ExpressionTypingServices { expectedReturnType = NO_EXPECTED_TYPE; } } - checkFunctionReturnType(function, ExpressionTypingContext.newContext( + + ExpressionTypingContext context = ExpressionTypingContext.newContext( trace, - functionInnerScope, dataFlowInfo, expectedReturnType != null ? expectedReturnType : NO_EXPECTED_TYPE, getLanguageVersionSettings(), - expressionTypingComponents.dataFlowValueFactory - )); + functionInnerScope, dataFlowInfo, expectedReturnType != null ? expectedReturnType : NO_EXPECTED_TYPE, + getLanguageVersionSettings(), expressionTypingComponents.dataFlowValueFactory, + localContext == null ? InferenceSession.Companion.getDefault() : localContext.inferenceSession + ); + + checkFunctionReturnType(function, context); } /*package*/ void checkFunctionReturnType(KtDeclarationWithBody function, ExpressionTypingContext context) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt index 323faf5f2e3..4fdda4039da 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt @@ -100,7 +100,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre ForceResolveUtil.forceResolveAllContents(functionDescriptor.returnType) } else { components.expressionTypingServices.checkFunctionReturnType( - functionInnerScope, function, functionDescriptor, context.dataFlowInfo, null, context.trace + functionInnerScope, function, functionDescriptor, context.dataFlowInfo, null, context.trace, context ) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt index 8643f9907be..1588c983802 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt @@ -116,7 +116,8 @@ class LocalClassifierAnalyzer( container.get().analyzeDeclarations( TopDownAnalysisMode.LocalDeclarations, listOf(classOrObject), - context.dataFlowInfo + context.dataFlowInfo, + localContext = context ) } } diff --git a/compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt b/compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt new file mode 100644 index 00000000000..f6b867db2ba --- /dev/null +++ b/compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt @@ -0,0 +1,34 @@ +// WITH_RUNTIME + +import kotlin.experimental.ExperimentalTypeInference + +interface Callback { + fun onSuccess() +} + +public interface SendChannelX { + public fun close(cause: Throwable? = null): Boolean +} + +public interface ProducerScopeX { + public val channel: SendChannelX + fun foo(x: E) +} + +public class FlowX {} + +@OptIn(ExperimentalTypeInference::class) +public fun callbackFlowX(@BuilderInference block: ProducerScopeX.() -> Unit): FlowX = FlowX() + +fun foo(): FlowX = callbackFlowX { + object : Callback { + override fun onSuccess() { + channel.close() + } + } +} + +fun box(): String { + foo() + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt deleted file mode 100644 index 08cdc63c5a2..00000000000 --- a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt +++ /dev/null @@ -1,14 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNREACHABLE_CODE - -interface Some { - fun method(): Unit -} - -fun elvis(nullable: S?, notNullable: S): S = TODO() - -fun Some.doWithPredicate(predicate: (R) -> Unit): R? = TODO() - -fun test(derived: Some) { - val expected: Some = derived.doWithPredicate { it.method() } ?: TODO() - val expected2: Some = elvis(derived.doWithPredicate { it.method() }, TODO()) -} diff --git a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt index 1c4ce614a63..5f15c280fb4 100644 --- a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt +++ b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNREACHABLE_CODE interface Some { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index eb2e084e999..f9792f9344b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -16723,6 +16723,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inference/builderInference/lackOfNullCheckOnNullableInsideBuild.kt"); } + @Test + @TestMetadata("propagateInferenceSessionIntoDeclarationAnalyzers.kt") + public void testPropagateInferenceSessionIntoDeclarationAnalyzers() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt"); + } + @Test @TestMetadata("specialCallsWithCallableReferences.kt") public void testSpecialCallsWithCallableReferences() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 36794d3d304..1bcf3e61bc8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -16723,6 +16723,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inference/builderInference/lackOfNullCheckOnNullableInsideBuild.kt"); } + @Test + @TestMetadata("propagateInferenceSessionIntoDeclarationAnalyzers.kt") + public void testPropagateInferenceSessionIntoDeclarationAnalyzers() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt"); + } + @Test @TestMetadata("specialCallsWithCallableReferences.kt") public void testSpecialCallsWithCallableReferences() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index a56ad4d5818..c11e3dbe4f7 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13907,6 +13907,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inference/builderInference/lackOfNullCheckOnNullableInsideBuild.kt"); } + @TestMetadata("propagateInferenceSessionIntoDeclarationAnalyzers.kt") + public void testPropagateInferenceSessionIntoDeclarationAnalyzers() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt"); + } + @TestMetadata("specialCallsWithCallableReferences.kt") public void testSpecialCallsWithCallableReferences() throws Exception { runTest("compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferences.kt"); diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt index 2b53bdea18f..f5800202432 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt @@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo import org.jetbrains.kotlin.resolve.lazy.* import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor import org.jetbrains.kotlin.resolve.scopes.LexicalScope +import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext import java.util.* import java.util.concurrent.ConcurrentMap @@ -677,7 +678,7 @@ class ResolveElementCache( ForceResolveUtil.forceResolveAllContents(functionDescriptor) val bodyResolver = createBodyResolver(resolveSession, trace, file, statementFilter) - bodyResolver.resolveFunctionBody(DataFlowInfo.EMPTY, trace, namedFunction, functionDescriptor, scope) + bodyResolver.resolveFunctionBody(DataFlowInfo.EMPTY, trace, namedFunction, functionDescriptor, scope, null) forceResolveAnnotationsInside(namedFunction) @@ -696,7 +697,7 @@ class ResolveElementCache( ForceResolveUtil.forceResolveAllContents(constructorDescriptor) val bodyResolver = createBodyResolver(resolveSession, trace, file, statementFilter) - bodyResolver.resolveSecondaryConstructorBody(DataFlowInfo.EMPTY, trace, constructor, constructorDescriptor, scope) + bodyResolver.resolveSecondaryConstructorBody(DataFlowInfo.EMPTY, trace, constructor, constructorDescriptor, scope, null) forceResolveAnnotationsInside(constructor) @@ -835,6 +836,8 @@ class ResolveElementCache( override fun getOuterDataFlowInfo(): DataFlowInfo = DataFlowInfo.EMPTY override fun getTopDownAnalysisMode() = topDownAnalysisMode + + override fun getLocalContext(): ExpressionTypingContext? = null } companion object { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index c21c768bbfd..2b135ba7a92 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -12187,6 +12187,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/inference/builderInference/lackOfNullCheckOnNullableInsideBuild.kt"); } + @TestMetadata("propagateInferenceSessionIntoDeclarationAnalyzers.kt") + public void testPropagateInferenceSessionIntoDeclarationAnalyzers() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt"); + } + @TestMetadata("specialCallsWithCallableReferences.kt") public void testSpecialCallsWithCallableReferences() throws Exception { runTest("compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferences.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 096a949eac2..4eb495a5214 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -11672,6 +11672,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inference/builderInference/lackOfNullCheckOnNullableInsideBuild.kt"); } + @TestMetadata("propagateInferenceSessionIntoDeclarationAnalyzers.kt") + public void testPropagateInferenceSessionIntoDeclarationAnalyzers() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt"); + } + @TestMetadata("specialCallsWithCallableReferences.kt") public void testSpecialCallsWithCallableReferences() throws Exception { runTest("compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferences.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 90693bc4ef8..58e05ec3fd8 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -11737,6 +11737,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inference/builderInference/lackOfNullCheckOnNullableInsideBuild.kt"); } + @TestMetadata("propagateInferenceSessionIntoDeclarationAnalyzers.kt") + public void testPropagateInferenceSessionIntoDeclarationAnalyzers() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt"); + } + @TestMetadata("specialCallsWithCallableReferences.kt") public void testSpecialCallsWithCallableReferences() throws Exception { runTest("compiler/testData/codegen/box/inference/builderInference/specialCallsWithCallableReferences.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index b81237dbc68..bbbb9fe5456 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -6208,6 +6208,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/inference/builderInference/lackOfNullCheckOnNullableInsideBuild.kt"); } + @TestMetadata("propagateInferenceSessionIntoDeclarationAnalyzers.kt") + public void testPropagateInferenceSessionIntoDeclarationAnalyzers() throws Exception { + runTest("compiler/testData/codegen/box/inference/builderInference/propagateInferenceSessionIntoDeclarationAnalyzers.kt"); + } + @TestMetadata("substituteStubTypeIntolambdaParameterDescriptor.kt") public void testSubstituteStubTypeIntolambdaParameterDescriptor() throws Exception { runTest("compiler/testData/codegen/box/inference/builderInference/substituteStubTypeIntolambdaParameterDescriptor.kt"); From a94086224d5ce2b4bfc581e7e20aea3c77ab5c51 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Thu, 11 Feb 2021 16:08:56 +0300 Subject: [PATCH 119/368] Clear request cache properly during disposing component --- .../jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt index 20b80cb6dbb..005b2f236a1 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt @@ -49,6 +49,11 @@ class KotlinBinaryClassCache : Disposable { } override fun dispose() { + cache.get().apply { + result = null + virtualFile = null + } + // This is only relevant for tests. We create a new instance of Application for each test, and so a new instance of this service is // also created for each test. However all tests share the same event dispatch thread, which would collect all instances of this // thread-local if they're not removed properly. Each instance would transitively retain VFS resulting in OutOfMemoryError From 67ad4249c8b792d39b13fe06924e6fd36cbb6d01 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 10 Feb 2021 13:39:02 +0300 Subject: [PATCH 120/368] [Test] Add FirDumpHandler to AbstractFirBlackBoxCodegenTest This is needed to add ability to enable `FIR_DUMP` directive which may be helpful in investigating bugs --- .../test/runners/codegen/AbstractFirBlackBoxCodegenTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractFirBlackBoxCodegenTest.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractFirBlackBoxCodegenTest.kt index ee0faae75c1..7145953a4ad 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractFirBlackBoxCodegenTest.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractFirBlackBoxCodegenTest.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirective import org.jetbrains.kotlin.test.frontend.fir.Fir2IrResultsConverter import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact +import org.jetbrains.kotlin.test.frontend.fir.handlers.FirDumpHandler import org.jetbrains.kotlin.test.model.* open class AbstractFirBlackBoxCodegenTest : AbstractJvmBlackBoxCodegenTestBase( @@ -35,6 +36,7 @@ open class AbstractFirBlackBoxCodegenTest : AbstractJvmBlackBoxCodegenTestBase Date: Wed, 10 Feb 2021 14:20:40 +0300 Subject: [PATCH 121/368] [FIR] Implement util Multimap classes --- .../PersistentImplicitReceiverStack.kt | 1 + .../kotlin/fir/scopes/impl/FirLocalScope.kt | 2 +- .../kotlin/fir/util/ChainedIterator.kt | 29 ++++++ .../org/jetbrains/kotlin/fir/util/Multimap.kt | 97 +++++++++++++++++++ .../{resolve => util}/PersistentMultimap.kt | 2 +- 5 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 compiler/fir/resolve/src/org/jetbrains/kotlin/fir/util/ChainedIterator.kt create mode 100644 compiler/fir/resolve/src/org/jetbrains/kotlin/fir/util/Multimap.kt rename compiler/fir/resolve/src/org/jetbrains/kotlin/fir/{resolve => util}/PersistentMultimap.kt (98%) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/PersistentImplicitReceiverStack.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/PersistentImplicitReceiverStack.kt index d7be8b91e7d..dd3184ddc6a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/PersistentImplicitReceiverStack.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/PersistentImplicitReceiverStack.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.resolve.calls.ImplicitDispatchReceiverValue import org.jetbrains.kotlin.fir.resolve.calls.ImplicitReceiverValue import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.util.PersistentSetMultimap import org.jetbrains.kotlin.name.Name class PersistentImplicitReceiverStack private constructor( diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirLocalScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirLocalScope.kt index d4dd9312a77..fd89cf77da7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirLocalScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirLocalScope.kt @@ -12,7 +12,7 @@ import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.declarations.FirVariable -import org.jetbrains.kotlin.fir.resolve.PersistentMultimap +import org.jetbrains.kotlin.fir.util.PersistentMultimap import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.scopes.FirContainingNamesAwareScope import org.jetbrains.kotlin.fir.scopes.FirScope diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/util/ChainedIterator.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/util/ChainedIterator.kt new file mode 100644 index 00000000000..dcebc1873db --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/util/ChainedIterator.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2021 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.fir.util + +class ChainedIterator(delegates: Collection>) : Iterator { + private var metaIterator = delegates.iterator() + private var currentIterator: Iterator? = null + + private fun promote() { + if (currentIterator?.hasNext() == true) return + while (metaIterator.hasNext()) { + currentIterator = metaIterator.next() + if (currentIterator!!.hasNext()) return + } + } + + override fun hasNext(): Boolean { + promote() + return currentIterator?.hasNext() == true + } + + override fun next(): T { + promote() + return currentIterator?.next() ?: throw NoSuchElementException() + } +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/util/Multimap.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/util/Multimap.kt new file mode 100644 index 00000000000..ce90a9568bc --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/util/Multimap.kt @@ -0,0 +1,97 @@ +/* + * Copyright 2010-2021 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.fir.util + +interface Multimap> { + operator fun get(key: K): C + operator fun contains(key: K): Boolean + val keys: Set + val values: Collection +} + +interface MutableMultimap> : Multimap { + fun put(key: K, value: V) + fun putAll(key: K, values: Collection) { + values.forEach { put(key, it) } + } + + fun remove(key: K, value: V) + fun removeKey(key: K) + + fun clear() +} + +abstract class BaseMultimap, MC : MutableCollection> : MutableMultimap { + private val map: MutableMap = mutableMapOf() + protected abstract fun createContainer(): MC + protected abstract fun createEmptyContainer(): C + + override fun get(key: K): C { + @Suppress("UNCHECKED_CAST") + return map[key] as C? ?: createEmptyContainer() + } + + override operator fun contains(key: K): Boolean { + return key in map + } + + override val keys: Set + get() = map.keys + + override val values: Collection + get() = object : AbstractCollection() { + override val size: Int + get() = map.values.sumBy { it.size } + + override fun iterator(): Iterator { + return ChainedIterator(map.values.map { it.iterator() }) + } + } + + override fun put(key: K, value: V) { + val container = map.getOrPut(key) { createContainer() } + container.add(value) + } + + override fun remove(key: K, value: V) { + val collection = map[key] ?: return + collection.remove(value) + if (collection.isEmpty()) { + map.remove(key) + } + } + + override fun removeKey(key: K) { + map.remove(key) + } + + override fun clear() { + map.clear() + } +} + +class SetMultimap : BaseMultimap, MutableSet>() { + override fun createContainer(): MutableSet { + return mutableSetOf() + } + + override fun createEmptyContainer(): Set { + return emptySet() + } +} + +class ListMultimap : BaseMultimap, MutableList>() { + override fun createContainer(): MutableList { + return mutableListOf() + } + + override fun createEmptyContainer(): List { + return emptyList() + } +} + +fun setMultimapOf(): SetMultimap = SetMultimap() +fun listMultimapOf(): ListMultimap = ListMultimap() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/PersistentMultimap.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/util/PersistentMultimap.kt similarity index 98% rename from compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/PersistentMultimap.kt rename to compiler/fir/resolve/src/org/jetbrains/kotlin/fir/util/PersistentMultimap.kt index 2d2961c3314..a38ac6bea2e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/PersistentMultimap.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/util/PersistentMultimap.kt @@ -3,7 +3,7 @@ * 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.fir.resolve +package org.jetbrains.kotlin.fir.util import kotlinx.collections.immutable.* From 5711a8d610083466738e9bf236202a3bad34aa2f Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 11 Feb 2021 17:42:30 +0300 Subject: [PATCH 122/368] [FIR] Support PreliminaryLoopVisitor in FIR DFA --- .../FirBlackBoxCodegenTestGenerated.java | 6 ++ .../fir/resolve/dfa/FirDataFlowAnalyzer.kt | 36 +++++++- .../kotlin/fir/resolve/dfa/LogicSystem.kt | 1 + .../fir/resolve/dfa/PersistentLogicSystem.kt | 15 ++++ .../fir/resolve/dfa/PreliminaryLoopVisitor.kt | 87 +++++++++++++++++++ .../kotlin/fir/resolve/dfa/VariableStorage.kt | 11 ++- .../codegen/box/regressions/kt41806.kt | 3 +- .../codegen/box/smartCasts/kt44804.kt | 43 +++++++++ .../smartCasts/lambdaAndArgumentFun.fir.kt | 2 +- .../ownerDeclaresBothModifies.fir.kt | 4 +- .../variables/lambdaBetweenArguments.fir.kt | 2 +- .../variables/varChangedInLoop.fir.kt | 4 +- .../variables/varNotChangedInLoop.fir.kt | 4 +- .../variables/whileWithBreak.fir.kt | 4 +- .../varnotnull/assignNestedWhile.fir.kt | 4 +- .../capturedInClosureModifiedBefore.fir.kt | 8 +- .../varnotnull/doWhileWithBreak.fir.kt | 21 ----- .../smartCasts/varnotnull/doWhileWithBreak.kt | 1 + .../varnotnull/doWhileWithMiddleBreak.fir.kt | 12 --- .../varnotnull/doWhileWithMiddleBreak.kt | 1 + .../smartCasts/varnotnull/forEach.fir.kt | 6 +- .../varnotnull/infiniteWhileWithBreak.fir.kt | 4 +- .../varnotnull/varChangedInLoop.fir.kt | 4 +- .../varnotnull/varNotChangedInLoop.fir.kt | 4 +- .../varnotnull/whileWithBreak.fir.kt | 4 +- .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++ .../LightAnalysisModeTestGenerated.java | 5 ++ .../diagnostics/notLinked/dfa/pos/54.fir.kt | 24 ++--- .../diagnostics/notLinked/dfa/pos/59.fir.kt | 48 +++++----- .../IrJsCodegenBoxES6TestGenerated.java | 5 ++ .../IrJsCodegenBoxTestGenerated.java | 5 ++ .../semantics/JsCodegenBoxTestGenerated.java | 5 ++ .../IrCodegenBoxWasmTestGenerated.java | 5 ++ 34 files changed, 294 insertions(+), 106 deletions(-) create mode 100644 compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PreliminaryLoopVisitor.kt create mode 100644 compiler/testData/codegen/box/smartCasts/kt44804.kt delete mode 100644 compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithBreak.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithMiddleBreak.fir.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 31f405e06f1..944a693285d 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -37516,6 +37516,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/smartCasts/kt42517.kt"); } + @Test + @TestMetadata("kt44804.kt") + public void testKt44804() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt index 84b0db2b66d..260f375901e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt @@ -29,19 +29,20 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.visitors.transformSingle import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.ConstantValueKind import org.jetbrains.kotlin.utils.addIfNotNull -import org.jetbrains.kotlin.utils.addToStdlib.runIf class DataFlowAnalyzerContext( val graphBuilder: ControlFlowGraphBuilder, variableStorage: VariableStorage, flowOnNodes: MutableMap, FLOW>, - val variablesForWhenConditions: MutableMap + val variablesForWhenConditions: MutableMap, + val preliminaryLoopVisitor: PreliminaryLoopVisitor ) { var flowOnNodes = flowOnNodes private set @@ -54,13 +55,15 @@ class DataFlowAnalyzerContext( variableStorage = variableStorage.clear() flowOnNodes = mutableMapOf() + + preliminaryLoopVisitor.resetState() } companion object { - fun empty(session: FirSession) = + fun empty(session: FirSession): DataFlowAnalyzerContext = DataFlowAnalyzerContext( ControlFlowGraphBuilder(), VariableStorage(session), - mutableMapOf(), mutableMapOf() + mutableMapOf(), mutableMapOf(), PreliminaryLoopVisitor() ) } } @@ -210,12 +213,14 @@ abstract class FirDataFlowAnalyzer( // TODO: questionable postponedLambdaExitNode?.mergeIncomingFlow() functionExitNode.mergeIncomingFlow() + exitCapturingStatement(anonymousFunction) return FirControlFlowGraphReferenceImpl(graph) } fun visitPostponedAnonymousFunction(anonymousFunction: FirAnonymousFunction) { val (enterNode, exitNode) = graphBuilder.visitPostponedAnonymousFunction(anonymousFunction) enterNode.mergeIncomingFlow() + enterCapturingStatement(enterNode, anonymousFunction) exitNode.mergeIncomingFlow() enterNode.flow = enterNode.flow.fork() } @@ -236,12 +241,14 @@ abstract class FirDataFlowAnalyzer( } private fun exitLocalClass(klass: FirRegularClass): ControlFlowGraph { + // TODO: support capturing of mutable properties, KT-44877 val (node, controlFlowGraph) = graphBuilder.exitLocalClass(klass) node.mergeIncomingFlow() return controlFlowGraph } fun exitAnonymousObject(anonymousObject: FirAnonymousObject): ControlFlowGraph { + // TODO: support capturing of mutable properties, KT-44877 val (node, controlFlowGraph) = graphBuilder.exitAnonymousObject(anonymousObject) node.mergeIncomingFlow() return controlFlowGraph @@ -601,11 +608,13 @@ abstract class FirDataFlowAnalyzer( shouldRemoveSynthetics = true ) } + exitCapturingStatement(exitNode.fir) } fun enterWhileLoop(loop: FirLoop) { val (loopEnterNode, loopConditionEnterNode) = graphBuilder.enterWhileLoop(loop) loopEnterNode.mergeIncomingFlow() + enterCapturingStatement(loopEnterNode, loop) loopConditionEnterNode.mergeIncomingFlow() } @@ -630,11 +639,30 @@ abstract class FirDataFlowAnalyzer( exitCommonLoop(exitNode) } + private fun enterCapturingStatement(node: CFGNode<*>, statement: FirStatement) { + val reassignedNames = context.preliminaryLoopVisitor.enterCapturingStatement(statement) + if (reassignedNames.isEmpty()) return + val possiblyChangedVariables = variableStorage.realVariables.filterKeys { + val fir = (it.symbol as? FirVariableSymbol<*>)?.fir ?: return@filterKeys false + fir.isVar && fir.name in reassignedNames + }.values + if (possiblyChangedVariables.isEmpty()) return + val flow = node.flow + for (variable in possiblyChangedVariables) { + logicSystem.removeAllAboutVariableIncludingAliasInformation(flow, variable) + } + } + + private fun exitCapturingStatement(statement: FirStatement) { + context.preliminaryLoopVisitor.exitCapturingStatement(statement) + } + // ----------------------------------- Do while Loop ----------------------------------- fun enterDoWhileLoop(loop: FirLoop) { val (loopEnterNode, loopBlockEnterNode) = graphBuilder.enterDoWhileLoop(loop) loopEnterNode.mergeIncomingFlow() + enterCapturingStatement(loopEnterNode, loop) loopBlockEnterNode.mergeIncomingFlow() } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt index 6e11d2ed8cf..5b3b04c16a3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt @@ -36,6 +36,7 @@ abstract class LogicSystem(protected val context: ConeInferenceCont abstract fun addImplication(flow: FLOW, implication: Implication) abstract fun removeAllAboutVariable(flow: FLOW, variable: RealVariable) + abstract fun removeAllAboutVariableIncludingAliasInformation(flow: FLOW, variable: RealVariable) abstract fun translateVariableFromConditionInStatements( flow: FLOW, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PersistentLogicSystem.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PersistentLogicSystem.kt index 61aaa618a76..20ab32e00cb 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PersistentLogicSystem.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PersistentLogicSystem.kt @@ -254,6 +254,21 @@ abstract class PersistentLogicSystem(context: ConeInferenceContext) : LogicSyste // TODO: should we search variable in all logic statements? } + override fun removeAllAboutVariableIncludingAliasInformation(flow: PersistentFlow, variable: RealVariable) { + removeAllAboutVariable(flow, variable) + val existedAlias = flow.directAliasMap[variable]?.variable + if (existedAlias != null) { + flow.directAliasMap = flow.directAliasMap.remove(variable) + val updatedBackwardsAliasList = flow.backwardsAliasMap.getValue(existedAlias).remove(variable) + flow.backwardsAliasMap = if (updatedBackwardsAliasList.isEmpty()) { + flow.backwardsAliasMap.remove(existedAlias) + } else { + flow.backwardsAliasMap.put(existedAlias, updatedBackwardsAliasList) + } + flow.updatedAliasDiff = flow.updatedAliasDiff.add(variable) + } + } + override fun translateVariableFromConditionInStatements( flow: PersistentFlow, originalVariable: DataFlowVariable, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PreliminaryLoopVisitor.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PreliminaryLoopVisitor.kt new file mode 100644 index 00000000000..f1384d2e6ce --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/PreliminaryLoopVisitor.kt @@ -0,0 +1,87 @@ +/* + * Copyright 2010-2021 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.fir.resolve.dfa + +import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.references.FirNamedReference +import org.jetbrains.kotlin.fir.util.SetMultimap +import org.jetbrains.kotlin.fir.util.setMultimapOf +import org.jetbrains.kotlin.fir.visitors.FirVisitor +import org.jetbrains.kotlin.name.Name + +class PreliminaryLoopVisitor { + private val reassignedVariablesPerElement: SetMultimap = setMultimapOf() + + fun enterCapturingStatement(statement: FirStatement): Set { + assert(statement is FirLoop || statement is FirClass<*> || statement is FirFunction<*>) + if (statement !in reassignedVariablesPerElement) { + statement.accept(visitor, null) + } + return reassignedVariablesPerElement[statement] + } + + fun exitCapturingStatement(statement: FirStatement) { + assert(statement is FirLoop || statement is FirClass<*> || statement is FirFunction<*>) + reassignedVariablesPerElement.removeKey(statement) + } + + fun resetState() { + reassignedVariablesPerElement.clear() + } + + // FirStatement -- closest statement (loop/lambda/local declaration) which may contain reassignments + private val visitor = object : FirVisitor() { + override fun visitElement(element: FirElement, data: FirStatement?) { + element.acceptChildren(this, data) + } + + override fun visitVariableAssignment(variableAssignment: FirVariableAssignment, data: FirStatement?) { + val reference = variableAssignment.lValue as? FirNamedReference + if (reference != null) { + requireNotNull(data) + reassignedVariablesPerElement.put(data, reference.name) + } + visitElement(variableAssignment, data) + } + + override fun visitWhileLoop(whileLoop: FirWhileLoop, data: FirStatement?) { + visitCapturingStatement(whileLoop, data) + } + + override fun visitDoWhileLoop(doWhileLoop: FirDoWhileLoop, data: FirStatement?) { + visitCapturingStatement(doWhileLoop, data) + } + + override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction, data: FirStatement?) { + visitCapturingStatement(anonymousFunction, data) + } + + override fun visitSimpleFunction(simpleFunction: FirSimpleFunction, data: FirStatement?) { + visitCapturingStatement(simpleFunction, data) + } + + override fun > visitFunction(function: FirFunction, data: FirStatement?) { + visitCapturingStatement(function, data) + } + + override fun visitRegularClass(regularClass: FirRegularClass, data: FirStatement?) { + visitCapturingStatement(regularClass, data) + } + + override fun visitAnonymousObject(anonymousObject: FirAnonymousObject, data: FirStatement?) { + visitCapturingStatement(anonymousObject, data) + } + + private fun visitCapturingStatement(statement: FirStatement, parent: FirStatement?) { + visitElement(statement, statement) + if (parent != null) { + reassignedVariablesPerElement.putAll(parent, reassignedVariablesPerElement[statement]) + } + } + } +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt index be162b7cc8a..1d33225ba4a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/VariableStorage.kt @@ -26,7 +26,10 @@ import kotlin.contracts.contract @OptIn(DfaInternals::class) class VariableStorage(private val session: FirSession) { private var counter = 1 - private val realVariables: MutableMap = HashMap() + private val _realVariables: MutableMap = HashMap() + val realVariables: Map + get() = _realVariables + private val syntheticVariables: MutableMap = HashMap() fun clear(): VariableStorage = VariableStorage(session) @@ -34,7 +37,7 @@ class VariableStorage(private val session: FirSession) { fun getOrCreateRealVariableWithoutUnwrappingAlias(flow: Flow, symbol: AbstractFirBasedSymbol<*>, fir: FirElement): RealVariable { val realFir = fir.unwrapElement() val identifier = getIdentifierBySymbol(flow, symbol, realFir) - return realVariables.getOrPut(identifier) { createRealVariableInternal(flow, identifier, realFir) } + return _realVariables.getOrPut(identifier) { createRealVariableInternal(flow, identifier, realFir) } } private fun getOrCreateRealVariable(flow: Flow, symbol: AbstractFirBasedSymbol<*>, fir: FirElement): RealVariable { @@ -108,7 +111,7 @@ class VariableStorage(private val session: FirSession) { fun getRealVariableWithoutUnwrappingAlias(symbol: AbstractFirBasedSymbol<*>?, fir: FirElement, flow: Flow): RealVariable? { val realFir = fir.unwrapElement() return symbol.takeIf { it.isStable(realFir) }?.let { - realVariables[getIdentifierBySymbol(flow, it, realFir.unwrapElement())] + _realVariables[getIdentifierBySymbol(flow, it, realFir.unwrapElement())] } } @@ -131,7 +134,7 @@ class VariableStorage(private val session: FirSession) { } fun removeRealVariable(symbol: AbstractFirBasedSymbol<*>) { - realVariables.remove(Identifier(symbol, null, null)) + _realVariables.remove(Identifier(symbol, null, null)) } fun removeSyntheticVariable(variable: DataFlowVariable) { diff --git a/compiler/testData/codegen/box/regressions/kt41806.kt b/compiler/testData/codegen/box/regressions/kt41806.kt index 5e3435df41b..cc28f1a25e1 100644 --- a/compiler/testData/codegen/box/regressions/kt41806.kt +++ b/compiler/testData/codegen/box/regressions/kt41806.kt @@ -1,6 +1,5 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME -// IGNORE_BACKEND_FIR: JVM_IR open class A { fun Foo() { @@ -23,4 +22,4 @@ fun box(): String { test.Foo() return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/smartCasts/kt44804.kt b/compiler/testData/codegen/box/smartCasts/kt44804.kt new file mode 100644 index 00000000000..54d169ab7b9 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/kt44804.kt @@ -0,0 +1,43 @@ +// ISSUE: KT-44804 +// WITH_STDLIB + +abstract class AbstractInsnNode(val next: AbstractInsnNode? = null) + +class LineNumberNode(next: AbstractInsnNode? = null) : AbstractInsnNode(next) { + val line: Int = 1 +} + +class LabelNode() : AbstractInsnNode(null) + +fun isDeadLineNumber(insn: LineNumberNode, index: Int, frames: Array): Boolean { + // Line number node is "dead" if the corresponding line number interval + // contains at least one "dead" meaningful instruction and no "live" meaningful instructions. + var finger: AbstractInsnNode = insn + var fingerIndex = index + var hasDeadInsn = false + loop@ while (true) { + finger = finger.next ?: break + fingerIndex++ + when (finger) { + is LabelNode -> + continue@loop + is LineNumberNode -> + if (finger.line != insn.line) return hasDeadInsn + else -> { + if (frames[fingerIndex] != null) return false + hasDeadInsn = true + } + } + } + return true +} + +fun box(): String { + val node = LineNumberNode( + LineNumberNode( + LabelNode() + ) + ) + val result = isDeadLineNumber(node, 0, arrayOf(null, null, "aaa", "bbb")) + return if (result) "OK" else "fail" +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgumentFun.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgumentFun.fir.kt index 393424290e4..49b404f34d6 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgumentFun.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgumentFun.fir.kt @@ -10,5 +10,5 @@ fun use() { // Write to x is AFTER x.hashCode() // No smart cast should be here! - foo(bar { x = null }, x.hashCode()) + foo(bar { x = null }, x.hashCode()) } diff --git a/compiler/testData/diagnostics/tests/smartCasts/ownerDeclaresBothModifies.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/ownerDeclaresBothModifies.fir.kt index a51ccd9e472..f9f45f3e355 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/ownerDeclaresBothModifies.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/ownerDeclaresBothModifies.fir.kt @@ -4,10 +4,10 @@ fun foo(arg: Int?) { if (x == null) return run { // Unsafe because of owner modification - x.hashCode() + x.hashCode() x = null } if (x != null) x = 42 // Unsafe because of lambda x.hashCode() -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/lambdaBetweenArguments.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/lambdaBetweenArguments.fir.kt index 1c423e36f0d..3d667d5f787 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/variables/lambdaBetweenArguments.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/variables/lambdaBetweenArguments.fir.kt @@ -6,5 +6,5 @@ fun foo(x: Int, f: () -> Unit, y: Int) {} fun bar() { var x: Int? x = 4 - foo(x, { x = null; x.hashCode() }, x) + foo(x, { x = null; x.hashCode() }, x) } diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/varChangedInLoop.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/varChangedInLoop.fir.kt index 3146821521a..c9ac93066a6 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/variables/varChangedInLoop.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/variables/varChangedInLoop.fir.kt @@ -2,8 +2,8 @@ public fun foo() { var i: Any = 1 if (i is Int) { while (i != 10) { - i++ // Here smart cast should not be performed due to a successor + i++ // Here smart cast should not be performed due to a successor i = "" } } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/varNotChangedInLoop.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/varNotChangedInLoop.fir.kt index 1a2eee01965..4c61f334a5c 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/variables/varNotChangedInLoop.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/variables/varNotChangedInLoop.fir.kt @@ -2,7 +2,7 @@ public fun foo() { var i: Any = 1 if (i is Int) { while (i != 10) { - i++ + i++ } } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/whileWithBreak.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/whileWithBreak.fir.kt index b34bb73ed5e..05f04ba2fba 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/variables/whileWithBreak.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/variables/whileWithBreak.fir.kt @@ -13,5 +13,5 @@ fun list(start: String) { e = e.next() } // e can never be null but we do not know it - e.hashCode() -} \ No newline at end of file + e.hashCode() +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/assignNestedWhile.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/assignNestedWhile.fir.kt index 58a8a768091..a1b3f87954b 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/assignNestedWhile.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/assignNestedWhile.fir.kt @@ -13,7 +13,7 @@ fun foo(): Bar { y = Bar() while (x != null) { // Here call is unsafe because of inner loop - y.next() + y.next() while (y != null) { if (x == y) // x is not null because of outer while @@ -25,4 +25,4 @@ fun foo(): Bar { x = x.next() } return Bar() -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/capturedInClosureModifiedBefore.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/capturedInClosureModifiedBefore.fir.kt index 5a017f5d5b1..3998cb0d6ed 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/capturedInClosureModifiedBefore.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/capturedInClosureModifiedBefore.fir.kt @@ -30,7 +30,7 @@ fun baz(s: String?) { x.hashCode() } run { - x.hashCode() + x.hashCode() x = null } } @@ -40,11 +40,11 @@ fun gaz(s: String?) { var x = s if (x != null) { run { - x.hashCode() + x.hashCode() x = null } run { - x.hashCode() + x.hashCode() } } } @@ -57,4 +57,4 @@ fun gav(s: String?) { } x = null } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithBreak.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithBreak.fir.kt deleted file mode 100644 index 3b1b5feabe3..00000000000 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithBreak.fir.kt +++ /dev/null @@ -1,21 +0,0 @@ -data class SomeObject(val n: SomeObject?) { - fun doSomething(): Boolean = true - fun next(): SomeObject? = n -} - - -fun list(start: SomeObject) { - var e: SomeObject? - e = start - do { - // In theory smart cast is possible here - // But in practice we have a loop with changing e - // ?: should we "or" entrance type info with condition type info? - if (!e.doSomething()) - break - // Smart cast here is still not possible - e = e.next() - } while (e != null) - // e can be null because of next() - e.doSomething() -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithBreak.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithBreak.kt index aab92ac48e5..78d39b82449 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithBreak.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithBreak.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL data class SomeObject(val n: SomeObject?) { fun doSomething(): Boolean = true fun next(): SomeObject? = n diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithMiddleBreak.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithMiddleBreak.fir.kt deleted file mode 100644 index 2b916f90fb0..00000000000 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithMiddleBreak.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -fun x(): Boolean { return true } - -public fun foo(pp: String?): Int { - var p = pp - do { - p!!.length - if (p == "abc") break - p = null - } while (!x()) - // Smart cast is NOT possible here - return p.length -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithMiddleBreak.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithMiddleBreak.kt index acb36871a81..b569d40edcf 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithMiddleBreak.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/doWhileWithMiddleBreak.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL fun x(): Boolean { return true } public fun foo(pp: String?): Int { diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/forEach.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/forEach.fir.kt index fe84aec9785..db4f2975016 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/forEach.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/forEach.fir.kt @@ -9,9 +9,9 @@ fun list(start: SomeObject): SomeObject { var e: SomeObject? = start for (i in 0..42) { // Unsafe calls because of nullable e at the beginning - e.doSomething() - e = e.next() + e.doSomething() + e = e.next() } // Smart cast is not possible here due to next() return e -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/infiniteWhileWithBreak.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/infiniteWhileWithBreak.fir.kt index f13e2013809..40cda33aff1 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/infiniteWhileWithBreak.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/infiniteWhileWithBreak.fir.kt @@ -16,5 +16,5 @@ fun list(start: SomeObject) { e = e.next() } // e can be null because of next() - e.doSomething() -} \ No newline at end of file + e.doSomething() +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/varChangedInLoop.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/varChangedInLoop.fir.kt index b0e56a1b8bc..80e56ac8127 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/varChangedInLoop.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/varChangedInLoop.fir.kt @@ -2,8 +2,8 @@ public fun foo() { var i: Int? = 1 if (i != null) { while (i != 10) { - i++ // Here smart cast should not be performed due to a successor + i++ // Here smart cast should not be performed due to a successor i = null } } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/varNotChangedInLoop.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/varNotChangedInLoop.fir.kt index b36be19bf86..30698d4327c 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/varNotChangedInLoop.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/varNotChangedInLoop.fir.kt @@ -2,7 +2,7 @@ public fun foo() { var i: Int? = 1 if (i != null) { while (i != 10) { - i++ + i++ } } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/whileWithBreak.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/whileWithBreak.fir.kt index 0d5e3c38d9f..47a0f063662 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/varnotnull/whileWithBreak.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/varnotnull/whileWithBreak.fir.kt @@ -13,5 +13,5 @@ fun list(start: SomeObject) { e = e.next() } // e can be null because of next() - e.doSomething() -} \ No newline at end of file + e.doSomething() +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index f9792f9344b..8c084859b75 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -37516,6 +37516,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/smartCasts/kt42517.kt"); } + @Test + @TestMetadata("kt44804.kt") + public void testKt44804() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 1bcf3e61bc8..f2f1b23d1b9 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -37516,6 +37516,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/smartCasts/kt42517.kt"); } + @Test + @TestMetadata("kt44804.kt") + public void testKt44804() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index c11e3dbe4f7..9b5bc96fc69 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -29984,6 +29984,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/smartCasts/kt42517.kt"); } + @TestMetadata("kt44804.kt") + public void testKt44804() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt index 4ee5892aa53..4523827f58f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt @@ -19,8 +19,8 @@ fun case_1() { b.length } - b - b.length + b + b.length } } @@ -41,8 +41,8 @@ fun case_2() { b.length } - b - b.length + b + b.length } } @@ -107,8 +107,8 @@ fun case_5() { b.length } - b - b.length + b + b.length } } @@ -240,12 +240,12 @@ fun case_12() { b b.length while (if (true) { b = a; true } else true) { - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -276,8 +276,8 @@ fun case_14() { b.length while (true) { if (true) { b = a; } else 3 - b - b.length + b + b.length } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt index d33a0d0e271..794488afdde 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt @@ -11,8 +11,8 @@ fun case_1() { var x: Any? = null if (x == null) return do { - x - x = x.equals(10) + x + x = x.equals(10) } while (x != null) } @@ -25,8 +25,8 @@ fun case_2() { var x: Any? = null if (x === null) return do { - x - x = x.equals(10) + x + x = x.equals(10) } while (x !== null) } @@ -57,8 +57,8 @@ fun case_5() { var x: Any? = null if (x == null) return do { - x - x = x.equals(10) + x + x = x.equals(10) } while (x !== null) } @@ -71,8 +71,8 @@ fun case_6() { var x: Any? = null if (x === null) return do { - x - x = x.equals(10) + x + x = x.equals(10) } while (x != null) } @@ -85,8 +85,8 @@ fun case_7() { var x: Any? = null x ?: return do { - x - x = x.equals(10) + x + x = x.equals(10) } while (x !== null) } @@ -99,8 +99,8 @@ fun case_8() { var x: Any? = null if (x == null) throw Exception() do { - x - x = x.equals(10) + x + x = x.equals(10) } while (x != null) } @@ -113,8 +113,8 @@ fun case_9() { var x: Any? = null x ?: throw Exception() do { - x - x = x.equals(10) + x + x = x.equals(10) } while (x !== null) } @@ -127,8 +127,8 @@ fun case_10() { var x: Any? = null x as Any do { - x - x = x.equals(10) + x + x = x.equals(10) } while (x != null) } @@ -155,8 +155,8 @@ fun case_12() { var x: Any? = null if (x is Any) { do { - x - x = x .equals(10) + x + x = x .equals(10) } while (x != null) } } @@ -170,8 +170,8 @@ fun case_13() { var x: Any? = null if (x != null) { do { - x - x = x .equals(10) + x + x = x .equals(10) } while (x != null) } } @@ -185,8 +185,8 @@ fun case_14() { var x: Any? = null if (x == null) return do { - x - x = x.equals(10) + x + x = x.equals(10) } while (x is Any) } @@ -199,8 +199,8 @@ fun case_15() { var x: Any? = null if (x is Any) { do { - x - x = x .equals(10) + x + x = x .equals(10) } while (x is Any) } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 2b135ba7a92..02f3332bfe2 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -25530,6 +25530,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/smartCasts/kt42517.kt"); } + @TestMetadata("kt44804.kt") + public void testKt44804() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 4eb495a5214..d9037c6bf6b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -25015,6 +25015,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/kt42517.kt"); } + @TestMetadata("kt44804.kt") + public void testKt44804() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 58e05ec3fd8..9493d37b40d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -24975,6 +24975,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/kt42517.kt"); } + @TestMetadata("kt44804.kt") + public void testKt44804() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index bbbb9fe5456..7123c292b71 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -13597,6 +13597,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/smartCasts/kt19100.kt"); } + @TestMetadata("kt44804.kt") + public void testKt44804() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); + } + @TestMetadata("multipleSmartCast.kt") public void testMultipleSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); From cf4e61bebb2800eefde477c843c083682755d307 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 12 Feb 2021 10:31:23 +0300 Subject: [PATCH 123/368] [FIR] Add spec diagnostic tests to `[JPS] Fast FIR tests` run configuration --- gradle/jps.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/jps.gradle.kts b/gradle/jps.gradle.kts index 463b2afb0eb..ae68ee41844 100644 --- a/gradle/jps.gradle.kts +++ b/gradle/jps.gradle.kts @@ -65,7 +65,7 @@ fun setupFirRunConfiguration() { val junit = JUnit("_stub").apply { configureForKotlin("2048m") } junit.moduleName = "kotlin.compiler.fir.fir2ir.test" - junit.pattern = """^.*\.Fir\w+TestGenerated$""" + junit.pattern = """^.*\.Fir\w+Test\w*Generated$""" junit.vmParameters = junit.vmParameters.replace(rootDir.absolutePath, "\$PROJECT_DIR\$") junit.workingDirectory = junit.workingDirectory.replace(rootDir.absolutePath, "\$PROJECT_DIR\$") From befe8599c42486b3a5e9b40f829ce041471e5eb3 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Mon, 1 Feb 2021 16:52:23 +0300 Subject: [PATCH 124/368] Report warnings or errors for violated type parameter's upper bounds from Java annotated with nullability annotations ^KT-43262 Fixed --- ...irOldFrontendDiagnosticsTestGenerated.java | 6 ++ .../jvm/checkers/EnhancedUpperBoundChecker.kt | 46 ++++++++++ .../diagnostics/DefaultErrorMessagesJvm.java | 1 + .../resolve/jvm/diagnostics/ErrorsJvm.java | 3 + .../jvm/platform/JvmPlatformConfigurator.kt | 1 + .../kotlin/resolve/DeclarationsChecker.kt | 12 +-- .../kotlin/resolve/DescriptorResolver.java | 55 ------------ .../jetbrains/kotlin/resolve/TypeResolver.kt | 5 +- .../kotlin/resolve/UpperBoundChecker.kt | 83 +++++++++++++++++++ .../kotlin/resolve/calls/CandidateResolver.kt | 5 +- .../java/checkEnhancedUpperBounds.fir.kt | 11 +++ .../java/checkEnhancedUpperBounds.kt | 17 ++++ .../java/checkEnhancedUpperBounds.txt | 15 ++++ .../test/runners/DiagnosticTestGenerated.java | 6 ++ 14 files changed, 202 insertions(+), 64 deletions(-) create mode 100644 compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/EnhancedUpperBoundChecker.kt create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 2979176d3f9..0a5ab2b5e86 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -34327,6 +34327,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/java"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("checkEnhancedUpperBounds.kt") + public void testCheckEnhancedUpperBounds() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt"); + } + @Test @TestMetadata("concurrentHashMapContains.kt") public void testConcurrentHashMapContains() throws Exception { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/EnhancedUpperBoundChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/EnhancedUpperBoundChecker.kt new file mode 100644 index 00000000000..73599004670 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/EnhancedUpperBoundChecker.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2021 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.resolve.jvm.checkers + +import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.config.LanguageVersionSettings +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.psi.KtTypeReference +import org.jetbrains.kotlin.resolve.BindingTrace +import org.jetbrains.kotlin.resolve.UpperBoundChecker +import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.checker.KotlinTypeChecker + +class EnhancedUpperBoundChecker(override val languageVersionSettings: LanguageVersionSettings) : UpperBoundChecker { + override fun checkBound( + bound: KotlinType, + substitutor: TypeSubstitutor, + trace: BindingTrace, + jetTypeArgument: KtTypeReference, + typeArgument: KotlinType + ): Boolean { + val isCheckPassed = super.checkBound(bound, substitutor, trace, jetTypeArgument, typeArgument) + + // The error is already reported, it's unnecessary to do more checks + if (!isCheckPassed) return false + + val enhancedBound = bound.getEnhancement() ?: return false + + val isTypeEnhancementImprovementsEnabled = + languageVersionSettings.supportsFeature(LanguageFeature.ImprovementsAroundTypeEnhancement) + val substitutedBound = substitutor.safeSubstitute(enhancedBound, Variance.INVARIANT) + if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) { + if (isTypeEnhancementImprovementsEnabled) { + trace.report(Errors.UPPER_BOUND_VIOLATED.on(jetTypeArgument, substitutedBound, typeArgument)) + } else { + trace.report(ErrorsJvm.UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS.on(jetTypeArgument, substitutedBound, typeArgument)) + } + return false + } + return true + } +} diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java index 354c80dddd4..52a4ce117ab 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java @@ -85,6 +85,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { MAP.put(SUBCLASS_CANT_CALL_COMPANION_PROTECTED_NON_STATIC, "Using non-JVM static members protected in the superclass companion is unsupported yet"); MAP.put(NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS, "Type mismatch: inferred type is {1} but {0} was expected", RENDER_TYPE, RENDER_TYPE); + MAP.put(UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS, "Type argument is not within its bounds: should be subtype of ''{0}''", RENDER_TYPE, RENDER_TYPE); MAP.put(NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER, "Type mismatch: value of a nullable type {0} is used where non-nullable type is expected. " + "This warning will become an error soon. " + diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java index 479358a99aa..05edf57b0c1 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java @@ -137,6 +137,9 @@ public interface ErrorsJvm { DiagnosticFactory2 NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS = DiagnosticFactory2.create(WARNING); + DiagnosticFactory2 UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS + = DiagnosticFactory2.create(WARNING); + DiagnosticFactory1 NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER = DiagnosticFactory1.create(WARNING); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt index cc8db2176c6..07a7924d721 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt @@ -97,6 +97,7 @@ object JvmPlatformConfigurator : PlatformConfiguratorBase( ) { override fun configureModuleComponents(container: StorageComponentContainer) { container.useImpl() + container.useImpl() container.useImpl() container.useImpl() container.useImpl() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt index 39e42e8a342..de02be8ba01 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt @@ -56,11 +56,12 @@ internal class DeclarationsCheckerBuilder( private val identifierChecker: IdentifierChecker, private val languageVersionSettings: LanguageVersionSettings, private val typeSpecificityComparator: TypeSpecificityComparator, - private val diagnosticSuppressor: PlatformDiagnosticSuppressor + private val diagnosticSuppressor: PlatformDiagnosticSuppressor, + private val upperBoundChecker: UpperBoundChecker ) { fun withTrace(trace: BindingTrace) = DeclarationsChecker( descriptorResolver, originalModifiersChecker, annotationChecker, identifierChecker, trace, languageVersionSettings, - typeSpecificityComparator, diagnosticSuppressor + typeSpecificityComparator, diagnosticSuppressor, upperBoundChecker ) } @@ -72,7 +73,8 @@ class DeclarationsChecker( private val trace: BindingTrace, private val languageVersionSettings: LanguageVersionSettings, typeSpecificityComparator: TypeSpecificityComparator, - private val diagnosticSuppressor: PlatformDiagnosticSuppressor + private val diagnosticSuppressor: PlatformDiagnosticSuppressor, + private val upperBoundChecker: UpperBoundChecker ) { private val modifiersChecker = modifiersChecker.withTrace(trace) @@ -360,7 +362,7 @@ class DeclarationsChecker( for (delegationSpecifier in classOrObject.superTypeListEntries) { val typeReference = delegationSpecifier.typeReference ?: continue - typeReference.type()?.let { DescriptorResolver.checkBounds(typeReference, it, trace) } + typeReference.type()?.let { upperBoundChecker.checkBounds(typeReference, it, trace) } } if (classOrObject !is KtClass) return @@ -383,7 +385,7 @@ class DeclarationsChecker( DescriptorResolver.checkUpperBoundTypes(trace, upperBoundCheckRequests, false) for (request in upperBoundCheckRequests) { - DescriptorResolver.checkBounds(request.upperBound, request.upperBoundType, trace) + upperBoundChecker.checkBounds(request.upperBound, request.upperBoundType, trace) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java index 3e5126207e1..d141dc9164b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java @@ -1312,61 +1312,6 @@ public class DescriptorResolver { return propertyDescriptor; } - public static void checkBounds(@NotNull KtTypeReference typeReference, @NotNull KotlinType type, @NotNull BindingTrace trace) { - if (KotlinTypeKt.isError(type)) return; - - KtTypeElement typeElement = typeReference.getTypeElement(); - if (typeElement == null) return; - - List parameters = type.getConstructor().getParameters(); - List arguments = type.getArguments(); - assert parameters.size() == arguments.size(); - - List ktTypeArguments = typeElement.getTypeArgumentsAsTypes(); - - // A type reference from Kotlin code can yield a flexible type only if it's `ft`, whose bounds should not be checked - if (FlexibleTypesKt.isFlexible(type) && !DynamicTypesKt.isDynamic(type)) { - assert ktTypeArguments.size() == 2 - : "Flexible type cannot be denoted in Kotlin otherwise than as ft, but was: " - + PsiUtilsKt.getElementTextWithContext(typeReference); - // it's really ft - FlexibleType flexibleType = FlexibleTypesKt.asFlexibleType(type); - checkBounds(ktTypeArguments.get(0), flexibleType.getLowerBound(), trace); - checkBounds(ktTypeArguments.get(1), flexibleType.getUpperBound(), trace); - return; - } - - // If the numbers of type arguments do not match, the error has been already reported in TypeResolver - if (ktTypeArguments.size() != arguments.size()) return; - - TypeSubstitutor substitutor = TypeSubstitutor.create(type); - for (int i = 0; i < ktTypeArguments.size(); i++) { - KtTypeReference ktTypeArgument = ktTypeArguments.get(i); - if (ktTypeArgument == null) continue; - - KotlinType typeArgument = arguments.get(i).getType(); - checkBounds(ktTypeArgument, typeArgument, trace); - - TypeParameterDescriptor typeParameterDescriptor = parameters.get(i); - checkBounds(ktTypeArgument, typeArgument, typeParameterDescriptor, substitutor, trace); - } - } - - public static void checkBounds( - @NotNull KtTypeReference jetTypeArgument, - @NotNull KotlinType typeArgument, - @NotNull TypeParameterDescriptor typeParameterDescriptor, - @NotNull TypeSubstitutor substitutor, - @NotNull BindingTrace trace - ) { - for (KotlinType bound : typeParameterDescriptor.getUpperBounds()) { - KotlinType substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT); - if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) { - trace.report(UPPER_BOUND_VIOLATED.on(jetTypeArgument, substitutedBound, typeArgument)); - } - } - } - public static boolean checkHasOuterClassInstance( @NotNull LexicalScope scope, @NotNull BindingTrace trace, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index ee724725e62..d85b0f53cdc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -70,7 +70,8 @@ class TypeResolver( private val dynamicCallableDescriptors: DynamicCallableDescriptors, private val identifierChecker: IdentifierChecker, private val platformToKotlinClassMapper: PlatformToKotlinClassMapper, - private val languageVersionSettings: LanguageVersionSettings + private val languageVersionSettings: LanguageVersionSettings, + private val upperBoundChecker: UpperBoundChecker ) { private val isNonParenthesizedAnnotationsOnFunctionalTypesEnabled = languageVersionSettings.getFeatureSupport(LanguageFeature.NonParenthesizedAnnotationsOnFunctionalTypes) == LanguageFeature.State.ENABLED @@ -524,7 +525,7 @@ class TypeResolver( val typeReference = collectedArgumentAsTypeProjections.getOrNull(i)?.typeReference if (typeReference != null) { - DescriptorResolver.checkBounds(typeReference, argument, parameter, substitutor, c.trace) + upperBoundChecker.checkBounds(typeReference, argument, parameter, substitutor, c.trace) } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt new file mode 100644 index 00000000000..fd0ebaa36ed --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt @@ -0,0 +1,83 @@ +/* + * Copyright 2010-2021 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.resolve + +import org.jetbrains.kotlin.config.LanguageVersionSettings +import org.jetbrains.kotlin.container.DefaultImplementation +import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.psi.KtTypeReference +import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.checker.KotlinTypeChecker + +@DefaultImplementation(impl = UpperBoundChecker::class) +interface UpperBoundChecker { + val languageVersionSettings: LanguageVersionSettings + + fun checkBounds(typeReference: KtTypeReference, type: KotlinType, trace: BindingTrace) { + if (type.isError) return + + val typeElement = typeReference.typeElement ?: return + val parameters = type.constructor.parameters + val arguments = type.arguments + + assert(parameters.size == arguments.size) + + val ktTypeArguments = typeElement.typeArgumentsAsTypes + + // A type reference from Kotlin code can yield a flexible type only if it's `ft`, whose bounds should not be checked + if (type.isFlexible() && !type.isDynamic()) { + assert(ktTypeArguments.size == 2) { + ("Flexible type cannot be denoted in Kotlin otherwise than as ft, but was: " + + typeReference.getElementTextWithContext()) + } + // it's really ft + val flexibleType = type.asFlexibleType() + checkBounds(ktTypeArguments[0], flexibleType.lowerBound, trace) + checkBounds(ktTypeArguments[1], flexibleType.upperBound, trace) + return + } + + // If the numbers of type arguments do not match, the error has been already reported in TypeResolver + if (ktTypeArguments.size != arguments.size) return + + val substitutor = TypeSubstitutor.create(type) + + for (i in ktTypeArguments.indices) { + val ktTypeArgument = ktTypeArguments[i] ?: continue + checkBounds(ktTypeArgument, arguments[i].type, trace) + checkBounds(ktTypeArgument, arguments[i].type, parameters[i], substitutor, trace) + } + } + + fun checkBounds( + jetTypeArgument: KtTypeReference, + typeArgument: KotlinType, + typeParameterDescriptor: TypeParameterDescriptor, + substitutor: TypeSubstitutor, + trace: BindingTrace + ) { + for (bound in typeParameterDescriptor.upperBounds) { + checkBound(bound, substitutor, trace, jetTypeArgument, typeArgument) + } + } + + fun checkBound( + bound: KotlinType, + substitutor: TypeSubstitutor, + trace: BindingTrace, + jetTypeArgument: KtTypeReference, + typeArgument: KotlinType + ): Boolean { + val substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT) + if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) { + trace.report(Errors.UPPER_BOUND_VIOLATED.on(jetTypeArgument, substitutedBound, typeArgument)) + return false + } + return true + } +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt index 8e47249548b..c7868682f92 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt @@ -53,7 +53,8 @@ class CandidateResolver( private val reflectionTypes: ReflectionTypes, private val additionalTypeCheckers: Iterable, private val smartCastManager: SmartCastManager, - private val dataFlowValueFactory: DataFlowValueFactory + private val dataFlowValueFactory: DataFlowValueFactory, + private val upperBoundChecker: UpperBoundChecker ) { fun performResolutionForCandidateCall( context: CallCandidateResolutionContext, @@ -596,7 +597,7 @@ class CandidateResolver( val typeArgument = typeArguments[i] val typeReference = ktTypeArguments[i].typeReference if (typeReference != null) { - DescriptorResolver.checkBounds(typeReference, typeArgument, typeParameterDescriptor, substitutor, trace) + upperBoundChecker.checkBounds(typeReference, typeArgument, typeParameterDescriptor, substitutor, trace) } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt new file mode 100644 index 00000000000..e89ef63ceb7 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt @@ -0,0 +1,11 @@ +// FULL_JDK + +// FILE: MapLike.java +import java.util.Map; + +public interface MapLike<@org.jetbrains.annotations.NotNull K, V> { + void putAll(Map map); +} + +// FILE: main.kt +fun test(map : MapLike) {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt new file mode 100644 index 00000000000..ba54ca91941 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt @@ -0,0 +1,17 @@ +// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +// !DIAGNOSTICS: -UNUSED_PARAMETER +// FULL_JDK + +// FILE: MapLike.java +import java.util.Map; + +public interface MapLike<@org.jetbrains.annotations.NotNull K, V> { + void putAll(Map map); +} + +// FILE: main.kt +fun test0(map : MapLike<Int?, Int>) {} +fun test11(map : MapLike<K, K>) {} +fun test12(map : MapLike<K?, K>) {} +fun test13(map : MapLike) {} +fun test14(map : MapLike<K?, K>) {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.txt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.txt new file mode 100644 index 00000000000..4307fbac502 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.txt @@ -0,0 +1,15 @@ +package + +public fun test0(/*0*/ map: MapLike): kotlin.Unit +public fun test11(/*0*/ map: MapLike): kotlin.Unit +public fun test12(/*0*/ map: MapLike): kotlin.Unit +public fun test13(/*0*/ map: MapLike): kotlin.Unit +public fun test14(/*0*/ map: MapLike): kotlin.Unit +public fun test2(/*0*/ map: MapLike): kotlin.Unit + +public interface MapLike { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun putAll(/*0*/ map: kotlin.collections.(Mutable)Map!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index b41b5ab81ca..12b689e3f1c 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -34423,6 +34423,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/java"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } + @Test + @TestMetadata("checkEnhancedUpperBounds.kt") + public void testCheckEnhancedUpperBounds() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt"); + } + @Test @TestMetadata("concurrentHashMapContains.kt") public void testConcurrentHashMapContains() throws Exception { From edb8007d52bd03f99a2e5e49bac9ce7132aa607f Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Tue, 2 Feb 2021 10:31:52 +0300 Subject: [PATCH 125/368] Add test for errors reporting of UPPER_BOUND_VIOLATED --- .../FirOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ .../java/checkEnhancedUpperBounds.kt | 1 - ...cedUpperBoundsWithEnabledImprovements.fir.kt | 17 +++++++++++++++++ ...nhancedUpperBoundsWithEnabledImprovements.kt | 17 +++++++++++++++++ ...hancedUpperBoundsWithEnabledImprovements.txt | 14 ++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 ++++++ 6 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 0a5ab2b5e86..76840862ce5 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -34333,6 +34333,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt"); } + @Test + @TestMetadata("checkEnhancedUpperBoundsWithEnabledImprovements.kt") + public void testCheckEnhancedUpperBoundsWithEnabledImprovements() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.kt"); + } + @Test @TestMetadata("concurrentHashMapContains.kt") public void testConcurrentHashMapContains() throws Exception { diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt index ba54ca91941..f64818275c2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt @@ -1,4 +1,3 @@ -// !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated // !DIAGNOSTICS: -UNUSED_PARAMETER // FULL_JDK diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt new file mode 100644 index 00000000000..9f94e4a8326 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt @@ -0,0 +1,17 @@ +// !LANGUAGE: +ImprovementsAroundTypeEnhancement +// !DIAGNOSTICS: -UNUSED_PARAMETER +// FULL_JDK + +// FILE: MapLike.java +import java.util.Map; + +public interface MapLike<@org.jetbrains.annotations.NotNull K, V> { + void putAll(Map map); +} + +// FILE: main.kt +fun test0(map : MapLike) {} +fun test11(map : MapLike) {} +fun test12(map : MapLike) {} +fun test13(map : MapLike) {} +fun test14(map : MapLike) {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.kt new file mode 100644 index 00000000000..2f4a92ce002 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.kt @@ -0,0 +1,17 @@ +// !LANGUAGE: +ImprovementsAroundTypeEnhancement +// !DIAGNOSTICS: -UNUSED_PARAMETER +// FULL_JDK + +// FILE: MapLike.java +import java.util.Map; + +public interface MapLike<@org.jetbrains.annotations.NotNull K, V> { + void putAll(Map map); +} + +// FILE: main.kt +fun test0(map : MapLike<Int?, Int>) {} +fun test11(map : MapLike<K, K>) {} +fun test12(map : MapLike<K?, K>) {} +fun test13(map : MapLike) {} +fun test14(map : MapLike<K?, K>) {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.txt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.txt new file mode 100644 index 00000000000..bc80a549fca --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.txt @@ -0,0 +1,14 @@ +package + +public fun test0(/*0*/ map: MapLike): kotlin.Unit +public fun test11(/*0*/ map: MapLike): kotlin.Unit +public fun test12(/*0*/ map: MapLike): kotlin.Unit +public fun test13(/*0*/ map: MapLike): kotlin.Unit +public fun test14(/*0*/ map: MapLike): kotlin.Unit + +public interface MapLike { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun putAll(/*0*/ map: kotlin.collections.(Mutable)Map!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 12b689e3f1c..1f5c983ab43 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -34429,6 +34429,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt"); } + @Test + @TestMetadata("checkEnhancedUpperBoundsWithEnabledImprovements.kt") + public void testCheckEnhancedUpperBoundsWithEnabledImprovements() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.kt"); + } + @Test @TestMetadata("concurrentHashMapContains.kt") public void testConcurrentHashMapContains() throws Exception { From d783d99443ee4e2f0782b9456949f5179742b991 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Wed, 3 Feb 2021 12:59:49 +0300 Subject: [PATCH 126/368] Use upper bound checker for typealias expansion --- .../jvm/checkers/EnhancedUpperBoundChecker.kt | 57 ++++++++++------- .../jvm/checkers/JavaNullabilityChecker.kt | 31 +-------- .../diagnostics/DefaultErrorMessagesJvm.java | 5 ++ .../resolve/jvm/diagnostics/ErrorsJvm.java | 4 ++ .../kotlin/resolve/DeclarationsChecker.kt | 12 ++-- .../jetbrains/kotlin/resolve/TypeResolver.kt | 14 ++--- .../kotlin/resolve/UpperBoundChecker.kt | 63 ++++++++++++++----- .../kotlin/resolve/calls/CandidateResolver.kt | 23 ++++--- .../DiagnosticReporterByTrackingStrategy.kt | 6 +- .../tower/KotlinToResolvedCallTransformer.kt | 1 + .../java/checkEnhancedUpperBounds.fir.kt | 29 ++++++++- .../java/checkEnhancedUpperBounds.kt | 24 ++++++- .../java/checkEnhancedUpperBounds.txt | 28 ++++++++- ...dUpperBoundsWithEnabledImprovements.fir.kt | 32 ++++++++-- ...ancedUpperBoundsWithEnabledImprovements.kt | 24 ++++++- ...ncedUpperBoundsWithEnabledImprovements.txt | 27 +++++++- .../kotlin/types/TypeAliasExpander.kt | 27 +------- .../types/TypeAliasExpansionReportStrategy.kt | 4 +- .../kotlin/types/TypeWithEnhancement.kt | 34 ++++++++++ .../CompositeResolverForModuleFactory.kt | 1 + 20 files changed, 306 insertions(+), 140 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/EnhancedUpperBoundChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/EnhancedUpperBoundChecker.kt index 73599004670..0a2c5fa18e4 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/EnhancedUpperBoundChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/EnhancedUpperBoundChecker.kt @@ -7,40 +7,49 @@ package org.jetbrains.kotlin.resolve.jvm.checkers import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageVersionSettings -import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor +import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtTypeReference import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.UpperBoundChecker -import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm +import org.jetbrains.kotlin.resolve.UpperBoundViolatedReporter +import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS +import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS import org.jetbrains.kotlin.types.* -import org.jetbrains.kotlin.types.checker.KotlinTypeChecker -class EnhancedUpperBoundChecker(override val languageVersionSettings: LanguageVersionSettings) : UpperBoundChecker { - override fun checkBound( - bound: KotlinType, +// TODO: remove this checker after removing support LV < 1.6 +class EnhancedUpperBoundChecker(languageVersionSettings: LanguageVersionSettings) : UpperBoundChecker(languageVersionSettings) { + val isTypeEnhancementImprovementsEnabled = languageVersionSettings.supportsFeature(LanguageFeature.ImprovementsAroundTypeEnhancement) + + override fun checkBounds( + argumentReference: KtTypeReference?, + argumentType: KotlinType, + typeParameterDescriptor: TypeParameterDescriptor, substitutor: TypeSubstitutor, trace: BindingTrace, - jetTypeArgument: KtTypeReference, - typeArgument: KotlinType - ): Boolean { - val isCheckPassed = super.checkBound(bound, substitutor, trace, jetTypeArgument, typeArgument) + typeAliasUsageElement: KtElement? + ) { + if (typeParameterDescriptor.upperBounds.isEmpty()) return - // The error is already reported, it's unnecessary to do more checks - if (!isCheckPassed) return false + val diagnosticsReporter = UpperBoundViolatedReporter(trace, argumentType, typeParameterDescriptor) + val diagnosticsReporterForWarnings = UpperBoundViolatedReporter( + trace, argumentType, typeParameterDescriptor, + baseDiagnostic = UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS, + diagnosticForTypeAliases = UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS + ) - val enhancedBound = bound.getEnhancement() ?: return false + for (bound in typeParameterDescriptor.upperBounds) { + val isCheckPassed = checkBound(bound, argumentType, argumentReference, substitutor, typeAliasUsageElement, diagnosticsReporter) - val isTypeEnhancementImprovementsEnabled = - languageVersionSettings.supportsFeature(LanguageFeature.ImprovementsAroundTypeEnhancement) - val substitutedBound = substitutor.safeSubstitute(enhancedBound, Variance.INVARIANT) - if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) { - if (isTypeEnhancementImprovementsEnabled) { - trace.report(Errors.UPPER_BOUND_VIOLATED.on(jetTypeArgument, substitutedBound, typeArgument)) - } else { - trace.report(ErrorsJvm.UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS.on(jetTypeArgument, substitutedBound, typeArgument)) - } - return false + // The error is already reported, it's unnecessary to do more checks + if (!isCheckPassed) continue + + // If improvements are enabled, then type parameter's upper bounds will already enhanced, and the error will reported inside the first check + if (isTypeEnhancementImprovementsEnabled) continue + + val enhancedBound = bound.getEnhancementDeeply() ?: continue + + checkBound(enhancedBound, argumentType, argumentReference, substitutor, typeAliasUsageElement, diagnosticsReporterForWarnings) } - return true } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt index 9a6254f7080..c3462845953 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt @@ -215,9 +215,9 @@ class JavaNullabilityChecker : AdditionalTypeChecker { if (!doesExpectedTypeContainsEnhancement && !doesExpressionTypeContainsEnhancement) return - val enhancedExpectedType = if (doesExpectedTypeContainsEnhancement) buildTypeWithEnhancement(expectedType) else expectedType + val enhancedExpectedType = if (doesExpectedTypeContainsEnhancement) expectedType.unwrapEnhancementDeeply() else expectedType val enhancedExpressionType = enhanceExpressionTypeByDataFlowNullability( - if (doesExpressionTypeContainsEnhancement) buildTypeWithEnhancement(expressionType) else expressionType, + if (doesExpressionTypeContainsEnhancement) expressionType.unwrapEnhancementDeeply() else expressionType, expressionTypeDataFlowValue, dataFlowInfo ) @@ -253,33 +253,6 @@ class JavaNullabilityChecker : AdditionalTypeChecker { } else { null } - - private fun enhanceTypeArguments(arguments: List) = - arguments.map { argument -> - // TODO: think about star projections with enhancement (e.g. came from Java: Foo<@NotNull ?>) - if (argument.isStarProjection) { - return@map argument - } - val argumentType = argument.type - val enhancedArgumentType = if (argumentType is TypeWithEnhancement) argumentType.enhancement else argumentType - val enhancedDeeplyArgumentType = buildTypeWithEnhancement(enhancedArgumentType) - - argument.replaceType(enhancedDeeplyArgumentType) - } - - fun buildTypeWithEnhancement(type: KotlinType): KotlinType { - val newArguments = enhanceTypeArguments(type.arguments) - val newArgumentsForUpperBound = - if (type is FlexibleType) { - enhanceTypeArguments(type.upperBound.arguments) - } else newArguments - val enhancedType = if (type is TypeWithEnhancement) type.enhancement else type - - return enhancedType.replace( - newArguments = newArguments, - newArgumentsForUpperBound = newArgumentsForUpperBound - ) - } } class EnhancedNullabilityInfo(val enhancedType: KotlinType, val isFromJava: Boolean) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java index 52a4ce117ab..ce2a5a46f29 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.utils.StringsKt; import java.util.List; import static kotlin.collections.CollectionsKt.*; +import static org.jetbrains.kotlin.diagnostics.Errors.UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION; import static org.jetbrains.kotlin.diagnostics.rendering.Renderers.*; import static org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.*; @@ -86,6 +87,10 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { MAP.put(NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS, "Type mismatch: inferred type is {1} but {0} was expected", RENDER_TYPE, RENDER_TYPE); MAP.put(UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS, "Type argument is not within its bounds: should be subtype of ''{0}''", RENDER_TYPE, RENDER_TYPE); + MAP.put(UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS, + "Type argument resulting from type alias expansion is not within required bounds for ''{2}'': " + + "should be subtype of ''{0}'', substituted type is ''{1}''", + RENDER_TYPE, RENDER_TYPE, NAME); MAP.put(NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER, "Type mismatch: value of a nullable type {0} is used where non-nullable type is expected. " + "This warning will become an error soon. " + diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java index 05edf57b0c1..cb549a51268 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.resolve.jvm.diagnostics; import com.intellij.psi.PsiElement; import org.jetbrains.kotlin.descriptors.CallableDescriptor; +import org.jetbrains.kotlin.descriptors.ClassifierDescriptor; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.diagnostics.*; import org.jetbrains.kotlin.name.FqName; @@ -140,6 +141,9 @@ public interface ErrorsJvm { DiagnosticFactory2 UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS = DiagnosticFactory2.create(WARNING); + DiagnosticFactory3 UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS + = DiagnosticFactory3.create(WARNING); + DiagnosticFactory1 NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER = DiagnosticFactory1.create(WARNING); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt index de02be8ba01..7322a4cb65f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt @@ -202,7 +202,8 @@ class DeclarationsChecker( private class TypeAliasDeclarationCheckingReportStrategy( private val trace: BindingTrace, typeAliasDescriptor: TypeAliasDescriptor, - declaration: KtTypeAlias + declaration: KtTypeAlias, + val upperBoundChecker: UpperBoundChecker ) : TypeAliasExpansionReportStrategy { private val typeReference = declaration.getTypeReference() ?: throw AssertionError("Incorrect type alias declaration for $typeAliasDescriptor") @@ -224,15 +225,12 @@ class DeclarationsChecker( } override fun boundsViolationInSubstitution( - bound: KotlinType, + substitutor: TypeSubstitutor, unsubstitutedArgument: KotlinType, argument: KotlinType, typeParameter: TypeParameterDescriptor ) { - // TODO more precise diagnostics - if (!argument.containsTypeAliasParameters() && !bound.containsTypeAliasParameters()) { - trace.report(UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION.on(typeReference, bound, argument, typeParameter)) - } + upperBoundChecker.checkBounds(null, argument, typeParameter, substitutor, trace, typeReference) } override fun repeatedAnnotation(annotation: AnnotationDescriptor) { @@ -243,7 +241,7 @@ class DeclarationsChecker( private fun checkTypeAliasExpansion(declaration: KtTypeAlias, typeAliasDescriptor: TypeAliasDescriptor) { val typeAliasExpansion = TypeAliasExpansion.createWithFormalArguments(typeAliasDescriptor) - val reportStrategy = TypeAliasDeclarationCheckingReportStrategy(trace, typeAliasDescriptor, declaration) + val reportStrategy = TypeAliasDeclarationCheckingReportStrategy(trace, typeAliasDescriptor, declaration, upperBoundChecker) TypeAliasExpander(reportStrategy, true).expandWithoutAbbreviation(typeAliasExpansion, Annotations.EMPTY) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index d85b0f53cdc..21da0f3ea0b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -597,7 +597,8 @@ class TypeResolver( c.trace, type, typeAliasQualifierPart.typeArguments ?: typeAliasQualifierPart.expression, descriptor, descriptor.declaredTypeParameters, - argumentElementsFromUserType // TODO arguments from inner scope + argumentElementsFromUserType, // TODO arguments from inner scope + upperBoundChecker ) if (parameters.size != arguments.size) { @@ -659,7 +660,8 @@ class TypeResolver( val typeArgumentsOrTypeName: KtElement?, val typeAliasDescriptor: TypeAliasDescriptor, typeParameters: List, - typeArguments: List + typeArguments: List, + val upperBoundChecker: UpperBoundChecker ) : TypeAliasExpansionReportStrategy { private val mappedArguments = typeParameters.zip(typeArguments).toMap() @@ -690,7 +692,7 @@ class TypeResolver( } override fun boundsViolationInSubstitution( - bound: KotlinType, + substitutor: TypeSubstitutor, unsubstitutedArgument: KotlinType, argument: KotlinType, typeParameter: TypeParameterDescriptor @@ -698,11 +700,7 @@ class TypeResolver( val descriptorForUnsubstitutedArgument = unsubstitutedArgument.constructor.declarationDescriptor val argumentElement = mappedArguments[descriptorForUnsubstitutedArgument] val argumentTypeReferenceElement = argumentElement?.typeReference - if (argumentTypeReferenceElement != null) { - trace.report(UPPER_BOUND_VIOLATED.on(argumentTypeReferenceElement, bound, argument)) - } else if (type != null) { - trace.report(UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION.on(type, bound, argument, typeParameter)) - } + upperBoundChecker.checkBounds(argumentTypeReferenceElement, argument, typeParameter, substitutor, trace, type) } override fun repeatedAnnotation(annotation: AnnotationDescriptor) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt index fd0ebaa36ed..2b29e5cbb9b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt @@ -7,17 +7,21 @@ package org.jetbrains.kotlin.resolve import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.container.DefaultImplementation +import org.jetbrains.kotlin.descriptors.ClassifierDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.diagnostics.DiagnosticFactory2 +import org.jetbrains.kotlin.diagnostics.DiagnosticFactory3 +import org.jetbrains.kotlin.diagnostics.Errors.UPPER_BOUND_VIOLATED +import org.jetbrains.kotlin.diagnostics.Errors.UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION +import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtTypeReference import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.KotlinTypeChecker +import org.jetbrains.kotlin.types.typeUtil.containsTypeAliasParameters @DefaultImplementation(impl = UpperBoundChecker::class) -interface UpperBoundChecker { - val languageVersionSettings: LanguageVersionSettings - +open class UpperBoundChecker(val languageVersionSettings: LanguageVersionSettings) { fun checkBounds(typeReference: KtTypeReference, type: KotlinType, trace: BindingTrace) { if (type.isError) return @@ -54,30 +58,59 @@ interface UpperBoundChecker { } } - fun checkBounds( - jetTypeArgument: KtTypeReference, - typeArgument: KotlinType, + open fun checkBounds( + argumentReference: KtTypeReference?, + argumentType: KotlinType, typeParameterDescriptor: TypeParameterDescriptor, substitutor: TypeSubstitutor, - trace: BindingTrace + trace: BindingTrace, + typeAliasUsageElement: KtElement? = null, ) { + if (typeParameterDescriptor.upperBounds.isEmpty()) return + + val diagnosticsReporter = UpperBoundViolatedReporter(trace, argumentType, typeParameterDescriptor) + for (bound in typeParameterDescriptor.upperBounds) { - checkBound(bound, substitutor, trace, jetTypeArgument, typeArgument) + checkBound(bound, argumentType, argumentReference, substitutor, typeAliasUsageElement, diagnosticsReporter) } } - fun checkBound( + protected fun checkBound( bound: KotlinType, + argumentType: KotlinType, + argumentReference: KtTypeReference?, substitutor: TypeSubstitutor, - trace: BindingTrace, - jetTypeArgument: KtTypeReference, - typeArgument: KotlinType + typeAliasUsageElement: KtElement? = null, + upperBoundViolatedReporter: UpperBoundViolatedReporter ): Boolean { val substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT) - if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) { - trace.report(Errors.UPPER_BOUND_VIOLATED.on(jetTypeArgument, substitutedBound, typeArgument)) + + if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(argumentType, substitutedBound)) { + if (argumentReference != null) { + upperBoundViolatedReporter.report(argumentReference, substitutedBound) + } else if (typeAliasUsageElement != null && !substitutedBound.containsTypeAliasParameters() && !argumentType.containsTypeAliasParameters()) { + upperBoundViolatedReporter.reportForTypeAliasExpansion(typeAliasUsageElement, substitutedBound) + } return false } + return true } } + +class UpperBoundViolatedReporter( + val trace: BindingTrace, + val argumentType: KotlinType, + val typeParameterDescriptor: TypeParameterDescriptor? = null, + val baseDiagnostic: DiagnosticFactory2 = UPPER_BOUND_VIOLATED, + val diagnosticForTypeAliases: DiagnosticFactory3 = UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION +) { + fun report(typeArgumentReference: KtTypeReference, substitutedBound: KotlinType) { + trace.report(baseDiagnostic.on(typeArgumentReference, substitutedBound, argumentType)) + } + + fun reportForTypeAliasExpansion(callElement: KtElement, substitutedBound: KotlinType) { + if (typeParameterDescriptor == null) return + trace.report(diagnosticForTypeAliases.on(callElement, substitutedBound, argumentType, typeParameterDescriptor)) + } +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt index c7868682f92..9e2a09eefb3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt @@ -606,7 +606,8 @@ class CandidateResolver( private val callElement: KtElement, typeAlias: TypeAliasDescriptor, ktTypeArguments: List, - private val trace: BindingTrace + private val trace: BindingTrace, + private val upperBoundChecker: UpperBoundChecker ) : TypeAliasExpansionReportStrategy { init { assert(!typeAlias.expandedType.isError) { "Incorrect type alias: $typeAlias" } @@ -635,7 +636,7 @@ class CandidateResolver( } override fun boundsViolationInSubstitution( - bound: KotlinType, + substitutor: TypeSubstitutor, unsubstitutedArgument: KotlinType, argument: KotlinType, typeParameter: TypeParameterDescriptor @@ -643,11 +644,8 @@ class CandidateResolver( val descriptorForUnsubstitutedArgument = unsubstitutedArgument.constructor.declarationDescriptor val argumentElement = argumentsMapping[descriptorForUnsubstitutedArgument] val argumentTypeReferenceElement = argumentElement?.typeReference - if (argumentTypeReferenceElement != null) { - trace.report(UPPER_BOUND_VIOLATED.on(argumentTypeReferenceElement, bound, argument)) - } else { - trace.report(UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION.on(callElement, bound, argument, typeParameter)) - } + + upperBoundChecker.checkBounds(argumentTypeReferenceElement, argument, typeParameter, substitutor, trace, callElement) } } @@ -665,7 +663,8 @@ class CandidateResolver( val unsubstitutedType = typeAliasDescriptor.expandedType if (unsubstitutedType.isError) return - val reportStrategy = TypeAliasSingleStepExpansionReportStrategy(call.callElement, typeAliasDescriptor, ktTypeArguments, trace) + val reportStrategy = + TypeAliasSingleStepExpansionReportStrategy(call.callElement, typeAliasDescriptor, ktTypeArguments, trace, upperBoundChecker) // TODO refactor TypeResolver // - perform full type alias expansion @@ -694,12 +693,12 @@ class CandidateResolver( val typeParameter = typeParameters[i] val substitutedTypeArgument = substitutedTypeProjection.type val unsubstitutedTypeArgument = unsubstitutedType.arguments[i].type - TypeAliasExpander.checkBoundsInTypeAlias( - reportStrategy, + + reportStrategy.boundsViolationInSubstitution( + boundsSubstitutor, unsubstitutedTypeArgument, substitutedTypeArgument, - typeParameter, - boundsSubstitutor + typeParameter ) checkTypeInTypeAliasSubstitutionRec( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index 7398559c52d..ad0373ae391 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -15,6 +15,8 @@ import org.jetbrains.kotlin.diagnostics.reportDiagnosticOnce import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.isNull import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.UpperBoundChecker +import org.jetbrains.kotlin.resolve.UpperBoundViolatedReporter import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.callUtil.reportTrailingLambdaErrorOr @@ -393,8 +395,8 @@ class DiagnosticReporterByTrackingStrategy( } (position as? ExplicitTypeParameterConstraintPositionImpl)?.let { - val typeArgumentReference = (it.typeArgument as SimpleTypeArgumentImpl).typeReference - trace.report(UPPER_BOUND_VIOLATED.on(typeArgumentReference, error.upperKotlinType, error.lowerKotlinType)) + UpperBoundViolatedReporter(trace, error.upperKotlinType) + .report((it.typeArgument as SimpleTypeArgumentImpl).typeReference, error.lowerKotlinType) } (position as? FixVariableConstraintPositionImpl)?.let { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt index af4e965302c..66fcf59578e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt @@ -84,6 +84,7 @@ class KotlinToResolvedCallTransformer( private val smartCastManager: SmartCastManager, private val typeApproximator: TypeApproximator, private val missingSupertypesResolver: MissingSupertypesResolver, + private val upperBoundChecker: UpperBoundChecker, ) { companion object { private val REPORT_MISSING_NEW_INFERENCE_DIAGNOSTIC diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt index e89ef63ceb7..c74590f7a23 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt @@ -1,11 +1,36 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE // FULL_JDK // FILE: MapLike.java import java.util.Map; -public interface MapLike<@org.jetbrains.annotations.NotNull K, V> { +public class MapLike<@org.jetbrains.annotations.NotNull K, V> { void putAll(Map map); } +// FILE: ListLike.java +import java.util.Collection; + +public class ListLike> {} + // FILE: main.kt -fun test(map : MapLike) {} +fun test0(map : MapLike<Int?, Int>) {} +fun test11(map : MapLike<K, K>) {} +fun test12(map : MapLike<K?, K>) {} +fun test13(map : MapLike) {} +fun test14(map : MapLike<K?, K>) {} + +class Foo + +typealias A = MapLike +typealias A2 = Foo> +typealias A3 = ListLike> + +fun main1(x: A<Int?>) {} +fun main2(x: A2<Int?>) {} +fun main3(x: A3) {} +fun main3() { + val x = A3() // TODO: support reporting errors on typealias constructor calls + val x2 = A() // TODO: support reporting errors on typealias constructor calls + val y: A3 = A3() +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt index f64818275c2..c74590f7a23 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt @@ -1,16 +1,36 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE // FULL_JDK // FILE: MapLike.java import java.util.Map; -public interface MapLike<@org.jetbrains.annotations.NotNull K, V> { +public class MapLike<@org.jetbrains.annotations.NotNull K, V> { void putAll(Map map); } +// FILE: ListLike.java +import java.util.Collection; + +public class ListLike> {} + // FILE: main.kt fun test0(map : MapLike<Int?, Int>) {} fun test11(map : MapLike<K, K>) {} fun test12(map : MapLike<K?, K>) {} fun test13(map : MapLike) {} fun test14(map : MapLike<K?, K>) {} + +class Foo + +typealias A = MapLike +typealias A2 = Foo> +typealias A3 = ListLike> + +fun main1(x: A<Int?>) {} +fun main2(x: A2<Int?>) {} +fun main3(x: A3) {} +fun main3() { + val x = A3() // TODO: support reporting errors on typealias constructor calls + val x2 = A() // TODO: support reporting errors on typealias constructor calls + val y: A3 = A3() +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.txt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.txt index 4307fbac502..1a2ba462509 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.txt @@ -1,15 +1,37 @@ package +public fun main1(/*0*/ x: A /* = MapLike */): kotlin.Unit +public fun main2(/*0*/ x: A2 /* = Foo> */): kotlin.Unit +public fun main3(): kotlin.Unit +public fun main3(/*0*/ x: A3 /* = ListLike> */): kotlin.Unit public fun test0(/*0*/ map: MapLike): kotlin.Unit public fun test11(/*0*/ map: MapLike): kotlin.Unit public fun test12(/*0*/ map: MapLike): kotlin.Unit public fun test13(/*0*/ map: MapLike): kotlin.Unit public fun test14(/*0*/ map: MapLike): kotlin.Unit -public fun test2(/*0*/ map: MapLike): kotlin.Unit -public interface MapLike { +public final class Foo { + public constructor Foo() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public abstract fun putAll(/*0*/ map: kotlin.collections.(Mutable)Map!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } + +public open class ListLike!> { + public constructor ListLike!>() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class MapLike { + public constructor MapLike() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public/*package*/ open fun putAll(/*0*/ map: kotlin.collections.(Mutable)Map!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} +public typealias A = MapLike +public typealias A2 = Foo> +public typealias A3 = ListLike> + diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt index 9f94e4a8326..a64a67bac51 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt @@ -1,17 +1,37 @@ // !LANGUAGE: +ImprovementsAroundTypeEnhancement -// !DIAGNOSTICS: -UNUSED_PARAMETER +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE // FULL_JDK // FILE: MapLike.java import java.util.Map; -public interface MapLike<@org.jetbrains.annotations.NotNull K, V> { +public class MapLike<@org.jetbrains.annotations.NotNull K, V> { void putAll(Map map); } +// FILE: ListLike.java +import java.util.Collection; + +public class ListLike> {} + // FILE: main.kt -fun test0(map : MapLike) {} -fun test11(map : MapLike) {} -fun test12(map : MapLike) {} +fun test0(map : MapLike<Int?, Int>) {} +fun test11(map : MapLike<K, K>) {} +fun test12(map : MapLike<K?, K>) {} fun test13(map : MapLike) {} -fun test14(map : MapLike) {} +fun test14(map : MapLike<K?, K>) {} + +class Foo + +typealias A = MapLike +typealias A2 = Foo> +typealias A3 = ListLike> + +fun main1(x: A<Int?>) {} +fun main2(x: A2<Int?>) {} +fun main3(x: A3) {} +fun main3() { + val x = A3() // TODO: support reporting errors on typealias constructor calls + val x2 = A() + val y: A3 = A3() +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.kt index 2f4a92ce002..2b1481db01e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.kt @@ -1,17 +1,37 @@ // !LANGUAGE: +ImprovementsAroundTypeEnhancement -// !DIAGNOSTICS: -UNUSED_PARAMETER +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE // FULL_JDK // FILE: MapLike.java import java.util.Map; -public interface MapLike<@org.jetbrains.annotations.NotNull K, V> { +public class MapLike<@org.jetbrains.annotations.NotNull K, V> { void putAll(Map map); } +// FILE: ListLike.java +import java.util.Collection; + +public class ListLike> {} + // FILE: main.kt fun test0(map : MapLike<Int?, Int>) {} fun test11(map : MapLike<K, K>) {} fun test12(map : MapLike<K?, K>) {} fun test13(map : MapLike) {} fun test14(map : MapLike<K?, K>) {} + +class Foo + +typealias A = MapLike +typealias A2 = Foo> +typealias A3 = ListLike> + +fun main1(x: A<Int?>) {} +fun main2(x: A2<Int?>) {} +fun main3(x: A3) {} +fun main3() { + val x = A3() // TODO: support reporting errors on typealias constructor calls + val x2 = A<Int?>() + val y: A3 = A3() +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.txt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.txt index bc80a549fca..89322e6d6db 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.txt @@ -1,14 +1,37 @@ package +public fun main1(/*0*/ x: A /* = MapLike */): kotlin.Unit +public fun main2(/*0*/ x: A2 /* = Foo> */): kotlin.Unit +public fun main3(): kotlin.Unit +public fun main3(/*0*/ x: A3 /* = ListLike> */): kotlin.Unit public fun test0(/*0*/ map: MapLike): kotlin.Unit public fun test11(/*0*/ map: MapLike): kotlin.Unit public fun test12(/*0*/ map: MapLike): kotlin.Unit public fun test13(/*0*/ map: MapLike): kotlin.Unit public fun test14(/*0*/ map: MapLike): kotlin.Unit -public interface MapLike { +public final class Foo { + public constructor Foo() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public abstract fun putAll(/*0*/ map: kotlin.collections.(Mutable)Map!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } + +public open class ListLike!> { + public constructor ListLike!>() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class MapLike { + public constructor MapLike() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public/*package*/ open fun putAll(/*0*/ map: kotlin.collections.(Mutable)Map!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} +public typealias A = MapLike +public typealias A2 = Foo> +public typealias A3 = ListLike> + diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeAliasExpander.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeAliasExpander.kt index 436d736e516..aef0505dd38 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeAliasExpander.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeAliasExpander.kt @@ -250,12 +250,11 @@ class TypeAliasExpander( val unsubstitutedArgument = unsubstitutedType.arguments[i] val typeParameter = unsubstitutedType.constructor.parameters[i] if (shouldCheckBounds) { - checkBoundsInTypeAlias( - reportStrategy, + reportStrategy.boundsViolationInSubstitution( + typeSubstitutor, unsubstitutedArgument.type, substitutedArgument.type, - typeParameter, - typeSubstitutor + typeParameter ) } } @@ -265,26 +264,6 @@ class TypeAliasExpander( companion object { private const val MAX_RECURSION_DEPTH = 100 - fun checkBoundsInTypeAlias( - reportStrategy: TypeAliasExpansionReportStrategy, - unsubstitutedArgument: KotlinType, - typeArgument: KotlinType, - typeParameterDescriptor: TypeParameterDescriptor, - substitutor: TypeSubstitutor - ) { - for (bound in typeParameterDescriptor.upperBounds) { - val substitutedBound = substitutor.safeSubstitute(bound, Variance.INVARIANT) - if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(typeArgument, substitutedBound)) { - reportStrategy.boundsViolationInSubstitution( - substitutedBound, - unsubstitutedArgument, - typeArgument, - typeParameterDescriptor - ) - } - } - } - private fun assertRecursionDepth(recursionDepth: Int, typeAliasDescriptor: TypeAliasDescriptor) { if (recursionDepth > MAX_RECURSION_DEPTH) { throw AssertionError("Too deep recursion while expanding type alias ${typeAliasDescriptor.name}") diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeAliasExpansionReportStrategy.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeAliasExpansionReportStrategy.kt index 9b029b47990..b6b0f4a26d4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeAliasExpansionReportStrategy.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeAliasExpansionReportStrategy.kt @@ -14,7 +14,7 @@ interface TypeAliasExpansionReportStrategy { fun conflictingProjection(typeAlias: TypeAliasDescriptor, typeParameter: TypeParameterDescriptor?, substitutedArgument: KotlinType) fun recursiveTypeAlias(typeAlias: TypeAliasDescriptor) fun boundsViolationInSubstitution( - bound: KotlinType, + substitutor: TypeSubstitutor, unsubstitutedArgument: KotlinType, argument: KotlinType, typeParameter: TypeParameterDescriptor @@ -33,7 +33,7 @@ interface TypeAliasExpansionReportStrategy { override fun recursiveTypeAlias(typeAlias: TypeAliasDescriptor) {} override fun boundsViolationInSubstitution( - bound: KotlinType, + substitutor: TypeSubstitutor, unsubstitutedArgument: KotlinType, argument: KotlinType, typeParameter: TypeParameterDescriptor diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt index 236de1041a2..b5f179ad799 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt @@ -88,6 +88,40 @@ fun KotlinType.getEnhancement(): KotlinType? = when (this) { else -> null } +private fun List.enhanceTypeArguments(depth: Int) = + map { argument -> + // TODO: think about star projections with enhancement (e.g. came from Java: Foo<@NotNull ?>) + if (argument.isStarProjection) { + return@map argument + } + val argumentType = argument.type + val enhancedArgumentType = if (argumentType is TypeWithEnhancement) argumentType.enhancement else argumentType + val enhancedDeeplyArgumentType = enhancedArgumentType.getEnhancementDeeply(depth + 1) + + argument.replaceType(enhancedDeeplyArgumentType) + } + +private fun KotlinType.getEnhancementDeeply(depth: Int): KotlinType { + val newArguments = arguments.enhanceTypeArguments(depth) + val newArgumentsForUpperBound = if (this is FlexibleType) upperBound.arguments.enhanceTypeArguments(depth) else newArguments + val enhancedType = if (this is TypeWithEnhancement) enhancement else this + + return enhancedType.replace( + newArguments = newArguments, + newArgumentsForUpperBound = newArgumentsForUpperBound + ) +} + +fun KotlinType.getEnhancementDeeply(): KotlinType? { + val enhancedTypeWithArguments = getEnhancementDeeply(depth = 0) + + if (enhancedTypeWithArguments === this) return null + + return enhancedTypeWithArguments +} + +fun KotlinType.unwrapEnhancementDeeply() = getEnhancementDeeply() ?: this + fun KotlinType.unwrapEnhancement(): KotlinType = getEnhancement() ?: this fun UnwrappedType.inheritEnhancement(origin: KotlinType): UnwrappedType = wrapEnhancement(origin.getEnhancement()) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CompositeResolverForModuleFactory.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CompositeResolverForModuleFactory.kt index ad6528edc56..3a3d7cefa66 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CompositeResolverForModuleFactory.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CompositeResolverForModuleFactory.kt @@ -266,5 +266,6 @@ class CompositePlatformConigurator(private val componentConfigurators: List() + container.useImpl() } } \ No newline at end of file From 0d40022d6de4de1d8dfbdb9b470f0acb35506d9d Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Thu, 4 Feb 2021 11:42:52 +0300 Subject: [PATCH 127/368] Add reporting of the warnings based on Java annotations for expanded type aliases Before that, such warnings weren't reported as the corresponding errors were reported during type inference (only original types took part there) --- .../src/org/jetbrains/kotlin/container/Dsl.kt | 4 ++ .../kotlin/resolve/PlatformConfigurator.kt | 3 +- .../jvm/checkers/JavaNullabilityChecker.kt | 13 +++-- ...er.kt => WarningAwareUpperBoundChecker.kt} | 43 ++++++++++---- .../jvm/platform/JvmPlatformConfigurator.kt | 17 +++--- .../kotlin/analyzer/common/CommonPlatform.kt | 3 +- .../jetbrains/kotlin/frontend/di/injection.kt | 2 +- .../kotlin/resolve/UpperBoundChecker.kt | 58 ++++++++++--------- .../DiagnosticReporterByTrackingStrategy.kt | 6 +- .../boundViolationInTypeAliasConstructor.kt | 6 +- ...peArgumentsInferenceWithNestedCalls.fir.kt | 14 ++++- ...orTypeArgumentsInferenceWithNestedCalls.kt | 16 ++++- ...peArgumentsInferenceWithNestedCalls.ni.txt | 14 ----- ...rTypeArgumentsInferenceWithNestedCalls.txt | 13 ++++- .../java/checkEnhancedUpperBounds.fir.kt | 16 ++--- .../java/checkEnhancedUpperBounds.kt | 6 +- ...dUpperBoundsWithEnabledImprovements.fir.kt | 16 ++--- .../ClassTypeParameterBoundWithWarnings.kt | 4 +- .../kotlin/types/TypeWithEnhancement.kt | 31 ++++++++-- .../CompositeResolverForModuleFactory.kt | 9 ++- .../js/resolve/JsPlatformConfigurator.kt | 3 +- .../platform/NativePlatformConfigurator.kt | 3 +- 22 files changed, 186 insertions(+), 114 deletions(-) rename compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/{EnhancedUpperBoundChecker.kt => WarningAwareUpperBoundChecker.kt} (58%) delete mode 100644 compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.ni.txt diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Dsl.kt b/compiler/container/src/org/jetbrains/kotlin/container/Dsl.kt index 3f90482fdce..ab2015861d2 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Dsl.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Dsl.kt @@ -29,6 +29,10 @@ inline fun StorageComponentContainer.useImpl() { registerSingleton(T::class.java) } +inline fun StorageComponentContainer.useImplIf(cond: Boolean) { + if (cond) useImpl() +} + inline fun ComponentProvider.get(): T { return getService(T::class.java) } diff --git a/compiler/frontend.common/src/org/jetbrains/kotlin/resolve/PlatformConfigurator.kt b/compiler/frontend.common/src/org/jetbrains/kotlin/resolve/PlatformConfigurator.kt index a7342ed3ac7..5ce1dd39146 100644 --- a/compiler/frontend.common/src/org/jetbrains/kotlin/resolve/PlatformConfigurator.kt +++ b/compiler/frontend.common/src/org/jetbrains/kotlin/resolve/PlatformConfigurator.kt @@ -5,10 +5,11 @@ package org.jetbrains.kotlin.resolve +import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.container.StorageComponentContainer interface PlatformConfigurator { val platformSpecificContainer: StorageComponentContainer - fun configureModuleComponents(container: StorageComponentContainer) + fun configureModuleComponents(container: StorageComponentContainer, languageVersionSettings: LanguageVersionSettings) fun configureModuleDependentCheckers(container: StorageComponentContainer) } \ No newline at end of file diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt index c3462845953..4677b70b5f1 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/JavaNullabilityChecker.kt @@ -21,11 +21,9 @@ import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.psi.KtBinaryExpression -import org.jetbrains.kotlin.psi.KtExpression -import org.jetbrains.kotlin.psi.KtPostfixExpression -import org.jetbrains.kotlin.psi.KtWhenExpression +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.UpperBoundChecker import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext @@ -43,14 +41,17 @@ import org.jetbrains.kotlin.types.model.KotlinTypeMarker import org.jetbrains.kotlin.types.typeUtil.contains import org.jetbrains.kotlin.types.typeUtil.makeNotNullable -class JavaNullabilityChecker : AdditionalTypeChecker { - +class JavaNullabilityChecker(val upperBoundChecker: UpperBoundChecker) : AdditionalTypeChecker { override fun checkType( expression: KtExpression, expressionType: KotlinType, expressionTypeWithSmartCast: KotlinType, c: ResolutionContext<*> ) { + if (expressionType is AbbreviatedType) { + upperBoundChecker.checkBoundsOfExpandedTypeAlias(expressionType.expandedType, expression, c.trace) + } + val dataFlowValue by lazy(LazyThreadSafetyMode.NONE) { c.dataFlowValueFactory.createDataFlowValue(expression, expressionType, c) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/EnhancedUpperBoundChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/WarningAwareUpperBoundChecker.kt similarity index 58% rename from compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/EnhancedUpperBoundChecker.kt rename to compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/WarningAwareUpperBoundChecker.kt index 0a2c5fa18e4..7c2fababedb 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/EnhancedUpperBoundChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/WarningAwareUpperBoundChecker.kt @@ -5,10 +5,9 @@ package org.jetbrains.kotlin.resolve.jvm.checkers -import org.jetbrains.kotlin.config.LanguageFeature -import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.psi.KtElement +import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtTypeReference import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.UpperBoundChecker @@ -18,8 +17,17 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.UPPER_BOUND_VIOLAT import org.jetbrains.kotlin.types.* // TODO: remove this checker after removing support LV < 1.6 -class EnhancedUpperBoundChecker(languageVersionSettings: LanguageVersionSettings) : UpperBoundChecker(languageVersionSettings) { - val isTypeEnhancementImprovementsEnabled = languageVersionSettings.supportsFeature(LanguageFeature.ImprovementsAroundTypeEnhancement) +class WarningAwareUpperBoundChecker : UpperBoundChecker() { + override fun checkBoundsOfExpandedTypeAlias(type: KotlinType, expression: KtExpression, trace: BindingTrace) { + val typeParameters = type.constructor.parameters + + for ((index, arg) in type.arguments.withIndex()) { + checkBounds( + null, arg.type, typeParameters[index], TypeSubstitutor.create(type), trace, expression, + withOnlyCheckForWarning = true + ) + } + } override fun checkBounds( argumentReference: KtTypeReference?, @@ -28,6 +36,21 @@ class EnhancedUpperBoundChecker(languageVersionSettings: LanguageVersionSettings substitutor: TypeSubstitutor, trace: BindingTrace, typeAliasUsageElement: KtElement? + ) { + checkBounds( + argumentReference, argumentType, typeParameterDescriptor, substitutor, trace, typeAliasUsageElement, + withOnlyCheckForWarning = false + ) + } + + fun checkBounds( + argumentReference: KtTypeReference?, + argumentType: KotlinType, + typeParameterDescriptor: TypeParameterDescriptor, + substitutor: TypeSubstitutor, + trace: BindingTrace, + typeAliasUsageElement: KtElement?, + withOnlyCheckForWarning: Boolean = false ) { if (typeParameterDescriptor.upperBounds.isEmpty()) return @@ -39,13 +62,13 @@ class EnhancedUpperBoundChecker(languageVersionSettings: LanguageVersionSettings ) for (bound in typeParameterDescriptor.upperBounds) { - val isCheckPassed = checkBound(bound, argumentType, argumentReference, substitutor, typeAliasUsageElement, diagnosticsReporter) + if (!withOnlyCheckForWarning) { + val isBaseCheckPassed = + checkBound(bound, argumentType, argumentReference, substitutor, typeAliasUsageElement, diagnosticsReporter) - // The error is already reported, it's unnecessary to do more checks - if (!isCheckPassed) continue - - // If improvements are enabled, then type parameter's upper bounds will already enhanced, and the error will reported inside the first check - if (isTypeEnhancementImprovementsEnabled) continue + // The error is already reported, it's unnecessary to do more checks + if (!isBaseCheckPassed) continue + } val enhancedBound = bound.getEnhancementDeeply() ?: continue diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt index 07a7924d721..f95625be0c8 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/platform/JvmPlatformConfigurator.kt @@ -6,10 +6,9 @@ package org.jetbrains.kotlin.resolve.jvm.platform import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMapper -import org.jetbrains.kotlin.container.PlatformExtensionsClashResolver -import org.jetbrains.kotlin.container.StorageComponentContainer -import org.jetbrains.kotlin.container.useImpl -import org.jetbrains.kotlin.container.useInstance +import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.config.LanguageVersionSettings +import org.jetbrains.kotlin.container.* import org.jetbrains.kotlin.load.java.sam.JvmSamConversionOracle import org.jetbrains.kotlin.resolve.PlatformConfiguratorBase import org.jetbrains.kotlin.resolve.checkers.BigFunctionTypeAvailabilityChecker @@ -61,7 +60,6 @@ object JvmPlatformConfigurator : PlatformConfiguratorBase( ), additionalTypeCheckers = listOf( - JavaNullabilityChecker(), RuntimeAssertionsTypeChecker, JavaGenericVarianceViolationTypeChecker, JavaTypeAccessibilityChecker(), @@ -95,9 +93,13 @@ object JvmPlatformConfigurator : PlatformConfiguratorBase( declarationReturnTypeSanitizer = JvmDeclarationReturnTypeSanitizer ) { - override fun configureModuleComponents(container: StorageComponentContainer) { + override fun configureModuleComponents(container: StorageComponentContainer, languageVersionSettings: LanguageVersionSettings) { + container.useImplIf( + !languageVersionSettings.supportsFeature(LanguageFeature.ImprovementsAroundTypeEnhancement) + ) + + container.useImpl() container.useImpl() - container.useImpl() container.useImpl() container.useImpl() container.useImpl() @@ -112,6 +114,7 @@ object JvmPlatformConfigurator : PlatformConfiguratorBase( container.useImpl() container.useImpl() container.useImpl() + container.useInstance(FunctionWithBigAritySupport.LanguageVersionDependent) container.useInstance(GenericArrayClassLiteralSupport.Enabled) container.useInstance(JavaActualAnnotationArgumentExtractor()) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/common/CommonPlatform.kt b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/common/CommonPlatform.kt index f6b55605db5..c3a6f2d984f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/analyzer/common/CommonPlatform.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/analyzer/common/CommonPlatform.kt @@ -6,12 +6,13 @@ package org.jetbrains.kotlin.analyzer.common import org.jetbrains.kotlin.analyzer.ModuleInfo +import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.container.StorageComponentContainer import org.jetbrains.kotlin.resolve.* import org.jetbrains.kotlin.storage.StorageManager private object CommonPlatformConfigurator : PlatformConfiguratorBase() { - override fun configureModuleComponents(container: StorageComponentContainer) {} + override fun configureModuleComponents(container: StorageComponentContainer, languageVersionSettings: LanguageVersionSettings) {} } object CommonPlatformAnalyzerServices : PlatformDependentAnalyzerServices() { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt b/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt index 20b936b0438..558c904c5c6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/frontend/di/injection.kt @@ -73,7 +73,7 @@ fun StorageComponentContainer.configureModule( useInstance(nonTrivialPlatformVersion ?: TargetPlatformVersion.NoVersion) - analyzerServices.platformConfigurator.configureModuleComponents(this) + analyzerServices.platformConfigurator.configureModuleComponents(this, languageVersionSettings) analyzerServices.platformConfigurator.configureModuleDependentCheckers(this) for (extension in StorageComponentContainerContributor.getInstances(moduleContext.project)) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt index 2b29e5cbb9b..72a7a59e9c2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/UpperBoundChecker.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.resolve -import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.container.DefaultImplementation import org.jetbrains.kotlin.descriptors.ClassifierDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor @@ -13,7 +12,9 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticFactory2 import org.jetbrains.kotlin.diagnostics.DiagnosticFactory3 import org.jetbrains.kotlin.diagnostics.Errors.UPPER_BOUND_VIOLATED import org.jetbrains.kotlin.diagnostics.Errors.UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION +import org.jetbrains.kotlin.diagnostics.reportDiagnosticOnce import org.jetbrains.kotlin.psi.KtElement +import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtTypeReference import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.types.* @@ -21,7 +22,28 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.typeUtil.containsTypeAliasParameters @DefaultImplementation(impl = UpperBoundChecker::class) -open class UpperBoundChecker(val languageVersionSettings: LanguageVersionSettings) { +open class UpperBoundChecker { + open fun checkBoundsOfExpandedTypeAlias(type: KotlinType, expression: KtExpression, trace: BindingTrace) { + // do nothing in the strict mode as the errors are already reported in the type inference if necessary + } + + open fun checkBounds( + argumentReference: KtTypeReference?, + argumentType: KotlinType, + typeParameterDescriptor: TypeParameterDescriptor, + substitutor: TypeSubstitutor, + trace: BindingTrace, + typeAliasUsageElement: KtElement? = null, + ) { + if (typeParameterDescriptor.upperBounds.isEmpty()) return + + val diagnosticsReporter = UpperBoundViolatedReporter(trace, argumentType, typeParameterDescriptor) + + for (bound in typeParameterDescriptor.upperBounds) { + checkBound(bound, argumentType, argumentReference, substitutor, typeAliasUsageElement, diagnosticsReporter) + } + } + fun checkBounds(typeReference: KtTypeReference, type: KotlinType, trace: BindingTrace) { if (type.isError) return @@ -58,23 +80,6 @@ open class UpperBoundChecker(val languageVersionSettings: LanguageVersionSetting } } - open fun checkBounds( - argumentReference: KtTypeReference?, - argumentType: KotlinType, - typeParameterDescriptor: TypeParameterDescriptor, - substitutor: TypeSubstitutor, - trace: BindingTrace, - typeAliasUsageElement: KtElement? = null, - ) { - if (typeParameterDescriptor.upperBounds.isEmpty()) return - - val diagnosticsReporter = UpperBoundViolatedReporter(trace, argumentType, typeParameterDescriptor) - - for (bound in typeParameterDescriptor.upperBounds) { - checkBound(bound, argumentType, argumentReference, substitutor, typeAliasUsageElement, diagnosticsReporter) - } - } - protected fun checkBound( bound: KotlinType, argumentType: KotlinType, @@ -99,18 +104,17 @@ open class UpperBoundChecker(val languageVersionSettings: LanguageVersionSetting } class UpperBoundViolatedReporter( - val trace: BindingTrace, - val argumentType: KotlinType, - val typeParameterDescriptor: TypeParameterDescriptor? = null, - val baseDiagnostic: DiagnosticFactory2 = UPPER_BOUND_VIOLATED, - val diagnosticForTypeAliases: DiagnosticFactory3 = UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION + private val trace: BindingTrace, + private val argumentType: KotlinType, + private val typeParameterDescriptor: TypeParameterDescriptor, + private val baseDiagnostic: DiagnosticFactory2 = UPPER_BOUND_VIOLATED, + private val diagnosticForTypeAliases: DiagnosticFactory3 = UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION ) { fun report(typeArgumentReference: KtTypeReference, substitutedBound: KotlinType) { - trace.report(baseDiagnostic.on(typeArgumentReference, substitutedBound, argumentType)) + trace.reportDiagnosticOnce(baseDiagnostic.on(typeArgumentReference, substitutedBound, argumentType)) } fun reportForTypeAliasExpansion(callElement: KtElement, substitutedBound: KotlinType) { - if (typeParameterDescriptor == null) return - trace.report(diagnosticForTypeAliases.on(callElement, substitutedBound, argumentType, typeParameterDescriptor)) + trace.reportDiagnosticOnce(diagnosticForTypeAliases.on(callElement, substitutedBound, argumentType, typeParameterDescriptor)) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index ad0373ae391..7398559c52d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -15,8 +15,6 @@ import org.jetbrains.kotlin.diagnostics.reportDiagnosticOnce import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.isNull import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.UpperBoundChecker -import org.jetbrains.kotlin.resolve.UpperBoundViolatedReporter import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.callUtil.reportTrailingLambdaErrorOr @@ -395,8 +393,8 @@ class DiagnosticReporterByTrackingStrategy( } (position as? ExplicitTypeParameterConstraintPositionImpl)?.let { - UpperBoundViolatedReporter(trace, error.upperKotlinType) - .report((it.typeArgument as SimpleTypeArgumentImpl).typeReference, error.lowerKotlinType) + val typeArgumentReference = (it.typeArgument as SimpleTypeArgumentImpl).typeReference + trace.report(UPPER_BOUND_VIOLATED.on(typeArgumentReference, error.upperKotlinType, error.lowerKotlinType)) } (position as? FixVariableConstraintPositionImpl)?.let { diff --git a/compiler/testData/diagnostics/tests/typealias/boundViolationInTypeAliasConstructor.kt b/compiler/testData/diagnostics/tests/typealias/boundViolationInTypeAliasConstructor.kt index ac96526df5b..9e236b31464 100644 --- a/compiler/testData/diagnostics/tests/typealias/boundViolationInTypeAliasConstructor.kt +++ b/compiler/testData/diagnostics/tests/typealias/boundViolationInTypeAliasConstructor.kt @@ -13,6 +13,6 @@ class TColl> typealias TC = TColl typealias TC2 = TC -val y1 = TCollAny>() -val y2 = TCAny>() -val y3 = TC2Any>() +val y1 = TCollAny>() +val y2 = TCAny>() +val y3 = TC2Any>() diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.fir.kt index 7f8a87e86f3..b09e808a9d6 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.fir.kt @@ -1,8 +1,18 @@ -// !WITH_NEW_INFERENCE -// NI_EXPECTED_FILE +// FULL_JDK +// FILE: MapLike.java +import java.util.Map; + +public class MapLike<@org.jetbrains.annotations.NotNull K> { + MapLike(K x) { } +} + +// FILE: main.kt class Cons(val head: T, val tail: Cons?) typealias C = Cons +typealias C2 = MapLike val test1 = C(1, C(2, null)) val test2 = C(1, C("", null)) +val test23 = C2(if (true) 1 else null) +val test234 = C2(C2(if (true) 1 else null)) diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.kt index 75f5863535f..79691b4f1bd 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.kt @@ -1,8 +1,18 @@ -// !WITH_NEW_INFERENCE -// NI_EXPECTED_FILE +// FULL_JDK +// FILE: MapLike.java +import java.util.Map; + +public class MapLike<@org.jetbrains.annotations.NotNull K> { + MapLike(K x) { } +} + +// FILE: main.kt class Cons(val head: T, val tail: Cons?) typealias C = Cons +typealias C2 = MapLike val test1 = C(1, C(2, null)) -val test2 = C(1, C("", null)) +val test2 = C(1, C("", null)) +val test23 = C2(if (true) 1 else null) +val test234 = C2(C2(if (true) 1 else null)) diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.ni.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.ni.txt deleted file mode 100644 index e22126a7d77..00000000000 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.ni.txt +++ /dev/null @@ -1,14 +0,0 @@ -package - -public val test1: C /* = Cons */ -public val test2: Cons - -public final class Cons { - public constructor Cons(/*0*/ head: T, /*1*/ tail: Cons?) - public final val head: T - public final val tail: Cons? - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} -public typealias C = Cons diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt index 10d357efcdc..24c31fabc9b 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.txt @@ -1,7 +1,9 @@ package public val test1: C /* = Cons */ -public val test2: C /* = Cons */ +public val test2: Cons +public val test23: C2 /* = MapLike */ +public val test234: C2<(C2 /* = MapLike */..C2? /* = MapLike? */)> /* = MapLike<(C2 /* = MapLike */..C2? /* = MapLike? */)> */ public final class Cons { public constructor Cons(/*0*/ head: T, /*1*/ tail: Cons?) @@ -11,4 +13,13 @@ public final class Cons { public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } + +public open class MapLike { + public/*package*/ constructor MapLike(/*0*/ x: K!) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} public typealias C = Cons +public typealias C2 = MapLike + diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt index c74590f7a23..13b6e46077b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.fir.kt @@ -14,11 +14,11 @@ import java.util.Collection; public class ListLike> {} // FILE: main.kt -fun test0(map : MapLike<Int?, Int>) {} -fun test11(map : MapLike<K, K>) {} -fun test12(map : MapLike<K?, K>) {} +fun test0(map : MapLike) {} +fun test11(map : MapLike) {} +fun test12(map : MapLike) {} fun test13(map : MapLike) {} -fun test14(map : MapLike<K?, K>) {} +fun test14(map : MapLike) {} class Foo @@ -26,11 +26,11 @@ typealias A = MapLike typealias A2 = Foo> typealias A3 = ListLike> -fun main1(x: A<Int?>) {} -fun main2(x: A2<Int?>) {} -fun main3(x: A3) {} +fun main1(x: A) {} +fun main2(x: A2) {} +fun main3(x: A3) {} fun main3() { val x = A3() // TODO: support reporting errors on typealias constructor calls val x2 = A() // TODO: support reporting errors on typealias constructor calls - val y: A3 = A3() + val y: A3 = A3() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt index c74590f7a23..556657578d8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBounds.kt @@ -30,7 +30,7 @@ fun main1(x: A<Int?>) {} fun main2(x: A2<Int?>) {} fun main3(x: A3) {} fun main3() { - val x = A3() // TODO: support reporting errors on typealias constructor calls - val x2 = A() // TODO: support reporting errors on typealias constructor calls - val y: A3 = A3() + val x = A3() // TODO: support reporting errors on typealias constructor calls + val x2 = A() // TODO: support reporting errors on typealias constructor calls + val y: A3 = A3() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt index a64a67bac51..bfc6b0c7b4d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/checkEnhancedUpperBoundsWithEnabledImprovements.fir.kt @@ -15,11 +15,11 @@ import java.util.Collection; public class ListLike> {} // FILE: main.kt -fun test0(map : MapLike<Int?, Int>) {} -fun test11(map : MapLike<K, K>) {} -fun test12(map : MapLike<K?, K>) {} +fun test0(map : MapLike) {} +fun test11(map : MapLike) {} +fun test12(map : MapLike) {} fun test13(map : MapLike) {} -fun test14(map : MapLike<K?, K>) {} +fun test14(map : MapLike) {} class Foo @@ -27,11 +27,11 @@ typealias A = MapLike typealias A2 = Foo> typealias A3 = ListLike> -fun main1(x: A<Int?>) {} -fun main2(x: A2<Int?>) {} -fun main3(x: A3) {} +fun main1(x: A) {} +fun main2(x: A2) {} +fun main3(x: A3) {} fun main3() { val x = A3() // TODO: support reporting errors on typealias constructor calls val x2 = A() - val y: A3 = A3() + val y: A3 = A3() } diff --git a/compiler/testData/foreignAnnotations/java8Tests/typeEnhancementOnCompiledJava/ClassTypeParameterBoundWithWarnings.kt b/compiler/testData/foreignAnnotations/java8Tests/typeEnhancementOnCompiledJava/ClassTypeParameterBoundWithWarnings.kt index 29f07a9f8e4..184846a4b67 100644 --- a/compiler/testData/foreignAnnotations/java8Tests/typeEnhancementOnCompiledJava/ClassTypeParameterBoundWithWarnings.kt +++ b/compiler/testData/foreignAnnotations/java8Tests/typeEnhancementOnCompiledJava/ClassTypeParameterBoundWithWarnings.kt @@ -3,13 +3,13 @@ // SKIP_TXT // TODO: report warnings "UPPER_BOUND_VIOLATED" -fun main(x: ClassTypeParameterBoundWithWarnings, y: ClassTypeParameterBoundWithWarnings, a: String?, b: String) { +fun main(x: ClassTypeParameterBoundWithWarnings<String?>, y: ClassTypeParameterBoundWithWarnings, a: String?, b: String) { val x2 = ClassTypeParameterBoundWithWarnings() val y2 = ClassTypeParameterBoundWithWarnings() val x3 = ClassTypeParameterBoundWithWarnings(a) val y3 = ClassTypeParameterBoundWithWarnings(b) - val x4: ClassTypeParameterBoundWithWarnings = ClassTypeParameterBoundWithWarnings() + val x4: ClassTypeParameterBoundWithWarnings<String?> = ClassTypeParameterBoundWithWarnings() val y4: ClassTypeParameterBoundWithWarnings = ClassTypeParameterBoundWithWarnings() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt index b5f179ad799..ca53bc49873 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt @@ -88,7 +88,7 @@ fun KotlinType.getEnhancement(): KotlinType? = when (this) { else -> null } -private fun List.enhanceTypeArguments(depth: Int) = +private fun List.enhanceTypeArguments() = map { argument -> // TODO: think about star projections with enhancement (e.g. came from Java: Foo<@NotNull ?>) if (argument.isStarProjection) { @@ -96,15 +96,34 @@ private fun List.enhanceTypeArguments(depth: Int) = } val argumentType = argument.type val enhancedArgumentType = if (argumentType is TypeWithEnhancement) argumentType.enhancement else argumentType - val enhancedDeeplyArgumentType = enhancedArgumentType.getEnhancementDeeply(depth + 1) + val enhancedDeeplyArgumentType = enhancedArgumentType.getEnhancementDeeplyInternal() + + if (argumentType === enhancedDeeplyArgumentType) return@map argument argument.replaceType(enhancedDeeplyArgumentType) } -private fun KotlinType.getEnhancementDeeply(depth: Int): KotlinType { - val newArguments = arguments.enhanceTypeArguments(depth) - val newArgumentsForUpperBound = if (this is FlexibleType) upperBound.arguments.enhanceTypeArguments(depth) else newArguments +private fun List.wereTypeArgumentsChanged(newArguments: List) = + newArguments.size != this.size || !this.withIndex().all { (i, arg) -> newArguments[i] === arg } + +private fun KotlinType.wereTypeArgumentsChanged(newArguments: List, newArgumentsForUpperBound: List) = + when (val type = unwrap()) { + is FlexibleType -> { + type.lowerBound.arguments.wereTypeArgumentsChanged(newArguments) || + type.upperBound.arguments.wereTypeArgumentsChanged(newArgumentsForUpperBound) + } + else -> { + type.arguments.wereTypeArgumentsChanged(newArguments) + } + } + +private fun KotlinType.getEnhancementDeeplyInternal(): KotlinType { + val newArguments = arguments.enhanceTypeArguments() + val newArgumentsForUpperBound = if (this is FlexibleType) upperBound.arguments.enhanceTypeArguments() else newArguments val enhancedType = if (this is TypeWithEnhancement) enhancement else this + val areArgumentsChanged = enhancedType.wereTypeArgumentsChanged(newArguments, newArgumentsForUpperBound) + + if (!areArgumentsChanged) return enhancedType return enhancedType.replace( newArguments = newArguments, @@ -113,7 +132,7 @@ private fun KotlinType.getEnhancementDeeply(depth: Int): KotlinType { } fun KotlinType.getEnhancementDeeply(): KotlinType? { - val enhancedTypeWithArguments = getEnhancementDeeply(depth = 0) + val enhancedTypeWithArguments = getEnhancementDeeplyInternal() if (enhancedTypeWithArguments === this) return null diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CompositeResolverForModuleFactory.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CompositeResolverForModuleFactory.kt index 3a3d7cefa66..80534bfa3fd 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CompositeResolverForModuleFactory.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/caches/resolve/CompositeResolverForModuleFactory.kt @@ -224,7 +224,7 @@ class CompositeResolverForModuleFactory( } class CompositeAnalyzerServices(val services: List) : PlatformDependentAnalyzerServices() { - override val platformConfigurator: PlatformConfigurator = CompositePlatformConigurator(services.map { it.platformConfigurator }) + override val platformConfigurator: PlatformConfigurator = CompositePlatformConfigurator(services.map { it.platformConfigurator }) override fun computePlatformSpecificDefaultImports(storageManager: StorageManager, result: MutableList) { val intersectionOfDefaultImports = services.map { service -> @@ -247,7 +247,7 @@ class CompositeAnalyzerServices(val services: List first.intersect(second) }.toList() } -class CompositePlatformConigurator(private val componentConfigurators: List) : PlatformConfigurator { +class CompositePlatformConfigurator(private val componentConfigurators: List) : PlatformConfigurator { override val platformSpecificContainer: StorageComponentContainer get() = composeContainer(this::class.java.simpleName) { configureDefaultCheckers() @@ -256,8 +256,8 @@ class CompositePlatformConigurator(private val componentConfigurators: List() - container.useImpl() } } \ No newline at end of file diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/JsPlatformConfigurator.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/JsPlatformConfigurator.kt index f7097f5a3c3..5cbd2b9d11e 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/JsPlatformConfigurator.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/JsPlatformConfigurator.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.js.resolve +import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.container.StorageComponentContainer import org.jetbrains.kotlin.container.useImpl import org.jetbrains.kotlin.container.useInstance @@ -34,7 +35,7 @@ object JsPlatformConfigurator : PlatformConfiguratorBase( ), identifierChecker = JsIdentifierChecker ) { - override fun configureModuleComponents(container: StorageComponentContainer) { + override fun configureModuleComponents(container: StorageComponentContainer, languageVersionSettings: LanguageVersionSettings) { container.useInstance(NameSuggestion()) container.useImpl() container.useImpl() diff --git a/native/frontend/src/org/jetbrains/kotlin/resolve/konan/platform/NativePlatformConfigurator.kt b/native/frontend/src/org/jetbrains/kotlin/resolve/konan/platform/NativePlatformConfigurator.kt index 35a53f10e57..04eb768078f 100644 --- a/native/frontend/src/org/jetbrains/kotlin/resolve/konan/platform/NativePlatformConfigurator.kt +++ b/native/frontend/src/org/jetbrains/kotlin/resolve/konan/platform/NativePlatformConfigurator.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.resolve.konan.platform +import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.container.StorageComponentContainer import org.jetbrains.kotlin.container.useImpl import org.jetbrains.kotlin.container.useInstance @@ -30,7 +31,7 @@ object NativePlatformConfigurator : PlatformConfiguratorBase( NativeTopLevelSingletonChecker, NativeThreadLocalChecker ) ) { - override fun configureModuleComponents(container: StorageComponentContainer) { + override fun configureModuleComponents(container: StorageComponentContainer, languageVersionSettings: LanguageVersionSettings) { container.useInstance(NativeInliningRule) } From c158c64ee00f86529092f953ccc03e124ca59fb2 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Thu, 4 Feb 2021 12:11:03 +0300 Subject: [PATCH 128/368] Reformat TypeWithEnhancement.kt --- .../kotlin/types/TypeWithEnhancement.kt | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt index ca53bc49873..36a32961d0a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeWithEnhancement.kt @@ -28,18 +28,18 @@ interface TypeWithEnhancement { } class SimpleTypeWithEnhancement( - override val delegate: SimpleType, - override val enhancement: KotlinType + override val delegate: SimpleType, + override val enhancement: KotlinType ) : DelegatingSimpleType(), TypeWithEnhancement { override val origin: UnwrappedType get() = delegate - override fun replaceAnnotations(newAnnotations: Annotations): SimpleType - = origin.replaceAnnotations(newAnnotations).wrapEnhancement(enhancement) as SimpleType + override fun replaceAnnotations(newAnnotations: Annotations): SimpleType = + origin.replaceAnnotations(newAnnotations).wrapEnhancement(enhancement) as SimpleType - override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType - = origin.makeNullableAsSpecified(newNullability).wrapEnhancement(enhancement.unwrap().makeNullableAsSpecified(newNullability)) as SimpleType + override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType = origin.makeNullableAsSpecified(newNullability) + .wrapEnhancement(enhancement.unwrap().makeNullableAsSpecified(newNullability)) as SimpleType @TypeRefinement override fun replaceDelegate(delegate: SimpleType) = SimpleTypeWithEnhancement(delegate, enhancement) @@ -47,23 +47,23 @@ class SimpleTypeWithEnhancement( @TypeRefinement @OptIn(TypeRefinement::class) override fun refine(kotlinTypeRefiner: KotlinTypeRefiner): SimpleTypeWithEnhancement = - SimpleTypeWithEnhancement( - kotlinTypeRefiner.refineType(delegate) as SimpleType, - kotlinTypeRefiner.refineType(enhancement) - ) + SimpleTypeWithEnhancement( + kotlinTypeRefiner.refineType(delegate) as SimpleType, + kotlinTypeRefiner.refineType(enhancement) + ) } class FlexibleTypeWithEnhancement( - override val origin: FlexibleType, - override val enhancement: KotlinType + override val origin: FlexibleType, + override val enhancement: KotlinType ) : FlexibleType(origin.lowerBound, origin.upperBound), TypeWithEnhancement { - override fun replaceAnnotations(newAnnotations: Annotations): UnwrappedType - = origin.replaceAnnotations(newAnnotations).wrapEnhancement(enhancement) + override fun replaceAnnotations(newAnnotations: Annotations): UnwrappedType = + origin.replaceAnnotations(newAnnotations).wrapEnhancement(enhancement) - override fun makeNullableAsSpecified(newNullability: Boolean): UnwrappedType - = origin.makeNullableAsSpecified(newNullability).wrapEnhancement(enhancement.unwrap().makeNullableAsSpecified(newNullability)) + override fun makeNullableAsSpecified(newNullability: Boolean): UnwrappedType = + origin.makeNullableAsSpecified(newNullability).wrapEnhancement(enhancement.unwrap().makeNullableAsSpecified(newNullability)) override fun render(renderer: DescriptorRenderer, options: DescriptorRendererOptions): String { if (options.enhancedTypes) { From 8acf3b1d7650b53dca8ad5b7fcdcb274cd29ee87 Mon Sep 17 00:00:00 2001 From: Yaroslav Chernyshev Date: Mon, 8 Feb 2021 16:35:16 +0300 Subject: [PATCH 129/368] [Cocoapods] Fail import if project's version wasn't specified #Fixed KT-44000 --- .../kotlin/gradle/native/CocoaPodsIT.kt | 16 ++++++++++++++++ .../native/cocoapods/CocoapodsExtension.kt | 10 +++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/CocoaPodsIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/CocoaPodsIT.kt index 22eb9cf3fea..cc6dbabdb3c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/CocoaPodsIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/CocoaPodsIT.kt @@ -309,6 +309,22 @@ class CocoaPodsIT : BaseGradleIT() { project.test(":kotlin-library:podDownload") } + @Test + fun errorIfVersionIsNotSpecified() { + with(project.gradleBuildScript()) { + useLines { lines -> + lines.filter { line -> "version = \"1.0\"" !in line }.joinToString(separator = "\n") + }.also { writeText(it) } + } + hooks.addHook { + assertContains("Cocoapods Integration requires version of this project to be specified.") + } + + project.build(POD_IMPORT_TASK_NAME, "-Pkotlin.native.cocoapods.generate.wrapper=true") { + assertFailed() + hooks.trigger(this) + } + } // up-to-date tests diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt index 00639d9740d..625ded6c061 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/cocoapods/CocoapodsExtension.kt @@ -19,7 +19,15 @@ import java.net.URI open class CocoapodsExtension(private val project: Project) { @get:Input val version: String - get() = project.version.toString() + get() { + require(project.version != Project.DEFAULT_VERSION) { """ + Cocoapods Integration requires version of this project to be specified. + Please, add line 'version = ""' to project's build file. + For more details, please, see https://guides.cocoapods.org/syntax/podspec.html#version + """.trimIndent() + } + return project.version.toString() + } /** * Configure authors of the pod built from this project. From c0759f96e931faae9b2d79de4b37be03fe37a1ae Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Mon, 15 Feb 2021 12:56:05 +0300 Subject: [PATCH 130/368] Fix FIR test `lambdaParameterTypeInElvis` --- .../inference/lambdaParameterTypeInElvis.fir.kt | 14 ++++++++++++++ .../tests/inference/lambdaParameterTypeInElvis.kt | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt diff --git a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt new file mode 100644 index 00000000000..08cdc63c5a2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt @@ -0,0 +1,14 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNREACHABLE_CODE + +interface Some { + fun method(): Unit +} + +fun elvis(nullable: S?, notNullable: S): S = TODO() + +fun Some.doWithPredicate(predicate: (R) -> Unit): R? = TODO() + +fun test(derived: Some) { + val expected: Some = derived.doWithPredicate { it.method() } ?: TODO() + val expected2: Some = elvis(derived.doWithPredicate { it.method() }, TODO()) +} diff --git a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt index 5f15c280fb4..1c4ce614a63 100644 --- a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt +++ b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNREACHABLE_CODE interface Some { From f4937665630e71ddff90a864cd69a98a3c65df4d Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Thu, 11 Feb 2021 13:46:33 +0100 Subject: [PATCH 131/368] Add IR tests to Android codegen test --- .../android-tests/android-module/build.gradle | 26 ++++--- .../tests/CodegenTestsOnAndroidGenerator.kt | 70 ++++++++++++------- .../tests/CodegenTestsOnAndroidRunner.kt | 34 ++++----- .../android/tests/gradle/GradleRunner.java | 4 +- .../jetbrains/kotlin/test/TargetBackend.kt | 1 + .../typeAnnotations/methodParameters.kt | 1 - .../invokedynamic/lambdas/lambdaToSting.kt | 5 +- 7 files changed, 84 insertions(+), 57 deletions(-) diff --git a/compiler/android-tests/android-module/build.gradle b/compiler/android-tests/android-module/build.gradle index 8536a0ca0b6..b5268a4822f 100644 --- a/compiler/android-tests/android-module/build.gradle +++ b/compiler/android-tests/android-module/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.1' + classpath 'com.android.tools.build:gradle:4.1.2' } } apply plugin: 'com.android.application' @@ -37,14 +37,6 @@ android { packagingOptions { exclude 'META-INF/build.txt' } - //TODO run under java 6, cause there is error on implicit 'stream' import in 'asWithMutable' test - lintOptions { - abortOnError false - } - - compileOptions { - incremental = false - } dexOptions { dexInProcess false @@ -80,6 +72,22 @@ android { reflect0 { dimension "box" } + + common_ir0 { + dimension "box" + } + + common_ir1 { + dimension "box" + } + + common_ir2 { + dimension "box" + } + + reflect_ir0 { + dimension "box" + } } } diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt index 48b9c7d1d21..28053f61c0f 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidGenerator.kt @@ -12,7 +12,6 @@ import com.intellij.openapi.util.io.FileUtilRt import org.jetbrains.kotlin.cli.common.output.writeAllTo import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.codegen.CodegenTestCase import org.jetbrains.kotlin.codegen.CodegenTestFiles import org.jetbrains.kotlin.codegen.GenerationUtils import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime @@ -22,8 +21,6 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.test.* import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder -import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives -import org.jetbrains.kotlin.test.directives.model.singleOrZeroValue import org.jetbrains.kotlin.test.model.DependencyKind import org.jetbrains.kotlin.test.model.FrontendKinds import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest @@ -57,15 +54,18 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager //keep it globally to avoid test grouping on TC private val generatedTestNames = hashSetOf() - private val COMMON = FlavorConfig("common", 3) - private val REFLECT = FlavorConfig("reflect", 1) + private val COMMON = FlavorConfig(TargetBackend.ANDROID,"common", 3) + private val REFLECT = FlavorConfig(TargetBackend.ANDROID, "reflect", 1) - class FlavorConfig(private val prefix: String, val limit: Int) { + private val COMMON_IR = FlavorConfig(TargetBackend.ANDROID_IR, "common_ir", 3) + private val REFLECT_IR = FlavorConfig(TargetBackend.ANDROID_IR,"reflect_ir", 1) + + class FlavorConfig(private val backend: TargetBackend, private val prefix: String, val limit: Int) { private var writtenFilesCount = 0 fun printStatistics() { - println("FlavorTestCompiler: $prefix, generated file count: $writtenFilesCount") + println("FlavorTestCompiler for $backend: $prefix, generated file count: $writtenFilesCount") } fun getFlavorForNewFiles(newFilesCount: Int): String { @@ -148,25 +148,47 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager private fun generateTestsAndFlavourSuites() { println("Generating test files...") - generateTestMethodsForDirectories(File("compiler/testData/codegen/box"), File("compiler/testData/codegen/boxInline")) + val folders = arrayOf( + File("compiler/testData/codegen/box"), + File("compiler/testData/codegen/boxInline") + ) + + generateTestMethodsForDirectories( + TargetBackend.ANDROID, + COMMON, + REFLECT, + *folders + ) + + generateTestMethodsForDirectories( + TargetBackend.ANDROID_IR, + COMMON_IR, + REFLECT_IR, + *folders + ) pendingUnitTestGenerators.values.forEach { it.generate() } } - private fun generateTestMethodsForDirectories(vararg dirs: File) { + private fun generateTestMethodsForDirectories( + backend: TargetBackend, + commonFlavor: FlavorConfig, + reflectionFlavor: FlavorConfig, + vararg dirs: File + ) { val holders = mutableMapOf() for (dir in dirs) { val files = dir.listFiles() ?: error("Folder with testData is empty: ${dir.absolutePath}") - processFiles(files, holders) + processFiles(files, holders, backend, commonFlavor, reflectionFlavor) } holders.values.forEach { it.writeFilesOnDisk() } - COMMON.printStatistics() - REFLECT.printStatistics() + commonFlavor.printStatistics() + reflectionFlavor.printStatistics() } internal inner class FilesWriter( @@ -254,7 +276,10 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager @Throws(IOException::class) private fun processFiles( files: Array, - holders: MutableMap + holders: MutableMap, + backend: TargetBackend, + commmonFlavor: FlavorConfig, + reflectionFlavor: FlavorConfig ) { holders.values.forEach { it.writeFilesOnDiskIfNeeded() @@ -264,7 +289,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager if (file.isDirectory) { val listFiles = file.listFiles() if (listFiles != null) { - processFiles(listFiles, holders) + processFiles(listFiles, holders, backend, commmonFlavor, reflectionFlavor) } } else if (FileUtilRt.getExtension(file.name) != KotlinFileType.EXTENSION) { // skip non kotlin files @@ -273,7 +298,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager continue } - if (!InTextDirectivesUtils.isPassingTarget(TargetBackend.JVM, file) || + if (!InTextDirectivesUtils.isPassingTarget(backend.compatibleWith, file) || InTextDirectivesUtils.isIgnoredTarget(TargetBackend.ANDROID, file) ) { continue @@ -304,7 +329,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager if (fullFileText.contains("// SKIP_JDK6")) continue if (hasBoxMethod(fullFileText)) { - val testConfiguration = createTestConfiguration(file) + val testConfiguration = createTestConfiguration(file, backend) val services = testConfiguration.testServices val moduleStructure = try { @@ -335,7 +360,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager keyConfiguration.languageVersionSettings = module.languageVersionSettings val key = ConfigurationKey(kind, jdkKind, keyConfiguration.toString()) - val compiler = if (kind.withReflection) REFLECT else COMMON + val compiler = if (kind.withReflection) reflectionFlavor else commmonFlavor val compilerConfigurationProvider = services.compilerConfigurationProvider as CompilerConfigurationProviderImpl val filesHolder = holders.getOrPut(key) { FilesWriter(compiler, compilerConfigurationProvider.createCompilerConfiguration(module)).also { @@ -349,9 +374,9 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager } } - private fun createTestConfiguration(testDataFile: File): TestConfiguration { + private fun createTestConfiguration(testDataFile: File, backend: TargetBackend): TestConfiguration { return TestConfigurationBuilder().apply { - testConfiguration() + configure(backend) testInfo = KotlinTestInfo( "org.jetbrains.kotlin.android.tests.AndroidRunner", "test${testDataFile.nameWithoutExtension.capitalize()}", @@ -360,10 +385,10 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager }.build(testDataFile.path) } - private val testConfiguration: TestConfigurationBuilder.() -> Unit = { + private fun TestConfigurationBuilder.configure(backend: TargetBackend) { globalDefaults { frontend = FrontendKinds.ClassicFrontend - targetBackend = TargetBackend.ANDROID + targetBackend = backend targetPlatform = JvmPlatforms.defaultJvmPlatform dependencyKind = DependencyKind.Binary } @@ -386,9 +411,6 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager useDirectives(*AbstractKotlinCompilerTest.defaultDirectiveContainers.toTypedArray()) } - private fun createTestFiles(file: File, expectedText: String): List = - CodegenTestCase.createTestFilesFromFile(file, expectedText, false, TargetBackend.JVM) - companion object { const val GRADLE_VERSION = "6.8.1" // update GRADLE_SHA_256 on change const val GRADLE_SHA_256 = "fd591a34af7385730970399f473afabdb8b28d57fd97d6625c388d090039d6fd" diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidRunner.kt b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidRunner.kt index b435d38066d..14562eb8d51 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidRunner.kt +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/CodegenTestsOnAndroidRunner.kt @@ -71,15 +71,20 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P return rootSuite } - private fun processReport(suite: TestSuite, resultOutput: String) { + private fun processReport(rootSuite: TestSuite, resultOutput: String) { val reportFolder = File(flavorFolder()) try { val folders = reportFolder.listFiles() assertTrue(folders != null && folders.isNotEmpty(), "No folders in ${reportFolder.path}") + folders.forEach { assertTrue("${it.path} is not directory") { it.isDirectory } + val isIr = it.name.contains("_ir") val testCases = parseSingleReportInFolder(it) - testCases.forEach { aCase -> suite.addTest(aCase) } + testCases.forEach { aCase -> + if (isIr) aCase.name += "_ir" + rootSuite.addTest(aCase) + } Assert.assertNotEquals("There is no test results in report", 0, testCases.size.toLong()) } } catch (e: Throwable) { @@ -87,10 +92,6 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P } } - private fun renameFlavorFolder() { - val reportFolder = File(flavorFolder()) - reportFolder.renameTo(File(reportFolder.parentFile, reportFolder.name + "_d8")) - } private fun flavorFolder() = pathManager.tmpFolder + "/build/test/results/connected/flavors" @@ -119,7 +120,7 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P private fun cleanAndBuildProject(gradleRunner: GradleRunner) { gradleRunner.clean() - gradleRunner.build() + gradleRunner.assembleAndroidTest() } @Throws(IOException::class, SAXException::class, ParserConfigurationException::class) @@ -138,21 +139,14 @@ class CodegenTestsOnAndroidRunner private constructor(private val pathManager: P return (0 until testCases.length).map { i -> val item = testCases.item(i) as Element - val failure = item.getElementsByTagName("failure") + val failure = item.getElementsByTagName("failure").takeIf { it.length != 0 }?.item(0) val name = item.getAttribute("name") - if (failure.length == 0) { - object : TestCase(name) { - @Throws(Throwable::class) - override fun runTest() { - - } - } - } else { - object : TestCase(name) { - @Throws(Throwable::class) - override fun runTest() { - Assert.fail(failure.item(0).textContent) + object : TestCase(name) { + @Throws(Throwable::class) + override fun runTest() { + if (failure != null) { + Assert.fail(failure.textContent) } } } diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/gradle/GradleRunner.java b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/gradle/GradleRunner.java index 268f923c5fa..e7739257418 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/gradle/GradleRunner.java +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/gradle/GradleRunner.java @@ -45,9 +45,9 @@ public class GradleRunner { OutputUtils.checkResult(result); } - public void build() { + public void assembleAndroidTest() { System.out.println("Building gradle project..."); - GeneralCommandLine build = generateCommandLine("build"); + GeneralCommandLine build = generateCommandLine("assembleAndroidTest"); build.addParameter("--stacktrace"); build.addParameter("--warn"); RunResult result = RunUtils.execute(build); diff --git a/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/test/TargetBackend.kt b/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/test/TargetBackend.kt index 9f512cc6f6b..0944ebc6542 100644 --- a/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/test/TargetBackend.kt +++ b/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/test/TargetBackend.kt @@ -20,6 +20,7 @@ enum class TargetBackend( JS_IR_ES6(true, JS_IR), WASM(true), ANDROID(false, JVM), + ANDROID_IR(true, JVM_IR), NATIVE(true); val compatibleWith get() = compatibleWithTargetBackend ?: ANY diff --git a/compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt b/compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt index 04a4d9a1cb5..036757a07e3 100644 --- a/compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt +++ b/compiler/testData/codegen/box/annotations/typeAnnotations/methodParameters.kt @@ -1,6 +1,5 @@ // EMIT_JVM_TYPE_ANNOTATIONS // TARGET_BACKEND: JVM -// IGNORE_BACKEND: ANDROID // JVM_TARGET: 1.8 // WITH_REFLECT // FULL_JDK diff --git a/compiler/testData/codegen/box/invokedynamic/lambdas/lambdaToSting.kt b/compiler/testData/codegen/box/invokedynamic/lambdas/lambdaToSting.kt index 66b3bcd5941..80bfbb72ea5 100644 --- a/compiler/testData/codegen/box/invokedynamic/lambdas/lambdaToSting.kt +++ b/compiler/testData/codegen/box/invokedynamic/lambdas/lambdaToSting.kt @@ -4,11 +4,14 @@ // LAMBDAS: INDY // WITH_RUNTIME +// desugaring on Android +// IGNORE_BACKEND: ANDROID + fun lambdaToString(fn: () -> Unit) = fn.toString() fun box(): String { val str = lambdaToString {} if (!str.startsWith("LambdaToStingKt")) - return "Failed: indy lambda toString is inherited from java.lang.Object" + return "Failed: indy lambda toString is inherited from java.lang.Object: $str" return "OK" } \ No newline at end of file From 6ff5704ef96046750a1c933eb5c798217a7dfd8f Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Mon, 15 Feb 2021 10:37:39 +0100 Subject: [PATCH 132/368] Delete obsolete test --- .../tests/AndroidJpsBuildTestCase.java | 62 ------------------- .../tests/AndroidJpsBuildTestCase.java.as41 | 0 .../tests/AndroidJpsBuildTestCase.java.as42 | 0 .../kotlin/android/tests/AndroidRunner.java | 8 +-- 4 files changed, 2 insertions(+), 68 deletions(-) delete mode 100644 compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java delete mode 100644 compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java.as41 delete mode 100644 compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java.as42 diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java deleted file mode 100644 index 60d860a9909..00000000000 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.android.tests; - -import org.jetbrains.kotlin.jps.build.BaseKotlinJpsBuildTestCase; -import org.junit.Ignore; - -import java.io.File; -import java.io.IOException; - -@Ignore -public class AndroidJpsBuildTestCase extends BaseKotlinJpsBuildTestCase { - private static final String PROJECT_NAME = "android-module"; - private static final String SDK_NAME = "Android_SDK"; - - private final File workDir = new File(AndroidRunner.getPathManager().getTmpFolder()); - - public void doTest() { - initProject(); - rebuildAllModules(); - buildAllModules().assertSuccessful(); - } - - @Override - protected String getProjectName() { - return "android-module"; - } - - @Override - protected void runTest() { - doTest(); - } - - @Override - public String getName() { - return "AndroidJpsTest"; - } - - @Override - protected File doGetProjectDir() throws IOException { - return workDir; - } - - private void initProject() { - addJdk(SDK_NAME, AndroidRunner.getPathManager().getPlatformFolderInAndroidSdk() + "/android.jar"); - loadProject(workDir.getAbsolutePath() + File.separator + PROJECT_NAME + ".ipr"); - } -} diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java.as41 b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java.as41 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java.as42 b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidJpsBuildTestCase.java.as42 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidRunner.java b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidRunner.java index a95405af339..7e7772988fb 100644 --- a/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidRunner.java +++ b/compiler/android-tests/tests/org/jetbrains/kotlin/android/tests/AndroidRunner.java @@ -46,12 +46,8 @@ public class AndroidRunner { CodegenTestsOnAndroidGenerator.generate(pathManager); - System.out.println("Run tests on android..."); - TestSuite suite = CodegenTestsOnAndroidRunner.runTestsInEmulator(pathManager); - //AndroidJpsBuildTestCase indirectly depends on UsefulTestCase which compiled against java 8 - //TODO: Need add separate run configuration for AndroidJpsBuildTestCase - //suite.addTest(new AndroidJpsBuildTestCase()); - return suite; + System.out.println("Run tests on Android..."); + return CodegenTestsOnAndroidRunner.runTestsInEmulator(pathManager); } public void tearDown() throws Exception { From 7f8f1dc4f8200f7a7af4fa31c6b17c8ecb87311f Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Fri, 12 Feb 2021 12:20:09 +0300 Subject: [PATCH 133/368] [Commonizer] Calculate hash code by pure name in approximation keys --- .../descriptors/commonizer/mergedtree/approximationKeys.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/approximationKeys.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/approximationKeys.kt index 2dff588cb1d..93249d1a8ac 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/approximationKeys.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/approximationKeys.kt @@ -84,5 +84,5 @@ private fun additionalValueParameterNamesHash(callable: FunctionDescriptor): Int if (callable.annotations.none { it.isObjCInteropCallableAnnotation }) return 0 // do not calculate hash for non-ObjC callables - return callable.valueParameters.fold(0) { acc, next -> acc.appendHashCode(next.name) } + return callable.valueParameters.fold(0) { acc, next -> acc.appendHashCode(next.name.asString()) } } From 8a17de38d0eec79c73a802b05920833e81147338 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Fri, 12 Feb 2021 15:01:30 +0300 Subject: [PATCH 134/368] [Commonizer] Fix integration tests: serialize only own module contents --- .../jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt index 24cb7675972..d689e0cc49b 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt @@ -190,7 +190,9 @@ internal class MockModulesProvider private constructor( languageVersionSettings = LanguageVersionSettingsImpl.DEFAULT, metadataVersion = KlibMetadataVersion.INSTANCE, skipExpects = false, - project = null + project = null, + includeOnlyModuleContent = true, + allowErrorTypes = false ) } } From 90cdb9203fbe5fcfd0e410aa5798a84bab2600de Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Fri, 12 Feb 2021 15:16:04 +0300 Subject: [PATCH 135/368] [Commonizer] Fix integration tests: wrong mismatches filter --- .../commonizer/utils/assertions.kt | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/assertions.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/assertions.kt index d7ff7ad7c44..3d2eefde44e 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/assertions.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/assertions.kt @@ -50,8 +50,28 @@ fun assertModulesAreEqual(reference: SerializedMetadata, generated: SerializedMe } private val FILTER_OUR_ACCEPTABLE_MISMATCHES: (Mismatch) -> Boolean = { mismatch -> - when (mismatch) { - is Mismatch.MissingEntity -> mismatch.kind == "AbbreviationType" && mismatch.missingInA - is Mismatch.DifferentValues -> false + var isAcceptableMismatch = false // don't filter it out by default + + if (mismatch is Mismatch.MissingEntity) { + if (mismatch.kind == "AbbreviatedType") { + val usefulPath = mismatch.path + .dropWhile { !it.startsWith("Package ") } + .drop(1) + .joinToString(" > ") { it.substringBefore(' ') } + + if (mismatch.missingInA) { + if (usefulPath == "TypeAlias > ExpandedType") { + // extra abbreviated type appeared in commonized declaration, it's OK + isAcceptableMismatch = true + } + } else /*if (mismatch.missingInB)*/ { + if ("> ReturnType >" in usefulPath && usefulPath.endsWith("TypeProjection > Type")) { + // extra abbreviated type gone in type argument of commonized declaration, it's OK + isAcceptableMismatch = true + } + } + } } + + !isAcceptableMismatch } From 0af31abb04889fe0a45b3ed234531f952bad363a Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Fri, 12 Feb 2021 15:51:08 +0300 Subject: [PATCH 136/368] [Commonizer] Add tests for overloading purely by different upper bounds --- .../commonized/common/package_root.kt | 45 +++++++++++++++++++ .../commonized/js/package_root.kt | 45 +++++++++++++++++++ .../commonized/jvm/package_root.kt | 45 +++++++++++++++++++ .../original/js/package_root.kt | 45 +++++++++++++++++++ .../original/jvm/package_root.kt | 45 +++++++++++++++++++ .../commonized/common/package_root.kt | 26 +++++++++++ .../commonized/js/package_root.kt | 26 +++++++++++ .../commonized/jvm/package_root.kt | 26 +++++++++++ .../original/js/package_root.kt | 26 +++++++++++ .../original/jvm/package_root.kt | 26 +++++++++++ .../FunctionCommonizationFromSourcesTest.kt | 2 + .../PropertyCommonizationFromSourcesTest.kt | 2 + 12 files changed, 359 insertions(+) create mode 100644 native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/common/package_root.kt create mode 100644 native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/js/package_root.kt create mode 100644 native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/jvm/package_root.kt create mode 100644 native/commonizer/testData/functionCommonization/overloadingByUpperBounds/original/js/package_root.kt create mode 100644 native/commonizer/testData/functionCommonization/overloadingByUpperBounds/original/jvm/package_root.kt create mode 100644 native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/common/package_root.kt create mode 100644 native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/js/package_root.kt create mode 100644 native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/jvm/package_root.kt create mode 100644 native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/original/js/package_root.kt create mode 100644 native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/original/jvm/package_root.kt diff --git a/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/common/package_root.kt b/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/common/package_root.kt new file mode 100644 index 00000000000..4fcbe279410 --- /dev/null +++ b/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/common/package_root.kt @@ -0,0 +1,45 @@ +expect interface I1 +expect interface I2 +expect interface I3 + +expect fun functionWithValueParameter(value: T): Unit +expect fun functionWithValueParameter(value: T): Unit +expect fun > functionWithValueParameter(value: T): Unit +expect fun > functionWithValueParameter(value: T): Unit +expect fun > functionWithValueParameter(value: T): Unit +expect fun > functionWithValueParameter(value: T): Unit +expect fun > functionWithValueParameter(value: T): Unit +expect fun > functionWithValueParameter(value: T): Unit +expect fun > functionWithValueParameter(value: T): Unit +expect fun > functionWithValueParameter(value: T): Unit +expect fun > functionWithValueParameter(value: T): Unit +expect fun > functionWithValueParameter(value: T): Unit +expect fun > functionWithValueParameter(value: T): Unit +expect fun functionWithValueParameter(value: T): Unit +expect fun functionWithValueParameter(value: T): Unit +expect fun functionWithValueParameter(value: I1): Unit +expect fun functionWithValueParameter(value: I2): Unit +expect fun functionWithValueParameter(value: Any): Unit +expect fun functionWithValueParameter(value: Any?): Unit +expect fun functionWithValueParameter(): Unit + +expect fun T.functionWithReceiver(): Unit +expect fun T.functionWithReceiver(): Unit +expect fun > T.functionWithReceiver(): Unit +expect fun > T.functionWithReceiver(): Unit +expect fun > T.functionWithReceiver(): Unit +expect fun > T.functionWithReceiver(): Unit +expect fun > T.functionWithReceiver(): Unit +expect fun > T.functionWithReceiver(): Unit +expect fun > T.functionWithReceiver(): Unit +expect fun > T.functionWithReceiver(): Unit +expect fun > T.functionWithReceiver(): Unit +expect fun > T.functionWithReceiver(): Unit +expect fun > T.functionWithReceiver(): Unit +expect fun T.functionWithReceiver(): Unit +expect fun T.functionWithReceiver(): Unit +expect fun I1.functionWithReceiver(): Unit +expect fun I2.functionWithReceiver(): Unit +expect fun Any.functionWithReceiver(): Unit +expect fun Any?.functionWithReceiver(): Unit +expect fun functionWithReceiver(): Unit diff --git a/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/js/package_root.kt b/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/js/package_root.kt new file mode 100644 index 00000000000..281165d3e82 --- /dev/null +++ b/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/js/package_root.kt @@ -0,0 +1,45 @@ +actual interface I1 +actual interface I2 +actual interface I3 + +actual fun functionWithValueParameter(value: T) = Unit +actual fun functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun functionWithValueParameter(value: T) = Unit +actual fun functionWithValueParameter(value: T) = Unit +actual fun functionWithValueParameter(value: I1) = Unit +actual fun functionWithValueParameter(value: I2) = Unit +actual fun functionWithValueParameter(value: Any) = Unit +actual fun functionWithValueParameter(value: Any?) = Unit +actual fun functionWithValueParameter() = Unit + +actual fun T.functionWithReceiver() = Unit +actual fun T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun T.functionWithReceiver() = Unit +actual fun T.functionWithReceiver() = Unit +actual fun I1.functionWithReceiver() = Unit +actual fun I2.functionWithReceiver() = Unit +actual fun Any.functionWithReceiver() = Unit +actual fun Any?.functionWithReceiver() = Unit +actual fun functionWithReceiver() = Unit diff --git a/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/jvm/package_root.kt b/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/jvm/package_root.kt new file mode 100644 index 00000000000..281165d3e82 --- /dev/null +++ b/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/commonized/jvm/package_root.kt @@ -0,0 +1,45 @@ +actual interface I1 +actual interface I2 +actual interface I3 + +actual fun functionWithValueParameter(value: T) = Unit +actual fun functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun > functionWithValueParameter(value: T) = Unit +actual fun functionWithValueParameter(value: T) = Unit +actual fun functionWithValueParameter(value: T) = Unit +actual fun functionWithValueParameter(value: I1) = Unit +actual fun functionWithValueParameter(value: I2) = Unit +actual fun functionWithValueParameter(value: Any) = Unit +actual fun functionWithValueParameter(value: Any?) = Unit +actual fun functionWithValueParameter() = Unit + +actual fun T.functionWithReceiver() = Unit +actual fun T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun > T.functionWithReceiver() = Unit +actual fun T.functionWithReceiver() = Unit +actual fun T.functionWithReceiver() = Unit +actual fun I1.functionWithReceiver() = Unit +actual fun I2.functionWithReceiver() = Unit +actual fun Any.functionWithReceiver() = Unit +actual fun Any?.functionWithReceiver() = Unit +actual fun functionWithReceiver() = Unit diff --git a/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/original/js/package_root.kt b/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/original/js/package_root.kt new file mode 100644 index 00000000000..63d0f26c8b2 --- /dev/null +++ b/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/original/js/package_root.kt @@ -0,0 +1,45 @@ +interface I1 +interface I2 +interface I3 + +fun functionWithValueParameter(value: T) = Unit +fun functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun functionWithValueParameter(value: T) = Unit +fun functionWithValueParameter(value: T) = Unit +fun functionWithValueParameter(value: I1) = Unit +fun functionWithValueParameter(value: I2) = Unit +fun functionWithValueParameter(value: Any) = Unit +fun functionWithValueParameter(value: Any?) = Unit +fun functionWithValueParameter() = Unit + +fun T.functionWithReceiver() = Unit +fun T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun T.functionWithReceiver() = Unit +fun T.functionWithReceiver() = Unit +fun I1.functionWithReceiver() = Unit +fun I2.functionWithReceiver() = Unit +fun Any.functionWithReceiver() = Unit +fun Any?.functionWithReceiver() = Unit +fun functionWithReceiver() = Unit diff --git a/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/original/jvm/package_root.kt b/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/original/jvm/package_root.kt new file mode 100644 index 00000000000..63d0f26c8b2 --- /dev/null +++ b/native/commonizer/testData/functionCommonization/overloadingByUpperBounds/original/jvm/package_root.kt @@ -0,0 +1,45 @@ +interface I1 +interface I2 +interface I3 + +fun functionWithValueParameter(value: T) = Unit +fun functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun > functionWithValueParameter(value: T) = Unit +fun functionWithValueParameter(value: T) = Unit +fun functionWithValueParameter(value: T) = Unit +fun functionWithValueParameter(value: I1) = Unit +fun functionWithValueParameter(value: I2) = Unit +fun functionWithValueParameter(value: Any) = Unit +fun functionWithValueParameter(value: Any?) = Unit +fun functionWithValueParameter() = Unit + +fun T.functionWithReceiver() = Unit +fun T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun > T.functionWithReceiver() = Unit +fun T.functionWithReceiver() = Unit +fun T.functionWithReceiver() = Unit +fun I1.functionWithReceiver() = Unit +fun I2.functionWithReceiver() = Unit +fun Any.functionWithReceiver() = Unit +fun Any?.functionWithReceiver() = Unit +fun functionWithReceiver() = Unit diff --git a/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/common/package_root.kt b/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/common/package_root.kt new file mode 100644 index 00000000000..d7c695e6da0 --- /dev/null +++ b/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/common/package_root.kt @@ -0,0 +1,26 @@ +expect interface I1 +expect interface I2 +expect interface I3 + +expect object Holder { + val T.propertyWithReceiver: Unit + val T.propertyWithReceiver: Unit + val > T.propertyWithReceiver: Unit + val > T.propertyWithReceiver: Unit + val > T.propertyWithReceiver: Unit + val > T.propertyWithReceiver: Unit + val > T.propertyWithReceiver: Unit + val > T.propertyWithReceiver: Unit + val > T.propertyWithReceiver: Unit + val > T.propertyWithReceiver: Unit + val > T.propertyWithReceiver: Unit + val > T.propertyWithReceiver: Unit + val > T.propertyWithReceiver: Unit + val T.propertyWithReceiver: Unit + val T.propertyWithReceiver: Unit + val I1.propertyWithReceiver: Unit + val I2.propertyWithReceiver: Unit + val Any.propertyWithReceiver: Unit + val Any?.propertyWithReceiver: Unit + val propertyWithReceiver: Unit +} diff --git a/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/js/package_root.kt b/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/js/package_root.kt new file mode 100644 index 00000000000..0661c51fd5f --- /dev/null +++ b/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/js/package_root.kt @@ -0,0 +1,26 @@ +actual interface I1 +actual interface I2 +actual interface I3 + +actual object Holder { + actual val T.propertyWithReceiver: Unit get() = Unit + actual val T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val T.propertyWithReceiver: Unit get() = Unit + actual val T.propertyWithReceiver: Unit get() = Unit + actual val I1.propertyWithReceiver: Unit get() = Unit + actual val I2.propertyWithReceiver: Unit get() = Unit + actual val Any.propertyWithReceiver: Unit get() = Unit + actual val Any?.propertyWithReceiver: Unit get() = Unit + actual val propertyWithReceiver: Unit get() = Unit +} diff --git a/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/jvm/package_root.kt b/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/jvm/package_root.kt new file mode 100644 index 00000000000..0661c51fd5f --- /dev/null +++ b/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/commonized/jvm/package_root.kt @@ -0,0 +1,26 @@ +actual interface I1 +actual interface I2 +actual interface I3 + +actual object Holder { + actual val T.propertyWithReceiver: Unit get() = Unit + actual val T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val > T.propertyWithReceiver: Unit get() = Unit + actual val T.propertyWithReceiver: Unit get() = Unit + actual val T.propertyWithReceiver: Unit get() = Unit + actual val I1.propertyWithReceiver: Unit get() = Unit + actual val I2.propertyWithReceiver: Unit get() = Unit + actual val Any.propertyWithReceiver: Unit get() = Unit + actual val Any?.propertyWithReceiver: Unit get() = Unit + actual val propertyWithReceiver: Unit get() = Unit +} diff --git a/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/original/js/package_root.kt b/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/original/js/package_root.kt new file mode 100644 index 00000000000..c17a84a0591 --- /dev/null +++ b/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/original/js/package_root.kt @@ -0,0 +1,26 @@ +interface I1 +interface I2 +interface I3 + +object Holder { + val T.propertyWithReceiver: Unit get() = Unit + val T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val T.propertyWithReceiver: Unit get() = Unit + val T.propertyWithReceiver: Unit get() = Unit + val I1.propertyWithReceiver: Unit get() = Unit + val I2.propertyWithReceiver: Unit get() = Unit + val Any.propertyWithReceiver: Unit get() = Unit + val Any?.propertyWithReceiver: Unit get() = Unit + val propertyWithReceiver: Unit get() = Unit +} diff --git a/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/original/jvm/package_root.kt b/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/original/jvm/package_root.kt new file mode 100644 index 00000000000..c17a84a0591 --- /dev/null +++ b/native/commonizer/testData/propertyCommonization/overloadingByUpperBounds/original/jvm/package_root.kt @@ -0,0 +1,26 @@ +interface I1 +interface I2 +interface I3 + +object Holder { + val T.propertyWithReceiver: Unit get() = Unit + val T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val > T.propertyWithReceiver: Unit get() = Unit + val T.propertyWithReceiver: Unit get() = Unit + val T.propertyWithReceiver: Unit get() = Unit + val I1.propertyWithReceiver: Unit get() = Unit + val I2.propertyWithReceiver: Unit get() = Unit + val Any.propertyWithReceiver: Unit get() = Unit + val Any?.propertyWithReceiver: Unit get() = Unit + val propertyWithReceiver: Unit get() = Unit +} diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/FunctionCommonizationFromSourcesTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/FunctionCommonizationFromSourcesTest.kt index 5cf962495e2..7d7b2dbfe31 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/FunctionCommonizationFromSourcesTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/FunctionCommonizationFromSourcesTest.kt @@ -17,4 +17,6 @@ class FunctionCommonizationFromSourcesTest : AbstractCommonizationFromSourcesTes fun testSpecifics() = doTestSuccessfulCommonization() fun testSignaturesWithNullableTypealiases() = doTestSuccessfulCommonization() + + fun testOverloadingByUpperBounds() = doTestSuccessfulCommonization() } diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/PropertyCommonizationFromSourcesTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/PropertyCommonizationFromSourcesTest.kt index 0a9c1950310..103d815fd7b 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/PropertyCommonizationFromSourcesTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/PropertyCommonizationFromSourcesTest.kt @@ -15,4 +15,6 @@ class PropertyCommonizationFromSourcesTest : AbstractCommonizationFromSourcesTes fun testSetters() = doTestSuccessfulCommonization() fun testLiftingUpConst() = doTestSuccessfulCommonization() + + fun testOverloadingByUpperBounds() = doTestSuccessfulCommonization() } From 3c6eb8f8f4ffb4fe2b4001d6ba66cc57ec2c6837 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Fri, 12 Feb 2021 15:15:16 +0300 Subject: [PATCH 137/368] Minor. Formatted --- .../commonizer/AbstractCommonizationFromSourcesTest.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt index dc9aef06856..d7bff9cd0fc 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt @@ -238,8 +238,6 @@ private class AnalyzedModules( createModules(sharedTarget, commonizedRoots, dependencies, parentDisposable) .mapValues { (_, moduleDescriptor) -> MockModulesProvider.SERIALIZER.serializeModule(moduleDescriptor) } - - return AnalyzedModules(originalModules, commonizedModules, dependeeModules) } From 0eaea655d0d5801023657b8206624b85005e8f5f Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Fri, 12 Feb 2021 22:48:24 +0300 Subject: [PATCH 138/368] [Commonization] Improvements in approx. keys - Don't print upper bounds if it contains only kotlin/Any? - Print variance in lowercase --- .../cir/factory/CirTypeParameterFactory.kt | 21 +++++-------- .../descriptors/commonizer/utils/type.kt | 31 ++++++++++--------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cir/factory/CirTypeParameterFactory.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cir/factory/CirTypeParameterFactory.kt index aede18423eb..824627b9fcb 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cir/factory/CirTypeParameterFactory.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cir/factory/CirTypeParameterFactory.kt @@ -12,22 +12,17 @@ import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirTypeParameterImpl import org.jetbrains.kotlin.descriptors.commonizer.utils.compactMap +import org.jetbrains.kotlin.descriptors.commonizer.utils.filteredUpperBounds import org.jetbrains.kotlin.types.Variance -import org.jetbrains.kotlin.types.typeUtil.isNullableAny object CirTypeParameterFactory { - fun create(source: TypeParameterDescriptor): CirTypeParameter { - val upperBounds = source.upperBounds - val filteredUpperBounds = if (upperBounds.singleOrNull()?.isNullableAny() == true) emptyList() else upperBounds - - return create( - annotations = source.annotations.compactMap(CirAnnotationFactory::create), - name = CirName.create(source.name), - isReified = source.isReified, - variance = source.variance, - upperBounds = filteredUpperBounds.compactMap(CirTypeFactory::create) - ) - } + fun create(source: TypeParameterDescriptor): CirTypeParameter = create( + annotations = source.annotations.compactMap(CirAnnotationFactory::create), + name = CirName.create(source.name), + isReified = source.isReified, + variance = source.variance, + upperBounds = source.filteredUpperBounds.compactMap(CirTypeFactory::create) + ) @Suppress("NOTHING_TO_INLINE") inline fun create( diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/type.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/type.kt index d56c1f07fb0..10cc5211801 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/type.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/type.kt @@ -5,16 +5,14 @@ package org.jetbrains.kotlin.descriptors.commonizer.utils -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.ClassifierDescriptor -import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters -import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor +import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPackageName import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeSignature import org.jetbrains.kotlin.resolve.descriptorUtil.classId import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.typeUtil.isNullableAny import org.jetbrains.kotlin.types.typeUtil.makeNotNullable internal inline val KotlinType.declarationDescriptor: ClassifierDescriptor @@ -42,6 +40,9 @@ internal val ClassifierDescriptorWithTypeParameters.classifierId: CirEntityId else -> error("Unexpected containing declaration type for $this: ${owner::class}, $owner") } +internal inline val TypeParameterDescriptor.filteredUpperBounds: List + get() = upperBounds.takeUnless { it.singleOrNull()?.isNullableAny() == true } ?: emptyList() + internal val KotlinType.signature: CirTypeSignature get() { // use of interner saves up to 95% of duplicates @@ -55,17 +56,17 @@ private fun StringBuilder.buildTypeSignature(type: KotlinType, exploredTypeParam append(typeParameterDescriptor.name.asString()) if (exploredTypeParameters.add(type.makeNotNullable())) { // print upper bounds once the first time when type parameter type is met - append(":[") - typeParameterDescriptor.upperBounds.forEachIndexed { index, upperBound -> + append(':').append('[') + typeParameterDescriptor.filteredUpperBounds.forEachIndexed { index, upperBound -> if (index > 0) - append(",") + append(',') buildTypeSignature(upperBound, exploredTypeParameters) } - append("]") + append(']') } if (type.isMarkedNullable) - append("?") + append('?') } else { // N.B. this is classifier type val abbreviation = (type as? AbbreviatedType)?.abbreviation ?: type @@ -73,25 +74,25 @@ private fun StringBuilder.buildTypeSignature(type: KotlinType, exploredTypeParam val arguments = abbreviation.arguments if (arguments.isNotEmpty()) { - append("<") + append('<') arguments.forEachIndexed { index, argument -> if (index > 0) - append(",") + append(',') if (argument.isStarProjection) - append("*") + append('*') else { val variance = argument.projectionKind if (variance != Variance.INVARIANT) - append(variance).append(" ") + append(variance.label).append(' ') buildTypeSignature(argument.type, exploredTypeParameters) } } - append(">") + append('>') } if (abbreviation.isMarkedNullable) - append("?") + append('?') } } From 069941cdaf6d99a27939e266223d0b1bbe5cc359 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Thu, 11 Feb 2021 14:02:32 +0100 Subject: [PATCH 139/368] Provide compiler classpath as task input. This ensures that compiler classpath is what is expected by Kotlin Plugin and removes possibility of leaking wrong jars from Gradle wrapper classpath. For 'kotlin.useFallbackCompilerSearch' old behaviour is still present, but this option should be marked as deprecated and removed in one of the Kotlin releases. --- .../jetbrains/kotlin/gradle/KotlinDaemonIT.kt | 40 +++++++++++++++++ .../gradle/plugin/KotlinPluginWrapper.kt | 28 +++++++++--- .../gradle/targets/js/KotlinJsDcePlugin.kt | 1 + .../targets/js/subtargets/KotlinBrowserJs.kt | 2 + .../jetbrains/kotlin/gradle/tasks/Tasks.kt | 43 +++++++++++-------- 5 files changed, 89 insertions(+), 25 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinDaemonIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinDaemonIT.kt index e01016439ff..51d1375cb2a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinDaemonIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinDaemonIT.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.compilerRunner.* import org.junit.Assert import org.junit.Test import java.io.File +import kotlin.test.assertTrue // todo: test client file creation/deletion // todo: test daemon start (does not start every build) @@ -91,4 +92,43 @@ class KotlinDaemonIT : BaseGradleIT() { } } } + + @Test + fun testGradleBuildClasspathShouldNotBeLeakedIntoDaemonClasspath() { + val testProject = Project("kotlinProject") + testProject.setupWorkingDir() + + testProject.build("assemble") { + assertGradleClasspathNotLeaked() + } + } + + @Test + fun testGradleBuildClasspathShouldNotBeLeakedIntoDaemonClasspathOnUsingCustomCompilerJar() { + val testProject = Project( + projectName = "customCompilerFile", + ) + testProject.setupWorkingDir() + + // copy compiler embeddable into project dir using custom name + val classpath = System.getProperty("java.class.path").split(File.pathSeparator) + val kotlinEmbeddableJar = File(classpath.find { it.contains("kotlin-compiler-embeddable") }!!) + + val compilerJar = File(testProject.projectDir, "compiler.jar") + kotlinEmbeddableJar.copyTo(compilerJar) + + testProject.build("build") { + assertGradleClasspathNotLeaked() + } + } + + private fun CompiledProject.assertGradleClasspathNotLeaked() { + assertContains("Kotlin compiler classpath:") + val daemonClasspath = output.lineSequence().find { + it.contains("Kotlin compiler classpath:") + }!! + assertTrue("Daemon classpath contains embeddable daemon jar leaked from Gradle dist classpath: $daemonClasspath") { + !daemonClasspath.contains(".gradle/wrapper/dists") + } + } } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt index 0a5f0cf2420..11549412937 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginWrapper.kt @@ -21,10 +21,8 @@ import org.gradle.api.NamedDomainObjectFactory import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.internal.FeaturePreviews -import org.gradle.api.internal.file.FileResolver import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging -import org.gradle.build.event.BuildEventsListenerRegistry import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry import org.jetbrains.kotlin.gradle.dsl.* import org.jetbrains.kotlin.gradle.logging.kotlinDebug @@ -36,10 +34,10 @@ import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute import org.jetbrains.kotlin.gradle.targets.js.KotlinJsPlugin import org.jetbrains.kotlin.gradle.targets.js.npm.addNpmDependencyExtension +import org.jetbrains.kotlin.gradle.tasks.* import org.jetbrains.kotlin.gradle.tasks.KOTLIN_COMPILER_EMBEDDABLE import org.jetbrains.kotlin.gradle.tasks.KOTLIN_KLIB_COMMONIZER_EMBEDDABLE import org.jetbrains.kotlin.gradle.tasks.KOTLIN_MODULE_GROUP -import org.jetbrains.kotlin.gradle.tasks.throwGradleExceptionIfError import org.jetbrains.kotlin.gradle.testing.internal.KotlinTestsRegistry import org.jetbrains.kotlin.gradle.utils.checkGradleCompatibility import org.jetbrains.kotlin.gradle.utils.loadPropertyFromResources @@ -68,9 +66,8 @@ abstract class KotlinBasePluginWrapper : Plugin { whenBuildEvaluated(project) } - project.configurations.maybeCreate(COMPILER_CLASSPATH_CONFIGURATION_NAME).defaultDependencies { - it.add(project.dependencies.create("$KOTLIN_MODULE_GROUP:$KOTLIN_COMPILER_EMBEDDABLE:$kotlinPluginVersion")) - } + addKotlinCompilerConfiguration(project) + project.configurations.maybeCreate(PLUGIN_CLASSPATH_CONFIGURATION_NAME) project.configurations.maybeCreate(NATIVE_COMPILER_PLUGIN_CLASSPATH_CONFIGURATION_NAME).apply { isTransitive = false @@ -106,6 +103,25 @@ abstract class KotlinBasePluginWrapper : Plugin { project.addNpmDependencyExtension() } + private fun addKotlinCompilerConfiguration(project: Project) { + project + .configurations + .maybeCreate(COMPILER_CLASSPATH_CONFIGURATION_NAME) + .defaultDependencies { + it.add( + project.dependencies.create("$KOTLIN_MODULE_GROUP:$KOTLIN_COMPILER_EMBEDDABLE:$kotlinPluginVersion") + ) + } + project + .tasks + .withType(AbstractKotlinCompile::class.java) + .configureEach { task -> + task.defaultCompilerClasspath.setFrom( + project.configurations.named(COMPILER_CLASSPATH_CONFIGURATION_NAME) + ) + } + } + open fun whenBuildEvaluated(project: Project) { } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsDcePlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsDcePlugin.kt index b5d537b0eaa..7bcda618c80 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsDcePlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/KotlinJsDcePlugin.kt @@ -64,6 +64,7 @@ class KotlinJsDcePlugin : Plugin { val dceTask = project.registerTask(dceTaskName) { it.dependsOn(kotlinTask) + it.defaultCompilerClasspath.setFrom(project.configurations.named(COMPILER_CLASSPATH_CONFIGURATION_NAME)) } project.tasks.named("build").dependsOn(dceTask) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinBrowserJs.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinBrowserJs.kt index 34dff65c12b..e93d5cdf14f 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinBrowserJs.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/subtargets/KotlinBrowserJs.kt @@ -10,6 +10,7 @@ import org.gradle.api.tasks.Copy import org.gradle.api.tasks.TaskProvider import org.gradle.language.base.plugins.LifecycleBasePlugin import org.jetbrains.kotlin.gradle.dsl.KotlinJsDce +import org.jetbrains.kotlin.gradle.plugin.COMPILER_CLASSPATH_CONFIGURATION_NAME import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget @@ -287,6 +288,7 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) : it.classpath = project.configurations.getByName(compilation.runtimeDependencyConfigurationName) it.destinationDir = it.dceOptions.outputDirectory?.let { File(it) } ?: compilation.npmProject.dir.resolve(if (dev) DCE_DEV_DIR else DCE_DIR) + it.defaultCompilerClasspath.setFrom(project.configurations.named(COMPILER_CLASSPATH_CONFIGURATION_NAME)) it.source(kotlinTask.map { it.outputFile }) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt index 9509274f7e0..4564dede92e 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle.tasks import org.gradle.api.Project import org.gradle.api.Task +import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.FileCollection import org.gradle.api.logging.Logger import org.gradle.api.provider.Provider @@ -98,28 +99,32 @@ abstract class AbstractKotlinCompileTool override val metrics: BuildMetricsReporter = BuildMetricsReporterImpl() + /** + * By default should be set by plugin from [COMPILER_CLASSPATH_CONFIGURATION_NAME] configuration. + * + * Empty classpath will fail the build. + */ + @get:Classpath + internal val defaultCompilerClasspath: ConfigurableFileCollection = + project.objects.fileCollection() + @get:Classpath @get:InputFiles internal val computedCompilerClasspath: List by lazy { - compilerClasspath?.takeIf { it.isNotEmpty() } - ?: compilerJarFile?.let { - // a hack to remove compiler jar from the cp, will be dropped when compilerJarFile will be removed - listOf(it) + findKotlinCompilerClasspath(project).filter { !it.name.startsWith("kotlin-compiler") } - } - ?: if (!useFallbackCompilerSearch) { - try { - project.configurations.getByName(COMPILER_CLASSPATH_CONFIGURATION_NAME).resolve().toList() - } catch (e: Exception) { - logger.error( - "Could not resolve compiler classpath. " + - "Check if Kotlin Gradle plugin repository is configured in $project." - ) - throw e - } - } else { - findKotlinCompilerClasspath(project) - } - ?: throw IllegalStateException("Could not find Kotlin Compiler classpath") + require(!defaultCompilerClasspath.isEmpty) { + "Default Kotlin compiler classpath is empty! Task: ${this::class.qualifiedName}" + } + + when { + !compilerClasspath.isNullOrEmpty() -> compilerClasspath!! + compilerJarFile != null -> listOf(compilerJarFile!!) + + defaultCompilerClasspath + .filterNot { + it.nameWithoutExtension.startsWith("kotlin-compiler") + } + useFallbackCompilerSearch -> findKotlinCompilerClasspath(project) + else -> defaultCompilerClasspath.toList() + } } From 440fc8c4e40aa1dd647e2ef8d852472169050eed Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Thu, 11 Feb 2021 14:58:21 +0100 Subject: [PATCH 140/368] Deprecated 'kotlin.useCompilerFallbackSearch' property. This property was introduced in 2018 and no longer supported. See https://discuss.kotlinlang.org/t/how-to-set-usefallbackcompilersearch/9039 for details why it was introduced. --- .../kotlin/gradle/plugin/KotlinProperties.kt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt index 4b0c5b44264..05a6a5f3acf 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt @@ -17,7 +17,6 @@ import org.jetbrains.kotlin.gradle.targets.js.dukat.ExternalsOutputFormat import org.jetbrains.kotlin.gradle.targets.js.dukat.ExternalsOutputFormat.Companion.externalsOutputFormatProperty import org.jetbrains.kotlin.gradle.targets.native.DisabledNativeTargetsReporter import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile -import org.jetbrains.kotlin.gradle.tasks.CacheBuilder import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.utils.SingleWarningPerBuild @@ -89,8 +88,19 @@ internal class PropertiesProvider private constructor(private val project: Proje val usePreciseJavaTracking: Boolean? get() = booleanProperty("kotlin.incremental.usePreciseJavaTracking") + private val useFallbackCompilerSearchPropName = "kotlin.useFallbackCompilerSearch" + + @Deprecated("Unsupported and will be removed in next major releases") val useFallbackCompilerSearch: Boolean? - get() = booleanProperty("kotlin.useFallbackCompilerSearch") + get() { + if (property(useFallbackCompilerSearchPropName) != null) { + SingleWarningPerBuild.show( + project, + "Project property '$useFallbackCompilerSearchPropName' is deprecated." + ) + } + return booleanProperty(useFallbackCompilerSearchPropName) + } val keepMppDependenciesIntactInPoms: Boolean? get() = booleanProperty("kotlin.mpp.keepMppDependenciesIntactInPoms") From dcad9c84fc6e923cda6b3b6848a9a310aba7ea55 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Thu, 11 Feb 2021 17:30:13 +0300 Subject: [PATCH 141/368] Don't fix type variables into Nothing in priority way ^KT-44546 Fixed --- .../components/VariableFixationFinder.kt | 15 ++++++++------- .../tests/inference/lambdaParameterTypeInElvis.kt | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt index 91bb087104c..3583da575f2 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/VariableFixationFinder.kt @@ -70,7 +70,7 @@ class VariableFixationFinder( isReified(variable) -> TypeVariableFixationReadiness.READY_FOR_FIXATION_REIFIED inferenceCompatibilityModeEnabled -> { when { - variableHasLowerProperConstraint(variable) -> TypeVariableFixationReadiness.READY_FOR_FIXATION_LOWER + variableHasLowerNonNothingProperConstraint(variable) -> TypeVariableFixationReadiness.READY_FOR_FIXATION_LOWER else -> TypeVariableFixationReadiness.READY_FOR_FIXATION_UPPER } } @@ -159,12 +159,13 @@ class VariableFixationFinder( private fun Context.isReified(variable: TypeConstructorMarker): Boolean = notFixedTypeVariables[variable]?.typeVariable?.let { isReified(it) } ?: false - private fun Context.variableHasLowerProperConstraint(variable: TypeConstructorMarker): Boolean = - notFixedTypeVariables[variable]?.constraints?.let { constraints -> - constraints.any { - it.kind.isLower() && isProperArgumentConstraint(it) - } - } ?: false + private fun Context.variableHasLowerNonNothingProperConstraint(variable: TypeConstructorMarker): Boolean { + val constraints = notFixedTypeVariables[variable]?.constraints ?: return false + + return constraints.any { + it.kind.isLower() && isProperArgumentConstraint(it) && !it.type.typeConstructor().isNothingConstructor() + } + } } inline fun TypeSystemInferenceExtensionContext.isProperTypeForFixation( diff --git a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt index 1c4ce614a63..8924f9b4924 100644 --- a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt +++ b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt @@ -10,5 +10,5 @@ fun Some.doWithPredicate(predicate: (R) -> Unit): R? = TODO() fun test(derived: Some) { val expected: Some = derived.doWithPredicate { it.method() } ?: TODO() - val expected2: Some = elvis(derived.doWithPredicate { it.method() }, TODO()) + val expected2: Some = elvis(derived.doWithPredicate { it.method() }, TODO()) } From 8bab20832278f5143e0c4806c11b2156a404b4d0 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 11 Feb 2021 11:28:20 +0300 Subject: [PATCH 142/368] FIR2IR: use information about callable reference adaptation from resolve --- .../backend/generators/AdapterGenerator.kt | 109 ++++++++---------- .../calls/CallableReferenceResolution.kt | 7 +- .../kotlin/fir/resolve/calls/Candidate.kt | 8 ++ .../calls/FirArgumentsToParametersMapper.kt | 1 - ...rCallCompletionResultsWriterTransformer.kt | 7 +- .../FirResolvedCallableReference.kt | 2 + .../FirResolvedCallableReferenceBuilder.kt | 3 + .../impl/FirResolvedCallableReferenceImpl.kt | 2 + .../fir/resolve/calls/ResolvedCallArgument.kt | 7 +- .../fir/tree/generator/NodeConfigurator.kt | 1 + .../kotlin/fir/tree/generator/Types.kt | 2 + .../adaptedReferences/toStringNoReflect.kt | 1 - ...bleReferencesNotEqualToCallablesFromAPI.kt | 1 - .../adaptedExtensionFunctions.fir.kt.txt | 15 ++- .../adaptedExtensionFunctions.fir.txt | 27 ++++- .../callableReferences/kt37131.fir.kt.txt | 5 +- .../callableReferences/kt37131.fir.txt | 6 +- ...erReferenceWithAdaptedArguments.fir.kt.txt | 2 +- ...emberReferenceWithAdaptedArguments.fir.txt | 2 + .../withAdaptedArguments.fir.kt.txt | 15 ++- .../withAdaptedArguments.fir.txt | 20 +++- .../withVarargViewedAsArray.fir.kt.txt | 5 +- .../withVarargViewedAsArray.fir.txt | 9 +- 23 files changed, 169 insertions(+), 88 deletions(-) rename compiler/fir/{resolve => tree}/src/org/jetbrains/kotlin/fir/resolve/calls/ResolvedCallArgument.kt (77%) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt index df955f46770..b17d0bceec7 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt @@ -12,7 +12,10 @@ import org.jetbrains.kotlin.fir.backend.convertWithOffsets import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression +import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference import org.jetbrains.kotlin.fir.render +import org.jetbrains.kotlin.fir.resolve.calls.FirFakeArgumentForCallableReference +import org.jetbrains.kotlin.fir.resolve.calls.ResolvedCallArgument import org.jetbrains.kotlin.fir.resolve.inference.* import org.jetbrains.kotlin.fir.types.ConeClassLikeType import org.jetbrains.kotlin.fir.types.ConeKotlinType @@ -29,10 +32,7 @@ import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl -import org.jetbrains.kotlin.ir.types.IrSimpleType -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.isUnit -import org.jetbrains.kotlin.ir.types.typeOrNull +import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.name.Name @@ -58,7 +58,7 @@ internal class AdapterGenerator( function: IrFunction ): Boolean = needSuspendConversion(type, function) || needCoercionToUnit(type, function) || - needVarargSpread(callableReferenceAccess, type, function) + needVarargSpread(callableReferenceAccess) /** * For example, @@ -96,26 +96,11 @@ internal class AdapterGenerator( * * At the use site, instead of referenced, we can put the adapter: { a, b -> referenced(a, b) } */ - private fun needVarargSpread( - callableReferenceAccess: FirCallableReferenceAccess, - type: IrSimpleType, - function: IrFunction - ): Boolean { + private fun needVarargSpread(callableReferenceAccess: FirCallableReferenceAccess): Boolean { // Unbound callable reference 'A::foo' - val shift = if (callableReferenceAccess.explicitReceiver is FirResolvedQualifier) 1 else 0 - val typeArguments = type.arguments - // Drop the return type from type arguments - val expectedParameterSize = typeArguments.size - 1 - shift - if (expectedParameterSize < function.valueParameters.size) { - return false - } - var hasSpreadCase = false - function.valueParameters.forEachIndexed { index, irValueParameter -> - if (irValueParameter.isVararg && typeArguments[shift + index] == irValueParameter.varargElementType) { - hasSpreadCase = true - } - } - return hasSpreadCase + return (callableReferenceAccess.calleeReference as? FirResolvedCallableReference)?.mappedArguments?.any { + it.value is ResolvedCallArgument.VarargArgument || it.value is ResolvedCallArgument.DefaultArgument + } == true } internal fun ConeKotlinType.kFunctionTypeToFunctionType(): IrSimpleType = @@ -138,7 +123,7 @@ internal class AdapterGenerator( callableReferenceAccess, startOffset, endOffset, firAdaptee!!, adaptee, type, boundDispatchReceiver, boundExtensionReceiver ) val irCall = createAdapteeCallForCallableReference( - callableReferenceAccess, adapteeSymbol, irAdapterFunction, boundDispatchReceiver, boundExtensionReceiver + callableReferenceAccess, firAdaptee, adapteeSymbol, irAdapterFunction, boundDispatchReceiver, boundExtensionReceiver ) irAdapterFunction.body = irFactory.createBlockBody(startOffset, endOffset) { if (expectedReturnType?.isUnit() == true) { @@ -268,6 +253,7 @@ internal class AdapterGenerator( private fun createAdapteeCallForCallableReference( callableReferenceAccess: FirCallableReferenceAccess, + firAdaptee: FirFunction<*>, adapteeSymbol: IrFunctionSymbol, adapterFunction: IrFunction, boundDispatchReceiver: IrExpression?, @@ -296,6 +282,7 @@ internal class AdapterGenerator( } var adapterParameterIndex = 0 + var parameterShift = 0 if (boundDispatchReceiver != null || boundExtensionReceiver != null) { val receiverValue = IrGetValueImpl( startOffset, endOffset, adapterFunction.extensionReceiverParameter!!.symbol, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE @@ -312,50 +299,56 @@ internal class AdapterGenerator( ) if (adapteeFunction.extensionReceiverParameter != null) { irCall.extensionReceiver = adaptedReceiverValue - adapterParameterIndex++ } else { irCall.dispatchReceiver = adaptedReceiverValue } + parameterShift++ } - adapteeFunction.valueParameters.mapIndexed { index, valueParameter -> - when { - valueParameter.isVararg -> { - if (adapterFunction.valueParameters.size <= index) { - irCall.putValueArgument(index, null) + val mappedArguments = (callableReferenceAccess.calleeReference as? FirResolvedCallableReference)?.mappedArguments + + fun buildIrGetValueArgument(argument: FirExpression): IrGetValue { + val parameterIndex = (argument as? FirFakeArgumentForCallableReference)?.index ?: adapterParameterIndex + adapterParameterIndex++ + return adapterFunction.valueParameters[parameterIndex + parameterShift].toIrGetValue(startOffset, endOffset) + } + + adapteeFunction.valueParameters.zip(firAdaptee.valueParameters).mapIndexed { index, (valueParameter, firParameter) -> + when (val mappedArgument = mappedArguments?.get(firParameter)) { + is ResolvedCallArgument.VarargArgument -> { + val valueArgument = if (mappedArgument.arguments.isEmpty()) { + null } else { - val adaptedValueArgument = - IrVarargImpl(startOffset, endOffset, valueParameter.type, valueParameter.varargElementType!!) - var neitherArrayNorSpread = false - while (adapterParameterIndex < adapterFunction.valueParameters.size) { - val irValueArgument = - adapterFunction.valueParameters[adapterParameterIndex].toIrGetValue(startOffset, endOffset) - if (irValueArgument.type == valueParameter.type) { - adaptedValueArgument.addElement(IrSpreadElementImpl(startOffset, endOffset, irValueArgument)) - adapterParameterIndex++ - break - } else if (irValueArgument.type == valueParameter.varargElementType) { - adaptedValueArgument.addElement(irValueArgument) - adapterParameterIndex++ - } else { - neitherArrayNorSpread = true - break - } - } - if (neitherArrayNorSpread) { - irCall.putValueArgument(index, null) - } else { - irCall.putValueArgument(index, adaptedValueArgument) + val adaptedValueArgument = IrVarargImpl( + startOffset, endOffset, + valueParameter.type, valueParameter.varargElementType!!, + ) + for (argument in mappedArgument.arguments) { + val irValueArgument = buildIrGetValueArgument(argument) + adaptedValueArgument.addElement(irValueArgument) } + adaptedValueArgument } + irCall.putValueArgument(index, valueArgument) } - valueParameter.hasDefaultValue() -> { + ResolvedCallArgument.DefaultArgument -> { irCall.putValueArgument(index, null) } - else -> { - irCall.putValueArgument( - index, adapterFunction.valueParameters[adapterParameterIndex++].toIrGetValue(startOffset, endOffset) - ) + is ResolvedCallArgument.SimpleArgument -> { + val irValueArgument = buildIrGetValueArgument(mappedArgument.callArgument) + if (valueParameter.isVararg) { + irCall.putValueArgument( + index, IrVarargImpl( + startOffset, endOffset, + valueParameter.type, valueParameter.varargElementType!!, + listOf(IrSpreadElementImpl(startOffset, endOffset, irValueArgument)) + ) + ) + } else { + irCall.putValueArgument(index, irValueArgument) + } + } + null -> { } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt index c7c0e2ce9a4..b2aa2187ffe 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt @@ -51,8 +51,7 @@ internal object CheckCallableReferenceExpectedType : CheckerStage() { } candidate.resultingTypeForCallableReference = resultingType - candidate.usesSuspendConversion = - callableReferenceAdaptation?.suspendConversionStrategy == SuspendConversionStrategy.SUSPEND_CONVERSION + candidate.callableReferenceAdaptation = callableReferenceAdaptation candidate.outerConstraintBuilderEffect = fun ConstraintSystemOperation.() { addOtherSystem(candidate.system.asReadOnlyStorage()) @@ -133,7 +132,7 @@ internal class CallableReferenceAdaptation( val argumentTypes: Array, val coercionStrategy: CoercionStrategy, val defaults: Int, - val mappedArguments: Map, + val mappedArguments: CallableReferenceMappedArguments, val suspendConversionStrategy: SuspendConversionStrategy ) @@ -351,7 +350,7 @@ private fun createFakeArgumentsForReference( } } -private class FirFakeArgumentForCallableReference( +class FirFakeArgumentForCallableReference( val index: Int ) : FirExpression() { override val source: FirSourceElement? diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt index 91096caae85..03c49b1ed0d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.ConeTypeVariable import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.resolve.calls.components.SuspendConversionStrategy import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage @@ -97,6 +98,13 @@ class Candidate( var resultingTypeForCallableReference: ConeKotlinType? = null var outerConstraintBuilderEffect: (ConstraintSystemOperation.() -> Unit)? = null var usesSAM: Boolean = false + + internal var callableReferenceAdaptation: CallableReferenceAdaptation? = null + set(value) { + field = value + usesSuspendConversion = value?.suspendConversionStrategy == SuspendConversionStrategy.SUSPEND_CONVERSION + } + var usesSuspendConversion: Boolean = false var argumentMapping: LinkedHashMap? = null diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirArgumentsToParametersMapper.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirArgumentsToParametersMapper.kt index c709fdfb012..e77990954d1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirArgumentsToParametersMapper.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirArgumentsToParametersMapper.kt @@ -18,7 +18,6 @@ import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.defaultParameterResolver import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.name.Name -import java.util.* import kotlin.collections.ArrayList import kotlin.collections.LinkedHashMap import kotlin.collections.component1 diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index c6ae1f159bc..fe7d1d2ad96 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -14,10 +14,8 @@ import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference import org.jetbrains.kotlin.fir.references.builder.buildResolvedCallableReference import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.* -import org.jetbrains.kotlin.fir.resolve.calls.Candidate -import org.jetbrains.kotlin.fir.resolve.calls.FirErrorReferenceWithCandidate -import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate -import org.jetbrains.kotlin.fir.resolve.calls.varargElementType +import org.jetbrains.kotlin.fir.resolve.calls.* +import org.jetbrains.kotlin.fir.resolve.calls.CallableReferenceAdaptation import org.jetbrains.kotlin.fir.resolve.dfa.FirDataFlowAnalyzer import org.jetbrains.kotlin.fir.resolve.inference.* import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor @@ -295,6 +293,7 @@ class FirCallCompletionResultsWriterTransformer( name = calleeReference.name resolvedSymbol = calleeReference.candidateSymbol inferredTypeArguments.addAll(computeTypeArgumentTypes(calleeReference.candidate)) + mappedArguments = subCandidate.callableReferenceAdaptation?.mappedArguments ?: emptyMap() }, ).transformDispatchReceiver(StoreReceiver, subCandidate.dispatchReceiverExpression()) .transformExtensionReceiver(StoreReceiver, subCandidate.extensionReceiverExpression()) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedCallableReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedCallableReference.kt index aa5572da77e..37456c2481e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedCallableReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedCallableReference.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.references import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.resolve.calls.CallableReferenceMappedArguments import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.name.Name @@ -22,6 +23,7 @@ abstract class FirResolvedCallableReference : FirResolvedNamedReference() { abstract override val candidateSymbol: AbstractFirBasedSymbol<*>? abstract override val resolvedSymbol: AbstractFirBasedSymbol<*> abstract val inferredTypeArguments: List + abstract val mappedArguments: CallableReferenceMappedArguments override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedCallableReference(this, data) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedCallableReferenceBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedCallableReferenceBuilder.kt index 443cc771a61..35c28b7c25c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedCallableReferenceBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/builder/FirResolvedCallableReferenceBuilder.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.builder.FirBuilderDsl import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl +import org.jetbrains.kotlin.fir.resolve.calls.CallableReferenceMappedArguments import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.visitors.* @@ -26,6 +27,7 @@ class FirResolvedCallableReferenceBuilder { lateinit var name: Name lateinit var resolvedSymbol: AbstractFirBasedSymbol<*> val inferredTypeArguments: MutableList = mutableListOf() + lateinit var mappedArguments: CallableReferenceMappedArguments fun build(): FirResolvedCallableReference { return FirResolvedCallableReferenceImpl( @@ -33,6 +35,7 @@ class FirResolvedCallableReferenceBuilder { name, resolvedSymbol, inferredTypeArguments, + mappedArguments, ) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt index 965d200deb5..bd5b475725f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.references.impl import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference +import org.jetbrains.kotlin.fir.resolve.calls.CallableReferenceMappedArguments import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.name.Name @@ -22,6 +23,7 @@ internal class FirResolvedCallableReferenceImpl( override val name: Name, override val resolvedSymbol: AbstractFirBasedSymbol<*>, override val inferredTypeArguments: MutableList, + override val mappedArguments: CallableReferenceMappedArguments, ) : FirResolvedCallableReference() { override val candidateSymbol: AbstractFirBasedSymbol<*>? get() = null diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolvedCallArgument.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/resolve/calls/ResolvedCallArgument.kt similarity index 77% rename from compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolvedCallArgument.kt rename to compiler/fir/tree/src/org/jetbrains/kotlin/fir/resolve/calls/ResolvedCallArgument.kt index 29f483c3bd5..e8d3d9f033a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolvedCallArgument.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/resolve/calls/ResolvedCallArgument.kt @@ -1,10 +1,11 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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.fir.resolve.calls +import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.FirExpression sealed class ResolvedCallArgument { @@ -23,4 +24,6 @@ sealed class ResolvedCallArgument { } class VarargArgument(override val arguments: List) : ResolvedCallArgument() -} \ No newline at end of file +} + +typealias CallableReferenceMappedArguments = Map \ No newline at end of file diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt index d655c4b4282..c14d0f0b7f0 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt @@ -535,6 +535,7 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild resolvedCallableReference.configure { +fieldList("inferredTypeArguments", coneKotlinTypeType) + +field("mappedArguments", callableReferenceMappedArgumentsType) } delegateFieldReference.configure { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt index 38e16b2f88b..a619f80682d 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt @@ -86,3 +86,5 @@ val declarationAttributesType = generatedType("declarations", "FirDeclarationAtt val annotationResolveStatusType = generatedType("expressions", "FirAnnotationResolveStatus") val exhaustivenessStatusType = generatedType("expressions", "ExhaustivenessStatus") + +val callableReferenceMappedArgumentsType = type("fir.resolve.calls", "CallableReferenceMappedArguments") \ No newline at end of file diff --git a/compiler/testData/codegen/box/callableReference/adaptedReferences/toStringNoReflect.kt b/compiler/testData/codegen/box/callableReference/adaptedReferences/toStringNoReflect.kt index 364e67296f6..1d0f6870953 100644 --- a/compiler/testData/codegen/box/callableReference/adaptedReferences/toStringNoReflect.kt +++ b/compiler/testData/codegen/box/callableReference/adaptedReferences/toStringNoReflect.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME package test diff --git a/compiler/testData/codegen/box/reflection/methodsFromAny/adaptedCallableReferencesNotEqualToCallablesFromAPI.kt b/compiler/testData/codegen/box/reflection/methodsFromAny/adaptedCallableReferencesNotEqualToCallablesFromAPI.kt index ee56bd23817..cf9dcb4463b 100644 --- a/compiler/testData/codegen/box/reflection/methodsFromAny/adaptedCallableReferencesNotEqualToCallablesFromAPI.kt +++ b/compiler/testData/codegen/box/reflection/methodsFromAny/adaptedCallableReferencesNotEqualToCallablesFromAPI.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_REFLECT import kotlin.reflect.* diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.kt.txt index 0dd8e57a20b..b6f65c65d60 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.kt.txt @@ -20,13 +20,22 @@ fun C.extensionBoth(i: Int, s: String = "", vararg t: String) { } fun testExtensionVararg() { - use(f = ::extensionVararg) + use(f = local fun extensionVararg(p0: C, p1: Int) { + p0.extensionVararg(i = p1) + } +) } fun testExtensionDefault() { - use(f = ::extensionDefault) + use(f = local fun extensionDefault(p0: C, p1: Int) { + p0.extensionDefault(i = p1) + } +) } fun testExtensionBoth() { - use(f = ::extensionBoth) + use(f = local fun extensionBoth(p0: C, p1: Int) { + p0.extensionBoth(i = p1) + } +) } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.txt index 7cacf363154..318a0636e69 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.fir.txt @@ -44,12 +44,33 @@ FILE fqName: fileName:/adaptedExtensionFunctions.kt FUN name:testExtensionVararg visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun use (f: @[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - f: FUNCTION_REFERENCE 'public final fun extensionVararg (i: kotlin.Int, vararg s: kotlin.String): kotlin.Unit declared in ' type=kotlin.reflect.KFunction2<.C, kotlin.Int, kotlin.Unit> origin=null reflectionTarget= + f: FUN_EXPR type=kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:extensionVararg visibility:local modality:FINAL <> (p0:.C, p1:kotlin.Int) returnType:kotlin.Unit + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:.C + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p1 index:1 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun extensionVararg (i: kotlin.Int, vararg s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'p0: .C declared in .testExtensionVararg.extensionVararg' type=.C origin=null + i: GET_VAR 'p1: kotlin.Int declared in .testExtensionVararg.extensionVararg' type=kotlin.Int origin=null FUN name:testExtensionDefault visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun use (f: @[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - f: FUNCTION_REFERENCE 'public final fun extensionDefault (i: kotlin.Int, s: kotlin.String): kotlin.Unit declared in ' type=kotlin.reflect.KFunction2<.C, kotlin.Int, kotlin.Unit> origin=null reflectionTarget= + f: FUN_EXPR type=kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:extensionDefault visibility:local modality:FINAL <> (p0:.C, p1:kotlin.Int) returnType:kotlin.Unit + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:.C + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p1 index:1 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun extensionDefault (i: kotlin.Int, s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'p0: .C declared in .testExtensionDefault.extensionDefault' type=.C origin=null + i: GET_VAR 'p1: kotlin.Int declared in .testExtensionDefault.extensionDefault' type=kotlin.Int origin=null FUN name:testExtensionBoth visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun use (f: @[ExtensionFunctionType] kotlin.Function2<.C, kotlin.Int, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - f: FUNCTION_REFERENCE 'public final fun extensionBoth (i: kotlin.Int, s: kotlin.String, vararg t: kotlin.String): kotlin.Unit declared in ' type=kotlin.reflect.KFunction2<.C, kotlin.Int, kotlin.Unit> origin=null reflectionTarget= + f: FUN_EXPR type=kotlin.Function2<.C, kotlin.Int, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:extensionBoth visibility:local modality:FINAL <> (p0:.C, p1:kotlin.Int) returnType:kotlin.Unit + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:.C + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p1 index:1 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun extensionBoth (i: kotlin.Int, s: kotlin.String, vararg t: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'p0: .C declared in .testExtensionBoth.extensionBoth' type=.C origin=null + i: GET_VAR 'p1: kotlin.Int declared in .testExtensionBoth.extensionBoth' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.kt.txt index f4cd26c31b7..eda7defdd2c 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.kt.txt @@ -20,7 +20,10 @@ fun use(fn: Function0): Any { } fun testFn(): Any { - return use(fn = ::foo) + return use(fn = local fun foo(): String { + return foo() + } +) } fun testCtor(): Any { diff --git a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.txt index e103fdec210..31909678561 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.txt @@ -49,7 +49,11 @@ FILE fqName: fileName:/kt37131.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testFn (): kotlin.Any declared in ' CALL 'public final fun use (fn: kotlin.Function0): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: FUNCTION_REFERENCE 'public final fun foo (x: kotlin.String): kotlin.String declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + fn: FUN_EXPR type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun foo (): kotlin.String declared in .testFn' + CALL 'public final fun foo (x: kotlin.String): kotlin.String declared in ' type=kotlin.String origin=null FUN name:testCtor visibility:public modality:FINAL <> () returnType:kotlin.Any BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testCtor (): kotlin.Any declared in ' diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.kt.txt index 3f60c4c9a20..5a8cd7bbd58 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.kt.txt @@ -32,7 +32,7 @@ object Obj : A { fun testUnbound() { use1(fn = local fun foo(p0: A, p1: Int) { - p0.foo() + p0.foo(xs = [p1]) } ) } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt index d74ac176161..ddd260c9264 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt @@ -67,6 +67,8 @@ FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt BLOCK_BODY CALL 'public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A' type=kotlin.Int origin=null $this: GET_VAR 'p0: .A declared in .testUnbound.foo' type=.A origin=null + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p1: kotlin.Int declared in .testUnbound.foo' type=kotlin.Int origin=null FUN name:testBound visibility:public modality:FINAL <> (a:.A) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.A BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.kt.txt index 8063416bc28..bd358b64efa 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.kt.txt @@ -35,7 +35,10 @@ object Host { } fun testDefault(): String { - return use(fn = ::fnWithDefault) + return use(fn = local fun fnWithDefault(p0: Int): String { + return fnWithDefault(a = p0) + } +) } fun testVararg(): String { @@ -63,9 +66,15 @@ fun testImportedObjectMember(): String { } fun testDefault0(): String { - return use0(fn = ::fnWithDefaults) + return use0(fn = local fun fnWithDefaults(): String { + return fnWithDefaults() + } +) } fun testVararg0(): String { - return use0(fn = ::fnWithVarargs) + return use0(fn = local fun fnWithVarargs(): String { + return fnWithVarargs() + } +) } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.txt index d9b00022000..c37272be7a3 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.txt @@ -67,7 +67,13 @@ FILE fqName: fileName:/withAdaptedArguments.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testDefault (): kotlin.String declared in ' CALL 'public final fun use (fn: kotlin.Function1): kotlin.String declared in ' type=kotlin.String origin=null - fn: FUNCTION_REFERENCE 'public final fun fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= + fn: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnWithDefault visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.String + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun fnWithDefault (p0: kotlin.Int): kotlin.String declared in .testDefault' + CALL 'public final fun fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null + a: GET_VAR 'p0: kotlin.Int declared in .testDefault.fnWithDefault' type=kotlin.Int origin=null FUN name:testVararg visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testVararg (): kotlin.String declared in ' @@ -109,9 +115,17 @@ FILE fqName: fileName:/withAdaptedArguments.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testDefault0 (): kotlin.String declared in ' CALL 'public final fun use0 (fn: kotlin.Function0): kotlin.String declared in ' type=kotlin.String origin=null - fn: FUNCTION_REFERENCE 'public final fun fnWithDefaults (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + fn: FUN_EXPR type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnWithDefaults visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun fnWithDefaults (): kotlin.String declared in .testDefault0' + CALL 'public final fun fnWithDefaults (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null FUN name:testVararg0 visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testVararg0 (): kotlin.String declared in ' CALL 'public final fun use0 (fn: kotlin.Function0): kotlin.String declared in ' type=kotlin.String origin=null - fn: FUNCTION_REFERENCE 'public final fun fnWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + fn: FUN_EXPR type=kotlin.Function0 origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnWithVarargs visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun fnWithVarargs (): kotlin.String declared in .testVararg0' + CALL 'public final fun fnWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt index b124b6438db..6d71b1eb0ad 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt @@ -48,5 +48,8 @@ fun testArrayAsVararg() { } fun testArrayAndDefaults() { - useStringArray(fn = ::zap) + useStringArray(fn = local fun zap(p0: Array) { + zap(b = [*p0]) + } +) } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.txt index bfeb06966e0..02ca2409cea 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.txt @@ -82,4 +82,11 @@ FILE fqName: fileName:/withVarargViewedAsArray.kt FUN name:testArrayAndDefaults visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun useStringArray (fn: kotlin.Function1, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUNCTION_REFERENCE 'public final fun zap (vararg b: kotlin.String, k: kotlin.Int): kotlin.Unit declared in ' type=kotlin.reflect.KFunction1, kotlin.Unit> origin=null reflectionTarget= + fn: FUN_EXPR type=kotlin.Function1, kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:zap visibility:local modality:FINAL <> (p0:kotlin.Array) returnType:kotlin.Unit + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Array + BLOCK_BODY + CALL 'public final fun zap (vararg b: kotlin.String, k: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=null + b: VARARG type=kotlin.Array varargElementType=kotlin.String + SPREAD_ELEMENT + GET_VAR 'p0: kotlin.Array declared in .testArrayAndDefaults.zap' type=kotlin.Array origin=null From fa0f967c8338acc157aa8cc20b8332077287e029 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 15 Feb 2021 12:55:28 +0300 Subject: [PATCH 143/368] FIR2IR: support adapted references for constructors --- .../backend/generators/AdapterGenerator.kt | 19 +++++----- .../generators/CallAndReferenceGenerator.kt | 15 ++------ ...oReflectionForAdaptedCallableReferences.kt | 1 - ...CallableReferencesWithSuspendConversion.kt | 1 - ...constructorWithAdaptedArguments.fir.kt.txt | 22 +++++++++-- .../constructorWithAdaptedArguments.fir.txt | 37 ++++++++++++++++--- .../callableReferences/kt37131.fir.kt.txt | 5 ++- .../callableReferences/kt37131.fir.txt | 6 ++- 8 files changed, 74 insertions(+), 32 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt index b17d0bceec7..8c87459170a 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt @@ -112,7 +112,7 @@ internal class AdapterGenerator( adapteeSymbol: IrFunctionSymbol, type: IrSimpleType ): IrExpression { - val firAdaptee = callableReferenceAccess.toResolvedCallableReference()?.resolvedSymbol?.fir as? FirSimpleFunction + val firAdaptee = callableReferenceAccess.toResolvedCallableReference()?.resolvedSymbol?.fir as? FirFunction val adaptee = adapteeSymbol.owner val expectedReturnType = type.arguments.last().typeOrNull return callableReferenceAccess.convertWithOffsets { startOffset, endOffset -> @@ -164,7 +164,7 @@ internal class AdapterGenerator( callableReferenceAccess: FirCallableReferenceAccess, startOffset: Int, endOffset: Int, - firAdaptee: FirSimpleFunction, + firAdaptee: FirFunction<*>, adaptee: IrFunction, type: IrSimpleType, boundDispatchReceiver: IrExpression?, @@ -172,6 +172,7 @@ internal class AdapterGenerator( ): IrSimpleFunction { val returnType = type.arguments.last().typeOrNull!! val parameterTypes = type.arguments.dropLast(1).map { it.typeOrNull!! } + val firMemberAdaptee = firAdaptee as FirMemberDeclaration return irFactory.createFunction( startOffset, endOffset, IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE, @@ -180,13 +181,13 @@ internal class AdapterGenerator( DescriptorVisibilities.LOCAL, Modality.FINAL, returnType, - isInline = firAdaptee.isInline, - isExternal = firAdaptee.isExternal, - isTailrec = firAdaptee.isTailRec, - isSuspend = firAdaptee.isSuspend || type.isSuspendFunction(), - isOperator = firAdaptee.isOperator, - isInfix = firAdaptee.isInfix, - isExpect = firAdaptee.isExpect, + isInline = firMemberAdaptee.isInline, + isExternal = firMemberAdaptee.isExternal, + isTailrec = firMemberAdaptee.isTailRec, + isSuspend = firMemberAdaptee.isSuspend || type.isSuspendFunction(), + isOperator = firMemberAdaptee.isOperator, + isInfix = firMemberAdaptee.isInfix, + isExpect = firMemberAdaptee.isExpect, isFakeOverride = false ).also { irAdapterFunction -> irAdapterFunction.metadata = FirMetadataSource.Function(firAdaptee) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index 77205c24102..4e98df5a288 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -122,16 +122,6 @@ class CallAndReferenceGenerator( origin ) } - is IrConstructorSymbol -> { - val constructor = symbol.owner - val klass = constructor.parent as? IrClass - IrFunctionReferenceImpl( - startOffset, endOffset, type, symbol, - typeArgumentsCount = constructor.typeParameters.size + (klass?.typeParameters?.size ?: 0), - valueArgumentsCount = constructor.valueParameters.size, - reflectionTarget = symbol - ) - } is IrFunctionSymbol -> { assert(type.isFunctionTypeOrSubtype()) { "Callable reference whose symbol refers to a function should be of functional type." @@ -144,9 +134,12 @@ class CallAndReferenceGenerator( generateAdaptedCallableReference(callableReferenceAccess, explicitReceiverExpression, symbol, adaptedType) } } else { + val klass = function.parent as? IrClass + val typeArgumentCount = function.typeParameters.size + + if (function is IrConstructor) klass?.typeParameters?.size ?: 0 else 0 IrFunctionReferenceImpl( startOffset, endOffset, type, symbol, - typeArgumentsCount = function.typeParameters.size, + typeArgumentsCount = typeArgumentCount, valueArgumentsCount = function.valueParameters.size, reflectionTarget = symbol ) diff --git a/compiler/testData/codegen/box/callableReference/adaptedReferences/noReflectionForAdaptedCallableReferences.kt b/compiler/testData/codegen/box/callableReference/adaptedReferences/noReflectionForAdaptedCallableReferences.kt index 3d1f52642a1..893eefb0a03 100644 --- a/compiler/testData/codegen/box/callableReference/adaptedReferences/noReflectionForAdaptedCallableReferences.kt +++ b/compiler/testData/codegen/box/callableReference/adaptedReferences/noReflectionForAdaptedCallableReferences.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME import kotlin.reflect.KCallable diff --git a/compiler/testData/codegen/box/callableReference/adaptedReferences/noReflectionForAdaptedCallableReferencesWithSuspendConversion.kt b/compiler/testData/codegen/box/callableReference/adaptedReferences/noReflectionForAdaptedCallableReferencesWithSuspendConversion.kt index 4a4f2e8f344..e9deaa41c8a 100644 --- a/compiler/testData/codegen/box/callableReference/adaptedReferences/noReflectionForAdaptedCallableReferencesWithSuspendConversion.kt +++ b/compiler/testData/codegen/box/callableReference/adaptedReferences/noReflectionForAdaptedCallableReferencesWithSuspendConversion.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +SuspendConversion // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME import kotlin.reflect.KCallable diff --git a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.kt.txt index d4ac82252f5..f0d6fc7435b 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.kt.txt @@ -30,13 +30,29 @@ class Outer { } fun testConstructor(): Any { - return use(fn = C::) + return use(fn = local fun (p0: Int): C { + return C(xs = [p0]) + } +) } fun testInnerClassConstructor(outer: Outer): Any { - return use(fn = outer::) + return use(fn = { // BLOCK + local fun Outer.(p0: Int): Inner { + return receiver.Inner(xs = [p0]) + } + + outer:: + }) } fun testInnerClassConstructorCapturingOuter(): Any { - return use(fn = Outer()::) + return use(fn = { // BLOCK + local fun Outer.(p0: Int): Inner { + return receiver.Inner(xs = [p0]) + } + + Outer():: + }) } + diff --git a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.txt index 22d99c69903..82ebbb6d5a9 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.txt @@ -70,17 +70,44 @@ FILE fqName: fileName:/constructorWithAdaptedArguments.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testConstructor (): kotlin.Any declared in ' CALL 'public final fun use (fn: kotlin.Function1): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: FUNCTION_REFERENCE 'public constructor (vararg xs: kotlin.Int) [primary] declared in .C' type=kotlin.reflect.KFunction1.C> origin=null reflectionTarget= + fn: FUN_EXPR type=kotlin.Function1.C> origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:.C + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (p0: kotlin.Int): .C declared in .testConstructor' + CONSTRUCTOR_CALL 'public constructor (vararg xs: kotlin.Int) [primary] declared in .C' type=.C origin=null + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .testConstructor.' type=kotlin.Int origin=null FUN name:testInnerClassConstructor visibility:public modality:FINAL <> (outer:.Outer) returnType:kotlin.Any VALUE_PARAMETER name:outer index:0 type:.Outer BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testInnerClassConstructor (outer: .Outer): kotlin.Any declared in ' CALL 'public final fun use (fn: kotlin.Function1): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: FUNCTION_REFERENCE 'public constructor (vararg xs: kotlin.Int) [primary] declared in .Outer.Inner' type=kotlin.reflect.KFunction1.Outer.Inner> origin=null reflectionTarget= - $this: GET_VAR 'outer: .Outer declared in .testInnerClassConstructor' type=.Outer origin=null + fn: BLOCK type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> ($receiver:.Outer, p0:kotlin.Int) returnType:.Outer.Inner + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Outer + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructor' + CONSTRUCTOR_CALL 'public constructor (vararg xs: kotlin.Int) [primary] declared in .Outer.Inner' type=.Outer.Inner origin=null + $outer: GET_VAR 'receiver: .Outer declared in .testInnerClassConstructor.' type=.Outer origin=ADAPTED_FUNCTION_REFERENCE + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .testInnerClassConstructor.' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructor' type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: GET_VAR 'outer: .Outer declared in .testInnerClassConstructor' type=.Outer origin=null FUN name:testInnerClassConstructorCapturingOuter visibility:public modality:FINAL <> () returnType:kotlin.Any BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testInnerClassConstructorCapturingOuter (): kotlin.Any declared in ' CALL 'public final fun use (fn: kotlin.Function1): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: FUNCTION_REFERENCE 'public constructor (vararg xs: kotlin.Int) [primary] declared in .Outer.Inner' type=kotlin.reflect.KFunction1.Outer.Inner> origin=null reflectionTarget= - $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Outer' type=.Outer origin=null + fn: BLOCK type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> ($receiver:.Outer, p0:kotlin.Int) returnType:.Outer.Inner + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Outer + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructorCapturingOuter' + CONSTRUCTOR_CALL 'public constructor (vararg xs: kotlin.Int) [primary] declared in .Outer.Inner' type=.Outer.Inner origin=null + $outer: GET_VAR 'receiver: .Outer declared in .testInnerClassConstructorCapturingOuter.' type=.Outer origin=ADAPTED_FUNCTION_REFERENCE + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .testInnerClassConstructorCapturingOuter.' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructorCapturingOuter' type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Outer' type=.Outer origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.kt.txt index eda7defdd2c..1ee61feeda0 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.kt.txt @@ -27,5 +27,8 @@ fun testFn(): Any { } fun testCtor(): Any { - return use(fn = C::) + return use(fn = local fun (): C { + return C() + } +) } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.txt index 31909678561..af4140b63a2 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/kt37131.fir.txt @@ -58,4 +58,8 @@ FILE fqName: fileName:/kt37131.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testCtor (): kotlin.Any declared in ' CALL 'public final fun use (fn: kotlin.Function0): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: FUNCTION_REFERENCE 'public constructor (x: kotlin.String) [primary] declared in .C' type=kotlin.reflect.KFunction0<.C> origin=null reflectionTarget= + fn: FUN_EXPR type=kotlin.Function0<.C> origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> () returnType:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): .C declared in .testCtor' + CONSTRUCTOR_CALL 'public constructor (x: kotlin.String) [primary] declared in .C' type=.C origin=null From b262d09a81bf20ffd71db18a0c24ac4f61fa151c Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Mon, 15 Feb 2021 15:49:14 +0300 Subject: [PATCH 144/368] JVM_IR KT-44627 fix bridge signature for parameter with primitive bound --- .../jvm/codegen/MethodSignatureMapper.kt | 4 ++- .../backend/jvm/lower/BridgeLowering.kt | 23 ++++++++++------ .../overrideWithPrimitiveUpperBound.kt | 5 ++++ .../overrideWithPrimitiveUpperBound.txt | 27 +++++++++++++++++++ .../overrideWithPrimitiveUpperBound2.kt | 5 ++++ .../overrideWithPrimitiveUpperBound2.txt | 26 ++++++++++++++++++ .../codegen/BytecodeListingTestGenerated.java | 10 +++++++ .../ir/IrBytecodeListingTestGenerated.java | 10 +++++++ 8 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound.kt create mode 100644 compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound.txt create mode 100644 compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound2.kt create mode 100644 compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound2.txt diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt index ab1e9090d9a..09fb473e718 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt @@ -198,7 +198,9 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { // See also: KotlinTypeMapper.forceBoxedReturnType private fun forceBoxedReturnType(function: IrFunction): Boolean = - isBoxMethodForInlineClass(function) || forceFoxedReturnTypeOnOverride(function) || forceBoxedReturnTypeOnDefaultImplFun(function) || + isBoxMethodForInlineClass(function) || + forceFoxedReturnTypeOnOverride(function) || + forceBoxedReturnTypeOnDefaultImplFun(function) || function.isFromJava() && function.returnType.isInlined() private fun forceFoxedReturnTypeOnOverride(function: IrFunction) = diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt index 063805baf08..ccbb511e39d 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt @@ -428,17 +428,24 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass copyParametersWithErasure(this@addBridge, bridge.overridden) body = context.createIrBuilder(symbol, startOffset, endOffset).run { irExprBody(delegatingCall(this@apply, target)) } - // The generated bridge method overrides all of the symbols which were overridden by its overrides. - // This is technically wrong, but it's necessary to generate a method which maps to the same signature. - val inheritedOverrides = bridge.overriddenSymbols.flatMapTo(mutableSetOf()) { function -> - function.owner.safeAs()?.overriddenSymbols ?: emptyList() + if (!bridge.overridden.returnType.isTypeParameterWithPrimitiveUpperBound()) { + // The generated bridge method overrides all of the symbols which were overridden by its overrides. + // This is technically wrong, but it's necessary to generate a method which maps to the same signature. + // In case of 'fun foo(): T', where 'T' is a type parameter with primitive upper bound (e.g., 'T : Char'), + // 'foo' is mapped to 'foo()C', regardless of its overrides. + val inheritedOverrides = bridge.overriddenSymbols.flatMapTo(mutableSetOf()) { function -> + function.owner.safeAs()?.overriddenSymbols ?: emptyList() + } + val redundantOverrides = inheritedOverrides.flatMapTo(mutableSetOf()) { + it.owner.allOverridden().map { override -> override.symbol } + } + overriddenSymbols = inheritedOverrides.filter { it !in redundantOverrides } } - val redundantOverrides = inheritedOverrides.flatMapTo(mutableSetOf()) { - it.owner.allOverridden().map { override -> override.symbol } - } - overriddenSymbols = inheritedOverrides.filter { it !in redundantOverrides } } + private fun IrType.isTypeParameterWithPrimitiveUpperBound(): Boolean = + isTypeParameter() && eraseTypeParameters().isPrimitiveType() + private fun IrClass.addSpecialBridge(specialBridge: SpecialBridge, target: IrSimpleFunction): IrSimpleFunction = addFunction { startOffset = this@addSpecialBridge.startOffset diff --git a/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound.kt b/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound.kt new file mode 100644 index 00000000000..54d4e76009b --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound.kt @@ -0,0 +1,5 @@ +open class ATChar(open var x: T) + +open class BTChar(override var x: T) : ATChar(x) + +class CChar(override var x: Char) : BTChar('x') diff --git a/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound.txt b/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound.txt new file mode 100644 index 00000000000..18c03ddc333 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound.txt @@ -0,0 +1,27 @@ +@kotlin.Metadata +public class ATChar { + // source: 'overrideWithPrimitiveUpperBound.kt' + private field x: char + public method (p0: char): void + public method getX(): char + public method setX(p0: char): void +} + +@kotlin.Metadata +public class BTChar { + // source: 'overrideWithPrimitiveUpperBound.kt' + private field x: char + public method (p0: char): void + public method getX(): char + public method setX(p0: char): void +} + +@kotlin.Metadata +public final class CChar { + // source: 'overrideWithPrimitiveUpperBound.kt' + private field x: char + public method (p0: char): void + public synthetic bridge method getX(): char + public @org.jetbrains.annotations.NotNull method getX(): java.lang.Character + public method setX(p0: char): void +} diff --git a/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound2.kt b/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound2.kt new file mode 100644 index 00000000000..e381f4327f4 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound2.kt @@ -0,0 +1,5 @@ +open class ATAny(open val x: T) + +open class BTChar(override val x: T) : ATAny(x) + +class CChar(override val x: Char) : BTChar('x') diff --git a/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound2.txt b/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound2.txt new file mode 100644 index 00000000000..b1d72d7162e --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound2.txt @@ -0,0 +1,26 @@ +@kotlin.Metadata +public class ATAny { + // source: 'overrideWithPrimitiveUpperBound2.kt' + private final field x: java.lang.Object + public method (p0: java.lang.Object): void + public method getX(): java.lang.Object +} + +@kotlin.Metadata +public class BTChar { + // source: 'overrideWithPrimitiveUpperBound2.kt' + private final field x: char + public method (p0: char): void + public method getX(): char + public synthetic bridge method getX(): java.lang.Object +} + +@kotlin.Metadata +public final class CChar { + // source: 'overrideWithPrimitiveUpperBound2.kt' + private final field x: char + public method (p0: char): void + public synthetic bridge method getX(): char + public @org.jetbrains.annotations.NotNull method getX(): java.lang.Character + public synthetic bridge method getX(): java.lang.Object +} diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index 40454e58f67..9bbc74d2da6 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -215,6 +215,16 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/noRemoveAtInReadOnly.kt"); } + @TestMetadata("overrideWithPrimitiveUpperBound.kt") + public void testOverrideWithPrimitiveUpperBound() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound.kt"); + } + + @TestMetadata("overrideWithPrimitiveUpperBound2.kt") + public void testOverrideWithPrimitiveUpperBound2() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound2.kt"); + } + @TestMetadata("privateCompanionFields.kt") public void testPrivateCompanionFields() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/privateCompanionFields.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index 8e298304579..3c3bc80545c 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -215,6 +215,16 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/noRemoveAtInReadOnly.kt"); } + @TestMetadata("overrideWithPrimitiveUpperBound.kt") + public void testOverrideWithPrimitiveUpperBound() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound.kt"); + } + + @TestMetadata("overrideWithPrimitiveUpperBound2.kt") + public void testOverrideWithPrimitiveUpperBound2() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/overrideWithPrimitiveUpperBound2.kt"); + } + @TestMetadata("privateCompanionFields.kt") public void testPrivateCompanionFields() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/privateCompanionFields.kt"); From 6d2465d00cd3e82b5494c0cb4d951356eefb2b92 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Thu, 4 Feb 2021 14:54:57 +0100 Subject: [PATCH 145/368] Update Gradle version for tests to 6.8.1. --- .../kotlin-gradle-plugin-integration-tests/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts index e8d6c910297..60c89d7c839 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts @@ -79,7 +79,7 @@ fun Test.includeNative(include: Boolean) { } fun Test.advanceGradleVersion() { - val gradleVersionForTests = "6.3" + val gradleVersionForTests = "6.8.1" systemProperty("kotlin.gradle.version.for.tests", gradleVersionForTests) } From 6c0ee2f9eaaad6cb9a879a1c62648109af94806b Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Fri, 5 Feb 2021 13:28:35 +0100 Subject: [PATCH 146/368] Update test to use new test xml output format. This format was slightly changed starting Gradle 6.6. Adapted tests to use new expected output when current Gradle runner is greater then 6.5. --- .../kotlin/gradle/Kotlin2JsGradlePluginIT.kt | 9 +++- .../kotlin/gradle/NewMultiplatformIT.kt | 13 +++++- .../kotlin/gradle/native/GeneralNativeIT.kt | 23 ++++++++-- .../kotlin-js-plugin-project/tests.xml | 13 +++--- .../kotlin-js-plugin-project/tests_pre6.6.xml | 9 ++++ .../native-tests/TEST-TestKit-iOSsim.xml | 16 +++++++ ...Ssim.xml => TEST-TestKt-iOSsim_pre6.6.xml} | 0 .../testProject/native-tests/TEST-TestKt.xml | 6 +-- .../native-tests/TEST-TestKt_pre6.6.xml | 14 ++++++ .../TEST-all-pre6.6.xml | 43 +++++++++++++++++++ .../new-mpp-lib-with-tests/TEST-all.xml | 10 ++--- 11 files changed, 136 insertions(+), 20 deletions(-) create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/tests_pre6.6.xml create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKit-iOSsim.xml rename libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/{TEST-TestKt-iOSsim.xml => TEST-TestKt-iOSsim_pre6.6.xml} (100%) create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKt_pre6.6.xml create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-with-tests/TEST-all-pre6.6.xml diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt index 50b73a400da..9b22611c856 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kotlin2JsGradlePluginIT.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.gradle import com.google.gson.Gson import org.gradle.api.logging.LogLevel import org.gradle.api.logging.configuration.WarningMode +import org.gradle.util.GradleVersion import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.targets.js.ir.KLIB_TYPE import org.jetbrains.kotlin.gradle.targets.js.npm.* @@ -541,7 +542,13 @@ abstract class AbstractKotlin2JsGradlePluginIT(val irBackend: Boolean) : BaseGra assertFileExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js") assertFileExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js.map") - assertTestResults("testProject/kotlin-js-plugin-project/tests.xml", "nodeTest") + // Gradle 6.6+ slightly changed format of xml test results + val testGradleVersion = GradleVersion.version(project.chooseWrapperVersionOrFinishTest()) + if (testGradleVersion < GradleVersion.version("6.6")) { + assertTestResults("testProject/kotlin-js-plugin-project/tests_pre6.6.xml", "nodeTest") + } else { + assertTestResults("testProject/kotlin-js-plugin-project/tests.xml", "nodeTest") + } } } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt index 169c996a960..46a59975511 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.checkNativeCommandLineArguments import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.containsSequentially import org.gradle.api.logging.configuration.WarningMode +import org.gradle.util.GradleVersion import org.jetbrains.kotlin.gradle.native.MPPNativeTargets import org.jetbrains.kotlin.gradle.native.configureMemoryInGradleProperties import org.jetbrains.kotlin.gradle.native.transformNativeTestProject @@ -672,8 +673,18 @@ class NewMultiplatformIT : BaseGradleIT() { expectedKotlinOutputFiles.forEach { assertFileExists(it) } + // Gradle 6.6+ slightly changed format of xml test results + // If, in the test project, preset name was updated, + // update accordingly test result output for Gradle 6.6+ + val testGradleVersion = chooseWrapperVersionOrFinishTest() + val expectedTestResults = if (GradleVersion.version(testGradleVersion) < GradleVersion.version("6.6")) { + "testProject/new-mpp-lib-with-tests/TEST-all-pre6.6.xml" + } else { + "testProject/new-mpp-lib-with-tests/TEST-all.xml" + } + assertTestResults( - "testProject/new-mpp-lib-with-tests/TEST-all.xml", + expectedTestResults, "jsNodeTest", "test", // jvmTest "${nativeHostTargetName}Test" diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt index a3a0697038e..4536e605559 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/GeneralNativeIT.kt @@ -6,9 +6,11 @@ package org.jetbrains.kotlin.gradle.native import com.intellij.testFramework.TestDataFile +import org.gradle.util.GradleVersion import org.jdom.input.SAXBuilder import org.jetbrains.kotlin.gradle.BaseGradleIT import org.jetbrains.kotlin.gradle.GradleVersionRequired +import org.jetbrains.kotlin.gradle.chooseWrapperVersionOrFinishTest import org.jetbrains.kotlin.gradle.internals.DISABLED_NATIVE_TARGETS_REPORTER_DISABLE_WARNING_PROPERTY_NAME import org.jetbrains.kotlin.gradle.internals.DISABLED_NATIVE_TARGETS_REPORTER_WARNING_PREFIX import org.jetbrains.kotlin.gradle.internals.NO_NATIVE_STDLIB_PROPERTY_WARNING @@ -678,14 +680,29 @@ class GeneralNativeIT : BaseGradleIT() { } } - assertTestResults("testProject/native-tests/TEST-TestKt.xml", hostTestTask) + // Gradle 6.6+ slightly changed format of xml test results + // If, in the test project, preset name was updated, + // update accordingly test result output for Gradle6.6+ + val testGradleVersion = project.chooseWrapperVersionOrFinishTest() + val expectedTestResults = if (GradleVersion.version(testGradleVersion) < GradleVersion.version("6.6")) { + listOf( + "testProject/native-tests/TEST-TestKt_pre6.6.xml", + "testProject/native-tests/TEST-TestKt-IOSsim_pre6.6.xml", + ) + } else { + listOf( + "testProject/native-tests/TEST-TestKt.xml", + "testProject/native-tests/TEST-TestKt-IOSsim.xml", + ) + } + assertTestResults(expectedTestResults.first(), hostTestTask) // K/N doesn't report line numbers correctly on Linux (see KT-35408). // TODO: Uncomment when this is fixed. //assertStacktrace(hostTestTask) if (hostIsMac) { assertTestResultsAnyOf( - "testProject/native-tests/TEST-TestKt.xml", - "testProject/native-tests/TEST-TestKt-IOSsim.xml", + expectedTestResults[0], + expectedTestResults[1], "iosTest" ) assertStacktrace("iosTest") diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/tests.xml b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/tests.xml index f6ab85a398a..b40db1b24fa 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/tests.xml +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/tests.xml @@ -1,10 +1,9 @@ - - - - - - + + + + + + - diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/tests_pre6.6.xml b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/tests_pre6.6.xml new file mode 100644 index 00000000000..23f889c00c0 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin-js-plugin-project/tests_pre6.6.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKit-iOSsim.xml b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKit-iOSsim.xml new file mode 100644 index 00000000000..c52f4e18616 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKit-iOSsim.xml @@ -0,0 +1,16 @@ + + + + + + + + ... + + + + + \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKt-iOSsim.xml b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKt-iOSsim_pre6.6.xml similarity index 100% rename from libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKt-iOSsim.xml rename to libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKt-iOSsim_pre6.6.xml diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKt.xml b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKt.xml index 41626ade0ba..e3f25180468 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKt.xml +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-tests/TEST-TestKt.xml @@ -2,9 +2,9 @@ - - - + + + ... + + + + + + + ... + + + + + \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-with-tests/TEST-all-pre6.6.xml b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-with-tests/TEST-all-pre6.6.xml new file mode 100644 index 00000000000..1d5e0d73d4c --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-with-tests/TEST-all-pre6.6.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-with-tests/TEST-all.xml b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-with-tests/TEST-all.xml index 1d5e0d73d4c..5962d0abbe9 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-with-tests/TEST-all.xml +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-lib-with-tests/TEST-all.xml @@ -2,8 +2,8 @@ - - + + @@ -16,8 +16,8 @@ - - + + @@ -29,7 +29,7 @@ - + From 9d9df0c4ffc454e1e0e065b866f0b61823c63117 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Fri, 5 Feb 2021 15:39:46 +0100 Subject: [PATCH 147/368] Expect new attributes compatibility error. Since Gradle 6.4 error message was changed, when dependency does not provide all required attributes. --- .../kotlin/gradle/KotlinGradlePluginIT.kt | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt index 2811bef9603..b0ea34716ce 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.gradle import org.gradle.api.logging.LogLevel import org.gradle.api.logging.configuration.WarningMode +import org.gradle.util.GradleVersion import org.jetbrains.kotlin.gradle.plugin.MULTIPLE_KOTLIN_PLUGINS_LOADED_WARNING import org.jetbrains.kotlin.gradle.plugin.MULTIPLE_KOTLIN_PLUGINS_SPECIFIC_PROJECTS_WARNING import org.jetbrains.kotlin.gradle.scripting.internal.ScriptingGradleSubplugin @@ -978,12 +979,26 @@ class KotlinGradleIT : BaseGradleIT() { build(":projB:compileKotlin") { assertSuccessful() } + + val projectGradleVersion = GradleVersion.version(chooseWrapperVersionOrFinishTest()) // Break dependency resolution by providing incompatible custom attributes in the target: gradleBuildScript("projB").appendText("\nkotlin.target.attributes.attribute(targetAttribute, \"bar\")") build(":projB:compileKotlin") { assertFailed() - assertContains("Required com.example.target 'bar'") + if (projectGradleVersion < GradleVersion.version("6.4")) { + assertContains("Required com.example.target 'bar'") + } else { + assertContains( + "No matching variant of project :projA was found. The consumer was configured to find an API of a library " + + "compatible with Java 8, preferably in the form of class files, " + + "and its dependencies declared externally, " + + "as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm', " + + "attribute 'com.example.compilation' with value 'foo', " + + "attribute 'com.example.target' with value 'bar' but:" + ) + } } + // And using the compilation attributes (fix the target attributes first): gradleBuildScript("projB").appendText( "\n" + """ @@ -993,7 +1008,18 @@ class KotlinGradleIT : BaseGradleIT() { ) build(":projB:compileKotlin") { assertFailed() - assertContains("Required com.example.compilation 'bar'") + val projectGradleVersion = project.chooseWrapperVersionOrFinishTest() + if (GradleVersion.version(projectGradleVersion) < GradleVersion.version("6.4")) { + assertContains("Required com.example.compilation 'bar'") + } else { + assertContains( + "No matching variant of project :projA was found. The consumer was configured to find an API of a library " + + "compatible with Java 8, preferably in the form of class files, and its dependencies declared externally, " + + "as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm', " + + "attribute 'com.example.compilation' with value 'bar', " + + "attribute 'com.example.target' with value 'foo' but:" + ) + } } } From 224aea095302bade6792192645719ce818e650a5 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Fri, 12 Feb 2021 14:17:48 +0100 Subject: [PATCH 148/368] Ignore test due to the bug in AGP on Gradle 6.8+. It is not possible to make it work via reflection. --- .../AbstractKotlinAndroidGradleTests.kt | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt index 9074011f5ed..a1b4662008a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt @@ -2,8 +2,8 @@ package org.jetbrains.kotlin.gradle import org.gradle.api.logging.LogLevel import org.gradle.api.logging.configuration.WarningMode +import org.gradle.util.GradleVersion import org.jetbrains.kotlin.gradle.util.* -import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.util.KtTestUtil import org.junit.Assume import org.junit.Test @@ -24,33 +24,41 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() { get() = GradleVersionRequired.AtLeast("6.0") @Test - fun testAndroidMppSourceSets(): Unit = with(Project("new-mpp-android-source-sets")) { - build("sourceSets") { - assertSuccessful() + fun testAndroidMppSourceSets(): Unit = with( + Project("new-mpp-android-source-sets") + ) { + // AbstractReportTask#generate() task action was removed in Gradle 6.8+, + // that SourceSetTask is using: https://github.com/gradle/gradle/commit/4dac91ab87ea33ee8689d2a62b691b119198e7c7 + // leading to the issue that ":sourceSets" task is always in 'UP-TO-DATE' state. + // Skipping this check until test will start using AGP 7.0-alpha03+ + if (GradleVersion.version(chooseWrapperVersionOrFinishTest()) < GradleVersion.version("6.8")) { + build("sourceSets", options = defaultBuildOptions().copy(debug = true)) { + assertSuccessful() - assertContains("Android resources: [lib/src/main/res, lib/src/androidMain/res]") - assertContains("Assets: [lib/src/main/assets, lib/src/androidMain/assets]") - assertContains("AIDL sources: [lib/src/main/aidl, lib/src/androidMain/aidl]") - assertContains("RenderScript sources: [lib/src/main/rs, lib/src/androidMain/rs]") - assertContains("JNI sources: [lib/src/main/jni, lib/src/androidMain/jni]") - assertContains("JNI libraries: [lib/src/main/jniLibs, lib/src/androidMain/jniLibs]") - assertContains("Java-style resources: [lib/src/main/resources, lib/src/androidMain/resources]") + assertContains("Android resources: [lib/src/main/res, lib/src/androidMain/res]") + assertContains("Assets: [lib/src/main/assets, lib/src/androidMain/assets]") + assertContains("AIDL sources: [lib/src/main/aidl, lib/src/androidMain/aidl]") + assertContains("RenderScript sources: [lib/src/main/rs, lib/src/androidMain/rs]") + assertContains("JNI sources: [lib/src/main/jni, lib/src/androidMain/jni]") + assertContains("JNI libraries: [lib/src/main/jniLibs, lib/src/androidMain/jniLibs]") + assertContains("Java-style resources: [lib/src/main/resources, lib/src/androidMain/resources]") - assertContains("Android resources: [lib/src/androidTestDebug/res, lib/src/androidAndroidTestDebug/res]") - assertContains("Assets: [lib/src/androidTestDebug/assets, lib/src/androidAndroidTestDebug/assets]") - assertContains("AIDL sources: [lib/src/androidTestDebug/aidl, lib/src/androidAndroidTestDebug/aidl]") - assertContains("RenderScript sources: [lib/src/androidTestDebug/rs, lib/src/androidAndroidTestDebug/rs]") - assertContains("JNI sources: [lib/src/androidTestDebug/jni, lib/src/androidAndroidTestDebug/jni]") - assertContains("JNI libraries: [lib/src/androidTestDebug/jniLibs, lib/src/androidAndroidTestDebug/jniLibs]") - assertContains("Java-style resources: [lib/src/androidTestDebug/resources, lib/src/androidAndroidTestDebug/resources]") + assertContains("Android resources: [lib/src/androidTestDebug/res, lib/src/androidAndroidTestDebug/res]") + assertContains("Assets: [lib/src/androidTestDebug/assets, lib/src/androidAndroidTestDebug/assets]") + assertContains("AIDL sources: [lib/src/androidTestDebug/aidl, lib/src/androidAndroidTestDebug/aidl]") + assertContains("RenderScript sources: [lib/src/androidTestDebug/rs, lib/src/androidAndroidTestDebug/rs]") + assertContains("JNI sources: [lib/src/androidTestDebug/jni, lib/src/androidAndroidTestDebug/jni]") + assertContains("JNI libraries: [lib/src/androidTestDebug/jniLibs, lib/src/androidAndroidTestDebug/jniLibs]") + assertContains("Java-style resources: [lib/src/androidTestDebug/resources, lib/src/androidAndroidTestDebug/resources]") - assertContains("Java-style resources: [lib/betaSrc/paidBeta/resources, lib/src/androidPaidBeta/resources]") - assertContains("Java-style resources: [lib/betaSrc/paidBetaDebug/resources, lib/src/androidPaidBetaDebug/resources]") - assertContains("Java-style resources: [lib/betaSrc/paidBetaRelease/resources, lib/src/androidPaidBetaRelease/resources]") + assertContains("Java-style resources: [lib/betaSrc/paidBeta/resources, lib/src/androidPaidBeta/resources]") + assertContains("Java-style resources: [lib/betaSrc/paidBetaDebug/resources, lib/src/androidPaidBetaDebug/resources]") + assertContains("Java-style resources: [lib/betaSrc/paidBetaRelease/resources, lib/src/androidPaidBetaRelease/resources]") - assertContains("Java-style resources: [lib/betaSrc/freeBeta/resources, lib/src/androidFreeBeta/resources]") - assertContains("Java-style resources: [lib/betaSrc/freeBetaDebug/resources, lib/src/androidFreeBetaDebug/resources]") - assertContains("Java-style resources: [lib/betaSrc/freeBetaRelease/resources, lib/src/androidFreeBetaRelease/resources]") + assertContains("Java-style resources: [lib/betaSrc/freeBeta/resources, lib/src/androidFreeBeta/resources]") + assertContains("Java-style resources: [lib/betaSrc/freeBetaDebug/resources, lib/src/androidFreeBetaDebug/resources]") + assertContains("Java-style resources: [lib/betaSrc/freeBetaRelease/resources, lib/src/androidFreeBetaRelease/resources]") + } } build("testFreeBetaDebug") { From 5c7aadece929f79a39bf0ad20549e30d5e391a7c Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Fri, 12 Feb 2021 15:02:30 +0100 Subject: [PATCH 149/368] Fix test founds more lines then expected. Now Gradle additionally prints warning message regarding using debug logs that wrapped in '####*' lines. --- .../org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt index e3a903fd6f2..8d1d3eda094 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt @@ -341,7 +341,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() { build("resolveCustom") { assertSuccessful() - val printedLine = output.lines().single { "###" in it }.substringAfter("###") + val printedLine = output.lines().single { "###[" in it }.substringAfter("###") val items = printedLine.removeSurrounding("[", "]").split(", ") assertTrue(items.toString()) { items.any { "kotlinx-cli-jvm" in it } } } From c63a9afa56fb3d4278689ff229174611145e7c55 Mon Sep 17 00:00:00 2001 From: Andrei Klunnyi Date: Thu, 11 Feb 2021 11:53:31 +0100 Subject: [PATCH 150/368] KT-44839 [Sealed interfaces]: move refactoring for language level < 1.5 This commit restores sealed-check-logic for language level < 1.5 mistakenly removed in 690fb47c. ^KT-44839 fixed --- .../messages/KotlinBundle.properties | 3 ++ .../moveDeclarations/moveConflictUtils.kt | 54 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/idea/resources-en/messages/KotlinBundle.properties b/idea/resources-en/messages/KotlinBundle.properties index 5e6248339db..df5660d2cba 100644 --- a/idea/resources-en/messages/KotlinBundle.properties +++ b/idea/resources-en/messages/KotlinBundle.properties @@ -946,6 +946,9 @@ text.rename.parameters.in.hierarchy.to=Rename parameter in hierarchy to: text.rename.parameters.title=Rename Parameters text.rename.warning=Rename warning +text.0.1.must.be.moved.with.sealed.parent.class.and.all.its.subclasses={0} ''{1}'' must be moved with sealed parent class and all its subclasses +text.sealed.class.0.must.be.moved.with.all.its.subclasses=Sealed class ''{0}'' must be moved with all its subclasses + text.sealed.broken.hierarchy.none.in.target=Sealed hierarchy of ''{0}'' would be split. None of its members reside in the package ''{1}'' of module ''{2}'': {3}. text.sealed.broken.hierarchy.still.in.source=Sealed hierarchy of ''{0}'' would be split. Package ''{1}'' of module ''{2}'' would still contain its members: {3}. diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt index fdcf2b8ca05..63339702a0b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/moveConflictUtils.kt @@ -25,12 +25,14 @@ import com.intellij.refactoring.util.MoveRenameUsageInfo import com.intellij.refactoring.util.NonCodeUsageInfo import com.intellij.refactoring.util.RefactoringUIUtil import com.intellij.usageView.UsageInfo +import com.intellij.usageView.UsageViewTypeLocation import com.intellij.util.containers.MultiMap import org.jetbrains.kotlin.asJava.namedUnwrappedElement import org.jetbrains.kotlin.asJava.toLightClass import org.jetbrains.kotlin.asJava.toLightMethods import org.jetbrains.kotlin.backend.common.serialization.findPackage import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor import org.jetbrains.kotlin.idea.KotlinBundle @@ -50,6 +52,7 @@ import org.jetbrains.kotlin.idea.core.util.toPsiFile import org.jetbrains.kotlin.idea.imports.importableFqName import org.jetbrains.kotlin.idea.project.TargetPlatformDetector import org.jetbrains.kotlin.idea.project.forcedTargetPlatform +import org.jetbrains.kotlin.idea.project.getLanguageVersionSettings import org.jetbrains.kotlin.idea.refactoring.getUsageContext import org.jetbrains.kotlin.idea.refactoring.move.KotlinMoveUsage import org.jetbrains.kotlin.idea.refactoring.pullUp.renderForConflicts @@ -531,6 +534,57 @@ class MoveConflictChecker( } private fun checkSealedClassMove(conflicts: MultiMap) { + val sealedInheritanceRulesRelaxed = + project.getLanguageVersionSettings().supportsFeature(LanguageFeature.AllowSealedInheritorsInDifferentFilesOfSamePackage) + + if (sealedInheritanceRulesRelaxed) + checkSealedClassMoveWithinPackageAndModule(conflicts) + else + checkSealedClassMoveWithinFile(conflicts) + } + + private fun checkSealedClassMoveWithinFile(conflicts: MultiMap) { + val visited = HashSet() + for (elementToMove in elementsToMove) { + if (!visited.add(elementToMove)) continue + if (elementToMove !is KtClassOrObject) continue + + val rootClass: KtClass + val rootClassDescriptor: ClassDescriptor + if (elementToMove is KtClass && elementToMove.isSealed()) { + rootClass = elementToMove + rootClassDescriptor = rootClass.resolveToDescriptorIfAny() ?: return + } else { + val classDescriptor = elementToMove.resolveToDescriptorIfAny() ?: return + val superClassDescriptor = classDescriptor.getSuperClassNotAny() ?: return + if (superClassDescriptor.modality != Modality.SEALED) return + rootClassDescriptor = superClassDescriptor + rootClass = rootClassDescriptor.source.getPsi() as? KtClass ?: return + } + + val subclasses = rootClassDescriptor.sealedSubclasses.mapNotNull { it.source.getPsi() } + if (subclasses.isEmpty()) continue + + visited.add(rootClass) + visited.addAll(subclasses) + + if (isToBeMoved(rootClass) && subclasses.all { isToBeMoved(it) }) continue + + val message = if (elementToMove == rootClass) { + KotlinBundle.message("text.sealed.class.0.must.be.moved.with.all.its.subclasses", rootClass.name.toString()) + } else { + val type = ElementDescriptionUtil.getElementDescription(elementToMove, UsageViewTypeLocation.INSTANCE).capitalize() + KotlinBundle.message( + "text.0.1.must.be.moved.with.sealed.parent.class.and.all.its.subclasses", + type, + rootClass.name.toString() + ) + } + conflicts.putValue(elementToMove, message) + } + } + + private fun checkSealedClassMoveWithinPackageAndModule(conflicts: MultiMap) { val hierarchyChecker = SealedHierarchyChecker() for (elementToMove in elementsToMove) { From eb0c73fd5e9e5b710c82beb8fe0cf9bdc4e99122 Mon Sep 17 00:00:00 2001 From: Andrei Klunnyi Date: Thu, 11 Feb 2021 16:38:06 +0100 Subject: [PATCH 151/368] KT-44839 [Sealed interfaces]: ability to specify compiler options in tests --- .../refactoring/AbstractMultifileRefactoringTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMultifileRefactoringTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMultifileRefactoringTest.kt index 5b598dd1e04..f9f048e4dfe 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMultifileRefactoringTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMultifileRefactoringTest.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.idea.refactoring import com.google.gson.JsonObject import com.google.gson.JsonParser import com.intellij.codeInsight.TargetElementUtil -import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.editor.EditorFactory import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.project.Project @@ -25,11 +24,9 @@ import com.intellij.testFramework.PlatformTestUtil import com.intellij.testFramework.UsefulTestCase import org.jetbrains.kotlin.idea.jsonUtils.getNullableString import org.jetbrains.kotlin.idea.refactoring.rename.loadTestConfiguration -import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase -import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor -import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor -import org.jetbrains.kotlin.idea.test.extractMultipleMarkerOffsets +import org.jetbrains.kotlin.idea.test.* import org.jetbrains.kotlin.test.KotlinTestUtils +import org.jetbrains.kotlin.util.prefixIfNot import java.io.File abstract class AbstractMultifileRefactoringTest : KotlinLightCodeInsightFixtureTestCase() { @@ -56,7 +53,10 @@ abstract class AbstractMultifileRefactoringTest : KotlinLightCodeInsightFixtureT val config = JsonParser().parse(FileUtil.loadFile(testFile, true)) as JsonObject doTestCommittingDocuments(testFile) { rootDir -> - runRefactoring(path, config, rootDir, project) + val opts = config.getNullableString("customCompilerOpts")?.prefixIfNot("// ") ?: "" + withCustomCompilerOptions(opts, project, module) { + runRefactoring(path, config, rootDir, project) + } } } From 53a7dc1126a27d85ab636be8516544ff5fe99d54 Mon Sep 17 00:00:00 2001 From: Andrei Klunnyi Date: Thu, 11 Feb 2021 16:39:30 +0100 Subject: [PATCH 152/368] KT-44839 [Sealed interfaces]: restore move-tests for lang-version < 15 This commit restores tests removed in 690fb47c. --- .../after/source/Foo.kt | 9 +++++++++ .../after/source/dummy.txt | 0 .../after/target/Expr.kt | 3 +++ .../before/source/Foo.kt | 8 ++++++++ .../before/source/dummy.txt | 0 .../conflicts.txt | 1 + .../sealedClassWithSkippedSubclasses.test | 6 ++++++ .../after/source/Foo.kt | 5 +++++ .../after/source/dummy.txt | 0 .../after/target/Const.kt | 5 +++++ .../before/source/Foo.kt | 6 ++++++ .../before/source/dummy.txt | 0 .../sealedSubclassWithSkippedRoot/conflicts.txt | 1 + .../sealedSubclassWithSkippedRoot.test | 6 ++++++ .../after/bar/SealedClass.kt | 5 +++++ .../after/foo/KotlinReferences.kt | 5 +++++ .../after/foo/SealedClass.kt | 5 +++++ .../before/foo/KotlinReferences.kt | 3 +++ .../before/foo/SealedClass.kt | 7 +++++++ .../conflicts.txt | 1 + ...ealedClassWithNestedImplsToAnotherPackage.test | 6 ++++++ .../idea/refactoring/move/MoveTestGenerated.java | 15 +++++++++++++++ 22 files changed, 97 insertions(+) create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/after/source/Foo.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/after/source/dummy.txt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/after/target/Expr.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/before/source/Foo.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/before/source/dummy.txt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/conflicts.txt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/sealedClassWithSkippedSubclasses.test create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/after/source/Foo.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/after/source/dummy.txt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/after/target/Const.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/before/source/Foo.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/before/source/dummy.txt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/conflicts.txt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/sealedSubclassWithSkippedRoot.test create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/bar/SealedClass.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/foo/KotlinReferences.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/foo/SealedClass.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/before/foo/KotlinReferences.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/before/foo/SealedClass.kt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/conflicts.txt create mode 100644 idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/after/source/Foo.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/after/source/Foo.kt new file mode 100644 index 00000000000..7b545ebec3f --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/after/source/Foo.kt @@ -0,0 +1,9 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-AllowSealedInheritorsInDifferentFilesOfSamePackage + +package source + +import target.Expr + +data class Const(val number: Double) : Expr() +data class Sum(val e1: Expr, val e2: Expr) : Expr() +object NotANumber : Expr() \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/after/source/dummy.txt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/after/source/dummy.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/after/target/Expr.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/after/target/Expr.kt new file mode 100644 index 00000000000..2e47c77daa5 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/after/target/Expr.kt @@ -0,0 +1,3 @@ +package target + +sealed class Expr \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/before/source/Foo.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/before/source/Foo.kt new file mode 100644 index 00000000000..d30f0eaaacd --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/before/source/Foo.kt @@ -0,0 +1,8 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-AllowSealedInheritorsInDifferentFilesOfSamePackage + +package source + +sealed class Expr +data class Const(val number: Double) : Expr() +data class Sum(val e1: Expr, val e2: Expr) : Expr() +object NotANumber : Expr() \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/before/source/dummy.txt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/before/source/dummy.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/conflicts.txt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/conflicts.txt new file mode 100644 index 00000000000..756eb0a8202 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/conflicts.txt @@ -0,0 +1 @@ +Sealed class 'Expr' must be moved with all its subclasses diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/sealedClassWithSkippedSubclasses.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/sealedClassWithSkippedSubclasses.test new file mode 100644 index 00000000000..2278113d65c --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/sealedClassWithSkippedSubclasses.test @@ -0,0 +1,6 @@ +{ + "customCompilerOpts": "COMPILER_ARGUMENTS: -XXLanguage:-AllowSealedInheritorsInDifferentFilesOfSamePackage", + "mainFile": "source/Foo.kt", + "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS", + "targetPackage": "target" +} diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/after/source/Foo.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/after/source/Foo.kt new file mode 100644 index 00000000000..bf5d08ed03c --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/after/source/Foo.kt @@ -0,0 +1,5 @@ +package source + +sealed class Expr +data class Sum(val e1: Expr, val e2: Expr) : Expr() +object NotANumber : Expr() \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/after/source/dummy.txt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/after/source/dummy.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/after/target/Const.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/after/target/Const.kt new file mode 100644 index 00000000000..b129fc50628 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/after/target/Const.kt @@ -0,0 +1,5 @@ +package target + +import source.Expr + +data class Const(val number: Double) : Expr() \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/before/source/Foo.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/before/source/Foo.kt new file mode 100644 index 00000000000..737027eefe1 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/before/source/Foo.kt @@ -0,0 +1,6 @@ +package source + +sealed class Expr +data class Const(val number: Double) : Expr() +data class Sum(val e1: Expr, val e2: Expr) : Expr() +object NotANumber : Expr() \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/before/source/dummy.txt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/before/source/dummy.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/conflicts.txt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/conflicts.txt new file mode 100644 index 00000000000..08ad262dd99 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/conflicts.txt @@ -0,0 +1 @@ +Class 'Expr' must be moved with sealed parent class and all its subclasses diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/sealedSubclassWithSkippedRoot.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/sealedSubclassWithSkippedRoot.test new file mode 100644 index 00000000000..2278113d65c --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/sealedSubclassWithSkippedRoot.test @@ -0,0 +1,6 @@ +{ + "customCompilerOpts": "COMPILER_ARGUMENTS: -XXLanguage:-AllowSealedInheritorsInDifferentFilesOfSamePackage", + "mainFile": "source/Foo.kt", + "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS", + "targetPackage": "target" +} diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/bar/SealedClass.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/bar/SealedClass.kt new file mode 100644 index 00000000000..2994bf4dd8f --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/bar/SealedClass.kt @@ -0,0 +1,5 @@ +package bar + +public sealed class SealedClass { + public class Impl1 : SealedClass() {} +} \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/foo/KotlinReferences.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/foo/KotlinReferences.kt new file mode 100644 index 00000000000..a5105b77f32 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/foo/KotlinReferences.kt @@ -0,0 +1,5 @@ +package foo + +import bar.SealedClass + +val v = SealedClass::Impl1 \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/foo/SealedClass.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/foo/SealedClass.kt new file mode 100644 index 00000000000..18534fbbc34 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/after/foo/SealedClass.kt @@ -0,0 +1,5 @@ +package foo + +import bar.SealedClass + +public class Impl2 : SealedClass() {} \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/before/foo/KotlinReferences.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/before/foo/KotlinReferences.kt new file mode 100644 index 00000000000..84b14682a40 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/before/foo/KotlinReferences.kt @@ -0,0 +1,3 @@ +package foo + +val v = SealedClass::Impl1 \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/before/foo/SealedClass.kt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/before/foo/SealedClass.kt new file mode 100644 index 00000000000..f7e9572c67b --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/before/foo/SealedClass.kt @@ -0,0 +1,7 @@ +package foo + +public sealed class SealedClass { + public class Impl1 : SealedClass() {} +} + +public class Impl2 : SealedClass() {} \ No newline at end of file diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/conflicts.txt b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/conflicts.txt new file mode 100644 index 00000000000..4e6bd3f2df2 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/conflicts.txt @@ -0,0 +1 @@ +Sealed class 'SealedClass' must be moved with all its subclasses diff --git a/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test new file mode 100644 index 00000000000..70ea6e45ae5 --- /dev/null +++ b/idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test @@ -0,0 +1,6 @@ +{ + "customCompilerOpts": "COMPILER_ARGUMENTS: -XXLanguage:-AllowSealedInheritorsInDifferentFilesOfSamePackage", + "mainFile": "foo/SealedClass.kt", + "type": "MOVE_KOTLIN_TOP_LEVEL_DECLARATIONS", + "targetPackage": "bar" +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java index c340d3b81af..65839a8e016 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/MoveTestGenerated.java @@ -644,6 +644,16 @@ public class MoveTestGenerated extends AbstractMoveTest { runTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithAllSubclasses/sealedClassWithAllSubclasses.test"); } + @TestMetadata("kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/sealedClassWithSkippedSubclasses.test") + public void testKotlin_moveTopLevelDeclarations_misc_sealedClassWithSkippedSubclasses_SealedClassWithSkippedSubclasses() throws Exception { + runTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedClassWithSkippedSubclasses/sealedClassWithSkippedSubclasses.test"); + } + + @TestMetadata("kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/sealedSubclassWithSkippedRoot.test") + public void testKotlin_moveTopLevelDeclarations_misc_sealedSubclassWithSkippedRoot_SealedSubclassWithSkippedRoot() throws Exception { + runTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/sealedSubclassWithSkippedRoot/sealedSubclassWithSkippedRoot.test"); + } + @TestMetadata("kotlin/moveTopLevelDeclarations/misc/selfReferences/selfReferences.test") public void testKotlin_moveTopLevelDeclarations_misc_selfReferences_SelfReferences() throws Exception { runTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/misc/selfReferences/selfReferences.test"); @@ -769,6 +779,11 @@ public class MoveTestGenerated extends AbstractMoveTest { runTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/movePropertyToPackage/movePropertyToPackage.test"); } + @TestMetadata("kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test") + public void testKotlin_moveTopLevelDeclarations_moveSealedClassWithImplsToAnotherPackage_MoveSealedClassWithNestedImplsToAnotherPackage() throws Exception { + runTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test"); + } + @TestMetadata("kotlin/moveTopLevelDeclarations/moveSealedClassWithNestedImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test") public void testKotlin_moveTopLevelDeclarations_moveSealedClassWithNestedImplsToAnotherPackage_MoveSealedClassWithNestedImplsToAnotherPackage() throws Exception { runTest("idea/testData/refactoring/move/kotlin/moveTopLevelDeclarations/moveSealedClassWithNestedImplsToAnotherPackage/moveSealedClassWithNestedImplsToAnotherPackage.test"); From 3909e3c54ca888344d2bae1b5d6bdf6bd5f36471 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 4 Feb 2021 05:14:29 +0300 Subject: [PATCH 153/368] Decouple TypeCheckerContext and TypeSystemContext --- .../fir/analysis/checkers/FirHelpers.kt | 4 +- .../FirUpperBoundViolatedChecker.kt | 30 +- .../fir/session/ComponentsContainers.kt | 5 +- .../generators/CallAndReferenceGenerator.kt | 2 +- .../kotlin/fir/java/FirJavaElementFinder.kt | 5 +- .../org/jetbrains/kotlin/fir/SessionUtils.kt | 8 +- .../kotlin/fir/resolve/calls/Arguments.kt | 16 +- .../resolve/inference/InferenceComponents.kt | 6 +- .../FirExpressionsResolveTransformer.kt | 3 +- .../scopes/impl/FirTypeIntersectionScope.kt | 7 +- .../kotlin/fir/types/ConeInferenceContext.kt | 12 +- .../kotlin/fir/types/ConeTypeContext.kt | 41 +-- .../types/FirCorrespondingSupertypesCache.kt | 21 +- .../backend/jvm/codegen/ExpressionCodegen.kt | 2 +- .../backend/jvm/codegen/IrTypeMapper.kt | 2 +- .../jvm/lower/CollectionStubMethodLowering.kt | 8 +- .../kotlin/ir/overrides/IrOverridingUtil.kt | 16 +- .../kotlin/ir/types/IrTypeCheckerContext.kt | 32 +- .../kotlin/ir/types/IrTypeCheckerUtils.kt | 4 +- .../kotlin/ir/types/IrTypeSystemContext.kt | 37 +++ .../jetbrains/kotlin/ir/types/IrTypeUtils.kt | 6 +- .../calls/NewCommonSuperTypeCalculator.kt | 4 +- ...ctTypeCheckerContextForConstraintSystem.kt | 152 +++++---- .../components/ConstraintInjector.kt | 10 +- .../multiplatform/ExpectedActualResolver.kt | 17 +- .../kotlin/types/AbstractTypeChecker.kt | 307 ++++++++++-------- .../kotlin/resolve/OverridingUtil.java | 40 +-- .../OverridingUtilTypeSystemContext.kt | 48 +++ .../checker/ClassicTypeCheckerContext.kt | 31 +- .../types/checker/ClassicTypeSystemContext.kt | 6 +- .../KtFirAnalysisSessionComponent.kt | 3 +- .../KotlinIntroduceVariableHandler.kt | 14 +- 32 files changed, 483 insertions(+), 416 deletions(-) create mode 100644 core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtilTypeSystemContext.kt diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt index f2989f19726..7cbb4857ddc 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirHelpers.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.fir.scopes.processOverriddenFunctions import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol -import org.jetbrains.kotlin.fir.typeCheckerContext +import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtTokens @@ -317,4 +317,4 @@ val FirFunctionCall.isIterator internal fun throwableClassLikeType(session: FirSession) = session.builtinTypes.throwableType.type fun ConeKotlinType.isSubtypeOfThrowable(session: FirSession) = - throwableClassLikeType(session).isSupertypeOf(session.typeCheckerContext, this.fullyExpandedType(session)) + throwableClassLikeType(session).isSupertypeOf(session.typeContext, this.fullyExpandedType(session)) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirUpperBoundViolatedChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirUpperBoundViolatedChecker.kt index d469fdeaf28..e72a8d6f142 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirUpperBoundViolatedChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirUpperBoundViolatedChecker.kt @@ -22,7 +22,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.types.AbstractTypeChecker -import org.jetbrains.kotlin.types.AbstractTypeCheckerContext import org.jetbrains.kotlin.utils.addToStdlib.min import org.jetbrains.kotlin.utils.addToStdlib.safeAs @@ -63,18 +62,13 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() { parameterPairs.mapValues { it.value.coneType } ) - val typeCheckerContext = context.session.typeContext.newBaseTypeCheckerContext( - errorTypesEqualToAnything = false, - stubTypesEqualToAnything = false - ) - parameterPairs.forEach { (proto, actual) -> if (actual.source == null) { // inferred types don't report INAPPLICABLE_CANDIDATE for type aliases! return@forEach } - if (!satisfiesBounds(proto, actual.coneType, substitutor, typeCheckerContext)) { + if (!satisfiesBounds(proto, actual.coneType, substitutor, context.session.typeContext)) { reporter.reportOn(actual.source, proto, actual.coneType, context) return } @@ -82,7 +76,7 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() { // we must analyze nested things like // S, T>() actual.coneType.safeAs()?.let { - val errorOccurred = analyzeTypeParameters(it, context, reporter, typeCheckerContext, actual.source) + val errorOccurred = analyzeTypeParameters(it, context, reporter, context.session.typeContext, actual.source) if (errorOccurred) { return @@ -99,14 +93,14 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() { // typealias A = B> // val a = A() when (calleeFir) { - is FirConstructor -> analyzeConstructorCall(expression, substitutor, typeCheckerContext, reporter, context) + is FirConstructor -> analyzeConstructorCall(expression, substitutor, context.session.typeContext, reporter, context) } } private fun analyzeConstructorCall( functionCall: FirQualifiedAccessExpression, callSiteSubstitutor: ConeSubstitutor, - typeCheckerContext: AbstractTypeCheckerContext, + typeSystemContext: ConeTypeContext, reporter: DiagnosticReporter, context: CheckerContext ) { @@ -157,7 +151,7 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() { constructorsParameterPairs.forEach { (proto, actual) -> // just in case - var intersection = typeCheckerContext.intersectTypes( + var intersection = typeSystemContext.intersectTypes( proto.fir.bounds.map { it.coneType } ).safeAs() ?: return@forEach @@ -167,7 +161,7 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() { // substitute Int for G from // the example above val target = callSiteSubstitutor.substituteOrSelf(actual) - val satisfiesBounds = AbstractTypeChecker.isSubtypeOf(typeCheckerContext, target, intersection) + val satisfiesBounds = AbstractTypeChecker.isSubtypeOf(typeSystemContext, target, intersection) if (!satisfiesBounds) { reporter.reportOn(functionCall.source, proto, actual, context) @@ -187,7 +181,7 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() { type: ConeClassLikeType, context: CheckerContext, reporter: DiagnosticReporter, - typeCheckerContext: AbstractTypeCheckerContext, + typeSystemContext: ConeTypeContext, reportTarget: FirSourceElement? ): Boolean { val prototypeClass = type.lookupTag.toSymbol(context.session) @@ -218,13 +212,13 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() { ) parameterPairs.forEach { (proto, actual) -> - if (!satisfiesBounds(proto, actual.type, substitutor, typeCheckerContext)) { + if (!satisfiesBounds(proto, actual.type, substitutor, typeSystemContext)) { // should report on the parameter instead! reporter.reportOn(reportTarget, proto, actual, context) return true } - val errorOccurred = analyzeTypeParameters(actual, context, reporter, typeCheckerContext, reportTarget) + val errorOccurred = analyzeTypeParameters(actual, context, reporter, typeSystemContext, reportTarget) if (errorOccurred) { return true @@ -242,14 +236,14 @@ object FirUpperBoundViolatedChecker : FirQualifiedAccessChecker() { prototypeSymbol: FirTypeParameterSymbol, target: ConeKotlinType, substitutor: ConeSubstitutor, - typeCheckerContext: AbstractTypeCheckerContext + typeSystemContext: ConeTypeContext ): Boolean { - var intersection = typeCheckerContext.intersectTypes( + var intersection = typeSystemContext.intersectTypes( prototypeSymbol.fir.bounds.map { it.coneType } ).safeAs() ?: return true intersection = substitutor.substituteOrSelf(intersection) - return AbstractTypeChecker.isSubtypeOf(typeCheckerContext, target, intersection) + return AbstractTypeChecker.isSubtypeOf(typeSystemContext, target, intersection, stubTypesEqualToAnything = false) } private fun DiagnosticReporter.reportOn( diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/ComponentsContainers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/ComponentsContainers.kt index 104321cbf0f..b8d86129a5c 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/ComponentsContainers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/ComponentsContainers.kt @@ -30,6 +30,9 @@ import org.jetbrains.kotlin.fir.types.FirCorrespondingSupertypesCache @OptIn(SessionConfiguration::class) fun FirSession.registerCommonComponents(languageVersionSettings: LanguageVersionSettings) { + register(FirLanguageSettingsComponent::class, FirLanguageSettingsComponent(languageVersionSettings)) + register(InferenceComponents::class, InferenceComponents(this)) + register(FirDeclaredMemberScopeProvider::class, FirDeclaredMemberScopeProvider()) register(FirCorrespondingSupertypesCache::class, FirCorrespondingSupertypesCache(this)) register(FirDefaultParametersResolver::class, FirDefaultParametersResolver()) @@ -38,8 +41,6 @@ fun FirSession.registerCommonComponents(languageVersionSettings: LanguageVersion register(FirRegisteredPluginAnnotations::class, FirRegisteredPluginAnnotations.create(this)) register(FirPredicateBasedProvider::class, FirPredicateBasedProvider.create(this)) register(GeneratedClassIndex::class, GeneratedClassIndex.create()) - register(FirLanguageSettingsComponent::class, FirLanguageSettingsComponent(languageVersionSettings)) - register(InferenceComponents::class, InferenceComponents(this)) } @OptIn(SessionConfiguration::class) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index 4e98df5a288..9bebfd9667d 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -636,7 +636,7 @@ class CallAndReferenceGenerator( // If the type of the argument is already an explicitly subtype of the type of the parameter, we don't need SAM conversion. if (argument.typeRef !is FirResolvedTypeRef || AbstractTypeChecker.isSubtypeOf( - session.inferenceComponents.ctx, + session.inferenceComponents.ctx.newBaseTypeCheckerContext(errorTypesEqualToAnything = false, stubTypesEqualToAnything = true), argument.typeRef.coneType, parameter.returnTypeRef.coneType, isFromNullabilityConstraint = true diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt index 3dce60664e4..207eee23502 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaElementFinder.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.transformers.resolveSupertypesInTheAir import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol +import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName @@ -241,9 +242,7 @@ private fun ConeClassLikeType.mapToCanonicalNoExpansionString(session: FirSessio } + "[]" } - val context = ConeTypeCheckerContext(isErrorTypeEqualsToAnything = false, isStubTypeEqualsToAnything = true, session = session) - - with(context) { + with(session.typeContext) { val typeConstructor = typeConstructor() typeConstructor.getPrimitiveType()?.let { return JvmPrimitiveType.get(it).wrapperFqName.asString() } typeConstructor.getPrimitiveArrayType()?.let { return JvmPrimitiveType.get(it).javaKeywordName + "[]" } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/SessionUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/SessionUtils.kt index cf587bfbd09..f90d401816d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/SessionUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/SessionUtils.kt @@ -6,21 +6,19 @@ package org.jetbrains.kotlin.fir import org.jetbrains.kotlin.descriptors.Visibility -import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.FirClass +import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction +import org.jetbrains.kotlin.fir.declarations.visibility import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.processOverriddenFunctions import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope import org.jetbrains.kotlin.fir.types.ConeInferenceContext -import org.jetbrains.kotlin.fir.types.ConeTypeCheckerContext val FirSession.typeContext: ConeInferenceContext get() = inferenceComponents.ctx -val FirSession.typeCheckerContext: ConeTypeCheckerContext - get() = inferenceComponents.ctx - /** * Returns the list of functions that overridden by given */ diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt index 172cbb4cae8..77bdd3df6e9 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Arguments.kt @@ -17,7 +17,6 @@ import org.jetbrains.kotlin.fir.resolve.transformers.ensureResolvedTypeDeclarati import org.jetbrains.kotlin.fir.returnExpressions import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.StandardClassIds -import org.jetbrains.kotlin.fir.typeCheckerContext import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.name.ClassId @@ -26,6 +25,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.addSubtypeConstraintIfCompat import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition import org.jetbrains.kotlin.types.AbstractTypeChecker import org.jetbrains.kotlin.types.model.CaptureStatus +import org.jetbrains.kotlin.types.model.TypeSystemCommonSuperTypesContext import org.jetbrains.kotlin.utils.addToStdlib.runIf fun Candidate.resolveArgumentExpression( @@ -416,7 +416,10 @@ fun FirExpression.isFunctional( val returnTypeCompatible = expectedReturnType is ConeTypeParameterType || AbstractTypeChecker.isSubtypeOf( - session.inferenceComponents.ctx, + session.inferenceComponents.ctx.newBaseTypeCheckerContext( + errorTypesEqualToAnything = false, + stubTypesEqualToAnything = true + ), invokeSymbol.fir.returnTypeRef.coneType, expectedReturnType, isFromNullabilityConstraint = false @@ -433,7 +436,10 @@ fun FirExpression.isFunctional( val expectedParameterType = expectedParameter!!.lowerBoundIfFlexible() expectedParameterType is ConeTypeParameterType || AbstractTypeChecker.isSubtypeOf( - session.inferenceComponents.ctx, + session.inferenceComponents.ctx.newBaseTypeCheckerContext( + errorTypesEqualToAnything = false, + stubTypesEqualToAnything = true + ), invokeParameter.returnTypeRef.coneType, expectedParameterType, isFromNullabilityConstraint = false @@ -488,7 +494,7 @@ internal fun captureFromTypeParameterUpperBoundIfNeeded( val simplifiedArgumentType = argumentType.lowerBoundIfFlexible() as? ConeTypeParameterType ?: return argumentType val typeParameter = simplifiedArgumentType.lookupTag.typeParameterSymbol.fir - val context = session.typeCheckerContext + val context = session.typeContext val chosenSupertype = typeParameter.bounds.map { it.coneType } .singleOrNull { it.hasSupertypeWithGivenClassId(expectedTypeClassId, context) } ?: return argumentType @@ -501,7 +507,7 @@ internal fun captureFromTypeParameterUpperBoundIfNeeded( } } -private fun ConeKotlinType.hasSupertypeWithGivenClassId(classId: ClassId, context: ConeTypeCheckerContext): Boolean { +private fun ConeKotlinType.hasSupertypeWithGivenClassId(classId: ClassId, context: TypeSystemCommonSuperTypesContext): Boolean { return with(context) { anySuperTypeConstructor { it is ConeClassLikeLookupTag && it.classId == classId diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceComponents.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceComponents.kt index ec132d66375..c29ed2205d1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceComponents.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceComponents.kt @@ -7,14 +7,16 @@ package org.jetbrains.kotlin.fir.resolve.inference import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.types.ConeInferenceContext -import org.jetbrains.kotlin.fir.types.ConeTypeCheckerContext import org.jetbrains.kotlin.resolve.calls.inference.components.* import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl import org.jetbrains.kotlin.types.AbstractTypeApproximator @NoMutableState class InferenceComponents(val session: FirSession) : FirSessionComponent { - val ctx: ConeTypeCheckerContext = ConeTypeCheckerContext(isErrorTypeEqualsToAnything = false, isStubTypeEqualsToAnything = true, session) + val ctx: ConeInferenceContext = object : ConeInferenceContext { + override val session: FirSession + get() = this@InferenceComponents.session + } val approximator: AbstractTypeApproximator = object : AbstractTypeApproximator(ctx) {} val trivialConstraintTypeInferenceOracle = TrivialConstraintTypeInferenceOracle.create(ctx) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 6db37b3e083..61f458b8844 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -496,7 +496,8 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform if (baseType !is ConeClassLikeType) return this val baseFirClass = baseType.lookupTag.toSymbol(session)?.fir ?: return this - val newArguments = if (AbstractTypeChecker.isSubtypeOfClass(session.typeCheckerContext, baseType.lookupTag, type.lookupTag)) { + val newArguments = if (AbstractTypeChecker.isSubtypeOfClass( + session.typeContext.newBaseTypeCheckerContext(errorTypesEqualToAnything = false, stubTypesEqualToAnything = true), baseType.lookupTag, type.lookupTag)) { // If actual type of declaration is more specific than bare type then we should just find // corresponding supertype with proper arguments with(session.typeContext) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScope.kt index 675553f33ce..0f76eff3432 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScope.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.scopes.* import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.* +import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.AbstractTypeChecker @@ -33,7 +34,7 @@ class FirTypeIntersectionScope private constructor( private val absentProperties: MutableSet = mutableSetOf() private val absentClassifiers: MutableSet = mutableSetOf() - private val typeContext = ConeTypeCheckerContext(isErrorTypeEqualsToAnything = false, isStubTypeEqualsToAnything = false, session) + private val typeCheckerContext = session.typeContext.newBaseTypeCheckerContext(false, false) private val overriddenSymbols: MutableMap, Collection>>> = mutableMapOf() @@ -357,7 +358,7 @@ class FirTypeIntersectionScope private constructor( require(bFir is FirProperty) { "b is " + b.javaClass } // TODO: if (!OverridingUtil.isAccessorMoreSpecific(pa.getSetter(), pb.getSetter())) return false return if (aFir.isVar && bFir.isVar) { - AbstractTypeChecker.equalTypes(typeContext as AbstractTypeCheckerContext, aReturnType, bReturnType) + AbstractTypeChecker.equalTypes(typeCheckerContext as AbstractTypeCheckerContext, aReturnType, bReturnType) } else { // both vals or var vs val: val can't be more specific then var !(!aFir.isVar && bFir.isVar) && isTypeMoreSpecific(aReturnType, bReturnType) } @@ -366,7 +367,7 @@ class FirTypeIntersectionScope private constructor( } private fun isTypeMoreSpecific(a: ConeKotlinType, b: ConeKotlinType): Boolean = - AbstractTypeChecker.isSubtypeOf(typeContext as AbstractTypeCheckerContext, a, b) + AbstractTypeChecker.isSubtypeOf(typeCheckerContext as AbstractTypeCheckerContext, a, b) private fun > findMemberWithMaxVisibility(members: Collection>): MemberWithBaseScope { assert(members.isNotEmpty()) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt index 18d9d81ec8b..4c2c0a9c5c3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt @@ -97,8 +97,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo override fun newBaseTypeCheckerContext( errorTypesEqualToAnything: Boolean, stubTypesEqualToAnything: Boolean - ): AbstractTypeCheckerContext = - ConeTypeCheckerContext(errorTypesEqualToAnything, stubTypesEqualToAnything, session) + ): ConeTypeCheckerContext = + ConeTypeCheckerContext(errorTypesEqualToAnything, stubTypesEqualToAnything, this) override fun KotlinTypeMarker.canHaveUndefinedNullability(): Boolean { require(this is ConeKotlinType) @@ -483,4 +483,12 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo return session.symbolProvider.getClassLikeSymbolByFqName(classId)?.toLookupTag() ?: error("Can't find KFunction type") } + + override fun createTypeWithAlternativeForIntersectionResult( + firstCandidate: KotlinTypeMarker, + secondCandidate: KotlinTypeMarker + ): KotlinTypeMarker { + // TODO + return firstCandidate + } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt index 91df2893bea..e424d75d3ab 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.AbstractTypeCheckerContext +import org.jetbrains.kotlin.types.AbstractTypeCheckerContext.SupertypesPolicy.* import org.jetbrains.kotlin.types.TypeSystemCommonBackendContext import org.jetbrains.kotlin.types.model.* @@ -540,10 +541,13 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty class ConeTypeCheckerContext( override val isErrorTypeEqualsToAnything: Boolean, override val isStubTypeEqualsToAnything: Boolean, - override val session: FirSession -) : AbstractTypeCheckerContext(), ConeInferenceContext { - override fun substitutionSupertypePolicy(type: SimpleTypeMarker): SupertypesPolicy { - if (type.argumentsCount() == 0) return SupertypesPolicy.LowerIfFlexible + override val typeSystemContext: ConeInferenceContext +) : AbstractTypeCheckerContext() { + + val session: FirSession = typeSystemContext.session + + override fun substitutionSupertypePolicy(type: SimpleTypeMarker): SupertypesPolicy = with(typeSystemContext) { + if (type.argumentsCount() == 0) return LowerIfFlexible require(type is ConeKotlinType) val declaration = when (type) { is ConeClassLikeType -> type.lookupTag.toSymbol(session)?.firUnsafe>() @@ -560,7 +564,7 @@ class ConeTypeCheckerContext( } else { ConeSubstitutor.Empty } - return object : SupertypesPolicy.DoCustomTransform() { + return object : DoCustomTransform() { override fun transformType(context: AbstractTypeCheckerContext, type: KotlinTypeMarker): SimpleTypeMarker { val lowerBound = type.lowerBoundIfFlexible() require(lowerBound is ConeKotlinType) @@ -570,35 +574,10 @@ class ConeTypeCheckerContext( } } - override fun areEqualTypeConstructors(c1: TypeConstructorMarker, c2: TypeConstructorMarker): Boolean { - return c1 == c2 - } - - override fun prepareType(type: KotlinTypeMarker): KotlinTypeMarker { - return super.prepareType(type) - } - override fun refineType(type: KotlinTypeMarker): KotlinTypeMarker { - return prepareType(type) + return typeSystemContext.prepareType(type) } override val KotlinTypeMarker.isAllowedTypeVariable: Boolean get() = this is ConeKotlinType && this is ConeTypeVariableType - - override fun newBaseTypeCheckerContext( - errorTypesEqualToAnything: Boolean, - stubTypesEqualToAnything: Boolean - ): AbstractTypeCheckerContext = - if (this.isErrorTypeEqualsToAnything == errorTypesEqualToAnything && this.isStubTypeEqualsToAnything == stubTypesEqualToAnything) - this - else - ConeTypeCheckerContext(errorTypesEqualToAnything, stubTypesEqualToAnything, session) - - override fun createTypeWithAlternativeForIntersectionResult( - firstCandidate: KotlinTypeMarker, - secondCandidate: KotlinTypeMarker - ): KotlinTypeMarker { - // TODO - return firstCandidate - } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/FirCorrespondingSupertypesCache.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/FirCorrespondingSupertypesCache.kt index 8422957eeeb..51d12a4428a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/FirCorrespondingSupertypesCache.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/FirCorrespondingSupertypesCache.kt @@ -13,10 +13,12 @@ import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRefsOwner import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol +import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.types.AbstractTypeCheckerContext import org.jetbrains.kotlin.types.model.CaptureStatus import org.jetbrains.kotlin.types.model.SimpleTypeMarker import org.jetbrains.kotlin.types.model.TypeConstructorMarker +import org.jetbrains.kotlin.types.model.TypeSystemContext @ThreadSafeMutableState class FirCorrespondingSupertypesCache(private val session: FirSession) : FirSessionComponent { @@ -28,9 +30,13 @@ class FirCorrespondingSupertypesCache(private val session: FirSession) : FirSess ): List? { if (type !is ConeClassLikeType || supertypeConstructor !is ConeClassLikeLookupTag) return null - val context = ConeTypeCheckerContext(isErrorTypeEqualsToAnything = false, isStubTypeEqualsToAnything = true, session = session) + val context = session.typeContext.newBaseTypeCheckerContext( + errorTypesEqualToAnything = false, + stubTypesEqualToAnything = true + ) + val lookupTag = type.lookupTag - if (lookupTag == supertypeConstructor) return listOf(captureType(type, context)) + if (lookupTag == supertypeConstructor) return listOf(captureType(type, context.typeSystemContext)) if (lookupTag !in cache) { cache[lookupTag] = computeSupertypesMap(lookupTag, context) } @@ -38,15 +44,15 @@ class FirCorrespondingSupertypesCache(private val session: FirSession) : FirSess val resultTypes = cache[lookupTag]?.getOrDefault(supertypeConstructor, emptyList()) ?: return null if (type.typeArguments.isEmpty()) return resultTypes - val capturedType = captureType(type, context) + val capturedType = captureType(type, context.typeSystemContext) val substitutionSupertypePolicy = context.substitutionSupertypePolicy(capturedType) return resultTypes.map { substitutionSupertypePolicy.transformType(context, it) as ConeClassLikeType } } - private fun captureType(type: ConeClassLikeType, context: ConeTypeCheckerContext): ConeClassLikeType = - (context.captureFromArguments(type, CaptureStatus.FOR_SUBTYPING) ?: type) as ConeClassLikeType + private fun captureType(type: ConeClassLikeType, typeSystemContext: ConeTypeContext): ConeClassLikeType = + (typeSystemContext.captureFromArguments(type, CaptureStatus.FOR_SUBTYPING) ?: type) as ConeClassLikeType private fun computeSupertypesMap( subtypeLookupTag: ConeClassLikeLookupTag, @@ -82,12 +88,13 @@ class FirCorrespondingSupertypesCache(private val session: FirSession) : FirSess context: ConeTypeCheckerContext ): AbstractTypeCheckerContext.SupertypesPolicy { val supertypeLookupTag = (supertype as ConeClassLikeType).lookupTag - val captured = context.captureFromArguments(supertype, CaptureStatus.FOR_SUBTYPING) as ConeClassLikeType? ?: supertype + val captured = + context.typeSystemContext.captureFromArguments(supertype, CaptureStatus.FOR_SUBTYPING) as ConeClassLikeType? ?: supertype resultingMap[supertypeLookupTag] = listOf(captured) return when { - with(context) { captured.argumentsCount() } == 0 -> { + with(context.typeSystemContext) { captured.argumentsCount() } == 0 -> { AbstractTypeCheckerContext.SupertypesPolicy.LowerIfFlexible } else -> { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 55a879d4acd..1ae7b43c724 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -1374,7 +1374,7 @@ class ExpressionCodegen( val reifiedTypeInliner = ReifiedTypeInliner( mappings, IrInlineIntrinsicsSupport(context, typeMapper), - IrTypeCheckerContext(context.irBuiltIns), + IrTypeSystemContextImpl(context.irBuiltIns), state.languageVersionSettings, state.unifiedNullChecks, ) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt index 43ed5866694..58e3d4985e8 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.ir.types.isKClass as isKClassImpl import org.jetbrains.kotlin.ir.util.isSuspendFunction as isSuspendFunctionImpl class IrTypeMapper(private val context: JvmBackendContext) : KotlinTypeMapperBase(), TypeMappingContext { - internal val typeSystem = IrTypeCheckerContext(context.irBuiltIns) + internal val typeSystem = IrTypeSystemContextImpl(context.irBuiltIns) override val typeContext: TypeSystemCommonBackendContextForTypeMapping = IrTypeCheckerContextForTypeMapping(typeSystem, context) override fun mapClass(classifier: ClassifierDescriptor): Type = diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt index 9b627b0a39a..2dbd3e9f69e 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt @@ -229,7 +229,13 @@ internal class CollectionStubMethodLowering(val context: JvmBackendContext) : Cl } private fun createTypeChecker(overrideFun: IrSimpleFunction, parentFun: IrSimpleFunction): AbstractTypeCheckerContext = - IrTypeCheckerContextWithAdditionalAxioms(context.irBuiltIns, overrideFun.typeParameters, parentFun.typeParameters) + IrTypeCheckerContext( + IrTypeSystemContextWithAdditionalAxioms( + context.irBuiltIns, + overrideFun.typeParameters, + parentFun.typeParameters + ) + ) private fun areTypeParametersEquivalent( overrideFun: IrSimpleFunction, diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/IrOverridingUtil.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/IrOverridingUtil.kt index cf1e7c00f3e..42b971c140b 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/IrOverridingUtil.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/overrides/IrOverridingUtil.kt @@ -425,14 +425,14 @@ class IrOverridingUtil( return if (a == null || b == null) true else isVisibilityMoreSpecific(a, b) } - private fun IrTypeCheckerContextWithAdditionalAxioms.isSubtypeOf(a: IrType, b: IrType) = + private fun IrTypeCheckerContext.isSubtypeOf(a: IrType, b: IrType) = AbstractTypeChecker.isSubtypeOf(this as AbstractTypeCheckerContext, a, b) - private fun IrTypeCheckerContextWithAdditionalAxioms.equalTypes(a: IrType, b: IrType) = + private fun IrTypeCheckerContext.equalTypes(a: IrType, b: IrType) = AbstractTypeChecker.equalTypes(this as AbstractTypeCheckerContext, a, b) private fun createTypeChecker(a: List, b: List) = - IrTypeCheckerContextWithAdditionalAxioms(irBuiltIns, a, b) + IrTypeCheckerContext(IrTypeSystemContextWithAdditionalAxioms(irBuiltIns, a, b)) private fun isReturnTypeMoreSpecific( a: IrOverridableMember, @@ -661,10 +661,12 @@ class IrOverridingUtil( } val typeCheckerContext = - IrTypeCheckerContextWithAdditionalAxioms( - irBuiltIns, - superTypeParameters, - subTypeParameters + IrTypeCheckerContext( + IrTypeSystemContextWithAdditionalAxioms( + irBuiltIns, + superTypeParameters, + subTypeParameters + ) ) /* TODO: check the bounds. See OverridingUtil.areTypeParametersEquivalent() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeCheckerContext.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeCheckerContext.kt index 2fe6f32b8b9..6a1e198e0e9 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeCheckerContext.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeCheckerContext.kt @@ -10,7 +10,9 @@ import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.types.AbstractTypeCheckerContext import org.jetbrains.kotlin.types.model.* -open class IrTypeCheckerContext(override val irBuiltIns: IrBuiltIns) : IrTypeSystemContext, AbstractTypeCheckerContext() { +open class IrTypeCheckerContext(override val typeSystemContext: IrTypeSystemContext): AbstractTypeCheckerContext() { + + val irBuiltIns: IrBuiltIns get() = typeSystemContext.irBuiltIns override fun substitutionSupertypePolicy(type: SimpleTypeMarker): SupertypesPolicy.DoCustomTransform { require(type is IrSimpleType) @@ -30,32 +32,4 @@ open class IrTypeCheckerContext(override val irBuiltIns: IrBuiltIns) : IrTypeSys override val KotlinTypeMarker.isAllowedTypeVariable: Boolean get() = false - - override fun newBaseTypeCheckerContext( - errorTypesEqualToAnything: Boolean, - stubTypesEqualToAnything: Boolean - ): AbstractTypeCheckerContext = IrTypeCheckerContext(irBuiltIns) - - override fun KotlinTypeMarker.isUninferredParameter(): Boolean = false - override fun KotlinTypeMarker.withNullability(nullable: Boolean): KotlinTypeMarker { - if (this.isSimpleType()) { - return this.asSimpleType()!!.withNullability(nullable) - } else { - error("withNullability for non-simple types is not supported in IR") - } - } - - override fun captureFromExpression(type: KotlinTypeMarker): KotlinTypeMarker? = - error("Captured type is unsupported in IR") - - override fun DefinitelyNotNullTypeMarker.original(): SimpleTypeMarker = - error("DefinitelyNotNull type is unsupported in IR") - - override fun KotlinTypeMarker.makeDefinitelyNotNullOrNotNull(): KotlinTypeMarker { - error("makeDefinitelyNotNullOrNotNull is not supported in IR") - } - - override fun SimpleTypeMarker.makeSimpleTypeDefinitelyNotNullOrNotNull(): SimpleTypeMarker { - error("makeSimpleTypeDefinitelyNotNullOrNotNull is not yet supported in IR") - } } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeCheckerUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeCheckerUtils.kt index 0b442c89a58..8309eef8eac 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeCheckerUtils.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeCheckerUtils.kt @@ -9,11 +9,11 @@ import org.jetbrains.kotlin.ir.declarations.IrTypeParameter import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.types.model.TypeConstructorMarker -open class IrTypeCheckerContextWithAdditionalAxioms( +class IrTypeSystemContextWithAdditionalAxioms( override val irBuiltIns: IrBuiltIns, firstParameters: List, secondParameters: List -) : IrTypeCheckerContext(irBuiltIns) { +) : IrTypeSystemContext { init { assert(firstParameters.size == secondParameters.size) { "different length of type parameter lists: $firstParameters vs $secondParameters" diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt index 7eca8a677a8..02df059bcd5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.types.AbstractTypeCheckerContext import org.jetbrains.kotlin.types.TypeSystemCommonBackendContext import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.model.* @@ -454,6 +455,39 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon val irClass = (this as IrType).classOrNull?.owner return irClass != null && (irClass.isInterface || irClass.isAnnotationClass) } + + + override fun newBaseTypeCheckerContext( + errorTypesEqualToAnything: Boolean, + stubTypesEqualToAnything: Boolean + ): AbstractTypeCheckerContext = IrTypeCheckerContext(this) + + override fun KotlinTypeMarker.isUninferredParameter(): Boolean = false + override fun KotlinTypeMarker.withNullability(nullable: Boolean): KotlinTypeMarker { + if (this.isSimpleType()) { + return this.asSimpleType()!!.withNullability(nullable) + } else { + error("withNullability for non-simple types is not supported in IR") + } + } + + override fun captureFromExpression(type: KotlinTypeMarker): KotlinTypeMarker? = + error("Captured type is unsupported in IR") + + override fun DefinitelyNotNullTypeMarker.original(): SimpleTypeMarker = + error("DefinitelyNotNull type is unsupported in IR") + + override fun KotlinTypeMarker.makeDefinitelyNotNullOrNotNull(): KotlinTypeMarker { + error("makeDefinitelyNotNullOrNotNull is not supported in IR") + } + + override fun SimpleTypeMarker.makeSimpleTypeDefinitelyNotNullOrNotNull(): SimpleTypeMarker { + error("makeSimpleTypeDefinitelyNotNullOrNotNull is not yet supported in IR") + } + + override fun prepareType(type: KotlinTypeMarker): KotlinTypeMarker { + return type + } } fun extractTypeParameters(parent: IrDeclarationParent): List { @@ -480,3 +514,6 @@ fun extractTypeParameters(parent: IrDeclarationParent): List { } return result } + + +class IrTypeSystemContextImpl(override val irBuiltIns: IrBuiltIns) : IrTypeSystemContext \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt index 93e047ba5b4..13427724dcc 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeUtils.kt @@ -32,7 +32,11 @@ fun IrType.isSubtypeOfClass(superClass: IrClassSymbol): Boolean { } fun IrType.isSubtypeOf(superType: IrType, irBuiltIns: IrBuiltIns): Boolean { - return AbstractTypeChecker.isSubtypeOf(IrTypeCheckerContext(irBuiltIns) as AbstractTypeCheckerContext, this, superType) + return AbstractTypeChecker.isSubtypeOf( + IrTypeCheckerContext(IrTypeSystemContextImpl(irBuiltIns)) as AbstractTypeCheckerContext, + this, + superType + ) } fun IrType.isNullable(): Boolean = diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt index 08b381d22dc..b98a365de9d 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt @@ -267,9 +267,7 @@ object NewCommonSuperTypeCalculator { * but it is too complicated and we will return not so accurate type: CS(List, List, List) */ val correspondingSuperTypes = types.flatMap { - with(AbstractTypeChecker) { - typeCheckerContext.findCorrespondingSupertypes(it, constructor) - } + AbstractTypeChecker.findCorrespondingSupertypes(typeCheckerContext, it, constructor) } val arguments = ArrayList(constructor.parametersCount()) diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt index d1a0df2ab40..b6e7697e17c 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt @@ -10,7 +10,8 @@ import org.jetbrains.kotlin.types.AbstractTypeChecker import org.jetbrains.kotlin.types.AbstractTypeCheckerContext import org.jetbrains.kotlin.types.model.* -abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheckerContext(), TypeSystemInferenceExtensionContext { +abstract class AbstractTypeCheckerContextForConstraintSystem(override val typeSystemContext: TypeSystemInferenceExtensionContext) : + AbstractTypeCheckerContext() { override val KotlinTypeMarker.isAllowedTypeVariable: Boolean get() = false @@ -36,21 +37,22 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck abstract fun addEqualityConstraint(typeVariable: TypeConstructorMarker, type: KotlinTypeMarker) - override fun getLowerCapturedTypePolicy(subType: SimpleTypeMarker, superType: CapturedTypeMarker): LowerCapturedTypePolicy { - return when { - isMyTypeVariable(subType) -> { - val projection = superType.typeConstructorProjection() - val type = projection.getType().asSimpleType() - if (projection.getVariance() == TypeVariance.IN && type != null && isMyTypeVariable(type)) { - LowerCapturedTypePolicy.CHECK_ONLY_LOWER - } else { - LowerCapturedTypePolicy.SKIP_LOWER + override fun getLowerCapturedTypePolicy(subType: SimpleTypeMarker, superType: CapturedTypeMarker): LowerCapturedTypePolicy = + with(typeSystemContext) { + return when { + isMyTypeVariable(subType) -> { + val projection = superType.typeConstructorProjection() + val type = projection.getType().asSimpleType() + if (projection.getVariance() == TypeVariance.IN && type != null && isMyTypeVariable(type)) { + LowerCapturedTypePolicy.CHECK_ONLY_LOWER + } else { + LowerCapturedTypePolicy.SKIP_LOWER + } } + subType.contains { it.anyBound(::isMyTypeVariable) } -> LowerCapturedTypePolicy.CHECK_ONLY_LOWER + else -> LowerCapturedTypePolicy.CHECK_SUBTYPE_AND_LOWER } - subType.contains { it.anyBound(this::isMyTypeVariable) } -> LowerCapturedTypePolicy.CHECK_ONLY_LOWER - else -> LowerCapturedTypePolicy.CHECK_SUBTYPE_AND_LOWER } - } /** * todo: possible we should override this method, because otherwise OR in subtyping transformed to AND in constraint system @@ -70,9 +72,11 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck // we should strip annotation's because we have incorporation operation and they should be not affected val mySubType = - if (hasExact) extractTypeForProjectedType(subType, out = true) ?: subType.removeExactAnnotation() else subType + if (hasExact) extractTypeForProjectedType(subType, out = true) + ?: with(typeSystemContext) { subType.removeExactAnnotation() } else subType val mySuperType = - if (hasExact) extractTypeForProjectedType(superType, out = false) ?: superType.removeExactAnnotation() else superType + if (hasExact) extractTypeForProjectedType(superType, out = false) + ?: with(typeSystemContext) { superType.removeExactAnnotation() } else superType val result = internalAddSubtypeConstraint(mySubType, mySuperType, isFromNullabilityConstraint) if (!hasExact) return result @@ -83,7 +87,7 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck return (result ?: true) && (result2 ?: true) } - private fun extractTypeForProjectedType(type: KotlinTypeMarker, out: Boolean): KotlinTypeMarker? { + private fun extractTypeForProjectedType(type: KotlinTypeMarker, out: Boolean): KotlinTypeMarker? = with(typeSystemContext) { val typeMarker = type.asSimpleType()?.asCapturedType() ?: return null val projection = typeMarker.typeConstructorProjection() @@ -98,10 +102,10 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck } private fun KotlinTypeMarker.isTypeVariableWithExact() = - hasExactAnnotation() && anyBound(this@AbstractTypeCheckerContextForConstraintSystem::isMyTypeVariable) + with(typeSystemContext) { hasExactAnnotation() } && anyBound(this@AbstractTypeCheckerContextForConstraintSystem::isMyTypeVariable) private fun KotlinTypeMarker.isTypeVariableWithNoInfer() = - hasNoInferAnnotation() && anyBound(this@AbstractTypeCheckerContextForConstraintSystem::isMyTypeVariable) + with(typeSystemContext) { hasNoInferAnnotation() } && anyBound(this@AbstractTypeCheckerContextForConstraintSystem::isMyTypeVariable) private fun internalAddSubtypeConstraint( subType: KotlinTypeMarker, @@ -128,32 +132,33 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck } // extract type variable only from type like Captured(out T) - private fun extractTypeVariableForSubtype(subType: KotlinTypeMarker, superType: KotlinTypeMarker): KotlinTypeMarker? { + private fun extractTypeVariableForSubtype(subType: KotlinTypeMarker, superType: KotlinTypeMarker): KotlinTypeMarker? = + with(typeSystemContext) { - val typeMarker = subType.asSimpleType()?.asCapturedType() ?: return null + val typeMarker = subType.asSimpleType()?.asCapturedType() ?: return null - val projection = typeMarker.typeConstructorProjection() - if (projection.isStarProjection()) return null - if (projection.getVariance() == TypeVariance.IN) { - val type = projection.getType().asSimpleType() ?: return null - if (isMyTypeVariable(type)) { - simplifyLowerConstraint(type, superType) - if (isMyTypeVariable(superType.asSimpleType() ?: return null)) { - addLowerConstraint(superType.typeConstructor(), nullableAnyType()) + val projection = typeMarker.typeConstructorProjection() + if (projection.isStarProjection()) return null + if (projection.getVariance() == TypeVariance.IN) { + val type = projection.getType().asSimpleType() ?: return null + if (isMyTypeVariable(type)) { + simplifyLowerConstraint(type, superType) + if (isMyTypeVariable(superType.asSimpleType() ?: return null)) { + addLowerConstraint(superType.typeConstructor(), nullableAnyType()) + } } + return null } - return null - } - return if (projection.getVariance() == TypeVariance.OUT) { - val type = projection.getType() - when { - type is SimpleTypeMarker && isMyTypeVariable(type) -> type.asSimpleType() - type is FlexibleTypeMarker && isMyTypeVariable(type.lowerBound()) -> type.asFlexibleType()?.lowerBound() - else -> null - } - } else null - } + return if (projection.getVariance() == TypeVariance.OUT) { + val type = projection.getType() + when { + type is SimpleTypeMarker && isMyTypeVariable(type) -> type.asSimpleType() + type is FlexibleTypeMarker && isMyTypeVariable(type.lowerBound()) -> type.asFlexibleType()?.lowerBound() + else -> null + } + } else null + } /** * Foo <: T -- leave as is @@ -196,7 +201,7 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck typeVariable: KotlinTypeMarker, subType: KotlinTypeMarker, isFromNullabilityConstraint: Boolean = false - ): Boolean { + ): Boolean = with(typeSystemContext) { val lowerConstraint = when (typeVariable) { is SimpleTypeMarker -> /* @@ -256,7 +261,7 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck return true } - private fun assertFlexibleTypeVariable(typeVariable: FlexibleTypeMarker) { + private fun assertFlexibleTypeVariable(typeVariable: FlexibleTypeMarker) = with(typeSystemContext) { assert(typeVariable.lowerBound().typeConstructor() == typeVariable.upperBound().typeConstructor()) { "Flexible type variable ($typeVariable) should have bounds with the same type constructor, i.e. (T..T?)" } @@ -267,7 +272,7 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck * T? <: Foo <=> T <: Foo && Nothing? <: Foo * T <: Foo -- leave as is */ - private fun simplifyUpperConstraint(typeVariable: KotlinTypeMarker, superType: KotlinTypeMarker): Boolean { + private fun simplifyUpperConstraint(typeVariable: KotlinTypeMarker, superType: KotlinTypeMarker): Boolean = with(typeSystemContext) { val typeVariableLowerBound = typeVariable.lowerBoundIfFlexible() val simplifiedSuperType = if (typeVariableLowerBound.isDefinitelyNotNullType()) { superType.withNullability(true) @@ -279,37 +284,38 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck if (typeVariableLowerBound.isMarkedNullable()) { // here is important that superType is singleClassifierType - return simplifiedSuperType.anyBound(this::isMyTypeVariable) || + return simplifiedSuperType.anyBound(::isMyTypeVariable) || isSubtypeOfByTypeChecker(nullableNothingType(), simplifiedSuperType) } return true } - private fun simplifyConstraintForPossibleIntersectionSubType(subType: KotlinTypeMarker, superType: KotlinTypeMarker): Boolean? { - @Suppress("NAME_SHADOWING") - val subType = subType.lowerBoundIfFlexible() + private fun simplifyConstraintForPossibleIntersectionSubType(subType: KotlinTypeMarker, superType: KotlinTypeMarker): Boolean? = + with(typeSystemContext) { + @Suppress("NAME_SHADOWING") + val subType = subType.lowerBoundIfFlexible() - if (!subType.typeConstructor().isIntersection()) return null + if (!subType.typeConstructor().isIntersection()) return null - assert(!subType.isMarkedNullable()) { "Intersection type should not be marked nullable!: $subType" } + assert(!subType.isMarkedNullable()) { "Intersection type should not be marked nullable!: $subType" } - // TODO: may be we lose flexibility here - val subIntersectionTypes = (subType.typeConstructor().supertypes()).map { it.lowerBoundIfFlexible() } + // TODO: may be we lose flexibility here + val subIntersectionTypes = (subType.typeConstructor().supertypes()).map { it.lowerBoundIfFlexible() } - val typeVariables = subIntersectionTypes.filter(this::isMyTypeVariable).takeIf { it.isNotEmpty() } ?: return null - val notTypeVariables = subIntersectionTypes.filterNot(this::isMyTypeVariable) + val typeVariables = subIntersectionTypes.filter(::isMyTypeVariable).takeIf { it.isNotEmpty() } ?: return null + val notTypeVariables = subIntersectionTypes.filterNot(::isMyTypeVariable) - // todo: may be we can do better then that. - if (notTypeVariables.isNotEmpty() && - AbstractTypeChecker.isSubtypeOf( - this as TypeCheckerProviderContext, - intersectTypes(notTypeVariables), - superType - ) - ) { - return true - } + // todo: may be we can do better then that. + if (notTypeVariables.isNotEmpty() && + AbstractTypeChecker.isSubtypeOf( + this as TypeCheckerProviderContext, + intersectTypes(notTypeVariables), + superType + ) + ) { + return true + } // Consider the following example: // fun id(x: T): T = x @@ -326,23 +332,25 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck // here we try to add constraint {Any & T} <: S from `id(a)` // Previously we thought that if `Any` isn't a subtype of S => T <: S, which is wrong, now we use weaker upper constraint // TODO: rethink, maybe we should take nullability into account somewhere else - if (notTypeVariables.any { AbstractNullabilityChecker.isSubtypeOfAny(this as TypeCheckerProviderContext, it) }) { - return typeVariables.all { simplifyUpperConstraint(it, superType.withNullability(true)) } - } + if (notTypeVariables.any { AbstractNullabilityChecker.isSubtypeOfAny(this as TypeCheckerProviderContext, it) }) { + return typeVariables.all { simplifyUpperConstraint(it, superType.withNullability(true)) } + } - return typeVariables.all { simplifyUpperConstraint(it, superType) } - } + return typeVariables.all { simplifyUpperConstraint(it, superType) } + } private fun isSubtypeOfByTypeChecker(subType: KotlinTypeMarker, superType: KotlinTypeMarker) = AbstractTypeChecker.isSubtypeOf(this as AbstractTypeCheckerContext, subType, superType) - private fun assertInputTypes(subType: KotlinTypeMarker, superType: KotlinTypeMarker) { + private fun assertInputTypes(subType: KotlinTypeMarker, superType: KotlinTypeMarker) = with(typeSystemContext) { if (!AbstractTypeChecker.RUN_SLOW_ASSERTIONS) return fun correctSubType(subType: SimpleTypeMarker) = - subType.isSingleClassifierType() || subType.typeConstructor().isIntersection() || isMyTypeVariable(subType) || subType.isError() || subType.isIntegerLiteralType() + subType.isSingleClassifierType() || subType.typeConstructor() + .isIntersection() || isMyTypeVariable(subType) || subType.isError() || subType.isIntegerLiteralType() fun correctSuperType(superType: SimpleTypeMarker) = - superType.isSingleClassifierType() || superType.typeConstructor().isIntersection() || isMyTypeVariable(superType) || superType.isError() || superType.isIntegerLiteralType() + superType.isSingleClassifierType() || superType.typeConstructor() + .isIntersection() || isMyTypeVariable(superType) || superType.isError() || superType.isIntegerLiteralType() assert(subType.bothBounds(::correctSubType)) { "Not singleClassifierType and not intersection subType: $subType" @@ -354,13 +362,13 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck private inline fun KotlinTypeMarker.bothBounds(f: (SimpleTypeMarker) -> Boolean) = when (this) { is SimpleTypeMarker -> f(this) - is FlexibleTypeMarker -> f(lowerBound()) && f(upperBound()) + is FlexibleTypeMarker -> with(typeSystemContext) { f(lowerBound()) && f(upperBound()) } else -> error("sealed") } private inline fun KotlinTypeMarker.anyBound(f: (SimpleTypeMarker) -> Boolean) = when (this) { is SimpleTypeMarker -> f(this) - is FlexibleTypeMarker -> f(lowerBound()) || f(upperBound()) + is FlexibleTypeMarker -> with(typeSystemContext) { f(lowerBound()) || f(upperBound()) } else -> error("sealed") } } diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt index 3905e1461de..61eca16a127 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt @@ -165,7 +165,7 @@ class ConstraintInjector( type.typeDepth() <= maxTypeDepthFromInitialConstraints + ALLOWED_DEPTH_DELTA_FOR_INCORPORATION private inner class TypeCheckerContext(val c: Context, val position: IncorporationConstraintPosition) : - AbstractTypeCheckerContextForConstraintSystem(), ConstraintIncorporator.Context, TypeSystemInferenceExtensionContext by c { + AbstractTypeCheckerContextForConstraintSystem(c), ConstraintIncorporator.Context, TypeSystemInferenceExtensionContext by c { // We use `var` intentionally to avoid extra allocations as this property is quite "hot" private var possibleNewConstraints: MutableList>? = null @@ -198,14 +198,6 @@ class ConstraintInjector( return baseContext.substitutionSupertypePolicy(type) } - override fun areEqualTypeConstructors(c1: TypeConstructorMarker, c2: TypeConstructorMarker): Boolean { - return baseContext.areEqualTypeConstructors(c1, c2) - } - - override fun prepareType(type: KotlinTypeMarker): KotlinTypeMarker { - return baseContext.prepareType(type) - } - override fun refineType(type: KotlinTypeMarker): KotlinTypeMarker { return with(constraintIncorporator.utilContext) { type.refineType() diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ExpectedActualResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ExpectedActualResolver.kt index 494efd77463..95f8fe6a603 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ExpectedActualResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ExpectedActualResolver.kt @@ -23,7 +23,9 @@ import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.TypeConstructorSubstitution import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.checker.ClassicTypeCheckerContext +import org.jetbrains.kotlin.types.checker.ClassicTypeSystemContext import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker +import org.jetbrains.kotlin.types.model.TypeConstructorMarker import org.jetbrains.kotlin.types.typeUtil.asTypeProjection import org.jetbrains.kotlin.utils.SmartList import org.jetbrains.kotlin.utils.keysToMap @@ -326,14 +328,17 @@ object ExpectedActualResolver { if (b == null) return false with(NewKotlinTypeChecker.Default) { - val context = object : ClassicTypeCheckerContext(false) { - override fun areEqualTypeConstructors(a: TypeConstructor, b: TypeConstructor): Boolean { - return isExpectedClassAndActualTypeAlias(a, b, platformModule) || - isExpectedClassAndActualTypeAlias(b, a, platformModule) || - super.areEqualTypeConstructors(a, b) + val context = object : ClassicTypeSystemContext { + override fun areEqualTypeConstructors(c1: TypeConstructorMarker, c2: TypeConstructorMarker): Boolean { + require(c1 is TypeConstructor) + require(c2 is TypeConstructor) + return isExpectedClassAndActualTypeAlias(c1, c2, platformModule) || + isExpectedClassAndActualTypeAlias(c2, c1, platformModule) || + super.areEqualTypeConstructors(c1, c2) } } - return context.equalTypes(a.unwrap(), b.unwrap()) + return ClassicTypeCheckerContext(errorTypeEqualsToAnything = false, typeSystemContext = context) + .equalTypes(a.unwrap(), b.unwrap()) } } diff --git a/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt b/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt index 017dd9873ed..3f0e2870800 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt @@ -13,15 +13,12 @@ import org.jetbrains.kotlin.utils.SmartSet import java.util.* -abstract class AbstractTypeCheckerContext : TypeSystemContext { +abstract class AbstractTypeCheckerContext() { + abstract val typeSystemContext: TypeSystemContext abstract fun substitutionSupertypePolicy(type: SimpleTypeMarker): SupertypesPolicy - override fun prepareType(type: KotlinTypeMarker): KotlinTypeMarker { - return type - } - open fun refineType(type: KotlinTypeMarker): KotlinTypeMarker { return type } @@ -34,7 +31,6 @@ abstract class AbstractTypeCheckerContext : TypeSystemContext { protected var argumentsDepth = 0 - internal inline fun runWithArgumentsSettings(subArgument: KotlinTypeMarker, f: AbstractTypeCheckerContext.() -> T): T { if (argumentsDepth > 100) { error("Arguments depth is too high. Some related argument: $subArgument") @@ -46,7 +42,8 @@ abstract class AbstractTypeCheckerContext : TypeSystemContext { return result } - open fun getLowerCapturedTypePolicy(subType: SimpleTypeMarker, superType: CapturedTypeMarker): LowerCapturedTypePolicy = CHECK_SUBTYPE_AND_LOWER + open fun getLowerCapturedTypePolicy(subType: SimpleTypeMarker, superType: CapturedTypeMarker): LowerCapturedTypePolicy = + CHECK_SUBTYPE_AND_LOWER open fun addSubtypeConstraint( subType: KotlinTypeMarker, @@ -109,7 +106,8 @@ abstract class AbstractTypeCheckerContext : TypeSystemContext { if (!visitedSupertypes.add(current)) continue val policy = supertypesPolicy(current).takeIf { it != SupertypesPolicy.None } ?: continue - for (supertype in current.typeConstructor().supertypes()) { + val supertypes = with(typeSystemContext) { current.typeConstructor().supertypes() } + for (supertype in supertypes) { val newType = policy.transformType(this, supertype) if (predicate(newType)) { clear() @@ -133,18 +131,21 @@ abstract class AbstractTypeCheckerContext : TypeSystemContext { object UpperIfFlexible : SupertypesPolicy() { override fun transformType(context: AbstractTypeCheckerContext, type: KotlinTypeMarker) = - with(context) { type.upperBoundIfFlexible() } + with(context.typeSystemContext) { type.upperBoundIfFlexible() } } object LowerIfFlexible : SupertypesPolicy() { override fun transformType(context: AbstractTypeCheckerContext, type: KotlinTypeMarker) = - with(context) { type.lowerBoundIfFlexible() } + with(context.typeSystemContext) { type.lowerBoundIfFlexible() } } abstract class DoCustomTransform : SupertypesPolicy() } abstract val KotlinTypeMarker.isAllowedTypeVariable: Boolean + + @JvmName("isAllowedTypeVariableBridge") + fun isAllowedTypeVariable(type: KotlinTypeMarker): Boolean = type.isAllowedTypeVariable } object AbstractTypeChecker { @@ -166,7 +167,7 @@ object AbstractTypeChecker { superConstructor: TypeConstructorMarker ): Boolean { if (typeConstructor == superConstructor) return true - with(context) { + with(context.typeSystemContext) { for (superType in typeConstructor.supertypes()) { if (isSubtypeOfClass(context, superType.typeConstructor(), superConstructor)) { return true @@ -182,7 +183,7 @@ object AbstractTypeChecker { b: KotlinTypeMarker, stubTypesEqualToAnything: Boolean = true ): Boolean { - return AbstractTypeChecker.equalTypes(context.newBaseTypeCheckerContext(false, stubTypesEqualToAnything), a, b) + return equalTypes(context.newBaseTypeCheckerContext(false, stubTypesEqualToAnything), a, b) } fun isSubtypeOf( @@ -195,55 +196,61 @@ object AbstractTypeChecker { if (!context.customIsSubtypeOf(subType, superType)) return false - return with(context) { - completeIsSubTypeOf(prepareType(refineType(subType)), prepareType(refineType(superType)), isFromNullabilityConstraint) - } + return completeIsSubTypeOf( + context, + context.typeSystemContext.prepareType(context.refineType(subType)), + context.typeSystemContext.prepareType(context.refineType(superType)), + isFromNullabilityConstraint + ) } - fun equalTypes(context: AbstractTypeCheckerContext, a: KotlinTypeMarker, b: KotlinTypeMarker): Boolean = with(context) { - if (a === b) return true + fun equalTypes(context: AbstractTypeCheckerContext, a: KotlinTypeMarker, b: KotlinTypeMarker): Boolean = + with(context.typeSystemContext) { + if (a === b) return true - if (isCommonDenotableType(a) && isCommonDenotableType(b)) { - val refinedA = refineType(a) - val refinedB = refineType(b) - val simpleA = refinedA.lowerBoundIfFlexible() - if (!areEqualTypeConstructors(refinedA.typeConstructor(), refinedB.typeConstructor())) return false - if (simpleA.argumentsCount() == 0) { - if (refinedA.hasFlexibleNullability() || refinedB.hasFlexibleNullability()) return true + if (isCommonDenotableType(a) && isCommonDenotableType(b)) { + val refinedA = context.refineType(a) + val refinedB = context.refineType(b) + val simpleA = refinedA.lowerBoundIfFlexible() + if (!areEqualTypeConstructors(refinedA.typeConstructor(), refinedB.typeConstructor())) return false + if (simpleA.argumentsCount() == 0) { + if (refinedA.hasFlexibleNullability() || refinedB.hasFlexibleNullability()) return true - return simpleA.isMarkedNullable() == refinedB.lowerBoundIfFlexible().isMarkedNullable() + return simpleA.isMarkedNullable() == refinedB.lowerBoundIfFlexible().isMarkedNullable() + } } + + return isSubtypeOf(context, a, b) && isSubtypeOf(context, b, a) } - return isSubtypeOf(context, a, b) && isSubtypeOf(context, b, a) - } - - private fun AbstractTypeCheckerContext.completeIsSubTypeOf( + private fun completeIsSubTypeOf( + context: AbstractTypeCheckerContext, subType: KotlinTypeMarker, superType: KotlinTypeMarker, isFromNullabilityConstraint: Boolean - ): Boolean { - checkSubtypeForSpecialCases(subType.lowerBoundIfFlexible(), superType.upperBoundIfFlexible())?.let { - addSubtypeConstraint(subType, superType, isFromNullabilityConstraint) + ): Boolean = with(context.typeSystemContext) { + checkSubtypeForSpecialCases(context, subType.lowerBoundIfFlexible(), superType.upperBoundIfFlexible())?.let { + context.addSubtypeConstraint(subType, superType, isFromNullabilityConstraint) return it } // we should add constraints with flexible types, otherwise we never get flexible type as answer in constraint system - addSubtypeConstraint(subType, superType, isFromNullabilityConstraint)?.let { return it } + context.addSubtypeConstraint(subType, superType, isFromNullabilityConstraint)?.let { return it } - return isSubtypeOfForSingleClassifierType(subType.lowerBoundIfFlexible(), superType.upperBoundIfFlexible()) + return isSubtypeOfForSingleClassifierType(context, subType.lowerBoundIfFlexible(), superType.upperBoundIfFlexible()) } - private fun AbstractTypeCheckerContext.checkSubtypeForIntegerLiteralType( + private fun checkSubtypeForIntegerLiteralType( + context: AbstractTypeCheckerContext, subType: SimpleTypeMarker, superType: SimpleTypeMarker - ): Boolean? { + ): Boolean? = with(context.typeSystemContext) { if (!subType.isIntegerLiteralType() && !superType.isIntegerLiteralType()) return null fun isTypeInIntegerLiteralType(integerLiteralType: SimpleTypeMarker, type: SimpleTypeMarker, checkSupertypes: Boolean): Boolean = integerLiteralType.possibleIntegerTypes().any { possibleType -> - (possibleType.typeConstructor() == type.typeConstructor()) || (checkSupertypes && isSubtypeOf(this, type, possibleType)) + (possibleType.typeConstructor() == type.typeConstructor()) || (checkSupertypes && isSubtypeOf(context, type, possibleType)) } fun isIntegerLiteralTypeInIntersectionComponents(type: SimpleTypeMarker): Boolean { @@ -276,12 +283,12 @@ object AbstractTypeChecker { return null } - private fun AbstractTypeCheckerContext.hasNothingSupertype(type: SimpleTypeMarker): Boolean { + private fun hasNothingSupertype(context: AbstractTypeCheckerContext, type: SimpleTypeMarker): Boolean = with(context.typeSystemContext) { val typeConstructor = type.typeConstructor() if (typeConstructor.isClassTypeConstructor()) { return typeConstructor.isNothingConstructor() } - return anySupertype(type, { it.typeConstructor().isNothingConstructor() }) { + return context.anySupertype(type, { it.typeConstructor().isNothingConstructor() }) { if (it.isClassType()) { SupertypesPolicy.None } else { @@ -290,20 +297,24 @@ object AbstractTypeChecker { } } - private fun AbstractTypeCheckerContext.isSubtypeOfForSingleClassifierType(subType: SimpleTypeMarker, superType: SimpleTypeMarker): Boolean { + private fun isSubtypeOfForSingleClassifierType( + context: AbstractTypeCheckerContext, + subType: SimpleTypeMarker, + superType: SimpleTypeMarker + ): Boolean = with(context.typeSystemContext) { if (AbstractTypeChecker.RUN_SLOW_ASSERTIONS) { - assert(subType.isSingleClassifierType() || subType.typeConstructor().isIntersection() || subType.isAllowedTypeVariable) { + assert(subType.isSingleClassifierType() || subType.typeConstructor().isIntersection() || context.isAllowedTypeVariable(subType)) { "Not singleClassifierType and not intersection subType: $subType" } - assert(superType.isSingleClassifierType() || superType.isAllowedTypeVariable) { + assert(superType.isSingleClassifierType() || context .isAllowedTypeVariable(superType)) { "Not singleClassifierType superType: $superType" } } - if (!AbstractNullabilityChecker.isPossibleSubtype(this, subType, superType)) return false + if (!AbstractNullabilityChecker.isPossibleSubtype(context, subType, superType)) return false - checkSubtypeForIntegerLiteralType(subType.lowerBoundIfFlexible(), superType.upperBoundIfFlexible())?.let { - addSubtypeConstraint(subType, superType) + checkSubtypeForIntegerLiteralType(context, subType.lowerBoundIfFlexible(), superType.upperBoundIfFlexible())?.let { + context.addSubtypeConstraint(subType, superType) return it } @@ -312,10 +323,10 @@ object AbstractTypeChecker { if (areEqualTypeConstructors(subType.typeConstructor(), superConstructor) && superConstructor.parametersCount() == 0) return true if (superType.typeConstructor().isAnyConstructor()) return true - val supertypesWithSameConstructor = findCorrespondingSupertypes(subType, superConstructor) + val supertypesWithSameConstructor = findCorrespondingSupertypes(context, subType, superConstructor) when (supertypesWithSameConstructor.size) { - 0 -> return hasNothingSupertype(subType) // todo Nothing & Array <: Array - 1 -> return isSubtypeForSameConstructor(supertypesWithSameConstructor.first().asArgumentList(), superType) + 0 -> return hasNothingSupertype(context, subType) // todo Nothing & Array <: Array + 1 -> return context.isSubtypeForSameConstructor(supertypesWithSameConstructor.first().asArgumentList(), superType) else -> { // at least 2 supertypes with same constructors. Such case is rare val newArguments = ArgumentList(superConstructor.parametersCount()) @@ -333,10 +344,10 @@ object AbstractTypeChecker { newArguments.add(intersection) } - if (!anyNonOutParameter && isSubtypeForSameConstructor(newArguments, superType)) return true + if (!anyNonOutParameter && context.isSubtypeForSameConstructor(newArguments, superType)) return true // TODO: rethink this; now components order in intersection type affects semantic due to run subtyping (which can add constraints) only until the first successful candidate - return supertypesWithSameConstructor.any { isSubtypeForSameConstructor(it.asArgumentList(), superType) } + return supertypesWithSameConstructor.any { context.isSubtypeForSameConstructor(it.asArgumentList(), superType) } } } } @@ -344,7 +355,7 @@ object AbstractTypeChecker { fun AbstractTypeCheckerContext.isSubtypeForSameConstructor( capturedSubArguments: TypeArgumentListMarker, superType: SimpleTypeMarker - ): Boolean { + ): Boolean = with(this.typeSystemContext) { // No way to check, as no index sometimes //if (capturedSubArguments === superType.arguments) return true @@ -375,7 +386,7 @@ object AbstractTypeChecker { return true } - private fun AbstractTypeCheckerContext.isCommonDenotableType(type: KotlinTypeMarker): Boolean = + private fun TypeSystemContext.isCommonDenotableType(type: KotlinTypeMarker): Boolean = type.typeConstructor().isDenotable() && !type.isDynamic() && !type.isDefinitelyNotNullType() && type.lowerBoundIfFlexible().typeConstructor() == type.upperBoundIfFlexible().typeConstructor() @@ -391,9 +402,13 @@ object AbstractTypeChecker { return null } - private fun AbstractTypeCheckerContext.checkSubtypeForSpecialCases(subType: SimpleTypeMarker, superType: SimpleTypeMarker): Boolean? { + private fun checkSubtypeForSpecialCases( + context: AbstractTypeCheckerContext, + subType: SimpleTypeMarker, + superType: SimpleTypeMarker + ): Boolean? = with(context.typeSystemContext) { if (subType.isError() || superType.isError()) { - if (isErrorTypeEqualsToAnything) return true + if (context.isErrorTypeEqualsToAnything) return true if (subType.isMarkedNullable() && !superType.isMarkedNullable()) return false @@ -404,7 +419,7 @@ object AbstractTypeChecker { ) } - if (subType.isStubType() || superType.isStubType()) return isStubTypeEqualsToAnything + if (subType.isStubType() || superType.isStubType()) return context.isStubTypeEqualsToAnything // superType might be a definitely notNull type (see KT-42824) val superOriginalType = superType.asDefinitelyNotNullType()?.original() ?: superType @@ -418,9 +433,9 @@ object AbstractTypeChecker { } else { if (superType.isDefinitelyNotNullType()) lowerType.makeDefinitelyNotNullOrNotNull() else lowerType } - when (getLowerCapturedTypePolicy(subType, superTypeCaptured)) { - CHECK_ONLY_LOWER -> return isSubtypeOf(this, subType, nullableLowerType) - CHECK_SUBTYPE_AND_LOWER -> if (isSubtypeOf(this, subType, nullableLowerType)) return true + when (context.getLowerCapturedTypePolicy(subType, superTypeCaptured)) { + CHECK_ONLY_LOWER -> return isSubtypeOf(context, subType, nullableLowerType) + CHECK_SUBTYPE_AND_LOWER -> if (isSubtypeOf(context, subType, nullableLowerType)) return true SKIP_LOWER -> Unit } } @@ -429,17 +444,18 @@ object AbstractTypeChecker { if (superTypeConstructor.isIntersection()) { assert(!superType.isMarkedNullable()) { "Intersection type should not be marked nullable!: $superType" } - return superTypeConstructor.supertypes().all { isSubtypeOf(this, subType, it) } + return superTypeConstructor.supertypes().all { isSubtypeOf(context, subType, it) } } return null } - private fun AbstractTypeCheckerContext.collectAllSupertypesWithGivenTypeConstructor( + private fun collectAllSupertypesWithGivenTypeConstructor( + context: AbstractTypeCheckerContext, subType: SimpleTypeMarker, superConstructor: TypeConstructorMarker - ): List { + ): List = with(context.typeSystemContext) { subType.fastCorrespondingSupertypes(superConstructor)?.let { return it } @@ -455,7 +471,7 @@ object AbstractTypeChecker { val result: MutableList = SmartList() - anySupertype(subType, { false }) { + context.anySupertype(subType, { false }) { val current = captureFromArguments(it, CaptureStatus.FOR_SUBTYPING) ?: it @@ -468,7 +484,7 @@ object AbstractTypeChecker { SupertypesPolicy.LowerIfFlexible } else -> { - substitutionSupertypePolicy(current) + context.substitutionSupertypePolicy(current) } } } @@ -476,8 +492,12 @@ object AbstractTypeChecker { return result } - private fun AbstractTypeCheckerContext.collectAndFilter(classType: SimpleTypeMarker, constructor: TypeConstructorMarker) = - selectOnlyPureKotlinSupertypes(collectAllSupertypesWithGivenTypeConstructor(classType, constructor)) + private fun collectAndFilter( + context: AbstractTypeCheckerContext, + classType: SimpleTypeMarker, + constructor: TypeConstructorMarker + ) = + selectOnlyPureKotlinSupertypes(context, collectAllSupertypesWithGivenTypeConstructor(context, classType, constructor)) /** @@ -490,7 +510,10 @@ object AbstractTypeChecker { * * More tests: javaAndKotlinSuperType & purelyImplementedCollection folder */ - private fun AbstractTypeCheckerContext.selectOnlyPureKotlinSupertypes(supertypes: List): List { + private fun selectOnlyPureKotlinSupertypes( + context: AbstractTypeCheckerContext, + supertypes: List + ): List = with(context.typeSystemContext) { if (supertypes.size < 2) return supertypes val allPureSupertypes = supertypes.filter { @@ -502,22 +525,23 @@ object AbstractTypeChecker { // nullability was checked earlier via nullabilityChecker // should be used only if you really sure that it is correct - fun AbstractTypeCheckerContext.findCorrespondingSupertypes( + fun findCorrespondingSupertypes( + context: AbstractTypeCheckerContext, subType: SimpleTypeMarker, superConstructor: TypeConstructorMarker - ): List { + ): List = with(context.typeSystemContext) { if (subType.isClassType()) { - return collectAndFilter(subType, superConstructor) + return collectAndFilter(context, subType, superConstructor) } // i.e. superType is not a classType if (!superConstructor.isClassTypeConstructor() && !superConstructor.isIntegerLiteralTypeConstructor()) { - return collectAllSupertypesWithGivenTypeConstructor(subType, superConstructor) + return collectAllSupertypesWithGivenTypeConstructor(context, subType, superConstructor) } // todo add tests val classTypeSupertypes = SmartList() - anySupertype(subType, { false }) { + context.anySupertype(subType, { false }) { if (it.isClassType()) { classTypeSupertypes.add(it) SupertypesPolicy.None @@ -526,7 +550,7 @@ object AbstractTypeChecker { } } - return classTypeSupertypes.flatMap { collectAndFilter(it, superConstructor) } + return classTypeSupertypes.flatMap { collectAndFilter(context, it, superConstructor) } } } @@ -534,7 +558,7 @@ object AbstractTypeChecker { object AbstractNullabilityChecker { // this method checks only nullability fun isPossibleSubtype(context: AbstractTypeCheckerContext, subType: SimpleTypeMarker, superType: SimpleTypeMarker): Boolean = - context.runIsPossibleSubtype(subType, superType) + runIsPossibleSubtype(context, subType, superType) fun isSubtypeOfAny(context: TypeCheckerProviderContext, type: KotlinTypeMarker): Boolean = AbstractNullabilityChecker.isSubtypeOfAny( @@ -546,82 +570,93 @@ object AbstractNullabilityChecker { ) fun isSubtypeOfAny(context: AbstractTypeCheckerContext, type: KotlinTypeMarker): Boolean = - with(context) { - hasNotNullSupertype(type.lowerBoundIfFlexible(), SupertypesPolicy.LowerIfFlexible) + with(context.typeSystemContext) { + context.hasNotNullSupertype(type.lowerBoundIfFlexible(), SupertypesPolicy.LowerIfFlexible) } - private fun AbstractTypeCheckerContext.runIsPossibleSubtype(subType: SimpleTypeMarker, superType: SimpleTypeMarker): Boolean { - if (AbstractTypeChecker.RUN_SLOW_ASSERTIONS) { - // it makes for case String? & Any <: String - assert(subType.isSingleClassifierType() || subType.typeConstructor().isIntersection() || subType.isAllowedTypeVariable) { - "Not singleClassifierType and not intersection subType: $subType" - } - assert(superType.isSingleClassifierType() || superType.isAllowedTypeVariable) { - "Not singleClassifierType superType: $superType" + private fun runIsPossibleSubtype(context: AbstractTypeCheckerContext, subType: SimpleTypeMarker, superType: SimpleTypeMarker): Boolean = + with(context.typeSystemContext) { + if (AbstractTypeChecker.RUN_SLOW_ASSERTIONS) { + // it makes for case String? & Any <: String + assert( + subType.isSingleClassifierType() || subType.typeConstructor().isIntersection() || context.isAllowedTypeVariable( + subType + ) + ) { + "Not singleClassifierType and not intersection subType: $subType" + } + assert(superType.isSingleClassifierType() || context.isAllowedTypeVariable(superType)) { + "Not singleClassifierType superType: $superType" + } } + + // superType is actually nullable + if (superType.isMarkedNullable()) return true + + // i.e. subType is definitely not null + if (subType.isDefinitelyNotNullType()) return true + + // i.e. subType is captured type, projection of which is marked not-null + if (subType is CapturedTypeMarker && subType.isProjectionNotNull()) return true + + // i.e. subType is not-nullable + if (context.hasNotNullSupertype(subType, SupertypesPolicy.LowerIfFlexible)) return true + + // i.e. subType hasn't not-null supertype and isn't definitely not-null, but superType is definitely not-null + if (superType.isDefinitelyNotNullType()) return false + + // i.e subType hasn't not-null supertype, but superType has + if (context.hasNotNullSupertype(superType, SupertypesPolicy.UpperIfFlexible)) return false + + // both superType and subType hasn't not-null supertype and are not definitely not null. + + /** + * If we still don't know, it means, that superType is not classType, for example -- type parameter. + * + * For captured types with lower bound this function can give to you false result. Example: + * class A, A => \exist Q : Number <: Q. A + * isPossibleSubtype(Number, Q) = false. + * Such cases should be taken in to account in [NewKotlinTypeChecker.isSubtypeOf] (same for intersection types) + */ + + // classType cannot has special type in supertype list + if (subType.isClassType()) return false + + return hasPathByNotMarkedNullableNodes(context, subType, superType.typeConstructor()) } - // superType is actually nullable - if (superType.isMarkedNullable()) return true - - // i.e. subType is definitely not null - if (subType.isDefinitelyNotNullType()) return true - - // i.e. subType is captured type, projection of which is marked not-null - if (subType is CapturedTypeMarker && subType.isProjectionNotNull()) return true - - // i.e. subType is not-nullable - if (hasNotNullSupertype(subType, SupertypesPolicy.LowerIfFlexible)) return true - - // i.e. subType hasn't not-null supertype and isn't definitely not-null, but superType is definitely not-null - if (superType.isDefinitelyNotNullType()) return false - - // i.e subType hasn't not-null supertype, but superType has - if (hasNotNullSupertype(superType, SupertypesPolicy.UpperIfFlexible)) return false - - // both superType and subType hasn't not-null supertype and are not definitely not null. - - /** - * If we still don't know, it means, that superType is not classType, for example -- type parameter. - * - * For captured types with lower bound this function can give to you false result. Example: - * class A, A => \exist Q : Number <: Q. A - * isPossibleSubtype(Number, Q) = false. - * Such cases should be taken in to account in [NewKotlinTypeChecker.isSubtypeOf] (same for intersection types) - */ - - // classType cannot has special type in supertype list - if (subType.isClassType()) return false - - return hasPathByNotMarkedNullableNodes(subType, superType.typeConstructor()) - } - fun AbstractTypeCheckerContext.hasNotNullSupertype(type: SimpleTypeMarker, supertypesPolicy: SupertypesPolicy) = - anySupertype(type, { - (it.isClassType() && !it.isMarkedNullable()) || it.isDefinitelyNotNullType() - }) { - if (it.isMarkedNullable()) SupertypesPolicy.None else supertypesPolicy + with(typeSystemContext) { + anySupertype(type, { + (it.isClassType() && !it.isMarkedNullable()) || it.isDefinitelyNotNullType() + }) { + if (it.isMarkedNullable()) SupertypesPolicy.None else supertypesPolicy + } } fun TypeCheckerProviderContext.hasPathByNotMarkedNullableNodes(start: SimpleTypeMarker, end: TypeConstructorMarker) = - newBaseTypeCheckerContext(errorTypesEqualToAnything = false, stubTypesEqualToAnything = true) - .hasPathByNotMarkedNullableNodes(start, end) - - fun AbstractTypeCheckerContext.hasPathByNotMarkedNullableNodes(start: SimpleTypeMarker, end: TypeConstructorMarker) = - anySupertype( - start, - { isApplicableAsEndNode(it, end) }, - { if (it.isMarkedNullable()) SupertypesPolicy.None else SupertypesPolicy.LowerIfFlexible } + hasPathByNotMarkedNullableNodes( + newBaseTypeCheckerContext(errorTypesEqualToAnything = false, stubTypesEqualToAnything = true), start, end ) - private fun AbstractTypeCheckerContext.isApplicableAsEndNode(type: SimpleTypeMarker, end: TypeConstructorMarker): Boolean { - if (type.isNothing()) return true - if (type.isMarkedNullable()) return false + fun hasPathByNotMarkedNullableNodes(context: AbstractTypeCheckerContext, start: SimpleTypeMarker, end: TypeConstructorMarker) = + with(context.typeSystemContext) { + context.anySupertype( + start, + { isApplicableAsEndNode(context, it, end) }, + { if (it.isMarkedNullable()) SupertypesPolicy.None else SupertypesPolicy.LowerIfFlexible } + ) + } - if (isStubTypeEqualsToAnything && type.isStubType()) return true + private fun isApplicableAsEndNode(context: AbstractTypeCheckerContext, type: SimpleTypeMarker, end: TypeConstructorMarker): Boolean = + with(context.typeSystemContext) { + if (type.isNothing()) return true + if (type.isMarkedNullable()) return false - return areEqualTypeConstructors(type.typeConstructor(), end) - } + if (context.isStubTypeEqualsToAnything && type.isStubType()) return true + + return areEqualTypeConstructors(type.typeConstructor(), end) + } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java index b8323730d34..95df25b7532 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java @@ -393,24 +393,28 @@ public class OverridingUtil { "Should be the same number of type parameters: " + firstParameters + " vs " + secondParameters; NewKotlinTypeCheckerImpl typeChecker = new NewKotlinTypeCheckerImpl(kotlinTypeRefiner); - OverridingUtilTypeCheckerContext context = createTypeCheckerContext(firstParameters, secondParameters); + ClassicTypeCheckerContext context = createTypeCheckerContext(firstParameters, secondParameters); return new Pair(typeChecker, context); } @NotNull - private OverridingUtilTypeCheckerContext createTypeCheckerContext( + private ClassicTypeCheckerContext createTypeCheckerContext( @NotNull List firstParameters, @NotNull List secondParameters ) { - if (firstParameters.isEmpty()) return new OverridingUtilTypeCheckerContext(null); + if (firstParameters.isEmpty()) { + return (ClassicTypeCheckerContext) new OverridingUtilTypeSystemContext(null, equalityAxioms, kotlinTypeRefiner) + .newBaseTypeCheckerContext(true, true); + } Map matchingTypeConstructors = new HashMap(); for (int i = 0; i < firstParameters.size(); i++) { matchingTypeConstructors.put(firstParameters.get(i).getTypeConstructor(), secondParameters.get(i).getTypeConstructor()); } - return new OverridingUtilTypeCheckerContext(matchingTypeConstructors); + return (ClassicTypeCheckerContext) new OverridingUtilTypeSystemContext(matchingTypeConstructors, equalityAxioms, kotlinTypeRefiner) + .newBaseTypeCheckerContext(true, true); } @Nullable @@ -977,34 +981,6 @@ public class OverridingUtil { return maxVisibility; } - private class OverridingUtilTypeCheckerContext extends ClassicTypeCheckerContext { - private final @Nullable Map matchingTypeConstructors; - - public OverridingUtilTypeCheckerContext(@Nullable Map matchingTypeConstructors) { - super( - /* errorTypesEqualsToAnything = */ true, - /* stubTypesEqualsToAnything = */ true, - /* allowedTypeVariable = */ true, - kotlinTypeRefiner - ); - this.matchingTypeConstructors = matchingTypeConstructors; - } - - @Override - public boolean areEqualTypeConstructors(@NotNull TypeConstructor a, @NotNull TypeConstructor b) { - return super.areEqualTypeConstructors(a, b) || areEqualTypeConstructorsByAxioms(a, b); - } - - private boolean areEqualTypeConstructorsByAxioms(@NotNull TypeConstructor a, @NotNull TypeConstructor b) { - if (equalityAxioms.equals(a, b)) return true; - if (matchingTypeConstructors == null) return false; - - TypeConstructor img1 = matchingTypeConstructors.get(a); - TypeConstructor img2 = matchingTypeConstructors.get(b); - return (img1 != null && img1.equals(b)) || (img2 != null && img2.equals(a)); - } - } - public static class OverrideCompatibilityInfo { public enum Result { OVERRIDABLE, diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtilTypeSystemContext.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtilTypeSystemContext.kt new file mode 100644 index 00000000000..46f0063ce70 --- /dev/null +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtilTypeSystemContext.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2010-2021 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.resolve + +import org.jetbrains.kotlin.types.AbstractTypeCheckerContext +import org.jetbrains.kotlin.types.TypeConstructor +import org.jetbrains.kotlin.types.checker.ClassicTypeCheckerContext +import org.jetbrains.kotlin.types.checker.ClassicTypeSystemContext +import org.jetbrains.kotlin.types.checker.KotlinTypeChecker +import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner +import org.jetbrains.kotlin.types.model.TypeConstructorMarker + +class OverridingUtilTypeSystemContext( + val matchingTypeConstructors: Map?, + private val equalityAxioms: KotlinTypeChecker.TypeConstructorEquality, + val kotlinTypeRefiner: KotlinTypeRefiner +) : ClassicTypeSystemContext { + + override fun areEqualTypeConstructors(c1: TypeConstructorMarker, c2: TypeConstructorMarker): Boolean { + require(c1 is TypeConstructor) + require(c2 is TypeConstructor) + return super.areEqualTypeConstructors(c1, c2) || areEqualTypeConstructorsByAxioms(c1, c2) + } + + override fun newBaseTypeCheckerContext( + errorTypesEqualToAnything: Boolean, + stubTypesEqualToAnything: Boolean + ): AbstractTypeCheckerContext { + return ClassicTypeCheckerContext( + errorTypesEqualToAnything, + stubTypesEqualToAnything, + allowedTypeVariable = true, + kotlinTypeRefiner, + this + ) + } + + private fun areEqualTypeConstructorsByAxioms(a: TypeConstructor, b: TypeConstructor): Boolean { + if (equalityAxioms.equals(a, b)) return true + if (matchingTypeConstructors == null) return false + val img1 = matchingTypeConstructors[a] + val img2 = matchingTypeConstructors[b] + return img1 != null && img1 == b || img2 != null && img2 == a + } +} \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeCheckerContext.kt b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeCheckerContext.kt index 47b2463e5d8..cc0abecc465 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeCheckerContext.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeCheckerContext.kt @@ -16,24 +16,18 @@ package org.jetbrains.kotlin.types.checker -import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.model.KotlinTypeMarker import org.jetbrains.kotlin.types.model.SimpleTypeMarker -import org.jetbrains.kotlin.types.model.TypeConstructorMarker import org.jetbrains.kotlin.types.refinement.TypeRefinement open class ClassicTypeCheckerContext( val errorTypeEqualsToAnything: Boolean, val stubTypeEqualsToAnything: Boolean = true, val allowedTypeVariable: Boolean = true, - val kotlinTypeRefiner: KotlinTypeRefiner = KotlinTypeRefiner.Default -) : ClassicTypeSystemContext, AbstractTypeCheckerContext() { - - override fun prepareType(type: KotlinTypeMarker): KotlinTypeMarker { - require(type is KotlinType, type::errorMessage) - return NewKotlinTypeChecker.Default.transformToNewType(type.unwrap()) - } + val kotlinTypeRefiner: KotlinTypeRefiner = KotlinTypeRefiner.Default, + override val typeSystemContext: ClassicTypeSystemContext = SimpleClassicTypeSystemContext +) : AbstractTypeCheckerContext() { @OptIn(TypeRefinement::class) override fun refineType(type: KotlinTypeMarker): KotlinTypeMarker { @@ -47,25 +41,8 @@ open class ClassicTypeCheckerContext( override val isStubTypeEqualsToAnything: Boolean get() = stubTypeEqualsToAnything - override fun areEqualTypeConstructors(c1: TypeConstructorMarker, c2: TypeConstructorMarker): Boolean { - require(c1 is TypeConstructor, c1::errorMessage) - require(c2 is TypeConstructor, c2::errorMessage) - return areEqualTypeConstructors(c1, c2) - } - - open fun areEqualTypeConstructors(a: TypeConstructor, b: TypeConstructor): Boolean = when { - /* - * For integer literal types we have special rules for constructor's equality, - * so we have to check it manually - * For example: Int in ILT.possibleTypes -> ILT == Int - */ - a is IntegerLiteralTypeConstructor -> a.checkConstructor(b) - b is IntegerLiteralTypeConstructor -> b.checkConstructor(a) - else -> a == b - } - override fun substitutionSupertypePolicy(type: SimpleTypeMarker): SupertypesPolicy.DoCustomTransform { - return classicSubstitutionSupertypePolicy(type) + return typeSystemContext.classicSubstitutionSupertypePolicy(type) } override val KotlinTypeMarker.isAllowedTypeVariable: Boolean get() = this is UnwrappedType && allowedTypeVariable && constructor is NewTypeVariableConstructor diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt index 4bc8700e92f..f929d3e2598 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt @@ -341,7 +341,7 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy errorTypesEqualToAnything: Boolean, stubTypesEqualToAnything: Boolean ): AbstractTypeCheckerContext { - return ClassicTypeCheckerContext(errorTypesEqualToAnything, stubTypesEqualToAnything) + return ClassicTypeCheckerContext(errorTypesEqualToAnything, stubTypesEqualToAnything, typeSystemContext = this) } override fun nullableNothingType(): SimpleTypeMarker { @@ -485,8 +485,8 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy } override fun prepareType(type: KotlinTypeMarker): KotlinTypeMarker { - require(type is UnwrappedType, type::errorMessage) - return NewKotlinTypeChecker.Default.transformToNewType(type) + require(type is KotlinType, type::errorMessage) + return NewKotlinTypeChecker.Default.transformToNewType(type.unwrap()) } override fun DefinitelyNotNullTypeMarker.original(): SimpleTypeMarker { diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt index ea772b79def..c3e8ab530e8 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic +import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.ConeTypeCheckerContext import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnostic @@ -33,6 +34,6 @@ internal interface KtFirAnalysisSessionComponent { fun createTypeCheckerContext() = ConeTypeCheckerContext( isErrorTypeEqualsToAnything = true, isStubTypeEqualsToAnything = true, - analysisSession.firResolveState.rootModuleSession //TODO use correct session here + analysisSession.firResolveState.rootModuleSession.typeContext //TODO use correct session here ) } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt index 0f83ed081d3..579be6e5685 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt @@ -52,11 +52,14 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfoAfter import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.source.getPsi +import org.jetbrains.kotlin.types.AbstractTypeCheckerContext import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.checker.ClassicTypeCheckerContext +import org.jetbrains.kotlin.types.checker.ClassicTypeSystemContext import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker +import org.jetbrains.kotlin.types.model.TypeConstructorMarker import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.ifEmpty import org.jetbrains.kotlin.utils.sure @@ -73,11 +76,16 @@ object KotlinIntroduceVariableHandler : RefactoringActionHandler { private var KtExpression.isOccurrence: Boolean by NotNullablePsiCopyableUserDataProperty(Key.create("OCCURRENCE"), false) private class TypeCheckerImpl(private val project: Project) : KotlinTypeChecker by KotlinTypeChecker.DEFAULT { - private inner class ContextImpl : ClassicTypeCheckerContext(false) { - override fun areEqualTypeConstructors(a: TypeConstructor, b: TypeConstructor): Boolean = - compareDescriptors(project, a.declarationDescriptor, b.declarationDescriptor) + private inner class TypeSystemContextImpl : ClassicTypeSystemContext { + override fun areEqualTypeConstructors(c1: TypeConstructorMarker, c2: TypeConstructorMarker): Boolean { + require(c1 is TypeConstructor) + require(c2 is TypeConstructor) + return compareDescriptors(project, c1.declarationDescriptor, c2.declarationDescriptor) + } } + private inner class ContextImpl : ClassicTypeCheckerContext(false, typeSystemContext = TypeSystemContextImpl()) + override fun equalTypes(a: KotlinType, b: KotlinType): Boolean = with(NewKotlinTypeChecker.Default) { ContextImpl().equalTypes(a.unwrap(), b.unwrap()) } From 83836037f8ee4541e206a564babb2d540e9d09a3 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 10 Feb 2021 18:38:31 +0300 Subject: [PATCH 154/368] Add documentation on type checker context / type system context --- .../kotlin/types/AbstractTypeChecker.kt | 10 ++++++++- .../kotlin/types/model/TypeSystemContext.kt | 21 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt b/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt index 3f0e2870800..ddba646ece2 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt @@ -12,7 +12,15 @@ import org.jetbrains.kotlin.utils.SmartList import org.jetbrains.kotlin.utils.SmartSet import java.util.* - +/** + * Context that defines how type-checker operates, stores type-checker state, + * created by [TypeCheckerProviderContext.newBaseTypeCheckerContext] in most cases + * + * Stateful and shouldn't be reused + * + * Once some type-checker operation is performed using a [TypeCheckerProviderContext], for example a [AbstractTypeChecker.isSubtypeOf], + * new instance of particular [AbstractTypeCheckerContext] should be created, with properly specified type system context + */ abstract class AbstractTypeCheckerContext() { abstract val typeSystemContext: TypeSystemContext diff --git a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt index 81a35b99371..28051c7825d 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt @@ -61,6 +61,9 @@ interface TypeSystemOptimizationContext { fun identicalArguments(a: SimpleTypeMarker, b: SimpleTypeMarker) = false } +/** + * Context that allow type-impl agnostic access to common types + */ interface TypeSystemBuiltInsContext { fun nullableNothingType(): SimpleTypeMarker fun nullableAnyType(): SimpleTypeMarker @@ -68,6 +71,9 @@ interface TypeSystemBuiltInsContext { fun anyType(): SimpleTypeMarker } +/** + * Context that allow construction of types + */ interface TypeSystemTypeFactoryContext { fun createFlexibleType(lowerBound: SimpleTypeMarker, upperBound: SimpleTypeMarker): KotlinTypeMarker fun createSimpleType( @@ -85,7 +91,10 @@ interface TypeSystemTypeFactoryContext { fun createErrorTypeWithCustomConstructor(debugName: String, constructor: TypeConstructorMarker): KotlinTypeMarker } - +/** + * Factory, that constructs [AbstractTypeCheckerContext], which defines type-checker behaviour + * Implementation is recommended to be [TypeSystemContext] + */ interface TypeCheckerProviderContext { fun newBaseTypeCheckerContext( errorTypesEqualToAnything: Boolean, @@ -93,6 +102,9 @@ interface TypeCheckerProviderContext { ): AbstractTypeCheckerContext } +/** + * Extended type system context, which defines set of operations specific to common super-type calculation + */ interface TypeSystemCommonSuperTypesContext : TypeSystemContext, TypeSystemTypeFactoryContext, TypeCheckerProviderContext { fun KotlinTypeMarker.anySuperTypeConstructor(predicate: (TypeConstructorMarker) -> Boolean) = @@ -130,6 +142,9 @@ interface TypeSystemCommonSuperTypesContext : TypeSystemContext, TypeSystemTypeF // component implementation for TypeSystemInferenceExtensionContext interface TypeSystemInferenceExtensionContextDelegate : TypeSystemInferenceExtensionContext +/** + * Extended type system context, which defines set of type operations specific for type inference + */ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBuiltInsContext, TypeSystemCommonSuperTypesContext { fun KotlinTypeMarker.contains(predicate: (KotlinTypeMarker) -> Boolean): Boolean @@ -228,7 +243,9 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui class ArgumentList(initialSize: Int) : ArrayList(initialSize), TypeArgumentListMarker - +/** + * Defines common kotlin type operations with types for abstract types + */ interface TypeSystemContext : TypeSystemOptimizationContext { fun KotlinTypeMarker.asSimpleType(): SimpleTypeMarker? fun KotlinTypeMarker.asFlexibleType(): FlexibleTypeMarker? From fa1507fb91a4a6a05a7e7b3ee71d68813e300318 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Mon, 15 Feb 2021 18:51:22 +0300 Subject: [PATCH 155/368] Fix FIR test `lambdaParameterTypeInElvis` --- .../inference/lambdaParameterTypeInElvis.fir.kt | 14 -------------- .../tests/inference/lambdaParameterTypeInElvis.kt | 1 + 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt diff --git a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt deleted file mode 100644 index 08cdc63c5a2..00000000000 --- a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.fir.kt +++ /dev/null @@ -1,14 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNREACHABLE_CODE - -interface Some { - fun method(): Unit -} - -fun elvis(nullable: S?, notNullable: S): S = TODO() - -fun Some.doWithPredicate(predicate: (R) -> Unit): R? = TODO() - -fun test(derived: Some) { - val expected: Some = derived.doWithPredicate { it.method() } ?: TODO() - val expected2: Some = elvis(derived.doWithPredicate { it.method() }, TODO()) -} diff --git a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt index 8924f9b4924..a365e67ebef 100644 --- a/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt +++ b/compiler/testData/diagnostics/tests/inference/lambdaParameterTypeInElvis.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -UNREACHABLE_CODE interface Some { From 9370f918e9d36ad630378417278a5b3ca40a9807 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Mon, 8 Feb 2021 15:49:48 -0800 Subject: [PATCH 156/368] FIR: use override checker when populating directOverriddenProperties --- .../scopes/impl/FirClassUseSiteMemberScope.kt | 18 +++++++- .../enum/overrideFinalEnumMethods.fir.kt | 11 ----- .../tests/enum/overrideFinalEnumMethods.kt | 1 + .../tests/j+k/properties/isName.fir.kt | 27 ------------ .../tests/j+k/properties/isName.kt | 1 + .../tests/j+k/properties/val.fir.kt | 25 ----------- .../diagnostics/tests/j+k/properties/val.kt | 1 + .../tests/j+k/properties/var.fir.kt | 42 ------------------- .../diagnostics/tests/j+k/properties/var.kt | 1 + 9 files changed, 20 insertions(+), 107 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/properties/isName.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/properties/val.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/properties/var.fir.kt diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteMemberScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteMemberScope.kt index d8b87d92d94..d21185e1846 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteMemberScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassUseSiteMemberScope.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.FirTypeScope import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol @@ -23,6 +24,10 @@ class FirClassUseSiteMemberScope( val seen = mutableSetOf>() declaredMemberScope.processPropertiesByName(name) l@{ if (it.isStatic) return@l + if (it is FirPropertySymbol) { + val directOverridden = computeDirectOverridden(it.fir) + this@FirClassUseSiteMemberScope.directOverriddenProperties[it] = directOverridden + } seen += it processor(it) } @@ -31,9 +36,18 @@ class FirClassUseSiteMemberScope( val overriddenBy = it.getOverridden(seen) if (overriddenBy == null) { processor(it) - } else if (overriddenBy is FirPropertySymbol && it is FirPropertySymbol) { - directOverriddenProperties.getOrPut(overriddenBy) { mutableListOf() }.add(it) } } } + + private fun computeDirectOverridden(property: FirProperty): MutableList { + val result = mutableListOf() + superTypesScope.processPropertiesByName(property.name) l@{ superSymbol -> + if (superSymbol !is FirPropertySymbol) return@l + if (overrideChecker.isOverriddenProperty(property, superSymbol.fir)) { + result.add(superSymbol) + } + } + return result + } } diff --git a/compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.fir.kt b/compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.fir.kt deleted file mode 100644 index 56a79f9ed22..00000000000 --- a/compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.fir.kt +++ /dev/null @@ -1,11 +0,0 @@ -enum class E { - ENTRY; - - override val name: String = "lol" - override val ordinal: Int = 0 - - override fun compareTo(other: E) = -1 - - override fun equals(other: Any?) = true - override fun hashCode() = -1 -} diff --git a/compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.kt b/compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.kt index aaf621d6bb2..a62c19554dd 100644 --- a/compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.kt +++ b/compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL enum class E { ENTRY; diff --git a/compiler/testData/diagnostics/tests/j+k/properties/isName.fir.kt b/compiler/testData/diagnostics/tests/j+k/properties/isName.fir.kt deleted file mode 100644 index 3e86adc7ca0..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/properties/isName.fir.kt +++ /dev/null @@ -1,27 +0,0 @@ -// FILE: A.java - -public class A extends B { - public int isFoo() { return 0; } - public void setFoo(int x) {} -} - -// FILE: F.java - -public class F extends B { - public final int isFoo() { return 0; } - public final void setFoo(int x) {} -} - -// FILE: main.kt - -open class B { - open var isFoo: Int = 1 -} - -class C1 : A() { - override var isFoo: Int = 2 -} - -class C2 : F() { - override var isFoo: Int = 3 -} diff --git a/compiler/testData/diagnostics/tests/j+k/properties/isName.kt b/compiler/testData/diagnostics/tests/j+k/properties/isName.kt index e990adaad05..70871528759 100644 --- a/compiler/testData/diagnostics/tests/j+k/properties/isName.kt +++ b/compiler/testData/diagnostics/tests/j+k/properties/isName.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: A.java public class A extends B { diff --git a/compiler/testData/diagnostics/tests/j+k/properties/val.fir.kt b/compiler/testData/diagnostics/tests/j+k/properties/val.fir.kt deleted file mode 100644 index 63aa0476c5d..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/properties/val.fir.kt +++ /dev/null @@ -1,25 +0,0 @@ -// FILE: A.java - -public class A extends B { - public int getFoo() { return 0; } -} - -// FILE: F.java - -public class F extends B { - public final int getFoo() { return 0; } -} - -// FILE: main.kt - -open class B { - open val foo: Int = 1 -} - -class C1 : A() { - override val foo: Int = 2 -} - -class C2 : F() { - override val foo: Int = 3 -} diff --git a/compiler/testData/diagnostics/tests/j+k/properties/val.kt b/compiler/testData/diagnostics/tests/j+k/properties/val.kt index 16d31136602..1e422bef0bb 100644 --- a/compiler/testData/diagnostics/tests/j+k/properties/val.kt +++ b/compiler/testData/diagnostics/tests/j+k/properties/val.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: A.java public class A extends B { diff --git a/compiler/testData/diagnostics/tests/j+k/properties/var.fir.kt b/compiler/testData/diagnostics/tests/j+k/properties/var.fir.kt deleted file mode 100644 index 41e5c92ff12..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/properties/var.fir.kt +++ /dev/null @@ -1,42 +0,0 @@ -// FILE: A.java - -public class A extends B { - public int getFoo() { return 0; } - public void setFoo(int x) {} -} - -// FILE: F.java - -public class F extends B { - public final int getFoo() { return 0; } - public final void setFoo(int x) {} -} - -// FILE: ConflictingModality.java - -public class ConflictingModality extends B { - public final int getFoo() { return 0; } - public abstract void setFoo(int x) {} -} - -// FILE: ConflictingVisibility.java - -public class ConflictingVisibility extends B { - public int getFoo() { return 0; } - protected void setFoo(int x) {} -} - -// FILE: main.kt - -open class B { - // check that final is not overridden - open protected var foo: Int = 1 -} - -class C1 : A() { - override var foo: Int = 2 -} - -class C2 : F() { - override var foo: Int = 3 -} diff --git a/compiler/testData/diagnostics/tests/j+k/properties/var.kt b/compiler/testData/diagnostics/tests/j+k/properties/var.kt index df5441b39b8..e34a2ce1ed9 100644 --- a/compiler/testData/diagnostics/tests/j+k/properties/var.kt +++ b/compiler/testData/diagnostics/tests/j+k/properties/var.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: A.java public class A extends B { From 09640d9d63a04933ff202d07a21751db0d0464ee Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Mon, 8 Feb 2021 16:03:35 -0800 Subject: [PATCH 157/368] FIR checker: apply override checker to anonymous objects ^KT-44695 Fixed --- .../checkers/declaration/FirOverrideChecker.kt | 4 ++-- .../fir/checkers/CommonDeclarationCheckers.kt | 2 +- .../tests/enum/openMemberInEnum.fir.kt | 17 ----------------- .../diagnostics/tests/enum/openMemberInEnum.kt | 1 + .../abstract-classes/p-2/neg/1.2.fir.kt | 4 ++-- 5 files changed, 6 insertions(+), 22 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/enum/openMemberInEnum.fir.kt diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOverrideChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOverrideChecker.kt index 401a0297724..9acf658006f 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOverrideChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOverrideChecker.kt @@ -26,8 +26,8 @@ import org.jetbrains.kotlin.types.AbstractTypeCheckerContext import org.jetbrains.kotlin.utils.addToStdlib.min import org.jetbrains.kotlin.utils.addToStdlib.safeAs -object FirOverrideChecker : FirRegularClassChecker() { - override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { +object FirOverrideChecker : FirClassChecker() { + override fun check(declaration: FirClass<*>, context: CheckerContext, reporter: DiagnosticReporter) { val typeCheckerContext = context.session.typeContext.newBaseTypeCheckerContext( errorTypesEqualToAnything = false, stubTypesEqualToAnything = false diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt index b0483c84c70..a158c5d35d9 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt @@ -37,6 +37,7 @@ object CommonDeclarationCheckers : DeclarationCheckers() { ) override val classCheckers: Set = setOf( + FirOverrideChecker, FirThrowableSubclassChecker, ) @@ -51,7 +52,6 @@ object CommonDeclarationCheckers : DeclarationCheckers() { FirLocalEntityNotAllowedChecker, FirManyCompanionObjectsChecker, FirMethodOfAnyImplementedInInterfaceChecker, - FirOverrideChecker, FirPrimaryConstructorRequiredForDataClassChecker, FirSupertypeInitializedInInterfaceChecker, FirSupertypeInitializedWithoutPrimaryConstructor, diff --git a/compiler/testData/diagnostics/tests/enum/openMemberInEnum.fir.kt b/compiler/testData/diagnostics/tests/enum/openMemberInEnum.fir.kt deleted file mode 100644 index 7f2e397e0fb..00000000000 --- a/compiler/testData/diagnostics/tests/enum/openMemberInEnum.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ -enum class EnumWithOpenMembers { - E1 { - override fun foo() = 1 - override val bar: String = "a" - }, - - E2 { - override fun f() = 3 - override val b = 4 - }; - - open fun foo() = 1 - open val bar: String = "" - - fun f() = 2 - val b = 3 -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/enum/openMemberInEnum.kt b/compiler/testData/diagnostics/tests/enum/openMemberInEnum.kt index d5e1eda0052..a128cabd3c7 100644 --- a/compiler/testData/diagnostics/tests/enum/openMemberInEnum.kt +++ b/compiler/testData/diagnostics/tests/enum/openMemberInEnum.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL enum class EnumWithOpenMembers { E1 { override fun foo() = 1 diff --git a/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/neg/1.2.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/neg/1.2.fir.kt index 1bb1365eb9d..8fd15d1f07f 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/neg/1.2.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/neg/1.2.fir.kt @@ -21,12 +21,12 @@ fun case1() { override var a: Any get() = TODO() set(value) {} - override val b: Any + override val b: Any get() = TODO() override var c: Any get() = TODO() set(value) {} - override val d: Any + override val d: Any get() = TODO() override fun foo() {} From a884555171227fc010c4d361755d2cec9c0b9439 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Fri, 12 Feb 2021 16:12:21 -0800 Subject: [PATCH 158/368] FIR: bail out early for override check if base candidate is private --- .../scopes/impl/FirStandardOverrideChecker.kt | 5 +++++ .../ideRegression/OverridingProtected.kt | 3 ++- .../properties/privatePropertyInConstructor.kt | 16 ++++++++++++---- .../override/AllPrivateFromSuperTypes.fir.kt | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt index ec62dfa1ce6..1fb60f89f84 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirStandardOverrideChecker.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.scopes.impl +import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor @@ -109,6 +110,8 @@ class FirStandardOverrideChecker(session: FirSession) : FirAbstractOverrideCheck } override fun isOverriddenFunction(overrideCandidate: FirSimpleFunction, baseDeclaration: FirSimpleFunction): Boolean { + if (Visibilities.isPrivate(baseDeclaration.visibility)) return false + if (overrideCandidate.valueParameters.size != baseDeclaration.valueParameters.size) return false val substitutor = buildTypeParametersSubstitutorIfCompatible(overrideCandidate, baseDeclaration) ?: return false @@ -124,6 +127,8 @@ class FirStandardOverrideChecker(session: FirSession) : FirAbstractOverrideCheck overrideCandidate: FirCallableMemberDeclaration<*>, baseDeclaration: FirProperty ): Boolean { + if (Visibilities.isPrivate(baseDeclaration.visibility)) return false + if (overrideCandidate !is FirProperty) return false val substitutor = buildTypeParametersSubstitutorIfCompatible(overrideCandidate, baseDeclaration) ?: return false return isEqualReceiverTypes(overrideCandidate.receiverTypeRef, baseDeclaration.receiverTypeRef, substitutor) diff --git a/compiler/testData/asJava/lightClasses/ideRegression/OverridingProtected.kt b/compiler/testData/asJava/lightClasses/ideRegression/OverridingProtected.kt index ed15b56c733..b1c9296ec36 100644 --- a/compiler/testData/asJava/lightClasses/ideRegression/OverridingProtected.kt +++ b/compiler/testData/asJava/lightClasses/ideRegression/OverridingProtected.kt @@ -10,4 +10,5 @@ class C : A() { } } -// LAZINESS:NoLaziness \ No newline at end of file +// LAZINESS:NoLaziness +// FIR_COMPARISON \ No newline at end of file diff --git a/compiler/testData/codegen/box/properties/privatePropertyInConstructor.kt b/compiler/testData/codegen/box/properties/privatePropertyInConstructor.kt index 9a9e186c8de..dccd29484ce 100644 --- a/compiler/testData/codegen/box/properties/privatePropertyInConstructor.kt +++ b/compiler/testData/codegen/box/properties/privatePropertyInConstructor.kt @@ -1,10 +1,11 @@ -class A( - private val x: String, - private var y: Double +open class A( + private val x: String, + private var y: Double ) { fun foo() { val r = { if (x != "abc") throw AssertionError("$x") + if (y < 0.0) throw AssertionError("$y < 0.0") y = 0.0 if (y != 0.0) throw AssertionError("$y") } @@ -12,7 +13,14 @@ class A( } } +class B( + val x: String, + y: Double +) : A("abc", y) + fun box(): String { A("abc", 3.14).foo() - return "OK" + val b = B("OK", 0.42) + b.foo() + return b.x } diff --git a/compiler/testData/diagnostics/tests/override/AllPrivateFromSuperTypes.fir.kt b/compiler/testData/diagnostics/tests/override/AllPrivateFromSuperTypes.fir.kt index 1d3a12557f7..a4844798bb0 100644 --- a/compiler/testData/diagnostics/tests/override/AllPrivateFromSuperTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/override/AllPrivateFromSuperTypes.fir.kt @@ -10,5 +10,5 @@ open class C { } class Subject : C(), A { - val c = a + val c = a } From 3432f581cb29b677f3307425bc7da95628b43ba4 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 9 Feb 2021 14:00:17 +0100 Subject: [PATCH 159/368] Remove compiler support for kotlin-annotations-android #KT-44815 --- .../kotlin/codegen/ArgumentGenerator.kt | 38 ++------------- .../codegen/CallBasedArgumentGenerator.kt | 6 --- .../kotlin/codegen/ExpressionCodegen.java | 10 ++-- .../ObjectSuperCallArgumentGenerator.kt | 7 --- .../jetbrains/kotlin/codegen/StackValue.kt | 48 ------------------- .../java/enhancement/SignatureEnhancement.kt | 30 ++++-------- .../fir/java/enhancement/javaTypeUtils.kt | 27 ----------- .../SignaturesPropagationData.java | 21 ++------ .../kotlin/load/java/JvmAnnotationNames.java | 4 -- .../descriptors/AnnotationDefaultValue.kt | 12 ----- .../kotlin/load/java/descriptors/util.kt | 27 ----------- .../java/lazy/descriptors/LazyJavaScope.kt | 12 ----- .../typeEnhancement/signatureEnhancement.kt | 24 +--------- .../org/jetbrains/kotlin/load/java/utils.kt | 47 ++---------------- 14 files changed, 28 insertions(+), 285 deletions(-) delete mode 100644 core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/descriptors/AnnotationDefaultValue.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ArgumentGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/ArgumentGenerator.kt index 63fd2f20488..57f8ae0e693 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ArgumentGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ArgumentGenerator.kt @@ -20,11 +20,9 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor import org.jetbrains.kotlin.resolve.calls.components.hasDefaultValue import org.jetbrains.kotlin.resolve.calls.model.* import org.jetbrains.kotlin.resolve.descriptorUtil.overriddenTreeUniqueAsSequence -import org.jetbrains.kotlin.utils.DFS import org.jetbrains.kotlin.utils.mapToIndex class ArgumentAndDeclIndex(val arg: ResolvedValueArgument, val declIndex: Int) @@ -70,12 +68,8 @@ abstract class ArgumentGenerator { generateExpression(declIndex, argument) } is DefaultValueArgument -> { - if (calleeDescriptor?.defaultValueFromJava(declIndex) == true) { - generateDefaultJava(declIndex, argument) - } else { - defaultArgs.mark(declIndex) - generateDefault(declIndex, argument) - } + defaultArgs.mark(declIndex) + generateDefault(declIndex, argument) } is VarargValueArgument -> { generateVararg(declIndex, argument) @@ -103,10 +97,6 @@ abstract class ArgumentGenerator { throw UnsupportedOperationException("Unsupported vararg value argument #$i: $argument") } - protected open fun generateDefaultJava(i: Int, argument: DefaultValueArgument) { - throw UnsupportedOperationException("Unsupported default java argument #$i: $argument") - } - protected open fun generateOther(i: Int, argument: ResolvedValueArgument) { throw UnsupportedOperationException("Unsupported value argument #$i: $argument") } @@ -116,28 +106,6 @@ abstract class ArgumentGenerator { } } -private fun CallableDescriptor.defaultValueFromJava(index: Int): Boolean = DFS.ifAny( - listOf(this), - { current -> current.original.overriddenDescriptors.map { it.original } }, - { descriptor -> - descriptor.original.overriddenDescriptors.isEmpty() && - descriptor is JavaCallableMemberDescriptor && - descriptor.valueParameters[index].declaresDefaultValue() - } -) - -fun shouldInvokeDefaultArgumentsStub(resolvedCall: ResolvedCall<*>): Boolean { - val descriptor = resolvedCall.resultingDescriptor - val valueArgumentsByIndex = resolvedCall.valueArgumentsByIndex ?: return false - for (index in valueArgumentsByIndex.indices) { - val resolvedValueArgument = valueArgumentsByIndex[index] - if (resolvedValueArgument is DefaultValueArgument && !descriptor.defaultValueFromJava(index)) { - return true - } - } - return false -} - fun getFunctionWithDefaultArguments(functionDescriptor: FunctionDescriptor): FunctionDescriptor { if (functionDescriptor.containingDeclaration !is ClassDescriptor) return functionDescriptor if (functionDescriptor.overriddenDescriptors.isEmpty()) return functionDescriptor @@ -155,4 +123,4 @@ fun getFunctionWithDefaultArguments(functionDescriptor: FunctionDescriptor): Fun function.valueParameters.any { valueParameter -> valueParameter.hasDefaultValue() } } ?: functionDescriptor -} \ No newline at end of file +} diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallBasedArgumentGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallBasedArgumentGenerator.kt index c9918229723..2af03c53ab4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CallBasedArgumentGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CallBasedArgumentGenerator.kt @@ -72,12 +72,6 @@ class CallBasedArgumentGenerator( callGenerator.putValueIfNeeded(getJvmKotlinType(i), lazyVararg, ValueKind.GENERAL_VARARG, i) } - override fun generateDefaultJava(i: Int, argument: DefaultValueArgument) { - val argumentValue = valueParameters[i].findJavaDefaultArgumentValue(valueParameterTypes[i], codegen.typeMapper) - - callGenerator.putValueIfNeeded(getJvmKotlinType(i), argumentValue) - } - override fun reorderArgumentsIfNeeded(args: List) { callGenerator.reorderArgumentsIfNeeded(args, valueParameterTypes) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 974f617c47d..cb23cd5c181 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -74,7 +74,10 @@ import org.jetbrains.kotlin.resolve.constants.*; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluatorKt; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; import org.jetbrains.kotlin.resolve.inline.InlineUtil; -import org.jetbrains.kotlin.resolve.jvm.*; +import org.jetbrains.kotlin.resolve.jvm.AsmTypes; +import org.jetbrains.kotlin.resolve.jvm.JvmBindingContextSlices; +import org.jetbrains.kotlin.resolve.jvm.JvmConstantsKt; +import org.jetbrains.kotlin.resolve.jvm.RuntimeAssertionInfo; import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature; @@ -2690,7 +2693,7 @@ public class ExpressionCodegen extends KtVisitor impleme } @NotNull - Callable resolveToCallable(@NotNull FunctionDescriptor fd, boolean superCall, @NotNull ResolvedCall resolvedCall) { + Callable resolveToCallable(@NotNull FunctionDescriptor fd, boolean superCall, @NotNull ResolvedCall resolvedCall) { IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(fd); if (intrinsic != null) { return intrinsic.toCallable(fd, superCall, resolvedCall, this); @@ -2698,7 +2701,8 @@ public class ExpressionCodegen extends KtVisitor impleme fd = SamCodegenUtil.resolveSamAdapter(fd); - if (ArgumentGeneratorKt.shouldInvokeDefaultArgumentsStub(resolvedCall)) { + List valueArguments = resolvedCall.getValueArgumentsByIndex(); + if (valueArguments != null && valueArguments.stream().anyMatch(it -> it instanceof DefaultValueArgument)) { // When we invoke a function with some arguments mapped as defaults, // we later reroute this call to an overridden function in a base class that processes the default arguments. // If the base class is generic, this overridden function can have a different Kotlin signature diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ObjectSuperCallArgumentGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/ObjectSuperCallArgumentGenerator.kt index 0b0f274db8a..165564ad61f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ObjectSuperCallArgumentGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ObjectSuperCallArgumentGenerator.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.descriptors.ConstructorDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.resolve.calls.model.* import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature -import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter internal class ObjectSuperCallArgumentGenerator( @@ -65,12 +64,6 @@ internal class ObjectSuperCallArgumentGenerator( pushDefaultValueOnStack(type, iv) } - public override fun generateDefaultJava(i: Int, argument: DefaultValueArgument) { - val type = parameters[i].asmType - val value = superValueParameters[i].findJavaDefaultArgumentValue(type, typeMapper) - value.put(type, iv) - } - public override fun generateVararg(i: Int, argument: VarargValueArgument) { generateSuperCallArgument(i) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.kt index 72a1f5ac118..5053ed02192 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.kt @@ -5,18 +5,7 @@ package org.jetbrains.kotlin.codegen -import org.jetbrains.kotlin.codegen.AsmUtil.unboxPrimitiveTypeOrNull -import org.jetbrains.kotlin.codegen.StackValue.* -import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper -import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor -import org.jetbrains.kotlin.load.java.Constant -import org.jetbrains.kotlin.load.java.EnumEntry -import org.jetbrains.kotlin.load.java.descriptors.NullDefaultValue -import org.jetbrains.kotlin.load.java.descriptors.StringDefaultValue -import org.jetbrains.kotlin.load.java.descriptors.getDefaultValueFromAnnotation -import org.jetbrains.kotlin.load.java.lexicalCastFrom import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.utils.DFS import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter @@ -86,40 +75,3 @@ class FunctionCallStackValue( resultKotlinType: KotlinType?, lambda: (v: InstructionAdapter) -> Unit ) : OperationStackValue(resultType, resultKotlinType, lambda) - -fun ValueParameterDescriptor.findJavaDefaultArgumentValue(targetType: Type, typeMapper: KotlinTypeMapper): StackValue { - val descriptorWithDefaultValue = DFS.dfs( - listOf(this.original), - { it.original.overriddenDescriptors.map(ValueParameterDescriptor::getOriginal) }, - object : DFS.AbstractNodeHandler() { - var result: ValueParameterDescriptor? = null - - override fun beforeChildren(current: ValueParameterDescriptor?): Boolean { - if (current?.declaresDefaultValue() == true && current.getDefaultValueFromAnnotation() != null) { - result = current - return false - } - - return true - } - - override fun result(): ValueParameterDescriptor? = result - } - ) ?: error("Should be at least one descriptor with default value: $this") - - val defaultValue = descriptorWithDefaultValue.getDefaultValueFromAnnotation() - if (defaultValue is NullDefaultValue) { - return constant(null, targetType) - } - - val value = (defaultValue as StringDefaultValue).value - val castResult = type.lexicalCastFrom(value) ?: error("Should be checked in frontend") - - return when (castResult) { - is EnumEntry -> enumEntry(castResult.descriptor, typeMapper) - is Constant -> { - val unboxedType = unboxPrimitiveTypeOrNull(targetType) ?: targetType - return coercion(constant(castResult.value, unboxedType), targetType, null) - } - } -} diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt index f139b9ab77b..9359dd373bd 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt @@ -18,8 +18,6 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty import org.jetbrains.kotlin.fir.declarations.synthetic.buildSyntheticProperty -import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.expressions.builder.buildConstExpression import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack import org.jetbrains.kotlin.fir.java.declarations.* import org.jetbrains.kotlin.fir.render @@ -30,12 +28,9 @@ import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef import org.jetbrains.kotlin.load.java.AnnotationQualifierApplicabilityType -import org.jetbrains.kotlin.load.java.descriptors.NullDefaultValue -import org.jetbrains.kotlin.load.java.descriptors.StringDefaultValue import org.jetbrains.kotlin.load.java.typeEnhancement.* import org.jetbrains.kotlin.load.kotlin.SignatureBuildingComponents import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.ConstantValueKind import org.jetbrains.kotlin.utils.JavaTypeEnhancementState import org.jetbrains.kotlin.utils.addToStdlib.safeAs @@ -185,27 +180,26 @@ class FirSignatureEnhancement( enhanceReturnType(firMethod, overriddenMembers, memberContext, predefinedEnhancementInfo) } - val newValueParameterInfo = mutableListOf() + val enhancedValueParameterTypes = mutableListOf() for ((index, valueParameter) in firMethod.valueParameters.withIndex()) { if (hasReceiver && index == 0) continue - newValueParameterInfo += enhanceValueParameter( + enhancedValueParameterTypes += enhanceValueParameterType( firMethod, overriddenMembers, hasReceiver, memberContext, predefinedEnhancementInfo, valueParameter as FirJavaValueParameter, if (hasReceiver) index - 1 else index ) } - val newValueParameters = firMethod.valueParameters.zip(newValueParameterInfo) { valueParameter, newInfo -> - val (newTypeRef, newDefaultValue) = newInfo + val newValueParameters = firMethod.valueParameters.zip(enhancedValueParameterTypes) { valueParameter, enhancedReturnType -> buildValueParameter { source = valueParameter.source session = this@FirSignatureEnhancement.session origin = FirDeclarationOrigin.Enhancement - returnTypeRef = newTypeRef + returnTypeRef = enhancedReturnType this.name = valueParameter.name symbol = FirVariableSymbol(this.name) - defaultValue = valueParameter.defaultValue ?: newDefaultValue + defaultValue = valueParameter.defaultValue isCrossinline = valueParameter.isCrossinline isNoinline = valueParameter.isNoinline isVararg = valueParameter.isVararg @@ -298,9 +292,7 @@ class FirSignatureEnhancement( return signatureParts.type } - private data class EnhanceValueParameterResult(val typeRef: FirResolvedTypeRef, val defaultValue: FirExpression?) - - private fun enhanceValueParameter( + private fun enhanceValueParameterType( ownerFunction: FirFunction<*>, overriddenMembers: List>, hasReceiver: Boolean, @@ -308,7 +300,7 @@ class FirSignatureEnhancement( predefinedEnhancementInfo: PredefinedFunctionEnhancementInfo?, ownerParameter: FirJavaValueParameter, index: Int - ): EnhanceValueParameterResult { + ): FirResolvedTypeRef { val signatureParts = ownerFunction.partsForValueParameter( typeQualifierResolver, overriddenMembers, @@ -321,13 +313,7 @@ class FirSignatureEnhancement( predefinedEnhancementInfo?.parametersInfo?.getOrNull(index), forAnnotationMember = owner.classKind == ClassKind.ANNOTATION_CLASS ) - val firResolvedTypeRef = signatureParts.type - val defaultValueExpression = when (val defaultValue = ownerParameter.getDefaultValueFromAnnotation()) { - NullDefaultValue -> buildConstExpression(null, ConstantValueKind.Null, null) - is StringDefaultValue -> firResolvedTypeRef.type.lexicalCastFrom(session, defaultValue.value) - null -> null - } - return EnhanceValueParameterResult(firResolvedTypeRef, defaultValueExpression) + return signatureParts.type } private fun enhanceReturnType( diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt index e6cb0f6b97a..b25ce89fe98 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt @@ -13,11 +13,6 @@ import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.builder.buildConstExpression import org.jetbrains.kotlin.fir.expressions.builder.buildQualifiedAccessExpression -import org.jetbrains.kotlin.fir.declarations.FirRegularClass -import org.jetbrains.kotlin.fir.declarations.FirValueParameter -import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall -import org.jetbrains.kotlin.fir.expressions.FirConstExpression -import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass import org.jetbrains.kotlin.fir.java.declarations.FirJavaField import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference @@ -31,11 +26,6 @@ import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef import org.jetbrains.kotlin.load.java.JavaDefaultQualifiers -import org.jetbrains.kotlin.load.java.JvmAnnotationNames.DEFAULT_NULL_FQ_NAME -import org.jetbrains.kotlin.load.java.JvmAnnotationNames.DEFAULT_VALUE_FQ_NAME -import org.jetbrains.kotlin.load.java.descriptors.AnnotationDefaultValue -import org.jetbrains.kotlin.load.java.descriptors.NullDefaultValue -import org.jetbrains.kotlin.load.java.descriptors.StringDefaultValue import org.jetbrains.kotlin.load.java.structure.JavaClassifierType import org.jetbrains.kotlin.load.java.structure.JavaType import org.jetbrains.kotlin.load.java.typeEnhancement.* @@ -45,7 +35,6 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.AbstractStrictEqualityTypeChecker import org.jetbrains.kotlin.types.ConstantValueKind import org.jetbrains.kotlin.types.RawType -import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.jetbrains.kotlin.utils.extractRadix internal class IndexedJavaTypeQualifiers(private val data: Array) { @@ -317,22 +306,6 @@ internal fun ConeKotlinType.lexicalCastFrom(session: FirSession, value: String): } } -internal fun FirValueParameter.getDefaultValueFromAnnotation(): AnnotationDefaultValue? { - annotations.find { it.classId == DEFAULT_VALUE_ID } - ?.arguments?.firstOrNull() - ?.safeAs>()?.value?.safeAs() - ?.let { return StringDefaultValue(it) } - - if (annotations.any { it.classId == DEFAULT_NULL_ID }) { - return NullDefaultValue - } - - return null -} - -private val DEFAULT_VALUE_ID = ClassId.topLevel(DEFAULT_VALUE_FQ_NAME) -private val DEFAULT_NULL_ID = ClassId.topLevel(DEFAULT_NULL_FQ_NAME) - internal fun List.computeTypeAttributesForJavaType(): ConeAttributes = computeTypeAttributes { classId -> when (classId) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java index bb1f88ff226..2044df9624b 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java @@ -22,12 +22,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl; import org.jetbrains.kotlin.incremental.components.NoLookupLocation; import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor; -import org.jetbrains.kotlin.load.java.descriptors.UtilKt; import org.jetbrains.kotlin.load.java.structure.JavaMethod; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.DescriptorUtils; @@ -68,12 +66,10 @@ public class SignaturesPropagationData { JavaMethodDescriptor autoMethodDescriptor = createAutoMethodDescriptor(containingClass, method, autoReturnType, autoValueParameters, autoTypeParameters); - boolean hasStableParameterNames = autoValueParameters.stream().allMatch(it -> UtilKt.getParameterNameAnnotation(it) != null); - superFunctions = getSuperFunctionsForMethod(method, autoMethodDescriptor, containingClass); modifiedValueParameters = superFunctions.isEmpty() - ? new ValueParameters(null, autoValueParameters, hasStableParameterNames) - : modifyValueParametersAccordingToSuperMethods(autoValueParameters, hasStableParameterNames); + ? new ValueParameters(null, autoValueParameters, false) + : modifyValueParametersAccordingToSuperMethods(autoValueParameters); } @NotNull @@ -123,10 +119,7 @@ public class SignaturesPropagationData { signatureErrors.add(error); } - private ValueParameters modifyValueParametersAccordingToSuperMethods( - @NotNull List parameters, - boolean annotatedWithParameterName - ) { + private ValueParameters modifyValueParametersAccordingToSuperMethods(@NotNull List parameters) { KotlinType resultReceiverType = null; List resultParameters = new ArrayList<>(parameters.size()); @@ -167,15 +160,12 @@ public class SignaturesPropagationData { } } - AnnotationDescriptor currentName = UtilKt.getParameterNameAnnotation(originalParam); - boolean shouldTakeOldName = currentName == null && stableName != null; - resultParameters.add(new ValueParameterDescriptorImpl( originalParam.getContainingDeclaration(), null, shouldBeExtension ? originalIndex - 1 : originalIndex, originalParam.getAnnotations(), - shouldTakeOldName ? stableName : originalParam.getName(), + stableName != null ? stableName : originalParam.getName(), altType, originalParam.declaresDefaultValue(), originalParam.isCrossinline(), @@ -186,8 +176,7 @@ public class SignaturesPropagationData { } } - boolean hasStableParameterNames = - annotatedWithParameterName || CollectionsKt.any(superFunctions, CallableDescriptor::hasStableParameterNames); + boolean hasStableParameterNames = CollectionsKt.any(superFunctions, CallableDescriptor::hasStableParameterNames); return new ValueParameters(resultReceiverType, resultParameters, hasStableParameterNames); } diff --git a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java index f5897f1ba1a..e2420c17411 100644 --- a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java +++ b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java @@ -72,10 +72,6 @@ public final class JvmAnnotationNames { public static final FqName ENHANCED_NULLABILITY_ANNOTATION = new FqName("kotlin.jvm.internal.EnhancedNullability"); public static final FqName ENHANCED_MUTABILITY_ANNOTATION = new FqName("kotlin.jvm.internal.EnhancedMutability"); - public static final FqName PARAMETER_NAME_FQ_NAME = new FqName("kotlin.annotations.jvm.internal.ParameterName"); - public static final FqName DEFAULT_VALUE_FQ_NAME = new FqName("kotlin.annotations.jvm.internal.DefaultValue"); - public static final FqName DEFAULT_NULL_FQ_NAME = new FqName("kotlin.annotations.jvm.internal.DefaultNull"); - private JvmAnnotationNames() { } } diff --git a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/descriptors/AnnotationDefaultValue.kt b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/descriptors/AnnotationDefaultValue.kt deleted file mode 100644 index c4abb83e5b7..00000000000 --- a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/descriptors/AnnotationDefaultValue.kt +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2010-2020 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.load.java.descriptors - -sealed class AnnotationDefaultValue - -class StringDefaultValue(val value: String) : AnnotationDefaultValue() - -object NullDefaultValue : AnnotationDefaultValue() diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/util.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/util.kt index dc8501dcb4d..9a1cd490190 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/util.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/descriptors/util.kt @@ -19,19 +19,14 @@ package org.jetbrains.kotlin.load.java.descriptors import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor -import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl -import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaStaticClassScope import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource -import org.jetbrains.kotlin.resolve.constants.StringValue -import org.jetbrains.kotlin.resolve.descriptorUtil.firstArgument import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny import org.jetbrains.kotlin.resolve.descriptorUtil.module import org.jetbrains.kotlin.resolve.jvm.JvmClassName import org.jetbrains.kotlin.serialization.deserialization.descriptors.DescriptorWithContainerSource import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.utils.addToStdlib.safeAs class ValueParameterData(val type: KotlinType, val hasDefaultValue: Boolean) @@ -72,25 +67,3 @@ fun DescriptorWithContainerSource.getImplClassNameForDeserialized(): JvmClassNam fun DescriptorWithContainerSource.isFromJvmPackagePart(): Boolean = containerSource is JvmPackagePartSource - -fun ValueParameterDescriptor.getParameterNameAnnotation(): AnnotationDescriptor? { - val annotation = annotations.findAnnotation(JvmAnnotationNames.PARAMETER_NAME_FQ_NAME) ?: return null - if (annotation.firstArgument()?.safeAs()?.value?.isEmpty() != false) { - return null - } - - return annotation -} - -fun ValueParameterDescriptor.getDefaultValueFromAnnotation(): AnnotationDefaultValue? { - annotations.findAnnotation(JvmAnnotationNames.DEFAULT_VALUE_FQ_NAME) - ?.firstArgument() - ?.safeAs()?.value - ?.let { return StringDefaultValue(it) } - - if (annotations.hasAnnotation(JvmAnnotationNames.DEFAULT_NULL_FQ_NAME)) { - return NullDefaultValue - } - - return null -} diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt index e38a6004ec2..c124c7dc8e7 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaScope.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.incremental.components.NoLookupLocation -import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.kotlin.load.java.components.TypeUsage import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor @@ -39,8 +38,6 @@ import org.jetbrains.kotlin.load.java.toDescriptorVisibility import org.jetbrains.kotlin.load.kotlin.computeJvmDescriptor import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.* -import org.jetbrains.kotlin.resolve.constants.StringValue -import org.jetbrains.kotlin.resolve.descriptorUtil.firstArgument import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude.NonExtensions import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.MemberScope @@ -53,7 +50,6 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.addIfNotNull -import org.jetbrains.kotlin.utils.addToStdlib.safeAs import java.util.* abstract class LazyJavaScope( @@ -212,15 +208,9 @@ abstract class LazyJavaScope( jValueParameters: List ): ResolvedValueParameters { var synthesizedNames = false - val usedNames = mutableSetOf() - val descriptors = jValueParameters.withIndex().map { (index, javaParameter) -> val annotations = c.resolveAnnotations(javaParameter) val typeUsage = TypeUsage.COMMON.toAttributes() - val parameterName = annotations - .findAnnotation(JvmAnnotationNames.PARAMETER_NAME_FQ_NAME) - ?.firstArgument() - ?.safeAs()?.value val (outType, varargElementType) = if (javaParameter.isVararg) { @@ -241,8 +231,6 @@ abstract class LazyJavaScope( // "other" in Any) // TODO: fix Java parameter name loading logic somehow (don't always load "p0", "p1", etc.) Name.identifier("other") - } else if (parameterName != null && parameterName.isNotEmpty() && usedNames.add(parameterName)) { - Name.identifier(parameterName) } else { // TODO: parameter names may be drawn from attached sources, which is slow; it's better to make them lazy val javaName = javaParameter.name diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt index 6e4a1f372ac..879d69b2925 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/typeEnhancement/signatureEnhancement.kt @@ -195,14 +195,8 @@ class SignatureEnhancement( } val valueParameterEnhancements = annotationOwnerForMember.valueParameters.map { p -> - val enhancementResult = partsForValueParameter(p, memberContext) { it.valueParameters[p.index].type } + partsForValueParameter(p, memberContext) { it.valueParameters[p.index].type } .enhance(predefinedEnhancementInfo?.parametersInfo?.getOrNull(p.index)) - - val actualType = if (enhancementResult.wereChanges) enhancementResult.type else p.type - val hasDefaultValue = p.hasDefaultValueInAnnotation(actualType) - val wereChanges = enhancementResult.wereChanges || (hasDefaultValue != p.declaresDefaultValue()) - - ValueParameterEnhancementResult(enhancementResult.type, hasDefaultValue, wereChanges, enhancementResult.containsFunctionN) } val returnTypeEnhancement = @@ -231,7 +225,7 @@ class SignatureEnhancement( @Suppress("UNCHECKED_CAST") return this.enhance( receiverTypeEnhancement?.type, - valueParameterEnhancements.map { ValueParameterData(it.type, it.hasDefaultValue) }, + valueParameterEnhancements.map { ValueParameterData(it.type, false) }, returnTypeEnhancement.type, additionalUserData ) as D @@ -263,13 +257,6 @@ class SignatureEnhancement( fun enhanceSuperType(type: KotlinType, context: LazyJavaResolverContext) = SignatureParts(null, type, emptyList(), false, context, AnnotationQualifierApplicabilityType.TYPE_USE).enhance().type - private fun ValueParameterDescriptor.hasDefaultValueInAnnotation(type: KotlinType) = - when (val defaultValue = getDefaultValueFromAnnotation()) { - is StringDefaultValue -> type.lexicalCastFrom(defaultValue.value) != null - NullDefaultValue -> TypeUtils.acceptsNullable(type) - null -> declaresDefaultValue() - } && overriddenDescriptors.isEmpty() - private inner class SignatureParts( private val typeContainer: Annotated?, private val fromOverride: KotlinType, @@ -592,13 +579,6 @@ class SignatureEnhancement( val containsFunctionN: Boolean ) - private class ValueParameterEnhancementResult( - type: KotlinType, - val hasDefaultValue: Boolean, - wereChanges: Boolean, - containsFunctionN: Boolean - ) : PartEnhancementResult(type, wereChanges, containsFunctionN) - private fun CallableMemberDescriptor.partsForValueParameter( // TODO: investigate if it's really can be a null (check properties' with extension overrides in Java) parameterDescriptor: ValueParameterDescriptor?, diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/utils.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/utils.kt index 020f81b21ea..30a82002d09 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/utils.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/utils.kt @@ -16,53 +16,12 @@ package org.jetbrains.kotlin.load.java -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.incremental.components.NoLookupLocation -import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.DescriptorVisibility +import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.resolve.deprecation.Deprecation import org.jetbrains.kotlin.resolve.deprecation.DeprecationLevelValue -import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.types.typeUtil.makeNotNullable -import org.jetbrains.kotlin.utils.extractRadix - -sealed class JavaDefaultValue -class EnumEntry(val descriptor: ClassDescriptor) : JavaDefaultValue() -class Constant(val value: Any) : JavaDefaultValue() - -fun KotlinType.lexicalCastFrom(value: String): JavaDefaultValue? { - val typeDescriptor = constructor.declarationDescriptor - if (typeDescriptor is ClassDescriptor && typeDescriptor.kind == ClassKind.ENUM_CLASS) { - val descriptor = typeDescriptor.unsubstitutedInnerClassesScope.getContributedClassifier( - Name.identifier(value), - NoLookupLocation.FROM_BACKEND - ) - - return if (descriptor is ClassDescriptor && descriptor.kind == ClassKind.ENUM_ENTRY) EnumEntry(descriptor) else null - } - - val type = this.makeNotNullable() - val (number, radix) = extractRadix(value) - val result: Any? = try { - when { - KotlinBuiltIns.isBoolean(type) -> value.toBoolean() - KotlinBuiltIns.isChar(type) -> value.singleOrNull() - KotlinBuiltIns.isByte(type) -> number.toByteOrNull(radix) - KotlinBuiltIns.isShort(type) -> number.toShortOrNull(radix) - KotlinBuiltIns.isInt(type) -> number.toIntOrNull(radix) - KotlinBuiltIns.isLong(type) -> number.toLongOrNull(radix) - KotlinBuiltIns.isFloat(type) -> value.toFloatOrNull() - KotlinBuiltIns.isDouble(type) -> value.toDoubleOrNull() - KotlinBuiltIns.isString(type) -> value - else -> null - } - } catch (e: IllegalArgumentException) { - null - } - - return if (result != null) Constant(result) else null -} class DeprecationCausedByFunctionN(override val target: DeclarationDescriptor) : Deprecation { override val deprecationLevel: DeprecationLevelValue From 899f75466d408ae92021e8c7ee7881d1d3cc54ae Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 9 Feb 2021 14:02:25 +0100 Subject: [PATCH 160/368] Remove tests on kotlin-annotations-android #KT-44815 --- .../java/FirTypeEnhancementTestGenerated.java | 18 ---- .../OwnFirTypeEnhancementTestGenerated.java | 63 ----------- .../java/AbstractFirTypeEnhancementTest.kt | 3 - .../testData/enhancement/note.txt | 2 +- .../signatureAnnotations/DefaultEnum.fir.txt | 33 ------ .../signatureAnnotations/DefaultEnum.java | 39 ------- .../DefaultLongLiteral.fir.txt | 24 ----- .../DefaultLongLiteral.java | 36 ------- .../signatureAnnotations/DefaultNull.fir.txt | 14 --- .../signatureAnnotations/DefaultNull.java | 17 --- .../DefaultNullAndParameter.fir.txt | 32 ------ .../DefaultNullAndParameter.java | 38 ------- .../DefaultParameter.fir.txt | 14 --- .../DefaultParameter.java | 23 ---- .../EmptyParameterName.fir.txt | 10 -- .../EmptyParameterName.java | 16 --- .../ReorderedParameterNames.fir.txt | 6 -- .../ReorderedParameterNames.java | 10 -- .../SameParameterName.fir.txt | 6 -- .../SameParameterName.java | 10 -- .../SpecialCharsParameterName.fir.txt | 8 -- .../SpecialCharsParameterName.java | 13 --- .../StaticMethodWithDefaultValue.fir.txt | 6 -- .../StaticMethodWithDefaultValue.java | 13 --- ...irOldFrontendDiagnosticsTestGenerated.java | 78 -------------- .../FirBlackBoxCodegenTestGenerated.java | 88 --------------- .../forTestCompile/ForTestCompileRuntime.java | 5 - .../defaultAndNamedCombination.kt | 39 ------- .../signatureAnnotations/defaultBoxTypes.kt | 82 -------------- .../signatureAnnotations/defaultEnumType.kt | 44 -------- .../defaultLongLiteral.kt | 50 --------- .../defaultMultipleParams.kt | 45 -------- .../box/signatureAnnotations/defaultNull.kt | 58 ---------- .../defaultNullableBoxTypes.kt | 83 --------------- .../signatureAnnotations/defaultOverrides.kt | 40 ------- .../defaultPrimitiveTypes.kt | 90 ---------------- .../defaultValueInConstructor.kt | 42 -------- .../defaultWithJavaBase.kt | 28 ----- .../defaultWithKotlinBase.kt | 23 ---- .../reorderedParameterNames.kt | 31 ------ .../signatureAnnotations/defaultEnum.fir.kt | 67 ------------ .../j+k/signatureAnnotations/defaultEnum.kt | 67 ------------ .../j+k/signatureAnnotations/defaultEnum.txt | 90 ---------------- .../defaultLongLiteral.fir.kt | 49 --------- .../defaultLongLiteral.kt | 49 --------- .../defaultLongLiteral.txt | 25 ----- .../signatureAnnotations/defaultNull.fir.kt | 31 ------ .../j+k/signatureAnnotations/defaultNull.kt | 31 ------ .../j+k/signatureAnnotations/defaultNull.txt | 20 ---- .../defaultNullAndParameter.kt | 58 ---------- .../defaultNullAndParameter.txt | 44 -------- .../defaultParameter.fir.kt | 45 -------- .../signatureAnnotations/defaultParameter.kt | 45 -------- .../signatureAnnotations/defaultParameter.txt | 15 --- .../emptyParameterName.fir.kt | 27 ----- .../emptyParameterName.kt | 27 ----- .../emptyParameterName.txt | 13 --- .../overridesDefaultValue.fir.kt | 100 ------------------ .../overridesDefaultValue.kt | 100 ------------------ .../overridesDefaultValue.txt | 81 -------------- .../overridesParameterName.fir.kt | 98 ----------------- .../overridesParameterName.kt | 98 ----------------- .../overridesParameterName.txt | 67 ------------ .../reorderedParameterNames.kt | 18 ---- .../reorderedParameterNames.txt | 11 -- .../sameParameterName.fir.kt | 17 --- .../signatureAnnotations/sameParameterName.kt | 17 --- .../sameParameterName.txt | 11 -- .../specialCharsParameterName.fir.kt | 24 ----- .../specialCharsParameterName.kt | 24 ----- .../specialCharsParameterName.txt | 12 --- .../stableParameterName.kt | 21 ---- .../stableParameterName.txt | 25 ----- .../staticMethodWithDefaultValue.kt | 18 ---- .../staticMethodWithDefaultValue.txt | 13 --- .../signatureAnnotations/StableName.fir.txt | 6 -- .../signatureAnnotations/StableName.java | 11 -- .../signatureAnnotations/StableName.txt | 6 -- .../test/runners/DiagnosticTestGenerated.java | 78 -------------- .../codegen/BlackBoxCodegenTestGenerated.java | 88 --------------- .../IrBlackBoxCodegenTestGenerated.java | 88 --------------- .../backend/classic/JavaCompilerFacade.kt | 13 +-- .../JvmEnvironmentConfigurationDirectives.kt | 2 - .../JvmEnvironmentConfigurator.kt | 4 - .../checkers/KotlinMultiFileTestWithJava.kt | 4 - .../kotlin/codegen/CodegenTestCase.java | 15 +-- .../jvm/compiler/AbstractLoadJavaTest.java | 4 - .../jvm/compiler/LoadDescriptorUtil.java | 4 - .../LightAnalysisModeTestGenerated.java | 78 -------------- .../jvm/compiler/LoadJavaTestGenerated.java | 18 ---- ...dJavaWithPsiClassReadingTestGenerated.java | 18 ---- .../compiler/ir/IrLoadJavaTestGenerated.java | 18 ---- .../LoadJavaUsingJavacTestGenerated.java | 18 ---- ...mRuntimeDescriptorLoaderTestGenerated.java | 18 ---- .../IrJsCodegenBoxES6TestGenerated.java | 13 --- .../IrJsCodegenBoxTestGenerated.java | 13 --- .../semantics/JsCodegenBoxTestGenerated.java | 13 --- .../IrCodegenBoxWasmTestGenerated.java | 13 --- 98 files changed, 5 insertions(+), 3276 deletions(-) delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultEnum.fir.txt delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultEnum.java delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultLongLiteral.fir.txt delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultLongLiteral.java delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNull.fir.txt delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNull.java delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNullAndParameter.fir.txt delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNullAndParameter.java delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultParameter.fir.txt delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultParameter.java delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/EmptyParameterName.fir.txt delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/EmptyParameterName.java delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/ReorderedParameterNames.fir.txt delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/ReorderedParameterNames.java delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SameParameterName.fir.txt delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SameParameterName.java delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SpecialCharsParameterName.fir.txt delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SpecialCharsParameterName.java delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/StaticMethodWithDefaultValue.fir.txt delete mode 100644 compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/StaticMethodWithDefaultValue.java delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/defaultWithKotlinBase.kt delete mode 100644 compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.txt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.txt delete mode 100644 compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.fir.txt delete mode 100644 compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.java delete mode 100644 compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.txt diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/java/FirTypeEnhancementTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/java/FirTypeEnhancementTestGenerated.java index 8ac45866e5d..06314da3ae8 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/java/FirTypeEnhancementTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/java/FirTypeEnhancementTestGenerated.java @@ -1484,24 +1484,6 @@ public class FirTypeEnhancementTestGenerated extends AbstractFirTypeEnhancementT } } - @TestMetadata("compiler/testData/loadJava/compiledJava/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractFirTypeEnhancementTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava/compiledJava/signatureAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); - } - - @TestMetadata("StableName.java") - public void testStableName() throws Exception { - runTest("compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.java"); - } - } - @TestMetadata("compiler/testData/loadJava/compiledJava/signaturePropagation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/java/OwnFirTypeEnhancementTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/java/OwnFirTypeEnhancementTestGenerated.java index 7c77d5c6f3c..c34e48d0992 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/java/OwnFirTypeEnhancementTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/java/OwnFirTypeEnhancementTestGenerated.java @@ -132,67 +132,4 @@ public class OwnFirTypeEnhancementTestGenerated extends AbstractOwnFirTypeEnhanc KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/enhancement/mapping"), Pattern.compile("^(.+)\\.java$"), null, true); } } - - @TestMetadata("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractOwnFirTypeEnhancementTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); - } - - @TestMetadata("DefaultEnum.java") - public void testDefaultEnum() throws Exception { - runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultEnum.java"); - } - - @TestMetadata("DefaultLongLiteral.java") - public void testDefaultLongLiteral() throws Exception { - runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultLongLiteral.java"); - } - - @TestMetadata("DefaultNull.java") - public void testDefaultNull() throws Exception { - runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNull.java"); - } - - @TestMetadata("DefaultNullAndParameter.java") - public void testDefaultNullAndParameter() throws Exception { - runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNullAndParameter.java"); - } - - @TestMetadata("DefaultParameter.java") - public void testDefaultParameter() throws Exception { - runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultParameter.java"); - } - - @TestMetadata("EmptyParameterName.java") - public void testEmptyParameterName() throws Exception { - runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/EmptyParameterName.java"); - } - - @TestMetadata("ReorderedParameterNames.java") - public void testReorderedParameterNames() throws Exception { - runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/ReorderedParameterNames.java"); - } - - @TestMetadata("SameParameterName.java") - public void testSameParameterName() throws Exception { - runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SameParameterName.java"); - } - - @TestMetadata("SpecialCharsParameterName.java") - public void testSpecialCharsParameterName() throws Exception { - runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SpecialCharsParameterName.java"); - } - - @TestMetadata("StaticMethodWithDefaultValue.java") - public void testStaticMethodWithDefaultValue() throws Exception { - runTest("compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/StaticMethodWithDefaultValue.java"); - } - } } diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests/org/jetbrains/kotlin/fir/java/AbstractFirTypeEnhancementTest.kt b/compiler/fir/analysis-tests/legacy-fir-tests/tests/org/jetbrains/kotlin/fir/java/AbstractFirTypeEnhancementTest.kt index cc082c6569b..de67356c912 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests/org/jetbrains/kotlin/fir/java/AbstractFirTypeEnhancementTest.kt +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests/org/jetbrains/kotlin/fir/java/AbstractFirTypeEnhancementTest.kt @@ -65,9 +65,6 @@ abstract class AbstractFirTypeEnhancementTest : KtUsefulTestCase() { private fun createEnvironment(content: String): KotlinCoreEnvironment { val classpath = mutableListOf(getAnnotationsJar(), ForTestCompileRuntime.runtimeJarForTests()) - if (InTextDirectivesUtils.isDirectiveDefined(content, "ANDROID_ANNOTATIONS")) { - classpath.add(ForTestCompileRuntime.androidAnnotationsForTests()) - } if (InTextDirectivesUtils.isDirectiveDefined(content, "JVM_ANNOTATIONS")) { classpath.add(ForTestCompileRuntime.jvmAnnotationsForTests()) } diff --git a/compiler/fir/analysis-tests/testData/enhancement/note.txt b/compiler/fir/analysis-tests/testData/enhancement/note.txt index 13a9f30bf4d..9df530d4da2 100644 --- a/compiler/fir/analysis-tests/testData/enhancement/note.txt +++ b/compiler/fir/analysis-tests/testData/enhancement/note.txt @@ -1 +1 @@ -Most FIR enhancement tests use compiler/testData/loadJava/compilerJava \ No newline at end of file +Most FIR enhancement tests use compiler/testData/loadJava/compiledJava diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultEnum.fir.txt b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultEnum.fir.txt deleted file mode 100644 index 330f35301ef..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultEnum.fir.txt +++ /dev/null @@ -1,33 +0,0 @@ -public/*package*/ open class A : R|kotlin/Any| { - public open fun a(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(HELLO)) arg: R|ft<@FlexibleNullability Signs, Signs?>!| = R|/Signs.HELLO|): R|ft<@FlexibleNullability Signs, Signs?>!| - - public open fun bar(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(X)) arg: R|ft<@FlexibleNullability Signs, Signs?>!| = R|/Signs.X|): R|ft<@FlexibleNullability Signs, Signs?>!| - - public open fun baz(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(NOT_ENTRY_EITHER)) arg: R|ft<@FlexibleNullability Signs, Signs?>!|): R|ft<@FlexibleNullability Signs, Signs?>!| - - public open fun bam(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(NOT_ENTRY_EITHER)) arg: R|ft<@FlexibleNullability Mixed, Mixed?>!| = R|/Mixed.NOT_ENTRY_EITHER|): R|ft<@FlexibleNullability Mixed, Mixed?>!| - - public/*package*/ constructor(): R|A| - -} -public final enum class Mixed : R|kotlin/Enum!>| { - public final static enum entry NOT_ENTRY_EITHER: R|@FlexibleNullability Mixed| - public final static fun values(): R|kotlin/Array| { - } - - public final static fun valueOf(value: R|kotlin/String|): R|Mixed| { - } - -} -public final enum class Signs : R|kotlin/Enum!>| { - public final static enum entry HELLO: R|@FlexibleNullability Signs| - public final static enum entry WORLD: R|@FlexibleNullability Signs| - public final static field X: R|ft<@FlexibleNullability Signs, Signs?>!| - - public final static fun values(): R|kotlin/Array| { - } - - public final static fun valueOf(value: R|kotlin/String|): R|Signs| { - } - -} diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultEnum.java b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultEnum.java deleted file mode 100644 index b8fbb6fb186..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -// FILE: Signs.java -// ANDROID_ANNOTATIONS - -public enum Signs { - HELLO, - WORLD; - - public static final Signs X; - public static final class NOT_ENTRY_EITHER {} -} - -// FILE: Mixed.java -public enum Mixed { - NOT_ENTRY_EITHER; - - public static final class NOT_ENTRY_EITHER {} -} - -// FILE: A.java -import kotlin.annotations.jvm.internal.*; - -class A { - public Signs a(@DefaultValue("HELLO") Signs arg) { - return arg; - } - - public Signs bar(@DefaultValue("X") Signs arg) { - return arg; - } - - public Signs baz(@DefaultValue("NOT_ENTRY_EITHER") Signs arg) { - return arg; - } - - public Mixed bam(@DefaultValue("NOT_ENTRY_EITHER") Mixed arg) { - return arg; - } - -} diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultLongLiteral.fir.txt b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultLongLiteral.fir.txt deleted file mode 100644 index c1955e3f730..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultLongLiteral.fir.txt +++ /dev/null @@ -1,24 +0,0 @@ -public open class A : R|kotlin/Any| { - public open fun first(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0x1F)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!| = Long(31)): R|kotlin/Unit| - - public open fun second(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0X1F)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!| = Long(31)): R|kotlin/Unit| - - public open fun third(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0b1010)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!| = Long(10)): R|kotlin/Unit| - - public open fun fourth(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0B1010)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!| = Long(10)): R|kotlin/Unit| - - public constructor(): R|A| - -} -public open class B : R|kotlin/Any| { - public open fun first(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0x)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!|): R|kotlin/Unit| - - public open fun second(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0xZZ)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!|): R|kotlin/Unit| - - public open fun third(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0b)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!|): R|kotlin/Unit| - - public open fun fourth(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(0B1234)) value: R|ft<@FlexibleNullability kotlin/Long, kotlin/Long?>!|): R|kotlin/Unit| - - public constructor(): R|B| - -} diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultLongLiteral.java b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultLongLiteral.java deleted file mode 100644 index 3e1c6e89950..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultLongLiteral.java +++ /dev/null @@ -1,36 +0,0 @@ -// FILE: A.java -// ANDROID_ANNOTATIONS - -import kotlin.annotations.jvm.internal.*; - -public class A { - public void first(@DefaultValue("0x1F") Long value) { - } - - public void second(@DefaultValue("0X1F") Long value) { - } - - public void third(@DefaultValue("0b1010") Long value) { - } - - public void fourth(@DefaultValue("0B1010") Long value) { - } -} - -// FILE: B.java -import kotlin.annotations.jvm.internal.*; - -public class B { - public void first(@DefaultValue("0x") Long value) { - } - - public void second(@DefaultValue("0xZZ") Long value) { - } - - public void third(@DefaultValue("0b") Long value) { - } - - public void fourth(@DefaultValue("0B1234") Long value) { - } -} - diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNull.fir.txt b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNull.fir.txt deleted file mode 100644 index dabe74a9ee5..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNull.fir.txt +++ /dev/null @@ -1,14 +0,0 @@ -public open class A : R|kotlin/Any| { - public open fun foo(@R|kotlin/annotations/jvm/internal/DefaultNull|() x: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Null(null)): R|kotlin/Unit| - - public open fun bar(@R|kotlin/annotations/jvm/internal/DefaultNull|() x: R|kotlin/Int| = Null(null)): R|kotlin/Unit| - - public constructor(): R|A| - -} -public open class B!|> : R|kotlin/Any| { - public open fun foo(@R|kotlin/annotations/jvm/internal/DefaultNull|() t: R|ft<@FlexibleNullability T, T?>!| = Null(null)): R|kotlin/Unit| - - public constructor!|>(): R|B| - -} diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNull.java b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNull.java deleted file mode 100644 index d3f0372f4cc..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNull.java +++ /dev/null @@ -1,17 +0,0 @@ -// FILE: A.java -// ANDROID_ANNOTATIONS - -import kotlin.annotations.jvm.internal.*; - -public class A { - public void foo(@DefaultNull Integer x) {} - public void bar(@DefaultNull int x) {} -} - -// FILE: B.java -import kotlin.annotations.jvm.internal.*; - -public class B { - public void foo(@DefaultNull T t) { } -} - diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNullAndParameter.fir.txt b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNullAndParameter.fir.txt deleted file mode 100644 index e9f356b4f8c..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNullAndParameter.fir.txt +++ /dev/null @@ -1,32 +0,0 @@ -public open class A : R|kotlin/Any| { - public open fun foo(@R|kotlin/annotations/jvm/internal/DefaultNull|() i: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Null(null)): R|kotlin/Unit| - - public open fun bar(@R|kotlin/annotations/jvm/internal/DefaultNull|() a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Null(null)): R|kotlin/Unit| - - public open fun bam(@R|kotlin/annotations/jvm/internal/DefaultNull|() a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Null(null)): R|kotlin/Unit| - - public open fun baz(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(42)) a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Int(42)): R|kotlin/Unit| - - public constructor(): R|A| - -} -public abstract interface AInt : R|kotlin/Any| { - public abstract fun foo(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(42)) i: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Int(42)): R|kotlin/Unit| - - public abstract fun bar(@R|kotlin/annotations/jvm/internal/DefaultNull|() a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Null(null)): R|kotlin/Unit| - -} -public open class B : R|A| { - public open fun foo(i: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!|): R|kotlin/Unit| - - public open fun bar(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(42)) a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Int(42)): R|kotlin/Unit| - - public open fun bam(@R|kotlin/annotations/jvm/internal/DefaultNull|() @R|kotlin/annotations/jvm/internal/DefaultValue|(String(42)) a: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!| = Int(42)): R|kotlin/Unit| - - public constructor(): R|B| - -} -public open class C : R|A|, R|AInt| { - public constructor(): R|C| - -} diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNullAndParameter.java b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNullAndParameter.java deleted file mode 100644 index c80e59df91b..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultNullAndParameter.java +++ /dev/null @@ -1,38 +0,0 @@ -// FILE: A.java -// ANDROID_ANNOTATIONS - -import kotlin.annotations.jvm.internal.*; - -public class A { - public void foo(@DefaultNull Integer i) {} - - public void bar(@DefaultNull Integer a) {} - - public void bam(@DefaultNull Integer a) {} - - public void baz(@DefaultValue("42") Integer a) {} -} - -// FILE: AInt.java -import kotlin.annotations.jvm.internal.*; - -public interface AInt { - public void foo(@DefaultValue("42") Integer i) {} - public void bar(@DefaultNull Integer a) {} -} - -// FILE: B.java -import kotlin.annotations.jvm.internal.*; - -public class B extends A { - public void foo(Integer i) {} - - public void bar(@DefaultValue("42") Integer a) {} - - public void bam(@DefaultNull @DefaultValue("42") Integer a) {} -} - -// FILE: C.java -public class C extends A implements AInt { -} - diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultParameter.fir.txt b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultParameter.fir.txt deleted file mode 100644 index f7075d724e5..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultParameter.fir.txt +++ /dev/null @@ -1,14 +0,0 @@ -public/*package*/ open class A : R|kotlin/Any| { - public open fun first(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(hello)) value: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(hello)): R|kotlin/Unit| - - public open fun second(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(first)) a: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(first), @R|kotlin/annotations/jvm/internal/DefaultValue|(String(second)) b: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(second)): R|kotlin/Unit| - - public open fun third(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(first)) a: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(first), b: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit| - - public open fun fourth(first: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|kotlin/annotations/jvm/internal/DefaultValue|(String(second)) second: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(second)): R|kotlin/Unit| - - public open fun wrong(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(hello)) i: R|ft<@FlexibleNullability kotlin/Int, kotlin/Int?>!|): R|kotlin/Unit| - - public/*package*/ constructor(): R|A| - -} diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultParameter.java b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultParameter.java deleted file mode 100644 index 2e92dd18d6b..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/DefaultParameter.java +++ /dev/null @@ -1,23 +0,0 @@ -// FILE: A.java -// ANDROID_ANNOTATIONS - -import kotlin.annotations.jvm.internal.*; - -class A { - public void first(@DefaultValue("hello") String value) { - } - - public void second(@DefaultValue("first") String a, @DefaultValue("second") String b) { - } - - public void third(@DefaultValue("first") String a, String b) { - } - - public void fourth(String first, @DefaultValue("second") String second) { - } - - public void wrong(@DefaultValue("hello") Integer i) { - } -} - - diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/EmptyParameterName.fir.txt b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/EmptyParameterName.fir.txt deleted file mode 100644 index 950fee2ec14..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/EmptyParameterName.fir.txt +++ /dev/null @@ -1,10 +0,0 @@ -public/*package*/ open class A : R|kotlin/Any| { - public open fun emptyName(@R|kotlin/annotations/jvm/internal/ParameterName|(String()) first: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|kotlin/annotations/jvm/internal/ParameterName|(String(ok)) second: R|kotlin/Int|): R|kotlin/Unit| - - public open fun missingName(@R|kotlin/annotations/jvm/internal/ParameterName|() first: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit| - - public open fun numberName(@R|kotlin/annotations/jvm/internal/ParameterName|(Int(42)) first: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit| - - public/*package*/ constructor(): R|A| - -} diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/EmptyParameterName.java b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/EmptyParameterName.java deleted file mode 100644 index 7e3d6ba9e0e..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/EmptyParameterName.java +++ /dev/null @@ -1,16 +0,0 @@ -// FILE: A.java -// ANDROID_ANNOTATIONS - -import kotlin.annotations.jvm.internal.*; - -class A { - public void emptyName(@ParameterName("") String first, @ParameterName("ok") int second) { - } - - public void missingName(@ParameterName() String first) { - } - - public void numberName(@ParameterName(42) String first) { - } -} - diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/ReorderedParameterNames.fir.txt b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/ReorderedParameterNames.fir.txt deleted file mode 100644 index 5b1de90168c..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/ReorderedParameterNames.fir.txt +++ /dev/null @@ -1,6 +0,0 @@ -public open class A : R|kotlin/Any| { - public open fun connect(@R|kotlin/annotations/jvm/internal/ParameterName|(String(host)) host: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|kotlin/annotations/jvm/internal/ParameterName|(String(port)) port: R|kotlin/Int|): R|kotlin/Unit| - - public constructor(): R|A| - -} diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/ReorderedParameterNames.java b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/ReorderedParameterNames.java deleted file mode 100644 index f971eb9150d..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/ReorderedParameterNames.java +++ /dev/null @@ -1,10 +0,0 @@ - -// FILE: A.java -// ANDROID_ANNOTATIONS -import kotlin.annotations.jvm.internal.*; - -public class A { - public void connect(@ParameterName("host") String host, @ParameterName("port") int port) { - } -} - diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SameParameterName.fir.txt b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SameParameterName.fir.txt deleted file mode 100644 index 8496ac8c6e7..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SameParameterName.fir.txt +++ /dev/null @@ -1,6 +0,0 @@ -public open class A : R|kotlin/Any| { - public open fun same(@R|kotlin/annotations/jvm/internal/ParameterName|(String(ok)) first: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|, @R|kotlin/annotations/jvm/internal/ParameterName|(String(ok)) second: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit| - - public constructor(): R|A| - -} diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SameParameterName.java b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SameParameterName.java deleted file mode 100644 index d610459e082..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SameParameterName.java +++ /dev/null @@ -1,10 +0,0 @@ - -// FILE: A.java -// ANDROID_ANNOTATIONS -import kotlin.annotations.jvm.internal.*; - -public class A { - public void same(@ParameterName("ok") String first, @ParameterName("ok") String second) { - } -} - diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SpecialCharsParameterName.fir.txt b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SpecialCharsParameterName.fir.txt deleted file mode 100644 index 7bbbe502442..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SpecialCharsParameterName.fir.txt +++ /dev/null @@ -1,8 +0,0 @@ -public open class A : R|kotlin/Any| { - public open fun dollarName(@R|kotlin/annotations/jvm/internal/ParameterName|(String($)) host: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit| - - public open fun numberName(@R|kotlin/annotations/jvm/internal/ParameterName|(String(42)) field: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit| - - public constructor(): R|A| - -} diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SpecialCharsParameterName.java b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SpecialCharsParameterName.java deleted file mode 100644 index 36bc004a9b3..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/SpecialCharsParameterName.java +++ /dev/null @@ -1,13 +0,0 @@ -// FILE: A.java -// ANDROID_ANNOTATIONS -import kotlin.annotations.jvm.internal.*; -import kotlin.internal.*; - -public class A { - public void dollarName(@ParameterName("$") String host) { - } - - public void numberName(@ParameterName("42") String field) { - } -} - diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/StaticMethodWithDefaultValue.fir.txt b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/StaticMethodWithDefaultValue.fir.txt deleted file mode 100644 index 4b39e431056..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/StaticMethodWithDefaultValue.fir.txt +++ /dev/null @@ -1,6 +0,0 @@ -public/*package*/ open class A : R|kotlin/Any| { - public open static fun withDefault(@R|kotlin/annotations/jvm/internal/DefaultValue|(String(OK)) arg: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = String(OK)): R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| - - public/*package*/ constructor(): R|A| - -} diff --git a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/StaticMethodWithDefaultValue.java b/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/StaticMethodWithDefaultValue.java deleted file mode 100644 index 3301ae534b2..00000000000 --- a/compiler/fir/analysis-tests/testData/enhancement/signatureAnnotations/StaticMethodWithDefaultValue.java +++ /dev/null @@ -1,13 +0,0 @@ -// IGNORE_BACKEND: JS, NATIVE - -// FILE: A.java -// ANDROID_ANNOTATIONS - -import kotlin.annotations.jvm.internal.*; - -class A { - public static String withDefault(@DefaultValue("OK") String arg) { - return arg; - } -} - diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 76840862ce5..72dfb47b790 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -16428,42 +16428,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/j+k/signatureAnnotations"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } - @Test - @TestMetadata("defaultEnum.kt") - public void testDefaultEnum() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.kt"); - } - - @Test - @TestMetadata("defaultLongLiteral.kt") - public void testDefaultLongLiteral() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.kt"); - } - - @Test - @TestMetadata("defaultNull.kt") - public void testDefaultNull() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.kt"); - } - - @Test - @TestMetadata("defaultNullAndParameter.kt") - public void testDefaultNullAndParameter() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.kt"); - } - - @Test - @TestMetadata("defaultParameter.kt") - public void testDefaultParameter() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.kt"); - } - - @Test - @TestMetadata("emptyParameterName.kt") - public void testEmptyParameterName() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.kt"); - } - @Test @TestMetadata("notNullVarargOverride.kt") public void testNotNullVarargOverride() throws Exception { @@ -16475,48 +16439,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti public void testNullableVarargOverride() throws Exception { runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/nullableVarargOverride.kt"); } - - @Test - @TestMetadata("overridesDefaultValue.kt") - public void testOverridesDefaultValue() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.kt"); - } - - @Test - @TestMetadata("overridesParameterName.kt") - public void testOverridesParameterName() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.kt"); - } - - @Test - @TestMetadata("reorderedParameterNames.kt") - public void testReorderedParameterNames() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.kt"); - } - - @Test - @TestMetadata("sameParameterName.kt") - public void testSameParameterName() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.kt"); - } - - @Test - @TestMetadata("specialCharsParameterName.kt") - public void testSpecialCharsParameterName() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.kt"); - } - - @Test - @TestMetadata("stableParameterName.kt") - public void testStableParameterName() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.kt"); - } - - @Test - @TestMetadata("staticMethodWithDefaultValue.kt") - public void testStaticMethodWithDefaultValue() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.kt"); - } } @Nested diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 944a693285d..12d4bc176b0 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -37307,94 +37307,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } - @Nested - @TestMetadata("compiler/testData/codegen/box/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - public class SignatureAnnotations { - @Test - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/signatureAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("defaultAndNamedCombination.kt") - public void testDefaultAndNamedCombination() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt"); - } - - @Test - @TestMetadata("defaultBoxTypes.kt") - public void testDefaultBoxTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt"); - } - - @Test - @TestMetadata("defaultEnumType.kt") - public void testDefaultEnumType() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt"); - } - - @Test - @TestMetadata("defaultLongLiteral.kt") - public void testDefaultLongLiteral() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt"); - } - - @Test - @TestMetadata("defaultMultipleParams.kt") - public void testDefaultMultipleParams() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt"); - } - - @Test - @TestMetadata("defaultNull.kt") - public void testDefaultNull() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt"); - } - - @Test - @TestMetadata("defaultNullableBoxTypes.kt") - public void testDefaultNullableBoxTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt"); - } - - @Test - @TestMetadata("defaultOverrides.kt") - public void testDefaultOverrides() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt"); - } - - @Test - @TestMetadata("defaultPrimitiveTypes.kt") - public void testDefaultPrimitiveTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt"); - } - - @Test - @TestMetadata("defaultValueInConstructor.kt") - public void testDefaultValueInConstructor() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt"); - } - - @Test - @TestMetadata("defaultWithJavaBase.kt") - public void testDefaultWithJavaBase() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt"); - } - - @Test - @TestMetadata("defaultWithKotlinBase.kt") - public void testDefaultWithKotlinBase() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultWithKotlinBase.kt"); - } - - @Test - @TestMetadata("reorderedParameterNames.kt") - public void testReorderedParameterNames() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/smap") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java b/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java index 13d69085b66..a9771702cc2 100644 --- a/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java +++ b/compiler/test-infrastructure-utils/tests/org/jetbrains/kotlin/codegen/forTestCompile/ForTestCompileRuntime.java @@ -95,11 +95,6 @@ public class ForTestCompileRuntime { return assertExists(new File("dist/kotlinc/lib/kotlin-annotations-jvm.jar")); } - @NotNull - public static File androidAnnotationsForTests() { - return assertExists(new File("dist/kotlinc/lib/kotlin-annotations-android.jar")); - } - @NotNull private static File assertExists(@NotNull File file) { if (!file.exists()) { diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt deleted file mode 100644 index 24b7f3a199a..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt +++ /dev/null @@ -1,39 +0,0 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public int first( - @ParameterName("first") @DefaultValue("42") int a, - @ParameterName("second") @DefaultValue("1") int b - ) { - return 100 * a + b; - } -} - -// FILE: main.kt -fun box(): String { - val a = A() - if (a.first() != 100 * 42 + 1) { - return "FAIL 1" - } - - if (a.first(second = 2) != 100 * 42 + 2) { - return "FAIL 2" - } - - if (a.first(first = 2) != 100 * 2 + 1) { - return "FAIL 3" - } - - if (a.first(second = 2, first = 5) != 100 * 5 + 2) { - return "FAIL 4" - } - - return "OK" -} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt deleted file mode 100644 index acd94051bf2..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt +++ /dev/null @@ -1,82 +0,0 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - - public Integer a(@DefaultValue("42") Integer arg) { - return arg; - } - - public Float b(@DefaultValue("42.5") Float arg) { - return arg; - } - - public Boolean c(@DefaultValue("true") Boolean arg) { - return arg; - } - - public Byte d(@DefaultValue("42") Byte arg) { - return arg; - } - - public Character e(@DefaultValue("o") Character arg) { - return arg; - } - - public Double f(@DefaultValue("1e12") Double arg) { - return arg; - } - - public Long g(@DefaultValue("42424242424242") Long arg) { - return arg; - } - - public Short h(@DefaultValue("123") Short arg) { - return arg; - } -} - -// FILE: test.kt -fun box(): String { - val a = A() - - if (a.a() != 42) { - return "FAIL Int: ${a.a()}" - } - - if (a.b() != 42.5f) { - return "FAIL Float: ${a.b()}" - } - - if (!a.c()) { - return "FAIL Boolean: ${a.c()}" - } - - if (a.d() != 42.toByte()) { - return "FAIL Byte: ${a.d()}" - } - - if (a.e() != 'o') { - return "FAIL Char: ${a.e()}" - } - - if (a.f() != 1e12) { - return "FAIl Double: ${a.f()}" - } - - if (a.g() != 42424242424242) { - return "FAIL Long: ${a.g()}" - } - - if (a.h() != 123.toShort()) { - return "FAIL Short: ${a.h()}" - } - - return "OK" -} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt deleted file mode 100644 index 2eabc0de9b2..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt +++ /dev/null @@ -1,44 +0,0 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: Signs.java - -public enum Signs { - HELLO, - WORLD; -} - -// FILE: B.kt -enum class B { - X, - Y; -} - -// FILE: A.java -import kotlin.annotations.jvm.internal.*; - -class A { - public Signs a(@DefaultValue("HELLO") Signs arg) { - return arg; - } - - public B b(@DefaultValue("Y") B arg) { - return arg; - } -} - -// FILE: test.kt -fun box(): String { - val a = A() - if (a.a() != Signs.HELLO) { - return "FAIL: enums Java" - } - - if (a.b() != B.Y) { - return "FAIL: enums Kotlin" - } - - return "OK" -} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt deleted file mode 100644 index 3432249dd8d..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt +++ /dev/null @@ -1,50 +0,0 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - public Long first(@DefaultValue("0x1F") Long value) { - return value; - } - - public Long second(@DefaultValue("0X1F") Long value) { - return value; - } - - public Long third(@DefaultValue("0b1010") Long value) { - return value; - } - - public Long fourth(@DefaultValue("0B1010") Long value) { - return value; - } -} - -// FILE: test.kt -fun box(): String { - val a = A() - - if (a.first() != 0x1F.toLong()) { - return "FAIL 1" - } - - if (a.second() != 0x1F.toLong()) { - return "FAIL 2" - } - - if (a.third() != 0b1010.toLong()) { - return "FAIL 3" - } - - if (a.fourth() != 0b1010.toLong()) { - return "FAIL 4" - } - - return "OK" -} - diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt deleted file mode 100644 index 9a8de425a9d..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt +++ /dev/null @@ -1,45 +0,0 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public int first(@DefaultValue("1") int a, @DefaultValue("2") int b) { - return 100 * a + b; - } - - public int second(int a, @DefaultValue("42") int b) { - return 100 * a + b; - } -} - -// FILE: main.kt -fun box(): String { - val a = A() - - if (a.first() != 102) { - return "FAIL 1" - } - - if (a.first(2) != 202) { - return "FAIL 2" - } - - if (a.first(3, 4) != 304) { - return "FAIL 3" - } - - if (a.second(7, 8) != 708) { - return "FAIL 4" - } - - if (a.second(1) != 142) { - return "FAIL 5" - } - - return "OK" -} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt deleted file mode 100644 index 29a3f9cebee..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt +++ /dev/null @@ -1,58 +0,0 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - public Integer foo(@DefaultNull Integer x) { return x; } - public Integer bar(@DefaultNull Integer x) { return x; } - - public Integer baz(@DefaultValue("42") Integer x) { return x; } -} - -// FILE: AInt.java -import kotlin.annotations.jvm.internal.*; - -public interface AInt { - public Integer foo(@DefaultValue("42") Integer x); - public Integer bar(@DefaultNull Integer x); -} - -// FILE: B.java - -public class B extends A { - public Integer foo(Integer x) { return x; } -} - -// FILE: C.java -import kotlin.annotations.jvm.internal.*; - -public class C extends A { - public Integer foo(@DefaultValue("42") Integer x) { return x; } - - public Integer baz(@DefaultNull Integer x) { return x; } -} - -// FILE: D.java - -public class D extends A implements AInt { -} - -// FILE: test.kt -fun box(): String { - if (A().foo() != null) return "FAIL 0" - - if (B().foo() != null) return "FAIL 1" - if (B().bar() != null) return "FAIL 2" - - if (C().foo() != null) return "FAIL 3" - if (C().baz() != 42) return "FAIL 4" - - if (D().baz() != 42) return "FAIL 5" - - return "OK" -} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt deleted file mode 100644 index 62249a7f70d..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt +++ /dev/null @@ -1,83 +0,0 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; -import org.jetbrains.annotations.*; - -public class A { - - public Integer a(@Nullable @DefaultValue("42") Integer arg) { - return arg; - } - - public Float b(@Nullable @DefaultValue("42.5") Float arg) { - return arg; - } - - public Boolean c(@Nullable @DefaultValue("true") Boolean arg) { - return arg; - } - - public Byte d(@Nullable @DefaultValue("42") Byte arg) { - return arg; - } - - public Character e(@Nullable @DefaultValue("o") Character arg) { - return arg; - } - - public Double f(@Nullable @DefaultValue("1e12") Double arg) { - return arg; - } - - public Long g(@Nullable @DefaultValue("42424242424242") Long arg) { - return arg; - } - - public Short h(@Nullable @DefaultValue("123") Short arg) { - return arg; - } -} - -// FILE: test.kt -fun box(): String { - val a = A() - - if (a.a() != 42) { - return "FAIL Int: ${a.a()}" - } - - if (a.b() != 42.5f) { - return "FAIL Float: ${a.b()}" - } - - if (!a.c()) { - return "FAIL Boolean: ${a.c()}" - } - - if (a.d() != 42.toByte()) { - return "FAIL Byte: ${a.d()}" - } - - if (a.e() != 'o') { - return "FAIL Char: ${a.e()}" - } - - if (a.f() != 1e12) { - return "FAIl Double: ${a.f()}" - } - - if (a.g() != 42424242424242) { - return "FAIL Long: ${a.g()}" - } - - if (a.h() != 123.toShort()) { - return "FAIL Short: ${a.h()}" - } - - return "OK" -} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt deleted file mode 100644 index 6c41645a32e..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt +++ /dev/null @@ -1,40 +0,0 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public int first(@DefaultValue("42") int a) { - return a; - } -} - -// FILE: B.java -class B extends A { - public int first(int a) { - return a; - } -} - -// FILE: test.kt -fun box(): String { - val a = A() - val b = B() - val ab: A = B() - - if (a.first() != 42) { - return "FAIL 1" - } - if (b.first() != 42) { - return "FAIL 2" - } - if (ab.first() != 42) { - return "FAIL 4" - } - - return "OK" -} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt deleted file mode 100644 index 99a5295c319..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt +++ /dev/null @@ -1,90 +0,0 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - - public int a(@DefaultValue("42") int arg) { - return arg; - } - - public float b(@DefaultValue("42.5") float arg) { - return arg; - } - - public boolean c(@DefaultValue("true") boolean arg) { - return arg; - } - - public byte d(@DefaultValue("42") byte arg) { - return arg; - } - - public char e(@DefaultValue("o") char arg) { - return arg; - } - - public double f(@DefaultValue("1e12") double arg) { - return arg; - } - - public String g(@DefaultValue("hello") String arg) { - return arg; - } - - public long h(@DefaultValue("42424242424242") long arg) { - return arg; - } - - public short i(@DefaultValue("123") short arg) { - return arg; - } -} - -// FILE: test.kt -fun box(): String { - val a = A() - - if (a.a() != 42) { - return "FAIL Int: ${a.a()}" - } - - if (a.b() != 42.5f) { - return "FAIL Float: ${a.b()}" - } - - if (!a.c()) { - return "FAIL Boolean: ${a.c()}" - } - - if (a.d() != 42.toByte()) { - return "FAIL Byte: ${a.d()}" - } - - if (a.e() != 'o') { - return "FAIL Char: ${a.e()}" - } - - if (a.f() != 1e12) { - return "FAIl Double: ${a.f()}" - } - - if (a.g() != "hello") { - return "FAIL String: ${a.g()}" - } - - if (a.h() != 42424242424242) { - return "FAIL Long: ${a.h()}" - } - - if (a.i() != 123.toShort()) { - return "FAIL Short: ${a.i()}" - } - - return "OK" -} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt deleted file mode 100644 index 416fb512aab..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt +++ /dev/null @@ -1,42 +0,0 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - public String x; - public A(@DefaultValue("OK") String hello) { - x = hello; - } -} - -// FILE: test.kt - -fun box(): String { - val a = A() - - val b = object : A() { - } - - val c = object : A() { - fun hello() = x - } - - if (a.x != "OK") { - return "FAIL 1" - } - - if (b.x != "OK") { - return "FAIL 2" - } - - if (c.hello() != "OK") { - return "FAIL 3" - } - - return "OK" -} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt deleted file mode 100644 index 6e751c3cdb9..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt +++ /dev/null @@ -1,28 +0,0 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - public int x(@DefaultValue("42") int x) { - return x; - } -} - -// FILE: B.kt -class B : A() { - override fun x(x: Int): Int = x + 1 -} - -// FILE: box.kt -fun box(): String { - if (B().x() != 43) { - return "FAIL" - } - - return "OK" -} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultWithKotlinBase.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultWithKotlinBase.kt deleted file mode 100644 index ac18373d15f..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultWithKotlinBase.kt +++ /dev/null @@ -1,23 +0,0 @@ -// TARGET_BACKEND: JVM - -// FILE: A.kt -open class A { - open fun x(x: Int = foo()) = x - private fun foo() = 42 -} - -// FILE: B.java -public class B extends A { - public int x(int i) { - return i + 1; - } -} - -// FILE: box.kt -fun box(): String { - if (B().x() != 43) { - return "FAIL" - } - - return "OK" -} diff --git a/compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt b/compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt deleted file mode 100644 index fbd23206736..00000000000 --- a/compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt +++ /dev/null @@ -1,31 +0,0 @@ -// TARGET_BACKEND: JVM -// ANDROID_ANNOTATIONS - -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - public int connect(@ParameterName("host") int host, @ParameterName("port") int port) { - return host; - } -} - -// FILE: test.kt -fun box(): String { - val test = A() - - if (test.connect(host = 42, port = 8080) != 42) { - return "FAIL 1" - } - - if (test.connect(port = 1234, host = 5678) != 5678) { - return "FAIL 2" - } - - if (test.connect(9876, 4321) != 9876) { - return "FAIL 3" - } - - return "OK" -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.fir.kt deleted file mode 100644 index 00fba4d7682..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.fir.kt +++ /dev/null @@ -1,67 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: Signs.java - -public enum Signs { - HELLO, - WORLD; - - public static final Signs X; - public static final class NOT_ENTRY_EITHER {} -} - -// FILE: Mixed.java -public enum Mixed { - NOT_ENTRY_EITHER; - - public static final class NOT_ENTRY_EITHER {} -} - -// FILE: B.kt -enum class B { - X, - Y; -} - -// FILE: A.java -import kotlin.annotations.jvm.internal.*; - -class A { - public Signs a(@DefaultValue("HELLO") Signs arg) { - return arg; - } - - public B b(@DefaultValue("Y") B arg) { - return arg; - } - - public void foooo(@DefaultValue("ok") B arg) { - } - - public Signs bar(@DefaultValue("X") Signs arg) { - return arg; - } - - public Signs baz(@DefaultValue("NOT_ENTRY_EITHER") Signs arg) { - return arg; - } - - public Mixed bam(@DefaultValue("NOT_ENTRY_EITHER") Mixed arg) { - return arg; - } - -} - -// FILE: test.kt -fun test(){ - val a = A() - a.a() - a.a(Signs.HELLO) - a.b() - a.b(B.X) - a.foooo() - a.foooo(B.Y) - a.bar() - a.baz() - - a.bam() -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.kt deleted file mode 100644 index da9c00ceb7f..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.kt +++ /dev/null @@ -1,67 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: Signs.java - -public enum Signs { - HELLO, - WORLD; - - public static final Signs X; - public static final class NOT_ENTRY_EITHER {} -} - -// FILE: Mixed.java -public enum Mixed { - NOT_ENTRY_EITHER; - - public static final class NOT_ENTRY_EITHER {} -} - -// FILE: B.kt -enum class B { - X, - Y; -} - -// FILE: A.java -import kotlin.annotations.jvm.internal.*; - -class A { - public Signs a(@DefaultValue("HELLO") Signs arg) { - return arg; - } - - public B b(@DefaultValue("Y") B arg) { - return arg; - } - - public void foooo(@DefaultValue("ok") B arg) { - } - - public Signs bar(@DefaultValue("X") Signs arg) { - return arg; - } - - public Signs baz(@DefaultValue("NOT_ENTRY_EITHER") Signs arg) { - return arg; - } - - public Mixed bam(@DefaultValue("NOT_ENTRY_EITHER") Mixed arg) { - return arg; - } - -} - -// FILE: test.kt -fun test(){ - val a = A() - a.a() - a.a(Signs.HELLO) - a.b() - a.b(B.X) - a.foooo() - a.foooo(B.Y) - a.bar() - a.baz() - - a.bam() -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.txt deleted file mode 100644 index 2eca50367a9..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.txt +++ /dev/null @@ -1,90 +0,0 @@ -package - -public fun test(): kotlin.Unit - -public/*package*/ open class A { - public/*package*/ constructor A() - public open fun a(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "HELLO") arg: Signs! = ...): Signs! - public open fun b(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "Y") arg: B! = ...): B! - public open fun bam(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "NOT_ENTRY_EITHER") arg: Mixed!): Mixed! - public open fun bar(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "X") arg: Signs!): Signs! - public open fun baz(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "NOT_ENTRY_EITHER") arg: Signs!): Signs! - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun foooo(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "ok") arg: B!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public final enum class B : kotlin.Enum { - enum entry X - - enum entry Y - - private constructor B() - public final override /*1*/ /*fake_override*/ val name: kotlin.String - public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int - protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: B): kotlin.Int - public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit - public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! - public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - - // Static members - public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): B - public final /*synthesized*/ fun values(): kotlin.Array -} - -public final enum class Mixed : kotlin.Enum { - public constructor Mixed() - public final override /*1*/ /*fake_override*/ val name: kotlin.String - public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int - protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: Mixed!): kotlin.Int - public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit - public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! - public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - - public final class NOT_ENTRY_EITHER { - public constructor NOT_ENTRY_EITHER() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } - - // Static members - public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): Mixed - public final /*synthesized*/ fun values(): kotlin.Array -} - -public final enum class Signs : kotlin.Enum { - enum entry HELLO - - enum entry WORLD - - public constructor Signs() - public final override /*1*/ /*fake_override*/ val name: kotlin.String - public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int - protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: Signs!): kotlin.Int - public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit - public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! - public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - - public final class NOT_ENTRY_EITHER { - public constructor NOT_ENTRY_EITHER() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } - - // Static members - public final val X: Signs! - public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): Signs - public final /*synthesized*/ fun values(): kotlin.Array -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.fir.kt deleted file mode 100644 index fb58760dce0..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.fir.kt +++ /dev/null @@ -1,49 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - public void first(@DefaultValue("0x1F") Long value) { - } - - public void second(@DefaultValue("0X1F") Long value) { - } - - public void third(@DefaultValue("0b1010") Long value) { - } - - public void fourth(@DefaultValue("0B1010") Long value) { - } -} - -// FILE: B.java -import kotlin.annotations.jvm.internal.*; - -public class B { - public void first(@DefaultValue("0x") Long value) { - } - - public void second(@DefaultValue("0xZZ") Long value) { - } - - public void third(@DefaultValue("0b") Long value) { - } - - public void fourth(@DefaultValue("0B1234") Long value) { - } -} - -// FILE: test.kt -fun main(a: A, b: B) { - a.first() - a.second() - a.third() - a.fourth() - - b.first() - b.second() - b.third() - b.fourth() -} - diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.kt deleted file mode 100644 index 11c7b4ba3e4..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.kt +++ /dev/null @@ -1,49 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - public void first(@DefaultValue("0x1F") Long value) { - } - - public void second(@DefaultValue("0X1F") Long value) { - } - - public void third(@DefaultValue("0b1010") Long value) { - } - - public void fourth(@DefaultValue("0B1010") Long value) { - } -} - -// FILE: B.java -import kotlin.annotations.jvm.internal.*; - -public class B { - public void first(@DefaultValue("0x") Long value) { - } - - public void second(@DefaultValue("0xZZ") Long value) { - } - - public void third(@DefaultValue("0b") Long value) { - } - - public void fourth(@DefaultValue("0B1234") Long value) { - } -} - -// FILE: test.kt -fun main(a: A, b: B) { - a.first() - a.second() - a.third() - a.fourth() - - b.first() - b.second() - b.third() - b.fourth() -} - diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.txt deleted file mode 100644 index d5782442f9c..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.txt +++ /dev/null @@ -1,25 +0,0 @@ -package - -public fun main(/*0*/ a: A, /*1*/ b: B): kotlin.Unit - -public open class A { - public constructor A() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun first(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "0x1F") value: kotlin.Long! = ...): kotlin.Unit - public open fun fourth(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "0B1010") value: kotlin.Long! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open fun second(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "0X1F") value: kotlin.Long! = ...): kotlin.Unit - public open fun third(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "0b1010") value: kotlin.Long! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public open class B { - public constructor B() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun first(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "0x") value: kotlin.Long!): kotlin.Unit - public open fun fourth(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "0B1234") value: kotlin.Long!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open fun second(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "0xZZ") value: kotlin.Long!): kotlin.Unit - public open fun third(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "0b") value: kotlin.Long!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.fir.kt deleted file mode 100644 index 9d374ae004d..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.fir.kt +++ /dev/null @@ -1,31 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - public void foo(@DefaultNull Integer x) {} - public void bar(@DefaultNull int x) {} -} - -// FILE: B.java -import kotlin.annotations.jvm.internal.*; - -public class B { - public void foo(@DefaultNull T t) { } -} - -// FILE: test.kt -fun test(a: A, first: B, second: B) { - a.foo() - a.foo(0) - - a.bar() - a.bar(0) - - first.foo() - first.foo(5) - - second.foo() - second.foo(5) -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.kt deleted file mode 100644 index 6d93e590297..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.kt +++ /dev/null @@ -1,31 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - public void foo(@DefaultNull Integer x) {} - public void bar(@DefaultNull int x) {} -} - -// FILE: B.java -import kotlin.annotations.jvm.internal.*; - -public class B { - public void foo(@DefaultNull T t) { } -} - -// FILE: test.kt -fun test(a: A, first: B, second: B) { - a.foo() - a.foo(0) - - a.bar() - a.bar(0) - - first.foo() - first.foo(5) - - second.foo() - second.foo(5) -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.txt deleted file mode 100644 index 9e8e4faecc2..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.txt +++ /dev/null @@ -1,20 +0,0 @@ -package - -public fun test(/*0*/ a: A, /*1*/ first: B, /*2*/ second: B): kotlin.Unit - -public open class A { - public constructor A() - public open fun bar(/*0*/ @kotlin.annotations.jvm.internal.DefaultNull x: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun foo(/*0*/ @kotlin.annotations.jvm.internal.DefaultNull x: kotlin.Int! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public open class B { - public constructor B() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun foo(/*0*/ @kotlin.annotations.jvm.internal.DefaultNull t: T! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.kt deleted file mode 100644 index 1387049e9df..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.kt +++ /dev/null @@ -1,58 +0,0 @@ -// FIR_IDENTICAL -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -public class A { - public void foo(@DefaultNull Integer i) {} - - public void bar(@DefaultNull Integer a) {} - - public void bam(@DefaultNull Integer a) {} - - public void baz(@DefaultValue("42") Integer a) {} -} - -// FILE: AInt.java -import kotlin.annotations.jvm.internal.*; - -public interface AInt { - public void foo(@DefaultValue("42") Integer i) {} - public void bar(@DefaultNull Integer a) {} -} - -// FILE: B.java -import kotlin.annotations.jvm.internal.*; - -public class B extends A { - public void foo(Integer i) {} - - public void bar(@DefaultValue("42") Integer a) {} - - public void bam(@DefaultNull @DefaultValue("42") Integer a) {} -} - -// FILE: C.java -public class C extends A implements AInt { -} - -// FILE: test.kt - -fun test(b: B, c: C) { - b.foo() - b.foo(5) - b.bar() - b.bar(5) - b.bam() - b.bam(5) - - c.foo() - c.foo(5) - c.bar() - c.bar(5) - c.bam() - c.bam(5) - c.baz() - c.baz(42) -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.txt deleted file mode 100644 index b57b5bf2d79..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.txt +++ /dev/null @@ -1,44 +0,0 @@ -package - -public fun test(/*0*/ b: B, /*1*/ c: C): kotlin.Unit - -public open class A { - public constructor A() - public open fun bam(/*0*/ @kotlin.annotations.jvm.internal.DefaultNull a: kotlin.Int! = ...): kotlin.Unit - public open fun bar(/*0*/ @kotlin.annotations.jvm.internal.DefaultNull a: kotlin.Int! = ...): kotlin.Unit - public open fun baz(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "42") a: kotlin.Int! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun foo(/*0*/ @kotlin.annotations.jvm.internal.DefaultNull i: kotlin.Int! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public interface AInt { - public abstract fun bar(/*0*/ @kotlin.annotations.jvm.internal.DefaultNull a: kotlin.Int! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public abstract fun foo(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "42") i: kotlin.Int! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public open class B : A { - public constructor B() - public open override /*1*/ fun bam(/*0*/ @kotlin.annotations.jvm.internal.DefaultNull @kotlin.annotations.jvm.internal.DefaultValue(value = "42") a: kotlin.Int! = ...): kotlin.Unit - public open override /*1*/ fun bar(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "42") a: kotlin.Int! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun baz(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "42") a: kotlin.Int! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ fun foo(/*0*/ i: kotlin.Int! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public open class C : A, AInt { - public constructor C() - public open override /*1*/ /*fake_override*/ fun bam(/*0*/ @kotlin.annotations.jvm.internal.DefaultNull a: kotlin.Int! = ...): kotlin.Unit - public open override /*2*/ /*fake_override*/ fun bar(/*0*/ @kotlin.annotations.jvm.internal.DefaultNull a: kotlin.Int! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun baz(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "42") a: kotlin.Int! = ...): kotlin.Unit - public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*2*/ /*fake_override*/ fun foo(/*0*/ @kotlin.annotations.jvm.internal.DefaultNull i: kotlin.Int! = ...): kotlin.Unit - public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.fir.kt deleted file mode 100644 index 2795c35fcdb..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.fir.kt +++ /dev/null @@ -1,45 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public void first(@DefaultValue("hello") String value) { - } - - public void second(@DefaultValue("first") String a, @DefaultValue("second") String b) { - } - - public void third(@DefaultValue("first") String a, String b) { - } - - public void fourth(String first, @DefaultValue("second") String second) { - } - - public void wrong(@DefaultValue("hello") Integer i) { - } -} - - -// FILE: test.kt -fun main() { - val a = A() - - a.first() - a.first("arg") - - a.second() - a.second("arg") - a.second("first", "second") - - a.third("OK") - a.third("first", "second") - - a.fourth() - a.fourth("first") - a.fourth("first", "second") - - a.wrong() - a.wrong(42) -} - diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.kt deleted file mode 100644 index be351fecb58..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.kt +++ /dev/null @@ -1,45 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public void first(@DefaultValue("hello") String value) { - } - - public void second(@DefaultValue("first") String a, @DefaultValue("second") String b) { - } - - public void third(@DefaultValue("first") String a, String b) { - } - - public void fourth(String first, @DefaultValue("second") String second) { - } - - public void wrong(@DefaultValue("hello") Integer i) { - } -} - - -// FILE: test.kt -fun main() { - val a = A() - - a.first() - a.first("arg") - - a.second() - a.second("arg") - a.second("first", "second") - - a.third("OK") - a.third("first", "second") - - a.fourth() - a.fourth("first") - a.fourth("first", "second") - - a.wrong() - a.wrong(42) -} - diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.txt deleted file mode 100644 index 86b96afdc34..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.txt +++ /dev/null @@ -1,15 +0,0 @@ -package - -public fun main(): kotlin.Unit - -public/*package*/ open class A { - public/*package*/ constructor A() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun first(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "hello") value: kotlin.String! = ...): kotlin.Unit - public open fun fourth(/*0*/ first: kotlin.String!, /*1*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "second") second: kotlin.String! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open fun second(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "first") a: kotlin.String! = ..., /*1*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "second") b: kotlin.String! = ...): kotlin.Unit - public open fun third(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "first") a: kotlin.String! = ..., /*1*/ b: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - public open fun wrong(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "hello") i: kotlin.Int!): kotlin.Unit -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.fir.kt deleted file mode 100644 index 284a8a3aa16..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.fir.kt +++ /dev/null @@ -1,27 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public void emptyName(@ParameterName("") String first, @ParameterName("ok") int second) { - } - - public void missingName(@ParameterName() String first) { - } - - public void numberName(@ParameterName(42) String first) { - } -} - -// FILE: test.kt -fun main() { - val test = A() - test.emptyName("first", 42) - test.emptyName("first", ok = 42) - - test.missingName(`first` = "arg") - test.missingName("arg") - - test.numberName("first") -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.kt deleted file mode 100644 index 161fa85a5bc..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.kt +++ /dev/null @@ -1,27 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public void emptyName(@ParameterName("") String first, @ParameterName("ok") int second) { - } - - public void missingName(@ParameterName() String first) { - } - - public void numberName(@ParameterName(42) String first) { - } -} - -// FILE: test.kt -fun main() { - val test = A() - test.emptyName("first", 42) - test.emptyName("first", ok = 42) - - test.missingName(`first` = "arg") - test.missingName("arg") - - test.numberName("first") -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.txt deleted file mode 100644 index 1e68dcac9a0..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.txt +++ /dev/null @@ -1,13 +0,0 @@ -package - -public fun main(): kotlin.Unit - -public/*package*/ open class A { - public/*package*/ constructor A() - public open fun emptyName(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = "") first: kotlin.String!, /*1*/ @kotlin.annotations.jvm.internal.ParameterName(value = "ok") ok: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open fun missingName(/*0*/ @kotlin.annotations.jvm.internal.ParameterName first: kotlin.String!): kotlin.Unit - public open fun numberName(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = 42) first: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.fir.kt deleted file mode 100644 index 350353f2296..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.fir.kt +++ /dev/null @@ -1,100 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public void first(@DefaultValue("42") int arg) { - } -} - -// FILE: B.java -class B { - public void first(int arg) { - } -} - -// FILE: C.java -import kotlin.annotations.jvm.internal.*; - -class C extends A { - public void first(@DefaultValue("73") int arg) { - } -} - -// FILE: D.java -import kotlin.internal.*; - -class D extends B { - public void first(@DefaultValue("37") int arg) { - } -} - -// FILE: E.java -import kotlin.annotations.jvm.internal.*; - -class E extends A { - public void first(int arg) { - } -} - -// FILE: F.kt -open class F { - open fun foo(x: String = "0") { - } -} - -// FILE: G.java -class G extends F { - public void foo(String y) { - } -} - -// FILE: K.java -import kotlin.annotations.jvm.internal.*; - -public interface K { - public void foo(@DefaultValue("1") String x) { } -} - -// FILE: L.java -import kotlin.annotations.jvm.internal.*; - -public interface L { - public void foo(@DefaultValue("1") String x) { } -} - -// FILE: M.java -public class M implements K, L { - public void foo(String x) { - } -} - -// FILE: main.kt -fun main() { - val a = A() - val c = C() - val d = D() - val e = E() - - val ac: A = C() - val bd: B = D() - - a.first() - c.first() - ac.first() - - d.first() - bd.first() - - e.first() - - val g = G() - g.foo() - g.foo("ok") - - val m = M() - m.foo() - -} - diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.kt deleted file mode 100644 index bf9bfd58166..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.kt +++ /dev/null @@ -1,100 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public void first(@DefaultValue("42") int arg) { - } -} - -// FILE: B.java -class B { - public void first(int arg) { - } -} - -// FILE: C.java -import kotlin.annotations.jvm.internal.*; - -class C extends A { - public void first(@DefaultValue("73") int arg) { - } -} - -// FILE: D.java -import kotlin.internal.*; - -class D extends B { - public void first(@DefaultValue("37") int arg) { - } -} - -// FILE: E.java -import kotlin.annotations.jvm.internal.*; - -class E extends A { - public void first(int arg) { - } -} - -// FILE: F.kt -open class F { - open fun foo(x: String = "0") { - } -} - -// FILE: G.java -class G extends F { - public void foo(String y) { - } -} - -// FILE: K.java -import kotlin.annotations.jvm.internal.*; - -public interface K { - public void foo(@DefaultValue("1") String x) { } -} - -// FILE: L.java -import kotlin.annotations.jvm.internal.*; - -public interface L { - public void foo(@DefaultValue("1") String x) { } -} - -// FILE: M.java -public class M implements K, L { - public void foo(String x) { - } -} - -// FILE: main.kt -fun main() { - val a = A() - val c = C() - val d = D() - val e = E() - - val ac: A = C() - val bd: B = D() - - a.first() - c.first() - ac.first() - - d.first() - bd.first() - - e.first() - - val g = G() - g.foo() - g.foo("ok") - - val m = M() - m.foo() - -} - diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.txt deleted file mode 100644 index 6c1c1c5a17e..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.txt +++ /dev/null @@ -1,81 +0,0 @@ -package - -public fun main(): kotlin.Unit - -public/*package*/ open class A { - public/*package*/ constructor A() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun first(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "42") arg: kotlin.Int = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public/*package*/ open class B { - public/*package*/ constructor B() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun first(/*0*/ arg: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public/*package*/ open class C : A { - public/*package*/ constructor C() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ fun first(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "73") arg: kotlin.Int = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public/*package*/ open class D : B { - public/*package*/ constructor D() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ fun first(/*0*/ @DefaultValue(value = "37") /* annotation class not found */ arg: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public/*package*/ open class E : A { - public/*package*/ constructor E() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ fun first(/*0*/ arg: kotlin.Int = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public open class F { - public constructor F() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun foo(/*0*/ x: kotlin.String = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public/*package*/ open class G : F { - public/*package*/ constructor G() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ fun foo(/*0*/ x: kotlin.String = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public interface K { - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public abstract fun foo(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "1") x: kotlin.String! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public interface L { - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public abstract fun foo(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "1") x: kotlin.String! = ...): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public open class M : K, L { - public constructor M() - public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*2*/ fun foo(/*0*/ x: kotlin.String! = ...): kotlin.Unit - public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.fir.kt deleted file mode 100644 index b022821911c..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.fir.kt +++ /dev/null @@ -1,98 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public void call(@ParameterName("foo") String arg) { - } -} - -// FILE: B.java -import kotlin.annotations.jvm.internal.*; - -class B extends A { - public void call(@ParameterName("bar") String arg) { - } -} - -// FILE: C.java - -class C extends A { - public void call(String arg) { - } -} - -// FILE: D.kt -open class D { - open fun call(foo: String) { - } -} - -// FILE: E.java -import kotlin.annotations.jvm.internal.*; - -class E extends D { - public void call(@ParameterName("baz") String bar) { - } -} - -// FILE: F.java -class F extends D { - public void call(String baaam) { - } -} - - -// FILE: G.java -import kotlin.annotations.jvm.internal.*; - -class G { - public void foo(String bar, @ParameterName("foo") String baz) { - } -} - -// FILE: H.java -class H extends G { - public void foo(String baz, String bam) { - } -} - -// FILE: test.kt -fun main() { - val a = A() - val b = B() - val c = C() - - a.call(foo = "hello") - a.call(arg = "hello") - a.call("hello") - - b.call(foo = "hello") - b.call(arg = "hello") - b.call(bar = "hello") - b.call("hello") - - c.call(foo = "hello") - c.call(arg = "hello") - c.call("hello") - - val e = E() - val f = F() - - e.call(foo = "hello") - e.call(bar = "hello") - e.call(baz = "hello") - e.call("hello") - - f.call(foo = "hello") - f.call(baaam = "hello") - f.call("hello") - - val g = G() - val h = H() - g.foo("ok", foo = "hohoho") - g.foo("ok", "hohoho") - h.foo("ok", foo = "hohoho") - h.foo("ok", "hohoho") -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.kt deleted file mode 100644 index 8c13de9edbb..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.kt +++ /dev/null @@ -1,98 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public void call(@ParameterName("foo") String arg) { - } -} - -// FILE: B.java -import kotlin.annotations.jvm.internal.*; - -class B extends A { - public void call(@ParameterName("bar") String arg) { - } -} - -// FILE: C.java - -class C extends A { - public void call(String arg) { - } -} - -// FILE: D.kt -open class D { - open fun call(foo: String) { - } -} - -// FILE: E.java -import kotlin.annotations.jvm.internal.*; - -class E extends D { - public void call(@ParameterName("baz") String bar) { - } -} - -// FILE: F.java -class F extends D { - public void call(String baaam) { - } -} - - -// FILE: G.java -import kotlin.annotations.jvm.internal.*; - -class G { - public void foo(String bar, @ParameterName("foo") String baz) { - } -} - -// FILE: H.java -class H extends G { - public void foo(String baz, String bam) { - } -} - -// FILE: test.kt -fun main() { - val a = A() - val b = B() - val c = C() - - a.call(foo = "hello") - a.call(arg = "hello") - a.call("hello") - - b.call(foo = "hello") - b.call(arg = "hello") - b.call(bar = "hello") - b.call("hello") - - c.call(foo = "hello") - c.call(arg = "hello") - c.call("hello") - - val e = E() - val f = F() - - e.call(foo = "hello") - e.call(bar = "hello") - e.call(baz = "hello") - e.call("hello") - - f.call(foo = "hello") - f.call(baaam = "hello") - f.call("hello") - - val g = G() - val h = H() - g.foo("ok", foo = "hohoho") - g.foo("ok", "hohoho") - h.foo("ok", foo = "hohoho") - h.foo("ok", "hohoho") -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.txt deleted file mode 100644 index 1b5630b0369..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.txt +++ /dev/null @@ -1,67 +0,0 @@ -package - -public fun main(): kotlin.Unit - -public/*package*/ open class A { - public/*package*/ constructor A() - public open fun call(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = "foo") foo: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public/*package*/ open class B : A { - public/*package*/ constructor B() - public open override /*1*/ fun call(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = "bar") bar: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public/*package*/ open class C : A { - public/*package*/ constructor C() - public open override /*1*/ fun call(/*0*/ foo: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public open class D { - public constructor D() - public open fun call(/*0*/ foo: kotlin.String): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public/*package*/ open class E : D { - public/*package*/ constructor E() - public open override /*1*/ fun call(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = "baz") baz: kotlin.String): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public/*package*/ open class F : D { - public/*package*/ constructor F() - public open override /*1*/ fun call(/*0*/ foo: kotlin.String): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public/*package*/ open class G { - public/*package*/ constructor G() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun foo(/*0*/ bar: kotlin.String!, /*1*/ @kotlin.annotations.jvm.internal.ParameterName(value = "foo") foo: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public/*package*/ open class H : G { - public/*package*/ constructor H() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ fun foo(/*0*/ baz: kotlin.String!, /*1*/ bam: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.kt deleted file mode 100644 index 037a24865c1..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.kt +++ /dev/null @@ -1,18 +0,0 @@ -// FIR_IDENTICAL - -// ANDROID_ANNOTATIONS -// FILE: A.java -import kotlin.annotations.jvm.internal.*; - -public class A { - public void connect(@ParameterName("host") String host, @ParameterName("port") int port) { - } -} - -// FILE: test.kt -fun main() { - val test = A() - test.connect("127.0.0.1", 8080) - test.connect(host = "127.0.0.1", port = 8080) - test.connect(port = 8080, host = "127.0.0.1") -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.txt deleted file mode 100644 index 67824fe0040..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.txt +++ /dev/null @@ -1,11 +0,0 @@ -package - -public fun main(): kotlin.Unit - -public open class A { - public constructor A() - public open fun connect(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = "host") host: kotlin.String!, /*1*/ @kotlin.annotations.jvm.internal.ParameterName(value = "port") port: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.fir.kt deleted file mode 100644 index 9a1dd337a6d..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ - -// ANDROID_ANNOTATIONS -// FILE: A.java -import kotlin.annotations.jvm.internal.*; - -public class A { - public void same(@ParameterName("ok") String first, @ParameterName("ok") String second) { - } -} - -// FILE: test.kt -fun main() { - val test = A() - test.same("hello", "world") - test.same(ok = "hello", ok = world) - test.same("hello", ok = "world") -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.kt deleted file mode 100644 index c9aa9b97ec0..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.kt +++ /dev/null @@ -1,17 +0,0 @@ - -// ANDROID_ANNOTATIONS -// FILE: A.java -import kotlin.annotations.jvm.internal.*; - -public class A { - public void same(@ParameterName("ok") String first, @ParameterName("ok") String second) { - } -} - -// FILE: test.kt -fun main() { - val test = A() - test.same("hello", "world") - test.same(ok = "hello", ok = world) - test.same("hello", ok = "world") -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.txt deleted file mode 100644 index 2f181c13e73..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.txt +++ /dev/null @@ -1,11 +0,0 @@ -package - -public fun main(): kotlin.Unit - -public open class A { - public constructor A() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open fun same(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = "ok") ok: kotlin.String!, /*1*/ @kotlin.annotations.jvm.internal.ParameterName(value = "ok") second: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.fir.kt deleted file mode 100644 index b1b5dab88ea..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.fir.kt +++ /dev/null @@ -1,24 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java -import kotlin.annotations.jvm.internal.*; -import kotlin.internal.*; - -public class A { - public void dollarName(@ParameterName("$") String host) { - } - - public void numberName(@ParameterName("42") String field) { - } -} - -// FILE: test.kt -fun main() { - val test = A() - test.dollarName(`$` = "hello") - test.dollarName("hello") - test.dollarName(host = "hello") - - test.numberName(`42` = "world") - test.numberName("world") - test.numberName(field = "world") -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.kt deleted file mode 100644 index 9220cc35987..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.kt +++ /dev/null @@ -1,24 +0,0 @@ -// ANDROID_ANNOTATIONS -// FILE: A.java -import kotlin.annotations.jvm.internal.*; -import kotlin.internal.*; - -public class A { - public void dollarName(@ParameterName("$") String host) { - } - - public void numberName(@ParameterName("42") String field) { - } -} - -// FILE: test.kt -fun main() { - val test = A() - test.dollarName(`$` = "hello") - test.dollarName("hello") - test.dollarName(host = "hello") - - test.numberName(`42` = "world") - test.numberName("world") - test.numberName(field = "world") -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.txt deleted file mode 100644 index 299fc9b6651..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.txt +++ /dev/null @@ -1,12 +0,0 @@ -package - -public fun main(): kotlin.Unit - -public open class A { - public constructor A() - public open fun dollarName(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = "$") `$`: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open fun numberName(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = "42") 42: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.kt deleted file mode 100644 index b6b925cc71e..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.kt +++ /dev/null @@ -1,21 +0,0 @@ -// FIR_IDENTICAL -// ANDROID_ANNOTATIONS -// FILE: A.java -import kotlin.annotations.jvm.internal.*; - - -public class A { - public void foo(@ParameterName("hello") String world) {} -} - -// FILE: B.kt - -class B : A() { - override fun foo(hello: String) {} -} - -// FILE: C.kt - -class C : A() { -} - diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.txt deleted file mode 100644 index a46b3ad3bac..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.txt +++ /dev/null @@ -1,25 +0,0 @@ -package - -public open class A { - public constructor A() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open fun foo(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = "hello") hello: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public final class B : A { - public constructor B() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ fun foo(/*0*/ hello: kotlin.String): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} - -public final class C : A { - public constructor C() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun foo(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = "hello") hello: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.kt deleted file mode 100644 index 70df865ef8d..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.kt +++ /dev/null @@ -1,18 +0,0 @@ -// FIR_IDENTICAL -// IGNORE_BACKEND: JS, NATIVE - -// ANDROID_ANNOTATIONS -// FILE: A.java - -import kotlin.annotations.jvm.internal.*; - -class A { - public static String withDefault(@DefaultValue("OK") String arg) { - return arg; - } -} - -// FILE: test.kt -fun box(): String { - return A.withDefault(); -} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.txt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.txt deleted file mode 100644 index d00162daa33..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.txt +++ /dev/null @@ -1,13 +0,0 @@ -package - -public fun box(): kotlin.String - -public/*package*/ open class A { - public/*package*/ constructor A() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - - // Static members - public open fun withDefault(/*0*/ @kotlin.annotations.jvm.internal.DefaultValue(value = "OK") arg: kotlin.String! = ...): kotlin.String! -} diff --git a/compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.fir.txt b/compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.fir.txt deleted file mode 100644 index 404a5540346..00000000000 --- a/compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.fir.txt +++ /dev/null @@ -1,6 +0,0 @@ -public open class StableName : R|kotlin/Any| { - public open fun connect(@R|kotlin/annotations/jvm/internal/ParameterName|(String(host)) host: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|): R|kotlin/Unit| - - public constructor(): R|test/StableName| - -} diff --git a/compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.java b/compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.java deleted file mode 100644 index f1da59361b5..00000000000 --- a/compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.java +++ /dev/null @@ -1,11 +0,0 @@ -// SKIP_IN_RUNTIME_TEST -// ANDROID_ANNOTATIONS - -package test; - -import kotlin.annotations.jvm.internal.*; - -public class StableName { - public void connect(@ParameterName("host") String host) { - } -} \ No newline at end of file diff --git a/compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.txt b/compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.txt deleted file mode 100644 index ea756e0de94..00000000000 --- a/compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.txt +++ /dev/null @@ -1,6 +0,0 @@ -package test - -public open class StableName { - public constructor StableName() - public open fun connect(/*0*/ @kotlin.annotations.jvm.internal.ParameterName(value = "host") /* annotation class not found */ host: kotlin.String!): kotlin.Unit -} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 1f5c983ab43..4c1b71b8aba 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -16434,42 +16434,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/j+k/signatureAnnotations"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); } - @Test - @TestMetadata("defaultEnum.kt") - public void testDefaultEnum() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.kt"); - } - - @Test - @TestMetadata("defaultLongLiteral.kt") - public void testDefaultLongLiteral() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.kt"); - } - - @Test - @TestMetadata("defaultNull.kt") - public void testDefaultNull() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.kt"); - } - - @Test - @TestMetadata("defaultNullAndParameter.kt") - public void testDefaultNullAndParameter() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.kt"); - } - - @Test - @TestMetadata("defaultParameter.kt") - public void testDefaultParameter() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.kt"); - } - - @Test - @TestMetadata("emptyParameterName.kt") - public void testEmptyParameterName() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.kt"); - } - @Test @TestMetadata("notNullVarargOverride.kt") public void testNotNullVarargOverride() throws Exception { @@ -16481,48 +16445,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { public void testNullableVarargOverride() throws Exception { runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/nullableVarargOverride.kt"); } - - @Test - @TestMetadata("overridesDefaultValue.kt") - public void testOverridesDefaultValue() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.kt"); - } - - @Test - @TestMetadata("overridesParameterName.kt") - public void testOverridesParameterName() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.kt"); - } - - @Test - @TestMetadata("reorderedParameterNames.kt") - public void testReorderedParameterNames() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.kt"); - } - - @Test - @TestMetadata("sameParameterName.kt") - public void testSameParameterName() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.kt"); - } - - @Test - @TestMetadata("specialCharsParameterName.kt") - public void testSpecialCharsParameterName() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.kt"); - } - - @Test - @TestMetadata("stableParameterName.kt") - public void testStableParameterName() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.kt"); - } - - @Test - @TestMetadata("staticMethodWithDefaultValue.kt") - public void testStaticMethodWithDefaultValue() throws Exception { - runTest("compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.kt"); - } } @Nested diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 8c084859b75..abbfa3e01ed 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -37307,94 +37307,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } - @Nested - @TestMetadata("compiler/testData/codegen/box/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - public class SignatureAnnotations { - @Test - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/signatureAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @Test - @TestMetadata("defaultAndNamedCombination.kt") - public void testDefaultAndNamedCombination() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt"); - } - - @Test - @TestMetadata("defaultBoxTypes.kt") - public void testDefaultBoxTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt"); - } - - @Test - @TestMetadata("defaultEnumType.kt") - public void testDefaultEnumType() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt"); - } - - @Test - @TestMetadata("defaultLongLiteral.kt") - public void testDefaultLongLiteral() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt"); - } - - @Test - @TestMetadata("defaultMultipleParams.kt") - public void testDefaultMultipleParams() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt"); - } - - @Test - @TestMetadata("defaultNull.kt") - public void testDefaultNull() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt"); - } - - @Test - @TestMetadata("defaultNullableBoxTypes.kt") - public void testDefaultNullableBoxTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt"); - } - - @Test - @TestMetadata("defaultOverrides.kt") - public void testDefaultOverrides() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt"); - } - - @Test - @TestMetadata("defaultPrimitiveTypes.kt") - public void testDefaultPrimitiveTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt"); - } - - @Test - @TestMetadata("defaultValueInConstructor.kt") - public void testDefaultValueInConstructor() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt"); - } - - @Test - @TestMetadata("defaultWithJavaBase.kt") - public void testDefaultWithJavaBase() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt"); - } - - @Test - @TestMetadata("defaultWithKotlinBase.kt") - public void testDefaultWithKotlinBase() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultWithKotlinBase.kt"); - } - - @Test - @TestMetadata("reorderedParameterNames.kt") - public void testReorderedParameterNames() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/smap") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index f2f1b23d1b9..1339990eb35 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -37307,94 +37307,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } - @Nested - @TestMetadata("compiler/testData/codegen/box/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - public class SignatureAnnotations { - @Test - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/signatureAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); - } - - @Test - @TestMetadata("defaultAndNamedCombination.kt") - public void testDefaultAndNamedCombination() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt"); - } - - @Test - @TestMetadata("defaultBoxTypes.kt") - public void testDefaultBoxTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt"); - } - - @Test - @TestMetadata("defaultEnumType.kt") - public void testDefaultEnumType() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt"); - } - - @Test - @TestMetadata("defaultLongLiteral.kt") - public void testDefaultLongLiteral() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt"); - } - - @Test - @TestMetadata("defaultMultipleParams.kt") - public void testDefaultMultipleParams() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt"); - } - - @Test - @TestMetadata("defaultNull.kt") - public void testDefaultNull() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt"); - } - - @Test - @TestMetadata("defaultNullableBoxTypes.kt") - public void testDefaultNullableBoxTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt"); - } - - @Test - @TestMetadata("defaultOverrides.kt") - public void testDefaultOverrides() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt"); - } - - @Test - @TestMetadata("defaultPrimitiveTypes.kt") - public void testDefaultPrimitiveTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt"); - } - - @Test - @TestMetadata("defaultValueInConstructor.kt") - public void testDefaultValueInConstructor() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt"); - } - - @Test - @TestMetadata("defaultWithJavaBase.kt") - public void testDefaultWithJavaBase() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt"); - } - - @Test - @TestMetadata("defaultWithKotlinBase.kt") - public void testDefaultWithKotlinBase() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultWithKotlinBase.kt"); - } - - @Test - @TestMetadata("reorderedParameterNames.kt") - public void testReorderedParameterNames() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt"); - } - } - @Nested @TestMetadata("compiler/testData/codegen/box/smap") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/classic/JavaCompilerFacade.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/classic/JavaCompilerFacade.kt index 9fb5c884459..a36a987209c 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/classic/JavaCompilerFacade.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/classic/JavaCompilerFacade.kt @@ -8,14 +8,12 @@ package org.jetbrains.kotlin.test.backend.classic import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots import org.jetbrains.kotlin.codegen.ClassFileFactory import org.jetbrains.kotlin.codegen.CodegenTestUtil -import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.JVMConfigurationKeys import org.jetbrains.kotlin.config.JvmTarget import org.jetbrains.kotlin.test.compileJavaFilesExternally import org.jetbrains.kotlin.test.directives.CodegenTestDirectives import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.USE_JAVAC_BASED_ON_JVM_TARGET -import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.assertions @@ -26,16 +24,11 @@ import org.jetbrains.kotlin.test.util.KtTestUtil import java.io.File class JavaCompilerFacade(private val testServices: TestServices) { - @OptIn(ExperimentalStdlibApi::class) fun compileJavaFiles(module: TestModule, configuration: CompilerConfiguration, classFileFactory: ClassFileFactory) { if (module.javaFiles.isEmpty()) return - val javaClasspath = buildList { - add(testServices.compiledClassesManager.getCompiledKotlinDirForModule(module, classFileFactory).path) - addAll(configuration.jvmClasspathRoots.map { it.absolutePath }) - if (JvmEnvironmentConfigurationDirectives.ANDROID_ANNOTATIONS in module.directives) { - add(ForTestCompileRuntime.androidAnnotationsForTests().path) - } - } + val javaClasspath = + listOf(testServices.compiledClassesManager.getCompiledKotlinDirForModule(module, classFileFactory).path) + + configuration.jvmClasspathRoots.map { it.absolutePath } val javaClassesOutputDirectory = testServices.compiledClassesManager.getOrCreateCompiledJavaDirForModule(module) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/JvmEnvironmentConfigurationDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/JvmEnvironmentConfigurationDirectives.kt index c0155f23963..1182466bfc1 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/JvmEnvironmentConfigurationDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/JvmEnvironmentConfigurationDirectives.kt @@ -30,8 +30,6 @@ object JvmEnvironmentConfigurationDirectives : SimpleDirectivesContainer() { val WITH_REFLECT by directive("Add Kotlin reflect to classpath") val NO_RUNTIME by directive("Don't add any runtime libs to classpath") - val ANDROID_ANNOTATIONS by directive("Add android annotations to classpath") - val USE_PSI_CLASS_FILES_READING by directive("Use a slower (PSI-based) class files reading implementation") val USE_JAVAC by directive("Enable javac integration") val SKIP_JAVA_SOURCES by directive("Don't add java sources to compile classpath") diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmEnvironmentConfigurator.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmEnvironmentConfigurator.kt index b175d6c327f..97defd76641 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmEnvironmentConfigurator.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/JvmEnvironmentConfigurator.kt @@ -132,10 +132,6 @@ class JvmEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfig configuration.addJvmClasspathRoot(ForTestCompileRuntime.runtimeJarForTestsWithJdk8()) } - if (JvmEnvironmentConfigurationDirectives.ANDROID_ANNOTATIONS in module.directives) { - configuration.addJvmClasspathRoot(ForTestCompileRuntime.androidAnnotationsForTests()) - } - val isIr = module.targetBackend?.isIR == true configuration.put(JVMConfigurationKeys.IR, isIr) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.kt index 8f239d5fc43..6b4a83fd5cb 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/checkers/KotlinMultiFileTestWithJava.kt @@ -4,7 +4,6 @@ */ package org.jetbrains.kotlin.checkers -import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment @@ -91,9 +90,6 @@ abstract class KotlinMultiFileTestWithJava InTextDirectivesUtils.isDirectiveDefined(it.content, "ANDROID_ANNOTATIONS") - ); - - List classpath = new ArrayList<>(); - classpath.add(getAnnotationsJar()); - - if (loadAndroidAnnotations) { - classpath.add(ForTestCompileRuntime.androidAnnotationsForTests()); - } CompilerConfiguration configuration = createConfiguration( configurationKind, getTestJdkKind(files), getBackend(), - classpath, + Collections.singletonList(getAnnotationsJar()), ArraysKt.filterNotNull(new File[] {javaSourceDir}), files ); @@ -453,9 +443,6 @@ public abstract class CodegenTestCase extends KotlinBaseTest javaClasspath = new ArrayList<>(); javaClasspath.add(kotlinOut.getPath()); - if (loadAndroidAnnotations) { - javaClasspath.add(ForTestCompileRuntime.androidAnnotationsForTests().getPath()); - } updateJavaClasspath(javaClasspath); javaClassesOutputDirectory = getJavaClassesOutputDirectory(); diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractLoadJavaTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractLoadJavaTest.java index 65efa2b6b6a..0b76d9d691a 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractLoadJavaTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/AbstractLoadJavaTest.java @@ -183,10 +183,6 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir { CommonConfigurationKeysKt.setLanguageVersionSettings(configuration, languageVersionSettings); - if (InTextDirectivesUtils.isDirectiveDefined(content, "ANDROID_ANNOTATIONS")) { - JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.androidAnnotationsForTests()); - } - if (InTextDirectivesUtils.isDirectiveDefined(content, "JVM_ANNOTATIONS")) { JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.jvmAnnotationsForTests()); } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/LoadDescriptorUtil.java b/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/LoadDescriptorUtil.java index 62b3f6b1dcb..66ca2ff5d4b 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/LoadDescriptorUtil.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/jvm/compiler/LoadDescriptorUtil.java @@ -173,10 +173,6 @@ public class LoadDescriptorUtil { args.addAll(InTextDirectivesUtils.findListWithPrefixes(content, "JAVAC_OPTIONS:")); - if (InTextDirectivesUtils.isDirectiveDefined(content, "ANDROID_ANNOTATIONS")) { - classpath.add(ForTestCompileRuntime.androidAnnotationsForTests()); - } - if (InTextDirectivesUtils.isDirectiveDefined(content, "JVM_ANNOTATIONS")) { classpath.add(ForTestCompileRuntime.jvmAnnotationsForTests()); } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 9b5bc96fc69..2c3562336a8 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -29796,84 +29796,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } - @TestMetadata("compiler/testData/codegen/box/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractLightAnalysisModeTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/signatureAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); - } - - @TestMetadata("defaultAndNamedCombination.kt") - public void testDefaultAndNamedCombination() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt"); - } - - @TestMetadata("defaultBoxTypes.kt") - public void testDefaultBoxTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt"); - } - - @TestMetadata("defaultEnumType.kt") - public void testDefaultEnumType() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt"); - } - - @TestMetadata("defaultLongLiteral.kt") - public void testDefaultLongLiteral() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt"); - } - - @TestMetadata("defaultMultipleParams.kt") - public void testDefaultMultipleParams() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt"); - } - - @TestMetadata("defaultNull.kt") - public void testDefaultNull() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt"); - } - - @TestMetadata("defaultNullableBoxTypes.kt") - public void testDefaultNullableBoxTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt"); - } - - @TestMetadata("defaultOverrides.kt") - public void testDefaultOverrides() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt"); - } - - @TestMetadata("defaultPrimitiveTypes.kt") - public void testDefaultPrimitiveTypes() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt"); - } - - @TestMetadata("defaultValueInConstructor.kt") - public void testDefaultValueInConstructor() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt"); - } - - @TestMetadata("defaultWithJavaBase.kt") - public void testDefaultWithJavaBase() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt"); - } - - @TestMetadata("defaultWithKotlinBase.kt") - public void testDefaultWithKotlinBase() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/defaultWithKotlinBase.kt"); - } - - @TestMetadata("reorderedParameterNames.kt") - public void testReorderedParameterNames() throws Exception { - runTest("compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt"); - } - } - @TestMetadata("compiler/testData/codegen/box/smap") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java index f2992668b76..ba3227bb772 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java @@ -1486,24 +1486,6 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { } } - @TestMetadata("compiler/testData/loadJava/compiledJava/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractLoadJavaTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTestCompiledJava, this, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava/compiledJava/signatureAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); - } - - @TestMetadata("StableName.java") - public void testStableName() throws Exception { - runTest("compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.java"); - } - } - @TestMetadata("compiler/testData/loadJava/compiledJava/signaturePropagation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaWithPsiClassReadingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaWithPsiClassReadingTestGenerated.java index b435219ddf8..c4c18aee26b 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaWithPsiClassReadingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaWithPsiClassReadingTestGenerated.java @@ -1484,24 +1484,6 @@ public class LoadJavaWithPsiClassReadingTestGenerated extends AbstractLoadJavaWi } } - @TestMetadata("compiler/testData/loadJava/compiledJava/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractLoadJavaWithPsiClassReadingTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTestCompiledJava, this, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava/compiledJava/signatureAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); - } - - @TestMetadata("StableName.java") - public void testStableName() throws Exception { - runTest("compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.java"); - } - } - @TestMetadata("compiler/testData/loadJava/compiledJava/signaturePropagation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java index dd139c4fd6d..d6a191a52fa 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java @@ -1487,24 +1487,6 @@ public class IrLoadJavaTestGenerated extends AbstractIrLoadJavaTest { } } - @TestMetadata("compiler/testData/loadJava/compiledJava/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractIrLoadJavaTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTestCompiledJava, TargetBackend.JVM_IR, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava/compiledJava/signatureAnnotations"), Pattern.compile("^(.+)\\.java$"), null, TargetBackend.JVM_IR, true); - } - - @TestMetadata("StableName.java") - public void testStableName() throws Exception { - runTest("compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.java"); - } - } - @TestMetadata("compiler/testData/loadJava/compiledJava/signaturePropagation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java index cc0633310fa..206798916dd 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java @@ -1486,24 +1486,6 @@ public class LoadJavaUsingJavacTestGenerated extends AbstractLoadJavaUsingJavacT } } - @TestMetadata("compiler/testData/loadJava/compiledJava/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractLoadJavaUsingJavacTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTestCompiledJava, this, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava/compiledJava/signatureAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); - } - - @TestMetadata("StableName.java") - public void testStableName() throws Exception { - runTest("compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.java"); - } - } - @TestMetadata("compiler/testData/loadJava/compiledJava/signaturePropagation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java b/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java index ac43705e26a..5f23b68e5d2 100644 --- a/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java +++ b/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java @@ -3766,24 +3766,6 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD } } - @TestMetadata("compiler/testData/loadJava/compiledJava/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractJvmRuntimeDescriptorLoaderTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava/compiledJava/signatureAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); - } - - @TestMetadata("StableName.java") - public void testStableName() throws Exception { - runTest("compiler/testData/loadJava/compiledJava/signatureAnnotations/StableName.java"); - } - } - @TestMetadata("compiler/testData/loadJava/compiledJava/signaturePropagation") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 02f3332bfe2..f492eff663c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -25427,19 +25427,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } - @TestMetadata("compiler/testData/codegen/box/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractIrJsCodegenBoxES6Test { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/signatureAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); - } - } - @TestMetadata("compiler/testData/codegen/box/smap") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index d9037c6bf6b..21a2241243b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -24912,19 +24912,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractIrJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/signatureAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); - } - } - @TestMetadata("compiler/testData/codegen/box/smap") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 9493d37b40d..d3970cd7a30 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -24872,19 +24872,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } - @TestMetadata("compiler/testData/codegen/box/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractJsCodegenBoxTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/signatureAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); - } - } - @TestMetadata("compiler/testData/codegen/box/smap") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 7123c292b71..afd26477072 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -13499,19 +13499,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } - @TestMetadata("compiler/testData/codegen/box/signatureAnnotations") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class SignatureAnnotations extends AbstractIrCodegenBoxWasmTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); - } - - public void testAllFilesPresentInSignatureAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/signatureAnnotations"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); - } - } - @TestMetadata("compiler/testData/codegen/box/smap") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From f1b0e893ae86a6fec680a4ed1bcbb4c8eb6eb66c Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 9 Feb 2021 12:34:38 +0100 Subject: [PATCH 161/368] Remove kotlin-annotations-android #KT-44815 Fixed --- libraries/ReadMe.md | 2 - .../build.gradle.kts | 37 ------------------ .../src/kotlin/Annotations.kt | 38 ------------------- prepare/compiler/build.gradle.kts | 1 - settings.gradle | 2 - 5 files changed, 80 deletions(-) delete mode 100644 libraries/tools/kotlin-annotations-android/build.gradle.kts delete mode 100644 libraries/tools/kotlin-annotations-android/src/kotlin/Annotations.kt diff --git a/libraries/ReadMe.md b/libraries/ReadMe.md index 4ad403c825d..68979c4252d 100644 --- a/libraries/ReadMe.md +++ b/libraries/ReadMe.md @@ -7,8 +7,6 @@ This part of the project contains the sources of the following libraries: - [kotlin-test](kotlin.test), the library for multiplatform unit testing - [kotlin-annotations-jvm](tools/kotlin-annotations-jvm), the annotations to improve types in the Java code to look better when being consumed in the Kotlin code. - - These libraries are built as a part of the [root](../) Gradle project. diff --git a/libraries/tools/kotlin-annotations-android/build.gradle.kts b/libraries/tools/kotlin-annotations-android/build.gradle.kts deleted file mode 100644 index 297e3f9c1fb..00000000000 --- a/libraries/tools/kotlin-annotations-android/build.gradle.kts +++ /dev/null @@ -1,37 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import org.jetbrains.kotlin.pill.PillExtension - -description = "Kotlin annotations for Android" - -plugins { - kotlin("jvm") - id("jps-compatible") -} - -pill { - variant = PillExtension.Variant.FULL -} - -jvmTarget = "1.6" -javaHome = rootProject.extra["JDK_16"] as String - -tasks.withType { - kotlinOptions.freeCompilerArgs += listOf("-Xallow-kotlin-package") - kotlinOptions.moduleName = project.name -} - -sourceSets { - "main" { - projectDefault() - } -} - -dependencies { - compileOnly(kotlinBuiltins()) -} - -publish() - -sourcesJar() -javadocJar() -runtimeJar() diff --git a/libraries/tools/kotlin-annotations-android/src/kotlin/Annotations.kt b/libraries/tools/kotlin-annotations-android/src/kotlin/Annotations.kt deleted file mode 100644 index 641e675fe5c..00000000000 --- a/libraries/tools/kotlin-annotations-android/src/kotlin/Annotations.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.annotations.jvm.internal - -/** - * Defines parameter name. - */ -@Target(AnnotationTarget.VALUE_PARAMETER) -@Retention(AnnotationRetention.BINARY) -public annotation class ParameterName(val value: String) - -/** - * Default value for java method parameter. - */ -@Target(AnnotationTarget.VALUE_PARAMETER) -@Retention(AnnotationRetention.BINARY) -public annotation class DefaultValue(val value: String) - -/** - * Define that null is default value for method parameter. - */ -@Target(AnnotationTarget.VALUE_PARAMETER) -@Retention(AnnotationRetention.BINARY) -public annotation class DefaultNull diff --git a/prepare/compiler/build.gradle.kts b/prepare/compiler/build.gradle.kts index d7d5ffab1ba..7c8c6eb99ab 100644 --- a/prepare/compiler/build.gradle.kts +++ b/prepare/compiler/build.gradle.kts @@ -80,7 +80,6 @@ val distLibraryProjects = listOfNotNull( ":kotlin-annotation-processing", ":kotlin-annotation-processing-cli", ":kotlin-annotation-processing-runtime", - ":kotlin-annotations-android", ":kotlin-annotations-jvm", ":kotlin-ant", ":kotlin-daemon", diff --git a/settings.gradle b/settings.gradle index aea202ba2eb..9ae697f5a7e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -263,7 +263,6 @@ include ":benchmarks", ":examples:kotlin-jsr223-local-example", ":examples:kotlin-jsr223-daemon-local-eval-example", ":kotlin-annotations-jvm", - ":kotlin-annotations-android", ":kotlin-scripting-common", ':kotlin-scripting-js', ':kotlin-scripting-js-test', @@ -532,7 +531,6 @@ project(':plugins:kapt3-idea').projectDir = "$rootDir/plugins/kapt3/kapt3-idea" project(':examples:kotlin-jsr223-local-example').projectDir = "$rootDir/libraries/examples/kotlin-jsr223-local-example" as File project(':examples:kotlin-jsr223-daemon-local-eval-example').projectDir = "$rootDir/libraries/examples/kotlin-jsr223-daemon-local-eval-example" as File project(':kotlin-annotations-jvm').projectDir = "$rootDir/libraries/tools/kotlin-annotations-jvm" as File -project(':kotlin-annotations-android').projectDir = "$rootDir/libraries/tools/kotlin-annotations-android" as File project(':kotlin-scripting-common').projectDir = "$rootDir/libraries/scripting/common" as File project(':kotlin-scripting-js').projectDir = "$rootDir/libraries/scripting/js" as File project(':kotlin-scripting-js-test').projectDir = "$rootDir/libraries/scripting/js-test" as File From b1ab64e854eab68fc8c12eff13c911481de74964 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 10 Feb 2021 12:55:28 +0300 Subject: [PATCH 162/368] JVM_IR KT-44483 argument adaptation is already done in PSI2IR --- .../FirBlackBoxCodegenTestGenerated.java | 6 ++++++ .../jvm/lower/FunctionReferenceLowering.kt | 19 ------------------- .../codegen/box/callableReference/kt37604.kt | 1 - .../codegen/box/callableReference/kt44483.kt | 10 ++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../LightAnalysisModeTestGenerated.java | 5 +++++ .../IrJsCodegenBoxES6TestGenerated.java | 5 +++++ .../IrJsCodegenBoxTestGenerated.java | 5 +++++ .../semantics/JsCodegenBoxTestGenerated.java | 5 +++++ 10 files changed, 48 insertions(+), 20 deletions(-) create mode 100644 compiler/testData/codegen/box/callableReference/kt44483.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 12d4bc176b0..d73b671d298 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -2440,6 +2440,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/callableReference/kt37604.kt"); } + @Test + @TestMetadata("kt44483.kt") + public void testKt44483() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt44483.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt index c44ca3b79e5..3d8f437d579 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt @@ -574,25 +574,6 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) else irGet(receiver!!) - // If a vararg parameter corresponds to exactly one KFunction argument, which is an array, that array - // is forwarded as is. - // - // fun f(x: (Int, Array) -> String) = x(0, arrayOf("OK", "FAIL")) - // fun h(i: Int, vararg xs: String) = xs[i] - // f(::h) - // - parameter.isVararg && unboundIndex < argumentTypes.size && parameter.type == valueParameters[unboundIndex].type -> - irGet(valueParameters[unboundIndex++]) - // In all other cases, excess arguments are packed into a new array. - // - // fun g(x: (Int, String, String) -> String) = x(0, "OK", "FAIL") - // f(::h) == g(::h) - // - parameter.isVararg && (unboundIndex < argumentTypes.size || !parameter.hasDefaultValue()) -> - irArray(parameter.type) { - (unboundIndex until argumentTypes.size).forEach { +irGet(valueParameters[unboundIndex++]) } - } - unboundIndex >= argumentTypes.size -> // Default value argument (this pass doesn't handle suspend functions, otherwise // it could also be the continuation argument) diff --git a/compiler/testData/codegen/box/callableReference/kt37604.kt b/compiler/testData/codegen/box/callableReference/kt37604.kt index 83f13e70955..a62e2771d30 100644 --- a/compiler/testData/codegen/box/callableReference/kt37604.kt +++ b/compiler/testData/codegen/box/callableReference/kt37604.kt @@ -1,4 +1,3 @@ - fun useUnit(fn: () -> Unit) { fn.invoke() } diff --git a/compiler/testData/codegen/box/callableReference/kt44483.kt b/compiler/testData/codegen/box/callableReference/kt44483.kt new file mode 100644 index 00000000000..25e2fbacd94 --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/kt44483.kt @@ -0,0 +1,10 @@ +// DONT_TARGET_EXACT_BACKEND: WASM +// WITH_RUNTIME + +fun f(vararg p: Pair): K = p[0].first + +fun box(): String { + // NB this is not an adapted function reference + val f: (Array>) -> String = ::f + return f(arrayOf("OK" to 0)) +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index abbfa3e01ed..f5eca379772 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -2440,6 +2440,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/callableReference/kt37604.kt"); } + @Test + @TestMetadata("kt44483.kt") + public void testKt44483() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt44483.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 1339990eb35..1edc33d351b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -2440,6 +2440,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/callableReference/kt37604.kt"); } + @Test + @TestMetadata("kt44483.kt") + public void testKt44483() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt44483.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 2c3562336a8..41c2fd07f52 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -2145,6 +2145,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/callableReference/kt37604.kt"); } + @TestMetadata("kt44483.kt") + public void testKt44483() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt44483.kt"); + } + @TestMetadata("nested.kt") public void testNested() throws Exception { runTest("compiler/testData/codegen/box/callableReference/nested.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index f492eff663c..c7360da197e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -1460,6 +1460,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/callableReference/kt37604.kt"); } + @TestMetadata("kt44483.kt") + public void testKt44483() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt44483.kt"); + } + @TestMetadata("nested.kt") public void testNested() throws Exception { runTest("compiler/testData/codegen/box/callableReference/nested.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 21a2241243b..3de8d8634a4 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -1460,6 +1460,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/kt37604.kt"); } + @TestMetadata("kt44483.kt") + public void testKt44483() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt44483.kt"); + } + @TestMetadata("nested.kt") public void testNested() throws Exception { runTest("compiler/testData/codegen/box/callableReference/nested.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index d3970cd7a30..a1313161de9 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -1460,6 +1460,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/kt37604.kt"); } + @TestMetadata("kt44483.kt") + public void testKt44483() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/kt44483.kt"); + } + @TestMetadata("nested.kt") public void testNested() throws Exception { runTest("compiler/testData/codegen/box/callableReference/nested.kt"); From 4e44804c775d0397c9ad5c5703a7ff95024c09bd Mon Sep 17 00:00:00 2001 From: Mark Punzalan Date: Fri, 12 Feb 2021 21:56:39 +0000 Subject: [PATCH 163/368] FIR IDE: Add quickfix for INAPPLICABLE_LATEINIT_MODIFIER. Also changed FE1.0 checker and all related fix factories to report error on the declaration instead of the lateinit modifier. This is consistent with the direction of all checkers in FIR (no reporting on modifiers). --- .../generator/diagnostics/DiagnosticData.kt | 1 + .../diagnostics/FirDiagnosticsList.kt | 2 +- .../fir/analysis/diagnostics/FirErrors.kt | 2 +- .../jetbrains/kotlin/diagnostics/Errors.java | 2 +- .../LateinitModifierApplicabilityChecker.kt | 28 ++++++------ .../kotlin/generators/tests/GenerateTests.kt | 1 + .../idea/quickfix/MainKtQuickFixRegistrar.kt | 1 + .../HighLevelQuickFixTestGenerated.java | 43 +++++++++++++++++++ .../api/fir/diagnostics/KtFirDiagnostics.kt | 2 +- .../fir/diagnostics/KtFirDiagnosticsImpl.kt | 2 +- .../quickfix/ChangeVariableMutabilityFix.kt | 6 +-- .../kotlin/idea/quickfix/RemoveModifierFix.kt | 3 +- ...ertLateinitPropertyToNotNullDelegateFix.kt | 3 +- .../kotlin/idea/quickfix/RemoveNullableFix.kt | 3 +- .../quickfix/RemovePartsFromPropertyFix.kt | 3 +- .../lateinitOfATypeWithNullableUpperBound.kt | 2 + idea/testData/quickfix/lateinit/val.kt | 3 +- idea/testData/quickfix/lateinit/val.kt.after | 3 +- 18 files changed, 78 insertions(+), 32 deletions(-) diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt index e880838ec49..bc38ea0e3f8 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt @@ -42,6 +42,7 @@ enum class PositioningStrategy(private val strategy: String) { WHEN_EXPRESSION("WHEN_EXPRESSION"), IF_EXPRESSION("IF_EXPRESSION"), VARIANCE_MODIFIER("VARIANCE_MODIFIER"), + LATEINIT_MODIFIER("LATEINIT_MODIFIER"), ; diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 97d3ce9e651..139fa2ae2a9 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -156,7 +156,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val INAPPLICABLE_CANDIDATE by error { parameter>("candidate") } - val INAPPLICABLE_LATEINIT_MODIFIER by error { + val INAPPLICABLE_LATEINIT_MODIFIER by error(PositioningStrategy.LATEINIT_MODIFIER) { parameter("reason") } } diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 43d304be839..6ef8930b030 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -140,7 +140,7 @@ object FirErrors { // Applicability val NONE_APPLICABLE by error1>>() val INAPPLICABLE_CANDIDATE by error1>() - val INAPPLICABLE_LATEINIT_MODIFIER by error1() + val INAPPLICABLE_LATEINIT_MODIFIER by error1(SourceElementPositioningStrategies.LATEINIT_MODIFIER) // Ambiguity val AMBIGUITY by error1>>() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 57e046bbc90..cb864463d37 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -590,7 +590,7 @@ public interface Errors { DiagnosticFactory0 PRIVATE_PROPERTY_IN_INTERFACE = DiagnosticFactory0.create(ERROR, PRIVATE_MODIFIER); DiagnosticFactory0 BACKING_FIELD_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); - DiagnosticFactory1 INAPPLICABLE_LATEINIT_MODIFIER = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 INAPPLICABLE_LATEINIT_MODIFIER = DiagnosticFactory1.create(ERROR, LATEINIT_MODIFIER); DiagnosticFactory0 LATEINIT_INTRINSIC_CALL_ON_NON_LITERAL = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 LATEINIT_INTRINSIC_CALL_ON_NON_LATEINIT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 LATEINIT_INTRINSIC_CALL_IN_INLINE_FUNCTION = DiagnosticFactory0.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LateinitModifierApplicabilityChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LateinitModifierApplicabilityChecker.kt index 0fdcfeab2fd..d566252e9a0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LateinitModifierApplicabilityChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LateinitModifierApplicabilityChecker.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.types.TypeUtils object LateinitModifierApplicabilityChecker { fun checkLateinitModifierApplicability(trace: BindingTrace, ktDeclaration: KtCallableDeclaration, descriptor: VariableDescriptor) { - val modifier = ktDeclaration.modifierList?.getModifier(KtTokens.LATEINIT_KEYWORD) ?: return + if (!ktDeclaration.hasModifier(KtTokens.LATEINIT_KEYWORD)) return val variables = when (descriptor) { is PropertyDescriptor -> "properties" @@ -43,37 +43,37 @@ object LateinitModifierApplicabilityChecker { val type = descriptor.type if (!descriptor.isVar) { - trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(modifier, "is allowed only on mutable $variables")) + trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(ktDeclaration, "is allowed only on mutable $variables")) } if (type.isInlineClassType()) { if (UnsignedTypes.isUnsignedType(type)) { - trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(modifier, "is not allowed on $variables of unsigned types")) + trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(ktDeclaration, "is not allowed on $variables of unsigned types")) } else { - trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(modifier, "is not allowed on $variables of inline class types")) + trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(ktDeclaration, "is not allowed on $variables of inline class types")) } } if (type.isMarkedNullable) { - trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(modifier, "is not allowed on $variables of nullable types")) + trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(ktDeclaration, "is not allowed on $variables of nullable types")) } else if (TypeUtils.isNullableType(type)) { trace.report( Errors.INAPPLICABLE_LATEINIT_MODIFIER.on( - modifier, + ktDeclaration, "is not allowed on $variables of a type with nullable upper bound" ) ) } if (KotlinBuiltIns.isPrimitiveType(type)) { - trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(modifier, "is not allowed on $variables of primitive types")) + trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(ktDeclaration, "is not allowed on $variables of primitive types")) } if (ktDeclaration is KtProperty) { if (ktDeclaration.hasDelegateExpression()) { - trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(modifier, "is not allowed on delegated properties")) + trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(ktDeclaration, "is not allowed on delegated properties")) } else if (ktDeclaration.hasInitializer()) { - trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(modifier, "is not allowed on $variables with initializer")) + trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(ktDeclaration, "is not allowed on $variables with initializer")) } } @@ -84,28 +84,28 @@ object LateinitModifierApplicabilityChecker { val hasBackingField = trace.bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor) ?: false if (ktDeclaration is KtParameter) { - trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(modifier, "is not allowed on primary constructor parameters")) + trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(ktDeclaration, "is not allowed on primary constructor parameters")) } if (isAbstract) { - trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(modifier, "is not allowed on abstract properties")) + trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(ktDeclaration, "is not allowed on abstract properties")) } if (!hasDelegateExpressionOrInitializer) { if (hasAccessorImplementation) { trace.report( Errors.INAPPLICABLE_LATEINIT_MODIFIER.on( - modifier, + ktDeclaration, "is not allowed on properties with a custom getter or setter" ) ) } else if (!isAbstract && !hasBackingField) { - trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(modifier, "is not allowed on properties without backing field")) + trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(ktDeclaration, "is not allowed on properties without backing field")) } } if (descriptor.extensionReceiverParameter != null) { - trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(modifier, "is not allowed on extension properties")) + trace.report(Errors.INAPPLICABLE_LATEINIT_MODIFIER.on(ktDeclaration, "is not allowed on extension properties")) } } } diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 4739fc48607..bebe4e05a3a 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -1104,6 +1104,7 @@ fun main(args: Array) { testClass { val pattern = "^([\\w\\-_]+)\\.kt$" + model("quickfix/lateinit", pattern = pattern, filenameStartsLowerCase = true) model("quickfix/modifiers", pattern = pattern, filenameStartsLowerCase = true, recursive = false) model("quickfix/override/typeMismatchOnOverride", pattern = pattern, filenameStartsLowerCase = true, recursive = false) model("quickfix/variables/changeMutability", pattern = pattern, filenameStartsLowerCase = true, recursive = false) diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt index 34f90742c3b..10ac75dd750 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt @@ -37,6 +37,7 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { private val mutability = KtQuickFixesListBuilder.registerPsiQuickFix { registerPsiQuickFix(ChangeVariableMutabilityFix.VAR_OVERRIDDEN_BY_VAL_FACTORY) + registerPsiQuickFix(ChangeVariableMutabilityFix.LATEINIT_VAL_FACTORY) } override val list: KtQuickFixesList = KtQuickFixesList.createCombined( diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java index 8422bcc0ff0..1cf3e270516 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java @@ -19,6 +19,49 @@ import java.util.regex.Pattern; @SuppressWarnings("all") @RunWith(JUnit3RunnerWithInners.class) public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTest { + @TestMetadata("idea/testData/quickfix/lateinit") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Lateinit extends AbstractHighLevelQuickFixTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInLateinit() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/lateinit"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true); + } + + @TestMetadata("nullable.kt") + public void testNullable() throws Exception { + runTest("idea/testData/quickfix/lateinit/nullable.kt"); + } + + @TestMetadata("val.kt") + public void testVal() throws Exception { + runTest("idea/testData/quickfix/lateinit/val.kt"); + } + + @TestMetadata("withGetter.kt") + public void testWithGetter() throws Exception { + runTest("idea/testData/quickfix/lateinit/withGetter.kt"); + } + + @TestMetadata("withGetterSetter.kt") + public void testWithGetterSetter() throws Exception { + runTest("idea/testData/quickfix/lateinit/withGetterSetter.kt"); + } + + @TestMetadata("withInitializer.kt") + public void testWithInitializer() throws Exception { + runTest("idea/testData/quickfix/lateinit/withInitializer.kt"); + } + + @TestMetadata("withSetter.kt") + public void testWithSetter() throws Exception { + runTest("idea/testData/quickfix/lateinit/withSetter.kt"); + } + } + @TestMetadata("idea/testData/quickfix/modifiers") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt index 1a7aca65037..5c3d07e9d6b 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -372,7 +372,7 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { abstract val candidate: KtSymbol } - abstract class InapplicableLateinitModifier : KtFirDiagnostic() { + abstract class InapplicableLateinitModifier : KtFirDiagnostic() { override val diagnosticClass get() = InapplicableLateinitModifier::class abstract val reason: String } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index 15b225a8cd3..d930ad9ee43 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -596,7 +596,7 @@ internal class InapplicableLateinitModifierImpl( override val reason: String, firDiagnostic: FirPsiDiagnostic<*>, override val token: ValidityToken, -) : KtFirDiagnostic.InapplicableLateinitModifier(), KtAbstractFirDiagnostic { +) : KtFirDiagnostic.InapplicableLateinitModifier(), KtAbstractFirDiagnostic { override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) } diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt index c03c529824a..a40ffb4fa6a 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt @@ -64,9 +64,9 @@ class ChangeVariableMutabilityFix( listOf(ChangeVariableMutabilityFix(psiElement, false)) } - val LATEINIT_VAL_FACTORY: QuickFixesPsiBasedFactory = - quickFixesPsiBasedFactory { psiElement: PsiElement -> - val property = psiElement.getStrictParentOfType() ?: return@quickFixesPsiBasedFactory emptyList() + val LATEINIT_VAL_FACTORY: QuickFixesPsiBasedFactory = + quickFixesPsiBasedFactory { psiElement: KtModifierListOwner -> + val property = psiElement as? KtProperty ?: return@quickFixesPsiBasedFactory emptyList() if (property.valOrVarKeyword.text != "val") { emptyList() } else { diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt index da1ed5968b7..21d1c90a84b 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt @@ -121,8 +121,7 @@ class RemoveModifierFix( fun createRemoveLateinitFactory(): QuickFixesPsiBasedFactory { return quickFixesPsiBasedFactory { psiElement: PsiElement -> - val modifierList = psiElement.parent as? KtDeclarationModifierList ?: return@quickFixesPsiBasedFactory emptyList() - val property = modifierList.parent as? KtProperty ?: return@quickFixesPsiBasedFactory emptyList() + val property = psiElement as? KtProperty ?: return@quickFixesPsiBasedFactory emptyList() if (!property.hasModifier(KtTokens.LATEINIT_KEYWORD)) return@quickFixesPsiBasedFactory emptyList() listOf(RemoveModifierFix(property, KtTokens.LATEINIT_KEYWORD, isRedundant = false)) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ConvertLateinitPropertyToNotNullDelegateFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ConvertLateinitPropertyToNotNullDelegateFix.kt index 9777abe886a..d68c693fc39 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ConvertLateinitPropertyToNotNullDelegateFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ConvertLateinitPropertyToNotNullDelegateFix.kt @@ -40,8 +40,7 @@ class ConvertLateinitPropertyToNotNullDelegateFix( companion object : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { - val modifierList = diagnostic.psiElement.parent as? KtDeclarationModifierList ?: return null - val property = modifierList.parent as? KtProperty ?: return null + val property = diagnostic.psiElement as? KtProperty ?: return null if (!property.hasModifier(KtTokens.LATEINIT_KEYWORD) || !property.isVar || property.hasInitializer()) return null val typeReference = property.typeReference ?: return null val type = property.analyze(BodyResolveMode.PARTIAL)[BindingContext.TYPE, typeReference] ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveNullableFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveNullableFix.kt index 5f1410130ba..1e089db92f9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveNullableFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemoveNullableFix.kt @@ -58,8 +58,7 @@ class RemoveNullableFix( object LATEINIT_FACTORY : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { - val lateinitElement = Errors.INAPPLICABLE_LATEINIT_MODIFIER.cast(diagnostic).psiElement - val property = lateinitElement.getStrictParentOfType() ?: return null + val property = Errors.INAPPLICABLE_LATEINIT_MODIFIER.cast(diagnostic).psiElement as? KtProperty ?: return null val typeReference = property.typeReference ?: return null val typeElement = (typeReference.typeElement ?: return null) as? KtNullableType ?: return null if (typeElement.innerType == null) return null diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemovePartsFromPropertyFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemovePartsFromPropertyFix.kt index f63ee42f68b..22ae0ca6739 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RemovePartsFromPropertyFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/RemovePartsFromPropertyFix.kt @@ -118,8 +118,7 @@ open class RemovePartsFromPropertyFix( object LateInitFactory : KotlinSingleIntentionActionFactory() { public override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { - val element = Errors.INAPPLICABLE_LATEINIT_MODIFIER.cast(diagnostic).psiElement - val property = PsiTreeUtil.getParentOfType(element, KtProperty::class.java) ?: return null + val property = Errors.INAPPLICABLE_LATEINIT_MODIFIER.cast(diagnostic).psiElement as? KtProperty ?: return null val hasInitializer = property.hasInitializer() val hasGetter = property.getter?.bodyExpression != null val hasSetter = property.setter?.bodyExpression != null diff --git a/idea/testData/checker/diagnosticsMessage/lateinitOfATypeWithNullableUpperBound.kt b/idea/testData/checker/diagnosticsMessage/lateinitOfATypeWithNullableUpperBound.kt index fed09f7e74c..bfbf3840fb1 100644 --- a/idea/testData/checker/diagnosticsMessage/lateinitOfATypeWithNullableUpperBound.kt +++ b/idea/testData/checker/diagnosticsMessage/lateinitOfATypeWithNullableUpperBound.kt @@ -1,3 +1,5 @@ +// FIR_COMPARISON + class C() { lateinit var item: V } \ No newline at end of file diff --git a/idea/testData/quickfix/lateinit/val.kt b/idea/testData/quickfix/lateinit/val.kt index dfa0119c891..07ea795d46d 100644 --- a/idea/testData/quickfix/lateinit/val.kt +++ b/idea/testData/quickfix/lateinit/val.kt @@ -2,4 +2,5 @@ class A() { lateinit val foo: String -} \ No newline at end of file +} +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/lateinit/val.kt.after b/idea/testData/quickfix/lateinit/val.kt.after index 10f4bff685f..be37d2414fd 100644 --- a/idea/testData/quickfix/lateinit/val.kt.after +++ b/idea/testData/quickfix/lateinit/val.kt.after @@ -2,4 +2,5 @@ class A() { lateinit var foo: String -} \ No newline at end of file +} +/* FIR_COMPARISON */ \ No newline at end of file From 2f450549ab4a98bcd7b4e836055d79cb8ed22acf Mon Sep 17 00:00:00 2001 From: Mark Punzalan Date: Sat, 13 Feb 2021 07:38:29 +0000 Subject: [PATCH 164/368] FIR IDE: Update FIR diagnostic test data for INAPPLICABLE_LATEINIT_MODIFIER. --- .../inapplicableLateinitModifier.kt | 32 +++++++++---------- .../resolve/fromBuilder/simpleClass.kt | 2 +- ...ocalVariablesWithTypeParameters_1_3.fir.kt | 2 +- ...ocalVariablesWithTypeParameters_1_4.fir.kt | 2 +- .../local/inapplicableLateinitModifier.fir.kt | 18 ----------- .../local/inapplicableLateinitModifier.kt | 1 + .../lateinit/modifierApplicability.fir.kt | 32 +++++++++---------- .../modifierApplicability_lv12.fir.kt | 32 +++++++++---------- .../properties/lateinitOnTopLevel.fir.kt | 14 -------- .../tests/properties/lateinitOnTopLevel.kt | 1 + 10 files changed, 53 insertions(+), 83 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/lateinit/local/inapplicableLateinitModifier.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/properties/lateinitOnTopLevel.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/inapplicableLateinitModifier.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/inapplicableLateinitModifier.kt index e5cdcc75457..3894b1275bf 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/inapplicableLateinitModifier.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/inapplicableLateinitModifier.kt @@ -3,36 +3,36 @@ object Delegate { operator fun setValue(instance: Any?, property: Any, value: String) {} } -lateinit var test: Int -lateinit var kest by Delegate +lateinit var test: Int +lateinit var kest by Delegate lateinit var good: String class A { - lateinit val fest = "10" + lateinit val fest = "10" lateinit var mest: String - lateinit var xest: String? - lateinit var nest: Int - lateinit var west: Char - lateinit var qest: Boolean - lateinit var aest: Short - lateinit var hest: Byte - lateinit var jest: Long - lateinit val dest: String - get() = "KEKER" + lateinit var xest: String? + lateinit var nest: Int + lateinit var west: Char + lateinit var qest: Boolean + lateinit var aest: Short + lateinit var hest: Byte + lateinit var jest: Long + lateinit val dest: String + get() = "KEKER" } class B { - lateinit var best: T + lateinit var best: T } class C { lateinit var pest: K - lateinit var vest: K? + lateinit var vest: K? } fun rest() { - lateinit var i: Int + lateinit var i: Int lateinit var a: A - lateinit var b: B = B() + lateinit var b: B = B() } diff --git a/compiler/fir/analysis-tests/testData/resolve/fromBuilder/simpleClass.kt b/compiler/fir/analysis-tests/testData/resolve/fromBuilder/simpleClass.kt index d6e91bf884b..bdadf0db4d7 100644 --- a/compiler/fir/analysis-tests/testData/resolve/fromBuilder/simpleClass.kt +++ b/compiler/fir/analysis-tests/testData/resolve/fromBuilder/simpleClass.kt @@ -15,7 +15,7 @@ class SomeClass : SomeInterface { get() = true set(value) {} - lateinit var fau: Double + lateinit var fau: Double } inline class InlineClass diff --git a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt index 0da46b5fa6e..5539b97ee64 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt @@ -9,7 +9,7 @@ fun test() { val a1 = "" val a2 = 0 const val a3 = 0 - lateinit val a4 = 0 + lateinit val a4 = 0 val a5 by Delegate() val a6 by Delegate<T>() } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt index 7e71a1f6c70..e86865131dd 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt @@ -9,7 +9,7 @@ fun test() { val a1 = "" val a2 = 0 const val a3 = 0 - lateinit val a4 = 0 + lateinit val a4 = 0 val a5 by Delegate() val a6 by Delegate<T>() } diff --git a/compiler/testData/diagnostics/tests/lateinit/local/inapplicableLateinitModifier.fir.kt b/compiler/testData/diagnostics/tests/lateinit/local/inapplicableLateinitModifier.fir.kt deleted file mode 100644 index 3a70287a722..00000000000 --- a/compiler/testData/diagnostics/tests/lateinit/local/inapplicableLateinitModifier.fir.kt +++ /dev/null @@ -1,18 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VALUE -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -// !LANGUAGE: +LateinitLocalVariables - -import kotlin.reflect.KProperty - -object Delegate { - operator fun getValue(instance: Any?, property: KProperty<*>) : String = "" - operator fun setValue(instance: Any?, property: KProperty<*>, value: String) {} -} - - -fun test() { - lateinit val test0: Any - lateinit var test1: Int - lateinit var test2: Any? - lateinit var test3: String = "" - lateinit var test4 by Delegate -} diff --git a/compiler/testData/diagnostics/tests/lateinit/local/inapplicableLateinitModifier.kt b/compiler/testData/diagnostics/tests/lateinit/local/inapplicableLateinitModifier.kt index 6aa250c0593..2acd899919b 100644 --- a/compiler/testData/diagnostics/tests/lateinit/local/inapplicableLateinitModifier.kt +++ b/compiler/testData/diagnostics/tests/lateinit/local/inapplicableLateinitModifier.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VALUE -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE // !LANGUAGE: +LateinitLocalVariables diff --git a/compiler/testData/diagnostics/tests/lateinit/modifierApplicability.fir.kt b/compiler/testData/diagnostics/tests/lateinit/modifierApplicability.fir.kt index 7342803baed..976959c2304 100644 --- a/compiler/testData/diagnostics/tests/lateinit/modifierApplicability.fir.kt +++ b/compiler/testData/diagnostics/tests/lateinit/modifierApplicability.fir.kt @@ -8,12 +8,12 @@ class CustomDelegate { public abstract class A(lateinit var p2: String) { - public lateinit val a: String - lateinit val b: T + public lateinit val a: String + lateinit val b: T private lateinit var c: CharSequence - lateinit val d: String - get + lateinit val d: String + get public lateinit var e: String get @@ -23,22 +23,22 @@ public abstract class A(lateinit var p2: String) { lateinit var a: String } - lateinit var e1: V - lateinit var e2: String? - lateinit var e3: Int - lateinit var e4: Int? - lateinit var e5 = "A" + lateinit var e1: V + lateinit var e2: String? + lateinit var e3: Int + lateinit var e4: Int? + lateinit var e5 = "A" // With initializer, primitive - lateinit var e6 = 3 + lateinit var e6 = 3 - lateinit var e7 by CustomDelegate() + lateinit var e7 by CustomDelegate() - lateinit var e8: String - get() = "A" + lateinit var e8: String + get() = "A" - lateinit var e9: String - set(v) { field = v } + lateinit var e9: String + set(v) { field = v } abstract lateinit var e10: String @@ -47,7 +47,7 @@ public abstract class A(lateinit var p2: String) { lateinit var String.e12: String } -lateinit val topLevel: String +lateinit val topLevel: String lateinit var topLevelMutable: String public interface Intf { diff --git a/compiler/testData/diagnostics/tests/lateinit/modifierApplicability_lv12.fir.kt b/compiler/testData/diagnostics/tests/lateinit/modifierApplicability_lv12.fir.kt index aadbc805a75..eeb08876d7f 100644 --- a/compiler/testData/diagnostics/tests/lateinit/modifierApplicability_lv12.fir.kt +++ b/compiler/testData/diagnostics/tests/lateinit/modifierApplicability_lv12.fir.kt @@ -8,12 +8,12 @@ class CustomDelegate { public abstract class A(lateinit var p2: String) { - public lateinit val a: String - lateinit val b: T + public lateinit val a: String + lateinit val b: T private lateinit var c: CharSequence - lateinit val d: String - get + lateinit val d: String + get public lateinit var e: String get @@ -23,22 +23,22 @@ public abstract class A(lateinit var p2: String) { lateinit var a: String } - lateinit var e1: V - lateinit var e2: String? - lateinit var e3: Int - lateinit var e4: Int? - lateinit var e5 = "A" + lateinit var e1: V + lateinit var e2: String? + lateinit var e3: Int + lateinit var e4: Int? + lateinit var e5 = "A" // With initializer, primitive - lateinit var e6 = 3 + lateinit var e6 = 3 - lateinit var e7 by CustomDelegate() + lateinit var e7 by CustomDelegate() - lateinit var e8: String - get() = "A" + lateinit var e8: String + get() = "A" - lateinit var e9: String - set(v) { field = v } + lateinit var e9: String + set(v) { field = v } abstract lateinit var e10: String @@ -47,7 +47,7 @@ public abstract class A(lateinit var p2: String) { lateinit var String.e12: String } -lateinit val topLevel: String +lateinit val topLevel: String lateinit var topLevelMutable: String public interface Intf { diff --git a/compiler/testData/diagnostics/tests/properties/lateinitOnTopLevel.fir.kt b/compiler/testData/diagnostics/tests/properties/lateinitOnTopLevel.fir.kt deleted file mode 100644 index 1abc684500f..00000000000 --- a/compiler/testData/diagnostics/tests/properties/lateinitOnTopLevel.fir.kt +++ /dev/null @@ -1,14 +0,0 @@ -// !LANGUAGE: +LateinitTopLevelProperties - -object Delegate { - operator fun getValue(instance: Any?, property: Any) : String = "" - operator fun setValue(instance: Any?, property: Any, value: String) {} -} - -lateinit var testOk: String - -lateinit val testErr0: Any -lateinit var testErr1: Int -lateinit var testErr2: Any? -lateinit var testErr3: String = "" -lateinit var testErr4 by Delegate diff --git a/compiler/testData/diagnostics/tests/properties/lateinitOnTopLevel.kt b/compiler/testData/diagnostics/tests/properties/lateinitOnTopLevel.kt index 3b3153be226..71ca1171cab 100644 --- a/compiler/testData/diagnostics/tests/properties/lateinitOnTopLevel.kt +++ b/compiler/testData/diagnostics/tests/properties/lateinitOnTopLevel.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +LateinitTopLevelProperties object Delegate { From 706d3e5aa87487c52d43cde735cd7c01f147407a Mon Sep 17 00:00:00 2001 From: Mark Punzalan Date: Fri, 12 Feb 2021 23:16:52 +0000 Subject: [PATCH 165/368] FIR IDE: Add quickfix for VAR_ANNOTATION_PARAMETER. --- .../kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt | 2 ++ .../idea/quickfix/HighLevelQuickFixTestGenerated.java | 5 +++++ .../variables/changeMutability/varAnnotationParameter.kt | 6 ++++++ .../changeMutability/varAnnotationParameter.kt.after | 6 ++++++ .../kotlin/idea/quickfix/QuickFixTestGenerated.java | 5 +++++ 5 files changed, 24 insertions(+) create mode 100644 idea/testData/quickfix/variables/changeMutability/varAnnotationParameter.kt create mode 100644 idea/testData/quickfix/variables/changeMutability/varAnnotationParameter.kt.after diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt index 10ac75dd750..d0f59fb5b8f 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic import org.jetbrains.kotlin.idea.quickfix.fixes.ChangeTypeQuickFix import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtModifierListOwner +import org.jetbrains.kotlin.psi.KtParameter class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { private val modifiers = KtQuickFixesListBuilder.registerPsiQuickFix { @@ -37,6 +38,7 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { private val mutability = KtQuickFixesListBuilder.registerPsiQuickFix { registerPsiQuickFix(ChangeVariableMutabilityFix.VAR_OVERRIDDEN_BY_VAL_FACTORY) + registerPsiQuickFix(ChangeVariableMutabilityFix.VAR_ANNOTATION_PARAMETER_FACTORY) registerPsiQuickFix(ChangeVariableMutabilityFix.LATEINIT_VAL_FACTORY) } diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java index 1cf3e270516..012869b9b17 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java @@ -564,5 +564,10 @@ public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTes public void testValWithSetter() throws Exception { runTest("idea/testData/quickfix/variables/changeMutability/valWithSetter.kt"); } + + @TestMetadata("varAnnotationParameter.kt") + public void testVarAnnotationParameter() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/varAnnotationParameter.kt"); + } } } diff --git a/idea/testData/quickfix/variables/changeMutability/varAnnotationParameter.kt b/idea/testData/quickfix/variables/changeMutability/varAnnotationParameter.kt new file mode 100644 index 00000000000..85eee7c13a0 --- /dev/null +++ b/idea/testData/quickfix/variables/changeMutability/varAnnotationParameter.kt @@ -0,0 +1,6 @@ +// "Change to val" "true" +annotation class Ann( + val a: Int, + var b: Int +) +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/testData/quickfix/variables/changeMutability/varAnnotationParameter.kt.after b/idea/testData/quickfix/variables/changeMutability/varAnnotationParameter.kt.after new file mode 100644 index 00000000000..605d8a3c9fb --- /dev/null +++ b/idea/testData/quickfix/variables/changeMutability/varAnnotationParameter.kt.after @@ -0,0 +1,6 @@ +// "Change to val" "true" +annotation class Ann( + val a: Int, + val b: Int +) +/* FIR_COMPARISON */ \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 938eea025e3..70c4af4e255 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -15167,6 +15167,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { runTest("idea/testData/quickfix/variables/changeMutability/valWithSetter.kt"); } + @TestMetadata("varAnnotationParameter.kt") + public void testVarAnnotationParameter() throws Exception { + runTest("idea/testData/quickfix/variables/changeMutability/varAnnotationParameter.kt"); + } + @TestMetadata("idea/testData/quickfix/variables/changeMutability/canBeVal") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 15aaf3a0789b175e80da77edcfefee92d79bb7c0 Mon Sep 17 00:00:00 2001 From: SokolovaMaria Date: Thu, 11 Feb 2021 12:24:28 +0300 Subject: [PATCH 166/368] Copy typeParameters from original declaration to the exportedDefaultStubFun before substitution of type parameters --- .../kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt index a991bb954ee..05f73e148b2 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt @@ -107,9 +107,9 @@ class ExportedDefaultParameterStub(val context: JsIrBackendContext) : Declaratio context.additionalExportedDeclarations.add(exportedDefaultStubFun) - exportedDefaultStubFun.returnType = declaration.returnType.remapTypeParameters(declaration, exportedDefaultStubFun) exportedDefaultStubFun.parent = declaration.parent exportedDefaultStubFun.copyParameterDeclarationsFrom(declaration) + exportedDefaultStubFun.returnType = declaration.returnType.remapTypeParameters(declaration, exportedDefaultStubFun) exportedDefaultStubFun.valueParameters.forEach { it.defaultValue = null } declaration.origin = JsLoweredDeclarationOrigin.JS_SHADOWED_EXPORT From 0a72e164510f1697297189bfb728619d51a073c2 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Tue, 9 Feb 2021 21:34:03 +0100 Subject: [PATCH 167/368] FIR: transform DiagnosticBuilder DSL to an object To make diagnostics visible in symbol search in IJ --- .../generator/diagnostics/DiagnosticData.kt | 7 +- .../generator/diagnostics/DiagnosticGroup.kt | 56 +++++++++ .../generator/diagnostics/DiagnosticList.kt | 69 +++++++++++ .../diagnostics/DiagnosticListBuilder.kt | 112 ------------------ .../ErrorListDiagnosticListRenderer.kt | 11 +- .../diagnostics/FirDiagnosticsList.kt | 55 ++++----- .../fir/analysis/diagnostics/FirErrors.kt | 4 +- .../fir/generator/HLDiagnosticConverter.kt | 2 +- 8 files changed, 162 insertions(+), 154 deletions(-) create mode 100644 compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticGroup.kt create mode 100644 compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticList.kt delete mode 100644 compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticListBuilder.kt diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt index bc38ea0e3f8..280b6f124fc 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt @@ -15,7 +15,6 @@ data class DiagnosticData( val psiType: KType, val parameters: List, val positioningStrategy: PositioningStrategy, - val group: String?, ) data class DiagnosticParameter( @@ -55,8 +54,4 @@ enum class PositioningStrategy(private val strategy: String) { fun DiagnosticData.hasDefaultPositioningStrategy(): Boolean = - positioningStrategy == PositioningStrategy.DEFAULT - -data class DiagnosticList( - val diagnostics: List, -) \ No newline at end of file + positioningStrategy == PositioningStrategy.DEFAULT \ No newline at end of file diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticGroup.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticGroup.kt new file mode 100644 index 00000000000..055b34a878b --- /dev/null +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticGroup.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2021 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.fir.checkers.generator.diagnostics + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.diagnostics.Severity +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.PrivateForInline +import kotlin.properties.PropertyDelegateProvider +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty +import kotlin.reflect.typeOf + +abstract class DiagnosticGroup @PrivateForInline constructor(val name: String) { + @Suppress("PropertyName") + @PrivateForInline + val _diagnostics = mutableListOf() + + @OptIn(PrivateForInline::class) + val diagnostics: List + get() = _diagnostics + + @OptIn(PrivateForInline::class) + inline fun error( + positioningStrategy: PositioningStrategy = PositioningStrategy.DEFAULT, + crossinline init: DiagnosticBuilder.() -> Unit = {} + ) = diagnosticDelegateProvider(Severity.ERROR, positioningStrategy, init) + + + @OptIn(PrivateForInline::class) + inline fun warning( + positioningStrategy: PositioningStrategy = PositioningStrategy.DEFAULT, + crossinline init: DiagnosticBuilder.() -> Unit = {} + ) = diagnosticDelegateProvider(Severity.WARNING, positioningStrategy, init) + + @PrivateForInline + @OptIn(ExperimentalStdlibApi::class) + inline fun diagnosticDelegateProvider( + severity: Severity, + positioningStrategy: PositioningStrategy, + crossinline init: DiagnosticBuilder.() -> Unit = {} + ) = PropertyDelegateProvider> { _, property -> + val diagnostic = DiagnosticBuilder( + severity, + name = property.name, + sourceElementType = typeOf(), + psiType = typeOf

(), + positioningStrategy, + ).apply(init).build() + _diagnostics += diagnostic + ReadOnlyProperty { _, _ -> diagnostic } + } +} \ No newline at end of file diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticList.kt new file mode 100644 index 00000000000..de70341f115 --- /dev/null +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticList.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2021 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.fir.checkers.generator.diagnostics + +import org.jetbrains.kotlin.diagnostics.Severity +import org.jetbrains.kotlin.fir.PrivateForInline +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty +import kotlin.reflect.KType +import kotlin.reflect.typeOf + +abstract class DiagnosticList { + @Suppress("PropertyName") + @PrivateForInline + val _groups = mutableListOf() + + @OptIn(PrivateForInline::class) + val groups: List + get() = _groups + + val allDiagnostics: List + get() = groups.flatMap { it.diagnostics } + + + @OptIn(PrivateForInline::class) + operator fun DiagnosticGroup.provideDelegate( + thisRef: DiagnosticList, + prop: KProperty<*> + ): ReadOnlyProperty { + val group = this + _groups += group + return ReadOnlyProperty { _, _ -> group } + } +} + +class DiagnosticBuilder( + private val severity: Severity, + private val name: String, + private val sourceElementType: KType, + private val psiType: KType, + private val positioningStrategy: PositioningStrategy, +) { + @PrivateForInline + val parameters = mutableListOf() + + @OptIn(PrivateForInline::class, ExperimentalStdlibApi::class) + inline fun parameter(name: String) { + if (parameters.size == 3) { + error("Diagnostic cannot have more than 3 parameters") + } + parameters += DiagnosticParameter( + name = name, + type = typeOf() + ) + } + + @OptIn(PrivateForInline::class) + fun build() = DiagnosticData( + severity, + name, + sourceElementType, + psiType, + parameters, + positioningStrategy, + ) +} \ No newline at end of file diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticListBuilder.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticListBuilder.kt deleted file mode 100644 index f2396db44b6..00000000000 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticListBuilder.kt +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2010-2021 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.fir.checkers.generator.diagnostics - -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.diagnostics.Severity -import org.jetbrains.kotlin.fir.FirSourceElement -import org.jetbrains.kotlin.fir.PrivateForInline -import kotlin.properties.PropertyDelegateProvider -import kotlin.properties.ReadOnlyProperty -import kotlin.reflect.KProperty -import kotlin.reflect.KType -import kotlin.reflect.typeOf - -class DiagnosticListBuilder private constructor() { - @PrivateForInline - val diagnostics = mutableListOf() - - @PrivateForInline - var currentGroupName: String? = null - - @OptIn(PrivateForInline::class) - inline fun group(groupName: String, inner: () -> Unit) { - if (currentGroupName != null) { - error("Groups can not be nested ") - } - currentGroupName = groupName - inner() - currentGroupName = null - } - - @OptIn(PrivateForInline::class) - inline fun error( - positioningStrategy: PositioningStrategy = PositioningStrategy.DEFAULT, - crossinline init: DiagnosticBuilder.() -> Unit = {} - ) = diagnosticDelegateProvider(Severity.ERROR, positioningStrategy, init) - - - @OptIn(PrivateForInline::class) - inline fun warning( - positioningStrategy: PositioningStrategy = PositioningStrategy.DEFAULT, - crossinline init: DiagnosticBuilder.() -> Unit = {} - ) = diagnosticDelegateProvider(Severity.WARNING, positioningStrategy, init) - - @PrivateForInline - @OptIn(ExperimentalStdlibApi::class) - inline fun diagnosticDelegateProvider( - severity: Severity, - positioningStrategy: PositioningStrategy, - crossinline init: DiagnosticBuilder.() -> Unit = {} - ) = PropertyDelegateProvider { _, property -> - diagnostics += DiagnosticBuilder( - severity, - name = property.name, - sourceElementType = typeOf(), - psiType = typeOf

(), - positioningStrategy, - group = currentGroupName, - ).apply(init).build() - AlwaysReturningUnitPropertyDelegate - } - - @PrivateForInline - object AlwaysReturningUnitPropertyDelegate : ReadOnlyProperty { - override fun getValue(thisRef: Any?, property: KProperty<*>) = Unit - } - - @OptIn(PrivateForInline::class) - private fun build() = DiagnosticList(diagnostics) - - companion object { - fun buildDiagnosticList(init: DiagnosticListBuilder.() -> Unit) = - DiagnosticListBuilder().apply(init).build() - } -} - -class DiagnosticBuilder( - private val severity: Severity, - private val name: String, - private val sourceElementType: KType, - private val psiType: KType, - private val positioningStrategy: PositioningStrategy, - private val group: String? -) { - @PrivateForInline - val parameters = mutableListOf() - - @OptIn(PrivateForInline::class, ExperimentalStdlibApi::class) - inline fun parameter(name: String) { - if (parameters.size == 3) { - error("Diagnostic cannot have more than 3 parameters") - } - parameters += DiagnosticParameter( - name = name, - type = typeOf() - ) - } - - @OptIn(PrivateForInline::class) - fun build() = DiagnosticData( - severity, - name, - sourceElementType, - psiType, - parameters, - positioningStrategy, - group - ) -} \ No newline at end of file diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/ErrorListDiagnosticListRenderer.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/ErrorListDiagnosticListRenderer.kt index 2d8543a7c08..dc031991214 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/ErrorListDiagnosticListRenderer.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/ErrorListDiagnosticListRenderer.kt @@ -33,19 +33,18 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() { private fun SmartPrinter.printErrorsObject(diagnosticList: DiagnosticList) { inBracketsWithIndent("object FirErrors") { - val groups = diagnosticList.diagnostics.groupBy { it.group } - for ((group, diagnostics) in groups) { - printDiagnosticGroup(group, diagnostics) + for (group in diagnosticList.groups) { + printDiagnosticGroup(group.name, group.diagnostics) println() } } } private fun SmartPrinter.printDiagnosticGroup( - group: String?, + group: String, diagnostics: List ) { - println("// ${group ?: "NO GROUP"}") + println("// $group") for (it in diagnostics) { printDiagnostic(it) } @@ -110,7 +109,7 @@ object ErrorListDiagnosticListRenderer : DiagnosticListRenderer() { @OptIn(ExperimentalStdlibApi::class) private fun collectImports(diagnosticList: DiagnosticList): Collection = buildSet { - diagnosticList.diagnostics.forEach { diagnostic -> + diagnosticList.allDiagnostics.forEach { diagnostic -> for (typeArgument in diagnostic.getAllTypeArguments()) { typeArgument.collectClassNamesTo(this) } diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 139fa2ae2a9..e3f4e665edf 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -25,15 +25,15 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* -@Suppress("UNUSED_VARIABLE", "LocalVariableName") +@Suppress("UNUSED_VARIABLE", "LocalVariableName", "ClassName", "unused") @OptIn(PrivateForInline::class) -val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { - group("Miscellaneous") { +object DIAGNOSTICS_LIST : DiagnosticList() { + val Miscellaneous by object : DiagnosticGroup("Miscellaneous") { val SYNTAX by error() val OTHER_ERROR by error() } - group("General syntax") { + val GENERAL_SYNTAX by object : DiagnosticGroup("General syntax") { val ILLEGAL_CONST_EXPRESSION by error() val ILLEGAL_UNDERSCORE by error() val EXPRESSION_REQUIRED by error() @@ -44,7 +44,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val DELEGATION_IN_INTERFACE by error() } - group("Unresolved") { + val UNRESOLVED by object : DiagnosticGroup("Unresolved") { val HIDDEN by error { parameter>("hidden") } @@ -59,7 +59,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val NO_THIS by error() } - group("Super") { + val SUPER by object : DiagnosticGroup("Super") { val SUPER_IS_NOT_AN_EXPRESSION by error() val SUPER_NOT_AVAILABLE by error() val ABSTRACT_SUPER_CALL by error() @@ -68,7 +68,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { } } - group("Supertypes") { + val SUPERTYPES by object : DiagnosticGroup("Supertypes") { val TYPE_PARAMETER_AS_SUPERTYPE by error() val ENUM_AS_SUPERTYPE by error() val RECURSION_IN_SUPERTYPES by error() @@ -84,7 +84,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val SEALED_SUPERTYPE_IN_LOCAL_CLASS by error() } - group(" Constructor problems") { + val CONSTRUCTOR_PROBLEMS by object : DiagnosticGroup("Constructor problems") { val CONSTRUCTOR_IN_OBJECT by error(PositioningStrategy.DECLARATION_SIGNATURE) val CONSTRUCTOR_IN_INTERFACE by error(PositioningStrategy.DECLARATION_SIGNATURE) val NON_PRIVATE_CONSTRUCTOR_IN_ENUM by error() @@ -98,7 +98,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val SEALED_CLASS_CONSTRUCTOR_CALL by error() } - group("Annotations") { + val ANNOTATIONS by object : DiagnosticGroup("Annotations") { val ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR by error() val ANNOTATION_ARGUMENT_MUST_BE_CONST by error() val ANNOTATION_ARGUMENT_MUST_BE_ENUM_CONST by error() @@ -116,7 +116,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val VAR_ANNOTATION_PARAMETER by error(PositioningStrategy.VAL_OR_VAR_NODE) } - group("Exposed visibility group") { + val EXPOSED_VISIBILITY by object : DiagnosticGroup("Exposed visibility") { val EXPOSED_TYPEALIAS_EXPANDED_TYPE by exposedVisibilityError(PositioningStrategy.DECLARATION_NAME) val EXPOSED_FUNCTION_RETURN_TYPE by exposedVisibilityError(PositioningStrategy.DECLARATION_NAME) @@ -128,7 +128,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val EXPOSED_TYPE_PARAMETER_BOUND by exposedVisibilityError() } - group("Modifiers") { + val MODIFIERS by object : DiagnosticGroup("Modifiers") { val INAPPLICABLE_INFIX_MODIFIER by error() val REPEATED_MODIFIER by error { parameter("modifier") @@ -148,7 +148,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val REDUNDANT_OPEN_IN_INTERFACE by warning(PositioningStrategy.OPEN_MODIFIER) } - group("Applicability") { + val APPLICABILITY by object : DiagnosticGroup("Applicability") { val NONE_APPLICABLE by error { parameter>>("candidates") } @@ -161,7 +161,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { } } - group("Ambiguity") { + val AMBIGUIRY by object : DiagnosticGroup("Ambiguity") { val AMBIGUITY by error { parameter>>("candidates") } @@ -170,7 +170,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { } } - group("Types & type parameters") { + val TYPES_AND_TYPE_PARAMETERS by object : DiagnosticGroup("Types & type parameters") { val TYPE_MISMATCH by error { parameter("expectedType") parameter("actualType") @@ -203,7 +203,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS by error(PositioningStrategy.DECLARATION_NAME) } - group("overrides") { + val OVERRIDES by object : DiagnosticGroup("overrides") { val NOTHING_TO_OVERRIDE by error(PositioningStrategy.OVERRIDE_MODIFIER) { parameter("declaration") } @@ -242,7 +242,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { } } - group("Redeclarations") { + val REDECLARATIONS by object : DiagnosticGroup("Redeclarations") { val MANY_COMPANION_OBJECTS by error() val CONFLICTING_OVERLOADS by error(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) { parameter>>("conflictingOverloads") @@ -253,7 +253,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val ANY_METHOD_IMPLEMENTED_IN_INTERFACE by error() } - group("Invalid local declarations") { + val INVALID_LOCAL_DECLARATIONS by object : DiagnosticGroup("Invalid local declarations") { val LOCAL_OBJECT_NOT_ALLOWED by error(PositioningStrategy.DECLARATION_NAME) { parameter("objectName") } @@ -262,7 +262,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { } } - group("Functions") { + val FUNCTIONS by object : DiagnosticGroup("Functions") { val ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS by error(PositioningStrategy.MODALITY_MODIFIER) { parameter("function") parameter("containingClass") // TODO use FirClass instead of FirMemberDeclaration @@ -288,7 +288,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val USELESS_VARARG_ON_PARAMETER by warning() } - group("Properties & accessors") { + val PROPERTIES_ANS_ACCESSORS by object : DiagnosticGroup("Properties & accessors") { val ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS by error(PositioningStrategy.MODALITY_MODIFIER) { parameter("property") parameter("containingClass") // TODO use FirClass instead of FirMemberDeclaration @@ -314,14 +314,15 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val EXPECTED_PRIVATE_DECLARATION by error(PositioningStrategy.VISIBILITY_MODIFIER) } - group("Multi-platform projects") { + val MPP_PROJECTS by object : DiagnosticGroup("Multi-platform projects") { val EXPECTED_DECLARATION_WITH_BODY by error(PositioningStrategy.DECLARATION_SIGNATURE) val EXPECTED_PROPERTY_INITIALIZER by error() + // TODO: need to cover `by` as well as delegate expression val EXPECTED_DELEGATED_PROPERTY by error() } - group("Destructuring declaration") { + val DESTRUCTING_DECLARATION by object : DiagnosticGroup("Destructuring declaration") { val INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION by error() val COMPONENT_FUNCTION_MISSING by error { parameter("missingFunctionName") @@ -339,7 +340,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { // TODO: val COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH by ... } - group("Control flow diagnostics") { + val CONTROL_FLOW by object : DiagnosticGroup("Control flow diagnostics") { val UNINITIALIZED_VARIABLE by error { parameter("variable") } @@ -354,7 +355,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { val WRONG_IMPLIES_CONDITION by warning() } - group("Nullability") { + val NULLABILITY by object : DiagnosticGroup("Nullability") { val UNSAFE_CALL by error(PositioningStrategy.DOT_BY_SELECTOR) { parameter("receiverType") } @@ -374,20 +375,20 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { // TODO: val UNEXPECTED_SAFE_CALL by ... } - group("When expressions") { + val WHNE_EXPRESSIONS by object : DiagnosticGroup("When expressions") { val NO_ELSE_IN_WHEN by error(PositioningStrategy.WHEN_EXPRESSION) { parameter>("missingWhenCases") } val INVALID_IF_AS_EXPRESSION by error(PositioningStrategy.IF_EXPRESSION) } - group("Function contracts") { + val FUNCTION_CONTRACTS by object : DiagnosticGroup("Function contracts") { val ERROR_IN_CONTRACT_DESCRIPTION by error { parameter("reason") } } - group("Extended checkers") { + val EXTENDED_CHECKERS by object : DiagnosticGroup("Extended checkers") { val REDUNDANT_VISIBILITY_MODIFIER by warning(PositioningStrategy.VISIBILITY_MODIFIER) val REDUNDANT_MODALITY_MODIFIER by warning(PositioningStrategy.MODALITY_MODIFIER) val REDUNDANT_RETURN_UNIT_TYPE by warning() @@ -407,7 +408,7 @@ val DIAGNOSTICS_LIST = DiagnosticListBuilder.buildDiagnosticList { } } -private inline fun DiagnosticListBuilder.exposedVisibilityError( +private inline fun DiagnosticGroup.exposedVisibilityError( positioningStrategy: PositioningStrategy = PositioningStrategy.DEFAULT ) = error(positioningStrategy) { parameter("elementVisibility") diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 6ef8930b030..e34c9481330 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -91,7 +91,7 @@ object FirErrors { val SEALED_SUPERTYPE by error0() val SEALED_SUPERTYPE_IN_LOCAL_CLASS by error0() - // Constructor problems + // Constructor problems val CONSTRUCTOR_IN_OBJECT by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) val CONSTRUCTOR_IN_INTERFACE by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) val NON_PRIVATE_CONSTRUCTOR_IN_ENUM by error0() @@ -119,7 +119,7 @@ object FirErrors { val NULLABLE_TYPE_OF_ANNOTATION_MEMBER by error0() val VAR_ANNOTATION_PARAMETER by error0(SourceElementPositioningStrategies.VAL_OR_VAR_NODE) - // Exposed visibility group + // Exposed visibility val EXPOSED_TYPEALIAS_EXPANDED_TYPE by error3(SourceElementPositioningStrategies.DECLARATION_NAME) val EXPOSED_FUNCTION_RETURN_TYPE by error3(SourceElementPositioningStrategies.DECLARATION_NAME) val EXPOSED_RECEIVER_TYPE by error3() diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLDiagnosticConverter.kt b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLDiagnosticConverter.kt index 96f9c01df21..e432dc1ae26 100644 --- a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLDiagnosticConverter.kt +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLDiagnosticConverter.kt @@ -35,7 +35,7 @@ import kotlin.reflect.full.isSubclassOf object HLDiagnosticConverter { fun convert(diagnosticList: DiagnosticList): HLDiagnosticList = - HLDiagnosticList(diagnosticList.diagnostics.map(::convertDiagnostic)) + HLDiagnosticList(diagnosticList.allDiagnostics.map(::convertDiagnostic)) private fun convertDiagnostic(diagnostic: DiagnosticData): HLDiagnostic = HLDiagnostic( From 592c285198b6e2bef653bc833b5e703bd59bddde Mon Sep 17 00:00:00 2001 From: Hung Nguyen Date: Tue, 2 Feb 2021 22:30:03 +0000 Subject: [PATCH 168/368] Kapt: Don't create KDocCommentKeeper when not needed Previously, even if `keepKdocComments=false`, we would still create the KDocCommentKeeper object unnecessarily. This commit makes sure we create the object only if `keepKdocComments=true`. Bug: Clean-up after commit e252171 for KT-43593 Test: Existing tests --- .../kotlin/kapt3/base/KaptContext.kt | 4 ++- .../stubs/ClassFileToSourceStubConverter.kt | 28 ++++++------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/plugins/kapt3/kapt3-base/src/org/jetbrains/kotlin/kapt3/base/KaptContext.kt b/plugins/kapt3/kapt3-base/src/org/jetbrains/kotlin/kapt3/base/KaptContext.kt index 5b8af760d28..264324babcb 100644 --- a/plugins/kapt3/kapt3-base/src/org/jetbrains/kotlin/kapt3/base/KaptContext.kt +++ b/plugins/kapt3/kapt3-base/src/org/jetbrains/kotlin/kapt3/base/KaptContext.kt @@ -150,7 +150,9 @@ open class KaptContext(val options: KaptOptions, val withJdk: Boolean, val logge } compiler = JavaCompiler.instance(context) as KaptJavaCompiler - compiler.keepComments = true + if (options.flags[KaptFlag.KEEP_KDOC_COMMENTS_IN_STUBS]) { + compiler.keepComments = true + } ClassReader.instance(context).saveParameterNames = true diff --git a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt index 3d363c91f3f..feddf55cbaa 100644 --- a/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt +++ b/plugins/kapt3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/stubs/ClassFileToSourceStubConverter.kt @@ -130,7 +130,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati private val signatureParser = SignatureParser(treeMaker) - private val kdocCommentKeeper = KDocCommentKeeper(kaptContext) + private val kdocCommentKeeper = if (keepKdocComments) KDocCommentKeeper(kaptContext) else null private val importsFromRoot by lazy(::collectImportsFromRootPackage) @@ -209,7 +209,9 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati val classes = JavacList.of(classDeclaration) val topLevel = treeMaker.TopLevelJava9Aware(packageClause, nonEmptyImports + classes) - topLevel.docComments = kdocCommentKeeper.getDocTable(topLevel) + if (kdocCommentKeeper != null) { + topLevel.docComments = kdocCommentKeeper.getDocTable(topLevel) + } KaptJavaFileObject(topLevel, classDeclaration).apply { topLevel.sourcefile = this @@ -440,11 +442,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati superTypes.superClass, superTypes.interfaces, enumValues + sortedFields + sortedMethods + nestedClasses - ).also { - if (keepKdocComments) { - it.keepKdocComments(clazz) - } - } + ).keepKdocCommentsIfNecessary(clazz) } private class MemberData(val name: String, val descriptor: String, val position: KotlinPosition?) @@ -734,11 +732,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati lineMappings.registerField(containingClass, field) val initializer = explicitInitializer ?: convertPropertyInitializer(containingClass, field) - return treeMaker.VarDef(modifiers, treeMaker.name(name), typeExpression, initializer).also { - if (keepKdocComments) { - it.keepKdocComments(field) - } - } + return treeMaker.VarDef(modifiers, treeMaker.name(name), typeExpression, initializer).keepKdocCommentsIfNecessary(field) } private fun convertPropertyInitializer(containingClass: ClassNode, field: FieldNode): JCExpression? { @@ -986,11 +980,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati modifiers, treeMaker.name(name), returnType, genericSignature.typeParameters, genericSignature.parameterTypes, genericSignature.exceptionTypes, body, defaultValue - ).keepSignature(lineMappings, method).also { - if (keepKdocComments) { - it.keepKdocComments(method) - } - } + ).keepSignature(lineMappings, method).keepKdocCommentsIfNecessary(method) } private fun isIgnored(annotations: List?): Boolean { @@ -1455,8 +1445,8 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati else -> null } - private fun T.keepKdocComments(node: Any): T { - kdocCommentKeeper.saveKDocComment(this, node) + private fun T.keepKdocCommentsIfNecessary(node: Any): T { + kdocCommentKeeper?.saveKDocComment(this, node) return this } From 291ed4a38a5793fd12e05d47fe623fbb34bf088c Mon Sep 17 00:00:00 2001 From: pyos Date: Wed, 10 Feb 2021 16:26:43 +0100 Subject: [PATCH 169/368] FIR: handle typealiases during conflict resolution --- .../fir/resolve/calls/AbstractConeCallConflictResolver.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt index f3f700736b5..3504b0bd341 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt @@ -104,6 +104,7 @@ abstract class AbstractConeCallConflictResolver( is FirConstructor -> createFlatSignature(call, declaration) is FirVariable<*> -> createFlatSignature(call, declaration) is FirClass<*> -> createFlatSignature(call, declaration) + is FirTypeAlias -> createFlatSignature(call, declaration) else -> error("Not supported: $declaration") } } @@ -163,10 +164,10 @@ abstract class AbstractConeCallConflictResolver( ?: call.argumentMapping?.map { it.value.argumentType() }.orEmpty()) } - private fun createFlatSignature(call: Candidate, klass: FirClass<*>): FlatSignature { + private fun createFlatSignature(call: Candidate, klass: FirClassLikeDeclaration<*>): FlatSignature { return FlatSignature( call, - (klass as? FirRegularClass)?.typeParameters?.map { it.symbol.toLookupTag() }.orEmpty(), + (klass as? FirTypeParameterRefsOwner)?.typeParameters?.map { it.symbol.toLookupTag() }.orEmpty(), valueParameterTypes = emptyList(), hasExtensionReceiver = false, hasVarargs = false, From 2dc0404751cbd224373263c9972c322e6fec6750 Mon Sep 17 00:00:00 2001 From: pyos Date: Wed, 10 Feb 2021 16:45:35 +0100 Subject: [PATCH 170/368] FIR: prioritize visible imported classes during type resolution and produce an error on ambiguity. --- .../org/jetbrains/kotlin/fir/scopes/Scopes.kt | 35 +++-- .../scopes/impl/FirAbstractImportingScope.kt | 135 ++++++++++++------ .../impl/FirAbstractSimpleImportingScope.kt | 24 +--- .../impl/FirAbstractStarImportingScope.kt | 37 ++--- .../impl/FirDefaultStarImportingScope.kt | 3 +- .../impl/FirExplicitStarImportingScope.kt | 5 +- .../imports/AllUnderImportsAmbiguity.fir.kt | 17 --- .../tests/imports/AllUnderImportsAmbiguity.kt | 1 + .../imports/ExplicitImportsAmbiguity.fir.kt | 2 +- .../JavaPackageLocalClassNotImported.fir.kt | 12 -- .../JavaPackageLocalClassNotImported.kt | 1 + .../tests/imports/NestedClassClash.fir.kt | 8 +- .../PackageLocalClassNotImported.fir.kt | 17 --- .../imports/PackageLocalClassNotImported.kt | 1 + .../imports/PrivateClassNotImported.fir.kt | 21 --- .../tests/imports/PrivateClassNotImported.kt | 1 + .../imports/AllUnderImportsAmbiguity.fir.kt | 2 +- .../deprecatedHiddenImportPriority.fir.kt | 4 +- .../deprecatedHiddenMultipleClasses.fir.kt | 4 +- .../sinceKotlinImportPriority.fir.kt | 4 +- .../sinceKotlinMultipleClasses.fir.kt | 4 +- ...ambiguateByFailedAbstractClassCheck.fir.kt | 4 +- .../p-5/neg/6.1.fir.kt | 2 +- .../p-5/neg/6.4.fir.kt | 6 +- .../p-5/pos/6.3.fir.kt | 8 +- 25 files changed, 160 insertions(+), 198 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/imports/AllUnderImportsAmbiguity.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/imports/JavaPackageLocalClassNotImported.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/imports/PackageLocalClassNotImported.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/imports/PrivateClassNotImported.fir.kt diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/Scopes.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/Scopes.kt index 74af476098c..8678c3a69bc 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/Scopes.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/Scopes.kt @@ -13,9 +13,11 @@ import org.jetbrains.kotlin.fir.scopes.impl.* import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.name.FqName -private object FirDefaultStarImportingScopeKey : ScopeSessionKey() -private object FirDefaultSimpleImportingScopeKey : ScopeSessionKey() -private object FileImportingScopeKey : ScopeSessionKey() +private val INVISIBLE_DEFAULT_STAR_IMPORT = scopeSessionKey() +private val VISIBLE_DEFAULT_STAR_IMPORT = scopeSessionKey() +private val DEFAULT_SIMPLE_IMPORT = scopeSessionKey() +private val PACKAGE_MEMBER = scopeSessionKey() +private val ALL_IMPORTS = scopeSessionKey() private class ListStorageFirScope(val result: List) : FirScope() @@ -25,7 +27,7 @@ fun createImportingScopes( scopeSession: ScopeSession, useCaching: Boolean = true ): List = if (useCaching) { - scopeSession.getOrBuild(file, FileImportingScopeKey) { + scopeSession.getOrBuild(file, ALL_IMPORTS) { ListStorageFirScope(doCreateImportingScopes(file, session, scopeSession)) }.result } else { @@ -39,17 +41,26 @@ private fun doCreateImportingScopes( ): List { return listOf( // from low priority to high priority - scopeSession.getOrBuild(DefaultImportPriority.LOW, FirDefaultStarImportingScopeKey) { - FirDefaultStarImportingScope(session, scopeSession, priority = DefaultImportPriority.LOW) + scopeSession.getOrBuild(DefaultImportPriority.LOW, INVISIBLE_DEFAULT_STAR_IMPORT) { + FirDefaultStarImportingScope(session, scopeSession, FirImportingScopeFilter.INVISIBLE_CLASSES, DefaultImportPriority.LOW) }, - scopeSession.getOrBuild(DefaultImportPriority.HIGH, FirDefaultStarImportingScopeKey) { - FirDefaultStarImportingScope(session, scopeSession, priority = DefaultImportPriority.HIGH) + scopeSession.getOrBuild(DefaultImportPriority.HIGH, INVISIBLE_DEFAULT_STAR_IMPORT) { + FirDefaultStarImportingScope(session, scopeSession, FirImportingScopeFilter.INVISIBLE_CLASSES, DefaultImportPriority.HIGH) }, - FirExplicitStarImportingScope(file.imports, session, scopeSession), - scopeSession.getOrBuild(DefaultImportPriority.LOW, FirDefaultSimpleImportingScopeKey) { + FirExplicitStarImportingScope(file.imports, session, scopeSession, FirImportingScopeFilter.INVISIBLE_CLASSES), + // TODO: invisible classes from current package should go before this point + scopeSession.getOrBuild(DefaultImportPriority.LOW, VISIBLE_DEFAULT_STAR_IMPORT) { + FirDefaultStarImportingScope(session, scopeSession, FirImportingScopeFilter.MEMBERS_AND_VISIBLE_CLASSES, DefaultImportPriority.LOW) + }, + scopeSession.getOrBuild(DefaultImportPriority.HIGH, VISIBLE_DEFAULT_STAR_IMPORT) { + FirDefaultStarImportingScope(session, scopeSession, FirImportingScopeFilter.MEMBERS_AND_VISIBLE_CLASSES, DefaultImportPriority.HIGH) + }, + FirExplicitStarImportingScope(file.imports, session, scopeSession, FirImportingScopeFilter.MEMBERS_AND_VISIBLE_CLASSES), + + scopeSession.getOrBuild(DefaultImportPriority.LOW, DEFAULT_SIMPLE_IMPORT) { FirDefaultSimpleImportingScope(session, scopeSession, priority = DefaultImportPriority.LOW) }, - scopeSession.getOrBuild(DefaultImportPriority.HIGH, FirDefaultSimpleImportingScopeKey) { + scopeSession.getOrBuild(DefaultImportPriority.HIGH, DEFAULT_SIMPLE_IMPORT) { FirDefaultSimpleImportingScope(session, scopeSession, priority = DefaultImportPriority.HIGH) }, scopeSession.getOrBuild(file.packageFqName, PACKAGE_MEMBER) { @@ -60,8 +71,6 @@ private fun doCreateImportingScopes( ) } -private val PACKAGE_MEMBER = scopeSessionKey() - fun ConeClassLikeLookupTag.getNestedClassifierScope(session: FirSession, scopeSession: ScopeSession): FirScope? { val klass = toSymbol(session)?.fir as? FirRegularClass ?: return null return klass.scopeProvider.getNestedClassifierScope(klass, session, scopeSession) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt index 1a4fbdd05ad..d5f524aa449 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt @@ -6,9 +6,12 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.declarations.expandedConeType +import org.jetbrains.kotlin.fir.moduleVisibilityChecker import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.transformers.ensureResolvedForCalls @@ -16,53 +19,89 @@ import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name +enum class FirImportingScopeFilter { + ALL, INVISIBLE_CLASSES, MEMBERS_AND_VISIBLE_CLASSES; + + fun check(symbol: FirClassLikeSymbol<*>, session: FirSession): Boolean { + if (this == ALL) return true + // TODO: also check DeprecationLevel.HIDDEN and required Kotlin version + val fir = symbol.fir as? FirMemberDeclaration ?: return false + val isVisible = when (fir.status.visibility) { + // When importing from the same module, status may be unknown because the status resolver depends on super types + // to determine visibility for functions, so it may not have finished yet. Since we only care about classes, + // though, "unknown" will always become public anyway. + Visibilities.Unknown -> true + Visibilities.Internal -> + symbol.fir.session == session || session.moduleVisibilityChecker?.isInFriendModule(fir) == true + // All non-`internal` visibilities are either even more restrictive (e.g. `private`) or must not + // be checked in imports (e.g. `protected` may be valid in some use sites). + else -> !fir.status.visibility.mustCheckInImports() + } + return isVisible == (this == MEMBERS_AND_VISIBLE_CLASSES) + } +} + abstract class FirAbstractImportingScope( session: FirSession, protected val scopeSession: ScopeSession, + protected val filter: FirImportingScopeFilter, lookupInFir: Boolean ) : FirAbstractProviderBasedScope(session, lookupInFir) { - - private fun getStaticsScope(symbol: FirClassLikeSymbol<*>): FirScope? { - if (symbol is FirTypeAliasSymbol) { - val expansionSymbol = symbol.fir.expandedConeType?.lookupTag?.toSymbol(session) - if (expansionSymbol != null) { - return getStaticsScope(expansionSymbol) - } - } else { - val firClass = (symbol as FirClassSymbol<*>).fir - - return if (firClass.classKind == ClassKind.OBJECT) { - FirObjectImportedCallableScope( - symbol.classId, - firClass.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = false) - ) - } else { - firClass.scopeProvider.getStaticScope(firClass, session, scopeSession) - } + private val FirClassLikeSymbol<*>.fullyExpandedSymbol: FirClassSymbol<*>? + get() = when (this) { + is FirTypeAliasSymbol -> fir.expandedConeType?.lookupTag?.toSymbol(session)?.fullyExpandedSymbol + is FirClassSymbol<*> -> this } - return null + private fun FirClassSymbol<*>.getStaticsScope(): FirScope? = + if (fir.classKind == ClassKind.OBJECT) { + FirObjectImportedCallableScope( + classId, fir.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = false) + ) + } else { + fir.scopeProvider.getStaticScope(fir, session, scopeSession) + } + fun getStaticsScope(classId: ClassId): FirScope? = + provider.getClassLikeSymbolByFqName(classId)?.fullyExpandedSymbol?.getStaticsScope() + + protected fun findSingleClassifierSymbolByName(name: Name?, imports: List): FirClassLikeSymbol<*>? { + var result: FirClassLikeSymbol<*>? = null + for (import in imports) { + val importedName = name ?: import.importedName ?: continue + val classId = import.resolvedClassId?.createNestedClassId(importedName) + ?: ClassId.topLevel(import.packageFqName.child(importedName)) + val symbol = provider.getClassLikeSymbolByFqName(classId) ?: continue + if (!filter.check(symbol, session)) continue + result = when { + result == null || result == symbol -> symbol + // Importing multiple versions of the same type is normally an ambiguity, but in the case of `kotlin.Throws`, + // it should take precedence over platform-specific variants. This is lifted directly from `LazyImportScope` + // from the old backend; most likely `Throws` predates expect-actual, and this is a backwards compatibility hack. + // TODO: remove redundant versions of `Throws` from the standard library + result.classId.isJvmOrNativeThrows && symbol.classId.isCommonThrows -> symbol + result.classId.isCommonThrows && symbol.classId.isJvmOrNativeThrows -> result + // TODO: if there is an ambiguity at this scope, further scopes should not be checked. + // Doing otherwise causes KT-39073. Also, returning null here instead of an error symbol + // or something produces poor quality diagnostics ("unresolved name" rather than "ambiguity"). + else -> return null + } + } + return result } - fun getStaticsScope(classId: ClassId): FirScope? { - val symbol = provider.getClassLikeSymbolByFqName(classId) ?: return null - return getStaticsScope(symbol) - } - - protected inline fun processFunctionsByNameWithImport( - name: Name, - import: FirResolvedImport, - crossinline processor: (FirNamedFunctionSymbol) -> Unit - ) { - import.resolvedClassId?.let { classId -> - getStaticsScope(classId)?.processFunctionsByName(name) { processor(it) } - } ?: run { - if (name.isSpecial || name.identifier.isNotEmpty()) { - val symbols = provider.getTopLevelFunctionSymbols(import.packageFqName, name) - for (symbol in symbols) { + protected fun processFunctionsByName(name: Name?, imports: List, processor: (FirNamedFunctionSymbol) -> Unit) { + if (filter == FirImportingScopeFilter.INVISIBLE_CLASSES) return + for (import in imports) { + val importedName = name ?: import.importedName ?: continue + val staticsScope = import.resolvedClassId?.let(::getStaticsScope) + if (staticsScope != null) { + staticsScope.processFunctionsByName(importedName, processor) + } else if (importedName.isSpecial || importedName.identifier.isNotEmpty()) { + for (symbol in provider.getTopLevelFunctionSymbols(import.packageFqName, importedName)) { symbol.ensureResolvedForCalls(session) processor(symbol) } @@ -70,17 +109,15 @@ abstract class FirAbstractImportingScope( } } - protected inline fun processPropertiesByNameWithImport( - name: Name, - import: FirResolvedImport, - crossinline processor: (FirVariableSymbol<*>) -> Unit - ) { - import.resolvedClassId?.let { classId -> - getStaticsScope(classId)?.processPropertiesByName(name) { processor(it) } - } ?: run { - if (name.isSpecial || name.identifier.isNotEmpty()) { - val symbols = provider.getTopLevelPropertySymbols(import.packageFqName, name) - for (symbol in symbols) { + protected fun processPropertiesByName(name: Name?, imports: List, processor: (FirVariableSymbol<*>) -> Unit) { + if (filter == FirImportingScopeFilter.INVISIBLE_CLASSES) return + for (import in imports) { + val importedName = name ?: import.importedName ?: continue + val staticsScope = import.resolvedClassId?.let(::getStaticsScope) + if (staticsScope != null) { + staticsScope.processPropertiesByName(importedName, processor) + } else if (importedName.isSpecial || importedName.identifier.isNotEmpty()) { + for (symbol in provider.getTopLevelPropertySymbols(import.packageFqName, importedName)) { symbol.ensureResolvedForCalls(session) processor(symbol) } @@ -88,3 +125,9 @@ abstract class FirAbstractImportingScope( } } } + +private val ClassId.isJvmOrNativeThrows: Boolean + get() = asSingleFqName() == FqName("kotlin.jvm.Throws") || asSingleFqName() == FqName("kotlin.native.Throws") + +private val ClassId.isCommonThrows: Boolean + get() = asSingleFqName() == FqName("kotlin.Throws") diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt index 9091f302220..a770f94bb3b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractSimpleImportingScope.kt @@ -8,47 +8,33 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.resolve.ScopeSession -import org.jetbrains.kotlin.fir.resolve.symbolProvider import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol -import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name abstract class FirAbstractSimpleImportingScope( session: FirSession, scopeSession: ScopeSession -) : FirAbstractImportingScope(session, scopeSession, lookupInFir = true) { +) : FirAbstractImportingScope(session, scopeSession, FirImportingScopeFilter.ALL, lookupInFir = true) { // TODO try to hide this abstract val simpleImports: Map> override fun processClassifiersByNameWithSubstitution(name: Name, processor: (FirClassifierSymbol<*>, ConeSubstitutor) -> Unit) { val imports = simpleImports[name] ?: return - if (imports.isEmpty()) return - val provider = session.symbolProvider - for (import in imports) { - val importedName = import.importedName ?: continue - val classId = - import.resolvedClassId?.createNestedClassId(importedName) - ?: ClassId.topLevel(import.packageFqName.child(importedName)) - val symbol = provider.getClassLikeSymbolByFqName(classId) ?: continue - processor(symbol, ConeSubstitutor.Empty) - } + val symbol = findSingleClassifierSymbolByName(null, imports) ?: return + processor(symbol, ConeSubstitutor.Empty) } override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) { val imports = simpleImports[name] ?: return - for (import in imports) { - processFunctionsByNameWithImport(import.importedName!!, import, processor) - } + processFunctionsByName(null, imports, processor) } override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { val imports = simpleImports[name] ?: return - for (import in imports) { - processPropertiesByNameWithImport(import.importedName!!, import, processor) - } + processPropertiesByName(null, imports, processor) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt index 601a6d39d51..1dcc48d1696 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractStarImportingScope.kt @@ -12,14 +12,14 @@ import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol -import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name abstract class FirAbstractStarImportingScope( session: FirSession, scopeSession: ScopeSession, - lookupInFir: Boolean = true -) : FirAbstractImportingScope(session, scopeSession, lookupInFir) { + filter: FirImportingScopeFilter, + lookupInFir: Boolean +) : FirAbstractImportingScope(session, scopeSession, filter, lookupInFir) { // TODO try to hide this abstract val starImports: List @@ -27,35 +27,20 @@ abstract class FirAbstractStarImportingScope( private val absentClassifierNames = mutableSetOf() override fun processClassifiersByNameWithSubstitution(name: Name, processor: (FirClassifierSymbol<*>, ConeSubstitutor) -> Unit) { - if (starImports.isEmpty() || name in absentClassifierNames) { + if ((!name.isSpecial && name.identifier.isEmpty()) || starImports.isEmpty() || name in absentClassifierNames) { return } - var empty = true - for (import in starImports) { - val relativeClassName = import.relativeClassName - val classId = when { - !name.isSpecial && name.identifier.isEmpty() -> return - relativeClassName == null -> ClassId(import.packageFqName, name) - else -> ClassId(import.packageFqName, relativeClassName.child(name), false) - } - val symbol = provider.getClassLikeSymbolByFqName(classId) ?: continue - empty = false + val symbol = findSingleClassifierSymbolByName(name, starImports) + if (symbol != null) { processor(symbol, ConeSubstitutor.Empty) - } - if (empty) { + } else { absentClassifierNames += name } } - override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) { - for (import in starImports) { - processFunctionsByNameWithImport(name, import, processor) - } - } + override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) = + processFunctionsByName(name, starImports, processor) - override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { - for (import in starImports) { - processPropertiesByNameWithImport(name, import, processor) - } - } + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) = + processPropertiesByName(name, starImports, processor) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt index 8fda4a031b2..98560e9ad6e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt @@ -17,8 +17,9 @@ import org.jetbrains.kotlin.name.Name class FirDefaultStarImportingScope( session: FirSession, scopeSession: ScopeSession, + filter: FirImportingScopeFilter, priority: DefaultImportPriority -) : FirAbstractStarImportingScope(session, scopeSession, lookupInFir = false) { +) : FirAbstractStarImportingScope(session, scopeSession, filter, lookupInFir = false) { // TODO: put languageVersionSettings into FirSession? override val starImports = run { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirExplicitStarImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirExplicitStarImportingScope.kt index a76bb479743..042fcac1400 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirExplicitStarImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirExplicitStarImportingScope.kt @@ -13,7 +13,8 @@ import org.jetbrains.kotlin.fir.resolve.ScopeSession class FirExplicitStarImportingScope( imports: List, session: FirSession, - scopeSession: ScopeSession -) : FirAbstractStarImportingScope(session, scopeSession) { + scopeSession: ScopeSession, + filter: FirImportingScopeFilter +) : FirAbstractStarImportingScope(session, scopeSession, filter, lookupInFir = true) { override val starImports = imports.filterIsInstance().filter { it.isAllUnder } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/imports/AllUnderImportsAmbiguity.fir.kt b/compiler/testData/diagnostics/tests/imports/AllUnderImportsAmbiguity.fir.kt deleted file mode 100644 index 3e478bc5576..00000000000 --- a/compiler/testData/diagnostics/tests/imports/AllUnderImportsAmbiguity.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ -// FILE: a.kt -package a - -class X - -// FILE: b.kt -package b - -class X - -// FILE: c.kt -package c - -import a.* -import b.* - -class Y : X \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/imports/AllUnderImportsAmbiguity.kt b/compiler/testData/diagnostics/tests/imports/AllUnderImportsAmbiguity.kt index 2e7741bb479..55afdb2760e 100644 --- a/compiler/testData/diagnostics/tests/imports/AllUnderImportsAmbiguity.kt +++ b/compiler/testData/diagnostics/tests/imports/AllUnderImportsAmbiguity.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: a.kt package a diff --git a/compiler/testData/diagnostics/tests/imports/ExplicitImportsAmbiguity.fir.kt b/compiler/testData/diagnostics/tests/imports/ExplicitImportsAmbiguity.fir.kt index 905fd270bb9..531567ef13f 100644 --- a/compiler/testData/diagnostics/tests/imports/ExplicitImportsAmbiguity.fir.kt +++ b/compiler/testData/diagnostics/tests/imports/ExplicitImportsAmbiguity.fir.kt @@ -14,4 +14,4 @@ package c import a.X import b.X -class Y : X \ No newline at end of file +class Y : X \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/imports/JavaPackageLocalClassNotImported.fir.kt b/compiler/testData/diagnostics/tests/imports/JavaPackageLocalClassNotImported.fir.kt deleted file mode 100644 index db191bd4cda..00000000000 --- a/compiler/testData/diagnostics/tests/imports/JavaPackageLocalClassNotImported.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -// FILE: File.kt -package pack - -public open class InetAddressImpl - -// FILE: Main.kt -package a - -import java.net.* // should not import java.net.InetAddressImpl because it's package local -import pack.* - -class X : InetAddressImpl() // should resolve to our pack.InetAddressImpl diff --git a/compiler/testData/diagnostics/tests/imports/JavaPackageLocalClassNotImported.kt b/compiler/testData/diagnostics/tests/imports/JavaPackageLocalClassNotImported.kt index 2f5ae2cce98..aa8f07b7bfc 100644 --- a/compiler/testData/diagnostics/tests/imports/JavaPackageLocalClassNotImported.kt +++ b/compiler/testData/diagnostics/tests/imports/JavaPackageLocalClassNotImported.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: File.kt package pack diff --git a/compiler/testData/diagnostics/tests/imports/NestedClassClash.fir.kt b/compiler/testData/diagnostics/tests/imports/NestedClassClash.fir.kt index 520a6fd70bc..d46d8dd0798 100644 --- a/compiler/testData/diagnostics/tests/imports/NestedClassClash.fir.kt +++ b/compiler/testData/diagnostics/tests/imports/NestedClassClash.fir.kt @@ -17,8 +17,8 @@ class D { import a.A.B import a.D.B -fun test(b: B) { - B() +fun test(b: B) { + B() } // FILE: d.kt @@ -26,6 +26,6 @@ import a.A.* import a.D.* // todo ambiguvity here -fun test2(b: B) { - B() +fun test2(b: B) { + B() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/imports/PackageLocalClassNotImported.fir.kt b/compiler/testData/diagnostics/tests/imports/PackageLocalClassNotImported.fir.kt deleted file mode 100644 index c3cc649331a..00000000000 --- a/compiler/testData/diagnostics/tests/imports/PackageLocalClassNotImported.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ -// FILE: File1.kt -package pack1 - -private class SomeClass - -// FILE: File2.kt -package pack2 - -public open class SomeClass - -// FILE: Main.kt -package a - -import pack1.* -import pack2.* - -class X : SomeClass() diff --git a/compiler/testData/diagnostics/tests/imports/PackageLocalClassNotImported.kt b/compiler/testData/diagnostics/tests/imports/PackageLocalClassNotImported.kt index 0be2c0005b1..252057e5647 100644 --- a/compiler/testData/diagnostics/tests/imports/PackageLocalClassNotImported.kt +++ b/compiler/testData/diagnostics/tests/imports/PackageLocalClassNotImported.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: File1.kt package pack1 diff --git a/compiler/testData/diagnostics/tests/imports/PrivateClassNotImported.fir.kt b/compiler/testData/diagnostics/tests/imports/PrivateClassNotImported.fir.kt deleted file mode 100644 index f522cf7c968..00000000000 --- a/compiler/testData/diagnostics/tests/imports/PrivateClassNotImported.fir.kt +++ /dev/null @@ -1,21 +0,0 @@ -// FILE: File1.kt -package pack1 - -public class SomeClass { - private class N - public open class PublicNested -} - -// FILE: File2.kt -package pack2 - -public open class N - -// FILE: Main.kt -package a - -import pack1.SomeClass.* -import pack2.* - -class X : N() -class Y : PublicNested() diff --git a/compiler/testData/diagnostics/tests/imports/PrivateClassNotImported.kt b/compiler/testData/diagnostics/tests/imports/PrivateClassNotImported.kt index 87a565d7880..336f2ba3760 100644 --- a/compiler/testData/diagnostics/tests/imports/PrivateClassNotImported.kt +++ b/compiler/testData/diagnostics/tests/imports/PrivateClassNotImported.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: File1.kt package pack1 diff --git a/compiler/testData/diagnostics/tests/javac/imports/AllUnderImportsAmbiguity.fir.kt b/compiler/testData/diagnostics/tests/javac/imports/AllUnderImportsAmbiguity.fir.kt index 895ab3a9db4..8968a947d85 100644 --- a/compiler/testData/diagnostics/tests/javac/imports/AllUnderImportsAmbiguity.fir.kt +++ b/compiler/testData/diagnostics/tests/javac/imports/AllUnderImportsAmbiguity.fir.kt @@ -24,4 +24,4 @@ package c import a.* import b.* -fun test(): x = d().x() +fun test(): x = d().x() diff --git a/compiler/testData/diagnostics/tests/multimodule/hiddenClass/deprecatedHiddenImportPriority.fir.kt b/compiler/testData/diagnostics/tests/multimodule/hiddenClass/deprecatedHiddenImportPriority.fir.kt index b7dca29721c..12b57a58025 100644 --- a/compiler/testData/diagnostics/tests/multimodule/hiddenClass/deprecatedHiddenImportPriority.fir.kt +++ b/compiler/testData/diagnostics/tests/multimodule/hiddenClass/deprecatedHiddenImportPriority.fir.kt @@ -22,8 +22,8 @@ class A { import p1.* import p2.* -fun test(a: A) { - a.m1() +fun test(a: A) { + a.m1() a.m2() } diff --git a/compiler/testData/diagnostics/tests/multimodule/hiddenClass/deprecatedHiddenMultipleClasses.fir.kt b/compiler/testData/diagnostics/tests/multimodule/hiddenClass/deprecatedHiddenMultipleClasses.fir.kt index 2290396a108..ee132551250 100644 --- a/compiler/testData/diagnostics/tests/multimodule/hiddenClass/deprecatedHiddenMultipleClasses.fir.kt +++ b/compiler/testData/diagnostics/tests/multimodule/hiddenClass/deprecatedHiddenMultipleClasses.fir.kt @@ -39,8 +39,8 @@ import p1.* import p2.* import p3.* -fun test(a: A) { - a.v1 +fun test(a: A) { + a.v1 a.v2 a.v3 } diff --git a/compiler/testData/diagnostics/tests/multimodule/hiddenClass/sinceKotlinImportPriority.fir.kt b/compiler/testData/diagnostics/tests/multimodule/hiddenClass/sinceKotlinImportPriority.fir.kt index 0af9e1e0168..f0001d93574 100644 --- a/compiler/testData/diagnostics/tests/multimodule/hiddenClass/sinceKotlinImportPriority.fir.kt +++ b/compiler/testData/diagnostics/tests/multimodule/hiddenClass/sinceKotlinImportPriority.fir.kt @@ -23,8 +23,8 @@ class A { import p1.* import p2.* -fun test(a: A) { - a.m1() +fun test(a: A) { + a.m1() a.m2() } diff --git a/compiler/testData/diagnostics/tests/multimodule/hiddenClass/sinceKotlinMultipleClasses.fir.kt b/compiler/testData/diagnostics/tests/multimodule/hiddenClass/sinceKotlinMultipleClasses.fir.kt index 5979ec665c0..afa057415a8 100644 --- a/compiler/testData/diagnostics/tests/multimodule/hiddenClass/sinceKotlinMultipleClasses.fir.kt +++ b/compiler/testData/diagnostics/tests/multimodule/hiddenClass/sinceKotlinMultipleClasses.fir.kt @@ -40,8 +40,8 @@ import p1.* import p2.* import p3.* -fun test(a: A) { - a.v1 +fun test(a: A) { + a.v1 a.v2 a.v3 } diff --git a/compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.fir.kt b/compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.fir.kt index 65841f1af65..fc78bbf9fb8 100644 --- a/compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.fir.kt @@ -29,6 +29,6 @@ fun test() { Cls() take(Cls()) - Cls2() - take(Cls2()) + Cls2() + take(Cls2()) } diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/neg/6.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/neg/6.1.fir.kt index d37c5f79351..6ffc5a758cd 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/neg/6.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/neg/6.1.fir.kt @@ -57,7 +57,7 @@ import libCase4.b.* import kotlin.text.* fun case4() { - Regex("") + Regex("") } // FILE: Lib4.kt diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/neg/6.4.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/neg/6.4.fir.kt index 01968f15cee..f2b084bd2cb 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/neg/6.4.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/neg/6.4.fir.kt @@ -221,8 +221,8 @@ import libCase8.b.* import libCase8.c.* fun case8(){ - A() - A() + A() + A() } // FILE: Lib11.kt @@ -278,7 +278,7 @@ import libCase10.b.* import libCase10.c.* fun case10(){ - A() + A() } // FILE: Liba.kt diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/pos/6.3.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/pos/6.3.fir.kt index 6d34b9324b2..ec54c89b60e 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/pos/6.3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/call-without-an-explicit-receiver/p-5/pos/6.3.fir.kt @@ -15,7 +15,7 @@ import libCase1.* import kotlin.text.* fun case1() { - Regex("") + Regex("") } // FILE: Lib1.kt @@ -35,7 +35,7 @@ import lib1Case2.* import kotlin.text.* fun case2() { - Regex("") + Regex("") } // FILE: Lib2.kt @@ -68,7 +68,7 @@ import libCase3.* import kotlin.text.* fun case3() { - Regex("") + Regex("") } // FILE: Lib3.kt @@ -95,7 +95,7 @@ import lib1Case4.* import kotlin.text.* fun case4() { - Regex("") + Regex("") } // FILE: Lib4.kt From 940588a9bbac2a768c65596f4c996cb40af96a63 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 15 Feb 2021 15:50:11 +0300 Subject: [PATCH 171/368] FE: commonize throw-related annotation FQ names --- .../kotlin/codegen/FunctionCodegen.java | 4 ++-- .../scopes/impl/FirAbstractImportingScope.kt | 8 +++++--- .../kotlin/resolve/annotations/ThrowUtil.kt | 17 +++++++++++++++++ .../jetbrains/kotlin/resolve/AnnotationUtil.kt | 8 -------- 4 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 compiler/frontend.common/src/org/jetbrains/kotlin/resolve/annotations/ThrowUtil.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index 5466c5c4d96..cb81bcabf03 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.load.java.SpecialBuiltinMembers; import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.*; -import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt; +import org.jetbrains.kotlin.resolve.annotations.ThrowUtilKt; import org.jetbrains.kotlin.resolve.calls.util.UnderscoreUtilKt; import org.jetbrains.kotlin.resolve.constants.ArrayValue; import org.jetbrains.kotlin.resolve.constants.ConstantValue; @@ -1105,7 +1105,7 @@ public class FunctionCodegen { return Collections.emptyList(); } - AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(AnnotationUtilKt.JVM_THROWS_ANNOTATION_FQ_NAME); + AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(ThrowUtilKt.JVM_THROWS_ANNOTATION_FQ_NAME); if (annotation == null) return Collections.emptyList(); Collection> values = annotation.getAllValueArguments().values(); diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt index d5f524aa449..2332520ddf4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt @@ -19,8 +19,10 @@ import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.resolve.annotations.JVM_THROWS_ANNOTATION_FQ_NAME +import org.jetbrains.kotlin.resolve.annotations.KOTLIN_NATIVE_THROWS_ANNOTATION_FQ_NAME +import org.jetbrains.kotlin.resolve.annotations.KOTLIN_THROWS_ANNOTATION_FQ_NAME enum class FirImportingScopeFilter { ALL, INVISIBLE_CLASSES, MEMBERS_AND_VISIBLE_CLASSES; @@ -127,7 +129,7 @@ abstract class FirAbstractImportingScope( } private val ClassId.isJvmOrNativeThrows: Boolean - get() = asSingleFqName() == FqName("kotlin.jvm.Throws") || asSingleFqName() == FqName("kotlin.native.Throws") + get() = asSingleFqName().let { it == JVM_THROWS_ANNOTATION_FQ_NAME || it == KOTLIN_NATIVE_THROWS_ANNOTATION_FQ_NAME } private val ClassId.isCommonThrows: Boolean - get() = asSingleFqName() == FqName("kotlin.Throws") + get() = asSingleFqName() == KOTLIN_THROWS_ANNOTATION_FQ_NAME diff --git a/compiler/frontend.common/src/org/jetbrains/kotlin/resolve/annotations/ThrowUtil.kt b/compiler/frontend.common/src/org/jetbrains/kotlin/resolve/annotations/ThrowUtil.kt new file mode 100644 index 00000000000..8572604807d --- /dev/null +++ b/compiler/frontend.common/src/org/jetbrains/kotlin/resolve/annotations/ThrowUtil.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2021 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.resolve.annotations + +import org.jetbrains.kotlin.name.FqName + +// This annotation is declared here in frontend (as opposed to frontend.java) because it's used in AllUnderImportScope +// If you wish to add another JVM-related annotation and has/find utility methods, please proceed to jvmAnnotationUtil.kt +@JvmField +val JVM_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.Throws") + +val KOTLIN_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.Throws") + +val KOTLIN_NATIVE_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.native.Throws") diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt index d2d9fc0337c..bc17c9c215f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt @@ -43,11 +43,3 @@ fun AnnotationDescriptor.argumentValue(parameterName: String): ConstantValue<*>? ) val JVM_FIELD_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.JvmField") -// This annotation is declared here in frontend (as opposed to frontend.java) because it's used in AllUnderImportScope -// If you wish to add another JVM-related annotation and has/find utility methods, please proceed to jvmAnnotationUtil.kt -@JvmField -val JVM_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.Throws") - -val KOTLIN_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.Throws") - -val KOTLIN_NATIVE_THROWS_ANNOTATION_FQ_NAME = FqName("kotlin.native.Throws") From a8c23e1c3a02886fe9486651cc3ba9a1a1082906 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 16 Feb 2021 12:30:26 +0300 Subject: [PATCH 172/368] FirDefaultStarImportingScope: filter INVISIBLE_CLASSES properly --- .../kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt index 98560e9ad6e..2b97b05bd05 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirDefaultStarImportingScope.kt @@ -39,6 +39,7 @@ class FirDefaultStarImportingScope( } override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) { + if (filter == FirImportingScopeFilter.INVISIBLE_CLASSES) return if (name.isSpecial || name.identifier.isNotEmpty()) { for (import in starImports) { for (symbol in provider.getTopLevelFunctionSymbols(import.packageFqName, name)) { @@ -49,6 +50,7 @@ class FirDefaultStarImportingScope( } override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { + if (filter == FirImportingScopeFilter.INVISIBLE_CLASSES) return if (name.isSpecial || name.identifier.isNotEmpty()) { for (import in starImports) { for (symbol in provider.getTopLevelPropertySymbols(import.packageFqName, name)) { From 91581d6c1ad6355b7f652e89fcd0e0210cae8c2e Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Mon, 15 Feb 2021 21:28:59 +0100 Subject: [PATCH 173/368] Move KotlinBundle to frontend-independent module to use from IDEA FIR --- .../src/org/jetbrains/kotlin/idea/KotlinBundle.kt | 3 ++- .../src/org/jetbrains/kotlin/util/AbstractKotlinBundle.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) rename idea/{ => idea-frontend-independent}/src/org/jetbrains/kotlin/idea/KotlinBundle.kt (93%) rename idea/{ide-common => idea-frontend-independent}/src/org/jetbrains/kotlin/util/AbstractKotlinBundle.kt (86%) diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinBundle.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/KotlinBundle.kt similarity index 93% rename from idea/src/org/jetbrains/kotlin/idea/KotlinBundle.kt rename to idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/KotlinBundle.kt index 403794cc86e..5334054a295 100644 --- a/idea/src/org/jetbrains/kotlin/idea/KotlinBundle.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/KotlinBundle.kt @@ -1,7 +1,8 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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.idea import org.jetbrains.annotations.NonNls diff --git a/idea/ide-common/src/org/jetbrains/kotlin/util/AbstractKotlinBundle.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/util/AbstractKotlinBundle.kt similarity index 86% rename from idea/ide-common/src/org/jetbrains/kotlin/util/AbstractKotlinBundle.kt rename to idea/idea-frontend-independent/src/org/jetbrains/kotlin/util/AbstractKotlinBundle.kt index c54005698d5..dd3a7aa2af5 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/util/AbstractKotlinBundle.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/util/AbstractKotlinBundle.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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. */ From 05ff2b12923960374d79d0ffa4bda8195cd63c6c Mon Sep 17 00:00:00 2001 From: Mads Ager Date: Fri, 12 Feb 2021 12:45:48 +0100 Subject: [PATCH 174/368] [JVM_IR] Extend when to switch translation to deal with nested ors. FIR translates: ``` when (x) { 1, 2, 3 -> action else -> other_action } ``` to an IR structure with nested ors: ``` if ((x == 1 || x == 2) || (x == 3)) action else other_action ``` This change allows that to turn into switch instructions in the JVM backend. --- .../codegen/FirBytecodeTextTestGenerated.java | 6 ++++++ .../backend/jvm/codegen/SwitchGenerator.kt | 17 ++++++++++++++--- .../when/switchOptimizationDuplicates.kt | 1 - .../whenEnumOptimization/bigEnum.kt | 1 - .../whenEnumOptimization/duplicatingItems.kt | 1 - .../whenEnumOptimization/expression.kt | 1 - .../manyWhensWithinClass.kt | 1 - .../whenEnumOptimization/nullability.kt | 1 - .../bytecodeText/whenEnumOptimization/whenOr.kt | 11 +++++++++++ .../whenEnumOptimization/withoutElse.kt | 1 - .../whenStringOptimization/duplicatingItems.kt | 1 - .../whenStringOptimization/expression.kt | 1 - .../inlineStringConstInsideWhen.kt | 1 - .../whenStringOptimization/nullability.kt | 1 - .../whenStringOptimization/sameHashCode.kt | 1 - .../whenStringOptimization/statement.kt | 1 - .../codegen/BytecodeTextTestGenerated.java | 6 ++++++ .../codegen/IrBytecodeTextTestGenerated.java | 6 ++++++ 18 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 compiler/testData/codegen/bytecodeText/whenEnumOptimization/whenOr.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java index 8dc66fd9614..2c1a4d39e5c 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java @@ -5574,6 +5574,12 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/subjectAny.kt"); } + @Test + @TestMetadata("whenOr.kt") + public void testWhenOr() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/whenOr.kt"); + } + @Test @TestMetadata("withoutElse.kt") public void testWithoutElse() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/SwitchGenerator.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/SwitchGenerator.kt index c7daf2809d6..9b39d0dc7e7 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/SwitchGenerator.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/SwitchGenerator.kt @@ -237,11 +237,13 @@ class SwitchGenerator(private val expression: IrWhen, private val data: BlockInf // action // } // + // fir2ir lowers the same to an or sequence: + // + // if (((subject == a) || (subject == b)) || (subject = c)) action + // // @return true if the conditions are equality checks of constants. private fun matchConditions(condition: IrExpression): ArrayList? { - if (condition is IrCall) { - return arrayListOf(condition) - } else if (condition is IrWhen && condition.origin == IrStatementOrigin.WHEN_COMMA) { + if (condition is IrWhen && condition.origin == IrStatementOrigin.WHEN_COMMA) { assert(condition.type.isBoolean()) { "WHEN_COMMA should always be a Boolean: ${condition.dump()}" } val candidates = ArrayList() @@ -268,6 +270,15 @@ class SwitchGenerator(private val expression: IrWhen, private val data: BlockInf } return if (candidates.isNotEmpty()) candidates else return null + } else if (condition is IrCall && condition.symbol == codegen.context.irBuiltIns.ororSymbol) { + val candidates = ArrayList() + for (i in 0 until condition.valueArgumentsCount) { + val argument = condition.getValueArgument(i)!! + candidates += matchConditions(argument) ?: return null + } + return if (candidates.isNotEmpty()) candidates else return null + } else if (condition is IrCall) { + return arrayListOf(condition) } return null diff --git a/compiler/testData/codegen/bytecodeText/when/switchOptimizationDuplicates.kt b/compiler/testData/codegen/bytecodeText/when/switchOptimizationDuplicates.kt index 34f6596cb38..a6438315fb7 100644 --- a/compiler/testData/codegen/bytecodeText/when/switchOptimizationDuplicates.kt +++ b/compiler/testData/codegen/bytecodeText/when/switchOptimizationDuplicates.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun foo(x: Int): Int { return when (x) { 1, 1, 2 -> 1001 diff --git a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/bigEnum.kt b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/bigEnum.kt index 0af7d4df73c..230eae422bb 100644 --- a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/bigEnum.kt +++ b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/bigEnum.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR import kotlin.test.assertEquals enum class BigEnum { diff --git a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/duplicatingItems.kt b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/duplicatingItems.kt index a2131007dc3..87e9d97c05a 100644 --- a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/duplicatingItems.kt +++ b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/duplicatingItems.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR import kotlin.test.assertEquals enum class Season { diff --git a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/expression.kt b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/expression.kt index 39424a42746..a1c4bc676c5 100644 --- a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/expression.kt +++ b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/expression.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR import kotlin.test.assertEquals enum class Season { diff --git a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/manyWhensWithinClass.kt b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/manyWhensWithinClass.kt index 07dcac76ee5..34dad145a32 100644 --- a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/manyWhensWithinClass.kt +++ b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/manyWhensWithinClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR package abc.foo enum class Season { diff --git a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/nullability.kt b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/nullability.kt index 47dbc05e968..4a4a6cc6340 100644 --- a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/nullability.kt +++ b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/nullability.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR enum class Season { WINTER, SPRING, diff --git a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/whenOr.kt b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/whenOr.kt new file mode 100644 index 00000000000..7814ae5c799 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/whenOr.kt @@ -0,0 +1,11 @@ +// IGNORE_BACKEND: JVM + +fun test(x: Int): String { + when { + x == 1 || x == 3 || x == 5 -> "135" + x == 2 || x == 4 || x == 6 -> "246" + else -> "other" + } +} + +// 1 TABLESWITCH diff --git a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/withoutElse.kt b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/withoutElse.kt index c89597748a1..09e8377c0b4 100644 --- a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/withoutElse.kt +++ b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/withoutElse.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR import kotlin.test.assertEquals enum class Season { diff --git a/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItems.kt b/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItems.kt index 21d45ba9699..15a2ebde392 100644 --- a/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItems.kt +++ b/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItems.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR import kotlin.test.assertEquals fun foo(x : String) : String { diff --git a/compiler/testData/codegen/bytecodeText/whenStringOptimization/expression.kt b/compiler/testData/codegen/bytecodeText/whenStringOptimization/expression.kt index 083d03e5351..4831cfb6df9 100644 --- a/compiler/testData/codegen/bytecodeText/whenStringOptimization/expression.kt +++ b/compiler/testData/codegen/bytecodeText/whenStringOptimization/expression.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun foo(x : String) : String { return when (x) { "abc", "cde" -> "abc_cde" diff --git a/compiler/testData/codegen/bytecodeText/whenStringOptimization/inlineStringConstInsideWhen.kt b/compiler/testData/codegen/bytecodeText/whenStringOptimization/inlineStringConstInsideWhen.kt index d55753d04cc..8563b273642 100644 --- a/compiler/testData/codegen/bytecodeText/whenStringOptimization/inlineStringConstInsideWhen.kt +++ b/compiler/testData/codegen/bytecodeText/whenStringOptimization/inlineStringConstInsideWhen.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR const val y = "cde" fun foo(x : String) : String { diff --git a/compiler/testData/codegen/bytecodeText/whenStringOptimization/nullability.kt b/compiler/testData/codegen/bytecodeText/whenStringOptimization/nullability.kt index 3461ba0bb80..52905d3a900 100644 --- a/compiler/testData/codegen/bytecodeText/whenStringOptimization/nullability.kt +++ b/compiler/testData/codegen/bytecodeText/whenStringOptimization/nullability.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun foo1(x : String?) : String { when (x) { "abc", "cde" -> return "abc_cde" diff --git a/compiler/testData/codegen/bytecodeText/whenStringOptimization/sameHashCode.kt b/compiler/testData/codegen/bytecodeText/whenStringOptimization/sameHashCode.kt index 2f4e7a773b8..f5f0d55b265 100644 --- a/compiler/testData/codegen/bytecodeText/whenStringOptimization/sameHashCode.kt +++ b/compiler/testData/codegen/bytecodeText/whenStringOptimization/sameHashCode.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun foo(x : String) : String { assert("abz]".hashCode() == "aby|".hashCode()) diff --git a/compiler/testData/codegen/bytecodeText/whenStringOptimization/statement.kt b/compiler/testData/codegen/bytecodeText/whenStringOptimization/statement.kt index bf3aa834ba4..7e07e9961d7 100644 --- a/compiler/testData/codegen/bytecodeText/whenStringOptimization/statement.kt +++ b/compiler/testData/codegen/bytecodeText/whenStringOptimization/statement.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun foo1(x : String) : String { when (x) { "abc", "cde" -> return "abc_cde" diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java index 2f284b56585..ae3c56d5cfd 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java @@ -5442,6 +5442,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/subjectAny.kt"); } + @Test + @TestMetadata("whenOr.kt") + public void testWhenOr() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/whenOr.kt"); + } + @Test @TestMetadata("withoutElse.kt") public void testWithoutElse() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java index db61e2845a4..05696042ddd 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java @@ -5574,6 +5574,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/subjectAny.kt"); } + @Test + @TestMetadata("whenOr.kt") + public void testWhenOr() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/whenEnumOptimization/whenOr.kt"); + } + @Test @TestMetadata("withoutElse.kt") public void testWithoutElse() throws Exception { From ec41775d7e4e27ab31c5a96091ca4db3a8c6c12f Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Tue, 16 Feb 2021 11:48:09 +0300 Subject: [PATCH 175/368] [all-open] Fix formatting --- ...penDeclarationAttributeAltererExtension.kt | 14 +++---- .../allopen/allopen-cli/src/AllOpenPlugin.kt | 41 +++++++++++-------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt b/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt index 751e81f6ac2..a574db29d5c 100644 --- a/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt +++ b/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt @@ -23,10 +23,10 @@ import org.jetbrains.kotlin.extensions.AnnotationBasedExtension import org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtModifierListOwner -import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.psi.psiUtil.isPrivate class CliAllOpenDeclarationAttributeAltererExtension( - private val allOpenAnnotationFqNames: List + private val allOpenAnnotationFqNames: List ) : AbstractAllOpenDeclarationAttributeAltererExtension() { override fun getAnnotationFqNames(modifierListOwner: KtModifierListOwner?) = allOpenAnnotationFqNames } @@ -37,11 +37,11 @@ abstract class AbstractAllOpenDeclarationAttributeAltererExtension : Declaration } override fun refineDeclarationModality( - modifierListOwner: KtModifierListOwner, - declaration: DeclarationDescriptor?, - containingDeclaration: DeclarationDescriptor?, - currentModality: Modality, - isImplicitModality: Boolean + modifierListOwner: KtModifierListOwner, + declaration: DeclarationDescriptor?, + containingDeclaration: DeclarationDescriptor?, + currentModality: Modality, + isImplicitModality: Boolean ): Modality? { if (currentModality != Modality.FINAL) { return null diff --git a/plugins/allopen/allopen-cli/src/AllOpenPlugin.kt b/plugins/allopen/allopen-cli/src/AllOpenPlugin.kt index a8c8feb8a26..95be76ed97a 100644 --- a/plugins/allopen/allopen-cli/src/AllOpenPlugin.kt +++ b/plugins/allopen/allopen-cli/src/AllOpenPlugin.kt @@ -26,33 +26,38 @@ import org.jetbrains.kotlin.config.CompilerConfigurationKey import org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension object AllOpenConfigurationKeys { - val ANNOTATION: CompilerConfigurationKey> = - CompilerConfigurationKey.create("annotation qualified name") - + val ANNOTATION: CompilerConfigurationKey> = CompilerConfigurationKey.create("annotation qualified name") val PRESET: CompilerConfigurationKey> = CompilerConfigurationKey.create("annotation preset") } class AllOpenCommandLineProcessor : CommandLineProcessor { companion object { val SUPPORTED_PRESETS = mapOf( - "spring" to listOf( - "org.springframework.stereotype.Component", - "org.springframework.transaction.annotation.Transactional", - "org.springframework.scheduling.annotation.Async", - "org.springframework.cache.annotation.Cacheable", - "org.springframework.boot.test.context.SpringBootTest", - "org.springframework.validation.annotation.Validated"), - "quarkus" to listOf( - "javax.enterprise.context.ApplicationScoped", - "javax.enterprise.context.RequestScoped")) + "spring" to listOf( + "org.springframework.stereotype.Component", + "org.springframework.transaction.annotation.Transactional", + "org.springframework.scheduling.annotation.Async", + "org.springframework.cache.annotation.Cacheable", + "org.springframework.boot.test.context.SpringBootTest", + "org.springframework.validation.annotation.Validated" + ), + "quarkus" to listOf( + "javax.enterprise.context.ApplicationScoped", + "javax.enterprise.context.RequestScoped" + ) + ) - val ANNOTATION_OPTION = CliOption("annotation", "", "Annotation qualified names", - required = false, allowMultipleOccurrences = true) + val ANNOTATION_OPTION = CliOption( + "annotation", "", "Annotation qualified names", + required = false, allowMultipleOccurrences = true + ) - val PRESET_OPTION = CliOption("preset", "", "Preset name (${SUPPORTED_PRESETS.keys.joinToString()})", - required = false, allowMultipleOccurrences = true) + val PRESET_OPTION = CliOption( + "preset", "", "Preset name (${SUPPORTED_PRESETS.keys.joinToString()})", + required = false, allowMultipleOccurrences = true + ) - val PLUGIN_ID = "org.jetbrains.kotlin.allopen" + const val PLUGIN_ID = "org.jetbrains.kotlin.allopen" } override val pluginId = PLUGIN_ID From baeee8988ea6d8191c60a8d9f62c4f5f047b0315 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Tue, 16 Feb 2021 11:48:20 +0300 Subject: [PATCH 176/368] [all-open] Don't affect private declarations to change their modality to open --- .../src/AllOpenDeclarationAttributeAltererExtension.kt | 2 +- .../allopen-cli/testData/bytecodeListing/privateMembers.kt | 2 ++ .../allopen-cli/testData/bytecodeListing/privateMembers.txt | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt b/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt index a574db29d5c..88dfe826959 100644 --- a/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt +++ b/plugins/allopen/allopen-cli/src/AllOpenDeclarationAttributeAltererExtension.kt @@ -43,7 +43,7 @@ abstract class AbstractAllOpenDeclarationAttributeAltererExtension : Declaration currentModality: Modality, isImplicitModality: Boolean ): Modality? { - if (currentModality != Modality.FINAL) { + if (currentModality != Modality.FINAL || modifierListOwner.isPrivate()) { return null } diff --git a/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.kt b/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.kt index 33668e5fcbb..e22039a07b7 100644 --- a/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.kt +++ b/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.kt @@ -13,4 +13,6 @@ private class Test { internal fun internalMethod() {} internal val internalProp: String = "" + + private tailrec fun privateTailrecMethod() {} } \ No newline at end of file diff --git a/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.txt b/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.txt index 832296ab5da..f170409bd3e 100644 --- a/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.txt +++ b/plugins/allopen/allopen-cli/testData/bytecodeListing/privateMembers.txt @@ -6,7 +6,7 @@ public annotation class AllOpen { @AllOpen @kotlin.Metadata -class Test { +final class Test { // source: 'privateMembers.kt' private final @org.jetbrains.annotations.NotNull field internalProp: java.lang.String private final field privateProp: java.lang.String @@ -17,7 +17,8 @@ class Test { protected @org.jetbrains.annotations.NotNull method getProtectedProp(): java.lang.String public @org.jetbrains.annotations.NotNull method getPublicProp(): java.lang.String public method internalMethod$test_module(): void - private method privateMethod(): void + private final method privateMethod(): void + private final method privateTailrecMethod(): void protected method protectedMethod(): void public method publicMethod(): void } From ef931d55611195e9a949f029f6523adb999686be Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Tue, 16 Feb 2021 09:31:17 +0300 Subject: [PATCH 177/368] [Commonizer] Don't keep kotlin/Any as the single supertype in CirClass --- .../commonizer/cir/factory/CirClassFactory.kt | 3 ++- .../commonizer/core/CommonizationVisitor.kt | 14 +++----------- .../commonizer/metadata/entityBuilders.kt | 9 ++++++++- .../kotlin/descriptors/commonizer/utils/fqName.kt | 4 ++++ .../kotlin/descriptors/commonizer/utils/type.kt | 4 ++++ 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cir/factory/CirClassFactory.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cir/factory/CirClassFactory.kt index 642311b7fac..6bec4463b00 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cir/factory/CirClassFactory.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cir/factory/CirClassFactory.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeParameter import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirClassImpl import org.jetbrains.kotlin.descriptors.commonizer.utils.compactMap +import org.jetbrains.kotlin.descriptors.commonizer.utils.filteredSupertypes import org.jetbrains.kotlin.resolve.isInlineClass object CirClassFactory { @@ -32,7 +33,7 @@ object CirClassFactory { isInner = source.isInner, isExternal = source.isExternal ).apply { - setSupertypes(source.typeConstructor.supertypes.compactMap { CirTypeFactory.create(it) }) + setSupertypes(source.filteredSupertypes.compactMap { CirTypeFactory.create(it) }) } @Suppress("NOTHING_TO_INLINE") diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt index 17e2832692c..dabc2e380c5 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt @@ -6,9 +6,7 @@ package org.jetbrains.kotlin.descriptors.commonizer.core import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClass -import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType -import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeFactory import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.* import org.jetbrains.kotlin.descriptors.commonizer.utils.* import org.jetbrains.kotlin.descriptors.commonizer.utils.compactMapNotNull @@ -98,7 +96,7 @@ internal class CommonizationVisitor( } // find out common (and commonized) supertypes - commonClass.commonizeSupertypes(node.classifierId, node.collectCommonSupertypes()) + commonClass.commonizeSupertypes(node.collectCommonSupertypes()) } } @@ -111,7 +109,7 @@ internal class CommonizationVisitor( if (commonClassifier is CirClass) { // find out common (and commonized) supertypes - commonClassifier.commonizeSupertypes(node.classifierId, node.collectCommonSupertypes()) + commonClassifier.commonizeSupertypes(node.collectCommonSupertypes()) } } @@ -144,18 +142,12 @@ internal class CommonizationVisitor( } private fun CirClass.commonizeSupertypes( - classId: CirEntityId, supertypesMap: Map>? ) { val commonSupertypes = supertypesMap?.values?.compactMapNotNull { supertypesGroup -> commonize(supertypesGroup, TypeCommonizer(classifiers)) }.orEmpty() - setSupertypes( - if (commonSupertypes.isEmpty() && classId !in SPECIAL_CLASS_WITHOUT_SUPERTYPES_CLASS_IDS) - listOf(CirTypeFactory.StandardTypes.ANY) - else - commonSupertypes - ) + setSupertypes(commonSupertypes) } } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/metadata/entityBuilders.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/metadata/entityBuilders.kt index 85405edf513..bd10dbe674d 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/metadata/entityBuilders.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/metadata/entityBuilders.kt @@ -10,11 +10,13 @@ import kotlinx.metadata.klib.* import org.jetbrains.kotlin.backend.common.serialization.metadata.DynamicTypeDeserializer import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.commonizer.cir.* +import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeFactory import org.jetbrains.kotlin.descriptors.commonizer.cir.impl.CirValueParameterImpl import org.jetbrains.kotlin.descriptors.commonizer.core.computeExpandedType import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.* import org.jetbrains.kotlin.descriptors.commonizer.metadata.TypeAliasExpansion.* import org.jetbrains.kotlin.descriptors.commonizer.utils.DEFAULT_SETTER_VALUE_NAME +import org.jetbrains.kotlin.descriptors.commonizer.utils.SPECIAL_CLASS_WITHOUT_SUPERTYPES_CLASS_NAMES import org.jetbrains.kotlin.descriptors.commonizer.utils.compactMap import org.jetbrains.kotlin.types.Variance @@ -99,7 +101,12 @@ internal fun CirClass.buildClass( } clazz.companionObject = companion?.name - supertypes.mapTo(clazz.supertypes) { it.buildType(context) } + + val supertypes = supertypes + if (supertypes.isEmpty() && className !in SPECIAL_CLASS_WITHOUT_SUPERTYPES_CLASS_NAMES) + clazz.supertypes += CirTypeFactory.StandardTypes.ANY.buildType(context) + else + supertypes.mapTo(clazz.supertypes) { it.buildType(context) } } internal fun linkSealedClassesWithSubclasses(packageName: CirPackageName, classConsumer: ClassConsumer) { diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/fqName.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/fqName.kt index cb356d0d220..f36c8e1af22 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/fqName.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/fqName.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.descriptors.commonizer.utils +import kotlinx.metadata.ClassName import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor @@ -26,6 +27,9 @@ internal val SPECIAL_CLASS_WITHOUT_SUPERTYPES_CLASS_IDS: List = lis NOTHING_CLASS_ID ) +internal val SPECIAL_CLASS_WITHOUT_SUPERTYPES_CLASS_NAMES: List = + SPECIAL_CLASS_WITHOUT_SUPERTYPES_CLASS_IDS.map(CirEntityId::toString) + private val STANDARD_KOTLIN_PACKAGES: List = listOf( CirPackageName.create(StandardNames.BUILT_INS_PACKAGE_FQ_NAME), CirPackageName.create("kotlinx") diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/type.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/type.kt index 10cc5211801..f63fb0847eb 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/type.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/type.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.descriptors.commonizer.utils +import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName @@ -43,6 +44,9 @@ internal val ClassifierDescriptorWithTypeParameters.classifierId: CirEntityId internal inline val TypeParameterDescriptor.filteredUpperBounds: List get() = upperBounds.takeUnless { it.singleOrNull()?.isNullableAny() == true } ?: emptyList() +internal inline val ClassDescriptor.filteredSupertypes: Collection + get() = typeConstructor.supertypes.takeUnless { it.size == 1 && KotlinBuiltIns.isAny(it.first()) } ?: emptyList() + internal val KotlinType.signature: CirTypeSignature get() { // use of interner saves up to 95% of duplicates From ec7e411d8068368b14cc4631246e1363a26123eb Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Tue, 16 Feb 2021 11:53:01 +0300 Subject: [PATCH 178/368] [Commonizer] Remove classifierId from CIR class/TA nodes --- .../commonizer/core/CommonizationVisitor.kt | 7 +++---- .../descriptors/commonizer/mergedtree/CirClassNode.kt | 4 +--- .../descriptors/commonizer/mergedtree/CirNode.kt | 10 ++++++---- .../commonizer/mergedtree/CirTypeAliasNode.kt | 4 +--- .../descriptors/commonizer/mergedtree/nodeBuilders.kt | 4 ++-- .../kotlin/descriptors/commonizer/utils/mocks.kt | 3 +-- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt index dabc2e380c5..584765d0f59 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt @@ -85,9 +85,8 @@ internal class CommonizationVisitor( // companion object should have the same name for each target class, then it could be set to common class val companionObjectName = node.targetDeclarations.mapTo(HashSet()) { it!!.companion }.singleOrNull() if (companionObjectName != null) { - val companionObjectClassId = node.classifierId.createNestedEntityId(companionObjectName) - val companionObjectNode = classifiers.commonized.classNode(companionObjectClassId) - ?: error("Can't find companion object with class ID $companionObjectClassId") + val companionObjectNode = node.classes[companionObjectName] + ?: error("Can't find node for companion object $companionObjectName in node for class ${node.classifierName}") if (companionObjectNode.commonDeclaration() != null) { // companion object has been successfully commonized @@ -132,7 +131,7 @@ internal class CommonizationVisitor( val expandedClassNode = classifiers.commonized.classNode(expandedClassId) ?: return null val expandedClass = expandedClassNode.targetDeclarations[index] - ?: error("Can't find expanded class with class ID $expandedClassId and index $index for type alias $classifierId") + ?: error("Can't find expanded class with class ID $expandedClassId and index $index for type alias $classifierName") for (supertype in expandedClass.supertypes) { supertypesMap.getOrPut(supertype) { CommonizedGroup(targetDeclarations.size) }[index] = supertype diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirClassNode.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirClassNode.kt index 71fca5e3f9a..d7548c16207 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirClassNode.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirClassNode.kt @@ -7,7 +7,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree import gnu.trove.THashMap import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClass -import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup import org.jetbrains.kotlin.storage.NullableLazyValue @@ -15,8 +14,7 @@ import org.jetbrains.kotlin.storage.NullableLazyValue class CirClassNode( override val targetDeclarations: CommonizedGroup, override val commonDeclaration: NullableLazyValue, - override val classifierId: CirEntityId -) : CirNodeWithClassifierId, CirNodeWithMembers { +) : CirClassifierNode, CirNodeWithMembers { val constructors: MutableMap = THashMap() override val properties: MutableMap = THashMap() diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirNode.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirNode.kt index b6069ae877c..d22683d2abc 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirNode.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirNode.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree import org.jetbrains.kotlin.descriptors.commonizer.cir.* import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup +import org.jetbrains.kotlin.descriptors.commonizer.utils.firstNonNull import org.jetbrains.kotlin.storage.NullableLazyValue interface CirNode { @@ -26,8 +27,8 @@ interface CirNode { if (node is CirPackageNode) { append("packageName=").append(node.packageName).append(", ") } - if (node is CirNodeWithClassifierId) { - append("classifierId=").append(node.classifierId).append(", ") + if (node is CirClassifierNode) { + append("classifierName=").append(node.classifierName).append(", ") } append("target=") node.targetDeclarations.joinTo(this) @@ -37,8 +38,9 @@ interface CirNode { } } -interface CirNodeWithClassifierId : CirNode { - val classifierId: CirEntityId +interface CirClassifierNode : CirNode { + val classifierName: CirName + get() = targetDeclarations.firstNonNull().name } interface CirNodeWithLiftingUp : CirNode { diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTypeAliasNode.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTypeAliasNode.kt index cddfbfb982e..8b3d58adc92 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTypeAliasNode.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTypeAliasNode.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree import org.jetbrains.kotlin.descriptors.commonizer.cir.CirClassifier -import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.cir.CirTypeAlias import org.jetbrains.kotlin.descriptors.commonizer.utils.CommonizedGroup import org.jetbrains.kotlin.storage.NullableLazyValue @@ -14,8 +13,7 @@ import org.jetbrains.kotlin.storage.NullableLazyValue class CirTypeAliasNode( override val targetDeclarations: CommonizedGroup, override val commonDeclaration: NullableLazyValue, - override val classifierId: CirEntityId -) : CirNodeWithClassifierId, CirNodeWithLiftingUp { +) : CirClassifierNode, CirNodeWithLiftingUp { override fun accept(visitor: CirNodeVisitor, data: T): R = visitor.visitTypeAliasNode(this, data) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/nodeBuilders.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/nodeBuilders.kt index dada2dfd93f..82644db2801 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/nodeBuilders.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/nodeBuilders.kt @@ -83,7 +83,7 @@ internal fun buildClassNode( commonizerProducer = { ClassCommonizer(classifiers) }, recursionMarker = CirClassRecursionMarker, nodeProducer = { targetDeclarations, commonDeclaration -> - CirClassNode(targetDeclarations, commonDeclaration, classId).also { + CirClassNode(targetDeclarations, commonDeclaration).also { classifiers.commonized.addClassNode(classId, it) } } @@ -113,7 +113,7 @@ internal fun buildTypeAliasNode( commonizerProducer = { TypeAliasCommonizer(classifiers) }, recursionMarker = CirClassifierRecursionMarker, nodeProducer = { targetDeclarations, commonDeclaration -> - CirTypeAliasNode(targetDeclarations, commonDeclaration, typeAliasId).also { + CirTypeAliasNode(targetDeclarations, commonDeclaration).also { classifiers.commonized.addTypeAliasNode(typeAliasId, it) } } diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt index d689e0cc49b..60c157fc34c 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt @@ -138,8 +138,7 @@ internal val MOCK_CLASSIFIERS = CirKnownClassifiers( isInner = false, isExternal = false ) - }, - CirEntityId.create("kotlin/Any") + } ) override fun classNode(classId: CirEntityId) = MOCK_CLASS_NODE From 45b17120ad4e0c0fc5038510ac2d372dfe5ebc49 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Tue, 16 Feb 2021 13:05:25 +0300 Subject: [PATCH 179/368] [Commonizer] Minor. Rename: 'dependee' -> 'dependency' --- .../commonizer/CommonizerParameters.kt | 2 +- .../descriptors/commonizer/TargetProvider.kt | 2 +- .../commonizer/core/CommonizationVisitor.kt | 2 +- .../commonizer/core/TypeCommonizer.kt | 14 ++--- .../commonizer/core/typeAliasUtils.kt | 2 +- .../kotlin/descriptors/commonizer/facade.kt | 6 +-- .../konan/NativeDistributionCommonizer.kt | 4 +- .../commonizer/mergedtree/CirTreeMerger.kt | 16 +++--- .../mergedtree/classifierContainers.kt | 6 +-- .../common/package_common_stuff.kt | 0 .../common/package_kotlinx_cinterop.kt | 0 .../common/package_kotlinx_cinterop.kt | 0 .../AbstractCommonizationFromSourcesTest.kt | 54 +++++++++---------- .../commonizer/CommonizerFacadeTest.kt | 2 +- .../commonizer/core/TypeCommonizerTest.kt | 2 +- .../descriptors/commonizer/utils/mocks.kt | 2 +- 16 files changed, 57 insertions(+), 57 deletions(-) rename native/commonizer/testData/classifierCommonization/differentTypeAliasesInArguments/{dependee => dependency}/common/package_common_stuff.kt (100%) rename native/commonizer/testData/classifierCommonization/typeAliases/{dependee => dependency}/common/package_kotlinx_cinterop.kt (100%) rename native/commonizer/testData/functionCommonization/valueParameters/{dependee => dependency}/common/package_kotlinx_cinterop.kt (100%) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerParameters.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerParameters.kt index 32c6f2746b7..e19779bf7a4 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerParameters.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerParameters.kt @@ -17,7 +17,7 @@ class CommonizerParameters( val sharedTarget: SharedTarget get() = SharedTarget(_targetProviders.keys) // common module dependencies (ex: Kotlin stdlib) - var dependeeModulesProvider: ModulesProvider? = null + var dependencyModulesProvider: ModulesProvider? = null set(value) { check(field == null) field = value diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt index fdd2be0ba74..5f0b287a857 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt @@ -12,7 +12,7 @@ import java.io.File class TargetProvider( val target: LeafTarget, val modulesProvider: ModulesProvider, - val dependeeModulesProvider: ModulesProvider? + val dependencyModulesProvider: ModulesProvider? ) interface ModulesProvider { diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt index 584765d0f59..14bd17fbd62 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt @@ -126,7 +126,7 @@ internal class CommonizationVisitor( val supertypesMap: MutableMap> = linkedMapOf() // preserve supertype order for ((index, typeAlias) in targetDeclarations.withIndex()) { val expandedClassId = typeAlias!!.expandedType.classifierId - if (classifiers.commonDependeeLibraries.hasClassifier(expandedClassId)) + if (classifiers.commonDependencies.hasClassifier(expandedClassId)) return null // this case is not supported yet val expandedClassNode = classifiers.commonized.classNode(expandedClassId) ?: return null diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizer.kt index 9225ec14d1a..49ad68f72e3 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizer.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.descriptors.DescriptorVisibility import org.jetbrains.kotlin.descriptors.commonizer.cir.* import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirTypeFactory import org.jetbrains.kotlin.descriptors.commonizer.core.CommonizedTypeAliasAnswer.Companion.FAILURE_MISSING_IN_SOME_TARGET -import org.jetbrains.kotlin.descriptors.commonizer.core.CommonizedTypeAliasAnswer.Companion.SUCCESS_FROM_DEPENDEE_LIBRARY +import org.jetbrains.kotlin.descriptors.commonizer.core.CommonizedTypeAliasAnswer.Companion.SUCCESS_FROM_DEPENDENCY_LIBRARY import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.CirKnownClassifiers import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderKotlinNativeSyntheticPackages @@ -192,8 +192,8 @@ private class FlexibleTypeCommonizer(classifiers: CirKnownClassifiers) : Abstrac } private fun commonizeClass(classId: CirEntityId, classifiers: CirKnownClassifiers): Boolean { - if (classifiers.commonDependeeLibraries.hasClassifier(classId)) { - // The class is from common fragment of dependee library (ex: stdlib). Already commonized. + if (classifiers.commonDependencies.hasClassifier(classId)) { + // The class is from common fragment of dependency library (ex: stdlib). Already commonized. return true } else if (classId.packageName.isUnderKotlinNativeSyntheticPackages) { // C/Obj-C forward declarations are: @@ -219,9 +219,9 @@ private fun commonizeClass(classId: CirEntityId, classifiers: CirKnownClassifier } private fun commonizeTypeAlias(typeAliasId: CirEntityId, classifiers: CirKnownClassifiers): CommonizedTypeAliasAnswer { - if (classifiers.commonDependeeLibraries.hasClassifier(typeAliasId)) { - // The type alias is from common fragment of dependee library (ex: stdlib). Already commonized. - return SUCCESS_FROM_DEPENDEE_LIBRARY + if (classifiers.commonDependencies.hasClassifier(typeAliasId)) { + // The type alias is from common fragment of dependency library (ex: stdlib). Already commonized. + return SUCCESS_FROM_DEPENDENCY_LIBRARY } return when (val node = classifiers.commonized.typeAliasNode(typeAliasId)) { @@ -238,7 +238,7 @@ private fun commonizeTypeAlias(typeAliasId: CirEntityId, classifiers: CirKnownCl private class CommonizedTypeAliasAnswer(val commonized: Boolean, val commonClassifier: CirClassifier?) { companion object { - val SUCCESS_FROM_DEPENDEE_LIBRARY = CommonizedTypeAliasAnswer(true, null) + val SUCCESS_FROM_DEPENDENCY_LIBRARY = CommonizedTypeAliasAnswer(true, null) val FAILURE_MISSING_IN_SOME_TARGET = CommonizedTypeAliasAnswer(false, null) fun create(commonClassifier: CirClassifier?) = diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/typeAliasUtils.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/typeAliasUtils.kt index 7d3dcd81241..137fe439718 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/typeAliasUtils.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/typeAliasUtils.kt @@ -25,7 +25,7 @@ internal tailrec fun computeSuitableUnderlyingType( ): CirClassOrTypeAliasType? { return when (underlyingType) { is CirClassType -> underlyingType.withCommonizedArguments(classifiers) - is CirTypeAliasType -> if (classifiers.commonDependeeLibraries.hasClassifier(underlyingType.classifierId)) + is CirTypeAliasType -> if (classifiers.commonDependencies.hasClassifier(underlyingType.classifierId)) underlyingType.withCommonizedArguments(classifiers) else computeSuitableUnderlyingType(classifiers, underlyingType.underlyingType) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt index 2fb60d174ca..fcb7eca39a3 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt @@ -41,10 +41,10 @@ private fun mergeAndCommonize(storageManager: StorageManager, parameters: Common val classifiers = CirKnownClassifiers( commonized = CirCommonizedClassifiers.default(), forwardDeclarations = CirForwardDeclarations.default(), - dependeeLibraries = mapOf( - // for now, supply only common dependee libraries (ex: Kotlin stdlib) + dependencies = mapOf( + // for now, supply only common dependency libraries (ex: Kotlin stdlib) parameters.sharedTarget to CirProvidedClassifiers.fromModules(storageManager) { - parameters.dependeeModulesProvider?.loadModules(emptyList())?.values.orEmpty() + parameters.dependencyModulesProvider?.loadModules(emptyList())?.values.orEmpty() } ) ) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionCommonizer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionCommonizer.kt index 4e831df93d2..76340070127 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionCommonizer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionCommonizer.kt @@ -135,7 +135,7 @@ class NativeDistributionCommonizer( copyEndorsedLibs = copyEndorsedLibs, logProgress = ::logProgress ) - dependeeModulesProvider = NativeDistributionModulesProvider.forStandardLibrary(storageManager, allLibraries.stdlib) + dependencyModulesProvider = NativeDistributionModulesProvider.forStandardLibrary(storageManager, allLibraries.stdlib) allLibraries.librariesByTargets.forEach { (target, librariesToCommonize) -> if (librariesToCommonize.libraries.isEmpty()) return@forEach @@ -146,7 +146,7 @@ class NativeDistributionCommonizer( TargetProvider( target = target, modulesProvider = modulesProvider, - dependeeModulesProvider = null // stdlib is already set as common dependency + dependencyModulesProvider = null // stdlib is already set as common dependency ) ) } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt index 200d2bf29bb..27274c344c5 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt @@ -63,11 +63,11 @@ class CirTreeMerger( private fun processRoot(): CirTreeMergeResult { val rootNode: CirRootNode = buildRootNode(storageManager, size) - // remember any exported forward declarations from common fragments of dependee modules - parameters.dependeeModulesProvider?.loadModuleInfos()?.forEach(::processCInteropModuleAttributes) + // remember any exported forward declarations from common fragments of dependency modules + parameters.dependencyModulesProvider?.loadModuleInfos()?.forEach(::processCInteropModuleAttributes) // load common dependencies - val dependeeModules = parameters.dependeeModulesProvider?.loadModules(emptyList())?.values.orEmpty() + val dependencyModules = parameters.dependencyModulesProvider?.loadModules(emptyList())?.values.orEmpty() val allModuleInfos: List> = parameters.targetProviders.map { targetProvider -> targetProvider.modulesProvider.loadModuleInfos().associateBy { it.name } @@ -76,7 +76,7 @@ class CirTreeMerger( parameters.targetProviders.forEachIndexed { targetIndex, targetProvider -> val commonModuleInfos = allModuleInfos[targetIndex].filterKeys { it in commonModuleNames } - processTarget(rootNode, targetIndex, targetProvider, commonModuleInfos, dependeeModules) + processTarget(rootNode, targetIndex, targetProvider, commonModuleInfos, dependencyModules) parameters.progressLogger?.invoke("Loaded declarations for ${targetProvider.target.prettyName}") System.gc() } @@ -98,14 +98,14 @@ class CirTreeMerger( targetIndex: Int, targetProvider: TargetProvider, commonModuleInfos: Map, - dependeeModules: Collection + dependencyModules: Collection ) { rootNode.targetDeclarations[targetIndex] = CirRootFactory.create(targetProvider.target) - val targetDependeeModules = targetProvider.dependeeModulesProvider?.loadModules(dependeeModules)?.values.orEmpty() - val allDependeeModules = targetDependeeModules + dependeeModules + val targetDependencyModules = targetProvider.dependencyModulesProvider?.loadModules(dependencyModules)?.values.orEmpty() + val allDependencyModules = targetDependencyModules + dependencyModules - val moduleDescriptors: Map = targetProvider.modulesProvider.loadModules(allDependeeModules) + val moduleDescriptors: Map = targetProvider.modulesProvider.loadModules(allDependencyModules) moduleDescriptors.forEach { (name, moduleDescriptor) -> val moduleInfo = commonModuleInfos[name] ?: return@forEach diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt index 2138318d4aa..2fe350c6502 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt @@ -21,11 +21,11 @@ import org.jetbrains.kotlin.storage.getValue class CirKnownClassifiers( val commonized: CirCommonizedClassifiers, val forwardDeclarations: CirForwardDeclarations, - val dependeeLibraries: Map + val dependencies: Map ) { // a shortcut for fast access - val commonDependeeLibraries: CirProvidedClassifiers = - dependeeLibraries.filterKeys { it is SharedTarget }.values.singleOrNull() ?: CirProvidedClassifiers.EMPTY + val commonDependencies: CirProvidedClassifiers = + dependencies.filterKeys { it is SharedTarget }.values.singleOrNull() ?: CirProvidedClassifiers.EMPTY } interface CirCommonizedClassifiers { diff --git a/native/commonizer/testData/classifierCommonization/differentTypeAliasesInArguments/dependee/common/package_common_stuff.kt b/native/commonizer/testData/classifierCommonization/differentTypeAliasesInArguments/dependency/common/package_common_stuff.kt similarity index 100% rename from native/commonizer/testData/classifierCommonization/differentTypeAliasesInArguments/dependee/common/package_common_stuff.kt rename to native/commonizer/testData/classifierCommonization/differentTypeAliasesInArguments/dependency/common/package_common_stuff.kt diff --git a/native/commonizer/testData/classifierCommonization/typeAliases/dependee/common/package_kotlinx_cinterop.kt b/native/commonizer/testData/classifierCommonization/typeAliases/dependency/common/package_kotlinx_cinterop.kt similarity index 100% rename from native/commonizer/testData/classifierCommonization/typeAliases/dependee/common/package_kotlinx_cinterop.kt rename to native/commonizer/testData/classifierCommonization/typeAliases/dependency/common/package_kotlinx_cinterop.kt diff --git a/native/commonizer/testData/functionCommonization/valueParameters/dependee/common/package_kotlinx_cinterop.kt b/native/commonizer/testData/functionCommonization/valueParameters/dependency/common/package_kotlinx_cinterop.kt similarity index 100% rename from native/commonizer/testData/functionCommonization/valueParameters/dependee/common/package_kotlinx_cinterop.kt rename to native/commonizer/testData/functionCommonization/valueParameters/dependency/common/package_kotlinx_cinterop.kt diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt index d7bff9cd0fc..95af8cb91d4 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt @@ -118,7 +118,7 @@ private data class SourceModuleRoot( private class SourceModuleRoots( val originalRoots: Map, val commonizedRoots: Map, - val dependeeRoots: Map + val dependencyRoots: Map ) { val leafTargets: Set = originalRoots.keys val sharedTarget: SharedTarget @@ -135,7 +135,7 @@ private class SourceModuleRoots( val allTargets = leafTargets + sharedTarget check(commonizedRoots.keys == allTargets) - check(allTargets.containsAll(dependeeRoots.keys)) + check(allTargets.containsAll(dependencyRoots.keys)) } companion object { @@ -149,16 +149,16 @@ private class SourceModuleRoots( if (targetName == SHARED_TARGET_NAME) sharedTarget else leafTargets.first { it.name == targetName } val commonizedRoots = listRoots(dataDir, COMMONIZED_ROOTS_DIR).mapKeys { getTarget(it.key) } - val dependeeRoots = listRoots(dataDir, DEPENDEE_ROOTS_DIR).mapKeys { getTarget(it.key) } + val dependencyRoots = listRoots(dataDir, DEPENDENCY_ROOTS_DIR).mapKeys { getTarget(it.key) } - SourceModuleRoots(originalRoots, commonizedRoots, dependeeRoots) + SourceModuleRoots(originalRoots, commonizedRoots, dependencyRoots) } catch (e: Exception) { fail("Source module misconfiguration in $dataDir", cause = e) } private const val ORIGINAL_ROOTS_DIR = "original" private const val COMMONIZED_ROOTS_DIR = "commonized" - private const val DEPENDEE_ROOTS_DIR = "dependee" + private const val DEPENDENCY_ROOTS_DIR = "dependency" private fun listRoots(dataDir: File, rootsDirName: String): Map = dataDir.resolve(rootsDirName).listFiles()?.toSet().orEmpty().map(SourceModuleRoot::load).associateBy { it.targetName } @@ -183,7 +183,7 @@ private class AnalyzedModuleDependencies( private class AnalyzedModules( val originalModules: Map, val commonizedModules: Map, - val dependeeModules: Map> + val dependencyModules: Map> ) { val leafTargets: Set val sharedTarget: SharedTarget @@ -200,13 +200,13 @@ private class AnalyzedModules( val allTargets = leafTargets + sharedTarget check(commonizedModules.keys == allTargets) - check(allTargets.containsAll(dependeeModules.keys)) + check(allTargets.containsAll(dependencyModules.keys)) } fun toCommonizerParameters(resultsConsumer: ResultsConsumer) = CommonizerParameters().also { parameters -> parameters.resultsConsumer = resultsConsumer - parameters.dependeeModulesProvider = dependeeModules[sharedTarget]?.let(MockModulesProvider::create) + parameters.dependencyModulesProvider = dependencyModules[sharedTarget]?.let(MockModulesProvider::create) leafTargets.forEach { leafTarget -> val originalModule = originalModules.getValue(leafTarget) @@ -215,7 +215,7 @@ private class AnalyzedModules( TargetProvider( target = leafTarget, modulesProvider = MockModulesProvider.create(originalModule), - dependeeModulesProvider = dependeeModules[leafTarget]?.let(MockModulesProvider::create) + dependencyModulesProvider = dependencyModules[leafTarget]?.let(MockModulesProvider::create) ) ) } @@ -227,8 +227,8 @@ private class AnalyzedModules( parentDisposable: Disposable ): AnalyzedModules = with(sourceModuleRoots) { // phase 1: provide the modules that are the dependencies for "original" and "commonized" modules - val (dependeeModules: Map>, dependencies: AnalyzedModuleDependencies) = - createDependeeModules(sharedTarget, dependeeRoots, parentDisposable) + val (dependencyModules: Map>, dependencies: AnalyzedModuleDependencies) = + createDependencyModules(sharedTarget, dependencyRoots, parentDisposable) // phase 2: build "original" and "commonized" modules val originalModules: Map = @@ -238,27 +238,27 @@ private class AnalyzedModules( createModules(sharedTarget, commonizedRoots, dependencies, parentDisposable) .mapValues { (_, moduleDescriptor) -> MockModulesProvider.SERIALIZER.serializeModule(moduleDescriptor) } - return AnalyzedModules(originalModules, commonizedModules, dependeeModules) + return AnalyzedModules(originalModules, commonizedModules, dependencyModules) } - private fun createDependeeModules( + private fun createDependencyModules( sharedTarget: SharedTarget, - dependeeRoots: Map, + dependencyRoots: Map, parentDisposable: Disposable ): Pair>, AnalyzedModuleDependencies> { - val customDependeeModules = - createModules(sharedTarget, dependeeRoots, AnalyzedModuleDependencies.EMPTY, parentDisposable, isDependeeModule = true) + val customDependencyModules = + createModules(sharedTarget, dependencyRoots, AnalyzedModuleDependencies.EMPTY, parentDisposable, isDependencyModule = true) val stdlibModule = DefaultBuiltIns.Instance.builtInsModule - val dependeeModules = (sharedTarget.targets + sharedTarget).associateWith { target -> + val dependencyModules = (sharedTarget.targets + sharedTarget).associateWith { target -> // prepend stdlib for each target explicitly, so that the commonizer can see symbols from the stdlib - listOfNotNull(stdlibModule, customDependeeModules[target]) + listOfNotNull(stdlibModule, customDependencyModules[target]) } - return dependeeModules to AnalyzedModuleDependencies( - regularDependencies = dependeeModules, - expectByDependencies = dependeeModules.getValue(sharedTarget).filter { module -> module !== stdlibModule } + return dependencyModules to AnalyzedModuleDependencies( + regularDependencies = dependencyModules, + expectByDependencies = dependencyModules.getValue(sharedTarget).filter { module -> module !== stdlibModule } ) } @@ -267,7 +267,7 @@ private class AnalyzedModules( moduleRoots: Map, dependencies: AnalyzedModuleDependencies, parentDisposable: Disposable, - isDependeeModule: Boolean = false + isDependencyModule: Boolean = false ): Map { val result = mutableMapOf() @@ -275,7 +275,7 @@ private class AnalyzedModules( // first, process the common module moduleRoots[sharedTarget]?.let { moduleRoot -> - val commonModule = createModule(sharedTarget, sharedTarget, moduleRoot, dependencies, parentDisposable, isDependeeModule) + val commonModule = createModule(sharedTarget, sharedTarget, moduleRoot, dependencies, parentDisposable, isDependencyModule) result[sharedTarget] = commonModule dependenciesForOthers = dependencies.withExpectByDependency(commonModule) } @@ -283,7 +283,7 @@ private class AnalyzedModules( // then, all platform modules moduleRoots.filterKeys { it != sharedTarget }.forEach { (leafTarget, moduleRoot) -> result[leafTarget] = - createModule(sharedTarget, leafTarget, moduleRoot, dependenciesForOthers, parentDisposable, isDependeeModule) + createModule(sharedTarget, leafTarget, moduleRoot, dependenciesForOthers, parentDisposable, isDependencyModule) } return result @@ -295,10 +295,10 @@ private class AnalyzedModules( moduleRoot: SourceModuleRoot, dependencies: AnalyzedModuleDependencies, parentDisposable: Disposable, - isDependeeModule: Boolean + isDependencyModule: Boolean ): ModuleDescriptor { val moduleName: String = moduleRoot.location.parentFile.parentFile.name.let { - if (isDependeeModule) "dependee-$it" else it + if (isDependencyModule) "dependency-$it" else it } check(Name.isValidIdentifier(moduleName)) @@ -329,7 +329,7 @@ private class AnalyzedModules( environment.createPackagePartProvider(content.moduleContentScope) }.moduleDescriptor - if (!isDependeeModule) + if (!isDependencyModule) module.accept(PatchingTestDescriptorVisitor, Unit) return module diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerFacadeTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerFacadeTest.kt index 1263e206da8..0f4af9f10f1 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerFacadeTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerFacadeTest.kt @@ -71,7 +71,7 @@ class CommonizerFacadeTest { TargetProvider( target = LeafTarget(targetName), modulesProvider = MockModulesProvider.create(moduleNames), - dependeeModulesProvider = null + dependencyModulesProvider = null ) ) } diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt index d1dd0ab3eed..7da9705f162 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt @@ -35,7 +35,7 @@ class TypeCommonizerTest : AbstractCommonizerTest() { classifiers = CirKnownClassifiers( commonized = CirCommonizedClassifiers.default(), forwardDeclarations = CirForwardDeclarations.default(), - dependeeLibraries = mapOf( + dependencies = mapOf( FAKE_SHARED_TARGET to object : CirProvidedClassifiers { override fun hasClassifier(classifierId: CirEntityId): Boolean = classifierId.packageName.isUnderStandardKotlinPackages } diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt index 60c157fc34c..03a7f70c316 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt @@ -150,7 +150,7 @@ internal val MOCK_CLASSIFIERS = CirKnownClassifiers( override fun isExportedForwardDeclaration(classId: CirEntityId) = false override fun addExportedForwardDeclaration(classId: CirEntityId) = error("This method should not be called") }, - dependeeLibraries = emptyMap() + dependencies = emptyMap() ) internal class MockModulesProvider private constructor( From 98ba379e075afc6719cbdb65c39682c2e86e458f Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Tue, 16 Feb 2021 13:25:47 +0100 Subject: [PATCH 180/368] Fixed NPE on StandaloneScriptRootsCache instantiation Relates to ^EA-218043 #KTIJ-1137 Fixed Original commit: 1d63a1b48d480b958ff44676c42b698a8ca5f64a --- .../gradle/roots/GradleBuildRootIndex.kt | 4 +- .../gradle/GradleBuildRootIndexTest.kt | 47 +++++++++++++++++++ .../gradle/GradleScriptListenerTest.kt | 12 ----- .../AbstractScriptConfigurationLoadingTest.kt | 13 +++++ 4 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 idea/idea-gradle/tests/org/jetbrains/kotlin/idea/scripting/gradle/GradleBuildRootIndexTest.kt diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/roots/GradleBuildRootIndex.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/roots/GradleBuildRootIndex.kt index 708299f0d2d..36a422853c9 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/roots/GradleBuildRootIndex.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/roots/GradleBuildRootIndex.kt @@ -16,7 +16,9 @@ class GradleBuildRootIndex(private val project: Project) : StandaloneScriptsUpda private val standaloneScripts: MutableSet get() = StandaloneScriptsStorage.getInstance(project)?.files ?: hashSetOf() - private val standaloneScriptRoots = mutableMapOf().apply { + private val standaloneScriptRoots = mutableMapOf() + + init { standaloneScripts.forEach(::updateRootsCache) } diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/scripting/gradle/GradleBuildRootIndexTest.kt b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/scripting/gradle/GradleBuildRootIndexTest.kt new file mode 100644 index 00000000000..31716aaee02 --- /dev/null +++ b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/scripting/gradle/GradleBuildRootIndexTest.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2021 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.idea.scripting.gradle + +import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil +import com.intellij.psi.PsiFile +import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationLoadingTest +import org.jetbrains.kotlin.idea.scripting.gradle.roots.GradleBuildRootsManager +import org.jetbrains.kotlin.idea.scripting.gradle.settings.StandaloneScriptsStorage +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.plugins.gradle.settings.DistributionType +import org.jetbrains.plugins.gradle.settings.GradleProjectSettings +import org.jetbrains.plugins.gradle.util.GradleConstants +import java.io.File + +class GradleBuildRootIndexTest : AbstractScriptConfigurationLoadingTest() { + override fun setUpTestProject() { + val rootDir = File("idea/testData/script/definition/loading/gradle/") + + val settings: KtFile = copyFromTestdataToProject(File(rootDir, GradleConstants.KOTLIN_DSL_SETTINGS_FILE_NAME).path) + val prop: PsiFile = copyFromTestdataToProject(File(rootDir, "gradle.properties").path) + + val gradleCoreJar = createFileInProject("gradle/lib/gradle-core-1.0.0.jar") + val gradleWrapperProperties = createFileInProject("gradle/wrapper/gradle-wrapper.properties") + + val buildGradleKts = rootDir.walkTopDown().find { it.name == GradleConstants.KOTLIN_DSL_SCRIPT_NAME } + ?: error("Couldn't find main script") + configureScriptFile(rootDir.path, buildGradleKts) + val build = (myFile as? KtFile) ?: error("") + + val newProjectSettings = GradleProjectSettings() + newProjectSettings.gradleHome = gradleCoreJar.parentFile.parent + newProjectSettings.distributionType = DistributionType.LOCAL + newProjectSettings.externalProjectPath = settings.virtualFile.parent.path + + StandaloneScriptsStorage.getInstance(project)!!.files.add("standalone.kts") + + ExternalSystemApiUtil.getSettings(project, GradleConstants.SYSTEM_ID).linkProject(newProjectSettings) + } + + fun `test standalone scripts on start`() { + assertNotNull(GradleBuildRootsManager.getInstance(project)) + } +} \ No newline at end of file diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptListenerTest.kt b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptListenerTest.kt index 47725f324e2..e7725779ae9 100644 --- a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptListenerTest.kt +++ b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/scripting/gradle/GradleScriptListenerTest.kt @@ -66,18 +66,6 @@ open class GradleScriptListenerTest : AbstractScriptConfigurationLoadingTest() { ) } - private inline fun copyFromTestdataToProject(file: String): T { - createFileAndSyncDependencies(File(file)) - return (myFile as? T) ?: error("Couldn't configure project by $file") - } - - private fun createFileInProject(path: String): File { - val file = File(project.basePath, path) - file.parentFile.mkdirs() - file.createNewFile() - return file - } - fun testSectionChange() { assertAndLoadInitialConfiguration(testFiles.buildKts) diff --git a/idea/tests/org/jetbrains/kotlin/idea/script/AbstractScriptConfigurationLoadingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/script/AbstractScriptConfigurationLoadingTest.kt index 8b644a32195..7d3d8d8a87e 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/script/AbstractScriptConfigurationLoadingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/script/AbstractScriptConfigurationLoadingTest.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.idea.core.script.configuration.testingBackgroundExec import org.jetbrains.kotlin.idea.core.script.configuration.utils.testScriptConfigurationNotification import org.jetbrains.kotlin.idea.util.application.runWriteAction import org.jetbrains.kotlin.psi.KtFile +import java.io.File abstract class AbstractScriptConfigurationLoadingTest : AbstractScriptConfigurationTest() { lateinit var scriptConfigurationManager: CompositeScriptConfigurationManager @@ -68,6 +69,18 @@ abstract class AbstractScriptConfigurationLoadingTest : AbstractScriptConfigurat // do nothings } + protected inline fun copyFromTestdataToProject(file: String): T { + createFileAndSyncDependencies(File(file)) + return (myFile as? T) ?: error("Couldn't configure project by $file") + } + + protected fun createFileInProject(path: String): File { + val file = File(project.basePath, path) + file.parentFile.mkdirs() + file.createNewFile() + return file + } + protected fun assertAndDoAllBackgroundTasks() { assertDoAllBackgroundTaskAndDoWhileLoading { } } From 6352814d452c4cf0b2e9ec13f1e990db67ec7fe8 Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Tue, 16 Feb 2021 13:28:58 +0100 Subject: [PATCH 181/368] Fix NPE #KTIJ-898 Fixed Original commit: 12d8e88b846f29598ca3904b49996bd6a9891ccd --- .../gradle/importing/KotlinDslScriptModelProcessor.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/importing/KotlinDslScriptModelProcessor.kt b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/importing/KotlinDslScriptModelProcessor.kt index ad23a5c757c..d0638edeb62 100644 --- a/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/importing/KotlinDslScriptModelProcessor.kt +++ b/idea/idea-gradle/src/org/jetbrains/kotlin/idea/scripting/gradle/importing/KotlinDslScriptModelProcessor.kt @@ -88,7 +88,7 @@ private fun Collection.collectErrors(): List = - scriptModels.map { (file, model) -> + scriptModels.mapNotNull { (file, model) -> val messages = mutableListOf() model.exceptions.forEach { @@ -120,13 +120,13 @@ private fun KotlinDslScriptsModel.toListOfScriptModels(project: Project): List Date: Tue, 16 Feb 2021 12:59:44 +0100 Subject: [PATCH 182/368] Unify message bundles used in IDEA FIR into KotlinBundle --- .../messages/KotlinBundle.properties | 73 +++++++++++++++++++ .../KotlinBundleIndependent.properties | 73 ------------------- ...inIdeaAnalysisBundleIndependent.properties | 1 - .../idea/AbstractKotlinBundleIndependent.kt | 12 --- .../kotlin/idea/KotlinBundleIndependent.kt | 24 ------ .../KotlinIdeaAnalysisBundleIndependent.kt | 23 ------ .../KotlinElementDescriptionProvider.kt | 44 +++++------ .../KotlinFindUsagesHandlerFactory.kt | 6 +- .../findUsages/KotlinFindUsagesProvider.kt | 20 ++--- .../idea/findUsages/KotlinUsageTypes.kt | 48 ++++++------ .../dialogs/KotlinFindClassUsagesDialog.java | 16 ++-- .../KotlinFindFunctionUsagesDialog.java | 12 +-- .../KotlinFindPropertyUsagesDialog.java | 16 ++-- .../handlers/KotlinFindMemberUsagesHandler.kt | 4 +- .../quickfix/ChangeVariableMutabilityFix.kt | 6 +- .../kotlin/idea/quickfix/RemoveModifierFix.kt | 10 +-- .../operators/OperatorReferenceSearcher.kt | 4 +- .../quickfix/ChangeVariableMutabilityFix.kt | 4 +- 18 files changed, 168 insertions(+), 228 deletions(-) rename idea/{ => idea-frontend-independent}/resources-en/messages/KotlinBundle.properties (97%) delete mode 100644 idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties delete mode 100644 idea/idea-frontend-independent/resources-en/messages/KotlinIdeaAnalysisBundleIndependent.properties delete mode 100644 idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/AbstractKotlinBundleIndependent.kt delete mode 100644 idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/KotlinBundleIndependent.kt delete mode 100644 idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/KotlinIdeaAnalysisBundleIndependent.kt diff --git a/idea/resources-en/messages/KotlinBundle.properties b/idea/idea-frontend-independent/resources-en/messages/KotlinBundle.properties similarity index 97% rename from idea/resources-en/messages/KotlinBundle.properties rename to idea/idea-frontend-independent/resources-en/messages/KotlinBundle.properties index df5660d2cba..c2f3f9059c5 100644 --- a/idea/resources-en/messages/KotlinBundle.properties +++ b/idea/idea-frontend-independent/resources-en/messages/KotlinBundle.properties @@ -2225,3 +2225,76 @@ hints.codevision.overrides.format={0, choice, 1#1 Override|2#{0,number} Override hints.codevision.overrides.to_many.format={0,number}+ Overrides hints.codevision.settings=Settings... inspection.unused.result.of.data.class.copy=Unused result of data class copy + + +find.declaration.implementing.methods.checkbox=&Implementing functions +find.declaration.overriding.methods.checkbox=Over&riding functions +find.declaration.implementing.properties.checkbox=&Implementing properties +find.declaration.overriding.properties.checkbox=Over&riding properties +find.declaration.property.readers.checkbox=Readers +find.declaration.property.writers.checkbox=Writers +find.declaration.include.overloaded.methods.checkbox=Include o&verloaded functions and extensions +find.declaration.functions.usages.checkbox=Usages of &functions +find.declaration.properties.usages.checkbox=Usages of &properties +find.declaration.constructor.usages.checkbox=Usages of &constructor +find.declaration.derived.classes.checkbox=&Derived classes +find.declaration.derived.interfaces.checkbox=Derived &interfaces + +find.usages.class=class +find.usages.companion.object=companion object +find.usages.constructor=constructor +find.usages.facade.class=facade class +find.usages.for.property={0} for property +find.usages.function=function +find.usages.getter=getter +find.usages.import.alias=import alias +find.usages.interface=interface +find.usages.label=label +find.usages.lambda=lambda +find.usages.object=object +find.usages.parameter=parameter +find.usages.property.accessor=property accessor +find.usages.property=property +find.usages.setter=setter +find.usages.type.alias=type alias +find.usages.type.parameter=type parameter +find.usages.variable=variable +find.usages.checkbox.name.expected.classes=Expected classes +find.usages.class.name.anonymous=Anonymous +find.usages.checkbox.name.expected.functions=Expected functions +find.usages.text.find.usages.for.data.class.components.and.destruction.declarations=

+find.usages.tool.tip.text.disable.search.for.data.class.components.and.destruction.declarations.project.wide.setting=Disable search for data class components and destructuring declarations. (Project wide setting) +find.usages.checkbox.text.fast.data.class.component.search=Fast data class component search +find.usages.checkbox.name.expected.properties=Expected properties +find.usages.action.text.find.usages.of=find usages of + +find.usages.type.named.argument=Named argument +find.usages.type.type.alias=Type alias +find.usages.type.callable.reference=Callable reference +find.usages.type.type.constraint=Type constraint +find.usages.type.value.parameter.type=Parameter type +find.usages.type.nonLocal.property.type=Class/object property type +find.usages.type.function.return.type=Function return types +find.usages.type.superType=Supertype +find.usages.type.is=Target type of 'is' operation +find.usages.type.class.object=Nested class/object +find.usages.type.companion.object=Companion object +find.usages.type.function.call=Function call +find.usages.type.implicit.get=Implicit 'get' +find.usages.type.implicit.set=Implicit 'set' +find.usages.type.implicit.invoke=Implicit 'invoke' +find.usages.type.implicit.iteration=Implicit iteration +find.usages.type.property.delegation=Property delegation +find.usages.type.extension.receiver.type=Extension receiver type +find.usages.type.super.type.qualifier=Super type qualifier +find.usages.type.receiver=Receiver +find.usages.type.delegate=Delegate +find.usages.type.packageDirective=Package directive +find.usages.type.packageMemberAccess=Package member access + +and.delete.initializer=\ and delete initializer +change.to.val=Change to val +change.to.var=Change to var + +remove.redundant.0.modifier=Remove redundant ''{0}'' modifier +searching.for.implicit.usages=Searching for implicit usages... \ No newline at end of file diff --git a/idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties b/idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties deleted file mode 100644 index 57eb28b42d1..00000000000 --- a/idea/idea-frontend-independent/resources-en/messages/KotlinBundleIndependent.properties +++ /dev/null @@ -1,73 +0,0 @@ -find.declaration.implementing.methods.checkbox=&Implementing functions -find.declaration.overriding.methods.checkbox=Over&riding functions -find.declaration.implementing.properties.checkbox=&Implementing properties -find.declaration.overriding.properties.checkbox=Over&riding properties -find.declaration.property.readers.checkbox=Readers -find.declaration.property.writers.checkbox=Writers -find.declaration.include.overloaded.methods.checkbox=Include o&verloaded functions and extensions -find.declaration.functions.usages.checkbox=Usages of &functions -find.declaration.properties.usages.checkbox=Usages of &properties -find.declaration.constructor.usages.checkbox=Usages of &constructor -find.declaration.derived.classes.checkbox=&Derived classes -find.declaration.derived.interfaces.checkbox=Derived &interfaces - -find.usages.class=class -find.usages.companion.object=companion object -find.usages.constructor=constructor -find.usages.facade.class=facade class -find.usages.for.property={0} for property -find.usages.function=function -find.usages.getter=getter -find.usages.import.alias=import alias -find.usages.interface=interface -find.usages.label=label -find.usages.lambda=lambda -find.usages.object=object -find.usages.parameter=parameter -find.usages.property.accessor=property accessor -find.usages.property=property -find.usages.setter=setter -find.usages.type.alias=type alias -find.usages.type.parameter=type parameter -find.usages.variable=variable -find.usages.checkbox.name.expected.classes=Expected classes -find.usages.class.name.anonymous=Anonymous -find.usages.checkbox.name.expected.functions=Expected functions -find.usages.text.find.usages.for.data.class.components.and.destruction.declarations=

Find usages for data class components and destructuring declarations
could be disabled once or disabled for a project.

-find.usages.tool.tip.text.disable.search.for.data.class.components.and.destruction.declarations.project.wide.setting=Disable search for data class components and destructuring declarations. (Project wide setting) -find.usages.checkbox.text.fast.data.class.component.search=Fast data class component search -find.usages.checkbox.name.expected.properties=Expected properties -find.usages.action.text.find.usages.of=find usages of - -find.usages.type.named.argument=Named argument -find.usages.type.type.alias=Type alias -find.usages.type.callable.reference=Callable reference -find.usages.type.type.constraint=Type constraint -find.usages.type.value.parameter.type=Parameter type -find.usages.type.nonLocal.property.type=Class/object property type -find.usages.type.function.return.type=Function return types -find.usages.type.superType=Supertype -find.usages.type.is=Target type of 'is' operation -find.usages.type.class.object=Nested class/object -find.usages.type.companion.object=Companion object -find.usages.type.function.call=Function call -find.usages.type.implicit.get=Implicit 'get' -find.usages.type.implicit.set=Implicit 'set' -find.usages.type.implicit.invoke=Implicit 'invoke' -find.usages.type.implicit.iteration=Implicit iteration -find.usages.type.property.delegation=Property delegation -find.usages.type.extension.receiver.type=Extension receiver type -find.usages.type.super.type.qualifier=Super type qualifier -find.usages.type.receiver=Receiver -find.usages.type.delegate=Delegate -find.usages.type.packageDirective=Package directive -find.usages.type.packageMemberAccess=Package member access - -and.delete.initializer=\ and delete initializer -change.to.val=Change to val -change.to.var=Change to var - -remove.redundant.0.modifier=Remove redundant ''{0}'' modifier -make.0.not.1=Make {0} not {1} -remove.0.modifier=Remove ''{0}'' modifier -remove.modifier=Remove modifier diff --git a/idea/idea-frontend-independent/resources-en/messages/KotlinIdeaAnalysisBundleIndependent.properties b/idea/idea-frontend-independent/resources-en/messages/KotlinIdeaAnalysisBundleIndependent.properties deleted file mode 100644 index d8c2a4229d5..00000000000 --- a/idea/idea-frontend-independent/resources-en/messages/KotlinIdeaAnalysisBundleIndependent.properties +++ /dev/null @@ -1 +0,0 @@ -searching.for.implicit.usages=Searching for implicit usages... \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/AbstractKotlinBundleIndependent.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/AbstractKotlinBundleIndependent.kt deleted file mode 100644 index cab9eeb4830..00000000000 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/AbstractKotlinBundleIndependent.kt +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright 2010-2020 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.idea - -import com.intellij.DynamicBundle - -abstract class AbstractKotlinBundleIndependent protected constructor(pathToBundle: String) : DynamicBundle(pathToBundle) { - protected fun String.withHtml(): String = "$this" -} \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/KotlinBundleIndependent.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/KotlinBundleIndependent.kt deleted file mode 100644 index b8f1bad9d04..00000000000 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/KotlinBundleIndependent.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2020 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.idea - -import org.jetbrains.annotations.NonNls -import org.jetbrains.annotations.PropertyKey - -@NonNls -private const val BUNDLE = "messages.KotlinBundleIndependent" - -//TODO Copy-pasted from KotlinBundle.kt -object KotlinBundleIndependent : AbstractKotlinBundleIndependent(BUNDLE) { - @JvmStatic - fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String = getMessage(key, *params) - - @JvmStatic - fun htmlMessage(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String = - getMessage(key, *params).withHtml() - - @JvmStatic - fun lazyMessage(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): () -> String = { getMessage(key, *params) } -} \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/KotlinIdeaAnalysisBundleIndependent.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/KotlinIdeaAnalysisBundleIndependent.kt deleted file mode 100644 index ea61fe4df25..00000000000 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/KotlinIdeaAnalysisBundleIndependent.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010-2020 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.idea - -import org.jetbrains.annotations.NonNls -import org.jetbrains.annotations.PropertyKey - -@NonNls -private const val BUNDLE = "messages.KotlinIdeaAnalysisBundleIndependent" - -object KotlinIdeaAnalysisBundleIndependent : AbstractKotlinBundleIndependent(BUNDLE) { - @JvmStatic - fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String = getMessage(key, *params) - - @JvmStatic - fun htmlMessage(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String = - getMessage(key, *params).withHtml() - - @JvmStatic - fun lazyMessage(@PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): () -> String = { getMessage(key, *params) } -} \ No newline at end of file diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinElementDescriptionProvider.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinElementDescriptionProvider.kt index 40ad4604321..6314c289b19 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinElementDescriptionProvider.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinElementDescriptionProvider.kt @@ -29,7 +29,7 @@ import com.intellij.usageView.UsageViewShortNameLocation import com.intellij.usageView.UsageViewTypeLocation import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade import org.jetbrains.kotlin.asJava.unwrapped -import org.jetbrains.kotlin.idea.KotlinBundleIndependent +import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.KotlinLanguage import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.name.Name @@ -138,39 +138,39 @@ open class KotlinElementDescriptionProviderBase : ElementDescriptionProvider { fun elementKind() = when (targetElement) { is KtClass -> if (targetElement.isInterface()) - KotlinBundleIndependent.message("find.usages.interface") + KotlinBundle.message("find.usages.interface") else - KotlinBundleIndependent.message("find.usages.class") + KotlinBundle.message("find.usages.class") is KtObjectDeclaration -> if (targetElement.isCompanion()) - KotlinBundleIndependent.message("find.usages.companion.object") + KotlinBundle.message("find.usages.companion.object") else - KotlinBundleIndependent.message("find.usages.object") - is KtNamedFunction -> KotlinBundleIndependent.message("find.usages.function") - is KtPropertyAccessor -> KotlinBundleIndependent.message( + KotlinBundle.message("find.usages.object") + is KtNamedFunction -> KotlinBundle.message("find.usages.function") + is KtPropertyAccessor -> KotlinBundle.message( "find.usages.for.property", (if (targetElement.isGetter) - KotlinBundleIndependent.message("find.usages.getter") + KotlinBundle.message("find.usages.getter") else - KotlinBundleIndependent.message("find.usages.setter")) + KotlinBundle.message("find.usages.setter")) ) + " " - is KtFunctionLiteral -> KotlinBundleIndependent.message("find.usages.lambda") - is KtPrimaryConstructor, is KtSecondaryConstructor -> KotlinBundleIndependent.message("find.usages.constructor") + is KtFunctionLiteral -> KotlinBundle.message("find.usages.lambda") + is KtPrimaryConstructor, is KtSecondaryConstructor -> KotlinBundle.message("find.usages.constructor") is KtProperty -> if (targetElement.isLocal) - KotlinBundleIndependent.message("find.usages.variable") + KotlinBundle.message("find.usages.variable") else - KotlinBundleIndependent.message("find.usages.property") - is KtTypeParameter -> KotlinBundleIndependent.message("find.usages.type.parameter") - is KtParameter -> KotlinBundleIndependent.message("find.usages.parameter") - is KtDestructuringDeclarationEntry -> KotlinBundleIndependent.message("find.usages.variable") - is KtTypeAlias -> KotlinBundleIndependent.message("find.usages.type.alias") - is KtLabeledExpression -> KotlinBundleIndependent.message("find.usages.label") - is KtImportAlias -> KotlinBundleIndependent.message("find.usages.import.alias") - is KtLightClassForFacade -> KotlinBundleIndependent.message("find.usages.facade.class") + KotlinBundle.message("find.usages.property") + is KtTypeParameter -> KotlinBundle.message("find.usages.type.parameter") + is KtParameter -> KotlinBundle.message("find.usages.parameter") + is KtDestructuringDeclarationEntry -> KotlinBundle.message("find.usages.variable") + is KtTypeAlias -> KotlinBundle.message("find.usages.type.alias") + is KtLabeledExpression -> KotlinBundle.message("find.usages.label") + is KtImportAlias -> KotlinBundle.message("find.usages.import.alias") + is KtLightClassForFacade -> KotlinBundle.message("find.usages.facade.class") else -> { //TODO Implement in FIR when { - targetElement.isRenameJavaSyntheticPropertyHandler -> KotlinBundleIndependent.message("find.usages.property") - targetElement.isRenameKotlinPropertyProcessor -> KotlinBundleIndependent.message("find.usages.property.accessor") + targetElement.isRenameJavaSyntheticPropertyHandler -> KotlinBundle.message("find.usages.property") + targetElement.isRenameKotlinPropertyProcessor -> KotlinBundle.message("find.usages.property.accessor") else -> null } } diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt index 602b147eef2..d89d4e6c83f 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt @@ -29,7 +29,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.search.searches.OverridingMethodsSearch import org.jetbrains.kotlin.asJava.toLightMethods import org.jetbrains.kotlin.asJava.unwrapped -import org.jetbrains.kotlin.idea.KotlinBundleIndependent +import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.findUsages.KotlinFindUsagesSupport.Companion.checkSuperMethods import org.jetbrains.kotlin.idea.search.KotlinSearchUsagesSupport.Companion.isOverridable import org.jetbrains.kotlin.idea.findUsages.handlers.DelegatingFindMemberUsagesHandler @@ -85,7 +85,7 @@ class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandlerFactor val declarationsToSearch = checkSuperMethods( element, null, - KotlinBundleIndependent.message("find.usages.action.text.find.usages.of") + KotlinBundle.message("find.usages.action.text.find.usages.of") ) return handlerForMultiple(element, declarationsToSearch) @@ -122,7 +122,7 @@ class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandlerFactor val declarationsToSearch = checkSuperMethods( declaration, null, - KotlinBundleIndependent.message("find.usages.action.text.find.usages.of") + KotlinBundle.message("find.usages.action.text.find.usages.of") ) return handlerForMultiple(declaration, declarationsToSearch) diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesProvider.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesProvider.kt index 0e4a92cb584..0af1e70711f 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesProvider.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesProvider.kt @@ -10,7 +10,7 @@ import com.intellij.lang.findUsages.FindUsagesProvider import com.intellij.lang.java.JavaFindUsagesProvider import com.intellij.psi.* import org.jetbrains.kotlin.asJava.elements.KtLightElement -import org.jetbrains.kotlin.idea.KotlinBundleIndependent +import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject import org.jetbrains.kotlin.psi.psiUtil.isPropertyParameter @@ -27,17 +27,17 @@ open class KotlinFindUsagesProviderBase : FindUsagesProvider { override fun getType(element: PsiElement): String { return when (element) { - is KtNamedFunction -> KotlinBundleIndependent.message("find.usages.function") - is KtClass -> KotlinBundleIndependent.message("find.usages.class") - is KtParameter -> KotlinBundleIndependent.message("find.usages.parameter") + is KtNamedFunction -> KotlinBundle.message("find.usages.function") + is KtClass -> KotlinBundle.message("find.usages.class") + is KtParameter -> KotlinBundle.message("find.usages.parameter") is KtProperty -> if (element.isLocal) - KotlinBundleIndependent.message("find.usages.variable") + KotlinBundle.message("find.usages.variable") else - KotlinBundleIndependent.message("find.usages.property") - is KtDestructuringDeclarationEntry -> KotlinBundleIndependent.message("find.usages.variable") - is KtTypeParameter -> KotlinBundleIndependent.message("find.usages.type.parameter") - is KtSecondaryConstructor -> KotlinBundleIndependent.message("find.usages.constructor") - is KtObjectDeclaration -> KotlinBundleIndependent.message("find.usages.object") + KotlinBundle.message("find.usages.property") + is KtDestructuringDeclarationEntry -> KotlinBundle.message("find.usages.variable") + is KtTypeParameter -> KotlinBundle.message("find.usages.type.parameter") + is KtSecondaryConstructor -> KotlinBundle.message("find.usages.constructor") + is KtObjectDeclaration -> KotlinBundle.message("find.usages.object") else -> "" } } diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinUsageTypes.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinUsageTypes.kt index b1341955556..a93d02687ed 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinUsageTypes.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/KotlinUsageTypes.kt @@ -6,7 +6,7 @@ package org.jetbrains.kotlin.idea.findUsages import com.intellij.usages.impl.rules.UsageType -import org.jetbrains.kotlin.idea.KotlinBundleIndependent +import org.jetbrains.kotlin.idea.KotlinBundle object KotlinUsageTypes { @@ -52,35 +52,35 @@ object KotlinUsageTypes { } // types - val TYPE_CONSTRAINT = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.type.constraint")) - val VALUE_PARAMETER_TYPE = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.value.parameter.type")) - val NON_LOCAL_PROPERTY_TYPE = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.nonLocal.property.type")) - val FUNCTION_RETURN_TYPE = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.function.return.type")) - val SUPER_TYPE = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.superType")) - val IS = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.is")) - val CLASS_OBJECT_ACCESS = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.class.object")) - val COMPANION_OBJECT_ACCESS = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.companion.object")) - val EXTENSION_RECEIVER_TYPE = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.extension.receiver.type")) - val SUPER_TYPE_QUALIFIER = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.super.type.qualifier")) - val TYPE_ALIAS = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.type.alias")) + val TYPE_CONSTRAINT = UsageType(KotlinBundle.lazyMessage("find.usages.type.type.constraint")) + val VALUE_PARAMETER_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.value.parameter.type")) + val NON_LOCAL_PROPERTY_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.nonLocal.property.type")) + val FUNCTION_RETURN_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.function.return.type")) + val SUPER_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.superType")) + val IS = UsageType(KotlinBundle.lazyMessage("find.usages.type.is")) + val CLASS_OBJECT_ACCESS = UsageType(KotlinBundle.lazyMessage("find.usages.type.class.object")) + val COMPANION_OBJECT_ACCESS = UsageType(KotlinBundle.lazyMessage("find.usages.type.companion.object")) + val EXTENSION_RECEIVER_TYPE = UsageType(KotlinBundle.lazyMessage("find.usages.type.extension.receiver.type")) + val SUPER_TYPE_QUALIFIER = UsageType(KotlinBundle.lazyMessage("find.usages.type.super.type.qualifier")) + val TYPE_ALIAS = UsageType(KotlinBundle.lazyMessage("find.usages.type.type.alias")) // functions - val FUNCTION_CALL = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.function.call")) - val IMPLICIT_GET = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.implicit.get")) - val IMPLICIT_SET = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.implicit.set")) - val IMPLICIT_INVOKE = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.implicit.invoke")) - val IMPLICIT_ITERATION = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.implicit.iteration")) - val PROPERTY_DELEGATION = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.property.delegation")) + val FUNCTION_CALL = UsageType(KotlinBundle.lazyMessage("find.usages.type.function.call")) + val IMPLICIT_GET = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.get")) + val IMPLICIT_SET = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.set")) + val IMPLICIT_INVOKE = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.invoke")) + val IMPLICIT_ITERATION = UsageType(KotlinBundle.lazyMessage("find.usages.type.implicit.iteration")) + val PROPERTY_DELEGATION = UsageType(KotlinBundle.lazyMessage("find.usages.type.property.delegation")) // values - val RECEIVER = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.receiver")) - val DELEGATE = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.delegate")) + val RECEIVER = UsageType(KotlinBundle.lazyMessage("find.usages.type.receiver")) + val DELEGATE = UsageType(KotlinBundle.lazyMessage("find.usages.type.delegate")) // packages - val PACKAGE_DIRECTIVE = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.packageDirective")) - val PACKAGE_MEMBER_ACCESS = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.packageMemberAccess")) + val PACKAGE_DIRECTIVE = UsageType(KotlinBundle.lazyMessage("find.usages.type.packageDirective")) + val PACKAGE_MEMBER_ACCESS = UsageType(KotlinBundle.lazyMessage("find.usages.type.packageMemberAccess")) // common usage types - val CALLABLE_REFERENCE = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.callable.reference")) - val NAMED_ARGUMENT = UsageType(KotlinBundleIndependent.lazyMessage("find.usages.type.named.argument")) + val CALLABLE_REFERENCE = UsageType(KotlinBundle.lazyMessage("find.usages.type.callable.reference")) + val NAMED_ARGUMENT = UsageType(KotlinBundle.lazyMessage("find.usages.type.named.argument")) } diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindClassUsagesDialog.java b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindClassUsagesDialog.java index 15b0803e248..d7165738b49 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindClassUsagesDialog.java +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindClassUsagesDialog.java @@ -32,7 +32,7 @@ import com.intellij.ui.StateRestoringCheckBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.asJava.LightClassUtilsKt; -import org.jetbrains.kotlin.idea.KotlinBundleIndependent; +import org.jetbrains.kotlin.idea.KotlinBundle; import org.jetbrains.kotlin.idea.findUsages.KotlinClassFindUsagesOptions; import org.jetbrains.kotlin.idea.search.KotlinSearchUsagesSupport; import org.jetbrains.kotlin.psi.KtClass; @@ -73,7 +73,7 @@ public class KotlinFindClassUsagesDialog extends FindClassUsagesDialog { String name = classOrObject.getName(); if (name == null || name.isEmpty()) { - name = KotlinBundleIndependent.message("find.usages.class.name.anonymous"); + name = KotlinBundle.message("find.usages.class.name.anonymous"); } PsiClass javaClass; @@ -108,31 +108,31 @@ public class KotlinFindClassUsagesDialog extends FindClassUsagesDialog { Utils.renameCheckbox( findWhatPanel, FindBundle.message("find.what.methods.usages.checkbox"), - KotlinBundleIndependent.message("find.declaration.functions.usages.checkbox") + KotlinBundle.message("find.declaration.functions.usages.checkbox") ); Utils.renameCheckbox( findWhatPanel, FindBundle.message("find.what.fields.usages.checkbox"), - KotlinBundleIndependent.message("find.declaration.properties.usages.checkbox") + KotlinBundle.message("find.declaration.properties.usages.checkbox") ); Utils.removeCheckbox(findWhatPanel, FindBundle.message("find.what.implementing.classes.checkbox")); Utils.removeCheckbox(findWhatPanel, FindBundle.message("find.what.derived.interfaces.checkbox")); Utils.removeCheckbox(findWhatPanel, FindBundle.message("find.what.derived.classes.checkbox")); derivedClasses = addCheckboxToPanel( - KotlinBundleIndependent.message("find.declaration.derived.classes.checkbox"), + KotlinBundle.message("find.declaration.derived.classes.checkbox"), getFindUsagesOptions().isDerivedClasses, findWhatPanel, true ); derivedTraits = addCheckboxToPanel( - KotlinBundleIndependent.message("find.declaration.derived.interfaces.checkbox"), + KotlinBundle.message("find.declaration.derived.interfaces.checkbox"), getFindUsagesOptions().isDerivedInterfaces, findWhatPanel, true ); constructorUsages = addCheckboxToPanel( - KotlinBundleIndependent.message("find.declaration.constructor.usages.checkbox"), + KotlinBundle.message("find.declaration.constructor.usages.checkbox"), getFindUsagesOptions().getSearchConstructorUsages(), findWhatPanel, true @@ -164,7 +164,7 @@ public class KotlinFindClassUsagesDialog extends FindClassUsagesDialog { KotlinClassFindUsagesOptions options = getFindUsagesOptions(); if (isActual) { expectedUsages = addCheckboxToPanel( - KotlinBundleIndependent.message("find.usages.checkbox.name.expected.classes"), + KotlinBundle.message("find.usages.checkbox.name.expected.classes"), options.getSearchExpected(), optionsPanel, false diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindFunctionUsagesDialog.java b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindFunctionUsagesDialog.java index d55cfca0634..b50c03de45c 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindFunctionUsagesDialog.java +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindFunctionUsagesDialog.java @@ -29,7 +29,7 @@ import com.intellij.ui.StateRestoringCheckBox; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.asJava.LightClassUtilsKt; import org.jetbrains.kotlin.asJava.elements.KtLightMethod; -import org.jetbrains.kotlin.idea.KotlinBundleIndependent; +import org.jetbrains.kotlin.idea.KotlinBundle; import org.jetbrains.kotlin.idea.findUsages.KotlinFunctionFindUsagesOptions; import org.jetbrains.kotlin.idea.search.KotlinSearchUsagesSupport; import org.jetbrains.kotlin.psi.KtDeclaration; @@ -72,12 +72,12 @@ public class KotlinFindFunctionUsagesDialog extends FindMethodUsagesDialog { Utils.renameCheckbox( findWhatPanel, FindBundle.message("find.what.implementing.methods.checkbox"), - KotlinBundleIndependent.message("find.declaration.implementing.methods.checkbox") + KotlinBundle.message("find.declaration.implementing.methods.checkbox") ); Utils.renameCheckbox( findWhatPanel, FindBundle.message("find.what.overriding.methods.checkbox"), - KotlinBundleIndependent.message("find.declaration.overriding.methods.checkbox") + KotlinBundle.message("find.declaration.overriding.methods.checkbox") ); } @@ -91,10 +91,10 @@ public class KotlinFindFunctionUsagesDialog extends FindMethodUsagesDialog { if (!Utils.renameCheckbox( optionsPanel, FindBundle.message("find.options.include.overloaded.methods.checkbox"), - KotlinBundleIndependent.message("find.declaration.include.overloaded.methods.checkbox") + KotlinBundle.message("find.declaration.include.overloaded.methods.checkbox") )) { addCheckboxToPanel( - KotlinBundleIndependent.message("find.declaration.include.overloaded.methods.checkbox"), + KotlinBundle.message("find.declaration.include.overloaded.methods.checkbox"), FindSettings.getInstance().isSearchOverloadedMethods(), optionsPanel, false @@ -110,7 +110,7 @@ public class KotlinFindFunctionUsagesDialog extends FindMethodUsagesDialog { KotlinFunctionFindUsagesOptions options = getFindUsagesOptions(); if (isActual) { expectedUsages = addCheckboxToPanel( - KotlinBundleIndependent.message("find.usages.checkbox.name.expected.functions"), + KotlinBundle.message("find.usages.checkbox.name.expected.functions"), options.getSearchExpected(), optionsPanel, false diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindPropertyUsagesDialog.java b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindPropertyUsagesDialog.java index e2351b8e7f3..cb0742860e8 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindPropertyUsagesDialog.java +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/findUsages/dialogs/KotlinFindPropertyUsagesDialog.java @@ -27,7 +27,7 @@ import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.SimpleColoredComponent; import com.intellij.ui.StateRestoringCheckBox; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.idea.KotlinBundleIndependent; +import org.jetbrains.kotlin.idea.KotlinBundle; import org.jetbrains.kotlin.idea.findUsages.KotlinPropertyFindUsagesOptions; import org.jetbrains.kotlin.lexer.KtTokens; import org.jetbrains.kotlin.psi.*; @@ -85,13 +85,13 @@ public class KotlinFindPropertyUsagesDialog extends JavaFindUsagesDialog protected c private const val DISABLE_ONCE = "DISABLE_ONCE" private const val DISABLE = "DISABLE" - private val DISABLE_COMPONENT_AND_DESTRUCTION_SEARCH_TEXT = KotlinBundleIndependent.message( + private val DISABLE_COMPONENT_AND_DESTRUCTION_SEARCH_TEXT = KotlinBundle.message( "find.usages.text.find.usages.for.data.class.components.and.destruction.declarations", DISABLE_ONCE, DISABLE diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt index a40ffb4fa6a..d3102c3dcb7 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.idea.KotlinBundleIndependent +import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType @@ -21,8 +21,8 @@ class ChangeVariableMutabilityFix( ) : KotlinPsiOnlyQuickFixAction(element) { override fun getText() = actionText - ?: (if (makeVar) KotlinBundleIndependent.message("change.to.var") else KotlinBundleIndependent.message("change.to.val")) + - if (deleteInitializer) KotlinBundleIndependent.message("and.delete.initializer") else "" + ?: (if (makeVar) KotlinBundle.message("change.to.var") else KotlinBundle.message("change.to.val")) + + if (deleteInitializer) KotlinBundle.message("and.delete.initializer") else "" override fun getFamilyName(): String = text diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt index 21d1c90a84b..334b64845d7 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt @@ -11,7 +11,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.psi.PsiNameIdentifierOwner import com.intellij.psi.util.PsiTreeUtil -import org.jetbrains.kotlin.idea.KotlinBundleIndependent +import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* @@ -28,15 +28,15 @@ class RemoveModifierFix( val modifierText = modifier.value when { isRedundant -> - KotlinBundleIndependent.message("remove.redundant.0.modifier", modifierText) + KotlinBundle.message("remove.redundant.0.modifier", modifierText) modifier === KtTokens.ABSTRACT_KEYWORD || modifier === KtTokens.OPEN_KEYWORD -> - KotlinBundleIndependent.message("make.0.not.1", getElementName(element), modifierText) + KotlinBundle.message("make.0.not.1", getElementName(element), modifierText) else -> - KotlinBundleIndependent.message("remove.0.modifier", modifierText, modifier) + KotlinBundle.message("remove.0.modifier", modifierText, modifier) } } - override fun getFamilyName() = KotlinBundleIndependent.message("remove.modifier") + override fun getFamilyName() = KotlinBundle.message("remove.modifier") override fun getText() = text diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/search/usagesSearch/operators/OperatorReferenceSearcher.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/search/usagesSearch/operators/OperatorReferenceSearcher.kt index 4f794c0d68f..8261a4a10de 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/search/usagesSearch/operators/OperatorReferenceSearcher.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/search/usagesSearch/operators/OperatorReferenceSearcher.kt @@ -12,8 +12,8 @@ import com.intellij.psi.search.* import com.intellij.util.Processor import org.jetbrains.kotlin.asJava.elements.KtLightMethod import org.jetbrains.kotlin.asJava.namedUnwrappedElement +import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.KotlinFileType -import org.jetbrains.kotlin.idea.KotlinIdeaAnalysisBundleIndependent import org.jetbrains.kotlin.idea.search.KotlinSearchUsagesSupport.Companion.forceResolveReferences import org.jetbrains.kotlin.idea.search.KotlinSearchUsagesSupport.Companion.getReceiverTypeSearcherInfo import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinReferencesSearchOptions @@ -275,7 +275,7 @@ abstract class OperatorReferenceSearcher( // we must unwrap progress indicator because ProgressWrapper does not do anything on changing text and fraction val progress = ProgressWrapper.unwrap(ProgressIndicatorProvider.getGlobalProgressIndicator()) progress?.pushState() - progress?.text = KotlinIdeaAnalysisBundleIndependent.message("searching.for.implicit.usages") + progress?.text = KotlinBundle.message("searching.for.implicit.usages") try { val files = runReadAction { FileTypeIndex.getFiles(KotlinFileType.INSTANCE, scope) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt index 546c39a2a5f..779f7c39154 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeVariableMutabilityFix.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1 import org.jetbrains.kotlin.diagnostics.Errors -import org.jetbrains.kotlin.idea.KotlinBundleIndependent +import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.CreatePropertyDelegateAccessorsActionFactory import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtProperty @@ -55,6 +55,6 @@ object DelegatedPropertyValFactory : KotlinSingleIntentionActionFactory() { val property = element.getStrictParentOfType() ?: return null val info = CreatePropertyDelegateAccessorsActionFactory.extractFixData(property, diagnostic).singleOrNull() ?: return null if (info.name != OperatorNameConventions.SET_VALUE.asString()) return null - return ChangeVariableMutabilityFix(property, makeVar = false, actionText = KotlinBundleIndependent.message("change.to.val")) + return ChangeVariableMutabilityFix(property, makeVar = false, actionText = KotlinBundle.message("change.to.val")) } } \ No newline at end of file From c13889c2ea28b38675a5477a17f33f7ed9e1b4af Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 11 Feb 2021 16:35:19 +0100 Subject: [PATCH 183/368] FIR: add ability to specify checkers list for checker components --- .../kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt | 10 +++++++--- .../ControlFlowAnalysisDiagnosticComponent.kt | 9 +++++++-- .../DeclarationCheckersDiagnosticComponent.kt | 5 +++-- .../ExpressionCheckersDiagnosticComponent.kt | 7 +++++-- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt index 3ec3775b576..9c2fb40cf1b 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirControlFlowAnalyzer.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.analysis.cfa import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.declaration.DeclarationCheckers import org.jetbrains.kotlin.fir.analysis.checkersComponent import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.declarations.FirClass @@ -15,9 +16,12 @@ import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirPropertyAccessor import org.jetbrains.kotlin.fir.resolve.dfa.cfg.ControlFlowGraph -class FirControlFlowAnalyzer(session: FirSession) { - private val cfaCheckers = session.checkersComponent.declarationCheckers.controlFlowAnalyserCheckers - private val variableAssignmentCheckers = session.checkersComponent.declarationCheckers.variableAssignmentCfaBasedCheckers +class FirControlFlowAnalyzer( + session: FirSession, + declarationCheckers: DeclarationCheckers = session.checkersComponent.declarationCheckers +) { + private val cfaCheckers = declarationCheckers.controlFlowAnalyserCheckers + private val variableAssignmentCheckers = declarationCheckers.variableAssignmentCfaBasedCheckers // Currently declaration in analyzeXXX is not used, but it may be useful in future @Suppress("UNUSED_PARAMETER") diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ControlFlowAnalysisDiagnosticComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ControlFlowAnalysisDiagnosticComponent.kt index c98d9a403ca..9cbe152f45b 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ControlFlowAnalysisDiagnosticComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ControlFlowAnalysisDiagnosticComponent.kt @@ -7,13 +7,18 @@ package org.jetbrains.kotlin.fir.analysis.collectors.components import org.jetbrains.kotlin.fir.analysis.cfa.FirControlFlowAnalyzer import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.declaration.DeclarationCheckers +import org.jetbrains.kotlin.fir.analysis.checkersComponent import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.resolve.dfa.controlFlowGraph -class ControlFlowAnalysisDiagnosticComponent(collector: AbstractDiagnosticCollector) : AbstractDiagnosticCollectorComponent(collector) { - private val controlFlowAnalyzer = FirControlFlowAnalyzer(session) +class ControlFlowAnalysisDiagnosticComponent( + collector: AbstractDiagnosticCollector, + declarationCheckers: DeclarationCheckers = collector.session.checkersComponent.declarationCheckers, +) : AbstractDiagnosticCollectorComponent(collector) { + private val controlFlowAnalyzer = FirControlFlowAnalyzer(session, declarationCheckers) // ------------------------------- Class initializer ------------------------------- diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt index 68d8ef88dee..0f81cec82c0 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.analysis.collectors.components import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.declaration.DeclarationCheckers import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirDeclarationChecker import org.jetbrains.kotlin.fir.analysis.checkersComponent import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector @@ -13,9 +14,9 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.declarations.* class DeclarationCheckersDiagnosticComponent( - collector: AbstractDiagnosticCollector + collector: AbstractDiagnosticCollector, + private val checkers: DeclarationCheckers = collector.session.checkersComponent.declarationCheckers, ) : AbstractDiagnosticCollectorComponent(collector) { - private val checkers = session.checkersComponent.declarationCheckers override fun visitFile(file: FirFile, data: CheckerContext) { checkers.fileCheckers.check(file, data, reporter) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ExpressionCheckersDiagnosticComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ExpressionCheckersDiagnosticComponent.kt index ba53b856b84..c8138ca5bbc 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ExpressionCheckersDiagnosticComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ExpressionCheckersDiagnosticComponent.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.analysis.collectors.components import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.expression.ExpressionCheckers import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirExpressionChecker import org.jetbrains.kotlin.fir.analysis.checkersComponent import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector @@ -13,8 +14,10 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.expressions.* -class ExpressionCheckersDiagnosticComponent(collector: AbstractDiagnosticCollector) : AbstractDiagnosticCollectorComponent(collector) { - private val checkers = session.checkersComponent.expressionCheckers +class ExpressionCheckersDiagnosticComponent( + collector: AbstractDiagnosticCollector, + private val checkers: ExpressionCheckers = collector.session.checkersComponent.expressionCheckers, +) : AbstractDiagnosticCollectorComponent(collector) { override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction, data: CheckerContext) { checkers.basicExpressionCheckers.check(anonymousFunction, data, reporter) From b9a4613e44e66066d2516c4f5fe9b4b4d440ab7a Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 11 Feb 2021 16:40:37 +0100 Subject: [PATCH 184/368] FIR IDE: remove getMessage from HLPresentation as it duplicates HLApplicator.getActionName --- .../idea/fir/api/AbstractHLInspection.kt | 2 +- .../idea/fir/api/applicator/HLApplicator.kt | 4 ++++ .../idea/fir/api/applicator/HLPresentation.kt | 23 +------------------ .../HLRedundantUnitReturnTypeInspection.kt | 4 ++-- 4 files changed, 8 insertions(+), 25 deletions(-) diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/AbstractHLInspection.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/AbstractHLInspection.kt index 8523de2ce30..bd820d5c685 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/AbstractHLInspection.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/AbstractHLInspection.kt @@ -54,7 +54,7 @@ abstract class AbstractHLInspection( val highlightType = presentation.getHighlightType(element) if (!isOnTheFly && highlightType == ProblemHighlightType.INFORMATION) return - val description = presentation.getMessage(element) + val description = applicator.getActionName(element, input) val fix = applicator.asLocalQuickFix(input, actionName = applicator.getActionName(element, input)) ranges.forEach { range -> diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/applicator/HLApplicator.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/applicator/HLApplicator.kt index 66b62a51a9d..a89468bf2b5 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/applicator/HLApplicator.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/applicator/HLApplicator.kt @@ -138,6 +138,10 @@ class HLApplicatorBuilder internal this.getActionName = getActionName } + fun actionName(getActionName: () -> String) { + this.getActionName = { _, _ -> getActionName() } + } + @OptIn(PrivateForInline::class) fun applyTo(doApply: (PSI, INPUT, Project?, Editor?) -> Unit) { applyTo = doApply diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/applicator/HLPresentation.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/applicator/HLPresentation.kt index 970298d56d3..4c7047f11fb 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/applicator/HLPresentation.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/applicator/HLPresentation.kt @@ -11,36 +11,25 @@ import org.jetbrains.kotlin.idea.frontend.api.ForbidKtResolve /** * Provides a presentation to display an message in the editor which may be latter fixed by [HLApplicator] - * Used by [org.jetbrains.kotlin.idea.fir.api.AbstractHLInspection] to provide higlighting message and type */ sealed class HLPresentation { fun getHighlightType(element: PSI): ProblemHighlightType = ForbidKtResolve.forbidResolveIn("HLPresentation.getHighlightType") { getHighlightTypeImpl(element) } - fun getMessage(element: PSI): String = ForbidKtResolve.forbidResolveIn("HLPresentation.getMessage") { - getMessageImpl(element) - } - - abstract fun getMessageImpl(element: PSI): String abstract fun getHighlightTypeImpl(element: PSI): ProblemHighlightType } private class HLPresentationImpl( private val getHighlightType: (element: PSI) -> ProblemHighlightType, - private val getMessage: (element: PSI) -> String, ) : HLPresentation() { override fun getHighlightTypeImpl(element: PSI): ProblemHighlightType = getHighlightType.invoke(element) - - override fun getMessageImpl(element: PSI): String = - getMessage.invoke(element) } class HLInspectionPresentationProviderBuilder internal constructor() { private var getHighlightType: ((element: PSI) -> ProblemHighlightType)? = null - private var getMessage: ((element: PSI) -> String)? = null fun highlightType(getType: (element: PSI) -> ProblemHighlightType) { getHighlightType = getType @@ -50,20 +39,10 @@ class HLInspectionPresentationProviderBuilder internal constru getHighlightType = { type } } - fun inspectionText(getText: (element: PSI) -> String) { - getMessage = getText - } - - fun inspectionText(text: String) { - getMessage = { text } - } - internal fun build(): HLPresentation { val getHighlightType = getHighlightType ?: error("Please, provide highlightType") - val getMessage = getMessage - ?: error("Please, provide getMessage") - return HLPresentationImpl(getHighlightType, getMessage) + return HLPresentationImpl(getHighlightType) } } diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/declarations/HLRedundantUnitReturnTypeInspection.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/declarations/HLRedundantUnitReturnTypeInspection.kt index 3981b5f3b08..0611d9c890c 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/declarations/HLRedundantUnitReturnTypeInspection.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/declarations/HLRedundantUnitReturnTypeInspection.kt @@ -29,7 +29,8 @@ internal class HLRedundantUnitReturnTypeInspection : val function = callable as? KtNamedFunction ?: return@isApplicableByPsi false function.hasBlockBody() && function.typeReference != null } - familyAndActionName(KotlinBundle.lazyMessage("remove.explicit.type.specification")) + familyName(KotlinBundle.lazyMessage("remove.explicit.type.specification")) + actionName(KotlinBundle.lazyMessage("redundant.unit.return.type")) } override val inputProvider = inputProvider { function -> @@ -40,7 +41,6 @@ internal class HLRedundantUnitReturnTypeInspection : } override val presentation = presentation { - inspectionText(KotlinBundle.message("redundant.unit.return.type")) highlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL) } } From 7fb6c22889540b1f896e1a45cb052114430b43be Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 11 Feb 2021 16:51:08 +0100 Subject: [PATCH 185/368] FIR IDE: allow creating inspections by extended checkers --- .../AbstractHLDiagnosticBasedInspection.kt | 31 ++++ .../fir/api/HLInputByDiagnosticProvider.kt | 27 ++++ ...tlinHighLevelDiagnosticHighlightingPass.kt | 3 +- .../idea/frontend/api/KtAnalysisSession.kt | 7 +- .../api/components/KtDiagnosticProvider.kt | 10 +- .../api/FirModuleResolveStateForCompletion.kt | 6 +- .../level/api/FirModuleResolveStateImpl.kt | 11 +- .../level/api/api/DiagnosticCheckerFilter.kt | 12 ++ .../level/api/api/FirModuleResolveState.kt | 4 +- .../low/level/api/api/LowLevelFirApiFacade.kt | 27 ++-- .../AbstractFirIdeDiagnosticsCollector.kt | 51 +++++-- .../api/diagnostics/DiagnosticsCollector.kt | 10 +- .../FileStructureElementDiagnosticList.kt | 17 +++ ...FileStructureElementDiagnosticRetriever.kt | 12 ++ .../FileStructureElementDiagnostics.kt | 45 ++++++ ...ileStructureElementDiagnosticsCollector.kt | 61 ++++++++ .../FirIdeFileDiagnosticsCollector.kt | 7 +- ...IdeStructureElementDiagnosticsCollector.kt | 78 ---------- .../level/api/file/structure/FileStructure.kt | 16 ++- .../file/structure/FileStructureElement.kt | 136 ++++++++++-------- .../FileStructureElementDiagnosticList.kt | 7 + ...FileStructureElementDiagnosticRetriever.kt | 7 + .../FileStructureElementDiagnostics.kt | 7 + .../api/sessions/FirIdeSessionFactory.kt | 3 +- 24 files changed, 413 insertions(+), 182 deletions(-) create mode 100644 idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/AbstractHLDiagnosticBasedInspection.kt create mode 100644 idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/HLInputByDiagnosticProvider.kt create mode 100644 idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/DiagnosticCheckerFilter.kt create mode 100644 idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticList.kt create mode 100644 idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticRetriever.kt create mode 100644 idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnostics.kt create mode 100644 idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticsCollector.kt delete mode 100644 idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FirIdeStructureElementDiagnosticsCollector.kt create mode 100644 idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnosticList.kt create mode 100644 idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnosticRetriever.kt create mode 100644 idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnostics.kt diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/AbstractHLDiagnosticBasedInspection.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/AbstractHLDiagnosticBasedInspection.kt new file mode 100644 index 00000000000..ded580e5fbb --- /dev/null +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/AbstractHLDiagnosticBasedInspection.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2021 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.idea.fir.api + +import org.jetbrains.kotlin.idea.fir.api.applicator.HLApplicatorInput +import org.jetbrains.kotlin.idea.fir.api.applicator.HLApplicatorInputProvider +import org.jetbrains.kotlin.idea.fir.api.applicator.inputProvider +import org.jetbrains.kotlin.idea.frontend.api.components.KtDiagnosticCheckerFilter +import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi +import org.jetbrains.kotlin.psi.KtElement +import kotlin.reflect.KClass + +abstract class AbstractHLDiagnosticBasedInspection, INPUT : HLApplicatorInput>( + elementType: KClass, + private val diagnosticType: KClass, +) : AbstractHLInspection(elementType) { + abstract val inputByDiagnosticProvider: HLInputByDiagnosticProvider + + final override val inputProvider: HLApplicatorInputProvider = inputProvider { psi -> + val diagnostics = psi.getDiagnostics(KtDiagnosticCheckerFilter.ONLY_EXTENDED_CHECKERS) + val suitableDiagnostics = diagnostics.filterIsInstance(diagnosticType.java) + val diagnostic = suitableDiagnostics.firstOrNull() ?: return@inputProvider null + // TODO handle case with multiple diagnostics on single element + with(inputByDiagnosticProvider) { createInfo(diagnostic) } + } +} + + diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/HLInputByDiagnosticProvider.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/HLInputByDiagnosticProvider.kt new file mode 100644 index 00000000000..eb069c0018a --- /dev/null +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/HLInputByDiagnosticProvider.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2021 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.idea.fir.api + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.idea.fir.api.applicator.HLApplicatorInput +import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession +import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi + +sealed class HLInputByDiagnosticProvider, INPUT : HLApplicatorInput> { + abstract fun KtAnalysisSession.createInfo(diagnostic: DIAGNOSTIC): INPUT? +} + +private class HLInputByDiagnosticProviderImpl, INPUT : HLApplicatorInput>( + private val createInfo: KtAnalysisSession.(DIAGNOSTIC) -> INPUT? +) : HLInputByDiagnosticProvider() { + override fun KtAnalysisSession.createInfo(diagnostic: DIAGNOSTIC): INPUT? = + createInfo.invoke(this, diagnostic) +} + +fun , INPUT : HLApplicatorInput> inputByDiagnosticProvider( + createInfo: KtAnalysisSession.(DIAGNOSTIC) -> INPUT? +): HLInputByDiagnosticProvider = + HLInputByDiagnosticProviderImpl(createInfo) \ No newline at end of file diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/highlighter/KotlinHighLevelDiagnosticHighlightingPass.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/highlighter/KotlinHighLevelDiagnosticHighlightingPass.kt index cb70641cb23..bf7a6da0605 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/highlighter/KotlinHighLevelDiagnosticHighlightingPass.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/highlighter/KotlinHighLevelDiagnosticHighlightingPass.kt @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi import org.jetbrains.kotlin.idea.frontend.api.diagnostics.getDefaultMessageWithFactoryName import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixService +import org.jetbrains.kotlin.idea.frontend.api.components.KtDiagnosticCheckerFilter import org.jetbrains.kotlin.psi.KtFile class KotlinHighLevelDiagnosticHighlightingPass( @@ -43,7 +44,7 @@ class KotlinHighLevelDiagnosticHighlightingPass( override fun doCollectInformation(progress: ProgressIndicator) { analyze(ktFile) { - ktFile.collectDiagnosticsForFile().forEach { diagnostic -> + ktFile.collectDiagnosticsForFile(KtDiagnosticCheckerFilter.ONLY_COMMON_CHECKERS).forEach { diagnostic -> addDiagnostic(diagnostic) } } diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt index cf643ccf248..147134cb497 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* +import kotlin.reflect.KClass /** * The entry point into all frontend-related work. Has the following contracts: @@ -91,9 +92,11 @@ abstract class KtAnalysisSession(final override val token: ValidityToken) : Vali fun KtClassOrObjectSymbol.buildSelfClassType(): KtType = typeProvider.buildSelfClassType(this) - fun KtElement.getDiagnostics(): Collection = diagnosticProvider.getDiagnosticsForElement(this) + fun KtElement.getDiagnostics(filter: KtDiagnosticCheckerFilter): Collection = + diagnosticProvider.getDiagnosticsForElement(this, filter) - fun KtFile.collectDiagnosticsForFile(): Collection> = diagnosticProvider.collectDiagnosticsForFile(this) + fun KtFile.collectDiagnosticsForFile(filter: KtDiagnosticCheckerFilter): Collection> = + diagnosticProvider.collectDiagnosticsForFile(this, filter) fun KtSymbolWithKind.getContainingSymbol(): KtSymbolWithKind? = containingDeclarationProvider.getContainingDeclaration(this) diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt index 045d09f02ff..7964d4e3c17 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt @@ -10,6 +10,12 @@ import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile abstract class KtDiagnosticProvider : KtAnalysisSessionComponent() { - abstract fun getDiagnosticsForElement(element: KtElement): Collection> - abstract fun collectDiagnosticsForFile(ktFile: KtFile): Collection> + abstract fun getDiagnosticsForElement(element: KtElement, filter: KtDiagnosticCheckerFilter): Collection> + abstract fun collectDiagnosticsForFile(ktFile: KtFile, filter: KtDiagnosticCheckerFilter): Collection> } + +enum class KtDiagnosticCheckerFilter { + ONLY_COMMON_CHECKERS, + ONLY_EXTENDED_CHECKERS, + EXTENDED_AND_COMMON_CHECKERS, +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirModuleResolveStateForCompletion.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirModuleResolveStateForCompletion.kt index b72b9f4ebf6..0b120d530d9 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirModuleResolveStateForCompletion.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirModuleResolveStateForCompletion.kt @@ -17,11 +17,13 @@ import org.jetbrains.kotlin.fir.resolve.FirTowerDataContext import org.jetbrains.kotlin.fir.resolve.providers.FirProvider import org.jetbrains.kotlin.idea.caches.project.IdeaModuleInfo import org.jetbrains.kotlin.idea.fir.low.level.api.annotations.InternalForInline +import org.jetbrains.kotlin.idea.fir.low.level.api.api.DiagnosticCheckerFilter import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirModuleResolveState import org.jetbrains.kotlin.idea.fir.low.level.api.file.builder.ModuleFileCache import org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FirElementsRecorder import org.jetbrains.kotlin.idea.fir.low.level.api.util.containingKtFileIfAny import org.jetbrains.kotlin.idea.fir.low.level.api.util.originalKtFile +import org.jetbrains.kotlin.idea.frontend.api.components.KtDiagnosticCheckerFilter import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile @@ -84,11 +86,11 @@ internal class FirModuleResolveStateForCompletion( } - override fun getDiagnostics(element: KtElement): List> { + override fun getDiagnostics(element: KtElement, filter: DiagnosticCheckerFilter): List> { error("Diagnostics should not be retrieved in completion") } - override fun collectDiagnosticsForFile(ktFile: KtFile): Collection> { + override fun collectDiagnosticsForFile(ktFile: KtFile, filter: DiagnosticCheckerFilter): Collection> { error("Diagnostics should not be retrieved in completion") } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirModuleResolveStateImpl.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirModuleResolveStateImpl.kt index 874301b35d0..5e2e9b90345 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirModuleResolveStateImpl.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirModuleResolveStateImpl.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.idea.caches.project.IdeaModuleInfo import org.jetbrains.kotlin.idea.caches.project.ModuleSourceInfo import org.jetbrains.kotlin.idea.caches.project.getModuleInfo import org.jetbrains.kotlin.idea.fir.low.level.api.annotations.InternalForInline +import org.jetbrains.kotlin.idea.fir.low.level.api.api.DiagnosticCheckerFilter import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirModuleResolveState import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostics.DiagnosticsCollector import org.jetbrains.kotlin.idea.fir.low.level.api.element.builder.FirElementBuilder @@ -69,11 +70,11 @@ internal class FirModuleResolveStateImpl( override fun getFirFile(ktFile: KtFile): FirFile = firFileBuilder.buildRawFirFileWithCaching(ktFile, rootModuleSession.cache, lazyBodiesMode = false) - override fun getDiagnostics(element: KtElement): List> = - diagnosticsCollector.getDiagnosticsFor(element) + override fun getDiagnostics(element: KtElement, filter: DiagnosticCheckerFilter): List> = + diagnosticsCollector.getDiagnosticsFor(element, filter) - override fun collectDiagnosticsForFile(ktFile: KtFile): Collection> = - diagnosticsCollector.collectDiagnosticsForFile(ktFile) + override fun collectDiagnosticsForFile(ktFile: KtFile, filter: DiagnosticCheckerFilter): Collection> = + diagnosticsCollector.collectDiagnosticsForFile(ktFile, filter) override fun getBuiltFirFileOrNull(ktFile: KtFile): FirFile? { val cache = sessionProvider.getModuleCache(ktFile.getModuleInfo() as ModuleSourceInfo) @@ -119,7 +120,7 @@ internal class FirModuleResolveStateImpl( container, cache, FirResolvePhase.BODY_RESOLVE, - checkPCE = false /*TODO*/, + checkPCE = false, /*TODO*/ towerDataContextCollector = collector, ) } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/DiagnosticCheckerFilter.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/DiagnosticCheckerFilter.kt new file mode 100644 index 00000000000..bc7d1fcdc34 --- /dev/null +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/DiagnosticCheckerFilter.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2010-2021 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.idea.fir.low.level.api.api + +enum class DiagnosticCheckerFilter(val runCommonCheckers: Boolean, val runExtendedCheckers: Boolean) { + ONLY_COMMON_CHECKERS(runCommonCheckers = true, runExtendedCheckers = false), + ONLY_EXTENDED_CHECKERS(runCommonCheckers = false, runExtendedCheckers = true), + EXTENDED_AND_COMMON_CHECKERS(runCommonCheckers = true, runExtendedCheckers = true), +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/FirModuleResolveState.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/FirModuleResolveState.kt index 07112416bba..2c842d4d156 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/FirModuleResolveState.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/FirModuleResolveState.kt @@ -37,9 +37,9 @@ abstract class FirModuleResolveState { internal abstract fun isFirFileBuilt(ktFile: KtFile): Boolean - internal abstract fun getDiagnostics(element: KtElement): List> + internal abstract fun getDiagnostics(element: KtElement, filter: DiagnosticCheckerFilter): List> - internal abstract fun collectDiagnosticsForFile(ktFile: KtFile): Collection> + internal abstract fun collectDiagnosticsForFile(ktFile: KtFile, filter: DiagnosticCheckerFilter): Collection> @TestOnly internal abstract fun getBuiltFirFileOrNull(ktFile: KtFile): FirFile? diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/LowLevelFirApiFacade.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/LowLevelFirApiFacade.kt index 5823adde819..b471486dc03 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/LowLevelFirApiFacade.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/api/LowLevelFirApiFacade.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.api -import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic import org.jetbrains.kotlin.fir.declarations.* @@ -17,7 +16,6 @@ import org.jetbrains.kotlin.idea.caches.project.getModuleInfo import org.jetbrains.kotlin.idea.fir.low.level.api.FirIdeResolveStateService import org.jetbrains.kotlin.idea.fir.low.level.api.annotations.InternalForInline import org.jetbrains.kotlin.idea.fir.low.level.api.sessions.FirIdeSourcesSession -import org.jetbrains.kotlin.idea.fir.low.level.api.util.ktDeclaration import org.jetbrains.kotlin.idea.util.getElementTextInContext import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtElement @@ -76,13 +74,13 @@ inline fun KtDeclaration.withFirDeclarationOfTyp } /** -* Creates [FirDeclaration] by [KtLambdaExpression] and executes an [action] on it -* -* If resulted [FirDeclaration] is not [F] throws [InvalidFirElementTypeException] -* -* [FirDeclaration] passed to [action] should not be leaked outside [action] lambda -* Otherwise, some threading problems may arise, -*/ + * Creates [FirDeclaration] by [KtLambdaExpression] and executes an [action] on it + * + * If resulted [FirDeclaration] is not [F] throws [InvalidFirElementTypeException] + * + * [FirDeclaration] passed to [action] should not be leaked outside [action] lambda + * Otherwise, some threading problems may arise, + */ @OptIn(InternalForInline::class) inline fun KtLambdaExpression.withFirDeclarationOfType( resolveState: FirModuleResolveState, @@ -121,14 +119,17 @@ fun D.withFirDeclaration( /** * Returns a list of Diagnostics compiler finds for given [KtElement] */ -fun KtElement.getDiagnostics(resolveState: FirModuleResolveState): Collection> = - resolveState.getDiagnostics(this) +fun KtElement.getDiagnostics(resolveState: FirModuleResolveState, filter: DiagnosticCheckerFilter): Collection> = + resolveState.getDiagnostics(this, filter) /** * Returns a list of Diagnostics compiler finds for given [KtFile] */ -fun KtFile.collectDiagnosticsForFile(resolveState: FirModuleResolveState): Collection> = - resolveState.collectDiagnosticsForFile(this) +fun KtFile.collectDiagnosticsForFile( + resolveState: FirModuleResolveState, + filter: DiagnosticCheckerFilter +): Collection> = + resolveState.collectDiagnosticsForFile(this, filter) /** * Resolves a given [FirDeclaration] to [phase] and returns resolved declaration diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/AbstractFirIdeDiagnosticsCollector.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/AbstractFirIdeDiagnosticsCollector.kt index e8015c33fe8..e8d1ecc99b4 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/AbstractFirIdeDiagnosticsCollector.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/AbstractFirIdeDiagnosticsCollector.kt @@ -5,24 +5,33 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.diagnostics -import com.intellij.openapi.diagnostic.Logger -import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.SessionConfiguration +import org.jetbrains.kotlin.fir.analysis.CheckersComponent import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.declaration.DeclarationCheckers +import org.jetbrains.kotlin.fir.analysis.checkers.expression.ExpressionCheckers import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector -import org.jetbrains.kotlin.fir.analysis.collectors.registerAllComponents +import org.jetbrains.kotlin.fir.analysis.collectors.components.ControlFlowAnalysisDiagnosticComponent +import org.jetbrains.kotlin.fir.analysis.collectors.components.DeclarationCheckersDiagnosticComponent +import org.jetbrains.kotlin.fir.analysis.collectors.components.ErrorNodeDiagnosticCollectorComponent +import org.jetbrains.kotlin.fir.analysis.collectors.components.ExpressionCheckersDiagnosticComponent import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic +import org.jetbrains.kotlin.fir.checkers.CommonDeclarationCheckers +import org.jetbrains.kotlin.fir.checkers.CommonExpressionCheckers +import org.jetbrains.kotlin.fir.checkers.ExtendedDeclarationCheckers +import org.jetbrains.kotlin.fir.checkers.ExtendedExpressionCheckers import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.ImplicitBodyResolveComputationSession import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.createReturnTypeCalculatorForIDE import org.jetbrains.kotlin.idea.fir.low.level.api.element.builder.FirIdeDesignatedBodyResolveTransformerForReturnTypeCalculator import org.jetbrains.kotlin.idea.fir.low.level.api.util.checkCanceled -import org.jetbrains.kotlin.psi.KtElement internal abstract class AbstractFirIdeDiagnosticsCollector( session: FirSession, + useExtendedCheckers: Boolean, ) : AbstractDiagnosticCollector( session, returnTypeCalculator = createReturnTypeCalculatorForIDE( @@ -33,7 +42,16 @@ internal abstract class AbstractFirIdeDiagnosticsCollector( ) ) { init { - registerAllComponents() + val declarationCheckers = CheckersFactory.createDeclarationCheckers(useExtendedCheckers) + val expressionCheckers = CheckersFactory.createExpressionCheckers(useExtendedCheckers) + + @Suppress("LeakingThis") + initializeComponents( + DeclarationCheckersDiagnosticComponent(this, declarationCheckers), + ExpressionCheckersDiagnosticComponent(this, expressionCheckers), + ErrorNodeDiagnosticCollectorComponent(this), + ControlFlowAnalysisDiagnosticComponent(this, declarationCheckers), + ) } protected abstract fun onDiagnostic(diagnostic: FirPsiDiagnostic<*>) @@ -60,8 +78,23 @@ internal abstract class AbstractFirIdeDiagnosticsCollector( // Not necessary in IDE return emptyList() } - - companion object { - private val LOG = Logger.getInstance(AbstractFirIdeDiagnosticsCollector::class.java) - } +} + + +private object CheckersFactory { + private val extendedDeclarationCheckers = createDeclarationCheckers(ExtendedDeclarationCheckers) + private val commonDeclarationCheckers = createDeclarationCheckers(CommonDeclarationCheckers) + + fun createDeclarationCheckers(useExtendedCheckers: Boolean): DeclarationCheckers = + if (useExtendedCheckers) extendedDeclarationCheckers else commonDeclarationCheckers + + fun createExpressionCheckers(useExtendedCheckers: Boolean): ExpressionCheckers = + if (useExtendedCheckers) ExtendedExpressionCheckers else CommonExpressionCheckers + + // TODO hack to have all checkers present in DeclarationCheckers.memberDeclarationCheckers and similar + // If use ExtendedDeclarationCheckers directly when DeclarationCheckers.memberDeclarationCheckers will not contain basicDeclarationCheckers + @OptIn(SessionConfiguration::class) + private fun createDeclarationCheckers(declarationCheckers: DeclarationCheckers): DeclarationCheckers = + CheckersComponent().apply { register(declarationCheckers) }.declarationCheckers + } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/DiagnosticsCollector.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/DiagnosticsCollector.kt index 227a091fb15..7b3d7688c0e 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/DiagnosticsCollector.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/DiagnosticsCollector.kt @@ -5,8 +5,8 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.diagnostics -import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic +import org.jetbrains.kotlin.idea.fir.low.level.api.api.DiagnosticCheckerFilter import org.jetbrains.kotlin.idea.fir.low.level.api.file.builder.ModuleFileCache import org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FileStructureCache import org.jetbrains.kotlin.psi.KtElement @@ -16,14 +16,14 @@ internal class DiagnosticsCollector( private val fileStructureCache: FileStructureCache, private val cache: ModuleFileCache, ) { - fun getDiagnosticsFor(element: KtElement): List> = + fun getDiagnosticsFor(element: KtElement, filter: DiagnosticCheckerFilter): List> = fileStructureCache .getFileStructure(element.containingKtFile, cache) .getStructureElementFor(element) - .diagnostics.diagnosticsFor(element) + .diagnostics.diagnosticsFor(filter, element) - fun collectDiagnosticsForFile(ktFile: KtFile): Collection> = + fun collectDiagnosticsForFile(ktFile: KtFile, filter: DiagnosticCheckerFilter): Collection> = fileStructureCache .getFileStructure(ktFile, cache) - .getAllDiagnosticsForFile() + .getAllDiagnosticsForFile(filter) } \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticList.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticList.kt new file mode 100644 index 00000000000..6a6686016df --- /dev/null +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticList.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2021 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.idea.fir.low.level.api.diagnostics + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic + +internal class FileStructureElementDiagnosticList( + private val map: Map>> +) { + fun diagnosticsFor(element: PsiElement): List> = map[element] ?: emptyList() + + inline fun forEach(action: (List>) -> Unit) = map.values.forEach(action) +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticRetriever.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticRetriever.kt new file mode 100644 index 00000000000..3a3874b74f1 --- /dev/null +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticRetriever.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2010-2021 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.idea.fir.low.level.api.diagnostics + +import org.jetbrains.kotlin.fir.declarations.FirFile + +internal abstract class FileStructureElementDiagnosticRetriever { + abstract fun retrieve(firFile: FirFile, collector: FileStructureElementDiagnosticsCollector): FileStructureElementDiagnosticList +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnostics.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnostics.kt new file mode 100644 index 00000000000..ce824bb3554 --- /dev/null +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnostics.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2021 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.idea.fir.low.level.api.diagnostics + +import com.intellij.psi.PsiElement +import com.intellij.util.SmartList +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic +import org.jetbrains.kotlin.fir.declarations.FirFile +import org.jetbrains.kotlin.idea.fir.low.level.api.api.DiagnosticCheckerFilter + +internal class FileStructureElementDiagnostics( + private val firFile: FirFile, + private val retriever: FileStructureElementDiagnosticRetriever +) { + private val diagnosticByCommonCheckers: FileStructureElementDiagnosticList by lazy { + retriever.retrieve(firFile, FileStructureElementDiagnosticsCollector.USUAL_COLLECTOR) + } + + private val diagnosticByExtendedCheckers: FileStructureElementDiagnosticList by lazy { + retriever.retrieve(firFile, FileStructureElementDiagnosticsCollector.EXTENDED_COLLECTOR) + } + + fun diagnosticsFor(filter: DiagnosticCheckerFilter, element: PsiElement): List> = + SmartList>().apply { + if (filter.runCommonCheckers) { + addAll(diagnosticByCommonCheckers.diagnosticsFor(element)) + } + if (filter.runExtendedCheckers) { + addAll(diagnosticByExtendedCheckers.diagnosticsFor(element)) + } + } + + + inline fun forEach(filter: DiagnosticCheckerFilter, action: (List>) -> Unit) { + if (filter.runCommonCheckers) { + diagnosticByCommonCheckers.forEach(action) + } + if (filter.runExtendedCheckers) { + diagnosticByExtendedCheckers.forEach(action) + } + } +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticsCollector.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticsCollector.kt new file mode 100644 index 00000000000..fe3b6e04efe --- /dev/null +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FileStructureElementDiagnosticsCollector.kt @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2020 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.idea.fir.low.level.api.diagnostics + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.analysis.collectors.DiagnosticCollectorDeclarationAction +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirFile +import org.jetbrains.kotlin.idea.fir.low.level.api.util.addValueFor + +internal class FileStructureElementDiagnosticsCollector private constructor(private val useExtendedCheckers: Boolean) { + companion object { + val USUAL_COLLECTOR = FileStructureElementDiagnosticsCollector(useExtendedCheckers = false) + val EXTENDED_COLLECTOR = FileStructureElementDiagnosticsCollector(useExtendedCheckers = true) + } + + fun collectForStructureElement( + firFile: FirFile, + onDeclarationExit: (FirDeclaration) -> Unit = {}, + onDeclarationEnter: (FirDeclaration) -> DiagnosticCollectorDeclarationAction, + ): FileStructureElementDiagnosticList = + FirIdeStructureElementDiagnosticsCollector( + firFile.session, + useExtendedCheckers, + onDeclarationEnter, + onDeclarationExit + ).let { collector -> + collector.collectDiagnostics(firFile) + FileStructureElementDiagnosticList(collector.result) + } + + private class FirIdeStructureElementDiagnosticsCollector( + session: FirSession, + useExtendedCheckers: Boolean, + private val onDeclarationEnter: (FirDeclaration) -> DiagnosticCollectorDeclarationAction, + private val onDeclarationExit: (FirDeclaration) -> Unit + ) : AbstractFirIdeDiagnosticsCollector( + session, + useExtendedCheckers, + ) { + val result = mutableMapOf>>() + + override fun onDiagnostic(diagnostic: FirPsiDiagnostic<*>) { + result.addValueFor(diagnostic.psiElement, diagnostic) + } + + override fun onDeclarationEnter( + declaration: FirDeclaration, + ): DiagnosticCollectorDeclarationAction = + onDeclarationEnter.invoke(declaration) + + override fun onDeclarationExit(declaration: FirDeclaration) { + onDeclarationExit.invoke(declaration) + } + } +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FirIdeFileDiagnosticsCollector.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FirIdeFileDiagnosticsCollector.kt index b75ec1041fd..e3993689532 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FirIdeFileDiagnosticsCollector.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FirIdeFileDiagnosticsCollector.kt @@ -5,15 +5,16 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.diagnostics -import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic import org.jetbrains.kotlin.fir.declarations.FirFile internal class FirIdeFileDiagnosticsCollector private constructor( session: FirSession, + useExtendedCheckers: Boolean, ) : AbstractFirIdeDiagnosticsCollector( session, + useExtendedCheckers, ) { private val result = mutableListOf>() @@ -22,8 +23,8 @@ internal class FirIdeFileDiagnosticsCollector private constructor( } companion object { - fun collectForFile(firFile: FirFile): List> = - FirIdeFileDiagnosticsCollector(firFile.session).let { collector -> + fun collectForFile(firFile: FirFile, useExtendedCheckers: Boolean): List> = + FirIdeFileDiagnosticsCollector(firFile.session, useExtendedCheckers).let { collector -> collector.collectDiagnostics(firFile) collector.result } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FirIdeStructureElementDiagnosticsCollector.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FirIdeStructureElementDiagnosticsCollector.kt deleted file mode 100644 index 4c476d7e156..00000000000 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostics/FirIdeStructureElementDiagnosticsCollector.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2010-2020 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.idea.fir.low.level.api.diagnostics - -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.diagnostics.Diagnostic -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.analysis.collectors.DiagnosticCollectorDeclarationAction -import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic -import org.jetbrains.kotlin.fir.declarations.FirDeclaration -import org.jetbrains.kotlin.fir.declarations.FirFile -import org.jetbrains.kotlin.fir.psi -import org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FileStructureElementDiagnostics -import org.jetbrains.kotlin.idea.fir.low.level.api.util.addValueFor -import org.jetbrains.kotlin.psi.KtAnnotated -import org.jetbrains.kotlin.psi.KtElement - -internal class FirIdeStructureElementDiagnosticsCollector private constructor( - session: FirSession, - private val onDeclarationEnter: (FirDeclaration) -> DiagnosticCollectorDeclarationAction, - private val onDeclarationExit: (FirDeclaration) -> Unit -) : AbstractFirIdeDiagnosticsCollector( - session, -) { - private val result = mutableMapOf>>() - - override fun onDiagnostic(diagnostic: FirPsiDiagnostic<*>) { - result.addValueFor(diagnostic.psiElement, diagnostic) - } - - override fun onDeclarationEnter( - declaration: FirDeclaration, - ): DiagnosticCollectorDeclarationAction = - onDeclarationEnter.invoke(declaration) - - override fun onDeclarationExit(declaration: FirDeclaration) { - onDeclarationExit.invoke(declaration) - } - - - companion object { - fun collectForStructureElement( - firFile: FirFile, - onDeclarationExit: (FirDeclaration) -> Unit = {}, - onDeclarationEnter: (FirDeclaration) -> DiagnosticCollectorDeclarationAction, - ): FileStructureElementDiagnostics = - FirIdeStructureElementDiagnosticsCollector(firFile.session, onDeclarationEnter, onDeclarationExit).let { collector -> - collector.collectDiagnostics(firFile) - FileStructureElementDiagnostics(collector.result) - } - - fun collectForSingleDeclaration(firFile: FirFile, declaration: FirDeclaration): FileStructureElementDiagnostics { - var inCurrentDeclaration = false - - return collectForStructureElement( - firFile, - onDeclarationEnter = { firDeclaration -> - when { - firDeclaration == declaration -> { - inCurrentDeclaration = true - DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_CHECK_NESTED - } - inCurrentDeclaration -> DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_CHECK_NESTED - else -> DiagnosticCollectorDeclarationAction.SKIP_CURRENT_DECLARATION_AND_CHECK_NESTED - } - }, - onDeclarationExit = { firDeclaration -> - if (declaration == firDeclaration) { - inCurrentDeclaration = false - } - } - ) - } - } -} diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructure.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructure.kt index fdcf235546d..7b8362dfda2 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructure.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructure.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirResolvePhase +import org.jetbrains.kotlin.idea.fir.low.level.api.api.DiagnosticCheckerFilter import org.jetbrains.kotlin.idea.fir.low.level.api.element.builder.FirTowerDataContextCollector import org.jetbrains.kotlin.idea.fir.low.level.api.element.builder.getNonLocalContainingOrThisDeclaration import org.jetbrains.kotlin.idea.fir.low.level.api.file.builder.FirFileBuilder @@ -56,10 +57,21 @@ internal class FileStructure( } @OptIn(ExperimentalStdlibApi::class) - fun getAllDiagnosticsForFile(): Collection> { + fun getAllDiagnosticsForFile(diagnosticCheckerFilter: DiagnosticCheckerFilter): Collection> { val structureElements = getAllStructureElements() return buildSet { - structureElements.forEach { it.diagnostics.forEach { diagnostics -> addAll(diagnostics) } } + collectDiagnosticsFromStructureElements(structureElements, diagnosticCheckerFilter) + } + } + + private fun MutableSet>.collectDiagnosticsFromStructureElements( + structureElements: Collection, + diagnosticCheckerFilter: DiagnosticCheckerFilter + ) { + structureElements.forEach { structureElement -> + structureElement.diagnostics.forEach(diagnosticCheckerFilter) { diagnostics -> + addAll(diagnostics) + } } } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElement.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElement.kt index 6d4722b34b4..24c68a085d9 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElement.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElement.kt @@ -5,18 +5,17 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.file.structure -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.analysis.collectors.DiagnosticCollectorDeclarationAction -import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic -import org.jetbrains.kotlin.fir.containingClass import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.psi import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol -import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostics.FirIdeStructureElementDiagnosticsCollector +import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostics.FileStructureElementDiagnosticList +import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostics.FileStructureElementDiagnosticRetriever +import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostics.FileStructureElementDiagnostics +import org.jetbrains.kotlin.idea.fir.low.level.api.diagnostics.FileStructureElementDiagnosticsCollector import org.jetbrains.kotlin.idea.fir.low.level.api.file.builder.ModuleFileCache import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyDeclarationResolver import org.jetbrains.kotlin.idea.fir.low.level.api.providers.FirIdeProvider @@ -25,22 +24,13 @@ import org.jetbrains.kotlin.idea.fir.low.level.api.util.isGeneratedDeclaration import org.jetbrains.kotlin.idea.fir.low.level.api.util.ktDeclaration import org.jetbrains.kotlin.psi.* -internal class FileStructureElementDiagnostics( - private val map: Map>> -) { - fun diagnosticsFor(element: PsiElement): List> = map[element] ?: emptyList() - - inline fun forEach(action: (List>) -> Unit) = map.values.forEach(action) -} - -internal sealed class FileStructureElement { - abstract val firFile: FirFile +internal sealed class FileStructureElement(val firFile: FirFile) { abstract val psi: KtAnnotated abstract val mappings: Map abstract val diagnostics: FileStructureElementDiagnostics } -internal sealed class ReanalyzableStructureElement : FileStructureElement() { +internal sealed class ReanalyzableStructureElement(firFile: FirFile) : FileStructureElement(firFile) { abstract override val psi: KtDeclaration abstract val firSymbol: AbstractFirBasedSymbol<*> abstract val timestamp: Long @@ -58,8 +48,31 @@ internal sealed class ReanalyzableStructureElement : FileStr fun isUpToDate(): Boolean = psi.getModificationStamp() == timestamp - override val diagnostics: FileStructureElementDiagnostics by lazy { - FirIdeStructureElementDiagnosticsCollector.collectForSingleDeclaration(firFile, firSymbol.fir as FirDeclaration) + override val diagnostics = FileStructureElementDiagnostics(firFile, FileStructureElementSingleDeclarationDiagnosticRetriever()) + + inner class FileStructureElementSingleDeclarationDiagnosticRetriever : FileStructureElementDiagnosticRetriever() { + override fun retrieve(firFile: FirFile, collector: FileStructureElementDiagnosticsCollector): FileStructureElementDiagnosticList { + var inCurrentDeclaration = false + val declaration = firSymbol.fir as FirDeclaration + return collector.collectForStructureElement( + firFile, + onDeclarationEnter = { firDeclaration -> + when { + firDeclaration == declaration -> { + inCurrentDeclaration = true + DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_CHECK_NESTED + } + inCurrentDeclaration -> DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_CHECK_NESTED + else -> DiagnosticCollectorDeclarationAction.SKIP_CURRENT_DECLARATION_AND_CHECK_NESTED + } + }, + onDeclarationExit = { firDeclaration -> + if (declaration == firDeclaration) { + inCurrentDeclaration = false + } + } + ) + } } companion object { @@ -68,11 +81,11 @@ internal sealed class ReanalyzableStructureElement : FileStr } internal class ReanalyzableFunctionStructureElement( - override val firFile: FirFile, + firFile: FirFile, override val psi: KtNamedFunction, override val firSymbol: FirFunctionSymbol<*>, override val timestamp: Long -) : ReanalyzableStructureElement() { +) : ReanalyzableStructureElement(firFile) { override val mappings: Map = FirElementsRecorder.recordElementsFrom(firSymbol.fir, recorder) @@ -106,11 +119,11 @@ internal class ReanalyzableFunctionStructureElement( } internal class ReanalyzablePropertyStructureElement( - override val firFile: FirFile, + firFile: FirFile, override val psi: KtProperty, override val firSymbol: FirPropertySymbol, override val timestamp: Long -) : ReanalyzableStructureElement() { +) : ReanalyzableStructureElement(firFile) { override val mappings: Map = FirElementsRecorder.recordElementsFrom(firSymbol.fir, recorder) @@ -144,42 +157,47 @@ internal class ReanalyzablePropertyStructureElement( } internal class NonReanalyzableDeclarationStructureElement( - override val firFile: FirFile, - fir: FirDeclaration, + firFile: FirFile, + private val fir: FirDeclaration, override val psi: KtDeclaration, -) : FileStructureElement() { +) : FileStructureElement(firFile) { override val mappings: Map = FirElementsRecorder.recordElementsFrom(fir, recorder) - override val diagnostics: FileStructureElementDiagnostics by lazy { - var inCurrentDeclaration = false - FirIdeStructureElementDiagnosticsCollector.collectForStructureElement( - firFile, - onDeclarationEnter = { firDeclaration -> - when { - firDeclaration.isGeneratedDeclaration -> DiagnosticCollectorDeclarationAction.SKIP - firDeclaration is FirFile -> DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_CHECK_NESTED - firDeclaration == fir -> { - inCurrentDeclaration = true - DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_CHECK_NESTED + override val diagnostics = FileStructureElementDiagnostics(firFile, DiagnosticRetriever()) + + private inner class DiagnosticRetriever : FileStructureElementDiagnosticRetriever() { + override fun retrieve(firFile: FirFile, collector: FileStructureElementDiagnosticsCollector): FileStructureElementDiagnosticList { + var inCurrentDeclaration = false + return collector.collectForStructureElement( + firFile, + onDeclarationEnter = { firDeclaration -> + when { + firDeclaration.isGeneratedDeclaration -> DiagnosticCollectorDeclarationAction.SKIP + firDeclaration is FirFile -> DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_CHECK_NESTED + firDeclaration == fir -> { + inCurrentDeclaration = true + DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_CHECK_NESTED + } + FileElementFactory.isReanalyzableContainer(firDeclaration.ktDeclaration) -> { + DiagnosticCollectorDeclarationAction.SKIP + } + inCurrentDeclaration -> { + DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_CHECK_NESTED + } + else -> DiagnosticCollectorDeclarationAction.SKIP_CURRENT_DECLARATION_AND_CHECK_NESTED } - FileElementFactory.isReanalyzableContainer(firDeclaration.ktDeclaration) -> { - DiagnosticCollectorDeclarationAction.SKIP + }, + onDeclarationExit = { firDeclaration -> + if (firDeclaration == fir) { + inCurrentDeclaration = false } - inCurrentDeclaration -> { - DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_CHECK_NESTED - } - else -> DiagnosticCollectorDeclarationAction.SKIP_CURRENT_DECLARATION_AND_CHECK_NESTED - } - }, - onDeclarationExit = { firDeclaration -> - if (firDeclaration == fir) { - inCurrentDeclaration = false - } - }, - ) + }, + ) + } } + companion object { private val recorder = object : FirElementsRecorder() { override fun visitProperty(property: FirProperty, data: MutableMap) { @@ -200,17 +218,21 @@ internal class NonReanalyzableDeclarationStructureElement( } -internal data class RootStructureElement( - override val firFile: FirFile, +internal class RootStructureElement( + firFile: FirFile, override val psi: KtFile, -) : FileStructureElement() { +) : FileStructureElement(firFile) { override val mappings: Map = FirElementsRecorder.recordElementsFrom(firFile, recorder) - override val diagnostics: FileStructureElementDiagnostics by lazy { - FirIdeStructureElementDiagnosticsCollector.collectForStructureElement(firFile) { firDeclaration -> - if (firDeclaration is FirFile) DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_SKIP_NESTED - else DiagnosticCollectorDeclarationAction.SKIP + override val diagnostics = FileStructureElementDiagnostics(firFile, DiagnosticRetriever) + + private object DiagnosticRetriever : FileStructureElementDiagnosticRetriever() { + override fun retrieve(firFile: FirFile, collector: FileStructureElementDiagnosticsCollector): FileStructureElementDiagnosticList { + return collector.collectForStructureElement(firFile) { firDeclaration -> + if (firDeclaration is FirFile) DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_SKIP_NESTED + else DiagnosticCollectorDeclarationAction.SKIP + } } } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnosticList.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnosticList.kt new file mode 100644 index 00000000000..55b0d4c0b47 --- /dev/null +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnosticList.kt @@ -0,0 +1,7 @@ +/* + * Copyright 2010-2021 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.idea.fir.low.level.api.file.structure + diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnosticRetriever.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnosticRetriever.kt new file mode 100644 index 00000000000..55b0d4c0b47 --- /dev/null +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnosticRetriever.kt @@ -0,0 +1,7 @@ +/* + * Copyright 2010-2021 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.idea.fir.low.level.api.file.structure + diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnostics.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnostics.kt new file mode 100644 index 00000000000..55b0d4c0b47 --- /dev/null +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FileStructureElementDiagnostics.kt @@ -0,0 +1,7 @@ +/* + * Copyright 2010-2021 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.idea.fir.low.level.api.file.structure + diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/sessions/FirIdeSessionFactory.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/sessions/FirIdeSessionFactory.kt index c8bfe92e09e..5967462492d 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/sessions/FirIdeSessionFactory.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/sessions/FirIdeSessionFactory.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.SessionConfiguration import org.jetbrains.kotlin.fir.backend.jvm.FirJvmTypeMapper import org.jetbrains.kotlin.fir.caches.FirCachesFactory import org.jetbrains.kotlin.fir.checkers.registerCommonCheckers +import org.jetbrains.kotlin.fir.checkers.registerExtendedCommonCheckers import org.jetbrains.kotlin.fir.dependenciesWithoutSelf import org.jetbrains.kotlin.fir.java.JavaSymbolProvider import org.jetbrains.kotlin.fir.java.deserialization.KotlinDeserializedJvmSymbolsProvider @@ -133,7 +134,7 @@ internal object FirIdeSessionFactory { registerJavaSpecificResolveComponents() FirSessionFactory.FirSessionConfigurator(this).apply { if (isRootModule) { - registerCommonCheckers() + registerExtendedCommonCheckers() } }.configure() } From 6d97841f388cfeb722a1b0323eff3a7bbc815a09 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Mon, 15 Feb 2021 13:13:39 +0100 Subject: [PATCH 186/368] FIR IDE: introduce HLLocalInspectionTest --- .../AbstractHLLocalInspectionTest.kt | 23 ++++++++++++++ .../AbstractLocalInspectionTest.kt | 31 ++++++++++++++++--- 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 idea/idea-fir/tests/org/jetbrains/kotlin/idea/inspections/AbstractHLLocalInspectionTest.kt diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/inspections/AbstractHLLocalInspectionTest.kt b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/inspections/AbstractHLLocalInspectionTest.kt new file mode 100644 index 00000000000..f90b92f73a6 --- /dev/null +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/inspections/AbstractHLLocalInspectionTest.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2010-2021 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.idea.inspections + +import org.jetbrains.kotlin.test.uitls.IgnoreTests +import java.io.File + +abstract class AbstractHLLocalInspectionTest : AbstractLocalInspectionTest() { + override fun isFirPlugin() = true + + override val inspectionFileName: String = ".firInspection" + + override fun checkForUnexpectedErrors(fileText: String) {} + + override fun doTestFor(mainFile: File, inspection: AbstractKotlinInspection, fileText: String) { + IgnoreTests.runTestIfNotDisabledByFileDirective(mainFile.toPath(), IgnoreTests.DIRECTIVES.IGNORE_FIR, "after") { + super.doTestFor(mainFile, inspection, fileText) + } + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt index 72eab58ba76..3f3f96210af 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt @@ -17,9 +17,12 @@ import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.io.FileUtil import com.intellij.profile.codeInspection.ProjectInspectionProfileManager import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl +import com.intellij.util.io.outputStream +import com.intellij.util.io.write import junit.framework.ComparisonFailure import junit.framework.TestCase import org.jdom.Element +import org.jetbrains.annotations.NotNull import org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager import org.jetbrains.kotlin.idea.highlighter.AbstractHighlightingPassBase import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils @@ -31,10 +34,14 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils import org.junit.Assert import java.io.File +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import kotlin.io.path.* abstract class AbstractLocalInspectionTest : KotlinLightCodeInsightFixtureTestCase() { - private val inspectionFileName: String + protected open val inspectionFileName: String get() = ".inspection" private val afterFileNameSuffix: String @@ -121,14 +128,18 @@ abstract class AbstractLocalInspectionTest : KotlinLightCodeInsightFixtureTestCa ScriptConfigurationManager.updateScriptDependenciesSynchronously(myFixture.file) } - doTestFor(mainFile.name, inspection, fileText) + doTestFor(mainFile, inspection, fileText) if (file is KtFile && !InTextDirectivesUtils.isDirectiveDefined(fileText, "// SKIP_ERRORS_AFTER")) { - DirectiveBasedActionUtils.checkForUnexpectedErrors(file as KtFile) + checkForUnexpectedErrors(fileText) } } } + protected open fun checkForUnexpectedErrors(fileText: String) { + DirectiveBasedActionUtils.checkForUnexpectedErrors(file as KtFile) + } + protected fun runInspectionWithFixesAndCheck( inspection: AbstractKotlinInspection, expectedProblemString: String?, @@ -241,7 +252,8 @@ abstract class AbstractLocalInspectionTest : KotlinLightCodeInsightFixtureTestCa return true } - private fun doTestFor(mainFilePath: String, inspection: AbstractKotlinInspection, fileText: String) { + protected open fun doTestFor(mainFile: File, inspection: AbstractKotlinInspection, fileText: String) { + val mainFilePath = mainFile.name val expectedProblemString = InTextDirectivesUtils.findStringWithPrefixes( fileText, "// $expectedProblemDirectiveName: " ) @@ -257,6 +269,7 @@ abstract class AbstractLocalInspectionTest : KotlinLightCodeInsightFixtureTestCa } val canonicalPathToExpectedFile = mainFilePath + afterFileNameSuffix + createAfterFileIfItDoesNotExist(canonicalPathToExpectedFile) try { myFixture.checkResultByFile(canonicalPathToExpectedFile) } catch (e: ComparisonFailure) { @@ -267,6 +280,16 @@ abstract class AbstractLocalInspectionTest : KotlinLightCodeInsightFixtureTestCa } } + @OptIn(ExperimentalPathApi::class) + private fun createAfterFileIfItDoesNotExist(canonicalPathToExpectedFile: String) { + val path = Path(testDataPath) / canonicalPathToExpectedFile + + if (!Files.exists(path)) { + path.createFile().write(editor.document.text) + error("File $canonicalPathToExpectedFile was not found and thus was generated") + } + } + companion object { private val EXTENSIONS = arrayOf(".kt", ".kts", ".java", ".groovy") } From e8f3ebdd199c2d619a6663a98ba2732a13ee8af6 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 11 Feb 2021 16:51:42 +0100 Subject: [PATCH 187/368] FIR IDE: introduce HLRedundantVisibilityModifierInspection by extended checker --- .../jetbrains/kotlin/psi/KtModifierList.java | 7 ++ .../kotlin/generators/tests/GenerateTests.kt | 10 ++ .../fir/applicators/ApplicabilityRanges.kt | 10 ++ .../fir/applicators/ModifierApplicators.kt | 42 +++++++ ...HLRedundantVisibilityModifierInspection.kt | 46 ++++++++ .../.firInspection | 1 + .../publicFunInPublicClass.kt | 3 + .../publicFunInPublicClass.kt.after | 3 + .../publicValInPublicClass.kt | 3 + .../publicValInPublicClass.kt.after | 3 + .../HLLocalInspectionTestGenerated.java | 110 ++++++++++++++++++ .../fir/components/KtFirDiagnosticProvider.kt | 21 +++- .../HLRedundantVisibilityModifier.html | 6 + .../resources-fir/META-INF/firInspections.xml | 9 ++ .../.firInspection | 1 + .../internalInPrivateClass.kt | 4 +- .../internalInPrivateClass.kt.after | 4 +- .../publicOverrideProtectedSetter3.kt | 2 + .../publicOverrideProtectedSetter3.kt.after | 2 + .../publicOverrideProtectedSetter6.kt | 4 +- .../publicOverrideProtectedSetter6.kt.after | 4 +- 21 files changed, 286 insertions(+), 9 deletions(-) create mode 100644 idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/applicators/ModifierApplicators.kt create mode 100644 idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/diagnosticBased/HLRedundantVisibilityModifierInspection.kt create mode 100644 idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/.firInspection create mode 100644 idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicFunInPublicClass.kt create mode 100644 idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicFunInPublicClass.kt.after create mode 100644 idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicValInPublicClass.kt create mode 100644 idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicValInPublicClass.kt.after create mode 100644 idea/idea-fir/tests/org/jetbrains/kotlin/idea/inspections/HLLocalInspectionTestGenerated.java create mode 100644 idea/resources-en/inspectionDescriptions/HLRedundantVisibilityModifier.html create mode 100644 idea/testData/inspectionsLocal/redundantVisibilityModifier/.firInspection diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtModifierList.java b/compiler/psi/src/org/jetbrains/kotlin/psi/KtModifierList.java index c5271219829..79c839ba0d3 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtModifierList.java +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtModifierList.java @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.stubs.IStubElementType; +import com.intellij.psi.tree.TokenSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.lexer.KtModifierKeywordToken; @@ -66,6 +67,12 @@ public abstract class KtModifierList extends KtElementImplStub) { model("inspections/redundantUnitReturnType", pattern = pattern, singleClass = true) } + testClass { val pattern = "^([\\w\\-_]+)\\.(kt|kts)$" model("intentions/specifyTypeExplicitly", pattern = pattern) @@ -1125,6 +1127,14 @@ fun main(args: Array) { } } + testGroup("idea/idea-fir/tests", "idea") { + testClass { + val pattern = "^([\\w\\-_]+)\\.(kt|kts)$" + model("testData/inspectionsLocal/redundantVisibilityModifier", pattern = pattern) + model("idea-fir/testData/inspectionsLocal", pattern = pattern) + } + } + testGroup("idea/idea-fir/tests", "idea/idea-completion/testData") { testClass { model("basic/common") diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/applicators/ApplicabilityRanges.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/applicators/ApplicabilityRanges.kt index dbbfbf9e6bc..9b60bddf435 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/applicators/ApplicabilityRanges.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/applicators/ApplicabilityRanges.kt @@ -6,8 +6,12 @@ package org.jetbrains.kotlin.idea.fir.applicators import com.intellij.psi.PsiElement +import com.intellij.psi.tree.TokenSet import org.jetbrains.kotlin.idea.fir.api.applicator.applicabilityTarget +import org.jetbrains.kotlin.idea.refactoring.safeDelete.removeOverrideModifier +import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtCallableDeclaration +import org.jetbrains.kotlin.psi.KtModifierListOwner object ApplicabilityRanges { val SELF = applicabilityTarget { it } @@ -15,4 +19,10 @@ object ApplicabilityRanges { val CALLABLE_RETURN_TYPE = applicabilityTarget { decalration -> decalration.typeReference?.typeElement } + + val VISIBILITY_MODIFIER = modifier(KtTokens.VISIBILITY_MODIFIERS) + + fun modifier(tokens: TokenSet) = applicabilityTarget { declaration -> + declaration.modifierList?.getModifier(tokens) + } } \ No newline at end of file diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/applicators/ModifierApplicators.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/applicators/ModifierApplicators.kt new file mode 100644 index 00000000000..b0b5025c49d --- /dev/null +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/applicators/ModifierApplicators.kt @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2021 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.idea.fir.applicators + +import com.intellij.psi.PsiElement +import com.intellij.psi.tree.TokenSet +import org.jetbrains.kotlin.idea.KotlinBundle +import org.jetbrains.kotlin.idea.fir.api.applicator.HLApplicatorInput +import org.jetbrains.kotlin.idea.fir.api.applicator.applicator +import org.jetbrains.kotlin.idea.util.application.runWriteAction +import org.jetbrains.kotlin.lexer.KtModifierKeywordToken + +import org.jetbrains.kotlin.psi.KtModifierListOwner + +object ModifierApplicators { + fun removeModifierApplicator(modifier: TokenSet, familyName: () -> String) = applicator { + familyName(familyName) + actionName { _, (modifier) -> KotlinBundle.message("remove.0.modifier", modifier.value) } + + isApplicableByPsi { modifierOwner -> + modifierOwner.modifierList?.getModifier(modifier) != null + } + + applyTo { modifierOwner, (modifier) -> + runWriteAction { + modifierOwner.removeModifier(modifier) + } + } + } + + class Modifier(val modifier: KtModifierKeywordToken) : HLApplicatorInput { + override fun isValidFor(psi: PsiElement): Boolean { + if (psi !is KtModifierListOwner) return false + return psi.hasModifier(modifier) + } + + operator fun component1() = modifier + } +} \ No newline at end of file diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/diagnosticBased/HLRedundantVisibilityModifierInspection.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/diagnosticBased/HLRedundantVisibilityModifierInspection.kt new file mode 100644 index 00000000000..18126a06907 --- /dev/null +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/diagnosticBased/HLRedundantVisibilityModifierInspection.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2021 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.idea.fir.inspections.diagnosticBased + +import com.intellij.codeInspection.ProblemHighlightType +import org.jetbrains.kotlin.idea.KotlinBundle +import org.jetbrains.kotlin.idea.KotlinBundleIndependent +import org.jetbrains.kotlin.idea.fir.api.AbstractHLDiagnosticBasedInspection +import org.jetbrains.kotlin.idea.fir.api.applicator.* +import org.jetbrains.kotlin.idea.fir.api.inputByDiagnosticProvider +import org.jetbrains.kotlin.idea.fir.applicators.ApplicabilityRanges +import org.jetbrains.kotlin.idea.fir.applicators.ModifierApplicators +import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic +import org.jetbrains.kotlin.lexer.KtTokens +import org.jetbrains.kotlin.psi.KtModifierListOwner +import org.jetbrains.kotlin.psi.psiUtil.visibilityModifierType + +class HLRedundantVisibilityModifierInspection : + AbstractHLDiagnosticBasedInspection( + elementType = KtModifierListOwner::class, + diagnosticType = KtFirDiagnostic.RedundantVisibilityModifier::class + ) { + + override val inputByDiagnosticProvider = + inputByDiagnosticProvider { diagnostic -> + val modifier = diagnostic.psi.visibilityModifierType() ?: return@inputByDiagnosticProvider null + ModifierApplicators.Modifier(modifier) + } + + override val presentation: HLPresentation = presentation { + highlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL) + } + + override val applicabilityRange: HLApplicabilityRange = ApplicabilityRanges.VISIBILITY_MODIFIER + + override val applicator: HLApplicator = + ModifierApplicators.removeModifierApplicator( + KtTokens.VISIBILITY_MODIFIERS, + KotlinBundle.lazyMessage("redundant.visibility.modifier") + ).with { + actionName { _, (modifier) -> KotlinBundleIndependent.message("remove.redundant.0.modifier", modifier.value) } + } +} \ No newline at end of file diff --git a/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/.firInspection b/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/.firInspection new file mode 100644 index 00000000000..de505cbf1ce --- /dev/null +++ b/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/.firInspection @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.fir.inspections.diagnosticBased.HLRedundantVisibilityModifierInspection \ No newline at end of file diff --git a/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicFunInPublicClass.kt b/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicFunInPublicClass.kt new file mode 100644 index 00000000000..487dccb7a96 --- /dev/null +++ b/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicFunInPublicClass.kt @@ -0,0 +1,3 @@ +public class C { + public fun bar() {} +} diff --git a/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicFunInPublicClass.kt.after b/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicFunInPublicClass.kt.after new file mode 100644 index 00000000000..be112761d2f --- /dev/null +++ b/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicFunInPublicClass.kt.after @@ -0,0 +1,3 @@ +public class C { + fun bar() {} +} diff --git a/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicValInPublicClass.kt b/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicValInPublicClass.kt new file mode 100644 index 00000000000..f361c7597ed --- /dev/null +++ b/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicValInPublicClass.kt @@ -0,0 +1,3 @@ +public class C { + public val foo: Int = 0 +} diff --git a/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicValInPublicClass.kt.after b/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicValInPublicClass.kt.after new file mode 100644 index 00000000000..e6b25690263 --- /dev/null +++ b/idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicValInPublicClass.kt.after @@ -0,0 +1,3 @@ +public class C { + val foo: Int = 0 +} diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/inspections/HLLocalInspectionTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/inspections/HLLocalInspectionTestGenerated.java new file mode 100644 index 00000000000..1c35c86ccb2 --- /dev/null +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/inspections/HLLocalInspectionTestGenerated.java @@ -0,0 +1,110 @@ +/* + * Copyright 2010-2021 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.idea.inspections; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@RunWith(JUnit3RunnerWithInners.class) +public class HLLocalInspectionTestGenerated extends AbstractHLLocalInspectionTest { + @TestMetadata("idea/testData/inspectionsLocal/redundantVisibilityModifier") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class RedundantVisibilityModifier extends AbstractHLLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInRedundantVisibilityModifier() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/inspectionsLocal/redundantVisibilityModifier"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), null, true); + } + + @TestMetadata("internalInPrivateClass.kt") + public void testInternalInPrivateClass() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantVisibilityModifier/internalInPrivateClass.kt"); + } + + @TestMetadata("overridePropertySetter.kt") + public void testOverridePropertySetter() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantVisibilityModifier/overridePropertySetter.kt"); + } + + @TestMetadata("publicOverrideProtectedSetter.kt") + public void testPublicOverrideProtectedSetter() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter.kt"); + } + + @TestMetadata("publicOverrideProtectedSetter2.kt") + public void testPublicOverrideProtectedSetter2() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter2.kt"); + } + + @TestMetadata("publicOverrideProtectedSetter3.kt") + public void testPublicOverrideProtectedSetter3() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter3.kt"); + } + + @TestMetadata("publicOverrideProtectedSetter4.kt") + public void testPublicOverrideProtectedSetter4() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter4.kt"); + } + + @TestMetadata("publicOverrideProtectedSetter5.kt") + public void testPublicOverrideProtectedSetter5() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter5.kt"); + } + + @TestMetadata("publicOverrideProtectedSetter6.kt") + public void testPublicOverrideProtectedSetter6() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter6.kt"); + } + } + + @TestMetadata("idea/idea-fir/testData/inspectionsLocal") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InspectionsLocal extends AbstractHLLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInInspectionsLocal() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-fir/testData/inspectionsLocal"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), null, true); + } + + @TestMetadata("idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class RedundantVisibilityModifierFir extends AbstractHLLocalInspectionTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInRedundantVisibilityModifierFir() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), null, true); + } + + @TestMetadata("publicFunInPublicClass.kt") + public void testPublicFunInPublicClass() throws Exception { + runTest("idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicFunInPublicClass.kt"); + } + + @TestMetadata("publicValInPublicClass.kt") + public void testPublicValInPublicClass() throws Exception { + runTest("idea/idea-fir/testData/inspectionsLocal/redundantVisibilityModifierFir/publicValInPublicClass.kt"); + } + } + } +} diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt index 6c5feacdf23..68bdd683e01 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt @@ -5,16 +5,18 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components +import com.intellij.psi.PsiElement import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic import org.jetbrains.kotlin.fir.analysis.diagnostics.toFirDiagnostic import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic +import org.jetbrains.kotlin.idea.fir.low.level.api.api.DiagnosticCheckerFilter import org.jetbrains.kotlin.idea.fir.low.level.api.api.collectDiagnosticsForFile import org.jetbrains.kotlin.idea.fir.low.level.api.api.getDiagnostics import org.jetbrains.kotlin.idea.frontend.api.ValidityToken +import org.jetbrains.kotlin.idea.frontend.api.components.KtDiagnosticCheckerFilter import org.jetbrains.kotlin.idea.frontend.api.components.KtDiagnosticProvider -import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnostic import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KT_DIAGNOSTIC_CONVERTER @@ -26,17 +28,26 @@ internal class KtFirDiagnosticProvider( override val analysisSession: KtFirAnalysisSession, override val token: ValidityToken, ) : KtDiagnosticProvider(), KtFirAnalysisSessionComponent { - override fun getDiagnosticsForElement(element: KtElement): Collection> = withValidityAssertion { - element.getDiagnostics(firResolveState).map { it.asKtDiagnostic() } + override fun getDiagnosticsForElement( + element: KtElement, + filter: KtDiagnosticCheckerFilter + ): Collection> = withValidityAssertion { + element.getDiagnostics(firResolveState, filter.asLLFilter()).map { it.asKtDiagnostic() } } - override fun collectDiagnosticsForFile(ktFile: KtFile): Collection> = - ktFile.collectDiagnosticsForFile(firResolveState).map { it.asKtDiagnostic() } + override fun collectDiagnosticsForFile(ktFile: KtFile, filter: KtDiagnosticCheckerFilter): Collection> = + ktFile.collectDiagnosticsForFile(firResolveState, filter.asLLFilter()).map { it.asKtDiagnostic() } fun firDiagnosticAsKtDiagnostic(diagnostic: FirPsiDiagnostic<*>): KtDiagnosticWithPsi<*> { return KT_DIAGNOSTIC_CONVERTER.convert(analysisSession, diagnostic as FirDiagnostic<*>) } + private fun KtDiagnosticCheckerFilter.asLLFilter() = when (this) { + KtDiagnosticCheckerFilter.ONLY_COMMON_CHECKERS -> DiagnosticCheckerFilter.ONLY_COMMON_CHECKERS + KtDiagnosticCheckerFilter.ONLY_EXTENDED_CHECKERS -> DiagnosticCheckerFilter.ONLY_EXTENDED_CHECKERS + KtDiagnosticCheckerFilter.EXTENDED_AND_COMMON_CHECKERS -> DiagnosticCheckerFilter.EXTENDED_AND_COMMON_CHECKERS + } + fun coneDiagnosticAsKtDiagnostic(coneDiagnostic: ConeDiagnostic, source: FirSourceElement): KtDiagnosticWithPsi<*>? { val firDiagnostic = coneDiagnostic.toFirDiagnostic(source) ?: return null check(firDiagnostic is FirPsiDiagnostic<*>) diff --git a/idea/resources-en/inspectionDescriptions/HLRedundantVisibilityModifier.html b/idea/resources-en/inspectionDescriptions/HLRedundantVisibilityModifier.html new file mode 100644 index 00000000000..5fdbbc91844 --- /dev/null +++ b/idea/resources-en/inspectionDescriptions/HLRedundantVisibilityModifier.html @@ -0,0 +1,6 @@ + + +This inspection reports visibility modifiers which match the default visibility of an element +(public for most elements, protected for members that override a protected member). + + diff --git a/idea/resources-fir/META-INF/firInspections.xml b/idea/resources-fir/META-INF/firInspections.xml index 003fc65c660..dadcf821fd6 100644 --- a/idea/resources-fir/META-INF/firInspections.xml +++ b/idea/resources-fir/META-INF/firInspections.xml @@ -8,5 +8,14 @@ level="WARNING" language="kotlin" key="inspection.redundant.unit.return.type.display.name" bundle="messages.KotlinBundle"/> + + \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantVisibilityModifier/.firInspection b/idea/testData/inspectionsLocal/redundantVisibilityModifier/.firInspection new file mode 100644 index 00000000000..de505cbf1ce --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantVisibilityModifier/.firInspection @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.fir.inspections.diagnosticBased.HLRedundantVisibilityModifierInspection \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantVisibilityModifier/internalInPrivateClass.kt b/idea/testData/inspectionsLocal/redundantVisibilityModifier/internalInPrivateClass.kt index 9cea07d7af6..e75d6e990f6 100644 --- a/idea/testData/inspectionsLocal/redundantVisibilityModifier/internalInPrivateClass.kt +++ b/idea/testData/inspectionsLocal/redundantVisibilityModifier/internalInPrivateClass.kt @@ -1,3 +1,5 @@ private class Foo { internal fun bar() {} -} \ No newline at end of file +} + +// IGNORE_FIR KT-44939 \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantVisibilityModifier/internalInPrivateClass.kt.after b/idea/testData/inspectionsLocal/redundantVisibilityModifier/internalInPrivateClass.kt.after index b5f07278a94..8e8a7f10eb8 100644 --- a/idea/testData/inspectionsLocal/redundantVisibilityModifier/internalInPrivateClass.kt.after +++ b/idea/testData/inspectionsLocal/redundantVisibilityModifier/internalInPrivateClass.kt.after @@ -1,3 +1,5 @@ private class Foo { fun bar() {} -} \ No newline at end of file +} + +// IGNORE_FIR KT-44939 \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter3.kt b/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter3.kt index 3a41bb02121..d5b18fd7c8c 100644 --- a/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter3.kt +++ b/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter3.kt @@ -12,3 +12,5 @@ fun main() { val c = C() c.attribute = "test" } + +// IGNORE_FIR KT-44939 \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter3.kt.after b/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter3.kt.after index 69fcad733f6..895ccf5e124 100644 --- a/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter3.kt.after +++ b/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter3.kt.after @@ -12,3 +12,5 @@ fun main() { val c = C() c.attribute = "test" } + +// IGNORE_FIR KT-44939 \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter6.kt b/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter6.kt index d9ed9aa9a11..de90ecaa00d 100644 --- a/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter6.kt +++ b/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter6.kt @@ -15,4 +15,6 @@ class C : B() { fun main() { val c = C() c.attribute = "test" -} \ No newline at end of file +} + +// IGNORE_FIR KT-44939 \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter6.kt.after b/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter6.kt.after index e9f9979fe40..ab3db3da572 100644 --- a/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter6.kt.after +++ b/idea/testData/inspectionsLocal/redundantVisibilityModifier/publicOverrideProtectedSetter6.kt.after @@ -15,4 +15,6 @@ class C : B() { fun main() { val c = C() c.attribute = "test" -} \ No newline at end of file +} + +// IGNORE_FIR KT-44939 \ No newline at end of file From 3e220116266b12bd6b15ecaa8d9c4e3d77c4377f Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Tue, 16 Feb 2021 15:47:08 +0100 Subject: [PATCH 188/368] Fix compilation of HLRedundantVisibilityModifierInspection --- .../diagnosticBased/HLRedundantVisibilityModifierInspection.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/diagnosticBased/HLRedundantVisibilityModifierInspection.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/diagnosticBased/HLRedundantVisibilityModifierInspection.kt index 18126a06907..30d797c6324 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/diagnosticBased/HLRedundantVisibilityModifierInspection.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/inspections/diagnosticBased/HLRedundantVisibilityModifierInspection.kt @@ -7,7 +7,6 @@ package org.jetbrains.kotlin.idea.fir.inspections.diagnosticBased import com.intellij.codeInspection.ProblemHighlightType import org.jetbrains.kotlin.idea.KotlinBundle -import org.jetbrains.kotlin.idea.KotlinBundleIndependent import org.jetbrains.kotlin.idea.fir.api.AbstractHLDiagnosticBasedInspection import org.jetbrains.kotlin.idea.fir.api.applicator.* import org.jetbrains.kotlin.idea.fir.api.inputByDiagnosticProvider @@ -41,6 +40,6 @@ class HLRedundantVisibilityModifierInspection : KtTokens.VISIBILITY_MODIFIERS, KotlinBundle.lazyMessage("redundant.visibility.modifier") ).with { - actionName { _, (modifier) -> KotlinBundleIndependent.message("remove.redundant.0.modifier", modifier.value) } + actionName { _, (modifier) -> KotlinBundle.message("remove.redundant.0.modifier", modifier.value) } } } \ No newline at end of file From b5619dbf370702a5e64977f20b0006e18ed06458 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 15 Feb 2021 11:02:15 +0300 Subject: [PATCH 189/368] [FIR] Add ability to render node levels in CFG graph dumper --- .../kotlin/test/directives/FirDiagnosticsDirectives.kt | 5 +++++ .../kotlin/test/frontend/fir/handlers/FirCfgDumpHandler.kt | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt index 05a4249f885..573669b1c09 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt @@ -17,6 +17,11 @@ object FirDiagnosticsDirectives : SimpleDirectivesContainer() { applicability = Global ) + val RENDERER_CFG_LEVELS by directive( + description = "Render leves of nodes in CFG dump", + applicability = Global + ) + val FIR_DUMP by directive( description = """ Dumps resulting fir to `testName.fir` file diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirCfgDumpHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirCfgDumpHandler.kt index 164d4a1880b..ed1389beb31 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirCfgDumpHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirCfgDumpHandler.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.test.frontend.fir.handlers import org.jetbrains.kotlin.fir.resolve.dfa.cfg.FirControlFlowGraphRenderVisitor import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives +import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.RENDERER_CFG_LEVELS import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact import org.jetbrains.kotlin.test.model.TestModule @@ -24,7 +25,8 @@ class FirCfgDumpHandler(testServices: TestServices) : FirAnalysisHandler(testSer override fun processModule(module: TestModule, info: FirOutputArtifact) { if (alreadyDumped || FirDiagnosticsDirectives.DUMP_CFG !in module.directives) return val file = info.firFiles.values.first() - file.accept(FirControlFlowGraphRenderVisitor(builder)) + val renderLevels = RENDERER_CFG_LEVELS in module.directives + file.accept(FirControlFlowGraphRenderVisitor(builder, renderLevels)) alreadyDumped = true } From 92271527cb81b0d8a90c455f9d690944cb6033d7 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 15 Feb 2021 11:02:41 +0300 Subject: [PATCH 190/368] [Test] Add CFG and IR dump handlers to FirBlackBoxTests --- .../test/runners/codegen/AbstractFirBlackBoxCodegenTest.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractFirBlackBoxCodegenTest.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractFirBlackBoxCodegenTest.kt index 7145953a4ad..420286b2c29 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractFirBlackBoxCodegenTest.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractFirBlackBoxCodegenTest.kt @@ -7,12 +7,14 @@ package org.jetbrains.kotlin.test.runners.codegen import org.jetbrains.kotlin.test.Constructor import org.jetbrains.kotlin.test.TargetBackend +import org.jetbrains.kotlin.test.backend.handlers.IrTextDumpHandler import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.USE_PSI_CLASS_FILES_READING import org.jetbrains.kotlin.test.frontend.fir.Fir2IrResultsConverter import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact +import org.jetbrains.kotlin.test.frontend.fir.handlers.FirCfgDumpHandler import org.jetbrains.kotlin.test.frontend.fir.handlers.FirDumpHandler import org.jetbrains.kotlin.test.model.* @@ -37,6 +39,8 @@ open class AbstractFirBlackBoxCodegenTest : AbstractJvmBlackBoxCodegenTestBase Date: Fri, 12 Feb 2021 14:40:41 +0300 Subject: [PATCH 191/368] [FIR] Increase level of sequential when branches Level of CFGNode is used to determine which call is a common one for creating node with union of arguments (to merge flow from multiple in-place lambdas). Before this change calls in different when branches may have same node level, which entail passing smartcasts from moddle of one branch to another ``` val x: Any = ... when { ... -> run { x as String } // (1) ... -> { run { x.foo() } // (2) "hello" } } ``` Call `(1)` was assumed as argument of call `(2)` which is incorrect #KT-44814 Fixed --- .../FirBlackBoxCodegenTestGenerated.java | 6 + .../dfa/cfg/ControlFlowGraphBuilder.kt | 5 + .../dfa/cfg/ControlFlowGraphRenderer.kt | 11 +- .../codegen/box/smartCasts/kt44814.dot | 1035 +++++++++++++++++ .../codegen/box/smartCasts/kt44814.fir.txt | 762 ++++++++++++ .../codegen/box/smartCasts/kt44814.kt | 86 ++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 + .../IrBlackBoxCodegenTestGenerated.java | 6 + .../LightAnalysisModeTestGenerated.java | 5 + .../IrJsCodegenBoxES6TestGenerated.java | 5 + .../IrJsCodegenBoxTestGenerated.java | 5 + .../semantics/JsCodegenBoxTestGenerated.java | 5 + .../IrCodegenBoxWasmTestGenerated.java | 5 + 13 files changed, 1940 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/codegen/box/smartCasts/kt44814.dot create mode 100644 compiler/testData/codegen/box/smartCasts/kt44814.fir.txt create mode 100644 compiler/testData/codegen/box/smartCasts/kt44814.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index d73b671d298..5c14b8ef5c8 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -37440,6 +37440,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); } + @Test + @TestMetadata("kt44814.kt") + public void testKt44814() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt index f9b62f6427b..e8d0a90a259 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt @@ -79,6 +79,7 @@ class ControlFlowGraphBuilder { private val exitsFromCompletedPostponedAnonymousFunctions: MutableList = mutableListOf() private val whenExitNodes: NodeStorage = NodeStorage() + private val whenBranchIndices: Stack> = stackOf() private val binaryAndExitNodes: Stack = stackOf() private val binaryOrExitNodes: Stack = stackOf() @@ -596,6 +597,7 @@ class ControlFlowGraphBuilder { val node = createWhenEnterNode(whenExpression) addNewSimpleNode(node) whenExitNodes.push(createWhenExitNode(whenExpression)) + whenBranchIndices.push(whenExpression.branches.mapIndexed { index, branch -> branch to index }.toMap()) levelCounter++ return node } @@ -613,6 +615,7 @@ class ControlFlowGraphBuilder { lastNodes.push(it) addEdge(conditionExitNode, it) } + levelCounter += whenBranchIndices.top().getValue(whenBranch) return conditionExitNode to branchEnterNode } @@ -622,6 +625,7 @@ class ControlFlowGraphBuilder { popAndAddEdge(node) val whenExitNode = whenExitNodes.top() addEdge(node, whenExitNode, propagateDeadness = false) + levelCounter -= whenBranchIndices.top().getValue(whenBranch) return node } @@ -640,6 +644,7 @@ class ControlFlowGraphBuilder { lastNodes.push(whenExitNode) dropPostponedLambdasForNonDeterministicCalls() levelCounter-- + whenBranchIndices.pop() return whenExitNode to syntheticElseBranchNode } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt index 2f25d1cd79a..665fbe7d430 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt @@ -18,6 +18,7 @@ import java.util.* class FirControlFlowGraphRenderVisitor( builder: StringBuilder, + private val renderLevels: Boolean = false ) : FirVisitorVoid() { companion object { private const val EDGE = " -> " @@ -81,7 +82,13 @@ class FirControlFlowGraphRenderVisitor( color = BLUE } val attributes = mutableListOf() - attributes += "label=\"${node.render().replace("\"", "")}\"" + val label = buildString { + append(node.render().replace("\"", "")) + if (renderLevels) { + append(" [${node.level}]") + } + } + attributes += "label=\"$label\"" fun fillColor(color: String) { attributes += "style=\"filled\"" @@ -218,4 +225,4 @@ private fun ControlFlowGraph.forEachSubGraph(block: (ControlFlowGraph) -> Unit) block(subGraph) subGraph.forEachSubGraph(block) } -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/smartCasts/kt44814.dot b/compiler/testData/codegen/box/smartCasts/kt44814.dot new file mode 100644 index 00000000000..ef4fbb6fce4 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/kt44814.dot @@ -0,0 +1,1035 @@ +digraph kt44814_kt { + graph [nodesep=3] + node [shape=box penwidth=2] + edge [penwidth=2] + + subgraph cluster_0 { + color=red + 0 [label="Enter class FlyweightCapableTreeStructure [1]" style="filled" fillcolor=red]; + 1 [label="Exit class FlyweightCapableTreeStructure [1]" style="filled" fillcolor=red]; + } + 0 -> {1} [color=green]; + + subgraph cluster_1 { + color=red + 2 [label="Enter function [2]" style="filled" fillcolor=red]; + 3 [label="Delegated constructor call: super() [2]"]; + 4 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 2 -> {3}; + 3 -> {4}; + + subgraph cluster_2 { + color=red + 5 [label="Enter class FirSourceElement [1]" style="filled" fillcolor=red]; + 6 [label="Exit class FirSourceElement [1]" style="filled" fillcolor=red]; + } + 5 -> {6} [color=green]; + + subgraph cluster_3 { + color=red + 7 [label="Enter function [2]" style="filled" fillcolor=red]; + 8 [label="Delegated constructor call: super() [2]"]; + 9 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 7 -> {8}; + 8 -> {9}; + + subgraph cluster_4 { + color=red + 10 [label="Enter function getter [2]" style="filled" fillcolor=red]; + 11 [label="Exit function getter [2]" style="filled" fillcolor=red]; + } + 10 -> {11}; + + subgraph cluster_5 { + color=red + 12 [label="Enter function getter [2]" style="filled" fillcolor=red]; + 13 [label="Exit function getter [2]" style="filled" fillcolor=red]; + } + 12 -> {13}; + + subgraph cluster_6 { + color=red + 14 [label="Enter class FirPsiSourceElement [1]" style="filled" fillcolor=red]; + 15 [label="Part of class initialization [1]"]; + 16 [label="Part of class initialization [1]"]; + 17 [label="Part of class initialization [1]"]; + 18 [label="Exit class FirPsiSourceElement [1]" style="filled" fillcolor=red]; + } + 14 -> {15} [color=green]; + 15 -> {16} [style=dotted]; + 15 -> {24} [color=green]; + 15 -> {24} [style=dashed]; + 16 -> {17} [style=dotted]; + 16 -> {29} [color=green]; + 16 -> {29} [style=dashed]; + 17 -> {18} [style=dotted]; + 17 -> {34} [color=green]; + 17 -> {34} [style=dashed]; + + subgraph cluster_7 { + color=red + 19 [label="Enter function [2]" style="filled" fillcolor=red]; + 20 [label="Delegated constructor call: super() [2]"]; + 21 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 19 -> {20}; + 20 -> {21}; + + subgraph cluster_8 { + color=red + 22 [label="Enter function getter [3]" style="filled" fillcolor=red]; + 23 [label="Exit function getter [3]" style="filled" fillcolor=red]; + } + 22 -> {23}; + + subgraph cluster_9 { + color=red + 24 [label="Enter property [2]" style="filled" fillcolor=red]; + 25 [label="Access variable R|/psi| [2]"]; + 26 [label="Exit property [2]" style="filled" fillcolor=red]; + } + 24 -> {25}; + 25 -> {26}; + 26 -> {16} [color=green]; + + subgraph cluster_10 { + color=red + 27 [label="Enter function getter [3]" style="filled" fillcolor=red]; + 28 [label="Exit function getter [3]" style="filled" fillcolor=red]; + } + 27 -> {28}; + + subgraph cluster_11 { + color=red + 29 [label="Enter property [2]" style="filled" fillcolor=red]; + 30 [label="Access variable R|/lighterASTNode| [2]"]; + 31 [label="Exit property [2]" style="filled" fillcolor=red]; + } + 29 -> {30}; + 30 -> {31}; + 31 -> {17} [color=green]; + + subgraph cluster_12 { + color=red + 32 [label="Enter function getter [3]" style="filled" fillcolor=red]; + 33 [label="Exit function getter [3]" style="filled" fillcolor=red]; + } + 32 -> {33}; + + subgraph cluster_13 { + color=red + 34 [label="Enter property [2]" style="filled" fillcolor=red]; + 35 [label="Access variable R|/treeStructure| [2]"]; + 36 [label="Exit property [2]" style="filled" fillcolor=red]; + } + 34 -> {35}; + 35 -> {36}; + 36 -> {18} [color=green]; + + subgraph cluster_14 { + color=red + 37 [label="Enter class FirLightSourceElement [1]" style="filled" fillcolor=red]; + 38 [label="Part of class initialization [1]"]; + 39 [label="Part of class initialization [1]"]; + 40 [label="Exit class FirLightSourceElement [1]" style="filled" fillcolor=red]; + } + 37 -> {38} [color=green]; + 38 -> {39} [style=dotted]; + 38 -> {46} [color=green]; + 38 -> {46} [style=dashed]; + 39 -> {40} [style=dotted]; + 39 -> {51} [color=green]; + 39 -> {51} [style=dashed]; + + subgraph cluster_15 { + color=red + 41 [label="Enter function [2]" style="filled" fillcolor=red]; + 42 [label="Delegated constructor call: super() [2]"]; + 43 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 41 -> {42}; + 42 -> {43}; + + subgraph cluster_16 { + color=red + 44 [label="Enter function getter [3]" style="filled" fillcolor=red]; + 45 [label="Exit function getter [3]" style="filled" fillcolor=red]; + } + 44 -> {45}; + + subgraph cluster_17 { + color=red + 46 [label="Enter property [2]" style="filled" fillcolor=red]; + 47 [label="Access variable R|/lighterASTNode| [2]"]; + 48 [label="Exit property [2]" style="filled" fillcolor=red]; + } + 46 -> {47}; + 47 -> {48}; + 48 -> {39} [color=green]; + + subgraph cluster_18 { + color=red + 49 [label="Enter function getter [3]" style="filled" fillcolor=red]; + 50 [label="Exit function getter [3]" style="filled" fillcolor=red]; + } + 49 -> {50}; + + subgraph cluster_19 { + color=red + 51 [label="Enter property [2]" style="filled" fillcolor=red]; + 52 [label="Access variable R|/treeStructure| [2]"]; + 53 [label="Exit property [2]" style="filled" fillcolor=red]; + } + 51 -> {52}; + 52 -> {53}; + 53 -> {40} [color=green]; + + subgraph cluster_20 { + color=red + 54 [label="Enter class PsiElement [1]" style="filled" fillcolor=red]; + 55 [label="Exit class PsiElement [1]" style="filled" fillcolor=red]; + } + 54 -> {55} [color=green]; + + subgraph cluster_21 { + color=red + 56 [label="Enter function [2]" style="filled" fillcolor=red]; + 57 [label="Delegated constructor call: super() [2]"]; + 58 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 56 -> {57}; + 57 -> {58}; + + subgraph cluster_22 { + color=red + 59 [label="Enter class ASTNode [1]" style="filled" fillcolor=red]; + 60 [label="Exit class ASTNode [1]" style="filled" fillcolor=red]; + } + 59 -> {60} [color=green]; + + subgraph cluster_23 { + color=red + 61 [label="Enter function [2]" style="filled" fillcolor=red]; + 62 [label="Delegated constructor call: super() [2]"]; + 63 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 61 -> {62}; + 62 -> {63}; + + subgraph cluster_24 { + color=red + 64 [label="Enter class LighterASTNode [1]" style="filled" fillcolor=red]; + 65 [label="Part of class initialization [1]"]; + 66 [label="Part of class initialization [1]"]; + 67 [label="Exit class LighterASTNode [1]" style="filled" fillcolor=red]; + } + 64 -> {65} [color=green]; + 65 -> {66} [style=dotted]; + 65 -> {76} [color=green]; + 65 -> {76} [style=dashed]; + 66 -> {67} [style=dotted]; + 66 -> {88} [color=green]; + 66 -> {88} [style=dashed]; + + subgraph cluster_25 { + color=red + 68 [label="Enter function [2]" style="filled" fillcolor=red]; + subgraph cluster_26 { + color=blue + 71 [label="Enter default value of _children [3]" style="filled" fillcolor=red]; + 72 [label="Function call: R|kotlin/collections/emptyList|() [3]"]; + 73 [label="Exit default value of _children [3]" style="filled" fillcolor=red]; + } + 69 [label="Delegated constructor call: super() [2]"]; + 70 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 68 -> {71 69}; + 69 -> {70}; + 71 -> {72}; + 71 -> {71} [style=dashed]; + 72 -> {73}; + + subgraph cluster_27 { + color=red + 74 [label="Enter function getter [3]" style="filled" fillcolor=red]; + 75 [label="Exit function getter [3]" style="filled" fillcolor=red]; + } + 74 -> {75}; + + subgraph cluster_28 { + color=red + 76 [label="Enter property [2]" style="filled" fillcolor=red]; + 77 [label="Access variable R|/_children| [2]"]; + 78 [label="Exit property [2]" style="filled" fillcolor=red]; + } + 76 -> {77}; + 77 -> {78}; + 78 -> {66} [color=green]; + + subgraph cluster_29 { + color=red + 79 [label="Enter function getChildren [2]" style="filled" fillcolor=red]; + subgraph cluster_30 { + color=blue + 80 [label="Enter block [2]"]; + 81 [label="Access variable R|/LighterASTNode._children| [2]"]; + 82 [label="Jump: ^getChildren this@R|/LighterASTNode|.R|/LighterASTNode._children| [2]"]; + 83 [label="Stub [2]" style="filled" fillcolor=gray]; + 84 [label="Exit block [2]" style="filled" fillcolor=gray]; + } + 85 [label="Exit function getChildren [2]" style="filled" fillcolor=red]; + } + 79 -> {80}; + 80 -> {81}; + 81 -> {82}; + 82 -> {85}; + 82 -> {83} [style=dotted]; + 83 -> {84} [style=dotted]; + 84 -> {85} [style=dotted]; + + subgraph cluster_31 { + color=red + 86 [label="Enter function getter [3]" style="filled" fillcolor=red]; + 87 [label="Exit function getter [3]" style="filled" fillcolor=red]; + } + 86 -> {87}; + + subgraph cluster_32 { + color=red + 88 [label="Enter property [2]" style="filled" fillcolor=red]; + 89 [label="Access qualifier /TokenType [2]"]; + 90 [label="Access variable R|/TokenType.Companion.MODIFIER_LIST| [2]"]; + 91 [label="Exit property [2]" style="filled" fillcolor=red]; + } + 88 -> {89}; + 89 -> {90}; + 90 -> {91}; + 91 -> {67} [color=green]; + + subgraph cluster_33 { + color=red + 92 [label="Enter class TokenType [1]" style="filled" fillcolor=red]; + 93 [label="Exit class TokenType [1]" style="filled" fillcolor=red]; + } + 92 -> {93} [color=green]; + + subgraph cluster_34 { + color=red + 94 [label="Enter function [2]" style="filled" fillcolor=red]; + 95 [label="Delegated constructor call: super() [2]"]; + 96 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 94 -> {95}; + 95 -> {96}; + + subgraph cluster_35 { + color=red + 97 [label="Enter class Companion [2]" style="filled" fillcolor=red]; + 98 [label="Part of class initialization [2]"]; + 99 [label="Exit class Companion [2]" style="filled" fillcolor=red]; + } + 97 -> {98} [color=green]; + 98 -> {99} [style=dotted]; + 98 -> {105} [color=green]; + 98 -> {105} [style=dashed]; + + subgraph cluster_36 { + color=red + 100 [label="Enter function [3]" style="filled" fillcolor=red]; + 101 [label="Delegated constructor call: super() [3]"]; + 102 [label="Exit function [3]" style="filled" fillcolor=red]; + } + 100 -> {101}; + 101 -> {102}; + + subgraph cluster_37 { + color=red + 103 [label="Enter function getter [4]" style="filled" fillcolor=red]; + 104 [label="Exit function getter [4]" style="filled" fillcolor=red]; + } + 103 -> {104}; + + subgraph cluster_38 { + color=red + 105 [label="Enter property [3]" style="filled" fillcolor=red]; + 106 [label="Function call: R|/TokenType.TokenType|() [3]"]; + 107 [label="Exit property [3]" style="filled" fillcolor=red]; + } + 105 -> {106}; + 106 -> {107}; + 107 -> {99} [color=green]; + + subgraph cluster_39 { + color=red + 108 [label="Enter class KtModifierKeywordToken [1]" style="filled" fillcolor=red]; + 109 [label="Exit class KtModifierKeywordToken [1]" style="filled" fillcolor=red]; + } + 108 -> {109} [color=green]; + + subgraph cluster_40 { + color=red + 110 [label="Enter function [2]" style="filled" fillcolor=red]; + 111 [label="Delegated constructor call: super() [2]"]; + 112 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 110 -> {111}; + 111 -> {112}; + + subgraph cluster_41 { + color=red + 113 [label="Enter class KtModifierList [1]" style="filled" fillcolor=red]; + 114 [label="Exit class KtModifierList [1]" style="filled" fillcolor=red]; + } + 113 -> {114} [color=green]; + + subgraph cluster_42 { + color=red + 115 [label="Enter function [2]" style="filled" fillcolor=red]; + 116 [label="Delegated constructor call: super() [2]"]; + 117 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 115 -> {116}; + 116 -> {117}; + + subgraph cluster_43 { + color=red + 118 [label="Enter class KtModifierListOwner [1]" style="filled" fillcolor=red]; + 119 [label="Part of class initialization [1]"]; + 120 [label="Exit class KtModifierListOwner [1]" style="filled" fillcolor=red]; + } + 118 -> {119} [color=green]; + 119 -> {120} [style=dotted]; + 119 -> {126} [color=green]; + 119 -> {126} [style=dashed]; + + subgraph cluster_44 { + color=red + 121 [label="Enter function [2]" style="filled" fillcolor=red]; + 122 [label="Delegated constructor call: super() [2]"]; + 123 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 121 -> {122}; + 122 -> {123}; + + subgraph cluster_45 { + color=red + 124 [label="Enter function getter [3]" style="filled" fillcolor=red]; + 125 [label="Exit function getter [3]" style="filled" fillcolor=red]; + } + 124 -> {125}; + + subgraph cluster_46 { + color=red + 126 [label="Enter property [2]" style="filled" fillcolor=red]; + 127 [label="Function call: R|/KtModifierList.KtModifierList|() [2]"]; + 128 [label="Exit property [2]" style="filled" fillcolor=red]; + } + 126 -> {127}; + 127 -> {128}; + 128 -> {120} [color=green]; + + subgraph cluster_47 { + color=red + 129 [label="Enter class FirModifier [1]" style="filled" fillcolor=red]; + 130 [label="Part of class initialization [1]"]; + 131 [label="Part of class initialization [1]"]; + 132 [label="Exit class FirModifier [1]" style="filled" fillcolor=red]; + } + 129 -> {130} [color=green]; + 130 -> {131} [style=dotted]; + 130 -> {138} [color=green]; + 130 -> {138} [style=dashed]; + 131 -> {132} [style=dotted]; + 131 -> {143} [color=green]; + 131 -> {143} [style=dashed]; + + subgraph cluster_48 { + color=red + 133 [label="Enter function [2]" style="filled" fillcolor=red]; + 134 [label="Delegated constructor call: super() [2]"]; + 135 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 133 -> {134}; + 134 -> {135}; + + subgraph cluster_49 { + color=red + 136 [label="Enter function getter [3]" style="filled" fillcolor=red]; + 137 [label="Exit function getter [3]" style="filled" fillcolor=red]; + } + 136 -> {137}; + + subgraph cluster_50 { + color=red + 138 [label="Enter property [2]" style="filled" fillcolor=red]; + 139 [label="Access variable R|/node| [2]"]; + 140 [label="Exit property [2]" style="filled" fillcolor=red]; + } + 138 -> {139}; + 139 -> {140}; + 140 -> {131} [color=green]; + + subgraph cluster_51 { + color=red + 141 [label="Enter function getter [3]" style="filled" fillcolor=red]; + 142 [label="Exit function getter [3]" style="filled" fillcolor=red]; + } + 141 -> {142}; + + subgraph cluster_52 { + color=red + 143 [label="Enter property [2]" style="filled" fillcolor=red]; + 144 [label="Access variable R|/token| [2]"]; + 145 [label="Exit property [2]" style="filled" fillcolor=red]; + } + 143 -> {144}; + 144 -> {145}; + 145 -> {132} [color=green]; + + subgraph cluster_53 { + color=red + 146 [label="Enter class FirPsiModifier [2]" style="filled" fillcolor=red]; + 147 [label="Exit class FirPsiModifier [2]" style="filled" fillcolor=red]; + } + 146 -> {147} [color=green]; + + subgraph cluster_54 { + color=red + 148 [label="Enter function [3]" style="filled" fillcolor=red]; + 149 [label="Access variable R|/node| [4]"]; + 150 [label="Access variable R|/token| [4]"]; + 151 [label="Delegated constructor call: super|>(...) [3]"]; + 152 [label="Exit function [3]" style="filled" fillcolor=red]; + } + 148 -> {149}; + 149 -> {150}; + 150 -> {151}; + 151 -> {152}; + + subgraph cluster_55 { + color=red + 153 [label="Enter class FirLightModifier [2]" style="filled" fillcolor=red]; + 154 [label="Part of class initialization [2]"]; + 155 [label="Exit class FirLightModifier [2]" style="filled" fillcolor=red]; + } + 153 -> {154} [color=green]; + 154 -> {155} [style=dotted]; + 154 -> {163} [color=green]; + 154 -> {163} [style=dashed]; + + subgraph cluster_56 { + color=red + 156 [label="Enter function [3]" style="filled" fillcolor=red]; + 157 [label="Access variable R|/node| [4]"]; + 158 [label="Access variable R|/token| [4]"]; + 159 [label="Delegated constructor call: super|>(...) [3]"]; + 160 [label="Exit function [3]" style="filled" fillcolor=red]; + } + 156 -> {157}; + 157 -> {158}; + 158 -> {159}; + 159 -> {160}; + + subgraph cluster_57 { + color=red + 161 [label="Enter function getter [4]" style="filled" fillcolor=red]; + 162 [label="Exit function getter [4]" style="filled" fillcolor=red]; + } + 161 -> {162}; + + subgraph cluster_58 { + color=red + 163 [label="Enter property [3]" style="filled" fillcolor=red]; + 164 [label="Access variable R|/tree| [3]"]; + 165 [label="Exit property [3]" style="filled" fillcolor=red]; + } + 163 -> {164}; + 164 -> {165}; + 165 -> {155} [color=green]; + + subgraph cluster_59 { + color=red + 166 [label="Enter class FirModifierList [1]" style="filled" fillcolor=red]; + 167 [label="Part of class initialization [1]"]; + 168 [label="Exit class FirModifierList [1]" style="filled" fillcolor=red]; + } + 166 -> {167} [color=green]; + 167 -> {168} [style=dotted]; + 167 -> {174} [color=green]; + 167 -> {174} [style=dashed]; + + subgraph cluster_60 { + color=red + 169 [label="Enter function [2]" style="filled" fillcolor=red]; + 170 [label="Delegated constructor call: super() [2]"]; + 171 [label="Exit function [2]" style="filled" fillcolor=red]; + } + 169 -> {170}; + 170 -> {171}; + + subgraph cluster_61 { + color=red + 172 [label="Enter function getter [3]" style="filled" fillcolor=red]; + 173 [label="Exit function getter [3]" style="filled" fillcolor=red]; + } + 172 -> {173}; + + subgraph cluster_62 { + color=red + 174 [label="Enter property [2]" style="filled" fillcolor=red]; + 175 [label="Function call: R|kotlin/collections/emptyList||>() [2]"]; + 176 [label="Exit property [2]" style="filled" fillcolor=red]; + } + 174 -> {175}; + 175 -> {176}; + 176 -> {168} [color=green]; + + subgraph cluster_63 { + color=red + 177 [label="Enter class FirPsiModifierList [2]" style="filled" fillcolor=red]; + 178 [label="Part of class initialization [2]"]; + 179 [label="Exit class FirPsiModifierList [2]" style="filled" fillcolor=red]; + } + 177 -> {178} [color=green]; + 178 -> {179} [style=dotted]; + 178 -> {185} [color=green]; + 178 -> {185} [style=dashed]; + + subgraph cluster_64 { + color=red + 180 [label="Enter function [3]" style="filled" fillcolor=red]; + 181 [label="Delegated constructor call: super() [3]"]; + 182 [label="Exit function [3]" style="filled" fillcolor=red]; + } + 180 -> {181}; + 181 -> {182}; + + subgraph cluster_65 { + color=red + 183 [label="Enter function getter [4]" style="filled" fillcolor=red]; + 184 [label="Exit function getter [4]" style="filled" fillcolor=red]; + } + 183 -> {184}; + + subgraph cluster_66 { + color=red + 185 [label="Enter property [3]" style="filled" fillcolor=red]; + 186 [label="Access variable R|/modifierList| [3]"]; + 187 [label="Exit property [3]" style="filled" fillcolor=red]; + } + 185 -> {186}; + 186 -> {187}; + 187 -> {179} [color=green]; + + subgraph cluster_67 { + color=red + 188 [label="Enter class FirLightModifierList [2]" style="filled" fillcolor=red]; + 189 [label="Part of class initialization [2]"]; + 190 [label="Part of class initialization [2]"]; + 191 [label="Exit class FirLightModifierList [2]" style="filled" fillcolor=red]; + } + 188 -> {189} [color=green]; + 189 -> {190} [style=dotted]; + 189 -> {197} [color=green]; + 189 -> {197} [style=dashed]; + 190 -> {191} [style=dotted]; + 190 -> {202} [color=green]; + 190 -> {202} [style=dashed]; + + subgraph cluster_68 { + color=red + 192 [label="Enter function [3]" style="filled" fillcolor=red]; + 193 [label="Delegated constructor call: super() [3]"]; + 194 [label="Exit function [3]" style="filled" fillcolor=red]; + } + 192 -> {193}; + 193 -> {194}; + + subgraph cluster_69 { + color=red + 195 [label="Enter function getter [4]" style="filled" fillcolor=red]; + 196 [label="Exit function getter [4]" style="filled" fillcolor=red]; + } + 195 -> {196}; + + subgraph cluster_70 { + color=red + 197 [label="Enter property [3]" style="filled" fillcolor=red]; + 198 [label="Access variable R|/modifierList| [3]"]; + 199 [label="Exit property [3]" style="filled" fillcolor=red]; + } + 197 -> {198}; + 198 -> {199}; + 199 -> {190} [color=green]; + + subgraph cluster_71 { + color=red + 200 [label="Enter function getter [4]" style="filled" fillcolor=red]; + 201 [label="Exit function getter [4]" style="filled" fillcolor=red]; + } + 200 -> {201}; + + subgraph cluster_72 { + color=red + 202 [label="Enter property [3]" style="filled" fillcolor=red]; + 203 [label="Access variable R|/tree| [3]"]; + 204 [label="Exit property [3]" style="filled" fillcolor=red]; + } + 202 -> {203}; + 203 -> {204}; + 204 -> {191} [color=green]; + + subgraph cluster_73 { + color=red + 205 [label="Enter class Companion [2]" style="filled" fillcolor=red]; + 206 [label="Exit class Companion [2]" style="filled" fillcolor=red]; + } + 205 -> {206} [color=green]; + + subgraph cluster_74 { + color=red + 207 [label="Enter function [3]" style="filled" fillcolor=red]; + 208 [label="Delegated constructor call: super() [3]"]; + 209 [label="Exit function [3]" style="filled" fillcolor=red]; + } + 207 -> {208}; + 208 -> {209}; + + subgraph cluster_75 { + color=red + 210 [label="Enter function getModifierList [3]" style="filled" fillcolor=red]; + subgraph cluster_76 { + color=blue + 211 [label="Enter block [3]"]; + subgraph cluster_77 { + color=blue + 212 [label="Enter when [3]"]; + 213 [label="Access variable this@R|/FirModifierList.Companion.getModifierList| [4]"]; + subgraph cluster_78 { + color=blue + 214 [label="Enter when branch condition [4]"]; + 215 [label="Const: Null(null) [5]"]; + 216 [label="Equality operator == [5]"]; + 217 [label="Exit when branch condition [4]"]; + } + subgraph cluster_79 { + color=blue + 218 [label="Enter when branch condition [4]"]; + 219 [label="Type operator: ($subj$ is R|FirPsiSourceElement|) [5]"]; + 220 [label="Exit when branch condition [4]"]; + } + subgraph cluster_80 { + color=blue + 221 [label="Enter when branch condition [4]"]; + 222 [label="Type operator: ($subj$ is R|FirLightSourceElement|) [5]"]; + 223 [label="Exit when branch condition [4]"]; + } + 224 [label="Enter when branch result [5]"]; + subgraph cluster_81 { + color=blue + 225 [label="Enter block [7]"]; + 226 [label="Access variable R|/FirLightSourceElement.lighterASTNode| [9]"]; + 227 [label="Access variable R|/FirLightSourceElement.treeStructure| [9]"]; + 228 [label="Function call: this@R|/FirModifierList.Companion.getModifierList|.R|/FirLightSourceElement.lighterASTNode|.R|/LighterASTNode.getChildren|(...) [8]"]; + 229 [label="Postponed enter to lambda [8]"]; + subgraph cluster_82 { + color=blue + 275 [label="Enter function anonymousFunction [9]" style="filled" fillcolor=red]; + subgraph cluster_83 { + color=blue + 276 [label="Enter block [9]"]; + 277 [label="Access variable R|/it| [9]"]; + 278 [label="Enter safe call [9]"]; + 279 [label="Access variable R|/LighterASTNode.tokenType| [9]"]; + 280 [label="Exit safe call [9]"]; + 281 [label="Access qualifier /TokenType [9]"]; + 282 [label="Access variable R|/TokenType.Companion.MODIFIER_LIST| [9]"]; + 283 [label="Equality operator == [9]"]; + 284 [label="Exit block [9]"]; + } + 285 [label="Exit function anonymousFunction [9]" style="filled" fillcolor=red]; + } + 230 [label="Postponed exit from lambda [8]"]; + 231 [label="Function call: this@R|/FirModifierList.Companion.getModifierList|.R|/FirLightSourceElement.lighterASTNode|.R|/LighterASTNode.getChildren|(...).R|kotlin/collections/find|(...) [7]"]; + 232 [label="Exit lhs of ?: [7]"]; + 233 [label="Enter rhs of ?: [7]"]; + 234 [label="Const: Null(null) [7]"]; + 235 [label="Jump: ^getModifierList Null(null) [7]"]; + 236 [label="Stub [7]" style="filled" fillcolor=gray]; + 237 [label="Lhs of ?: is not null [7]"]; + 238 [label="Exit ?: [7]"]; + 239 [label="Variable declaration: lval modifierListNode: R|LighterASTNode| [7]"]; + 240 [label="Access variable R|/modifierListNode| [8]"]; + 241 [label="Access variable R|/FirLightSourceElement.treeStructure| [8]"]; + 242 [label="Function call: R|/FirModifierList.FirLightModifierList.FirLightModifierList|(...) [7]"]; + 243 [label="Exit block [7]"]; + } + 244 [label="Exit when branch result [6]"]; + 245 [label="Enter when branch result [5]"]; + subgraph cluster_84 { + color=blue + 246 [label="Enter block [6]"]; + 247 [label="Access variable R|/FirPsiSourceElement.psi| [6]"]; + 248 [label="Type operator: (this@R|/FirModifierList.Companion.getModifierList|.R|/FirPsiSourceElement.psi| as? R|KtModifierListOwner|) [6]"]; + 249 [label="Enter safe call [6]"]; + 250 [label="Access variable R|/KtModifierListOwner.modifierList| [6]"]; + 251 [label="Exit safe call [6]"]; + 252 [label="Enter safe call [6]"]; + 253 [label="Postponed enter to lambda [7]"]; + subgraph cluster_85 { + color=blue + 269 [label="Enter function anonymousFunction [8]" style="filled" fillcolor=red]; + subgraph cluster_86 { + color=blue + 270 [label="Enter block [8]"]; + 271 [label="Access variable R|/it| [9]"]; + 272 [label="Function call: R|/FirModifierList.FirPsiModifierList.FirPsiModifierList|(...) [8]"]; + 273 [label="Exit block [8]"]; + } + 274 [label="Exit function anonymousFunction [8]" style="filled" fillcolor=red]; + } + 254 [label="Postponed exit from lambda [7]"]; + 255 [label="Function call: $subj$.R|kotlin/let|(...) [6]"]; + 256 [label="Exit safe call [6]"]; + 257 [label="Exit block [6]"]; + } + 258 [label="Exit when branch result [5]"]; + 259 [label="Enter when branch result [5]"]; + subgraph cluster_87 { + color=blue + 260 [label="Enter block [5]"]; + 261 [label="Const: Null(null) [5]"]; + 262 [label="Exit block [5]"]; + } + 263 [label="Exit when branch result [4]"]; + 264 [label="Exit when [3]"]; + } + 265 [label="Jump: ^getModifierList when (this@R|/FirModifierList.Companion.getModifierList|) { + ==($subj$, Null(null)) -> { + Null(null) + } + ($subj$ is R|FirPsiSourceElement|) -> { + (this@R|/FirModifierList.Companion.getModifierList|.R|/FirPsiSourceElement.psi| as? R|KtModifierListOwner|)?.{ $subj$.R|/KtModifierListOwner.modifierList| }?.{ $subj$.R|kotlin/let|( = let@fun (it: R|KtModifierList|): R|FirModifierList.FirPsiModifierList| { + ^ R|/FirModifierList.FirPsiModifierList.FirPsiModifierList|(R|/it|) + } + ) } + } + ($subj$ is R|FirLightSourceElement|) -> { + lval modifierListNode: R|LighterASTNode| = this@R|/FirModifierList.Companion.getModifierList|.R|/FirLightSourceElement.lighterASTNode|.R|/LighterASTNode.getChildren|(this@R|/FirModifierList.Companion.getModifierList|.R|/FirLightSourceElement.treeStructure|).R|kotlin/collections/find|( = find@fun (it: R|LighterASTNode?|): R|kotlin/Boolean| { + ^ ==(R|/it|?.{ $subj$.R|/LighterASTNode.tokenType| }, Q|TokenType|.R|/TokenType.Companion.MODIFIER_LIST|) + } + ) ?: ^getModifierList Null(null) + R|/FirModifierList.FirLightModifierList.FirLightModifierList|(R|/modifierListNode|, this@R|/FirModifierList.Companion.getModifierList|.R|/FirLightSourceElement.treeStructure|) + } +} + [3]"]; + 266 [label="Stub [3]" style="filled" fillcolor=gray]; + 267 [label="Exit block [3]" style="filled" fillcolor=gray]; + } + 268 [label="Exit function getModifierList [3]" style="filled" fillcolor=red]; + } + 210 -> {211}; + 211 -> {212}; + 212 -> {213}; + 213 -> {214}; + 214 -> {215}; + 215 -> {216}; + 216 -> {217}; + 217 -> {259 218}; + 218 -> {219}; + 219 -> {220}; + 220 -> {245 221}; + 221 -> {222}; + 222 -> {223}; + 223 -> {224}; + 224 -> {225}; + 225 -> {226}; + 226 -> {227}; + 227 -> {228}; + 228 -> {229}; + 229 -> {275}; + 229 -> {230} [color=red]; + 229 -> {275} [style=dashed]; + 230 -> {231}; + 231 -> {232}; + 232 -> {237 233}; + 233 -> {234}; + 234 -> {235}; + 235 -> {268}; + 235 -> {236} [style=dotted]; + 236 -> {238} [style=dotted]; + 237 -> {238}; + 238 -> {239}; + 239 -> {240}; + 240 -> {241}; + 241 -> {242}; + 242 -> {243}; + 243 -> {244}; + 244 -> {264}; + 245 -> {246}; + 246 -> {247}; + 247 -> {248}; + 248 -> {249 251}; + 249 -> {250}; + 250 -> {251}; + 251 -> {252 256}; + 252 -> {253}; + 253 -> {269}; + 253 -> {254} [color=red]; + 253 -> {269} [style=dashed]; + 254 -> {255}; + 255 -> {256}; + 256 -> {257}; + 257 -> {258}; + 258 -> {264}; + 259 -> {260}; + 260 -> {261}; + 261 -> {262}; + 262 -> {263}; + 263 -> {264}; + 264 -> {265}; + 265 -> {268}; + 265 -> {266} [style=dotted]; + 266 -> {267} [style=dotted]; + 267 -> {268} [style=dotted]; + 269 -> {270}; + 270 -> {271}; + 271 -> {272}; + 272 -> {273}; + 273 -> {274}; + 274 -> {254} [color=green]; + 275 -> {285 276}; + 276 -> {277}; + 277 -> {278 280}; + 278 -> {279}; + 279 -> {280}; + 280 -> {281}; + 281 -> {282}; + 282 -> {283}; + 283 -> {284}; + 284 -> {285}; + 285 -> {230} [color=green]; + 285 -> {275} [color=green style=dashed]; + + subgraph cluster_88 { + color=red + 286 [label="Enter function boxImpl [3]" style="filled" fillcolor=red]; + subgraph cluster_89 { + color=blue + 287 [label="Enter block [3]"]; + 288 [label="Function call: R|/LighterASTNode.LighterASTNode|() [6]"]; + 289 [label="Function call: R|kotlin/collections/listOf|(...) [5]"]; + 290 [label="Function call: R|/LighterASTNode.LighterASTNode|(...) [4]"]; + 291 [label="Function call: R|/FlyweightCapableTreeStructure.FlyweightCapableTreeStructure|() [4]"]; + 292 [label="Function call: R|/FirLightSourceElement.FirLightSourceElement|(...) [3]"]; + 293 [label="Variable declaration: lval sourceElement: R|FirSourceElement?| [3]"]; + 294 [label="Access variable R|/sourceElement| [4]"]; + 295 [label="Function call: (this@R|/FirModifierList.Companion|, R|/sourceElement|).R|/FirModifierList.Companion.getModifierList|() [3]"]; + 296 [label="Variable declaration: lval result: R|FirModifierList?| [3]"]; + subgraph cluster_90 { + color=blue + 297 [label="Enter when [3]"]; + subgraph cluster_91 { + color=blue + 298 [label="Enter when branch condition [4]"]; + 299 [label="Access variable R|/result| [5]"]; + 300 [label="Type operator: (R|/result| is R|FirModifierList.FirLightModifierList|) [5]"]; + 301 [label="Exit when branch condition [4]"]; + } + subgraph cluster_92 { + color=blue + 302 [label="Enter when branch condition else [4]"]; + 303 [label="Exit when branch condition [4]"]; + } + 304 [label="Enter when branch result [5]"]; + subgraph cluster_93 { + color=blue + 305 [label="Enter block [6]"]; + 306 [label="Const: String(Fail) [6]"]; + 307 [label="Exit block [6]"]; + } + 308 [label="Exit when branch result [5]"]; + 309 [label="Enter when branch result [5]"]; + subgraph cluster_94 { + color=blue + 310 [label="Enter block [5]"]; + 311 [label="Const: String(OK) [5]"]; + 312 [label="Exit block [5]"]; + } + 313 [label="Exit when branch result [4]"]; + 314 [label="Exit when [3]"]; + } + 315 [label="Jump: ^boxImpl when () { + (R|/result| is R|FirModifierList.FirLightModifierList|) -> { + String(OK) + } + else -> { + String(Fail) + } +} + [3]"]; + 316 [label="Stub [3]" style="filled" fillcolor=gray]; + 317 [label="Exit block [3]" style="filled" fillcolor=gray]; + } + 318 [label="Exit function boxImpl [3]" style="filled" fillcolor=red]; + } + 286 -> {287}; + 287 -> {288}; + 288 -> {289}; + 289 -> {290}; + 290 -> {291}; + 291 -> {292}; + 292 -> {293}; + 293 -> {294}; + 294 -> {295}; + 295 -> {296}; + 296 -> {297}; + 297 -> {298}; + 298 -> {299}; + 299 -> {300}; + 300 -> {301}; + 301 -> {309 302}; + 302 -> {303}; + 303 -> {304}; + 304 -> {305}; + 305 -> {306}; + 306 -> {307}; + 307 -> {308}; + 308 -> {314}; + 309 -> {310}; + 310 -> {311}; + 311 -> {312}; + 312 -> {313}; + 313 -> {314}; + 314 -> {315}; + 315 -> {318}; + 315 -> {316} [style=dotted]; + 316 -> {317} [style=dotted]; + 317 -> {318} [style=dotted]; + + subgraph cluster_95 { + color=red + 319 [label="Enter function box [1]" style="filled" fillcolor=red]; + subgraph cluster_96 { + color=blue + 320 [label="Enter block [1]"]; + 321 [label="Access qualifier /FirModifierList [2]"]; + 322 [label="Function call: Q|FirModifierList|.R|/FirModifierList.Companion.boxImpl|() [1]"]; + 323 [label="Jump: ^box Q|FirModifierList|.R|/FirModifierList.Companion.boxImpl|() [1]"]; + 324 [label="Stub [1]" style="filled" fillcolor=gray]; + 325 [label="Exit block [1]" style="filled" fillcolor=gray]; + } + 326 [label="Exit function box [1]" style="filled" fillcolor=red]; + } + 319 -> {320}; + 320 -> {321}; + 321 -> {322}; + 322 -> {323}; + 323 -> {326}; + 323 -> {324} [style=dotted]; + 324 -> {325} [style=dotted]; + 325 -> {326} [style=dotted]; + +} diff --git a/compiler/testData/codegen/box/smartCasts/kt44814.fir.txt b/compiler/testData/codegen/box/smartCasts/kt44814.fir.txt new file mode 100644 index 00000000000..3a7a063cd9d --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/kt44814.fir.txt @@ -0,0 +1,762 @@ +FILE fqName: fileName:/kt44814.kt + CLASS CLASS name:FlyweightCapableTreeStructure modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FlyweightCapableTreeStructure + CONSTRUCTOR visibility:public <> () returnType:.FlyweightCapableTreeStructure [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FlyweightCapableTreeStructure modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:FirSourceElement modality:SEALED visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirSourceElement + CONSTRUCTOR visibility:protected <> () returnType:.FirSourceElement [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FirSourceElement modality:SEALED visibility:public superTypes:[kotlin.Any]' + PROPERTY name:lighterASTNode visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.FirSourceElement) returnType:.LighterASTNode + correspondingProperty: PROPERTY name:lighterASTNode visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.FirSourceElement + PROPERTY name:treeStructure visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.FirSourceElement) returnType:.FlyweightCapableTreeStructure + correspondingProperty: PROPERTY name:treeStructure visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.FirSourceElement + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:FirPsiSourceElement modality:FINAL visibility:public superTypes:[.FirSourceElement] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirPsiSourceElement + CONSTRUCTOR visibility:public <> (psi:.PsiElement, lighterASTNode:.LighterASTNode, treeStructure:.FlyweightCapableTreeStructure) returnType:.FirPsiSourceElement [primary] + VALUE_PARAMETER name:psi index:0 type:.PsiElement + VALUE_PARAMETER name:lighterASTNode index:1 type:.LighterASTNode + VALUE_PARAMETER name:treeStructure index:2 type:.FlyweightCapableTreeStructure + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .FirSourceElement' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FirPsiSourceElement modality:FINAL visibility:public superTypes:[.FirSourceElement]' + PROPERTY name:psi visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:psi type:.PsiElement visibility:private [final] + EXPRESSION_BODY + GET_VAR 'psi: .PsiElement declared in .FirPsiSourceElement.' type=.PsiElement origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirPsiSourceElement) returnType:.PsiElement + correspondingProperty: PROPERTY name:psi visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.FirPsiSourceElement + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .PsiElement declared in .FirPsiSourceElement' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:psi type:.PsiElement visibility:private [final]' type=.PsiElement origin=null + receiver: GET_VAR ': .FirPsiSourceElement declared in .FirPsiSourceElement.' type=.FirPsiSourceElement origin=null + PROPERTY name:lighterASTNode visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:lighterASTNode type:.LighterASTNode visibility:private [final] + EXPRESSION_BODY + GET_VAR 'lighterASTNode: .LighterASTNode declared in .FirPsiSourceElement.' type=.LighterASTNode origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirPsiSourceElement) returnType:.LighterASTNode + correspondingProperty: PROPERTY name:lighterASTNode visibility:public modality:FINAL [val] + overridden: + public abstract fun (): .LighterASTNode declared in .FirSourceElement + $this: VALUE_PARAMETER name: type:.FirPsiSourceElement + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .LighterASTNode declared in .FirPsiSourceElement' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:lighterASTNode type:.LighterASTNode visibility:private [final]' type=.LighterASTNode origin=null + receiver: GET_VAR ': .FirPsiSourceElement declared in .FirPsiSourceElement.' type=.FirPsiSourceElement origin=null + PROPERTY name:treeStructure visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:treeStructure type:.FlyweightCapableTreeStructure visibility:private [final] + EXPRESSION_BODY + GET_VAR 'treeStructure: .FlyweightCapableTreeStructure declared in .FirPsiSourceElement.' type=.FlyweightCapableTreeStructure origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirPsiSourceElement) returnType:.FlyweightCapableTreeStructure + correspondingProperty: PROPERTY name:treeStructure visibility:public modality:FINAL [val] + overridden: + public abstract fun (): .FlyweightCapableTreeStructure declared in .FirSourceElement + $this: VALUE_PARAMETER name: type:.FirPsiSourceElement + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .FlyweightCapableTreeStructure declared in .FirPsiSourceElement' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:treeStructure type:.FlyweightCapableTreeStructure visibility:private [final]' type=.FlyweightCapableTreeStructure origin=null + receiver: GET_VAR ': .FirPsiSourceElement declared in .FirPsiSourceElement.' type=.FirPsiSourceElement origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:FirLightSourceElement modality:FINAL visibility:public superTypes:[.FirSourceElement] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirLightSourceElement + CONSTRUCTOR visibility:public <> (lighterASTNode:.LighterASTNode, treeStructure:.FlyweightCapableTreeStructure) returnType:.FirLightSourceElement [primary] + VALUE_PARAMETER name:lighterASTNode index:0 type:.LighterASTNode + VALUE_PARAMETER name:treeStructure index:1 type:.FlyweightCapableTreeStructure + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .FirSourceElement' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FirLightSourceElement modality:FINAL visibility:public superTypes:[.FirSourceElement]' + PROPERTY name:lighterASTNode visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:lighterASTNode type:.LighterASTNode visibility:private [final] + EXPRESSION_BODY + GET_VAR 'lighterASTNode: .LighterASTNode declared in .FirLightSourceElement.' type=.LighterASTNode origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirLightSourceElement) returnType:.LighterASTNode + correspondingProperty: PROPERTY name:lighterASTNode visibility:public modality:FINAL [val] + overridden: + public abstract fun (): .LighterASTNode declared in .FirSourceElement + $this: VALUE_PARAMETER name: type:.FirLightSourceElement + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .LighterASTNode declared in .FirLightSourceElement' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:lighterASTNode type:.LighterASTNode visibility:private [final]' type=.LighterASTNode origin=null + receiver: GET_VAR ': .FirLightSourceElement declared in .FirLightSourceElement.' type=.FirLightSourceElement origin=null + PROPERTY name:treeStructure visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:treeStructure type:.FlyweightCapableTreeStructure visibility:private [final] + EXPRESSION_BODY + GET_VAR 'treeStructure: .FlyweightCapableTreeStructure declared in .FirLightSourceElement.' type=.FlyweightCapableTreeStructure origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirLightSourceElement) returnType:.FlyweightCapableTreeStructure + correspondingProperty: PROPERTY name:treeStructure visibility:public modality:FINAL [val] + overridden: + public abstract fun (): .FlyweightCapableTreeStructure declared in .FirSourceElement + $this: VALUE_PARAMETER name: type:.FirLightSourceElement + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .FlyweightCapableTreeStructure declared in .FirLightSourceElement' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:treeStructure type:.FlyweightCapableTreeStructure visibility:private [final]' type=.FlyweightCapableTreeStructure origin=null + receiver: GET_VAR ': .FirLightSourceElement declared in .FirLightSourceElement.' type=.FirLightSourceElement origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:PsiElement modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.PsiElement + CONSTRUCTOR visibility:public <> () returnType:.PsiElement [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:PsiElement modality:OPEN visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:ASTNode modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ASTNode + CONSTRUCTOR visibility:public <> () returnType:.ASTNode [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ASTNode modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:LighterASTNode modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.LighterASTNode + CONSTRUCTOR visibility:public <> (_children:kotlin.collections.List<.LighterASTNode?>) returnType:.LighterASTNode [primary] + VALUE_PARAMETER name:_children index:0 type:kotlin.collections.List<.LighterASTNode?> + EXPRESSION_BODY + CALL 'public final fun emptyList (): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.LighterASTNode?> origin=null + : .LighterASTNode? + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:LighterASTNode modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:_children visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:_children type:kotlin.collections.List<.LighterASTNode?> visibility:private [final] + EXPRESSION_BODY + GET_VAR '_children: kotlin.collections.List<.LighterASTNode?> declared in .LighterASTNode.' type=kotlin.collections.List<.LighterASTNode?> origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.LighterASTNode) returnType:kotlin.collections.List<.LighterASTNode?> + correspondingProperty: PROPERTY name:_children visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.LighterASTNode + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.collections.List<.LighterASTNode?> declared in .LighterASTNode' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:_children type:kotlin.collections.List<.LighterASTNode?> visibility:private [final]' type=kotlin.collections.List<.LighterASTNode?> origin=null + receiver: GET_VAR ': .LighterASTNode declared in .LighterASTNode.' type=.LighterASTNode origin=null + FUN name:getChildren visibility:public modality:FINAL <> ($this:.LighterASTNode, treeStructure:.FlyweightCapableTreeStructure) returnType:kotlin.collections.List<.LighterASTNode?> + $this: VALUE_PARAMETER name: type:.LighterASTNode + VALUE_PARAMETER name:treeStructure index:0 type:.FlyweightCapableTreeStructure + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun getChildren (treeStructure: .FlyweightCapableTreeStructure): kotlin.collections.List<.LighterASTNode?> declared in .LighterASTNode' + CALL 'public final fun (): kotlin.collections.List<.LighterASTNode?> declared in .LighterASTNode' type=kotlin.collections.List<.LighterASTNode?> origin=GET_PROPERTY + $this: GET_VAR ': .LighterASTNode declared in .LighterASTNode.getChildren' type=.LighterASTNode origin=null + PROPERTY name:tokenType visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:tokenType type:.TokenType visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun (): .TokenType declared in .TokenType.Companion' type=.TokenType origin=GET_PROPERTY + $this: GET_OBJECT 'CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' type=.TokenType.Companion + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.LighterASTNode) returnType:.TokenType + correspondingProperty: PROPERTY name:tokenType visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.LighterASTNode + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .TokenType declared in .LighterASTNode' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:tokenType type:.TokenType visibility:private [final]' type=.TokenType origin=null + receiver: GET_VAR ': .LighterASTNode declared in .LighterASTNode.' type=.LighterASTNode origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:TokenType modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TokenType + CONSTRUCTOR visibility:public <> () returnType:.TokenType [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TokenType modality:FINAL visibility:public superTypes:[kotlin.Any]' + CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TokenType.Companion + CONSTRUCTOR visibility:private <> () returnType:.TokenType.Companion [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' + PROPERTY name:MODIFIER_LIST visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:MODIFIER_LIST type:.TokenType visibility:private [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .TokenType' type=.TokenType origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TokenType.Companion) returnType:.TokenType + correspondingProperty: PROPERTY name:MODIFIER_LIST visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.TokenType.Companion + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .TokenType declared in .TokenType.Companion' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:MODIFIER_LIST type:.TokenType visibility:private [final]' type=.TokenType origin=null + receiver: GET_VAR ': .TokenType.Companion declared in .TokenType.Companion.' type=.TokenType.Companion origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:KtModifierKeywordToken modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KtModifierKeywordToken + CONSTRUCTOR visibility:public <> () returnType:.KtModifierKeywordToken [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:KtModifierKeywordToken modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:KtModifierList modality:FINAL visibility:public superTypes:[.PsiElement] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KtModifierList + CONSTRUCTOR visibility:public <> () returnType:.KtModifierList [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .PsiElement' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:KtModifierList modality:FINAL visibility:public superTypes:[.PsiElement]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:KtModifierListOwner modality:FINAL visibility:public superTypes:[.PsiElement] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KtModifierListOwner + CONSTRUCTOR visibility:public <> () returnType:.KtModifierListOwner [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .PsiElement' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:KtModifierListOwner modality:FINAL visibility:public superTypes:[.PsiElement]' + PROPERTY name:modifierList visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:modifierList type:.KtModifierList visibility:private [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .KtModifierList' type=.KtModifierList origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.KtModifierListOwner) returnType:.KtModifierList + correspondingProperty: PROPERTY name:modifierList visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.KtModifierListOwner + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .KtModifierList declared in .KtModifierListOwner' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:modifierList type:.KtModifierList visibility:private [final]' type=.KtModifierList origin=null + receiver: GET_VAR ': .KtModifierListOwner declared in .KtModifierListOwner.' type=.KtModifierListOwner origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:FirModifier modality:SEALED visibility:internal superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirModifier.FirModifier> + TYPE_PARAMETER name:Node index:0 variance: superTypes:[kotlin.Any] + CONSTRUCTOR visibility:protected <> (node:Node of .FirModifier, token:.KtModifierKeywordToken) returnType:.FirModifier.FirModifier> [primary] + VALUE_PARAMETER name:node index:0 type:Node of .FirModifier + VALUE_PARAMETER name:token index:1 type:.KtModifierKeywordToken + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FirModifier modality:SEALED visibility:internal superTypes:[kotlin.Any]' + PROPERTY name:node visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:node type:Node of .FirModifier visibility:private [final] + EXPRESSION_BODY + GET_VAR 'node: Node of .FirModifier declared in .FirModifier.' type=Node of .FirModifier origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirModifier.FirModifier>) returnType:Node of .FirModifier + correspondingProperty: PROPERTY name:node visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.FirModifier.FirModifier> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): Node of .FirModifier declared in .FirModifier' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:node type:Node of .FirModifier visibility:private [final]' type=Node of .FirModifier origin=null + receiver: GET_VAR ': .FirModifier.FirModifier> declared in .FirModifier.' type=.FirModifier.FirModifier> origin=null + PROPERTY name:token visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:token type:.KtModifierKeywordToken visibility:private [final] + EXPRESSION_BODY + GET_VAR 'token: .KtModifierKeywordToken declared in .FirModifier.' type=.KtModifierKeywordToken origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirModifier.FirModifier>) returnType:.KtModifierKeywordToken + correspondingProperty: PROPERTY name:token visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.FirModifier.FirModifier> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .KtModifierKeywordToken declared in .FirModifier' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:token type:.KtModifierKeywordToken visibility:private [final]' type=.KtModifierKeywordToken origin=null + receiver: GET_VAR ': .FirModifier.FirModifier> declared in .FirModifier.' type=.FirModifier.FirModifier> origin=null + CLASS CLASS name:FirPsiModifier modality:FINAL visibility:public superTypes:[.FirModifier<.ASTNode>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirModifier.FirPsiModifier + CONSTRUCTOR visibility:public <> (node:.ASTNode, token:.KtModifierKeywordToken) returnType:.FirModifier.FirPsiModifier [primary] + VALUE_PARAMETER name:node index:0 type:.ASTNode + VALUE_PARAMETER name:token index:1 type:.KtModifierKeywordToken + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'protected constructor (node: Node of .FirModifier, token: .KtModifierKeywordToken) [primary] declared in .FirModifier' + : .ASTNode + node: GET_VAR 'node: .ASTNode declared in .FirModifier.FirPsiModifier.' type=.ASTNode origin=null + token: GET_VAR 'token: .KtModifierKeywordToken declared in .FirModifier.FirPsiModifier.' type=.KtModifierKeywordToken origin=null + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FirPsiModifier modality:FINAL visibility:public superTypes:[.FirModifier<.ASTNode>]' + PROPERTY FAKE_OVERRIDE name:node visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.FirModifier.FirModifier>) returnType:.ASTNode [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:node visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): Node of .FirModifier declared in .FirModifier + $this: VALUE_PARAMETER name: type:.FirModifier.FirModifier> + PROPERTY FAKE_OVERRIDE name:token visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.FirModifier.FirModifier>) returnType:.KtModifierKeywordToken [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:token visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): .KtModifierKeywordToken declared in .FirModifier + $this: VALUE_PARAMETER name: type:.FirModifier.FirModifier> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:FirLightModifier modality:FINAL visibility:public superTypes:[.FirModifier<.LighterASTNode>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirModifier.FirLightModifier + CONSTRUCTOR visibility:public <> (node:.LighterASTNode, token:.KtModifierKeywordToken, tree:.FlyweightCapableTreeStructure) returnType:.FirModifier.FirLightModifier [primary] + VALUE_PARAMETER name:node index:0 type:.LighterASTNode + VALUE_PARAMETER name:token index:1 type:.KtModifierKeywordToken + VALUE_PARAMETER name:tree index:2 type:.FlyweightCapableTreeStructure + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'protected constructor (node: Node of .FirModifier, token: .KtModifierKeywordToken) [primary] declared in .FirModifier' + : .LighterASTNode + node: GET_VAR 'node: .LighterASTNode declared in .FirModifier.FirLightModifier.' type=.LighterASTNode origin=null + token: GET_VAR 'token: .KtModifierKeywordToken declared in .FirModifier.FirLightModifier.' type=.KtModifierKeywordToken origin=null + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FirLightModifier modality:FINAL visibility:public superTypes:[.FirModifier<.LighterASTNode>]' + PROPERTY name:tree visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:tree type:.FlyweightCapableTreeStructure visibility:private [final] + EXPRESSION_BODY + GET_VAR 'tree: .FlyweightCapableTreeStructure declared in .FirModifier.FirLightModifier.' type=.FlyweightCapableTreeStructure origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirModifier.FirLightModifier) returnType:.FlyweightCapableTreeStructure + correspondingProperty: PROPERTY name:tree visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.FirModifier.FirLightModifier + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .FlyweightCapableTreeStructure declared in .FirModifier.FirLightModifier' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:tree type:.FlyweightCapableTreeStructure visibility:private [final]' type=.FlyweightCapableTreeStructure origin=null + receiver: GET_VAR ': .FirModifier.FirLightModifier declared in .FirModifier.FirLightModifier.' type=.FirModifier.FirLightModifier origin=null + PROPERTY FAKE_OVERRIDE name:node visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.FirModifier.FirModifier>) returnType:.LighterASTNode [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:node visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): Node of .FirModifier declared in .FirModifier + $this: VALUE_PARAMETER name: type:.FirModifier.FirModifier> + PROPERTY FAKE_OVERRIDE name:token visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.FirModifier.FirModifier>) returnType:.KtModifierKeywordToken [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:token visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): .KtModifierKeywordToken declared in .FirModifier + $this: VALUE_PARAMETER name: type:.FirModifier.FirModifier> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:FirModifierList modality:SEALED visibility:internal superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirModifierList + CONSTRUCTOR visibility:protected <> () returnType:.FirModifierList [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FirModifierList modality:SEALED visibility:internal superTypes:[kotlin.Any]' + PROPERTY name:modifiers visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:modifiers type:kotlin.collections.List<.FirModifier<*>> visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun emptyList (): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.FirModifier<*>> origin=null + : .FirModifier<*> + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirModifierList) returnType:kotlin.collections.List<.FirModifier<*>> + correspondingProperty: PROPERTY name:modifiers visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.FirModifierList + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.collections.List<.FirModifier<*>> declared in .FirModifierList' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:modifiers type:kotlin.collections.List<.FirModifier<*>> visibility:private [final]' type=kotlin.collections.List<.FirModifier<*>> origin=null + receiver: GET_VAR ': .FirModifierList declared in .FirModifierList.' type=.FirModifierList origin=null + CLASS CLASS name:FirPsiModifierList modality:FINAL visibility:public superTypes:[.FirModifierList] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirModifierList.FirPsiModifierList + CONSTRUCTOR visibility:public <> (modifierList:.KtModifierList) returnType:.FirModifierList.FirPsiModifierList [primary] + VALUE_PARAMETER name:modifierList index:0 type:.KtModifierList + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .FirModifierList' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FirPsiModifierList modality:FINAL visibility:public superTypes:[.FirModifierList]' + PROPERTY name:modifierList visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:modifierList type:.KtModifierList visibility:private [final] + EXPRESSION_BODY + GET_VAR 'modifierList: .KtModifierList declared in .FirModifierList.FirPsiModifierList.' type=.KtModifierList origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirModifierList.FirPsiModifierList) returnType:.KtModifierList + correspondingProperty: PROPERTY name:modifierList visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.FirModifierList.FirPsiModifierList + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .KtModifierList declared in .FirModifierList.FirPsiModifierList' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:modifierList type:.KtModifierList visibility:private [final]' type=.KtModifierList origin=null + receiver: GET_VAR ': .FirModifierList.FirPsiModifierList declared in .FirModifierList.FirPsiModifierList.' type=.FirModifierList.FirPsiModifierList origin=null + PROPERTY FAKE_OVERRIDE name:modifiers visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.FirModifierList) returnType:kotlin.collections.List<.FirModifier<*>> [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:modifiers visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.collections.List<.FirModifier<*>> declared in .FirModifierList + $this: VALUE_PARAMETER name: type:.FirModifierList + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:FirLightModifierList modality:FINAL visibility:public superTypes:[.FirModifierList] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirModifierList.FirLightModifierList + CONSTRUCTOR visibility:public <> (modifierList:.LighterASTNode, tree:.FlyweightCapableTreeStructure) returnType:.FirModifierList.FirLightModifierList [primary] + VALUE_PARAMETER name:modifierList index:0 type:.LighterASTNode + VALUE_PARAMETER name:tree index:1 type:.FlyweightCapableTreeStructure + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .FirModifierList' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FirLightModifierList modality:FINAL visibility:public superTypes:[.FirModifierList]' + PROPERTY name:modifierList visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:modifierList type:.LighterASTNode visibility:private [final] + EXPRESSION_BODY + GET_VAR 'modifierList: .LighterASTNode declared in .FirModifierList.FirLightModifierList.' type=.LighterASTNode origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirModifierList.FirLightModifierList) returnType:.LighterASTNode + correspondingProperty: PROPERTY name:modifierList visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.FirModifierList.FirLightModifierList + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .LighterASTNode declared in .FirModifierList.FirLightModifierList' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:modifierList type:.LighterASTNode visibility:private [final]' type=.LighterASTNode origin=null + receiver: GET_VAR ': .FirModifierList.FirLightModifierList declared in .FirModifierList.FirLightModifierList.' type=.FirModifierList.FirLightModifierList origin=null + PROPERTY name:tree visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:tree type:.FlyweightCapableTreeStructure visibility:private [final] + EXPRESSION_BODY + GET_VAR 'tree: .FlyweightCapableTreeStructure declared in .FirModifierList.FirLightModifierList.' type=.FlyweightCapableTreeStructure origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.FirModifierList.FirLightModifierList) returnType:.FlyweightCapableTreeStructure + correspondingProperty: PROPERTY name:tree visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.FirModifierList.FirLightModifierList + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): .FlyweightCapableTreeStructure declared in .FirModifierList.FirLightModifierList' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:tree type:.FlyweightCapableTreeStructure visibility:private [final]' type=.FlyweightCapableTreeStructure origin=null + receiver: GET_VAR ': .FirModifierList.FirLightModifierList declared in .FirModifierList.FirLightModifierList.' type=.FirModifierList.FirLightModifierList origin=null + PROPERTY FAKE_OVERRIDE name:modifiers visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.FirModifierList) returnType:kotlin.collections.List<.FirModifier<*>> [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:modifiers visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.collections.List<.FirModifier<*>> declared in .FirModifierList + $this: VALUE_PARAMETER name: type:.FirModifierList + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirModifierList.Companion + CONSTRUCTOR visibility:private <> () returnType:.FirModifierList.Companion [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' + FUN name:getModifierList visibility:public modality:FINAL <> ($this:.FirModifierList.Companion, $receiver:.FirSourceElement?) returnType:.FirModifierList? + $this: VALUE_PARAMETER name: type:.FirModifierList.Companion + $receiver: VALUE_PARAMETER name: type:.FirSourceElement? + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun getModifierList (): .FirModifierList? declared in .FirModifierList.Companion' + BLOCK type=.FirModifierList? origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.FirSourceElement? [val] + GET_VAR ': .FirSourceElement? declared in .FirModifierList.Companion.getModifierList' type=.FirSourceElement? origin=null + WHEN type=.FirModifierList? origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: .FirSourceElement? [val] declared in .FirModifierList.Companion.getModifierList' type=.FirSourceElement? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.FirPsiSourceElement + GET_VAR 'val tmp_0: .FirSourceElement? [val] declared in .FirModifierList.Companion.getModifierList' type=.FirSourceElement? origin=null + then: BLOCK type=.FirModifierList.FirPsiModifierList? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.KtModifierList? [val] + BLOCK type=.KtModifierList? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.KtModifierListOwner? [val] + TYPE_OP type=.KtModifierListOwner? origin=SAFE_CAST typeOperand=.KtModifierListOwner + CALL 'public final fun (): .PsiElement declared in .FirPsiSourceElement' type=.PsiElement origin=GET_PROPERTY + $this: TYPE_OP type=.FirPsiSourceElement origin=IMPLICIT_CAST typeOperand=.FirPsiSourceElement + GET_VAR ': .FirSourceElement? declared in .FirModifierList.Companion.getModifierList' type=.FirSourceElement? origin=null + WHEN type=.KtModifierList? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_2: .KtModifierListOwner? [val] declared in .FirModifierList.Companion.getModifierList' type=.KtModifierListOwner? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun (): .KtModifierList declared in .KtModifierListOwner' type=.KtModifierList origin=GET_PROPERTY + $this: GET_VAR 'val tmp_2: .KtModifierListOwner? [val] declared in .FirModifierList.Companion.getModifierList' type=.KtModifierListOwner? origin=null + WHEN type=.FirModifierList.FirPsiModifierList? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: .KtModifierList? [val] declared in .FirModifierList.Companion.getModifierList' type=.KtModifierList? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun let (block: kotlin.Function1): R of kotlin.StandardKt.let [inline] declared in kotlin.StandardKt' type=.FirModifierList.FirPsiModifierList origin=null + : .KtModifierList + : .FirModifierList.FirPsiModifierList + $receiver: GET_VAR 'val tmp_1: .KtModifierList? [val] declared in .FirModifierList.Companion.getModifierList' type=.KtModifierList? origin=null + block: FUN_EXPR type=kotlin.Function1<.KtModifierList, .FirModifierList.FirPsiModifierList> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.KtModifierList) returnType:.FirModifierList.FirPsiModifierList + VALUE_PARAMETER name:it index:0 type:.KtModifierList + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: .KtModifierList): .FirModifierList.FirPsiModifierList declared in .FirModifierList.Companion.getModifierList' + CONSTRUCTOR_CALL 'public constructor (modifierList: .KtModifierList) [primary] declared in .FirModifierList.FirPsiModifierList' type=.FirModifierList.FirPsiModifierList origin=null + modifierList: GET_VAR 'it: .KtModifierList declared in .FirModifierList.Companion.getModifierList.' type=.KtModifierList origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.FirLightSourceElement + GET_VAR 'val tmp_0: .FirSourceElement? [val] declared in .FirModifierList.Companion.getModifierList' type=.FirSourceElement? origin=null + then: BLOCK type=.FirModifierList.FirLightModifierList origin=null + VAR name:modifierListNode type:.LighterASTNode [val] + BLOCK type=.LighterASTNode origin=ELVIS + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:.LighterASTNode? [val] + CALL 'public final fun find (predicate: kotlin.Function1): T of kotlin.collections.CollectionsKt.find? [inline] declared in kotlin.collections.CollectionsKt' type=.LighterASTNode? origin=null + : .LighterASTNode? + $receiver: CALL 'public final fun getChildren (treeStructure: .FlyweightCapableTreeStructure): kotlin.collections.List<.LighterASTNode?> declared in .LighterASTNode' type=kotlin.collections.List<.LighterASTNode?> origin=null + $this: CALL 'public final fun (): .LighterASTNode declared in .FirLightSourceElement' type=.LighterASTNode origin=GET_PROPERTY + $this: TYPE_OP type=.FirLightSourceElement origin=IMPLICIT_CAST typeOperand=.FirLightSourceElement + GET_VAR ': .FirSourceElement? declared in .FirModifierList.Companion.getModifierList' type=.FirSourceElement? origin=null + treeStructure: CALL 'public final fun (): .FlyweightCapableTreeStructure declared in .FirLightSourceElement' type=.FlyweightCapableTreeStructure origin=GET_PROPERTY + $this: TYPE_OP type=.FirLightSourceElement origin=IMPLICIT_CAST typeOperand=.FirLightSourceElement + GET_VAR ': .FirSourceElement? declared in .FirModifierList.Companion.getModifierList' type=.FirSourceElement? origin=null + predicate: FUN_EXPR type=kotlin.Function1<.LighterASTNode?, kotlin.Boolean> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.LighterASTNode?) returnType:kotlin.Boolean + VALUE_PARAMETER name:it index:0 type:.LighterASTNode? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: .LighterASTNode?): kotlin.Boolean declared in .FirModifierList.Companion.getModifierList' + CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: BLOCK type=.TokenType? origin=SAFE_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:.LighterASTNode? [val] + GET_VAR 'it: .LighterASTNode? declared in .FirModifierList.Companion.getModifierList.' type=.LighterASTNode? origin=null + WHEN type=.TokenType? origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_4: .LighterASTNode? [val] declared in .FirModifierList.Companion.getModifierList.' type=.LighterASTNode? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun (): .TokenType declared in .LighterASTNode' type=.TokenType origin=GET_PROPERTY + $this: GET_VAR 'val tmp_4: .LighterASTNode? [val] declared in .FirModifierList.Companion.getModifierList.' type=.LighterASTNode? origin=null + arg1: CALL 'public final fun (): .TokenType declared in .TokenType.Companion' type=.TokenType origin=GET_PROPERTY + $this: GET_OBJECT 'CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' type=.TokenType.Companion + WHEN type=.LighterASTNode origin=ELVIS + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_3: .LighterASTNode? [val] declared in .FirModifierList.Companion.getModifierList' type=.LighterASTNode? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: RETURN type=kotlin.Nothing from='public final fun getModifierList (): .FirModifierList? declared in .FirModifierList.Companion' + CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: GET_VAR 'val tmp_3: .LighterASTNode? [val] declared in .FirModifierList.Companion.getModifierList' type=.LighterASTNode? origin=null + CONSTRUCTOR_CALL 'public constructor (modifierList: .LighterASTNode, tree: .FlyweightCapableTreeStructure) [primary] declared in .FirModifierList.FirLightModifierList' type=.FirModifierList.FirLightModifierList origin=null + modifierList: GET_VAR 'val modifierListNode: .LighterASTNode [val] declared in .FirModifierList.Companion.getModifierList' type=.LighterASTNode origin=null + tree: CALL 'public final fun (): .FlyweightCapableTreeStructure declared in .FirLightSourceElement' type=.FlyweightCapableTreeStructure origin=GET_PROPERTY + $this: TYPE_OP type=.FirLightSourceElement origin=IMPLICIT_CAST typeOperand=.FirLightSourceElement + GET_VAR ': .FirSourceElement? declared in .FirModifierList.Companion.getModifierList' type=.FirSourceElement? origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null + FUN name:boxImpl visibility:public modality:FINAL <> ($this:.FirModifierList.Companion) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.FirModifierList.Companion + BLOCK_BODY + VAR name:sourceElement type:.FirSourceElement? [val] + CONSTRUCTOR_CALL 'public constructor (lighterASTNode: .LighterASTNode, treeStructure: .FlyweightCapableTreeStructure) [primary] declared in .FirLightSourceElement' type=.FirLightSourceElement origin=null + lighterASTNode: CONSTRUCTOR_CALL 'public constructor (_children: kotlin.collections.List<.LighterASTNode?>) [primary] declared in .LighterASTNode' type=.LighterASTNode origin=null + _children: CALL 'public final fun listOf (element: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.LighterASTNode> origin=null + : .LighterASTNode + element: CONSTRUCTOR_CALL 'public constructor (_children: kotlin.collections.List<.LighterASTNode?>) [primary] declared in .LighterASTNode' type=.LighterASTNode origin=null + treeStructure: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .FlyweightCapableTreeStructure' type=.FlyweightCapableTreeStructure origin=null + VAR name:result type:.FirModifierList? [val] + CALL 'public final fun getModifierList (): .FirModifierList? declared in .FirModifierList.Companion' type=.FirModifierList? origin=null + $this: GET_VAR ': .FirModifierList.Companion declared in .FirModifierList.Companion.boxImpl' type=.FirModifierList.Companion origin=null + $receiver: GET_VAR 'val sourceElement: .FirSourceElement? [val] declared in .FirModifierList.Companion.boxImpl' type=.FirSourceElement? origin=null + RETURN type=kotlin.Nothing from='public final fun boxImpl (): kotlin.String declared in .FirModifierList.Companion' + WHEN type=kotlin.String origin=IF + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.FirModifierList.FirLightModifierList + GET_VAR 'val result: .FirModifierList? [val] declared in .FirModifierList.Companion.boxImpl' type=.FirModifierList? origin=null + then: CONST String type=kotlin.String value="OK" + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST String type=kotlin.String value="Fail" + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun boxImpl (): kotlin.String declared in .FirModifierList.Companion' type=kotlin.String origin=null + $this: GET_OBJECT 'CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' type=.FirModifierList.Companion diff --git a/compiler/testData/codegen/box/smartCasts/kt44814.kt b/compiler/testData/codegen/box/smartCasts/kt44814.kt new file mode 100644 index 00000000000..efab025c5a8 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/kt44814.kt @@ -0,0 +1,86 @@ +// ISSUE: KT-44814 +// WITH_STDLIB +// DUMP_IR +// DUMP_CFG +// RENDERER_CFG_LEVELS + +class FlyweightCapableTreeStructure + +sealed class FirSourceElement { + abstract val lighterASTNode: LighterASTNode + abstract val treeStructure: FlyweightCapableTreeStructure +} +class FirPsiSourceElement( + val psi: PsiElement, + override val lighterASTNode: LighterASTNode, + override val treeStructure: FlyweightCapableTreeStructure +) : FirSourceElement() +class FirLightSourceElement( + override val lighterASTNode: LighterASTNode, + override val treeStructure: FlyweightCapableTreeStructure +) : FirSourceElement() + +open class PsiElement +class ASTNode +class LighterASTNode(val _children: List = emptyList()) { + fun getChildren(treeStructure: FlyweightCapableTreeStructure): List = _children + + val tokenType: TokenType = TokenType.MODIFIER_LIST +} + +class TokenType { + companion object { + val MODIFIER_LIST = TokenType() + } +} + +class KtModifierKeywordToken +class KtModifierList : PsiElement() +class KtModifierListOwner : PsiElement() { + val modifierList: KtModifierList = KtModifierList() +} + +internal sealed class FirModifier(val node: Node, val token: KtModifierKeywordToken) { + class FirPsiModifier( + node: ASTNode, + token: KtModifierKeywordToken + ) : FirModifier(node, token) + + class FirLightModifier( + node: LighterASTNode, + token: KtModifierKeywordToken, + val tree: FlyweightCapableTreeStructure + ) : FirModifier(node, token) +} + +internal sealed class FirModifierList { + val modifiers: List> = emptyList() + + class FirPsiModifierList(val modifierList: KtModifierList) : FirModifierList() + + class FirLightModifierList(val modifierList: LighterASTNode, val tree: FlyweightCapableTreeStructure) : FirModifierList() + + companion object { + fun FirSourceElement?.getModifierList(): FirModifierList? { + return when (this) { + null -> null + is FirPsiSourceElement-> (psi as? KtModifierListOwner)?.modifierList?.let { FirPsiModifierList(it) } + is FirLightSourceElement -> { + val modifierListNode = lighterASTNode.getChildren(treeStructure).find { it?.tokenType == TokenType.MODIFIER_LIST } + ?: return null // error is here + FirLightModifierList(modifierListNode, treeStructure) + } + } + } + + fun boxImpl(): String { + val sourceElement: FirSourceElement? = FirLightSourceElement(LighterASTNode(listOf(LighterASTNode())), FlyweightCapableTreeStructure()) + val result = sourceElement.getModifierList() + return if (result is FirLightModifierList) "OK" else "Fail" + } + } +} + +fun box(): String { + return FirModifierList.boxImpl() +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index f5eca379772..fe567f15a8d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -37440,6 +37440,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); } + @Test + @TestMetadata("kt44814.kt") + public void testKt44814() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 1edc33d351b..83e4f5b8d59 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -37440,6 +37440,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); } + @Test + @TestMetadata("kt44814.kt") + public void testKt44814() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 41c2fd07f52..4085b7eb97d 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -29916,6 +29916,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); } + @TestMetadata("kt44814.kt") + public void testKt44814() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index c7360da197e..e1bfd4bfe53 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -25527,6 +25527,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); } + @TestMetadata("kt44814.kt") + public void testKt44814() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 3de8d8634a4..9c0fa9c796d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -25012,6 +25012,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); } + @TestMetadata("kt44814.kt") + public void testKt44814() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index a1313161de9..e93dce59051 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -24972,6 +24972,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); } + @TestMetadata("kt44814.kt") + public void testKt44814() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index afd26477072..318e3c70622 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -13589,6 +13589,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); } + @TestMetadata("kt44814.kt") + public void testKt44814() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); + } + @TestMetadata("multipleSmartCast.kt") public void testMultipleSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); From d4c26cca52a689a8d32c445562a762bd64602f51 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 15 Feb 2021 12:26:13 +0300 Subject: [PATCH 192/368] [FIR] Use type without smartcast for local variable with smartcasted initializer --- .../FirBlackBoxCodegenTestGenerated.java | 6 + .../FirDeclarationsResolveTransformer.kt | 3 +- .../codegen/box/smartCasts/kt44932.kt | 40 +++++ .../localDelegatedProperties.fir.kt.txt | 2 +- .../localDelegatedProperties.fir.txt | 6 +- .../caoWithAdaptationForSam.fir.kt.txt | 12 +- .../caoWithAdaptationForSam.fir.txt | 24 ++- .../expressions/multipleSmartCasts.fir.kt.txt | 6 +- .../expressions/multipleSmartCasts.fir.txt | 8 +- .../smartCastsWithDestructuring.fir.kt.txt | 6 +- .../smartCastsWithDestructuring.fir.txt | 8 +- .../codegen/BlackBoxCodegenTestGenerated.java | 6 + .../IrBlackBoxCodegenTestGenerated.java | 6 + .../LightAnalysisModeTestGenerated.java | 5 + .../diagnostics/notLinked/dfa/pos/34.fir.kt | 24 +-- .../diagnostics/notLinked/dfa/pos/36.fir.kt | 24 +-- .../diagnostics/notLinked/dfa/pos/54.fir.kt | 164 +++++++++--------- .../diagnostics/notLinked/dfa/pos/57.fir.kt | 2 +- .../diagnostics/notLinked/dfa/pos/8.fir.kt | 20 +-- .../diagnostics/notLinked/dfa/pos/9.fir.kt | 20 +-- .../IrJsCodegenBoxES6TestGenerated.java | 5 + .../IrJsCodegenBoxTestGenerated.java | 5 + .../semantics/JsCodegenBoxTestGenerated.java | 5 + .../IrCodegenBoxWasmTestGenerated.java | 5 + 24 files changed, 253 insertions(+), 159 deletions(-) create mode 100644 compiler/testData/codegen/box/smartCasts/kt44932.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 5c14b8ef5c8..60503ce7e00 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -37446,6 +37446,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @Test + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index cd46b7f931a..68734347c7d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -989,7 +989,8 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor if (variable.returnTypeRef is FirImplicitTypeRef) { when { initializer != null -> { - val expectedType = when (val resultType = initializer.resultType) { + val unwrappedInitializer = (initializer as? FirExpressionWithSmartcast)?.originalExpression ?: initializer + val expectedType = when (val resultType = unwrappedInitializer.resultType) { is FirImplicitTypeRef -> buildErrorTypeRef { diagnostic = ConeSimpleDiagnostic("No result type for initializer", DiagnosticKind.InferenceError) } diff --git a/compiler/testData/codegen/box/smartCasts/kt44932.kt b/compiler/testData/codegen/box/smartCasts/kt44932.kt new file mode 100644 index 00000000000..dad06a82a77 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/kt44932.kt @@ -0,0 +1,40 @@ +// ISSUE: KT-44932 +// WITH_STDLIB + +abstract class PsiElement { + abstract val parent: PsiElement +} + +class KtNameReferenceExpression(override val parent: PsiElement) : PsiElement() + +class OtherElement(override val parent: PsiElement) : PsiElement() + +class KtDotQualifiedExpression : PsiElement() { + override val parent: PsiElement + get() = this + + val psi: PsiElement = EndElement() +} + +class EndElement : PsiElement() { + override val parent: PsiElement + get() = this +} + +fun mark(element: PsiElement): String { + when (element) { + is KtNameReferenceExpression -> { + var parent = element + repeat(2) { + parent = parent.parent + (parent as? KtDotQualifiedExpression)?.psi?.let { return mark(it) } + } + } + } + return if (element is EndElement) "OK" else "Fail" +} + +fun box(): String { + val element = KtNameReferenceExpression(OtherElement(KtDotQualifiedExpression())) + return mark(element) +} diff --git a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.kt.txt b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.kt.txt index cda338ab4fd..34f2a1b0736 100644 --- a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.kt.txt @@ -22,7 +22,7 @@ fun test2() { } ( = 0) - val : Int = () + val : Int? = () ( = .inc()) /*~> Unit */ ( = ().plus(other = 1)) diff --git a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt index 4bead69ab4c..7a1a2afb8d1 100644 --- a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt @@ -47,13 +47,13 @@ FILE fqName: fileName:/localDelegatedProperties.kt value: GET_VAR ': kotlin.Int? declared in .test2.' type=kotlin.Int? origin=null CALL 'local final fun (: kotlin.Int?): kotlin.Unit declared in .test2' type=kotlin.Unit origin=EQ : CONST Int type=kotlin.Int value=0 - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int? [val] CALL 'local final fun (): kotlin.Int? declared in .test2' type=kotlin.Int? origin=GET_LOCAL_PROPERTY CALL 'local final fun (: kotlin.Int?): kotlin.Unit declared in .test2' type=kotlin.Unit origin=EQ : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_0: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_0: kotlin.Int? [val] declared in .test2' type=kotlin.Int? origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'val tmp_0: kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null + GET_VAR 'val tmp_0: kotlin.Int? [val] declared in .test2' type=kotlin.Int? origin=null CALL 'local final fun (: kotlin.Int?): kotlin.Unit declared in .test2' type=kotlin.Unit origin=EQ : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'local final fun (): kotlin.Int? declared in .test2' type=kotlin.Int? origin=GET_LOCAL_PROPERTY diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt index 16b3427c296..c5798a0e780 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt @@ -63,8 +63,8 @@ fun test4(fn: Function1) { when { fn is IFoo -> { // BLOCK val <>: A = A - val <>: IFoo = fn /*as IFoo */ - <>.set(i = <>, newValue = <>.get(i = <>).plus(other = 1)) + val <>: Function1 = fn /*as IFoo */ + <>.set(i = <> /*as IFoo */, newValue = <>.get(i = <> /*as IFoo */).plus(other = 1)) } } } @@ -73,8 +73,8 @@ fun test5(a: Any) { a as Function1 /*~> Unit */ { // BLOCK val <>: A = A - val <>: Function1 = a /*as Function1 */ - <>.set(i = <> /*-> IFoo */, newValue = <>.get(i = <> /*-> IFoo */).plus(other = 1)) + val <>: Any = a /*as Function1 */ + <>.set(i = <> /*as Function1 */ /*-> IFoo */, newValue = <>.get(i = <> /*as Function1 */ /*-> IFoo */).plus(other = 1)) } } @@ -83,8 +83,8 @@ fun test6(a: Any) { a /*as Function1 */ as IFoo /*~> Unit */ { // BLOCK val <>: A = A - val <>: Function1 = a /*as Function1 */ - <>.set(i = <>, newValue = <>.get(i = <>).plus(other = 1)) + val <>: Any = a /*as Function1 */ + <>.set(i = <> /*as Function1 */, newValue = <>.get(i = <> /*as Function1 */).plus(other = 1)) } } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt index d1943517037..bb7afd74455 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt @@ -136,16 +136,18 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt then: BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.A [val] GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:.IFoo [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Function1 [val] TYPE_OP type=.IFoo origin=IMPLICIT_CAST typeOperand=.IFoo GET_VAR 'fn: kotlin.Function1 declared in .test4' type=kotlin.Function1 origin=null CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'val tmp_2: .A [val] declared in .test4' type=.A origin=null - i: GET_VAR 'val tmp_3: .IFoo [val] declared in .test4' type=.IFoo origin=null + i: TYPE_OP type=.IFoo origin=IMPLICIT_CAST typeOperand=.IFoo + GET_VAR 'val tmp_3: kotlin.Function1 [val] declared in .test4' type=kotlin.Function1 origin=null newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'val tmp_2: .A [val] declared in .test4' type=.A origin=null - i: GET_VAR 'val tmp_3: .IFoo [val] declared in .test4' type=.IFoo origin=null + i: TYPE_OP type=.IFoo origin=IMPLICIT_CAST typeOperand=.IFoo + GET_VAR 'val tmp_3: kotlin.Function1 [val] declared in .test4' type=kotlin.Function1 origin=null other: CONST Int type=kotlin.Int value=1 FUN name:test5 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any @@ -156,18 +158,20 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:.A [val] GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A - VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Function1 [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Any [val] TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 GET_VAR 'a: kotlin.Any declared in .test5' type=kotlin.Any origin=null CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'val tmp_4: .A [val] declared in .test5' type=.A origin=null i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - GET_VAR 'val tmp_5: kotlin.Function1 [val] declared in .test5' type=kotlin.Function1 origin=null + TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'val tmp_5: kotlin.Any [val] declared in .test5' type=kotlin.Any origin=null newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'val tmp_4: .A [val] declared in .test5' type=.A origin=null i: TYPE_OP type=.IFoo origin=SAM_CONVERSION typeOperand=.IFoo - GET_VAR 'val tmp_5: kotlin.Function1 [val] declared in .test5' type=kotlin.Function1 origin=null + TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'val tmp_5: kotlin.Any [val] declared in .test5' type=kotlin.Any origin=null other: CONST Int type=kotlin.Int value=1 FUN name:test6 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any @@ -182,14 +186,16 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt BLOCK type=kotlin.Unit origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:.A [val] GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A - VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Function1 [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Any [val] TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 GET_VAR 'a: kotlin.Any declared in .test6' type=kotlin.Any origin=null CALL 'public final fun set (i: .IFoo, newValue: kotlin.Int): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null $receiver: GET_VAR 'val tmp_6: .A [val] declared in .test6' type=.A origin=null - i: GET_VAR 'val tmp_7: kotlin.Function1 [val] declared in .test6' type=kotlin.Function1 origin=null + i: TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'val tmp_7: kotlin.Any [val] declared in .test6' type=kotlin.Any origin=null newValue: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: CALL 'public final fun get (i: .IFoo): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null $receiver: GET_VAR 'val tmp_6: .A [val] declared in .test6' type=.A origin=null - i: GET_VAR 'val tmp_7: kotlin.Function1 [val] declared in .test6' type=kotlin.Function1 origin=null + i: TYPE_OP type=kotlin.Function1 origin=IMPLICIT_CAST typeOperand=kotlin.Function1 + GET_VAR 'val tmp_7: kotlin.Any [val] declared in .test6' type=kotlin.Any origin=null other: CONST Int type=kotlin.Int value=1 diff --git a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt index 1cdd20ca6d0..b583cac2401 100644 --- a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.kt.txt @@ -14,9 +14,9 @@ fun test(x: Any) { x is IC1 -> x /*as IC1 */ is IC2 else -> false } -> { // BLOCK - val : IC1 = x /*as IC1 */ - val x1: Int = .component1() - val x2: String = /*as IC2 */.component2() + val : Any = x /*as IC1 */ + val x1: Int = /*as IC1 */.component1() + val x2: String = /*as IC1 */ /*as IC2 */.component2() } } } diff --git a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt index 3f44bf5ad7f..1d8244a2161 100644 --- a/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt +++ b/compiler/testData/ir/irText/expressions/multipleSmartCasts.fir.txt @@ -49,13 +49,15 @@ FILE fqName: fileName:/multipleSmartCasts.kt if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false then: BLOCK type=kotlin.Unit origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.IC1 [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any [val] TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 GET_VAR 'x: kotlin.Any declared in .test' type=kotlin.Any origin=null VAR name:x1 type:kotlin.Int [val] CALL 'public abstract fun component1 (): kotlin.Int [operator] declared in .IC1' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_0: .IC1 [val] declared in .test' type=.IC1 origin=null + $this: TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 + GET_VAR 'val tmp_0: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null VAR name:x2 type:kotlin.String [val] CALL 'public abstract fun component2 (): kotlin.String [operator] declared in .IC2' type=kotlin.String origin=null $this: TYPE_OP type=.IC2 origin=IMPLICIT_CAST typeOperand=.IC2 - GET_VAR 'val tmp_0: .IC1 [val] declared in .test' type=.IC1 origin=null + TYPE_OP type=.IC1 origin=IMPLICIT_CAST typeOperand=.IC1 + GET_VAR 'val tmp_0: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt index 077e7fa05d0..1255fb8d0c4 100644 --- a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.kt.txt @@ -18,7 +18,7 @@ fun test(x: I1) { when { x !is I2 -> return Unit } - val : I2 = x /*as I2 */ - val c1: Int = .component1() - val c2: String = .component2() + val : I1 = x /*as I2 */ + val c1: Int = /*as I2 */.component1() + val c2: String = /*as I2 */.component2() } diff --git a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.txt b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.txt index 5776b9e0b2c..fcb85af7862 100644 --- a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.txt +++ b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.fir.txt @@ -48,12 +48,14 @@ FILE fqName: fileName:/smartCastsWithDestructuring.kt GET_VAR 'x: .I1 declared in .test' type=.I1 origin=null then: RETURN type=kotlin.Nothing from='public final fun test (x: .I1): kotlin.Unit declared in ' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.I2 [val] + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.I1 [val] TYPE_OP type=.I2 origin=IMPLICIT_CAST typeOperand=.I2 GET_VAR 'x: .I1 declared in .test' type=.I1 origin=null VAR name:c1 type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null - $receiver: GET_VAR 'val tmp_0: .I2 [val] declared in .test' type=.I2 origin=null + $receiver: TYPE_OP type=.I2 origin=IMPLICIT_CAST typeOperand=.I2 + GET_VAR 'val tmp_0: .I1 [val] declared in .test' type=.I1 origin=null VAR name:c2 type:kotlin.String [val] CALL 'public final fun component2 (): kotlin.String [operator] declared in ' type=kotlin.String origin=null - $receiver: GET_VAR 'val tmp_0: .I2 [val] declared in .test' type=.I2 origin=null + $receiver: TYPE_OP type=.I2 origin=IMPLICIT_CAST typeOperand=.I2 + GET_VAR 'val tmp_0: .I1 [val] declared in .test' type=.I1 origin=null diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index fe567f15a8d..291a14d1ad9 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -37446,6 +37446,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @Test + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 83e4f5b8d59..f5ffd7be0e1 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -37446,6 +37446,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @Test + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 4085b7eb97d..0125295a2e4 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -29921,6 +29921,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt index 65416d54d1a..bdda892a162 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt @@ -9,8 +9,8 @@ fun case_1() { val b = select(a) val c = a b - c - c.equals(10) + c + c.equals(10) b.equals(10) } @@ -18,8 +18,8 @@ fun case_1() { fun case_2(a: Any?) { if (a is String) { val b = a - b - b.length + b + b.length } } @@ -30,8 +30,8 @@ fun case_3(a: Any?) { val c = b val d = c val e = d - e - e.length + e + e.length } } @@ -46,12 +46,12 @@ fun case_4(a: Any?) { if (d is ClassLevel4) { val e = d if (e is ClassLevel5) { - e - e.test1() - e.test2() - e.test3() - e.test4() - e.test5() + e + e.test1() + e.test2() + e.test3() + e.test4() + e.test5() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt index 5dd0a55d89a..80abecf96f6 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt @@ -13,8 +13,8 @@ fun case_1() { b b.equals(10) - c - c.equals(10) + c + c.equals(10) } // TESTCASE NUMBER: 2 @@ -22,8 +22,8 @@ fun case_2(x: Any) { if (x is String) { val y = x x - y - y.length + y + y.length } } @@ -34,10 +34,10 @@ fun case_3(x: Any?) { if (y == null) throw Exception() var z = y x - y - z - y.toByte() - z.toByte() + y + z + y.toByte() + z.toByte() } } @@ -48,10 +48,10 @@ fun case_4(x: Any?) { while (true && y != null) { var z = y x - y - z - y.toByte() - z.toByte() + y + z + y.toByte() + z.toByte() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt index 4523827f58f..6f4aaf0c91d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt @@ -11,16 +11,16 @@ fun case_1() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (a is String) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -33,16 +33,16 @@ fun case_2() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (true) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -55,16 +55,16 @@ fun case_3() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length do { b = a - b - b.length + b + b.length } while (true) - b - b.length + b + b.length } } @@ -77,16 +77,16 @@ fun case_4() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length do { b = a - b - b.length + b + b.length } while (false) - b - b.length + b + b.length } } @@ -99,16 +99,16 @@ fun case_5() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length for (i in 0..10) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -117,16 +117,16 @@ fun case_6() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length if (a is String) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -135,14 +135,14 @@ fun case_7() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length when (true) { true -> b = a } - b - b.length + b + b.length } } @@ -155,16 +155,16 @@ fun case_8() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { b = a - b - b.length + b + b.length } catch (e: Exception) { } - b - b.length + b + b.length } } @@ -173,18 +173,18 @@ fun case_9() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { } catch (e: Exception) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -193,18 +193,18 @@ fun case_10() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { b = a - b - b.length + b + b.length } finally { } - b - b.length + b + b.length } } @@ -213,18 +213,18 @@ fun case_11() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { } finally { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -237,15 +237,15 @@ fun case_12() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (if (true) { b = a; true } else true) { - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -254,12 +254,12 @@ fun case_13() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length a.plus(if (true) { b = a; true } else true) - b - b.length + b + b.length } } @@ -272,12 +272,12 @@ fun case_14() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (true) { if (true) { b = a; } else 3 - b - b.length + b + b.length } } } @@ -287,12 +287,12 @@ fun case_15() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (true) { if (true) { b = a; } else { b = a; } - b - b.length + b + b.length } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt index c32e6f134f3..887757f5a7e 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt @@ -78,7 +78,7 @@ fun case_6(x: Any?, b: Class) { x val y = if (true) b::fun_1 else b::fun_1 x - z1 + z1 val z2: Int = z1 } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt index 321e2d48bea..eab764412c4 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt @@ -57,16 +57,16 @@ fun case_3(a: Inv?) { if (a != null) { val b = a if (a == null) { - & Inv")!>b - & Inv")!>b.equals(null) - & Inv")!>b.propT - & Inv")!>b.propAny - & Inv")!>b.propNullableT - & Inv")!>b.propNullableAny - & Inv")!>b.funT() - & Inv")!>b.funAny() - & Inv")!>b.funNullableT() - & Inv")!>b.funNullableAny() + & Inv?")!>b + & Inv?")!>b.equals(null) + & Inv?")!>b.propT + & Inv?")!>b.propAny + & Inv?")!>b.propNullableT + & Inv?")!>b.propNullableAny + & Inv?")!>b.funT() + & Inv?")!>b.funAny() + & Inv?")!>b.funNullableT() + & Inv?")!>b.funNullableAny() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt index 56172b08e81..59bd9a60449 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt @@ -61,16 +61,16 @@ fun case_3(a: Inv?) { if (a != null) { val b = a if (a == null) - & Inv")!>b - & Inv")!>b.equals(null) - & Inv")!>b.propT - & Inv")!>b.propAny - & Inv")!>b.propNullableT - & Inv")!>b.propNullableAny - & Inv")!>b.funT() - & Inv")!>b.funAny() - & Inv")!>b.funNullableT() - & Inv")!>b.funNullableAny() + & Inv?")!>b + & Inv?")!>b.equals(null) + & Inv?")!>b.propT + & Inv?")!>b.propAny + & Inv?")!>b.propNullableT + & Inv?")!>b.propNullableAny + & Inv?")!>b.funT() + & Inv?")!>b.funAny() + & Inv?")!>b.funNullableT() + & Inv?")!>b.funNullableAny() } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index e1bfd4bfe53..a2c682d5817 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -25532,6 +25532,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 9c0fa9c796d..8e9184a794f 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -25017,6 +25017,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index e93dce59051..49d053060d1 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -24977,6 +24977,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 318e3c70622..278e24bee54 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -13594,6 +13594,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/smartCasts/kt44814.kt"); } + @TestMetadata("kt44932.kt") + public void testKt44932() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); + } + @TestMetadata("multipleSmartCast.kt") public void testMultipleSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); From 2b39282682245f28446863ca8c8d32a71dcc6725 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 15 Feb 2021 13:34:15 +0300 Subject: [PATCH 193/368] [FIR] Render original type before smartcasted type in DEBUG_INFO_EXPRESSION_TYPE This is made for keep consistency with same renderer in FE 1.0 --- .../intersectDfiTypesBeforeCapturing.fir.kt | 2 +- .../fir/handlers/FirDiagnosticsHandler.kt | 2 +- .../abstract-classes/p-2/pos/1.4.kt | 2 +- .../p-2/neg/1.1.fir.kt | 2 +- .../p-2/neg/1.1.fir.kt | 2 +- .../p-3/pos/1.1.fir.kt | 4 +- .../p-1/pos/1.3.fir.kt | 14 +- .../diagnostics/notLinked/dfa/neg/1.fir.kt | 40 +- .../diagnostics/notLinked/dfa/neg/10.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/11.fir.kt | 12 +- .../diagnostics/notLinked/dfa/neg/13.fir.kt | 8 +- .../diagnostics/notLinked/dfa/neg/15.fir.kt | 14 +- .../diagnostics/notLinked/dfa/neg/16.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/17.fir.kt | 8 +- .../diagnostics/notLinked/dfa/neg/18.fir.kt | 6 +- .../diagnostics/notLinked/dfa/neg/19.fir.kt | 32 +- .../diagnostics/notLinked/dfa/neg/2.fir.kt | 44 +- .../diagnostics/notLinked/dfa/neg/20.fir.kt | 36 +- .../diagnostics/notLinked/dfa/neg/22.fir.kt | 32 +- .../diagnostics/notLinked/dfa/neg/23.fir.kt | 20 +- .../diagnostics/notLinked/dfa/neg/25.fir.kt | 12 +- .../diagnostics/notLinked/dfa/neg/26.fir.kt | 18 +- .../diagnostics/notLinked/dfa/neg/27.fir.kt | 8 +- .../diagnostics/notLinked/dfa/neg/28.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/3.fir.kt | 18 +- .../diagnostics/notLinked/dfa/neg/31.fir.kt | 2 +- .../diagnostics/notLinked/dfa/neg/32.fir.kt | 16 +- .../diagnostics/notLinked/dfa/neg/34.fir.kt | 16 +- .../diagnostics/notLinked/dfa/neg/37.fir.kt | 16 +- .../diagnostics/notLinked/dfa/neg/39.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/41.fir.kt | 40 +- .../diagnostics/notLinked/dfa/neg/42.fir.kt | 60 +- .../diagnostics/notLinked/dfa/neg/5.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/8.fir.kt | 22 +- .../diagnostics/notLinked/dfa/neg/9.fir.kt | 8 +- .../diagnostics/notLinked/dfa/pos/1.fir.kt | 3640 ++++++++--------- .../diagnostics/notLinked/dfa/pos/10.fir.kt | 620 +-- .../diagnostics/notLinked/dfa/pos/11.fir.kt | 264 +- .../diagnostics/notLinked/dfa/pos/12.fir.kt | 1254 +++--- .../diagnostics/notLinked/dfa/pos/13.fir.kt | 1250 +++--- .../diagnostics/notLinked/dfa/pos/14.fir.kt | 16 +- .../diagnostics/notLinked/dfa/pos/15.fir.kt | 134 +- .../diagnostics/notLinked/dfa/pos/16.fir.kt | 476 +-- .../diagnostics/notLinked/dfa/pos/17.fir.kt | 226 +- .../diagnostics/notLinked/dfa/pos/18.fir.kt | 230 +- .../diagnostics/notLinked/dfa/pos/19.fir.kt | 48 +- .../diagnostics/notLinked/dfa/pos/2.fir.kt | 82 +- .../diagnostics/notLinked/dfa/pos/21.fir.kt | 36 +- .../diagnostics/notLinked/dfa/pos/22.fir.kt | 56 +- .../diagnostics/notLinked/dfa/pos/23.fir.kt | 22 +- .../diagnostics/notLinked/dfa/pos/24.fir.kt | 6 +- .../diagnostics/notLinked/dfa/pos/25.fir.kt | 38 +- .../diagnostics/notLinked/dfa/pos/26.fir.kt | 38 +- .../diagnostics/notLinked/dfa/pos/27.fir.kt | 38 +- .../diagnostics/notLinked/dfa/pos/28.fir.kt | 136 +- .../diagnostics/notLinked/dfa/pos/29.fir.kt | 42 +- .../diagnostics/notLinked/dfa/pos/3.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/30.fir.kt | 62 +- .../diagnostics/notLinked/dfa/pos/31.fir.kt | 62 +- .../diagnostics/notLinked/dfa/pos/32.fir.kt | 8 +- .../diagnostics/notLinked/dfa/pos/33.fir.kt | 20 +- .../diagnostics/notLinked/dfa/pos/34.fir.kt | 66 +- .../diagnostics/notLinked/dfa/pos/35.fir.kt | 22 +- .../diagnostics/notLinked/dfa/pos/36.fir.kt | 52 +- .../diagnostics/notLinked/dfa/pos/37.fir.kt | 34 +- .../diagnostics/notLinked/dfa/pos/38.fir.kt | 48 +- .../diagnostics/notLinked/dfa/pos/39.fir.kt | 8 +- .../diagnostics/notLinked/dfa/pos/40.fir.kt | 24 +- .../diagnostics/notLinked/dfa/pos/41.fir.kt | 20 +- .../diagnostics/notLinked/dfa/pos/42.fir.kt | 12 +- .../diagnostics/notLinked/dfa/pos/43.fir.kt | 18 +- .../diagnostics/notLinked/dfa/pos/44.fir.kt | 16 +- .../diagnostics/notLinked/dfa/pos/45.fir.kt | 32 +- .../diagnostics/notLinked/dfa/pos/46.fir.kt | 8 +- .../diagnostics/notLinked/dfa/pos/47.fir.kt | 24 +- .../diagnostics/notLinked/dfa/pos/48.fir.kt | 32 +- .../diagnostics/notLinked/dfa/pos/49.fir.kt | 16 +- .../diagnostics/notLinked/dfa/pos/5.fir.kt | 346 +- .../diagnostics/notLinked/dfa/pos/50.fir.kt | 40 +- .../diagnostics/notLinked/dfa/pos/51.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/53.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/54.fir.kt | 140 +- .../diagnostics/notLinked/dfa/pos/55.fir.kt | 8 +- .../diagnostics/notLinked/dfa/pos/57.fir.kt | 38 +- .../diagnostics/notLinked/dfa/pos/59.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/6.fir.kt | 300 +- .../diagnostics/notLinked/dfa/pos/60.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/61.fir.kt | 40 +- .../diagnostics/notLinked/dfa/pos/63.fir.kt | 24 +- .../diagnostics/notLinked/dfa/pos/64.fir.kt | 16 +- .../diagnostics/notLinked/dfa/pos/65.fir.kt | 52 +- .../diagnostics/notLinked/dfa/pos/66.fir.kt | 12 +- .../diagnostics/notLinked/dfa/pos/67.fir.kt | 24 +- .../diagnostics/notLinked/dfa/pos/68.fir.kt | 32 +- .../diagnostics/notLinked/dfa/pos/69.fir.kt | 16 +- .../diagnostics/notLinked/dfa/pos/7.fir.kt | 260 +- .../diagnostics/notLinked/dfa/pos/70.fir.kt | 6 +- .../diagnostics/notLinked/dfa/pos/71.fir.kt | 6 +- .../diagnostics/notLinked/dfa/pos/72.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/73.fir.kt | 12 +- .../diagnostics/notLinked/dfa/pos/8.fir.kt | 154 +- .../diagnostics/notLinked/dfa/pos/9.fir.kt | 444 +- 102 files changed, 5883 insertions(+), 5883 deletions(-) diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/intersectDfiTypesBeforeCapturing.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/intersectDfiTypesBeforeCapturing.fir.kt index b2f05188b74..c32fce9ce41 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/intersectDfiTypesBeforeCapturing.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/intersectDfiTypesBeforeCapturing.fir.kt @@ -10,7 +10,7 @@ fun test1(y: Any) { y as Map y as Map<*, *> y.forEach { (k: String, u: Any?) -> } - & kotlin.Any")!>y + ")!>y } fun test2(x: Any, y: Inv) { diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt index 2d2fa173333..2eefc1a3f02 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt @@ -166,7 +166,7 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes val rendered = type.renderForDebugInfo() val originalTypeRendered = originalTypeRef?.coneTypeSafe()?.renderForDebugInfo() ?: return rendered - return "$rendered & $originalTypeRendered" + return "$originalTypeRendered & $rendered" } private fun createCallDiagnosticIfExpected( diff --git a/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/pos/1.4.kt b/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/pos/1.4.kt index 584a50b6f87..b7f4e96b56f 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/pos/1.4.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/class-declaration/abstract-classes/p-2/pos/1.4.kt @@ -95,4 +95,4 @@ class B() : CaseOuter.CaseBase() { override fun outerFoo() { } -} \ No newline at end of file +} diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-conjunction-expression/p-2/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-conjunction-expression/p-2/neg/1.1.fir.kt index cf2d070a07f..c1972ebfce1 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-conjunction-expression/p-2/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-conjunction-expression/p-2/neg/1.1.fir.kt @@ -41,7 +41,7 @@ fun case2() { fun case3() { val a1 = false val a2 = JavaClass.VALUE - a2 + a2 val x3 = a1 && a2 x3 diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg/1.1.fir.kt index e67c169a61b..39970ea2b99 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/logical-disjunction-expression/p-2/neg/1.1.fir.kt @@ -41,7 +41,7 @@ fun case2() { fun case3() { val a1 = false val a2 = JavaClass.VALUE - a2 + a2 val x3 = a1 || a2 x3 diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/not-null-assertion-expression/p-3/pos/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/expressions/not-null-assertion-expression/p-3/pos/1.1.fir.kt index 9443862fcd6..983d85c5502 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/not-null-assertion-expression/p-3/pos/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/not-null-assertion-expression/p-3/pos/1.1.fir.kt @@ -22,7 +22,7 @@ import checkSubtype // TESTCASE NUMBER: 1 fun case1() { val a = JavaClass.STR - a + a val res = a!! res } @@ -30,7 +30,7 @@ fun case1() { // TESTCASE NUMBER: 2 fun case2() { val a = JavaClass.obj - a + a val x = a!! x } diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-for-intersection-types/p-1/pos/1.3.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-for-intersection-types/p-1/pos/1.3.fir.kt index f8a3c0ac2cf..a77e14c3079 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-for-intersection-types/p-1/pos/1.3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-for-intersection-types/p-1/pos/1.3.fir.kt @@ -11,7 +11,7 @@ fun case1(x: Any) { checkSubtype(x) checkSubtype(x) - x // A1 & B1 & kotlin.Any + x // A1 & B1 & kotlin.Any } } @@ -26,7 +26,7 @@ fun case2(x: T) { checkSubtype(x) x //NI A2 & B2 & T & T!! OI A2 & B2 & T - x + x } } @@ -40,7 +40,7 @@ fun case3a(x: T) { checkSubtype(x) checkSubtype(x) checkSubtype(x) - x + x } } fun case3b(x: T) { @@ -50,7 +50,7 @@ fun case3b(x: T) { checkSubtype(x) checkSubtype(x) - x + x } } fun case3c(x: T) { @@ -60,7 +60,7 @@ fun case3c(x: T) { checkSubtype(x) checkSubtype(x) - x + x } } @@ -72,7 +72,7 @@ interface A3 fun case4(x: C?) { if (x is B4 && x is A4) { x - x + x x.foo() } } @@ -89,7 +89,7 @@ class C : A4, B4 { fun case5(x: T) { if (x is B5 && x is A5) { x - x + x } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt index 51c1b9ece1b..de341abcac6 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/1.fir.kt @@ -379,16 +379,16 @@ fun case_23(a: ((Float) -> Int?)?, b: Float?) { if (a != null !is Boolean && b !== null is Boolean) { val x = a(b) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -423,16 +423,16 @@ fun case_25(b: Boolean) { val z = ?")!>y() if (z != null !== false) { - & ?")!>z.a - & ?")!>z.a.equals(null) - & ?")!>z.a.propT - & ?")!>z.a.propAny - & ?")!>z.a.propNullableT - & ?")!>z.a.propNullableAny - & ?")!>z.a.funT() - & ?")!>z.a.funAny() - & ?")!>z.a.funNullableT() - & ?")!>z.a.funNullableAny() + ? & ")!>z.a + ? & ")!>z.a.equals(null) + ? & ")!>z.a.propT + ? & ")!>z.a.propAny + ? & ")!>z.a.propNullableT + ? & ")!>z.a.propNullableAny + ? & ")!>z.a.funT() + ? & ")!>z.a.funAny() + ? & ")!>z.a.funNullableT() + ? & ")!>z.a.funNullableAny() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/10.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/10.fir.kt index 0cd6498ffd3..dc9d5286641 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/10.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/10.fir.kt @@ -12,6 +12,6 @@ fun case_1() { x = ClassLevel3() } - x - x.inv() + x + x.inv() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt index 50ea24660e2..7a9e67c7ab5 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt @@ -6,8 +6,8 @@ fun case_1() { var x: Boolean? = true if (x is Boolean && if (true) { x = null; true } else { false }) { - x - x.not() + x + x.not() } } @@ -15,8 +15,8 @@ fun case_1() { fun case_2() { var x: Boolean? = true if (x != null && try { x = null; true } catch (e: Exception) { false }) { - x - x.not() + x + x.not() } } @@ -47,8 +47,8 @@ fun case_4() { fun case_5() { var x: Int? = null if (x == try { x = 10; null } finally {} && x != null) { - x - x.inv() + x + x.inv() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt index 48f60a6a8c8..16525fa04cf 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt @@ -5,9 +5,9 @@ // TESTCASE NUMBER: 1 fun case_1(x: Class?) { x!! - x[if (true) {x=null;0} else 0] += x[0] - x - x[0].inv() + x[if (true) {x=null;0} else 0] += x[0] + x + x[0].inv() } // TESTCASE NUMBER: 2 @@ -23,7 +23,7 @@ fun case_2() { fun case_3() { var x: Class? = Class() x!! - val y = x[if (true) {x=null;0} else 0, x[0]] + val y = x[if (true) {x=null;0} else 0, x[0]] x x.fun_1() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt index 83f18f2d875..c64857f04cc 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt @@ -10,8 +10,8 @@ fun case_1() { var x: Boolean? = true if (x is Boolean && if (true) { x = null; true } else { false }) { - x - x.not() + x + x.not() } } @@ -23,8 +23,8 @@ fun case_1() { fun case_2() { var x: Boolean? = true if (x !== null && try { x = null; true } catch (e: Exception) { false }) { - x - x.not() + x + x.not() } } @@ -50,8 +50,8 @@ fun case_3() { fun case_4() { var x: Int? = null if (x == try { x = 10; null } finally {} && x != null) { - x - x.inv() + x + x.inv() println(1) } } @@ -76,7 +76,7 @@ fun case_5() { fun case_6() { var x: Boolean? = true if (x != null) { - if (true) {x = null; true} else true && x.not() + if (true) {x = null; true} else true && x.not() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/16.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/16.fir.kt index 532a51a30e5..a2221158e07 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/16.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/16.fir.kt @@ -100,7 +100,7 @@ fun case_8(x: ClassWithCustomEquals, y: Nothing?) { */ fun case_9(x: ClassWithCustomEquals?, y: Interface1) { if (x == y) { - x - x.itest1() + x + x.itest1() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/17.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/17.fir.kt index a45f4ec3d58..8a04e1124d6 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/17.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/17.fir.kt @@ -9,8 +9,8 @@ fun case_1(x: Any) { if (x is Interface1) { if (x is Interface2) { - x - x.itest00() + x + x.itest00() } } } @@ -22,8 +22,8 @@ fun case_1(x: Any) { fun case_2(x: Any) { if (x is Interface2) { if (x is Interface1) { - x - x.itest00000() + x + x.itest00000() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt index 5734223bf9f..3131236c2e5 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt @@ -10,7 +10,7 @@ fun case_1(x: Interface1?) { var y = x y as Interface2 val foo = { - y.itest2() + y.itest2() } y = null foo() @@ -24,7 +24,7 @@ fun case_2(x: Interface1?) { var y = x y as Interface2 val foo = fun () { - y.itest2() + y.itest2() } y = null foo() @@ -38,7 +38,7 @@ fun case_3(x: Interface1?) { var y = x y as Interface2 fun foo() { - y.itest2() + y.itest2() } y = null foo() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/19.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/19.fir.kt index 29281311324..9cf9800100c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/19.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/19.fir.kt @@ -62,8 +62,8 @@ fun case_4(x: Boolean?) { } while (x!!) } while (true) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 5 @@ -74,8 +74,8 @@ fun case_5(x: Boolean?) { } while (x!!) } while (true) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 6 @@ -86,8 +86,8 @@ fun case_6(x: Boolean?) { } while (true) } while (x!!) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 7 @@ -127,8 +127,8 @@ fun case_9(x: Boolean?) { } } - x - x.not() + x + x.not() } /* @@ -205,8 +205,8 @@ fun case_16(x: Boolean?) { break } while (x!!) - x - x.not() + x + x.not() } /* @@ -344,8 +344,8 @@ fun case_26(x: Boolean?) { } } - x - x.not() + x + x.not() } /* @@ -358,8 +358,8 @@ fun case_27(x: Int?, y: Class) { y[break, x!!] } - x - x.inv() + x + x.inv() } /* @@ -372,6 +372,6 @@ fun case_28(x: Int?, y: List>) { y[break][x!!] } - x - x.inv() + x + x.inv() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/2.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/2.fir.kt index 190cca95eb0..f1f736785a8 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/2.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/2.fir.kt @@ -5,87 +5,87 @@ // TESTCASE NUMBER: 1 fun case_1(x: Any?) { if (x is Nothing) { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 2 fun case_2(x: Any) { if (x is Nothing) { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 3 fun case_3(x: Any?) { if (x !is Nothing) else { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 4 fun case_4(x: Any) { if (x !is Nothing) else { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 5 fun case_5(x: Any?) { if (!(x !is Nothing?)) { - x - x?.inv() + x + x?.inv() } } // TESTCASE NUMBER: 6 fun case_6(x: Any?) { if (!(x !is Nothing)) { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 7 fun case_7(x: Any) { if (!(x is Nothing)) else { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 8 fun case_8(x: Any?) { if (!(x is Nothing?)) else { - x - x?.inv() + x + x?.inv() } } // TESTCASE NUMBER: 9 fun case_9(x: Any?) { if (!!(x !is Nothing?)) else { - x - x?.inv() + x + x?.inv() } } // TESTCASE NUMBER: 10 fun case_10(x: Any?) { if (!!(x !is Nothing)) else { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 11 fun case_11(x: Any?) { if (x is Nothing?) { - x - x?.inv() + x + x?.inv() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/20.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/20.fir.kt index 44ea11ab5d3..27c1f8c659a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/20.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/20.fir.kt @@ -62,8 +62,8 @@ fun case_4(x: Boolean?) { } while (x as Boolean) } while (true) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 5 @@ -74,8 +74,8 @@ fun case_5(x: Boolean?) { } while (x as Boolean) } while (true) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 6 @@ -86,8 +86,8 @@ fun case_6(x: Boolean?) { } while (true) } while (x as Boolean) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 7 @@ -127,8 +127,8 @@ fun case_9(x: Boolean?) { } } - x - x.not() + x + x.not() } /* @@ -205,8 +205,8 @@ fun case_16(x: Boolean?) { break } while (x as Boolean) - x - x.not() + x + x.not() } /* @@ -344,8 +344,8 @@ fun case_26(x: Boolean?) { } } - x - x.not() + x + x.not() } /* @@ -358,8 +358,8 @@ fun case_27(x: Int?, y: Class) { y[break, x as Int] } - x - x.inv() + x + x.inv() } /* @@ -372,8 +372,8 @@ fun case_28(x: Int?, y: List>) { y[break][x as Int] } - x - x.inv() + x + x.inv() } /* @@ -387,6 +387,6 @@ fun case_29(x: Boolean?, y: MutableList) { x!! } - x - x.not() + x + x.not() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/22.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/22.fir.kt index 71d43d415ad..24c983e97d2 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/22.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/22.fir.kt @@ -69,8 +69,8 @@ fun case_5(x: Boolean?, y: Boolean?) { x!! } - x - x.not() + x + x.not() } // TESTCASE NUMBER: 6 @@ -80,8 +80,8 @@ fun case_6(x: Boolean?, y: ((x: Nothing) -> Unit)?) { x!! } - x - x.not() + x + x.not() } // TESTCASE NUMBER: 7 @@ -121,8 +121,8 @@ fun case_9(x: Int?) { y = break as Int + x!! } - x - x.inv() + x + x.inv() } /* @@ -136,8 +136,8 @@ fun case_10(x: Int?) { break as Int + x as Int } while (true) - x - x.inv() + x + x.inv() } /* @@ -153,8 +153,8 @@ fun case_11(x: Int?) { break(x!!) } - x - x.inv() + x + x.inv() } /* @@ -170,8 +170,8 @@ fun case_12(x: Int?) { break[x!!] } - x - x.inv() + x + x.inv() } /* @@ -187,8 +187,8 @@ fun case_13(x: Int?) { break[x!!] = 10 } - x - x.inv() + x + x.inv() } /* @@ -204,8 +204,8 @@ fun case_14(x: Int?) { break[10] = x!! } - x - x.inv() + x + x.inv() } // TESTCASE NUMBER: 15 diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt index 19ec9118af8..824509b6e92 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt @@ -8,8 +8,8 @@ */ inline fun case_1(x: T) { if (x is K) { - x - x.equals(x) + x + x.equals(x) } } @@ -19,8 +19,8 @@ inline fun case_1(x: T) { */ inline fun case_2(x: T) { x as K - x - x.equals(x) + x + x.equals(x) } /* @@ -31,8 +31,8 @@ inline fun case_3() { var x: T? = 10 as T x = null if (x is K) { - x.equals(10) - x + x.equals(10) + x println(1) } } @@ -40,16 +40,16 @@ inline fun case_3() { // TESTCASE NUMBER: 4 inline fun case_4(x: T?) { if (x is K) { - x - x.equals(x) + x + x.equals(x) } } // TESTCASE NUMBER: 5 inline fun case_5(x: T) { if (x is K?) { - x - x.equals(x) + x + x.equals(x) } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/25.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/25.fir.kt index f87df30ef9f..07953b467f5 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/25.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/25.fir.kt @@ -17,8 +17,8 @@ fun case_1() { val x: ClassWithEqualsOverride? = null val y = ClassWithEqualsOverride() if (y == x) { - x - x.fun_1() + x + x.fun_1() } } @@ -32,8 +32,8 @@ fun case_2() { val y: ClassWithEqualsOverride? = ClassWithEqualsOverride() if (y != null) { if (y == x) { - x - x.fun_1() + x + x.fun_1() } } } @@ -47,7 +47,7 @@ fun case_3() { val x: ClassWithEqualsOverride? = null val y: ClassWithEqualsOverride? = ClassWithEqualsOverride() if (y!! == x) { - x - x.fun_1() + x + x.fun_1() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt index 4da5f9b1b57..54118ea35c6 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt @@ -10,7 +10,7 @@ fun case_1() { var x: MutableList? = mutableListOf(1) x!! - & kotlin.collections.MutableList?")!>x[if (true) {x=null;0} else 0] += ? & kotlin.collections.MutableList?")!>x[0] + ? & kotlin.collections.MutableList")!>x[if (true) {x=null;0} else 0] += ? & kotlin.collections.MutableList?")!>x[0] ? & kotlin.collections.MutableList?")!>x ? & kotlin.collections.MutableList?")!>x[0].inv() } @@ -19,7 +19,7 @@ fun case_1() { fun case_2() { var x: MutableList? = mutableListOf(1) x!! - & kotlin.collections.MutableList?")!>x[if (true) {x=null;0} else 0] = ? & kotlin.collections.MutableList?")!>x[0] + ? & kotlin.collections.MutableList")!>x[if (true) {x=null;0} else 0] = ? & kotlin.collections.MutableList?")!>x[0] ? & kotlin.collections.MutableList?")!>x ? & kotlin.collections.MutableList?")!>x[0].inv() } @@ -28,7 +28,7 @@ fun case_2() { fun case_3() { var x: MutableList? = mutableListOf(1) x!! - & kotlin.collections.MutableList?")!>x[0] = if (true) {x=null;0} else 0 + ? & kotlin.collections.MutableList")!>x[0] = if (true) {x=null;0} else 0 ? & kotlin.collections.MutableList?")!>x ? & kotlin.collections.MutableList?")!>x[0].inv() } @@ -41,7 +41,7 @@ fun case_3() { fun case_4() { var x: Class? = Class() x!! - val y = x[if (true) {x=null;0} else 0, x[0]] + val y = x[if (true) {x=null;0} else 0, x[0]] x x[0].inv() } @@ -62,7 +62,7 @@ fun case_5() { fun case_6() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - > & kotlin.collections.MutableList>?")!>x[if (true) {x=null;0} else 0][>? & kotlin.collections.MutableList>?")!>x[0][0]] += 10 + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0][>? & kotlin.collections.MutableList>?")!>x[0][0]] += 10 >? & kotlin.collections.MutableList>?")!>x >? & kotlin.collections.MutableList>?")!>x[0][0].inv() } @@ -83,14 +83,14 @@ fun case_7() { fun case_8() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - > & kotlin.collections.MutableList>?")!>x[if (true) {x=null;0} else 0].addAll(1, >? & kotlin.collections.MutableList>?")!>x[0]) + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].addAll(1, >? & kotlin.collections.MutableList>?")!>x[0]) } // TESTCASE NUMBER: 9 fun case_9() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - > & kotlin.collections.MutableList>?")!>x[if (true) {x=null;0} else 0].subList(0, 2)[>? & kotlin.collections.MutableList>?")!>x[0][0]] + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].subList(0, 2)[>? & kotlin.collections.MutableList>?")!>x[0][0]] } /* @@ -101,7 +101,7 @@ fun case_9() { fun case_10() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - > & kotlin.collections.MutableList>?")!>x.subList(if (true) {x=null;0} else 0, 2)[>? & kotlin.collections.MutableList>?")!>x[0][0]] + >? & kotlin.collections.MutableList>")!>x.subList(if (true) {x=null;0} else 0, 2)[>? & kotlin.collections.MutableList>?")!>x[0][0]] } /* @@ -112,5 +112,5 @@ fun case_10() { fun case_11() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - > & kotlin.collections.MutableList>?")!>x[if (true) {x=null;0} else 0].subList(>? & kotlin.collections.MutableList>?")!>x[0][0], 2) + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].subList(>? & kotlin.collections.MutableList>?")!>x[0][0], 2) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/27.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/27.fir.kt index 4f19703d7e7..8fc1dc6a2e8 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/27.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/27.fir.kt @@ -24,8 +24,8 @@ fun case_2(x: Boolean?, y: Int?) { x!! } - x - x.not() + x + x.not() } // TESTCASE NUMBER: 3 @@ -93,8 +93,8 @@ fun case_7(x: Boolean?, y: Boolean?) { x!! } - x - x.not() + x + x.not() } // TESTCASE NUMBER: 8 diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/28.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/28.fir.kt index 788f77ff66f..6b73e404062 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/28.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/28.fir.kt @@ -5,7 +5,7 @@ // TESTCASE NUMBER: 1 fun > Inv.case_1() { if (this is MutableList<*>) { - & Inv & Inv")!>this - & Inv & Inv")!>this[0] = & Inv & Inv")!>this[1] + & kotlin.collections.MutableList<*> & Inv")!>this + & kotlin.collections.MutableList<*> & Inv")!>this[0] = & kotlin.collections.MutableList<*> & Inv")!>this[1] } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt index f75d37beeb3..3a0a0ca8a49 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt @@ -5,8 +5,8 @@ // TESTCASE NUMBER: 1 fun case_1(x: Nothing?) { if (x is Int) { - x - x.inv() + x + x.inv() } } @@ -21,8 +21,8 @@ fun case_2(x: Nothing) { // TESTCASE NUMBER: 3 fun case_3(x: Nothing?) { if (x !is Class) else { - x - x.prop_1 + x + x.prop_1 } } @@ -45,8 +45,8 @@ fun case_5(x: Nothing?) { // TESTCASE NUMBER: 6 fun case_6(x: Nothing?) { if (!(x !is Object)) { - x - x.prop_1 + x + x.prop_1 } } @@ -77,9 +77,9 @@ fun case_9(x: Nothing?) { // TESTCASE NUMBER: 10 fun case_10(x: Nothing?) { if (!!(x !is Interface3)) else { - x - x.itest() - x.itest3() + x + x.itest() + x.itest3() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/31.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/31.fir.kt index c43ed9e5002..b8e6634377c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/31.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/31.fir.kt @@ -8,5 +8,5 @@ fun case_1(x: Interface2) = x fun case_1() { val x: Interface1 = null as Interface1 x as Interface2 - case_1(x) + case_1(x) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/32.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/32.fir.kt index d9ef014fb22..68b7a915f63 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/32.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/32.fir.kt @@ -13,7 +13,7 @@ fun stringArg(number: String) {} fun case_1(x: Int?) { if (x == null) { stringArg(x!!) - x + x } } @@ -25,7 +25,7 @@ fun case_1(x: Int?) { fun case_2(x: Int?, y: Nothing?) { if (x == y) { stringArg(x!!) - x + x } } @@ -37,8 +37,8 @@ fun case_2(x: Int?, y: Nothing?) { fun case_3(x: Int?) { if (x == null) { x as Int - stringArg(x) - x + stringArg(x) + x } } @@ -50,8 +50,8 @@ fun case_3(x: Int?) { fun case_4(x: Int?) { if (x == null) { x!! - stringArg(x) - x + stringArg(x) + x } } @@ -64,7 +64,7 @@ fun case_5(x: Int?) { if (x == null) { var y = x y!! - stringArg(y) - y + stringArg(y) + y } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt index eb64aabd76c..82010624f7a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt @@ -51,8 +51,8 @@ fun case_4() { fun case_5() { var x: Boolean? = true while (true && x!!) { - x - x.not() + x + x.not() x = null break } @@ -106,8 +106,8 @@ fun case_9() { x = null break } while (x!!.length > 1) - x - x.length + x + x.length } // TESTCASE NUMBER: 10 @@ -117,8 +117,8 @@ fun case_10() { x = null break } while ((x as String).length > 1) - x - x.length + x + x.length } // TESTCASE NUMBER: 11 @@ -128,8 +128,8 @@ fun case_11() { x = null break } while (x!!) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 12 diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt index 14cb2e392c8..c8976901980 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt @@ -10,7 +10,7 @@ fun case_1() { var x: Class? = Class() if (x != null) { - x + x x++ x x.equals(10) @@ -25,7 +25,7 @@ fun case_1() { fun case_2() { var x: Class? x = Class() - x + x x-- x x.equals(10) @@ -39,7 +39,7 @@ fun case_2() { fun case_3() { var x: Class? = Class() x!! - x + x --x x x.equals(10) @@ -53,7 +53,7 @@ fun case_3() { fun case_4() { var x: Class? = Class() x as Class - x + x ++x x x.equals(10) @@ -63,7 +63,7 @@ fun case_4() { fun case_5() { var x: Class? = Class() x as Class - x + x x = x + x x x.equals(10) @@ -73,7 +73,7 @@ fun case_5() { fun case_6() { var x: Class? = Class() if (x is Class) { - x + x x = x - x x x.equals(10) @@ -88,7 +88,7 @@ fun case_6() { fun case_7() { var x: Class? x = Class() - x + x x += x x x.equals(10) @@ -102,7 +102,7 @@ fun case_7() { fun case_8() { var x: Class? = Class() x!! - x + x x -= x x x.equals(10) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/39.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/39.fir.kt index f994dc91d35..56737b0323d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/39.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/39.fir.kt @@ -162,6 +162,6 @@ fun case_13() { while (true) { val z = y * if (x != null) break else 10 } - x - x.inv() + x + x.inv() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/41.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/41.fir.kt index d2fa24869ce..838fdb7b345 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/41.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/41.fir.kt @@ -6,30 +6,30 @@ inline fun case_1(x: Any?) { when (x) { is T -> { - x - x.equals(10) + x + x.equals(10) } else -> return } - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 2 inline fun case_2(x: Any?) { when (x) { is Any -> { - x - x.equals(10) + x + x.equals(10) } is T -> { - x - x.equals(10) + x + x.equals(10) } else -> return } - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 3 @@ -61,11 +61,11 @@ inline fun case_4(x: Any?) { // TESTCASE NUMBER: 5 inline fun case_5(x: Any?) { if (x is T) { - x - x.equals(10) + x + x.equals(10) } else return - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 6 @@ -78,12 +78,12 @@ inline fun case_6(x: Any?) { // TESTCASE NUMBER: 7 inline fun case_7(x: Any?) { if (x is Any) { - x - x.equals(10) + x + x.equals(10) } else if (x is T) { - x - x.equals(10) + x + x.equals(10) } else return - x - x.equals(10) + x + x.equals(10) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/42.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/42.fir.kt index 9f0ec94f07c..7b5dbfaf037 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/42.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/42.fir.kt @@ -8,8 +8,8 @@ */ fun case_1(x: Any) { if (x is Int || x is Float) { - & kotlin.Any")!>x - & kotlin.Any")!>x.toByte() + ")!>x + ")!>x.toByte() } } @@ -19,8 +19,8 @@ fun case_1(x: Any) { */ fun case_2(x: Any?) { if (x is Int || x is Float?) { - ? & kotlin.Any?")!>x - ? & kotlin.Any?")!>x.toByte() + ?")!>x + ?")!>x.toByte() } } @@ -30,8 +30,8 @@ fun case_2(x: Any?) { */ fun case_3(x: Any?) { if (x is Int? || x is Float) { - ? & kotlin.Any?")!>x - ? & kotlin.Any?")!>x.toByte() + ?")!>x + ?")!>x.toByte() } } @@ -41,8 +41,8 @@ fun case_3(x: Any?) { */ fun case_4(x: Any?) { if (x is Int? || x is Float?) { - ? & kotlin.Any?")!>x - ? & kotlin.Any?")!>x?.toByte() + ?")!>x + ?")!>x?.toByte() } } @@ -52,8 +52,8 @@ fun case_4(x: Any?) { */ fun case_5(x: Any?) { if (x is Int || x is Float) { - & kotlin.Any?")!>x - & kotlin.Any?")!>x.toByte() + ")!>x + ")!>x.toByte() } } @@ -63,8 +63,8 @@ fun case_5(x: Any?) { */ fun case_6(x: T) { if (x is Int || x is Float) { - & T!! & T")!>x - & T!! & T")!>x.toByte() + & T!!")!>x + & T!!")!>x.toByte() } } @@ -74,8 +74,8 @@ fun case_6(x: T) { */ fun case_7(x: T) { if (x is Int? || x is Float?) { - ? & T & T")!>x - ? & T & T")!>x.toByte() + ? & T")!>x + ? & T")!>x.toByte() } } @@ -85,8 +85,8 @@ fun case_7(x: T) { */ inline fun case_8(x: T) { if (x is Int? || x is Float?) { - ? & T & T")!>x - ? & T & T")!>x.toByte() + ? & T")!>x + ? & T")!>x.toByte() } } @@ -96,8 +96,8 @@ inline fun case_8(x: T) { */ inline fun case_9(x: T) { if (x is Int? || x is Float?) { - & T & T")!>x - & T & T")!>x.toByte() + & T")!>x + & T")!>x.toByte() } } @@ -107,8 +107,8 @@ inline fun case_9(x: T) { */ inline fun case_10(x: T) { if (x is ClassLevel2 || x is ClassLevel21 || x is ClassLevel22 || x is ClassLevel23) { - x - x.test1() + x + x.test1() } } @@ -118,8 +118,8 @@ inline fun case_10(x: T) { */ inline fun case_11(x: T) { if (x !is ClassLevel2 && x !is ClassLevel21 && x !is ClassLevel22 && x !is ClassLevel23) return - x - x.test1() + x + x.test1() } /* @@ -128,8 +128,8 @@ inline fun case_11(x: T) { */ fun case_12(x: Any) { if (x !is Int && x !is Float) return - & kotlin.Any")!>x - & kotlin.Any")!>x.toByte() + ")!>x + ")!>x.toByte() } /* @@ -138,8 +138,8 @@ fun case_12(x: Any) { */ fun case_13(x: T) { if (x !is Int && x !is Float) throw Exception() - & T!! & T")!>x - & T!! & T")!>x.toByte() + & T!!")!>x + & T!!")!>x.toByte() } /* @@ -149,11 +149,11 @@ fun case_13(x: T) { fun case_14(x: Any) { if (x is Int || x is Float) { if (x is Float) { - x - x.NaN + x + x.NaN } else { - & kotlin.Any")!>x - & kotlin.Any")!>x.inv() + ")!>x + ")!>x.inv() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/5.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/5.fir.kt index 831a7ddcdec..4ebf1b2ea41 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/5.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/5.fir.kt @@ -6,8 +6,8 @@ class Case1 { inline fun case_1(x: Any?) { if (x is T) { - x - x.toByte() + x + x.toByte() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/8.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/8.fir.kt index 487cce29809..0ffda3f9cbf 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/8.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/8.fir.kt @@ -5,29 +5,29 @@ // TESTCASE NUMBER: 1 fun case_1(x: Class?) { if (x?.fun_4()?.fun_4()?.fun_4()?.fun_4() != null) { - x - x.fun_4() - x.fun_4().fun_4() - x.fun_4().fun_4().fun_4() - x.fun_4().fun_4().fun_4().fun_4() + x + x.fun_4() + x.fun_4().fun_4() + x.fun_4().fun_4().fun_4() + x.fun_4().fun_4().fun_4().fun_4() } } // TESTCASE NUMBER: 2 fun case_2(x: Class?) { if (x?.fun_4()?.prop_8 != null) { - x - x.fun_4() - x.fun_4().prop_8 + x + x.fun_4() + x.fun_4().prop_8 } } // TESTCASE NUMBER: 3 fun case_3(x: Class?) { if (x?.prop_8?.fun_4() != null) { - x - x.prop_8 - x.prop_8.fun_4().prop_8 + x + x.prop_8 + x.prop_8.fun_4().prop_8 } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/9.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/9.fir.kt index 1ef6103365a..30061b6d5fa 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/9.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/9.fir.kt @@ -6,9 +6,9 @@ fun case_1(x: T?, y: K?) { x as T y as K - val z = x ?: y + val z = x ?: y - x.equals(10) + x.equals(10) z z.equals(10) } @@ -17,6 +17,6 @@ fun case_1(x: T?, y: K?) { inline fun case_2(y: K?) { y as K - y - y.equals(10) + y + y.equals(10) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt index cf64e0234b7..7acc5f215f0 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt @@ -28,16 +28,16 @@ import otherpackage.* // TESTCASE NUMBER: 1 fun case_1(x: Any?) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -48,8 +48,8 @@ fun case_1(x: Any?) { */ fun case_2(x: Nothing?) { if (x !== null) { - x - x.hashCode() + x + x.hashCode() } } @@ -73,16 +73,16 @@ fun case_3() { // TESTCASE NUMBER: 4 fun case_4(x: Char?) { if (x != null && true) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -90,16 +90,16 @@ fun case_4(x: Char?) { fun case_5() { val x: Unit? = null - if (x !== null) x - if (x !== null) x.equals(null) - if (x !== null) x.propT - if (x !== null) x.propAny - if (x !== null) x.propNullableT - if (x !== null) x.propNullableAny - if (x !== null) x.funT() - if (x !== null) x.funAny() - if (x !== null) x.funNullableT() - if (x !== null) x.funNullableAny() + if (x !== null) x + if (x !== null) x.equals(null) + if (x !== null) x.propT + if (x !== null) x.propAny + if (x !== null) x.propNullableT + if (x !== null) x.propNullableAny + if (x !== null) x.funT() + if (x !== null) x.funAny() + if (x !== null) x.funNullableT() + if (x !== null) x.funNullableAny() } // TESTCASE NUMBER: 6 @@ -107,47 +107,47 @@ fun case_6(x: EmptyClass?) { val y = true if (x != null && !y) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } // TESTCASE NUMBER: 7 fun case_7() { if (nullableNumberProperty != null || nullableNumberProperty != null) { - nullableNumberProperty - nullableNumberProperty.equals(null) - nullableNumberProperty.propT - nullableNumberProperty.propAny - nullableNumberProperty.propNullableT - nullableNumberProperty.propNullableAny - nullableNumberProperty.funT() - nullableNumberProperty.funAny() - nullableNumberProperty.funNullableT() - nullableNumberProperty.funNullableAny() + nullableNumberProperty + nullableNumberProperty.equals(null) + nullableNumberProperty.propT + nullableNumberProperty.propAny + nullableNumberProperty.propNullableT + nullableNumberProperty.propNullableAny + nullableNumberProperty.funT() + nullableNumberProperty.funAny() + nullableNumberProperty.funNullableT() + nullableNumberProperty.funNullableAny() } } // TESTCASE NUMBER: 8 fun case_8(x: TypealiasNullableString) { - if (x !== null && x != null) x - if (x !== null && x != null) x.equals(null) - if (x !== null && x != null) x.propT - if (x !== null && x != null) x.propAny - if (x !== null && x != null) x.propNullableT - if (x !== null && x != null) x.propNullableAny - if (x !== null && x != null) x.funT() - if (x !== null && x != null) x.funAny() - if (x !== null && x != null) x.funNullableT() - if (x !== null && x != null) x.funNullableAny() + if (x !== null && x != null) x + if (x !== null && x != null) x.equals(null) + if (x !== null && x != null) x.propT + if (x !== null && x != null) x.propAny + if (x !== null && x != null) x.propNullableT + if (x !== null && x != null) x.propNullableAny + if (x !== null && x != null) x.funT() + if (x !== null && x != null) x.funAny() + if (x !== null && x != null) x.funNullableT() + if (x !== null && x != null) x.funNullableAny() } // TESTCASE NUMBER: 9 @@ -155,16 +155,16 @@ fun case_9(x: TypealiasNullableString?) { if (x === null) { } else if (false) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -198,16 +198,16 @@ fun case_11(x: TypealiasNullableStringIndirect?, y: TypealiasNullableStringIndir if (y != null) { if (nullableStringProperty == null) { if (t != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -217,16 +217,16 @@ fun case_11(x: TypealiasNullableStringIndirect?, y: TypealiasNullableStringIndir // TESTCASE NUMBER: 12 fun case_12(x: TypealiasNullableStringIndirect, y: TypealiasNullableStringIndirect) = if (x == null) "1" - else if (y === null) x - else if (y === null) x.equals(null) - else if (y === null) x.propT - else if (y === null) x.propAny - else if (y === null) x.propNullableT - else if (y === null) x.propNullableAny - else if (y === null) x.funT() - else if (y === null) x.funAny() - else if (y === null) x.funNullableT() - else if (y === null) x.funNullableAny() + else if (y === null) x + else if (y === null) x.equals(null) + else if (y === null) x.propT + else if (y === null) x.propAny + else if (y === null) x.propNullableT + else if (y === null) x.propNullableAny + else if (y === null) x.funT() + else if (y === null) x.funAny() + else if (y === null) x.funNullableT() + else if (y === null) x.funNullableAny() else "-1" // TESTCASE NUMBER: 13 @@ -234,16 +234,16 @@ fun case_13(x: otherpackage.Case13?) = if (x == null) { throw Exception() } else { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 14 @@ -322,37 +322,37 @@ fun case_16() { val x: TypealiasNullableNothing = null if (x != null) { - x + x } } // TESTCASE NUMBER: 17 val case_17 = if (nullableIntProperty == null) 0 else { - nullableIntProperty - nullableIntProperty.equals(null) - nullableIntProperty.propT - nullableIntProperty.propAny - nullableIntProperty.propNullableT - nullableIntProperty.propNullableAny - nullableIntProperty.funT() - nullableIntProperty.funAny() - nullableIntProperty.funNullableT() - nullableIntProperty.funNullableAny() + nullableIntProperty + nullableIntProperty.equals(null) + nullableIntProperty.propT + nullableIntProperty.propAny + nullableIntProperty.propNullableT + nullableIntProperty.propNullableAny + nullableIntProperty.funT() + nullableIntProperty.funAny() + nullableIntProperty.funNullableT() + nullableIntProperty.funNullableAny() } //TESTCASE NUMBER: 18 fun case_18(a: DeepObject.A.B.C.D.E.F.G.J?) { if (a != null) { - a - a.equals(null) - a.propT - a.propAny - a.propNullableT - a.propNullableAny - a.funT() - a.funAny() - a.funNullableT() - a.funNullableAny() + a + a.equals(null) + a.propT + a.propAny + a.propNullableT + a.propNullableAny + a.funT() + a.funAny() + a.funNullableT() + a.funNullableAny() } } @@ -451,18 +451,18 @@ fun case_22(a: (() -> Unit)?) { // TESTCASE NUMBER: 23 fun case_23(a: ((Float) -> Int?)?, b: Float?) { if (a != null && b !== null) { - val x = a(b) + val x = a(b) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -470,17 +470,17 @@ fun case_23(a: ((Float) -> Int?)?, b: Float?) { // TESTCASE NUMBER: 24 fun case_24(a: ((() -> Unit) -> Unit)?, b: (() -> Unit)?) = if (a !== null && b !== null) { - a( & kotlin.Function0?")!>b) + a(? & kotlin.Function0")!>b) a(b) - & kotlin.Function0?")!>b.equals(null) - & kotlin.Function0?")!>b.propT - & kotlin.Function0?")!>b.propAny - & kotlin.Function0?")!>b.propNullableT - & kotlin.Function0?")!>b.propNullableAny - & kotlin.Function0?")!>b.funT() - & kotlin.Function0?")!>b.funAny() - & kotlin.Function0?")!>b.funNullableT() - & kotlin.Function0?")!>b.funNullableAny() + ? & kotlin.Function0")!>b.equals(null) + ? & kotlin.Function0")!>b.propT + ? & kotlin.Function0")!>b.propAny + ? & kotlin.Function0")!>b.propNullableT + ? & kotlin.Function0")!>b.propNullableAny + ? & kotlin.Function0")!>b.funT() + ? & kotlin.Function0")!>b.funAny() + ? & kotlin.Function0")!>b.funNullableT() + ? & kotlin.Function0")!>b.funNullableAny() } else null // TESTCASE NUMBER: 25 @@ -497,16 +497,16 @@ fun case_25(b: Boolean) { val z = ?")!>y() if (z != null) { - & ?")!>z.a - & ?")!>z.a.equals(null) - & ?")!>z.a.propT - & ?")!>z.a.propAny - & ?")!>z.a.propNullableT - & ?")!>z.a.propNullableAny - & ?")!>z.a.funT() - & ?")!>z.a.funAny() - & ?")!>z.a.funNullableT() - & ?")!>z.a.funNullableAny() + ? & ")!>z.a + ? & ")!>z.a.equals(null) + ? & ")!>z.a.propT + ? & ")!>z.a.propAny + ? & ")!>z.a.propNullableT + ? & ")!>z.a.propNullableAny + ? & ")!>z.a.funT() + ? & ")!>z.a.funAny() + ? & ")!>z.a.funNullableT() + ? & ")!>z.a.funNullableAny() } } } @@ -514,18 +514,18 @@ fun case_25(b: Boolean) { // TESTCASE NUMBER: 26 fun case_26(a: ((Float) -> Int?)?, b: Float?) { if (a != null == true && b != null == true) { - val x = a(b) + val x = a(b) if (x != null == true) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -550,16 +550,16 @@ fun case_27() { //TESTCASE NUMBER: 28 fun case_28(a: DeepObject.A.B.C.D.E.F.G.J?) = if (a != null == true == false == false == false == true == false == true == false == false == true == true) { - a.x - a.equals(null) - a.propT - a.propAny - a.propNullableT - a.propNullableAny - a.funT() - a.funAny() - a.funNullableT() - a.funNullableAny() + a.x + a.equals(null) + a.propT + a.propAny + a.propNullableT + a.propNullableAny + a.funT() + a.funAny() + a.funNullableT() + a.funNullableAny() } else -1 // TESTCASE NUMBER: 29 @@ -574,35 +574,35 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: val t: String? = if (u != null) this.u else null init { - if (a != null) a.equals(null) - if (a != null) a.propT - if (a != null) a.propAny - if (a != null) a.propNullableT - if (a != null) a.propNullableAny - if (a != null) a.funT() - if (a != null) a.funAny() - if (a != null) a.funNullableT() - if (a != null) a.funNullableAny() - if (a != null) a + if (a != null) a.equals(null) + if (a != null) a.propT + if (a != null) a.propAny + if (a != null) a.propNullableT + if (a != null) a.propNullableAny + if (a != null) a.funT() + if (a != null) a.funAny() + if (a != null) a.funNullableT() + if (a != null) a.funNullableAny() + if (a != null) a - if (b != null) b.equals(null) + if (b != null) b.equals(null) - if (b != null) b.propT + if (b != null) b.propT - if (b != null) b.propAny + if (b != null) b.propAny - if (b != null) b.propNullableT + if (b != null) b.propNullableT - if (b != null) b.propNullableAny + if (b != null) b.propNullableAny - if (b != null) b.funT() + if (b != null) b.funT() - if (b != null) b.funAny() + if (b != null) b.funAny() - if (b != null) b.funNullableT() + if (b != null) b.funNullableT() - if (b != null) b.funNullableAny() - if (b != null) b + if (b != null) b.funNullableAny() + if (b != null) b if (this.b != null) this.b if (this.b != null) this.b.equals(null) if (this.b != null) this.b.propT @@ -613,16 +613,16 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (this.b != null) this.b.funAny() if (this.b != null) this.b.funNullableT() if (this.b != null) this.b.funNullableAny() - if (this.b != null) b - if (this.b != null) b.equals(null) - if (this.b != null) b.propT - if (this.b != null) b.propAny - if (this.b != null) b.propNullableT - if (this.b != null) b.propNullableAny - if (this.b != null) b.funT() - if (this.b != null) b.funAny() - if (this.b != null) b.funNullableT() - if (this.b != null) b.funNullableAny() + if (this.b != null) b + if (this.b != null) b.equals(null) + if (this.b != null) b.propT + if (this.b != null) b.propAny + if (this.b != null) b.propNullableT + if (this.b != null) b.propNullableAny + if (this.b != null) b.funT() + if (this.b != null) b.funAny() + if (this.b != null) b.funNullableT() + if (this.b != null) b.funNullableAny() if (b != null) this.b if (b != null) this.b.equals(null) if (b != null) this.b.propT @@ -633,16 +633,16 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (b != null) this.b.funAny() if (b != null) this.b.funNullableT() if (b != null) this.b.funNullableAny() - if (b != null || this.b != null) b.equals(null) - if (b != null || this.b != null) b.propT - if (b != null || this.b != null) b.propAny - if (b != null || this.b != null) b.propNullableT - if (b != null || this.b != null) b.propNullableAny - if (b != null || this.b != null) b.funT() - if (b != null || this.b != null) b.funAny() - if (b != null || this.b != null) b.funNullableT() - if (b != null || this.b != null) b.funNullableAny() - if (b != null || this.b != null) b + if (b != null || this.b != null) b.equals(null) + if (b != null || this.b != null) b.propT + if (b != null || this.b != null) b.propAny + if (b != null || this.b != null) b.propNullableT + if (b != null || this.b != null) b.propNullableAny + if (b != null || this.b != null) b.funT() + if (b != null || this.b != null) b.funAny() + if (b != null || this.b != null) b.funNullableT() + if (b != null || this.b != null) b.funNullableAny() + if (b != null || this.b != null) b if (b != null || this.b != null) this.b.equals(null) if (b != null || this.b != null) this.b.propT if (b != null || this.b != null) this.b.propAny @@ -654,24 +654,24 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (b != null || this.b != null) this.b.funNullableAny() if (b != null || this.b != null) this.b - if (c != null) c.equals(null) + if (c != null) c.equals(null) - if (c != null) c.propT + if (c != null) c.propT - if (c != null) c.propAny + if (c != null) c.propAny - if (c != null) c.propNullableT + if (c != null) c.propNullableT - if (c != null) c.propNullableAny + if (c != null) c.propNullableAny - if (c != null) c.funT() + if (c != null) c.funT() - if (c != null) c.funAny() + if (c != null) c.funAny() - if (c != null) c.funNullableT() + if (c != null) c.funNullableT() - if (c != null) c.funNullableAny() - if (c != null) c + if (c != null) c.funNullableAny() + if (c != null) c if (this.c != null) this.c.equals(null) if (this.c != null) this.c.propT if (this.c != null) this.c.propAny @@ -692,26 +692,26 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (c != null) this.c.funNullableT() if (c != null) this.c.funNullableAny() if (c != null) this.c - if (this.c != null) c.equals(null) - if (this.c != null) c.propT - if (this.c != null) c.propAny - if (this.c != null) c.propNullableT - if (this.c != null) c.propNullableAny - if (this.c != null) c.funT() - if (this.c != null) c.funAny() - if (this.c != null) c.funNullableT() - if (this.c != null) c.funNullableAny() - if (this.c != null) c - if (c != null || this.c != null) c.equals(null) - if (c != null || this.c != null) c.propT - if (c != null || this.c != null) c.propAny - if (c != null || this.c != null) c.propNullableT - if (c != null || this.c != null) c.propNullableAny - if (c != null || this.c != null) c.funT() - if (c != null || this.c != null) c.funAny() - if (c != null || this.c != null) c.funNullableT() - if (c != null || this.c != null) c.funNullableAny() - if (c != null || this.c != null) c + if (this.c != null) c.equals(null) + if (this.c != null) c.propT + if (this.c != null) c.propAny + if (this.c != null) c.propNullableT + if (this.c != null) c.propNullableAny + if (this.c != null) c.funT() + if (this.c != null) c.funAny() + if (this.c != null) c.funNullableT() + if (this.c != null) c.funNullableAny() + if (this.c != null) c + if (c != null || this.c != null) c.equals(null) + if (c != null || this.c != null) c.propT + if (c != null || this.c != null) c.propAny + if (c != null || this.c != null) c.propNullableT + if (c != null || this.c != null) c.propNullableAny + if (c != null || this.c != null) c.funT() + if (c != null || this.c != null) c.funAny() + if (c != null || this.c != null) c.funNullableT() + if (c != null || this.c != null) c.funNullableAny() + if (c != null || this.c != null) c if (c != null || this.c != null) this.c.equals(null) if (c != null || this.c != null) this.c.propT if (c != null || this.c != null) this.c.propAny @@ -723,24 +723,24 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (c != null || this.c != null) this.c.funNullableAny() if (c != null || this.c != null) this.c - if (d != null) d.equals(null) + if (d != null) d.equals(null) - if (d != null) d.propT + if (d != null) d.propT - if (d != null) d.propAny + if (d != null) d.propAny - if (d != null) d.propNullableT + if (d != null) d.propNullableT - if (d != null) d.propNullableAny + if (d != null) d.propNullableAny - if (d != null) d.funT() + if (d != null) d.funT() - if (d != null) d.funAny() + if (d != null) d.funAny() - if (d != null) d.funNullableT() + if (d != null) d.funNullableT() - if (d != null) d.funNullableAny() - if (d != null) d + if (d != null) d.funNullableAny() + if (d != null) d if (this.d != null) this.d.equals(null) if (this.d != null) this.d.propT if (this.d != null) this.d.propAny @@ -761,26 +761,26 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (d != null) this.d.funNullableT() if (d != null) this.d.funNullableAny() if (d != null) this.d - if (this.d != null) d.equals(null) - if (this.d != null) d.propT - if (this.d != null) d.propAny - if (this.d != null) d.propNullableT - if (this.d != null) d.propNullableAny - if (this.d != null) d.funT() - if (this.d != null) d.funAny() - if (this.d != null) d.funNullableT() - if (this.d != null) d.funNullableAny() - if (this.d != null) d - if (d != null || this.d != null) d.equals(null) - if (d != null || this.d != null) d.propT - if (d != null || this.d != null) d.propAny - if (d != null || this.d != null) d.propNullableT - if (d != null || this.d != null) d.propNullableAny - if (d != null || this.d != null) d.funT() - if (d != null || this.d != null) d.funAny() - if (d != null || this.d != null) d.funNullableT() - if (d != null || this.d != null) d.funNullableAny() - if (d != null || this.d != null) d + if (this.d != null) d.equals(null) + if (this.d != null) d.propT + if (this.d != null) d.propAny + if (this.d != null) d.propNullableT + if (this.d != null) d.propNullableAny + if (this.d != null) d.funT() + if (this.d != null) d.funAny() + if (this.d != null) d.funNullableT() + if (this.d != null) d.funNullableAny() + if (this.d != null) d + if (d != null || this.d != null) d.equals(null) + if (d != null || this.d != null) d.propT + if (d != null || this.d != null) d.propAny + if (d != null || this.d != null) d.propNullableT + if (d != null || this.d != null) d.propNullableAny + if (d != null || this.d != null) d.funT() + if (d != null || this.d != null) d.funAny() + if (d != null || this.d != null) d.funNullableT() + if (d != null || this.d != null) d.funNullableAny() + if (d != null || this.d != null) d if (d != null || this.d != null) this.d.equals(null) if (d != null || this.d != null) this.d.propT if (d != null || this.d != null) this.d.propAny @@ -792,24 +792,24 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (d != null || this.d != null) this.d.funNullableAny() if (d != null || this.d != null) this.d - if (e != null) e.equals(null) + if (e != null) e.equals(null) - if (e != null) e.propT + if (e != null) e.propT - if (e != null) e.propAny + if (e != null) e.propAny - if (e != null) e.propNullableT + if (e != null) e.propNullableT - if (e != null) e.propNullableAny + if (e != null) e.propNullableAny - if (e != null) e.funT() + if (e != null) e.funT() - if (e != null) e.funAny() + if (e != null) e.funAny() - if (e != null) e.funNullableT() + if (e != null) e.funNullableT() - if (e != null) e.funNullableAny() - if (e != null) e + if (e != null) e.funNullableAny() + if (e != null) e if (this.e != null) this.e.equals(null) if (this.e != null) this.e.propT if (this.e != null) this.e.propAny @@ -820,16 +820,16 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (this.e != null) this.e.funNullableT() if (this.e != null) this.e.funNullableAny() if (this.e != null) this.e - if (this.e != null) e.equals(null) - if (this.e != null) e.propT - if (this.e != null) e.propAny - if (this.e != null) e.propNullableT - if (this.e != null) e.propNullableAny - if (this.e != null) e.funT() - if (this.e != null) e.funAny() - if (this.e != null) e.funNullableT() - if (this.e != null) e.funNullableAny() - if (this.e != null) e + if (this.e != null) e.equals(null) + if (this.e != null) e.propT + if (this.e != null) e.propAny + if (this.e != null) e.propNullableT + if (this.e != null) e.propNullableAny + if (this.e != null) e.funT() + if (this.e != null) e.funAny() + if (this.e != null) e.funNullableT() + if (this.e != null) e.funNullableAny() + if (this.e != null) e if (e != null) this.e.equals(null) if (e != null) this.e.propT if (e != null) this.e.propAny @@ -840,16 +840,16 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (e != null) this.e.funNullableT() if (e != null) this.e.funNullableAny() if (e != null) this.e - if (e != null || this.e != null) e.equals(null) - if (e != null || this.e != null) e.propT - if (e != null || this.e != null) e.propAny - if (e != null || this.e != null) e.propNullableT - if (e != null || this.e != null) e.propNullableAny - if (e != null || this.e != null) e.funT() - if (e != null || this.e != null) e.funAny() - if (e != null || this.e != null) e.funNullableT() - if (e != null || this.e != null) e.funNullableAny() - if (e != null || this.e != null) e + if (e != null || this.e != null) e.equals(null) + if (e != null || this.e != null) e.propT + if (e != null || this.e != null) e.propAny + if (e != null || this.e != null) e.propNullableT + if (e != null || this.e != null) e.propNullableAny + if (e != null || this.e != null) e.funT() + if (e != null || this.e != null) e.funAny() + if (e != null || this.e != null) e.funNullableT() + if (e != null || this.e != null) e.funNullableAny() + if (e != null || this.e != null) e if (e != null || this.e != null) this.e.equals(null) if (e != null || this.e != null) this.e.propT if (e != null || this.e != null) this.e.propAny @@ -861,24 +861,24 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (e != null || this.e != null) this.e.funNullableAny() if (e != null || this.e != null) this.e - if (f != null) f.equals(null) + if (f != null) f.equals(null) - if (f != null) f.propT + if (f != null) f.propT - if (f != null) f.propAny + if (f != null) f.propAny - if (f != null) f.propNullableT + if (f != null) f.propNullableT - if (f != null) f.propNullableAny + if (f != null) f.propNullableAny - if (f != null) f.funT() + if (f != null) f.funT() - if (f != null) f.funAny() + if (f != null) f.funAny() - if (f != null) f.funNullableT() + if (f != null) f.funNullableT() - if (f != null) f.funNullableAny() - if (f != null) f + if (f != null) f.funNullableAny() + if (f != null) f if (this.f != null) this.f.equals(null) if (this.f != null) this.f.propT if (this.f != null) this.f.propAny @@ -889,16 +889,16 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (this.f != null) this.f.funNullableT() if (this.f != null) this.f.funNullableAny() if (this.f != null) this.f - if (this.f != null) f.equals(null) - if (this.f != null) f.propT - if (this.f != null) f.propAny - if (this.f != null) f.propNullableT - if (this.f != null) f.propNullableAny - if (this.f != null) f.funT() - if (this.f != null) f.funAny() - if (this.f != null) f.funNullableT() - if (this.f != null) f.funNullableAny() - if (this.f != null) f + if (this.f != null) f.equals(null) + if (this.f != null) f.propT + if (this.f != null) f.propAny + if (this.f != null) f.propNullableT + if (this.f != null) f.propNullableAny + if (this.f != null) f.funT() + if (this.f != null) f.funAny() + if (this.f != null) f.funNullableT() + if (this.f != null) f.funNullableAny() + if (this.f != null) f if (f != null) this.f.equals(null) if (f != null) this.f.propT if (f != null) this.f.propAny @@ -909,16 +909,16 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (f != null) this.f.funNullableT() if (f != null) this.f.funNullableAny() if (f != null) this.f - if (f != null || this.f != null) f.equals(null) - if (f != null || this.f != null) f.propT - if (f != null || this.f != null) f.propAny - if (f != null || this.f != null) f.propNullableT - if (f != null || this.f != null) f.propNullableAny - if (f != null || this.f != null) f.funT() - if (f != null || this.f != null) f.funAny() - if (f != null || this.f != null) f.funNullableT() - if (f != null || this.f != null) f.funNullableAny() - if (f != null || this.f != null) f + if (f != null || this.f != null) f.equals(null) + if (f != null || this.f != null) f.propT + if (f != null || this.f != null) f.propAny + if (f != null || this.f != null) f.propNullableT + if (f != null || this.f != null) f.propNullableAny + if (f != null || this.f != null) f.funT() + if (f != null || this.f != null) f.funAny() + if (f != null || this.f != null) f.funNullableT() + if (f != null || this.f != null) f.funNullableAny() + if (f != null || this.f != null) f if (f != null || this.f != null) this.f.equals(null) if (f != null || this.f != null) this.f.propT if (f != null || this.f != null) this.f.propAny @@ -930,24 +930,24 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (f != null || this.f != null) this.f.funNullableAny() if (f != null || this.f != null) this.f - if (x != null) x.equals(null) + if (x != null) x.equals(null) - if (x != null) x.propT + if (x != null) x.propT - if (x != null) x.propAny + if (x != null) x.propAny - if (x != null) x.propNullableT + if (x != null) x.propNullableT - if (x != null) x.propNullableAny + if (x != null) x.propNullableAny - if (x != null) x.funT() + if (x != null) x.funT() - if (x != null) x.funAny() + if (x != null) x.funAny() - if (x != null) x.funNullableT() + if (x != null) x.funNullableT() - if (x != null) x.funNullableAny() - if (x != null) x + if (x != null) x.funNullableAny() + if (x != null) x if (this.x != null) this.x.equals(null) if (this.x != null) this.x.propT if (this.x != null) this.x.propAny @@ -968,26 +968,26 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (x != null) this.x.funNullableT() if (x != null) this.x.funNullableAny() if (x != null) this.x - if (this.x != null) x.equals(null) - if (this.x != null) x.propT - if (this.x != null) x.propAny - if (this.x != null) x.propNullableT - if (this.x != null) x.propNullableAny - if (this.x != null) x.funT() - if (this.x != null) x.funAny() - if (this.x != null) x.funNullableT() - if (this.x != null) x.funNullableAny() - if (this.x != null) x - if (x != null || this.x != null) x.equals(null) - if (x != null || this.x != null) x.propT - if (x != null || this.x != null) x.propAny - if (x != null || this.x != null) x.propNullableT - if (x != null || this.x != null) x.propNullableAny - if (x != null || this.x != null) x.funT() - if (x != null || this.x != null) x.funAny() - if (x != null || this.x != null) x.funNullableT() - if (x != null || this.x != null) x.funNullableAny() - if (x != null || this.x != null) x + if (this.x != null) x.equals(null) + if (this.x != null) x.propT + if (this.x != null) x.propAny + if (this.x != null) x.propNullableT + if (this.x != null) x.propNullableAny + if (this.x != null) x.funT() + if (this.x != null) x.funAny() + if (this.x != null) x.funNullableT() + if (this.x != null) x.funNullableAny() + if (this.x != null) x + if (x != null || this.x != null) x.equals(null) + if (x != null || this.x != null) x.propT + if (x != null || this.x != null) x.propAny + if (x != null || this.x != null) x.propNullableT + if (x != null || this.x != null) x.propNullableAny + if (x != null || this.x != null) x.funT() + if (x != null || this.x != null) x.funAny() + if (x != null || this.x != null) x.funNullableT() + if (x != null || this.x != null) x.funNullableAny() + if (x != null || this.x != null) x if (x != null || this.x != null) this.x.equals(null) if (x != null || this.x != null) this.x.propT if (x != null || this.x != null) this.x.propAny @@ -999,24 +999,24 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (x != null || this.x != null) this.x.funNullableAny() if (x != null || this.x != null) this.x - if (y != null) y.equals(null) + if (y != null) y.equals(null) - if (y != null) y.propT + if (y != null) y.propT - if (y != null) y.propAny + if (y != null) y.propAny - if (y != null) y.propNullableT + if (y != null) y.propNullableT - if (y != null) y.propNullableAny + if (y != null) y.propNullableAny - if (y != null) y.funT() + if (y != null) y.funT() - if (y != null) y.funAny() + if (y != null) y.funAny() - if (y != null) y.funNullableT() + if (y != null) y.funNullableT() - if (y != null) y.funNullableAny() - if (y != null) y + if (y != null) y.funNullableAny() + if (y != null) y if (this.y != null) this.y.equals(null) if (this.y != null) this.y.propT if (this.y != null) this.y.propAny @@ -1027,16 +1027,16 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (this.y != null) this.y.funNullableT() if (this.y != null) this.y.funNullableAny() if (this.y != null) this.y - if (this.y != null) y.equals(null) - if (this.y != null) y.propT - if (this.y != null) y.propAny - if (this.y != null) y.propNullableT - if (this.y != null) y.propNullableAny - if (this.y != null) y.funT() - if (this.y != null) y.funAny() - if (this.y != null) y.funNullableT() - if (this.y != null) y.funNullableAny() - if (this.y != null) y + if (this.y != null) y.equals(null) + if (this.y != null) y.propT + if (this.y != null) y.propAny + if (this.y != null) y.propNullableT + if (this.y != null) y.propNullableAny + if (this.y != null) y.funT() + if (this.y != null) y.funAny() + if (this.y != null) y.funNullableT() + if (this.y != null) y.funNullableAny() + if (this.y != null) y if (y != null) this.y.equals(null) if (y != null) this.y.propT if (y != null) this.y.propAny @@ -1047,16 +1047,16 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (y != null) this.y.funNullableT() if (y != null) this.y.funNullableAny() if (y != null) this.y - if (y != null || this.y != null) y.equals(null) - if (y != null || this.y != null) y.propT - if (y != null || this.y != null) y.propAny - if (y != null || this.y != null) y.propNullableT - if (y != null || this.y != null) y.propNullableAny - if (y != null || this.y != null) y.funT() - if (y != null || this.y != null) y.funAny() - if (y != null || this.y != null) y.funNullableT() - if (y != null || this.y != null) y.funNullableAny() - if (y != null || this.y != null) y + if (y != null || this.y != null) y.equals(null) + if (y != null || this.y != null) y.propT + if (y != null || this.y != null) y.propAny + if (y != null || this.y != null) y.propNullableT + if (y != null || this.y != null) y.propNullableAny + if (y != null || this.y != null) y.funT() + if (y != null || this.y != null) y.funAny() + if (y != null || this.y != null) y.funNullableT() + if (y != null || this.y != null) y.funNullableAny() + if (y != null || this.y != null) y if (y != null || this.y != null) this.y.equals(null) if (y != null || this.y != null) this.y.propT if (y != null || this.y != null) this.y.propAny @@ -1068,24 +1068,24 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (y != null || this.y != null) this.y.funNullableAny() if (y != null || this.y != null) this.y - if (z != null) z.equals(null) + if (z != null) z.equals(null) - if (z != null) z.propT + if (z != null) z.propT - if (z != null) z.propAny + if (z != null) z.propAny - if (z != null) z.propNullableT + if (z != null) z.propNullableT - if (z != null) z.propNullableAny + if (z != null) z.propNullableAny - if (z != null) z.funT() + if (z != null) z.funT() - if (z != null) z.funAny() + if (z != null) z.funAny() - if (z != null) z.funNullableT() + if (z != null) z.funNullableT() - if (z != null) z.funNullableAny() - if (z != null) z + if (z != null) z.funNullableAny() + if (z != null) z if (this.z != null) this.z.equals(null) if (this.z != null) this.z.propT if (this.z != null) this.z.propAny @@ -1106,26 +1106,26 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (z != null) this.z.funNullableT() if (z != null) this.z.funNullableAny() if (z != null) this.z - if (this.z != null) z.equals(null) - if (this.z != null) z.propT - if (this.z != null) z.propAny - if (this.z != null) z.propNullableT - if (this.z != null) z.propNullableAny - if (this.z != null) z.funT() - if (this.z != null) z.funAny() - if (this.z != null) z.funNullableT() - if (this.z != null) z.funNullableAny() - if (this.z != null) z - if (z != null || this.z != null) z - if (z != null || this.z != null) z.equals(null) - if (z != null || this.z != null) z.propT - if (z != null || this.z != null) z.propAny - if (z != null || this.z != null) z.propNullableT - if (z != null || this.z != null) z.propNullableAny - if (z != null || this.z != null) z.funT() - if (z != null || this.z != null) z.funAny() - if (z != null || this.z != null) z.funNullableT() - if (z != null || this.z != null) z.funNullableAny() + if (this.z != null) z.equals(null) + if (this.z != null) z.propT + if (this.z != null) z.propAny + if (this.z != null) z.propNullableT + if (this.z != null) z.propNullableAny + if (this.z != null) z.funT() + if (this.z != null) z.funAny() + if (this.z != null) z.funNullableT() + if (this.z != null) z.funNullableAny() + if (this.z != null) z + if (z != null || this.z != null) z + if (z != null || this.z != null) z.equals(null) + if (z != null || this.z != null) z.propT + if (z != null || this.z != null) z.propAny + if (z != null || this.z != null) z.propNullableT + if (z != null || this.z != null) z.propNullableAny + if (z != null || this.z != null) z.funT() + if (z != null || this.z != null) z.funAny() + if (z != null || this.z != null) z.funNullableT() + if (z != null || this.z != null) z.funNullableAny() if (z != null || this.z != null) this.z if (z != null || this.z != null) this.z.equals(null) if (z != null || this.z != null) this.z.propT @@ -1137,24 +1137,24 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (z != null || this.z != null) this.z.funNullableT() if (z != null || this.z != null) this.z.funNullableAny() - if (u != null) u.equals(null) + if (u != null) u.equals(null) - if (u != null) u.propT + if (u != null) u.propT - if (u != null) u.propAny + if (u != null) u.propAny - if (u != null) u.propNullableT + if (u != null) u.propNullableT - if (u != null) u.propNullableAny + if (u != null) u.propNullableAny - if (u != null) u.funT() + if (u != null) u.funT() - if (u != null) u.funAny() + if (u != null) u.funAny() - if (u != null) u.funNullableT() + if (u != null) u.funNullableT() - if (u != null) u.funNullableAny() - if (u != null) u + if (u != null) u.funNullableAny() + if (u != null) u if (this.u != null) this.u.equals(null) if (this.u != null) this.u.propT if (this.u != null) this.u.propAny @@ -1165,16 +1165,16 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (this.u != null) this.u.funNullableT() if (this.u != null) this.u.funNullableAny() if (this.u != null) this.u - if (this.u != null) u.equals(null) - if (this.u != null) u.propT - if (this.u != null) u.propAny - if (this.u != null) u.propNullableT - if (this.u != null) u.propNullableAny - if (this.u != null) u.funT() - if (this.u != null) u.funAny() - if (this.u != null) u.funNullableT() - if (this.u != null) u.funNullableAny() - if (this.u != null) u + if (this.u != null) u.equals(null) + if (this.u != null) u.propT + if (this.u != null) u.propAny + if (this.u != null) u.propNullableT + if (this.u != null) u.propNullableAny + if (this.u != null) u.funT() + if (this.u != null) u.funAny() + if (this.u != null) u.funNullableT() + if (this.u != null) u.funNullableAny() + if (this.u != null) u if (u != null) this.u.equals(null) if (u != null) this.u.propT if (u != null) this.u.propAny @@ -1185,16 +1185,16 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (u != null) this.u.funNullableT() if (u != null) this.u.funNullableAny() if (u != null) this.u - if (u != null || this.u != null) u.equals(null) - if (u != null || this.u != null) u.propT - if (u != null || this.u != null) u.propAny - if (u != null || this.u != null) u.propNullableT - if (u != null || this.u != null) u.propNullableAny - if (u != null || this.u != null) u.funT() - if (u != null || this.u != null) u.funAny() - if (u != null || this.u != null) u.funNullableT() - if (u != null || this.u != null) u.funNullableAny() - if (u != null || this.u != null) u + if (u != null || this.u != null) u.equals(null) + if (u != null || this.u != null) u.propT + if (u != null || this.u != null) u.propAny + if (u != null || this.u != null) u.propNullableT + if (u != null || this.u != null) u.propNullableAny + if (u != null || this.u != null) u.funT() + if (u != null || this.u != null) u.funAny() + if (u != null || this.u != null) u.funNullableT() + if (u != null || this.u != null) u.funNullableAny() + if (u != null || this.u != null) u if (u != null || this.u != null) this.u.equals(null) if (u != null || this.u != null) this.u.propT if (u != null || this.u != null) this.u.propAny @@ -1207,46 +1207,46 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (u != null || this.u != null) this.u v = 0 - v.equals(null) - v.propT - v.propAny - v.propNullableT - v.propNullableAny - v.funT() - v.funAny() - v.funNullableT() - v.funNullableAny() - v - if (v != null) v.equals(null) - if (v != null) v.propT - if (v != null) v.propAny - if (v != null) v.propNullableT - if (v != null) v.propNullableAny - if (v != null) v.funT() - if (v != null) v.funAny() - if (v != null) v.funNullableT() - if (v != null) v.funNullableAny() - if (v != null) v - if (this.v != null) v.equals(null) - if (this.v != null) v.propT - if (this.v != null) v.propAny - if (this.v != null) v.propNullableT - if (this.v != null) v.propNullableAny - if (this.v != null) v.funT() - if (this.v != null) v.funAny() - if (this.v != null) v.funNullableT() - if (this.v != null) v.funNullableAny() - if (this.v != null) v - if (v != null || this.v != null) v.equals(null) - if (v != null || this.v != null) v.propT - if (v != null || this.v != null) v.propAny - if (v != null || this.v != null) v.propNullableT - if (v != null || this.v != null) v.propNullableAny - if (v != null || this.v != null) v.funT() - if (v != null || this.v != null) v.funAny() - if (v != null || this.v != null) v.funNullableT() - if (v != null || this.v != null) v.funNullableAny() - if (v != null || this.v != null) v + v.equals(null) + v.propT + v.propAny + v.propNullableT + v.propNullableAny + v.funT() + v.funAny() + v.funNullableT() + v.funNullableAny() + v + if (v != null) v.equals(null) + if (v != null) v.propT + if (v != null) v.propAny + if (v != null) v.propNullableT + if (v != null) v.propNullableAny + if (v != null) v.funT() + if (v != null) v.funAny() + if (v != null) v.funNullableT() + if (v != null) v.funNullableAny() + if (v != null) v + if (this.v != null) v.equals(null) + if (this.v != null) v.propT + if (this.v != null) v.propAny + if (this.v != null) v.propNullableT + if (this.v != null) v.propNullableAny + if (this.v != null) v.funT() + if (this.v != null) v.funAny() + if (this.v != null) v.funNullableT() + if (this.v != null) v.funNullableAny() + if (this.v != null) v + if (v != null || this.v != null) v.equals(null) + if (v != null || this.v != null) v.propT + if (v != null || this.v != null) v.propAny + if (v != null || this.v != null) v.propNullableT + if (v != null || this.v != null) v.propNullableAny + if (v != null || this.v != null) v.funT() + if (v != null || this.v != null) v.funAny() + if (v != null || this.v != null) v.funNullableT() + if (v != null || this.v != null) v.funNullableAny() + if (v != null || this.v != null) v if (v != null || this.v != null) this.v.equals(null) if (v != null || this.v != null) this.v.propT if (v != null || this.v != null) this.v.propAny @@ -1259,37 +1259,37 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (v != null || this.v != null) this.v w = if (null != null) 10 else null - w - if (w != null) w.equals(null) - if (w != null) w.propT - if (w != null) w.propAny - if (w != null) w.propNullableT - if (w != null) w.propNullableAny - if (w != null) w.funT() - if (w != null) w.funAny() - if (w != null) w.funNullableT() - if (w != null) w.funNullableAny() - if (w != null) w - if (this.w != null) w.equals(null) - if (this.w != null) w.propT - if (this.w != null) w.propAny - if (this.w != null) w.propNullableT - if (this.w != null) w.propNullableAny - if (this.w != null) w.funT() - if (this.w != null) w.funAny() - if (this.w != null) w.funNullableT() - if (this.w != null) w.funNullableAny() - if (this.w != null) w - if (w != null || this.w != null) w.equals(null) - if (w != null || this.w != null) w.propT - if (w != null || this.w != null) w.propAny - if (w != null || this.w != null) w.propNullableT - if (w != null || this.w != null) w.propNullableAny - if (w != null || this.w != null) w.funT() - if (w != null || this.w != null) w.funAny() - if (w != null || this.w != null) w.funNullableT() - if (w != null || this.w != null) w.funNullableAny() - if (w != null || this.w != null) w + w + if (w != null) w.equals(null) + if (w != null) w.propT + if (w != null) w.propAny + if (w != null) w.propNullableT + if (w != null) w.propNullableAny + if (w != null) w.funT() + if (w != null) w.funAny() + if (w != null) w.funNullableT() + if (w != null) w.funNullableAny() + if (w != null) w + if (this.w != null) w.equals(null) + if (this.w != null) w.propT + if (this.w != null) w.propAny + if (this.w != null) w.propNullableT + if (this.w != null) w.propNullableAny + if (this.w != null) w.funT() + if (this.w != null) w.funAny() + if (this.w != null) w.funNullableT() + if (this.w != null) w.funNullableAny() + if (this.w != null) w + if (w != null || this.w != null) w.equals(null) + if (w != null || this.w != null) w.propT + if (w != null || this.w != null) w.propAny + if (w != null || this.w != null) w.propNullableT + if (w != null || this.w != null) w.propNullableAny + if (w != null || this.w != null) w.funT() + if (w != null || this.w != null) w.funAny() + if (w != null || this.w != null) w.funNullableT() + if (w != null || this.w != null) w.funNullableAny() + if (w != null || this.w != null) w if (w != null || this.w != null) this.w.equals(null) if (w != null || this.w != null) this.w.propT if (w != null || this.w != null) this.w.propAny @@ -1304,232 +1304,232 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: s = null s.hashCode() s - if (s != null) s - if (this.s != null) s - if (s != null || this.s != null) s + if (s != null) s + if (this.s != null) s + if (s != null || this.s != null) s if (s != null || this.s != null) this.s } fun test() { - if (b != null) b.equals(null) - if (b != null) b.propT - if (b != null) b.propAny - if (b != null) b.propNullableT - if (b != null) b.propNullableAny - if (b != null) b.funT() - if (b != null) b.funAny() - if (b != null) b.funNullableT() - if (b != null) b.funNullableAny() - if (b != null) b + if (b != null) b.equals(null) + if (b != null) b.propT + if (b != null) b.propAny + if (b != null) b.propNullableT + if (b != null) b.propNullableAny + if (b != null) b.funT() + if (b != null) b.funAny() + if (b != null) b.funNullableT() + if (b != null) b.funNullableAny() + if (b != null) b - if (c != null) c.equals(null) + if (c != null) c.equals(null) - if (c != null) c.propT + if (c != null) c.propT - if (c != null) c.propAny + if (c != null) c.propAny - if (c != null) c.propNullableT + if (c != null) c.propNullableT - if (c != null) c.propNullableAny + if (c != null) c.propNullableAny - if (c != null) c.funT() + if (c != null) c.funT() - if (c != null) c.funAny() + if (c != null) c.funAny() - if (c != null) c.funNullableT() + if (c != null) c.funNullableT() - if (c != null) c.funNullableAny() - if (c != null) c + if (c != null) c.funNullableAny() + if (c != null) c - if (d != null) d.equals(null) + if (d != null) d.equals(null) - if (d != null) d.propT + if (d != null) d.propT - if (d != null) d.propAny + if (d != null) d.propAny - if (d != null) d.propNullableT + if (d != null) d.propNullableT - if (d != null) d.propNullableAny + if (d != null) d.propNullableAny - if (d != null) d.funT() + if (d != null) d.funT() - if (d != null) d.funAny() + if (d != null) d.funAny() - if (d != null) d.funNullableT() + if (d != null) d.funNullableT() - if (d != null) d.funNullableAny() - if (d != null) d + if (d != null) d.funNullableAny() + if (d != null) d - if (e != null) e.equals(null) + if (e != null) e.equals(null) - if (e != null) e.propT + if (e != null) e.propT - if (e != null) e.propAny + if (e != null) e.propAny - if (e != null) e.propNullableT + if (e != null) e.propNullableT - if (e != null) e.propNullableAny + if (e != null) e.propNullableAny - if (e != null) e.funT() + if (e != null) e.funT() - if (e != null) e.funAny() + if (e != null) e.funAny() - if (e != null) e.funNullableT() + if (e != null) e.funNullableT() - if (e != null) e.funNullableAny() - if (e != null) e + if (e != null) e.funNullableAny() + if (e != null) e - if (f != null) f.equals(null) + if (f != null) f.equals(null) - if (f != null) f.propT + if (f != null) f.propT - if (f != null) f.propAny + if (f != null) f.propAny - if (f != null) f.propNullableT + if (f != null) f.propNullableT - if (f != null) f.propNullableAny + if (f != null) f.propNullableAny - if (f != null) f.funT() + if (f != null) f.funT() - if (f != null) f.funAny() + if (f != null) f.funAny() - if (f != null) f.funNullableT() + if (f != null) f.funNullableT() - if (f != null) f.funNullableAny() - if (f != null) f + if (f != null) f.funNullableAny() + if (f != null) f - if (x != null) x.equals(null) + if (x != null) x.equals(null) - if (x != null) x.propT + if (x != null) x.propT - if (x != null) x.propAny + if (x != null) x.propAny - if (x != null) x.propNullableT + if (x != null) x.propNullableT - if (x != null) x.propNullableAny + if (x != null) x.propNullableAny - if (x != null) x.funT() + if (x != null) x.funT() - if (x != null) x.funAny() + if (x != null) x.funAny() - if (x != null) x.funNullableT() + if (x != null) x.funNullableT() - if (x != null) x.funNullableAny() - if (x != null) x + if (x != null) x.funNullableAny() + if (x != null) x - if (y != null) y.equals(null) + if (y != null) y.equals(null) - if (y != null) y.propT + if (y != null) y.propT - if (y != null) y.propAny + if (y != null) y.propAny - if (y != null) y.propNullableT + if (y != null) y.propNullableT - if (y != null) y.propNullableAny + if (y != null) y.propNullableAny - if (y != null) y.funT() + if (y != null) y.funT() - if (y != null) y.funAny() + if (y != null) y.funAny() - if (y != null) y.funNullableT() + if (y != null) y.funNullableT() - if (y != null) y.funNullableAny() - if (y != null) y + if (y != null) y.funNullableAny() + if (y != null) y - if (z != null) z.equals(null) + if (z != null) z.equals(null) - if (z != null) z.propT + if (z != null) z.propT - if (z != null) z.propAny + if (z != null) z.propAny - if (z != null) z.propNullableT + if (z != null) z.propNullableT - if (z != null) z.propNullableAny + if (z != null) z.propNullableAny - if (z != null) z.funT() + if (z != null) z.funT() - if (z != null) z.funAny() + if (z != null) z.funAny() - if (z != null) z.funNullableT() + if (z != null) z.funNullableT() - if (z != null) z.funNullableAny() - if (z != null) z + if (z != null) z.funNullableAny() + if (z != null) z - if (u != null) u.equals(null) + if (u != null) u.equals(null) - if (u != null) u.propT + if (u != null) u.propT - if (u != null) u.propAny + if (u != null) u.propAny - if (u != null) u.propNullableT + if (u != null) u.propNullableT - if (u != null) u.propNullableAny + if (u != null) u.propNullableAny - if (u != null) u.funT() + if (u != null) u.funT() - if (u != null) u.funAny() + if (u != null) u.funAny() - if (u != null) u.funNullableT() + if (u != null) u.funNullableT() - if (u != null) u.funNullableAny() - if (u != null) u + if (u != null) u.funNullableAny() + if (u != null) u - if (v != null) v.equals(null) + if (v != null) v.equals(null) - if (v != null) v.propT + if (v != null) v.propT - if (v != null) v.propAny + if (v != null) v.propAny - if (v != null) v.propNullableT + if (v != null) v.propNullableT - if (v != null) v.propNullableAny + if (v != null) v.propNullableAny - if (v != null) v.funT() + if (v != null) v.funT() - if (v != null) v.funAny() + if (v != null) v.funAny() - if (v != null) v.funNullableT() + if (v != null) v.funNullableT() - if (v != null) v.funNullableAny() - if (v != null) v + if (v != null) v.funNullableAny() + if (v != null) v - if (w != null) w.equals(null) + if (w != null) w.equals(null) - if (w != null) w.propT + if (w != null) w.propT - if (w != null) w.propAny + if (w != null) w.propAny - if (w != null) w.propNullableT + if (w != null) w.propNullableT - if (w != null) w.propNullableAny + if (w != null) w.propNullableAny - if (w != null) w.funT() + if (w != null) w.funT() - if (w != null) w.funAny() + if (w != null) w.funAny() - if (w != null) w.funNullableT() + if (w != null) w.funNullableT() - if (w != null) w.funNullableAny() - if (w != null) w + if (w != null) w.funNullableAny() + if (w != null) w - if (s != null) s.equals(null) + if (s != null) s.equals(null) - if (s != null) s.propT + if (s != null) s.propT - if (s != null) s.propAny + if (s != null) s.propAny - if (s != null) s.propNullableT + if (s != null) s.propNullableT - if (s != null) s.propNullableAny + if (s != null) s.propNullableAny - if (s != null) s.funT() + if (s != null) s.funT() - if (s != null) s.funAny() + if (s != null) s.funAny() - if (s != null) s.funNullableT() + if (s != null) s.funNullableT() - if (s != null) s.funNullableAny() - if (s != null) s + if (s != null) s.funNullableAny() + if (s != null) s } } @@ -1618,35 +1618,35 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val val t: String? = if (u != null) this.u else null init { - if (a != null) a.equals(null) - if (a != null) a.propT - if (a != null) a.propAny - if (a != null) a.propNullableT - if (a != null) a.propNullableAny - if (a != null) a.funT() - if (a != null) a.funAny() - if (a != null) a.funNullableT() - if (a != null) a.funNullableAny() - if (a != null) a + if (a != null) a.equals(null) + if (a != null) a.propT + if (a != null) a.propAny + if (a != null) a.propNullableT + if (a != null) a.propNullableAny + if (a != null) a.funT() + if (a != null) a.funAny() + if (a != null) a.funNullableT() + if (a != null) a.funNullableAny() + if (a != null) a - if (b != null) b.equals(null) + if (b != null) b.equals(null) - if (b != null) b.propT + if (b != null) b.propT - if (b != null) b.propAny + if (b != null) b.propAny - if (b != null) b.propNullableT + if (b != null) b.propNullableT - if (b != null) b.propNullableAny + if (b != null) b.propNullableAny - if (b != null) b.funT() + if (b != null) b.funT() - if (b != null) b.funAny() + if (b != null) b.funAny() - if (b != null) b.funNullableT() + if (b != null) b.funNullableT() - if (b != null) b.funNullableAny() - if (b != null) b + if (b != null) b.funNullableAny() + if (b != null) b if (this.b != null) this.b.equals(null) if (this.b != null) this.b.propT if (this.b != null) this.b.propAny @@ -1657,16 +1657,16 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (this.b != null) this.b.funNullableT() if (this.b != null) this.b.funNullableAny() if (this.b != null) this.b - if (this.b != null) b.equals(null) - if (this.b != null) b.propT - if (this.b != null) b.propAny - if (this.b != null) b.propNullableT - if (this.b != null) b.propNullableAny - if (this.b != null) b.funT() - if (this.b != null) b.funAny() - if (this.b != null) b.funNullableT() - if (this.b != null) b.funNullableAny() - if (this.b != null) b + if (this.b != null) b.equals(null) + if (this.b != null) b.propT + if (this.b != null) b.propAny + if (this.b != null) b.propNullableT + if (this.b != null) b.propNullableAny + if (this.b != null) b.funT() + if (this.b != null) b.funAny() + if (this.b != null) b.funNullableT() + if (this.b != null) b.funNullableAny() + if (this.b != null) b if (b != null) this.b.equals(null) if (b != null) this.b.propT if (b != null) this.b.propAny @@ -1677,16 +1677,16 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (b != null) this.b.funNullableT() if (b != null) this.b.funNullableAny() if (b != null) this.b - if (b != null || this.b != null) b.equals(null) - if (b != null || this.b != null) b.propT - if (b != null || this.b != null) b.propAny - if (b != null || this.b != null) b.propNullableT - if (b != null || this.b != null) b.propNullableAny - if (b != null || this.b != null) b.funT() - if (b != null || this.b != null) b.funAny() - if (b != null || this.b != null) b.funNullableT() - if (b != null || this.b != null) b.funNullableAny() - if (b != null || this.b != null) b + if (b != null || this.b != null) b.equals(null) + if (b != null || this.b != null) b.propT + if (b != null || this.b != null) b.propAny + if (b != null || this.b != null) b.propNullableT + if (b != null || this.b != null) b.propNullableAny + if (b != null || this.b != null) b.funT() + if (b != null || this.b != null) b.funAny() + if (b != null || this.b != null) b.funNullableT() + if (b != null || this.b != null) b.funNullableAny() + if (b != null || this.b != null) b if (b != null || this.b != null) this.b.equals(null) if (b != null || this.b != null) this.b.propT if (b != null || this.b != null) this.b.propAny @@ -1698,24 +1698,24 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (b != null || this.b != null) this.b.funNullableAny() if (b != null || this.b != null) this.b - if (c != null) c.equals(null) + if (c != null) c.equals(null) - if (c != null) c.propT + if (c != null) c.propT - if (c != null) c.propAny + if (c != null) c.propAny - if (c != null) c.propNullableT + if (c != null) c.propNullableT - if (c != null) c.propNullableAny + if (c != null) c.propNullableAny - if (c != null) c.funT() + if (c != null) c.funT() - if (c != null) c.funAny() + if (c != null) c.funAny() - if (c != null) c.funNullableT() + if (c != null) c.funNullableT() - if (c != null) c.funNullableAny() - if (c != null) c + if (c != null) c.funNullableAny() + if (c != null) c if (this.c != null) this.c.equals(null) if (this.c != null) this.c.propT if (this.c != null) this.c.propAny @@ -1736,26 +1736,26 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (c != null) this.c.funNullableT() if (c != null) this.c.funNullableAny() if (c != null) this.c - if (this.c != null) c.equals(null) - if (this.c != null) c.propT - if (this.c != null) c.propAny - if (this.c != null) c.propNullableT - if (this.c != null) c.propNullableAny - if (this.c != null) c.funT() - if (this.c != null) c.funAny() - if (this.c != null) c.funNullableT() - if (this.c != null) c.funNullableAny() - if (this.c != null) c - if (c != null || this.c != null) c.equals(null) - if (c != null || this.c != null) c.propT - if (c != null || this.c != null) c.propAny - if (c != null || this.c != null) c.propNullableT - if (c != null || this.c != null) c.propNullableAny - if (c != null || this.c != null) c.funT() - if (c != null || this.c != null) c.funAny() - if (c != null || this.c != null) c.funNullableT() - if (c != null || this.c != null) c.funNullableAny() - if (c != null || this.c != null) c + if (this.c != null) c.equals(null) + if (this.c != null) c.propT + if (this.c != null) c.propAny + if (this.c != null) c.propNullableT + if (this.c != null) c.propNullableAny + if (this.c != null) c.funT() + if (this.c != null) c.funAny() + if (this.c != null) c.funNullableT() + if (this.c != null) c.funNullableAny() + if (this.c != null) c + if (c != null || this.c != null) c.equals(null) + if (c != null || this.c != null) c.propT + if (c != null || this.c != null) c.propAny + if (c != null || this.c != null) c.propNullableT + if (c != null || this.c != null) c.propNullableAny + if (c != null || this.c != null) c.funT() + if (c != null || this.c != null) c.funAny() + if (c != null || this.c != null) c.funNullableT() + if (c != null || this.c != null) c.funNullableAny() + if (c != null || this.c != null) c if (c != null || this.c != null) this.c.equals(null) if (c != null || this.c != null) this.c.propT if (c != null || this.c != null) this.c.propAny @@ -1767,24 +1767,24 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (c != null || this.c != null) this.c.funNullableAny() if (c != null || this.c != null) this.c - if (d != null) d.equals(null) + if (d != null) d.equals(null) - if (d != null) d.propT + if (d != null) d.propT - if (d != null) d.propAny + if (d != null) d.propAny - if (d != null) d.propNullableT + if (d != null) d.propNullableT - if (d != null) d.propNullableAny + if (d != null) d.propNullableAny - if (d != null) d.funT() + if (d != null) d.funT() - if (d != null) d.funAny() + if (d != null) d.funAny() - if (d != null) d.funNullableT() + if (d != null) d.funNullableT() - if (d != null) d.funNullableAny() - if (d != null) d + if (d != null) d.funNullableAny() + if (d != null) d if (this.d != null) this.d.equals(null) if (this.d != null) this.d.propT if (this.d != null) this.d.propAny @@ -1805,26 +1805,26 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (d != null) this.d.funNullableT() if (d != null) this.d.funNullableAny() if (d != null) this.d - if (this.d != null) d.equals(null) - if (this.d != null) d.propT - if (this.d != null) d.propAny - if (this.d != null) d.propNullableT - if (this.d != null) d.propNullableAny - if (this.d != null) d.funT() - if (this.d != null) d.funAny() - if (this.d != null) d.funNullableT() - if (this.d != null) d.funNullableAny() - if (this.d != null) d - if (d != null || this.d != null) d.equals(null) - if (d != null || this.d != null) d.propT - if (d != null || this.d != null) d.propAny - if (d != null || this.d != null) d.propNullableT - if (d != null || this.d != null) d.propNullableAny - if (d != null || this.d != null) d.funT() - if (d != null || this.d != null) d.funAny() - if (d != null || this.d != null) d.funNullableT() - if (d != null || this.d != null) d.funNullableAny() - if (d != null || this.d != null) d + if (this.d != null) d.equals(null) + if (this.d != null) d.propT + if (this.d != null) d.propAny + if (this.d != null) d.propNullableT + if (this.d != null) d.propNullableAny + if (this.d != null) d.funT() + if (this.d != null) d.funAny() + if (this.d != null) d.funNullableT() + if (this.d != null) d.funNullableAny() + if (this.d != null) d + if (d != null || this.d != null) d.equals(null) + if (d != null || this.d != null) d.propT + if (d != null || this.d != null) d.propAny + if (d != null || this.d != null) d.propNullableT + if (d != null || this.d != null) d.propNullableAny + if (d != null || this.d != null) d.funT() + if (d != null || this.d != null) d.funAny() + if (d != null || this.d != null) d.funNullableT() + if (d != null || this.d != null) d.funNullableAny() + if (d != null || this.d != null) d if (d != null || this.d != null) this.d.equals(null) if (d != null || this.d != null) this.d.propT if (d != null || this.d != null) this.d.propAny @@ -1836,24 +1836,24 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (d != null || this.d != null) this.d.funNullableAny() if (d != null || this.d != null) this.d - if (e != null) e.equals(null) + if (e != null) e.equals(null) - if (e != null) e.propT + if (e != null) e.propT - if (e != null) e.propAny + if (e != null) e.propAny - if (e != null) e.propNullableT + if (e != null) e.propNullableT - if (e != null) e.propNullableAny + if (e != null) e.propNullableAny - if (e != null) e.funT() + if (e != null) e.funT() - if (e != null) e.funAny() + if (e != null) e.funAny() - if (e != null) e.funNullableT() + if (e != null) e.funNullableT() - if (e != null) e.funNullableAny() - if (e != null) e + if (e != null) e.funNullableAny() + if (e != null) e if (this.e != null) this.e.equals(null) if (this.e != null) this.e.propT if (this.e != null) this.e.propAny @@ -1864,16 +1864,16 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (this.e != null) this.e.funNullableT() if (this.e != null) this.e.funNullableAny() if (this.e != null) this.e - if (this.e != null) e.equals(null) - if (this.e != null) e.propT - if (this.e != null) e.propAny - if (this.e != null) e.propNullableT - if (this.e != null) e.propNullableAny - if (this.e != null) e.funT() - if (this.e != null) e.funAny() - if (this.e != null) e.funNullableT() - if (this.e != null) e.funNullableAny() - if (this.e != null) e + if (this.e != null) e.equals(null) + if (this.e != null) e.propT + if (this.e != null) e.propAny + if (this.e != null) e.propNullableT + if (this.e != null) e.propNullableAny + if (this.e != null) e.funT() + if (this.e != null) e.funAny() + if (this.e != null) e.funNullableT() + if (this.e != null) e.funNullableAny() + if (this.e != null) e if (e != null) this.e.equals(null) if (e != null) this.e.propT if (e != null) this.e.propAny @@ -1884,16 +1884,16 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (e != null) this.e.funNullableT() if (e != null) this.e.funNullableAny() if (e != null) this.e - if (e != null || this.e != null) e.equals(null) - if (e != null || this.e != null) e.propT - if (e != null || this.e != null) e.propAny - if (e != null || this.e != null) e.propNullableT - if (e != null || this.e != null) e.propNullableAny - if (e != null || this.e != null) e.funT() - if (e != null || this.e != null) e.funAny() - if (e != null || this.e != null) e.funNullableT() - if (e != null || this.e != null) e.funNullableAny() - if (e != null || this.e != null) e + if (e != null || this.e != null) e.equals(null) + if (e != null || this.e != null) e.propT + if (e != null || this.e != null) e.propAny + if (e != null || this.e != null) e.propNullableT + if (e != null || this.e != null) e.propNullableAny + if (e != null || this.e != null) e.funT() + if (e != null || this.e != null) e.funAny() + if (e != null || this.e != null) e.funNullableT() + if (e != null || this.e != null) e.funNullableAny() + if (e != null || this.e != null) e if (e != null || this.e != null) this.e.equals(null) if (e != null || this.e != null) this.e.propT if (e != null || this.e != null) this.e.propAny @@ -1905,24 +1905,24 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (e != null || this.e != null) this.e.funNullableAny() if (e != null || this.e != null) this.e - if (f != null) f.equals(null) + if (f != null) f.equals(null) - if (f != null) f.propT + if (f != null) f.propT - if (f != null) f.propAny + if (f != null) f.propAny - if (f != null) f.propNullableT + if (f != null) f.propNullableT - if (f != null) f.propNullableAny + if (f != null) f.propNullableAny - if (f != null) f.funT() + if (f != null) f.funT() - if (f != null) f.funAny() + if (f != null) f.funAny() - if (f != null) f.funNullableT() + if (f != null) f.funNullableT() - if (f != null) f.funNullableAny() - if (f != null) f + if (f != null) f.funNullableAny() + if (f != null) f if (this.f != null) this.f.equals(null) if (this.f != null) this.f.propT if (this.f != null) this.f.propAny @@ -1933,16 +1933,16 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (this.f != null) this.f.funNullableT() if (this.f != null) this.f.funNullableAny() if (this.f != null) this.f - if (this.f != null) f.equals(null) - if (this.f != null) f.propT - if (this.f != null) f.propAny - if (this.f != null) f.propNullableT - if (this.f != null) f.propNullableAny - if (this.f != null) f.funT() - if (this.f != null) f.funAny() - if (this.f != null) f.funNullableT() - if (this.f != null) f.funNullableAny() - if (this.f != null) f + if (this.f != null) f.equals(null) + if (this.f != null) f.propT + if (this.f != null) f.propAny + if (this.f != null) f.propNullableT + if (this.f != null) f.propNullableAny + if (this.f != null) f.funT() + if (this.f != null) f.funAny() + if (this.f != null) f.funNullableT() + if (this.f != null) f.funNullableAny() + if (this.f != null) f if (f != null) this.f.equals(null) if (f != null) this.f.propT if (f != null) this.f.propAny @@ -1953,16 +1953,16 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (f != null) this.f.funNullableT() if (f != null) this.f.funNullableAny() if (f != null) this.f - if (f != null || this.f != null) f.equals(null) - if (f != null || this.f != null) f.propT - if (f != null || this.f != null) f.propAny - if (f != null || this.f != null) f.propNullableT - if (f != null || this.f != null) f.propNullableAny - if (f != null || this.f != null) f.funT() - if (f != null || this.f != null) f.funAny() - if (f != null || this.f != null) f.funNullableT() - if (f != null || this.f != null) f.funNullableAny() - if (f != null || this.f != null) f + if (f != null || this.f != null) f.equals(null) + if (f != null || this.f != null) f.propT + if (f != null || this.f != null) f.propAny + if (f != null || this.f != null) f.propNullableT + if (f != null || this.f != null) f.propNullableAny + if (f != null || this.f != null) f.funT() + if (f != null || this.f != null) f.funAny() + if (f != null || this.f != null) f.funNullableT() + if (f != null || this.f != null) f.funNullableAny() + if (f != null || this.f != null) f if (f != null || this.f != null) this.f.equals(null) if (f != null || this.f != null) this.f.propT if (f != null || this.f != null) this.f.propAny @@ -1974,24 +1974,24 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (f != null || this.f != null) this.f.funNullableAny() if (f != null || this.f != null) this.f - if (x != null) x.equals(null) + if (x != null) x.equals(null) - if (x != null) x.propT + if (x != null) x.propT - if (x != null) x.propAny + if (x != null) x.propAny - if (x != null) x.propNullableT + if (x != null) x.propNullableT - if (x != null) x.propNullableAny + if (x != null) x.propNullableAny - if (x != null) x.funT() + if (x != null) x.funT() - if (x != null) x.funAny() + if (x != null) x.funAny() - if (x != null) x.funNullableT() + if (x != null) x.funNullableT() - if (x != null) x.funNullableAny() - if (x != null) x + if (x != null) x.funNullableAny() + if (x != null) x if (this.x != null) this.x.equals(null) if (this.x != null) this.x.propT if (this.x != null) this.x.propAny @@ -2012,26 +2012,26 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (x != null) this.x.funNullableT() if (x != null) this.x.funNullableAny() if (x != null) this.x - if (this.x != null) x.equals(null) - if (this.x != null) x.propT - if (this.x != null) x.propAny - if (this.x != null) x.propNullableT - if (this.x != null) x.propNullableAny - if (this.x != null) x.funT() - if (this.x != null) x.funAny() - if (this.x != null) x.funNullableT() - if (this.x != null) x.funNullableAny() - if (this.x != null) x - if (x != null || this.x != null) x.equals(null) - if (x != null || this.x != null) x.propT - if (x != null || this.x != null) x.propAny - if (x != null || this.x != null) x.propNullableT - if (x != null || this.x != null) x.propNullableAny - if (x != null || this.x != null) x.funT() - if (x != null || this.x != null) x.funAny() - if (x != null || this.x != null) x.funNullableT() - if (x != null || this.x != null) x.funNullableAny() - if (x != null || this.x != null) x + if (this.x != null) x.equals(null) + if (this.x != null) x.propT + if (this.x != null) x.propAny + if (this.x != null) x.propNullableT + if (this.x != null) x.propNullableAny + if (this.x != null) x.funT() + if (this.x != null) x.funAny() + if (this.x != null) x.funNullableT() + if (this.x != null) x.funNullableAny() + if (this.x != null) x + if (x != null || this.x != null) x.equals(null) + if (x != null || this.x != null) x.propT + if (x != null || this.x != null) x.propAny + if (x != null || this.x != null) x.propNullableT + if (x != null || this.x != null) x.propNullableAny + if (x != null || this.x != null) x.funT() + if (x != null || this.x != null) x.funAny() + if (x != null || this.x != null) x.funNullableT() + if (x != null || this.x != null) x.funNullableAny() + if (x != null || this.x != null) x if (x != null || this.x != null) this.x.equals(null) if (x != null || this.x != null) this.x.propT if (x != null || this.x != null) this.x.propAny @@ -2043,24 +2043,24 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (x != null || this.x != null) this.x.funNullableAny() if (x != null || this.x != null) this.x - if (y != null) y.equals(null) + if (y != null) y.equals(null) - if (y != null) y.propT + if (y != null) y.propT - if (y != null) y.propAny + if (y != null) y.propAny - if (y != null) y.propNullableT + if (y != null) y.propNullableT - if (y != null) y.propNullableAny + if (y != null) y.propNullableAny - if (y != null) y.funT() + if (y != null) y.funT() - if (y != null) y.funAny() + if (y != null) y.funAny() - if (y != null) y.funNullableT() + if (y != null) y.funNullableT() - if (y != null) y.funNullableAny() - if (y != null) y + if (y != null) y.funNullableAny() + if (y != null) y if (this.y != null) this.y.equals(null) if (this.y != null) this.y.propT if (this.y != null) this.y.propAny @@ -2071,16 +2071,16 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (this.y != null) this.y.funNullableT() if (this.y != null) this.y.funNullableAny() if (this.y != null) this.y - if (this.y != null) y.equals(null) - if (this.y != null) y.propT - if (this.y != null) y.propAny - if (this.y != null) y.propNullableT - if (this.y != null) y.propNullableAny - if (this.y != null) y.funT() - if (this.y != null) y.funAny() - if (this.y != null) y.funNullableT() - if (this.y != null) y.funNullableAny() - if (this.y != null) y + if (this.y != null) y.equals(null) + if (this.y != null) y.propT + if (this.y != null) y.propAny + if (this.y != null) y.propNullableT + if (this.y != null) y.propNullableAny + if (this.y != null) y.funT() + if (this.y != null) y.funAny() + if (this.y != null) y.funNullableT() + if (this.y != null) y.funNullableAny() + if (this.y != null) y if (y != null) this.y.equals(null) if (y != null) this.y.propT if (y != null) this.y.propAny @@ -2091,16 +2091,16 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (y != null) this.y.funNullableT() if (y != null) this.y.funNullableAny() if (y != null) this.y - if (y != null || this.y != null) y.equals(null) - if (y != null || this.y != null) y.propT - if (y != null || this.y != null) y.propAny - if (y != null || this.y != null) y.propNullableT - if (y != null || this.y != null) y.propNullableAny - if (y != null || this.y != null) y.funT() - if (y != null || this.y != null) y.funAny() - if (y != null || this.y != null) y.funNullableT() - if (y != null || this.y != null) y.funNullableAny() - if (y != null || this.y != null) y + if (y != null || this.y != null) y.equals(null) + if (y != null || this.y != null) y.propT + if (y != null || this.y != null) y.propAny + if (y != null || this.y != null) y.propNullableT + if (y != null || this.y != null) y.propNullableAny + if (y != null || this.y != null) y.funT() + if (y != null || this.y != null) y.funAny() + if (y != null || this.y != null) y.funNullableT() + if (y != null || this.y != null) y.funNullableAny() + if (y != null || this.y != null) y if (y != null || this.y != null) this.y.equals(null) if (y != null || this.y != null) this.y.propT if (y != null || this.y != null) this.y.propAny @@ -2112,24 +2112,24 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (y != null || this.y != null) this.y.funNullableAny() if (y != null || this.y != null) this.y - if (z != null) z.equals(null) + if (z != null) z.equals(null) - if (z != null) z.propT + if (z != null) z.propT - if (z != null) z.propAny + if (z != null) z.propAny - if (z != null) z.propNullableT + if (z != null) z.propNullableT - if (z != null) z.propNullableAny + if (z != null) z.propNullableAny - if (z != null) z.funT() + if (z != null) z.funT() - if (z != null) z.funAny() + if (z != null) z.funAny() - if (z != null) z.funNullableT() + if (z != null) z.funNullableT() - if (z != null) z.funNullableAny() - if (z != null) z + if (z != null) z.funNullableAny() + if (z != null) z if (this.z != null) this.z.equals(null) if (this.z != null) this.z.propT if (this.z != null) this.z.propAny @@ -2150,26 +2150,26 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (z != null) this.z.funNullableT() if (z != null) this.z.funNullableAny() if (z != null) this.z - if (this.z != null) z.equals(null) - if (this.z != null) z.propT - if (this.z != null) z.propAny - if (this.z != null) z.propNullableT - if (this.z != null) z.propNullableAny - if (this.z != null) z.funT() - if (this.z != null) z.funAny() - if (this.z != null) z.funNullableT() - if (this.z != null) z.funNullableAny() - if (this.z != null) z - if (z != null || this.z != null) z.equals(null) - if (z != null || this.z != null) z.propT - if (z != null || this.z != null) z.propAny - if (z != null || this.z != null) z.propNullableT - if (z != null || this.z != null) z.propNullableAny - if (z != null || this.z != null) z.funT() - if (z != null || this.z != null) z.funAny() - if (z != null || this.z != null) z.funNullableT() - if (z != null || this.z != null) z.funNullableAny() - if (z != null || this.z != null) z + if (this.z != null) z.equals(null) + if (this.z != null) z.propT + if (this.z != null) z.propAny + if (this.z != null) z.propNullableT + if (this.z != null) z.propNullableAny + if (this.z != null) z.funT() + if (this.z != null) z.funAny() + if (this.z != null) z.funNullableT() + if (this.z != null) z.funNullableAny() + if (this.z != null) z + if (z != null || this.z != null) z.equals(null) + if (z != null || this.z != null) z.propT + if (z != null || this.z != null) z.propAny + if (z != null || this.z != null) z.propNullableT + if (z != null || this.z != null) z.propNullableAny + if (z != null || this.z != null) z.funT() + if (z != null || this.z != null) z.funAny() + if (z != null || this.z != null) z.funNullableT() + if (z != null || this.z != null) z.funNullableAny() + if (z != null || this.z != null) z if (z != null || this.z != null) this.z.equals(null) if (z != null || this.z != null) this.z.propT if (z != null || this.z != null) this.z.propAny @@ -2181,24 +2181,24 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (z != null || this.z != null) this.z.funNullableAny() if (z != null || this.z != null) this.z - if (u != null) u.equals(null) + if (u != null) u.equals(null) - if (u != null) u.propT + if (u != null) u.propT - if (u != null) u.propAny + if (u != null) u.propAny - if (u != null) u.propNullableT + if (u != null) u.propNullableT - if (u != null) u.propNullableAny + if (u != null) u.propNullableAny - if (u != null) u.funT() + if (u != null) u.funT() - if (u != null) u.funAny() + if (u != null) u.funAny() - if (u != null) u.funNullableT() + if (u != null) u.funNullableT() - if (u != null) u.funNullableAny() - if (u != null) u + if (u != null) u.funNullableAny() + if (u != null) u if (this.u != null) this.u.equals(null) if (this.u != null) this.u.propT if (this.u != null) this.u.propAny @@ -2209,16 +2209,16 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (this.u != null) this.u.funNullableT() if (this.u != null) this.u.funNullableAny() if (this.u != null) this.u - if (this.u != null) u.equals(null) - if (this.u != null) u.propT - if (this.u != null) u.propAny - if (this.u != null) u.propNullableT - if (this.u != null) u.propNullableAny - if (this.u != null) u.funT() - if (this.u != null) u.funAny() - if (this.u != null) u.funNullableT() - if (this.u != null) u.funNullableAny() - if (this.u != null) u + if (this.u != null) u.equals(null) + if (this.u != null) u.propT + if (this.u != null) u.propAny + if (this.u != null) u.propNullableT + if (this.u != null) u.propNullableAny + if (this.u != null) u.funT() + if (this.u != null) u.funAny() + if (this.u != null) u.funNullableT() + if (this.u != null) u.funNullableAny() + if (this.u != null) u if (u != null) this.u.equals(null) if (u != null) this.u.propT if (u != null) this.u.propAny @@ -2229,16 +2229,16 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (u != null) this.u.funNullableT() if (u != null) this.u.funNullableAny() if (u != null) this.u - if (u != null || this.u != null) u.equals(null) - if (u != null || this.u != null) u.propT - if (u != null || this.u != null) u.propAny - if (u != null || this.u != null) u.propNullableT - if (u != null || this.u != null) u.propNullableAny - if (u != null || this.u != null) u.funT() - if (u != null || this.u != null) u.funAny() - if (u != null || this.u != null) u.funNullableT() - if (u != null || this.u != null) u.funNullableAny() - if (u != null || this.u != null) u + if (u != null || this.u != null) u.equals(null) + if (u != null || this.u != null) u.propT + if (u != null || this.u != null) u.propAny + if (u != null || this.u != null) u.propNullableT + if (u != null || this.u != null) u.propNullableAny + if (u != null || this.u != null) u.funT() + if (u != null || this.u != null) u.funAny() + if (u != null || this.u != null) u.funNullableT() + if (u != null || this.u != null) u.funNullableAny() + if (u != null || this.u != null) u if (u != null || this.u != null) this.u.equals(null) if (u != null || this.u != null) this.u.propT if (u != null || this.u != null) this.u.propAny @@ -2251,46 +2251,46 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (u != null || this.u != null) this.u v = 0 - v.equals(null) - v.propT - v.propAny - v.propNullableT - v.propNullableAny - v.funT() - v.funAny() - v.funNullableT() - v.funNullableAny() - v - if (v != null) v.equals(null) - if (v != null) v.propT - if (v != null) v.propAny - if (v != null) v.propNullableT - if (v != null) v.propNullableAny - if (v != null) v.funT() - if (v != null) v.funAny() - if (v != null) v.funNullableT() - if (v != null) v.funNullableAny() - if (v != null) v - if (this.v != null) v.equals(null) - if (this.v != null) v.propT - if (this.v != null) v.propAny - if (this.v != null) v.propNullableT - if (this.v != null) v.propNullableAny - if (this.v != null) v.funT() - if (this.v != null) v.funAny() - if (this.v != null) v.funNullableT() - if (this.v != null) v.funNullableAny() - if (this.v != null) v - if (v != null || this.v != null) v.equals(null) - if (v != null || this.v != null) v.propT - if (v != null || this.v != null) v.propAny - if (v != null || this.v != null) v.propNullableT - if (v != null || this.v != null) v.propNullableAny - if (v != null || this.v != null) v.funT() - if (v != null || this.v != null) v.funAny() - if (v != null || this.v != null) v.funNullableT() - if (v != null || this.v != null) v.funNullableAny() - if (v != null || this.v != null) v + v.equals(null) + v.propT + v.propAny + v.propNullableT + v.propNullableAny + v.funT() + v.funAny() + v.funNullableT() + v.funNullableAny() + v + if (v != null) v.equals(null) + if (v != null) v.propT + if (v != null) v.propAny + if (v != null) v.propNullableT + if (v != null) v.propNullableAny + if (v != null) v.funT() + if (v != null) v.funAny() + if (v != null) v.funNullableT() + if (v != null) v.funNullableAny() + if (v != null) v + if (this.v != null) v.equals(null) + if (this.v != null) v.propT + if (this.v != null) v.propAny + if (this.v != null) v.propNullableT + if (this.v != null) v.propNullableAny + if (this.v != null) v.funT() + if (this.v != null) v.funAny() + if (this.v != null) v.funNullableT() + if (this.v != null) v.funNullableAny() + if (this.v != null) v + if (v != null || this.v != null) v.equals(null) + if (v != null || this.v != null) v.propT + if (v != null || this.v != null) v.propAny + if (v != null || this.v != null) v.propNullableT + if (v != null || this.v != null) v.propNullableAny + if (v != null || this.v != null) v.funT() + if (v != null || this.v != null) v.funAny() + if (v != null || this.v != null) v.funNullableT() + if (v != null || this.v != null) v.funNullableAny() + if (v != null || this.v != null) v if (v != null || this.v != null) this.v.equals(null) if (v != null || this.v != null) this.v.propT if (v != null || this.v != null) this.v.propAny @@ -2303,37 +2303,37 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (v != null || this.v != null) this.v w = if (null != null) 10 else null - w - if (w != null) w.equals(null) - if (w != null) w.propT - if (w != null) w.propAny - if (w != null) w.propNullableT - if (w != null) w.propNullableAny - if (w != null) w.funT() - if (w != null) w.funAny() - if (w != null) w.funNullableT() - if (w != null) w.funNullableAny() - if (w != null) w - if (this.w != null) w.equals(null) - if (this.w != null) w.propT - if (this.w != null) w.propAny - if (this.w != null) w.propNullableT - if (this.w != null) w.propNullableAny - if (this.w != null) w.funT() - if (this.w != null) w.funAny() - if (this.w != null) w.funNullableT() - if (this.w != null) w.funNullableAny() - if (this.w != null) w - if (w != null || this.w != null) w.equals(null) - if (w != null || this.w != null) w.propT - if (w != null || this.w != null) w.propAny - if (w != null || this.w != null) w.propNullableT - if (w != null || this.w != null) w.propNullableAny - if (w != null || this.w != null) w.funT() - if (w != null || this.w != null) w.funAny() - if (w != null || this.w != null) w.funNullableT() - if (w != null || this.w != null) w.funNullableAny() - if (w != null || this.w != null) w + w + if (w != null) w.equals(null) + if (w != null) w.propT + if (w != null) w.propAny + if (w != null) w.propNullableT + if (w != null) w.propNullableAny + if (w != null) w.funT() + if (w != null) w.funAny() + if (w != null) w.funNullableT() + if (w != null) w.funNullableAny() + if (w != null) w + if (this.w != null) w.equals(null) + if (this.w != null) w.propT + if (this.w != null) w.propAny + if (this.w != null) w.propNullableT + if (this.w != null) w.propNullableAny + if (this.w != null) w.funT() + if (this.w != null) w.funAny() + if (this.w != null) w.funNullableT() + if (this.w != null) w.funNullableAny() + if (this.w != null) w + if (w != null || this.w != null) w.equals(null) + if (w != null || this.w != null) w.propT + if (w != null || this.w != null) w.propAny + if (w != null || this.w != null) w.propNullableT + if (w != null || this.w != null) w.propNullableAny + if (w != null || this.w != null) w.funT() + if (w != null || this.w != null) w.funAny() + if (w != null || this.w != null) w.funNullableT() + if (w != null || this.w != null) w.funNullableAny() + if (w != null || this.w != null) w if (w != null || this.w != null) this.w.equals(null) if (w != null || this.w != null) this.w.propT if (w != null || this.w != null) this.w.propAny @@ -2348,232 +2348,232 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val s = null s.hashCode() s - if (s != null) s - if (this.s != null) s - if (s != null || this.s != null) s + if (s != null) s + if (this.s != null) s + if (s != null || this.s != null) s if (s != null || this.s != null) this.s } fun test() { - if (b != null) b.equals(null) - if (b != null) b.propT - if (b != null) b.propAny - if (b != null) b.propNullableT - if (b != null) b.propNullableAny - if (b != null) b.funT() - if (b != null) b.funAny() - if (b != null) b.funNullableT() - if (b != null) b.funNullableAny() - if (b != null) b + if (b != null) b.equals(null) + if (b != null) b.propT + if (b != null) b.propAny + if (b != null) b.propNullableT + if (b != null) b.propNullableAny + if (b != null) b.funT() + if (b != null) b.funAny() + if (b != null) b.funNullableT() + if (b != null) b.funNullableAny() + if (b != null) b - if (c != null) c.equals(null) + if (c != null) c.equals(null) - if (c != null) c.propT + if (c != null) c.propT - if (c != null) c.propAny + if (c != null) c.propAny - if (c != null) c.propNullableT + if (c != null) c.propNullableT - if (c != null) c.propNullableAny + if (c != null) c.propNullableAny - if (c != null) c.funT() + if (c != null) c.funT() - if (c != null) c.funAny() + if (c != null) c.funAny() - if (c != null) c.funNullableT() + if (c != null) c.funNullableT() - if (c != null) c.funNullableAny() - if (c != null) c + if (c != null) c.funNullableAny() + if (c != null) c - if (d != null) d.equals(null) + if (d != null) d.equals(null) - if (d != null) d.propT + if (d != null) d.propT - if (d != null) d.propAny + if (d != null) d.propAny - if (d != null) d.propNullableT + if (d != null) d.propNullableT - if (d != null) d.propNullableAny + if (d != null) d.propNullableAny - if (d != null) d.funT() + if (d != null) d.funT() - if (d != null) d.funAny() + if (d != null) d.funAny() - if (d != null) d.funNullableT() + if (d != null) d.funNullableT() - if (d != null) d.funNullableAny() - if (d != null) d + if (d != null) d.funNullableAny() + if (d != null) d - if (e != null) e.equals(null) + if (e != null) e.equals(null) - if (e != null) e.propT + if (e != null) e.propT - if (e != null) e.propAny + if (e != null) e.propAny - if (e != null) e.propNullableT + if (e != null) e.propNullableT - if (e != null) e.propNullableAny + if (e != null) e.propNullableAny - if (e != null) e.funT() + if (e != null) e.funT() - if (e != null) e.funAny() + if (e != null) e.funAny() - if (e != null) e.funNullableT() + if (e != null) e.funNullableT() - if (e != null) e.funNullableAny() - if (e != null) e + if (e != null) e.funNullableAny() + if (e != null) e - if (f != null) f.equals(null) + if (f != null) f.equals(null) - if (f != null) f.propT + if (f != null) f.propT - if (f != null) f.propAny + if (f != null) f.propAny - if (f != null) f.propNullableT + if (f != null) f.propNullableT - if (f != null) f.propNullableAny + if (f != null) f.propNullableAny - if (f != null) f.funT() + if (f != null) f.funT() - if (f != null) f.funAny() + if (f != null) f.funAny() - if (f != null) f.funNullableT() + if (f != null) f.funNullableT() - if (f != null) f.funNullableAny() - if (f != null) f + if (f != null) f.funNullableAny() + if (f != null) f - if (x != null) x.equals(null) + if (x != null) x.equals(null) - if (x != null) x.propT + if (x != null) x.propT - if (x != null) x.propAny + if (x != null) x.propAny - if (x != null) x.propNullableT + if (x != null) x.propNullableT - if (x != null) x.propNullableAny + if (x != null) x.propNullableAny - if (x != null) x.funT() + if (x != null) x.funT() - if (x != null) x.funAny() + if (x != null) x.funAny() - if (x != null) x.funNullableT() + if (x != null) x.funNullableT() - if (x != null) x.funNullableAny() - if (x != null) x + if (x != null) x.funNullableAny() + if (x != null) x - if (y != null) y.equals(null) + if (y != null) y.equals(null) - if (y != null) y.propT + if (y != null) y.propT - if (y != null) y.propAny + if (y != null) y.propAny - if (y != null) y.propNullableT + if (y != null) y.propNullableT - if (y != null) y.propNullableAny + if (y != null) y.propNullableAny - if (y != null) y.funT() + if (y != null) y.funT() - if (y != null) y.funAny() + if (y != null) y.funAny() - if (y != null) y.funNullableT() + if (y != null) y.funNullableT() - if (y != null) y.funNullableAny() - if (y != null) y + if (y != null) y.funNullableAny() + if (y != null) y - if (z != null) z.equals(null) + if (z != null) z.equals(null) - if (z != null) z.propT + if (z != null) z.propT - if (z != null) z.propAny + if (z != null) z.propAny - if (z != null) z.propNullableT + if (z != null) z.propNullableT - if (z != null) z.propNullableAny + if (z != null) z.propNullableAny - if (z != null) z.funT() + if (z != null) z.funT() - if (z != null) z.funAny() + if (z != null) z.funAny() - if (z != null) z.funNullableT() + if (z != null) z.funNullableT() - if (z != null) z.funNullableAny() - if (z != null) z + if (z != null) z.funNullableAny() + if (z != null) z - if (u != null) u.equals(null) + if (u != null) u.equals(null) - if (u != null) u.propT + if (u != null) u.propT - if (u != null) u.propAny + if (u != null) u.propAny - if (u != null) u.propNullableT + if (u != null) u.propNullableT - if (u != null) u.propNullableAny + if (u != null) u.propNullableAny - if (u != null) u.funT() + if (u != null) u.funT() - if (u != null) u.funAny() + if (u != null) u.funAny() - if (u != null) u.funNullableT() + if (u != null) u.funNullableT() - if (u != null) u.funNullableAny() - if (u != null) u + if (u != null) u.funNullableAny() + if (u != null) u - if (v != null) v.equals(null) + if (v != null) v.equals(null) - if (v != null) v.propT + if (v != null) v.propT - if (v != null) v.propAny + if (v != null) v.propAny - if (v != null) v.propNullableT + if (v != null) v.propNullableT - if (v != null) v.propNullableAny + if (v != null) v.propNullableAny - if (v != null) v.funT() + if (v != null) v.funT() - if (v != null) v.funAny() + if (v != null) v.funAny() - if (v != null) v.funNullableT() + if (v != null) v.funNullableT() - if (v != null) v.funNullableAny() - if (v != null) v + if (v != null) v.funNullableAny() + if (v != null) v - if (w != null) w.equals(null) + if (w != null) w.equals(null) - if (w != null) w.propT + if (w != null) w.propT - if (w != null) w.propAny + if (w != null) w.propAny - if (w != null) w.propNullableT + if (w != null) w.propNullableT - if (w != null) w.propNullableAny + if (w != null) w.propNullableAny - if (w != null) w.funT() + if (w != null) w.funT() - if (w != null) w.funAny() + if (w != null) w.funAny() - if (w != null) w.funNullableT() + if (w != null) w.funNullableT() - if (w != null) w.funNullableAny() - if (w != null) w + if (w != null) w.funNullableAny() + if (w != null) w - if (s != null) s.equals(null) + if (s != null) s.equals(null) - if (s != null) s.propT + if (s != null) s.propT - if (s != null) s.propAny + if (s != null) s.propAny - if (s != null) s.propNullableT + if (s != null) s.propNullableT - if (s != null) s.propNullableAny + if (s != null) s.propNullableAny - if (s != null) s.funT() + if (s != null) s.funT() - if (s != null) s.funAny() + if (s != null) s.funAny() - if (s != null) s.funNullableT() + if (s != null) s.funNullableT() - if (s != null) s.funNullableAny() - if (s != null) s + if (s != null) s.funNullableAny() + if (s != null) s } } @@ -2664,35 +2664,35 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: val t: String? = if (u != null) this.u else null init { - if (a != null) a.equals(null) - if (a != null) a.propT - if (a != null) a.propAny - if (a != null) a.propNullableT - if (a != null) a.propNullableAny - if (a != null) a.funT() - if (a != null) a.funAny() - if (a != null) a.funNullableT() - if (a != null) a.funNullableAny() - if (a != null) a + if (a != null) a.equals(null) + if (a != null) a.propT + if (a != null) a.propAny + if (a != null) a.propNullableT + if (a != null) a.propNullableAny + if (a != null) a.funT() + if (a != null) a.funAny() + if (a != null) a.funNullableT() + if (a != null) a.funNullableAny() + if (a != null) a - if (b != null) b.equals(null) + if (b != null) b.equals(null) - if (b != null) b.propT + if (b != null) b.propT - if (b != null) b.propAny + if (b != null) b.propAny - if (b != null) b.propNullableT + if (b != null) b.propNullableT - if (b != null) b.propNullableAny + if (b != null) b.propNullableAny - if (b != null) b.funT() + if (b != null) b.funT() - if (b != null) b.funAny() + if (b != null) b.funAny() - if (b != null) b.funNullableT() + if (b != null) b.funNullableT() - if (b != null) b.funNullableAny() - if (b != null) b + if (b != null) b.funNullableAny() + if (b != null) b if (this.b != null) this.b.equals(null) if (this.b != null) this.b.propT if (this.b != null) this.b.propAny @@ -2703,16 +2703,16 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (this.b != null) this.b.funNullableT() if (this.b != null) this.b.funNullableAny() if (this.b != null) this.b - if (this.b != null) b.equals(null) - if (this.b != null) b.propT - if (this.b != null) b.propAny - if (this.b != null) b.propNullableT - if (this.b != null) b.propNullableAny - if (this.b != null) b.funT() - if (this.b != null) b.funAny() - if (this.b != null) b.funNullableT() - if (this.b != null) b.funNullableAny() - if (this.b != null) b + if (this.b != null) b.equals(null) + if (this.b != null) b.propT + if (this.b != null) b.propAny + if (this.b != null) b.propNullableT + if (this.b != null) b.propNullableAny + if (this.b != null) b.funT() + if (this.b != null) b.funAny() + if (this.b != null) b.funNullableT() + if (this.b != null) b.funNullableAny() + if (this.b != null) b if (b != null) this.b.equals(null) if (b != null) this.b.propT if (b != null) this.b.propAny @@ -2723,16 +2723,16 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (b != null) this.b.funNullableT() if (b != null) this.b.funNullableAny() if (b != null) this.b - if (b != null || this.b != null) b.equals(null) - if (b != null || this.b != null) b.propT - if (b != null || this.b != null) b.propAny - if (b != null || this.b != null) b.propNullableT - if (b != null || this.b != null) b.propNullableAny - if (b != null || this.b != null) b.funT() - if (b != null || this.b != null) b.funAny() - if (b != null || this.b != null) b.funNullableT() - if (b != null || this.b != null) b.funNullableAny() - if (b != null || this.b != null) b + if (b != null || this.b != null) b.equals(null) + if (b != null || this.b != null) b.propT + if (b != null || this.b != null) b.propAny + if (b != null || this.b != null) b.propNullableT + if (b != null || this.b != null) b.propNullableAny + if (b != null || this.b != null) b.funT() + if (b != null || this.b != null) b.funAny() + if (b != null || this.b != null) b.funNullableT() + if (b != null || this.b != null) b.funNullableAny() + if (b != null || this.b != null) b if (b != null || this.b != null) this.b.equals(null) if (b != null || this.b != null) this.b.propT if (b != null || this.b != null) this.b.propAny @@ -2744,24 +2744,24 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (b != null || this.b != null) this.b.funNullableAny() if (b != null || this.b != null) this.b - if (c != null) c.equals(null) + if (c != null) c.equals(null) - if (c != null) c.propT + if (c != null) c.propT - if (c != null) c.propAny + if (c != null) c.propAny - if (c != null) c.propNullableT + if (c != null) c.propNullableT - if (c != null) c.propNullableAny + if (c != null) c.propNullableAny - if (c != null) c.funT() + if (c != null) c.funT() - if (c != null) c.funAny() + if (c != null) c.funAny() - if (c != null) c.funNullableT() + if (c != null) c.funNullableT() - if (c != null) c.funNullableAny() - if (c != null) c + if (c != null) c.funNullableAny() + if (c != null) c if (this.c != null) this.c.equals(null) if (this.c != null) this.c.propT if (this.c != null) this.c.propAny @@ -2782,26 +2782,26 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (c != null) this.c.funNullableT() if (c != null) this.c.funNullableAny() if (c != null) this.c - if (this.c != null) c.equals(null) - if (this.c != null) c.propT - if (this.c != null) c.propAny - if (this.c != null) c.propNullableT - if (this.c != null) c.propNullableAny - if (this.c != null) c.funT() - if (this.c != null) c.funAny() - if (this.c != null) c.funNullableT() - if (this.c != null) c.funNullableAny() - if (this.c != null) c - if (c != null || this.c != null) c.equals(null) - if (c != null || this.c != null) c.propT - if (c != null || this.c != null) c.propAny - if (c != null || this.c != null) c.propNullableT - if (c != null || this.c != null) c.propNullableAny - if (c != null || this.c != null) c.funT() - if (c != null || this.c != null) c.funAny() - if (c != null || this.c != null) c.funNullableT() - if (c != null || this.c != null) c.funNullableAny() - if (c != null || this.c != null) c + if (this.c != null) c.equals(null) + if (this.c != null) c.propT + if (this.c != null) c.propAny + if (this.c != null) c.propNullableT + if (this.c != null) c.propNullableAny + if (this.c != null) c.funT() + if (this.c != null) c.funAny() + if (this.c != null) c.funNullableT() + if (this.c != null) c.funNullableAny() + if (this.c != null) c + if (c != null || this.c != null) c.equals(null) + if (c != null || this.c != null) c.propT + if (c != null || this.c != null) c.propAny + if (c != null || this.c != null) c.propNullableT + if (c != null || this.c != null) c.propNullableAny + if (c != null || this.c != null) c.funT() + if (c != null || this.c != null) c.funAny() + if (c != null || this.c != null) c.funNullableT() + if (c != null || this.c != null) c.funNullableAny() + if (c != null || this.c != null) c if (c != null || this.c != null) this.c.equals(null) if (c != null || this.c != null) this.c.propT if (c != null || this.c != null) this.c.propAny @@ -2813,24 +2813,24 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (c != null || this.c != null) this.c.funNullableAny() if (c != null || this.c != null) this.c - if (d != null) d.equals(null) + if (d != null) d.equals(null) - if (d != null) d.propT + if (d != null) d.propT - if (d != null) d.propAny + if (d != null) d.propAny - if (d != null) d.propNullableT + if (d != null) d.propNullableT - if (d != null) d.propNullableAny + if (d != null) d.propNullableAny - if (d != null) d.funT() + if (d != null) d.funT() - if (d != null) d.funAny() + if (d != null) d.funAny() - if (d != null) d.funNullableT() + if (d != null) d.funNullableT() - if (d != null) d.funNullableAny() - if (d != null) d + if (d != null) d.funNullableAny() + if (d != null) d if (this.d != null) this.d.equals(null) if (this.d != null) this.d.propT if (this.d != null) this.d.propAny @@ -2851,26 +2851,26 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (d != null) this.d.funNullableT() if (d != null) this.d.funNullableAny() if (d != null) this.d - if (this.d != null) d.equals(null) - if (this.d != null) d.propT - if (this.d != null) d.propAny - if (this.d != null) d.propNullableT - if (this.d != null) d.propNullableAny - if (this.d != null) d.funT() - if (this.d != null) d.funAny() - if (this.d != null) d.funNullableT() - if (this.d != null) d.funNullableAny() - if (this.d != null) d - if (d != null || this.d != null) d.equals(null) - if (d != null || this.d != null) d.propT - if (d != null || this.d != null) d.propAny - if (d != null || this.d != null) d.propNullableT - if (d != null || this.d != null) d.propNullableAny - if (d != null || this.d != null) d.funT() - if (d != null || this.d != null) d.funAny() - if (d != null || this.d != null) d.funNullableT() - if (d != null || this.d != null) d.funNullableAny() - if (d != null || this.d != null) d + if (this.d != null) d.equals(null) + if (this.d != null) d.propT + if (this.d != null) d.propAny + if (this.d != null) d.propNullableT + if (this.d != null) d.propNullableAny + if (this.d != null) d.funT() + if (this.d != null) d.funAny() + if (this.d != null) d.funNullableT() + if (this.d != null) d.funNullableAny() + if (this.d != null) d + if (d != null || this.d != null) d.equals(null) + if (d != null || this.d != null) d.propT + if (d != null || this.d != null) d.propAny + if (d != null || this.d != null) d.propNullableT + if (d != null || this.d != null) d.propNullableAny + if (d != null || this.d != null) d.funT() + if (d != null || this.d != null) d.funAny() + if (d != null || this.d != null) d.funNullableT() + if (d != null || this.d != null) d.funNullableAny() + if (d != null || this.d != null) d if (d != null || this.d != null) this.d.equals(null) if (d != null || this.d != null) this.d.propT if (d != null || this.d != null) this.d.propAny @@ -2882,24 +2882,24 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (d != null || this.d != null) this.d.funNullableAny() if (d != null || this.d != null) this.d - if (e != null) e.equals(null) + if (e != null) e.equals(null) - if (e != null) e.propT + if (e != null) e.propT - if (e != null) e.propAny + if (e != null) e.propAny - if (e != null) e.propNullableT + if (e != null) e.propNullableT - if (e != null) e.propNullableAny + if (e != null) e.propNullableAny - if (e != null) e.funT() + if (e != null) e.funT() - if (e != null) e.funAny() + if (e != null) e.funAny() - if (e != null) e.funNullableT() + if (e != null) e.funNullableT() - if (e != null) e.funNullableAny() - if (e != null) e + if (e != null) e.funNullableAny() + if (e != null) e if (this.e != null) this.e.equals(null) if (this.e != null) this.e.propT if (this.e != null) this.e.propAny @@ -2910,16 +2910,16 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (this.e != null) this.e.funNullableT() if (this.e != null) this.e.funNullableAny() if (this.e != null) this.e - if (this.e != null) e.equals(null) - if (this.e != null) e.propT - if (this.e != null) e.propAny - if (this.e != null) e.propNullableT - if (this.e != null) e.propNullableAny - if (this.e != null) e.funT() - if (this.e != null) e.funAny() - if (this.e != null) e.funNullableT() - if (this.e != null) e.funNullableAny() - if (this.e != null) e + if (this.e != null) e.equals(null) + if (this.e != null) e.propT + if (this.e != null) e.propAny + if (this.e != null) e.propNullableT + if (this.e != null) e.propNullableAny + if (this.e != null) e.funT() + if (this.e != null) e.funAny() + if (this.e != null) e.funNullableT() + if (this.e != null) e.funNullableAny() + if (this.e != null) e if (e != null) this.e.equals(null) if (e != null) this.e.propT if (e != null) this.e.propAny @@ -2930,16 +2930,16 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (e != null) this.e.funNullableT() if (e != null) this.e.funNullableAny() if (e != null) this.e - if (e != null || this.e != null) e.equals(null) - if (e != null || this.e != null) e.propT - if (e != null || this.e != null) e.propAny - if (e != null || this.e != null) e.propNullableT - if (e != null || this.e != null) e.propNullableAny - if (e != null || this.e != null) e.funT() - if (e != null || this.e != null) e.funAny() - if (e != null || this.e != null) e.funNullableT() - if (e != null || this.e != null) e.funNullableAny() - if (e != null || this.e != null) e + if (e != null || this.e != null) e.equals(null) + if (e != null || this.e != null) e.propT + if (e != null || this.e != null) e.propAny + if (e != null || this.e != null) e.propNullableT + if (e != null || this.e != null) e.propNullableAny + if (e != null || this.e != null) e.funT() + if (e != null || this.e != null) e.funAny() + if (e != null || this.e != null) e.funNullableT() + if (e != null || this.e != null) e.funNullableAny() + if (e != null || this.e != null) e if (e != null || this.e != null) this.e.equals(null) if (e != null || this.e != null) this.e.propT if (e != null || this.e != null) this.e.propAny @@ -2951,24 +2951,24 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (e != null || this.e != null) this.e.funNullableAny() if (e != null || this.e != null) this.e - if (f != null) f.equals(null) + if (f != null) f.equals(null) - if (f != null) f.propT + if (f != null) f.propT - if (f != null) f.propAny + if (f != null) f.propAny - if (f != null) f.propNullableT + if (f != null) f.propNullableT - if (f != null) f.propNullableAny + if (f != null) f.propNullableAny - if (f != null) f.funT() + if (f != null) f.funT() - if (f != null) f.funAny() + if (f != null) f.funAny() - if (f != null) f.funNullableT() + if (f != null) f.funNullableT() - if (f != null) f.funNullableAny() - if (f != null) f + if (f != null) f.funNullableAny() + if (f != null) f if (this.f != null) this.f.equals(null) if (this.f != null) this.f.propT if (this.f != null) this.f.propAny @@ -2979,16 +2979,16 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (this.f != null) this.f.funNullableT() if (this.f != null) this.f.funNullableAny() if (this.f != null) this.f - if (this.f != null) f.equals(null) - if (this.f != null) f.propT - if (this.f != null) f.propAny - if (this.f != null) f.propNullableT - if (this.f != null) f.propNullableAny - if (this.f != null) f.funT() - if (this.f != null) f.funAny() - if (this.f != null) f.funNullableT() - if (this.f != null) f.funNullableAny() - if (this.f != null) f + if (this.f != null) f.equals(null) + if (this.f != null) f.propT + if (this.f != null) f.propAny + if (this.f != null) f.propNullableT + if (this.f != null) f.propNullableAny + if (this.f != null) f.funT() + if (this.f != null) f.funAny() + if (this.f != null) f.funNullableT() + if (this.f != null) f.funNullableAny() + if (this.f != null) f if (f != null) this.f.equals(null) if (f != null) this.f.propT if (f != null) this.f.propAny @@ -2999,16 +2999,16 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (f != null) this.f.funNullableT() if (f != null) this.f.funNullableAny() if (f != null) this.f - if (f != null || this.f != null) f.equals(null) - if (f != null || this.f != null) f.propT - if (f != null || this.f != null) f.propAny - if (f != null || this.f != null) f.propNullableT - if (f != null || this.f != null) f.propNullableAny - if (f != null || this.f != null) f.funT() - if (f != null || this.f != null) f.funAny() - if (f != null || this.f != null) f.funNullableT() - if (f != null || this.f != null) f.funNullableAny() - if (f != null || this.f != null) f + if (f != null || this.f != null) f.equals(null) + if (f != null || this.f != null) f.propT + if (f != null || this.f != null) f.propAny + if (f != null || this.f != null) f.propNullableT + if (f != null || this.f != null) f.propNullableAny + if (f != null || this.f != null) f.funT() + if (f != null || this.f != null) f.funAny() + if (f != null || this.f != null) f.funNullableT() + if (f != null || this.f != null) f.funNullableAny() + if (f != null || this.f != null) f if (f != null || this.f != null) this.f.equals(null) if (f != null || this.f != null) this.f.propT if (f != null || this.f != null) this.f.propAny @@ -3020,24 +3020,24 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (f != null || this.f != null) this.f.funNullableAny() if (f != null || this.f != null) this.f - if (x != null) x.equals(null) + if (x != null) x.equals(null) - if (x != null) x.propT + if (x != null) x.propT - if (x != null) x.propAny + if (x != null) x.propAny - if (x != null) x.propNullableT + if (x != null) x.propNullableT - if (x != null) x.propNullableAny + if (x != null) x.propNullableAny - if (x != null) x.funT() + if (x != null) x.funT() - if (x != null) x.funAny() + if (x != null) x.funAny() - if (x != null) x.funNullableT() + if (x != null) x.funNullableT() - if (x != null) x.funNullableAny() - if (x != null) x + if (x != null) x.funNullableAny() + if (x != null) x if (this.x != null) this.x.equals(null) if (this.x != null) this.x.propT if (this.x != null) this.x.propAny @@ -3058,26 +3058,26 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (x != null) this.x.funNullableT() if (x != null) this.x.funNullableAny() if (x != null) this.x - if (this.x != null) x.equals(null) - if (this.x != null) x.propT - if (this.x != null) x.propAny - if (this.x != null) x.propNullableT - if (this.x != null) x.propNullableAny - if (this.x != null) x.funT() - if (this.x != null) x.funAny() - if (this.x != null) x.funNullableT() - if (this.x != null) x.funNullableAny() - if (this.x != null) x - if (x != null || this.x != null) x.equals(null) - if (x != null || this.x != null) x.propT - if (x != null || this.x != null) x.propAny - if (x != null || this.x != null) x.propNullableT - if (x != null || this.x != null) x.propNullableAny - if (x != null || this.x != null) x.funT() - if (x != null || this.x != null) x.funAny() - if (x != null || this.x != null) x.funNullableT() - if (x != null || this.x != null) x.funNullableAny() - if (x != null || this.x != null) x + if (this.x != null) x.equals(null) + if (this.x != null) x.propT + if (this.x != null) x.propAny + if (this.x != null) x.propNullableT + if (this.x != null) x.propNullableAny + if (this.x != null) x.funT() + if (this.x != null) x.funAny() + if (this.x != null) x.funNullableT() + if (this.x != null) x.funNullableAny() + if (this.x != null) x + if (x != null || this.x != null) x.equals(null) + if (x != null || this.x != null) x.propT + if (x != null || this.x != null) x.propAny + if (x != null || this.x != null) x.propNullableT + if (x != null || this.x != null) x.propNullableAny + if (x != null || this.x != null) x.funT() + if (x != null || this.x != null) x.funAny() + if (x != null || this.x != null) x.funNullableT() + if (x != null || this.x != null) x.funNullableAny() + if (x != null || this.x != null) x if (x != null || this.x != null) this.x.equals(null) if (x != null || this.x != null) this.x.propT if (x != null || this.x != null) this.x.propAny @@ -3089,24 +3089,24 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (x != null || this.x != null) this.x.funNullableAny() if (x != null || this.x != null) this.x - if (y != null) y.equals(null) + if (y != null) y.equals(null) - if (y != null) y.propT + if (y != null) y.propT - if (y != null) y.propAny + if (y != null) y.propAny - if (y != null) y.propNullableT + if (y != null) y.propNullableT - if (y != null) y.propNullableAny + if (y != null) y.propNullableAny - if (y != null) y.funT() + if (y != null) y.funT() - if (y != null) y.funAny() + if (y != null) y.funAny() - if (y != null) y.funNullableT() + if (y != null) y.funNullableT() - if (y != null) y.funNullableAny() - if (y != null) y + if (y != null) y.funNullableAny() + if (y != null) y if (this.y != null) this.y.equals(null) if (this.y != null) this.y.propT if (this.y != null) this.y.propAny @@ -3117,16 +3117,16 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (this.y != null) this.y.funNullableT() if (this.y != null) this.y.funNullableAny() if (this.y != null) this.y - if (this.y != null) y.equals(null) - if (this.y != null) y.propT - if (this.y != null) y.propAny - if (this.y != null) y.propNullableT - if (this.y != null) y.propNullableAny - if (this.y != null) y.funT() - if (this.y != null) y.funAny() - if (this.y != null) y.funNullableT() - if (this.y != null) y.funNullableAny() - if (this.y != null) y + if (this.y != null) y.equals(null) + if (this.y != null) y.propT + if (this.y != null) y.propAny + if (this.y != null) y.propNullableT + if (this.y != null) y.propNullableAny + if (this.y != null) y.funT() + if (this.y != null) y.funAny() + if (this.y != null) y.funNullableT() + if (this.y != null) y.funNullableAny() + if (this.y != null) y if (y != null) this.y.equals(null) if (y != null) this.y.propT if (y != null) this.y.propAny @@ -3137,16 +3137,16 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (y != null) this.y.funNullableT() if (y != null) this.y.funNullableAny() if (y != null) this.y - if (y != null || this.y != null) y.equals(null) - if (y != null || this.y != null) y.propT - if (y != null || this.y != null) y.propAny - if (y != null || this.y != null) y.propNullableT - if (y != null || this.y != null) y.propNullableAny - if (y != null || this.y != null) y.funT() - if (y != null || this.y != null) y.funAny() - if (y != null || this.y != null) y.funNullableT() - if (y != null || this.y != null) y.funNullableAny() - if (y != null || this.y != null) y + if (y != null || this.y != null) y.equals(null) + if (y != null || this.y != null) y.propT + if (y != null || this.y != null) y.propAny + if (y != null || this.y != null) y.propNullableT + if (y != null || this.y != null) y.propNullableAny + if (y != null || this.y != null) y.funT() + if (y != null || this.y != null) y.funAny() + if (y != null || this.y != null) y.funNullableT() + if (y != null || this.y != null) y.funNullableAny() + if (y != null || this.y != null) y if (y != null || this.y != null) this.y.equals(null) if (y != null || this.y != null) this.y.propT if (y != null || this.y != null) this.y.propAny @@ -3158,24 +3158,24 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (y != null || this.y != null) this.y.funNullableAny() if (y != null || this.y != null) this.y - if (z != null) z.equals(null) + if (z != null) z.equals(null) - if (z != null) z.propT + if (z != null) z.propT - if (z != null) z.propAny + if (z != null) z.propAny - if (z != null) z.propNullableT + if (z != null) z.propNullableT - if (z != null) z.propNullableAny + if (z != null) z.propNullableAny - if (z != null) z.funT() + if (z != null) z.funT() - if (z != null) z.funAny() + if (z != null) z.funAny() - if (z != null) z.funNullableT() + if (z != null) z.funNullableT() - if (z != null) z.funNullableAny() - if (z != null) z + if (z != null) z.funNullableAny() + if (z != null) z if (this.z != null) this.z.equals(null) if (this.z != null) this.z.propT if (this.z != null) this.z.propAny @@ -3196,26 +3196,26 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (z != null) this.z.funNullableT() if (z != null) this.z.funNullableAny() if (z != null) this.z - if (this.z != null) z.equals(null) - if (this.z != null) z.propT - if (this.z != null) z.propAny - if (this.z != null) z.propNullableT - if (this.z != null) z.propNullableAny - if (this.z != null) z.funT() - if (this.z != null) z.funAny() - if (this.z != null) z.funNullableT() - if (this.z != null) z.funNullableAny() - if (this.z != null) z - if (z != null || this.z != null) z.equals(null) - if (z != null || this.z != null) z.propT - if (z != null || this.z != null) z.propAny - if (z != null || this.z != null) z.propNullableT - if (z != null || this.z != null) z.propNullableAny - if (z != null || this.z != null) z.funT() - if (z != null || this.z != null) z.funAny() - if (z != null || this.z != null) z.funNullableT() - if (z != null || this.z != null) z.funNullableAny() - if (z != null || this.z != null) z + if (this.z != null) z.equals(null) + if (this.z != null) z.propT + if (this.z != null) z.propAny + if (this.z != null) z.propNullableT + if (this.z != null) z.propNullableAny + if (this.z != null) z.funT() + if (this.z != null) z.funAny() + if (this.z != null) z.funNullableT() + if (this.z != null) z.funNullableAny() + if (this.z != null) z + if (z != null || this.z != null) z.equals(null) + if (z != null || this.z != null) z.propT + if (z != null || this.z != null) z.propAny + if (z != null || this.z != null) z.propNullableT + if (z != null || this.z != null) z.propNullableAny + if (z != null || this.z != null) z.funT() + if (z != null || this.z != null) z.funAny() + if (z != null || this.z != null) z.funNullableT() + if (z != null || this.z != null) z.funNullableAny() + if (z != null || this.z != null) z if (z != null || this.z != null) this.z.equals(null) if (z != null || this.z != null) this.z.propT if (z != null || this.z != null) this.z.propAny @@ -3227,24 +3227,24 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (z != null || this.z != null) this.z.funNullableAny() if (z != null || this.z != null) this.z - if (u != null) u.equals(null) + if (u != null) u.equals(null) - if (u != null) u.propT + if (u != null) u.propT - if (u != null) u.propAny + if (u != null) u.propAny - if (u != null) u.propNullableT + if (u != null) u.propNullableT - if (u != null) u.propNullableAny + if (u != null) u.propNullableAny - if (u != null) u.funT() + if (u != null) u.funT() - if (u != null) u.funAny() + if (u != null) u.funAny() - if (u != null) u.funNullableT() + if (u != null) u.funNullableT() - if (u != null) u.funNullableAny() - if (u != null) u + if (u != null) u.funNullableAny() + if (u != null) u if (this.u != null) this.u.equals(null) if (this.u != null) this.u.propT if (this.u != null) this.u.propAny @@ -3255,16 +3255,16 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (this.u != null) this.u.funNullableT() if (this.u != null) this.u.funNullableAny() if (this.u != null) this.u - if (this.u != null) u.equals(null) - if (this.u != null) u.propT - if (this.u != null) u.propAny - if (this.u != null) u.propNullableT - if (this.u != null) u.propNullableAny - if (this.u != null) u.funT() - if (this.u != null) u.funAny() - if (this.u != null) u.funNullableT() - if (this.u != null) u.funNullableAny() - if (this.u != null) u + if (this.u != null) u.equals(null) + if (this.u != null) u.propT + if (this.u != null) u.propAny + if (this.u != null) u.propNullableT + if (this.u != null) u.propNullableAny + if (this.u != null) u.funT() + if (this.u != null) u.funAny() + if (this.u != null) u.funNullableT() + if (this.u != null) u.funNullableAny() + if (this.u != null) u if (u != null) this.u.equals(null) if (u != null) this.u.propT if (u != null) this.u.propAny @@ -3275,16 +3275,16 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (u != null) this.u.funNullableT() if (u != null) this.u.funNullableAny() if (u != null) this.u - if (u != null || this.u != null) u.equals(null) - if (u != null || this.u != null) u.propT - if (u != null || this.u != null) u.propAny - if (u != null || this.u != null) u.propNullableT - if (u != null || this.u != null) u.propNullableAny - if (u != null || this.u != null) u.funT() - if (u != null || this.u != null) u.funAny() - if (u != null || this.u != null) u.funNullableT() - if (u != null || this.u != null) u.funNullableAny() - if (u != null || this.u != null) u + if (u != null || this.u != null) u.equals(null) + if (u != null || this.u != null) u.propT + if (u != null || this.u != null) u.propAny + if (u != null || this.u != null) u.propNullableT + if (u != null || this.u != null) u.propNullableAny + if (u != null || this.u != null) u.funT() + if (u != null || this.u != null) u.funAny() + if (u != null || this.u != null) u.funNullableT() + if (u != null || this.u != null) u.funNullableAny() + if (u != null || this.u != null) u if (u != null || this.u != null) this.u.equals(null) if (u != null || this.u != null) this.u.propT if (u != null || this.u != null) this.u.propAny @@ -3297,46 +3297,46 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (u != null || this.u != null) this.u v = 0 - v.equals(null) - v.propT - v.propAny - v.propNullableT - v.propNullableAny - v.funT() - v.funAny() - v.funNullableT() - v.funNullableAny() - v - if (v != null) v.equals(null) - if (v != null) v.propT - if (v != null) v.propAny - if (v != null) v.propNullableT - if (v != null) v.propNullableAny - if (v != null) v.funT() - if (v != null) v.funAny() - if (v != null) v.funNullableT() - if (v != null) v.funNullableAny() - if (v != null) v - if (this.v != null) v.equals(null) - if (this.v != null) v.propT - if (this.v != null) v.propAny - if (this.v != null) v.propNullableT - if (this.v != null) v.propNullableAny - if (this.v != null) v.funT() - if (this.v != null) v.funAny() - if (this.v != null) v.funNullableT() - if (this.v != null) v.funNullableAny() - if (this.v != null) v - if (v != null || this.v != null) v.equals(null) - if (v != null || this.v != null) v.propT - if (v != null || this.v != null) v.propAny - if (v != null || this.v != null) v.propNullableT - if (v != null || this.v != null) v.propNullableAny - if (v != null || this.v != null) v.funT() - if (v != null || this.v != null) v.funAny() - if (v != null || this.v != null) v.funNullableT() - if (v != null || this.v != null) v.funNullableAny() - if (v != null || this.v != null) v + v.equals(null) + v.propT + v.propAny + v.propNullableT + v.propNullableAny + v.funT() + v.funAny() + v.funNullableT() + v.funNullableAny() + v + if (v != null) v.equals(null) + if (v != null) v.propT + if (v != null) v.propAny + if (v != null) v.propNullableT + if (v != null) v.propNullableAny + if (v != null) v.funT() + if (v != null) v.funAny() + if (v != null) v.funNullableT() + if (v != null) v.funNullableAny() + if (v != null) v + if (this.v != null) v.equals(null) + if (this.v != null) v.propT + if (this.v != null) v.propAny + if (this.v != null) v.propNullableT + if (this.v != null) v.propNullableAny + if (this.v != null) v.funT() + if (this.v != null) v.funAny() + if (this.v != null) v.funNullableT() + if (this.v != null) v.funNullableAny() + if (this.v != null) v + if (v != null || this.v != null) v.equals(null) + if (v != null || this.v != null) v.propT + if (v != null || this.v != null) v.propAny + if (v != null || this.v != null) v.propNullableT + if (v != null || this.v != null) v.propNullableAny + if (v != null || this.v != null) v.funT() + if (v != null || this.v != null) v.funAny() + if (v != null || this.v != null) v.funNullableT() + if (v != null || this.v != null) v.funNullableAny() + if (v != null || this.v != null) v if (v != null || this.v != null) this.v.equals(null) if (v != null || this.v != null) this.v.propT if (v != null || this.v != null) this.v.propAny @@ -3349,36 +3349,36 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (v != null || this.v != null) this.v w = if (null != null) 10 else null - if (w != null) w.equals(null) - if (w != null) w.propT - if (w != null) w.propAny - if (w != null) w.propNullableT - if (w != null) w.propNullableAny - if (w != null) w.funT() - if (w != null) w.funAny() - if (w != null) w.funNullableT() - if (w != null) w.funNullableAny() - if (w != null) w - if (this.w != null) w.equals(null) - if (this.w != null) w.propT - if (this.w != null) w.propAny - if (this.w != null) w.propNullableT - if (this.w != null) w.propNullableAny - if (this.w != null) w.funT() - if (this.w != null) w.funAny() - if (this.w != null) w.funNullableT() - if (this.w != null) w.funNullableAny() - if (this.w != null) w - if (w != null || this.w != null) w.equals(null) - if (w != null || this.w != null) w.propT - if (w != null || this.w != null) w.propAny - if (w != null || this.w != null) w.propNullableT - if (w != null || this.w != null) w.propNullableAny - if (w != null || this.w != null) w.funT() - if (w != null || this.w != null) w.funAny() - if (w != null || this.w != null) w.funNullableT() - if (w != null || this.w != null) w.funNullableAny() - if (w != null || this.w != null) w + if (w != null) w.equals(null) + if (w != null) w.propT + if (w != null) w.propAny + if (w != null) w.propNullableT + if (w != null) w.propNullableAny + if (w != null) w.funT() + if (w != null) w.funAny() + if (w != null) w.funNullableT() + if (w != null) w.funNullableAny() + if (w != null) w + if (this.w != null) w.equals(null) + if (this.w != null) w.propT + if (this.w != null) w.propAny + if (this.w != null) w.propNullableT + if (this.w != null) w.propNullableAny + if (this.w != null) w.funT() + if (this.w != null) w.funAny() + if (this.w != null) w.funNullableT() + if (this.w != null) w.funNullableAny() + if (this.w != null) w + if (w != null || this.w != null) w.equals(null) + if (w != null || this.w != null) w.propT + if (w != null || this.w != null) w.propAny + if (w != null || this.w != null) w.propNullableT + if (w != null || this.w != null) w.propNullableAny + if (w != null || this.w != null) w.funT() + if (w != null || this.w != null) w.funAny() + if (w != null || this.w != null) w.funNullableT() + if (w != null || this.w != null) w.funNullableAny() + if (w != null || this.w != null) w if (w != null || this.w != null) this.w.equals(null) if (w != null || this.w != null) this.w.propT if (w != null || this.w != null) this.w.propAny @@ -3393,232 +3393,232 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: s = null s.hashCode() s - if (s != null) s - if (this.s != null) s - if (s != null || this.s != null) s + if (s != null) s + if (this.s != null) s + if (s != null || this.s != null) s if (s != null || this.s != null) this.s } fun test() { - if (b != null) b.equals(null) - if (b != null) b.propT - if (b != null) b.propAny - if (b != null) b.propNullableT - if (b != null) b.propNullableAny - if (b != null) b.funT() - if (b != null) b.funAny() - if (b != null) b.funNullableT() - if (b != null) b.funNullableAny() - if (b != null) b + if (b != null) b.equals(null) + if (b != null) b.propT + if (b != null) b.propAny + if (b != null) b.propNullableT + if (b != null) b.propNullableAny + if (b != null) b.funT() + if (b != null) b.funAny() + if (b != null) b.funNullableT() + if (b != null) b.funNullableAny() + if (b != null) b - if (c != null) c.equals(null) + if (c != null) c.equals(null) - if (c != null) c.propT + if (c != null) c.propT - if (c != null) c.propAny + if (c != null) c.propAny - if (c != null) c.propNullableT + if (c != null) c.propNullableT - if (c != null) c.propNullableAny + if (c != null) c.propNullableAny - if (c != null) c.funT() + if (c != null) c.funT() - if (c != null) c.funAny() + if (c != null) c.funAny() - if (c != null) c.funNullableT() + if (c != null) c.funNullableT() - if (c != null) c.funNullableAny() - if (c != null) c + if (c != null) c.funNullableAny() + if (c != null) c - if (d != null) d.equals(null) + if (d != null) d.equals(null) - if (d != null) d.propT + if (d != null) d.propT - if (d != null) d.propAny + if (d != null) d.propAny - if (d != null) d.propNullableT + if (d != null) d.propNullableT - if (d != null) d.propNullableAny + if (d != null) d.propNullableAny - if (d != null) d.funT() + if (d != null) d.funT() - if (d != null) d.funAny() + if (d != null) d.funAny() - if (d != null) d.funNullableT() + if (d != null) d.funNullableT() - if (d != null) d.funNullableAny() - if (d != null) d + if (d != null) d.funNullableAny() + if (d != null) d - if (e != null) e.equals(null) + if (e != null) e.equals(null) - if (e != null) e.propT + if (e != null) e.propT - if (e != null) e.propAny + if (e != null) e.propAny - if (e != null) e.propNullableT + if (e != null) e.propNullableT - if (e != null) e.propNullableAny + if (e != null) e.propNullableAny - if (e != null) e.funT() + if (e != null) e.funT() - if (e != null) e.funAny() + if (e != null) e.funAny() - if (e != null) e.funNullableT() + if (e != null) e.funNullableT() - if (e != null) e.funNullableAny() - if (e != null) e + if (e != null) e.funNullableAny() + if (e != null) e - if (f != null) f.equals(null) + if (f != null) f.equals(null) - if (f != null) f.propT + if (f != null) f.propT - if (f != null) f.propAny + if (f != null) f.propAny - if (f != null) f.propNullableT + if (f != null) f.propNullableT - if (f != null) f.propNullableAny + if (f != null) f.propNullableAny - if (f != null) f.funT() + if (f != null) f.funT() - if (f != null) f.funAny() + if (f != null) f.funAny() - if (f != null) f.funNullableT() + if (f != null) f.funNullableT() - if (f != null) f.funNullableAny() - if (f != null) f + if (f != null) f.funNullableAny() + if (f != null) f - if (x != null) x.equals(null) + if (x != null) x.equals(null) - if (x != null) x.propT + if (x != null) x.propT - if (x != null) x.propAny + if (x != null) x.propAny - if (x != null) x.propNullableT + if (x != null) x.propNullableT - if (x != null) x.propNullableAny + if (x != null) x.propNullableAny - if (x != null) x.funT() + if (x != null) x.funT() - if (x != null) x.funAny() + if (x != null) x.funAny() - if (x != null) x.funNullableT() + if (x != null) x.funNullableT() - if (x != null) x.funNullableAny() - if (x != null) x + if (x != null) x.funNullableAny() + if (x != null) x - if (y != null) y.equals(null) + if (y != null) y.equals(null) - if (y != null) y.propT + if (y != null) y.propT - if (y != null) y.propAny + if (y != null) y.propAny - if (y != null) y.propNullableT + if (y != null) y.propNullableT - if (y != null) y.propNullableAny + if (y != null) y.propNullableAny - if (y != null) y.funT() + if (y != null) y.funT() - if (y != null) y.funAny() + if (y != null) y.funAny() - if (y != null) y.funNullableT() + if (y != null) y.funNullableT() - if (y != null) y.funNullableAny() - if (y != null) y + if (y != null) y.funNullableAny() + if (y != null) y - if (z != null) z.equals(null) + if (z != null) z.equals(null) - if (z != null) z.propT + if (z != null) z.propT - if (z != null) z.propAny + if (z != null) z.propAny - if (z != null) z.propNullableT + if (z != null) z.propNullableT - if (z != null) z.propNullableAny + if (z != null) z.propNullableAny - if (z != null) z.funT() + if (z != null) z.funT() - if (z != null) z.funAny() + if (z != null) z.funAny() - if (z != null) z.funNullableT() + if (z != null) z.funNullableT() - if (z != null) z.funNullableAny() - if (z != null) z + if (z != null) z.funNullableAny() + if (z != null) z - if (u != null) u.equals(null) + if (u != null) u.equals(null) - if (u != null) u.propT + if (u != null) u.propT - if (u != null) u.propAny + if (u != null) u.propAny - if (u != null) u.propNullableT + if (u != null) u.propNullableT - if (u != null) u.propNullableAny + if (u != null) u.propNullableAny - if (u != null) u.funT() + if (u != null) u.funT() - if (u != null) u.funAny() + if (u != null) u.funAny() - if (u != null) u.funNullableT() + if (u != null) u.funNullableT() - if (u != null) u.funNullableAny() - if (u != null) u + if (u != null) u.funNullableAny() + if (u != null) u - if (v != null) v.equals(null) + if (v != null) v.equals(null) - if (v != null) v.propT + if (v != null) v.propT - if (v != null) v.propAny + if (v != null) v.propAny - if (v != null) v.propNullableT + if (v != null) v.propNullableT - if (v != null) v.propNullableAny + if (v != null) v.propNullableAny - if (v != null) v.funT() + if (v != null) v.funT() - if (v != null) v.funAny() + if (v != null) v.funAny() - if (v != null) v.funNullableT() + if (v != null) v.funNullableT() - if (v != null) v.funNullableAny() - if (v != null) v + if (v != null) v.funNullableAny() + if (v != null) v - if (w != null) w.equals(null) + if (w != null) w.equals(null) - if (w != null) w.propT + if (w != null) w.propT - if (w != null) w.propAny + if (w != null) w.propAny - if (w != null) w.propNullableT + if (w != null) w.propNullableT - if (w != null) w.propNullableAny + if (w != null) w.propNullableAny - if (w != null) w.funT() + if (w != null) w.funT() - if (w != null) w.funAny() + if (w != null) w.funAny() - if (w != null) w.funNullableT() + if (w != null) w.funNullableT() - if (w != null) w.funNullableAny() - if (w != null) w + if (w != null) w.funNullableAny() + if (w != null) w - if (s != null) s.equals(null) + if (s != null) s.equals(null) - if (s != null) s.propT + if (s != null) s.propT - if (s != null) s.propAny + if (s != null) s.propAny - if (s != null) s.propNullableT + if (s != null) s.propNullableT - if (s != null) s.propNullableAny + if (s != null) s.propNullableAny - if (s != null) s.funT() + if (s != null) s.funT() - if (s != null) s.funAny() + if (s != null) s.funAny() - if (s != null) s.funNullableT() + if (s != null) s.funNullableT() - if (s != null) s.funNullableAny() - if (s != null) s + if (s != null) s.funNullableAny() + if (s != null) s } } @@ -3745,16 +3745,16 @@ object Case32 { val t: String? = if (u != null) this.u else null init { - if (x != null) x.equals(null) - if (x != null) x.propT - if (x != null) x.propAny - if (x != null) x.propNullableT - if (x != null) x.propNullableAny - if (x != null) x.funT() - if (x != null) x.funAny() - if (x != null) x.funNullableT() - if (x != null) x.funNullableAny() - if (x != null) x + if (x != null) x.equals(null) + if (x != null) x.propT + if (x != null) x.propAny + if (x != null) x.propNullableT + if (x != null) x.propNullableAny + if (x != null) x.funT() + if (x != null) x.funAny() + if (x != null) x.funNullableT() + if (x != null) x.funNullableAny() + if (x != null) x if (this.x != null) this.x.equals(null) if (this.x != null) this.x.propT if (this.x != null) this.x.propAny @@ -3775,26 +3775,26 @@ object Case32 { if (x != null) this.x.funNullableT() if (x != null) this.x.funNullableAny() if (x != null) this.x - if (this.x != null) x.equals(null) - if (this.x != null) x.propT - if (this.x != null) x.propAny - if (this.x != null) x.propNullableT - if (this.x != null) x.propNullableAny - if (this.x != null) x.funT() - if (this.x != null) x.funAny() - if (this.x != null) x.funNullableT() - if (this.x != null) x.funNullableAny() - if (this.x != null) x - if (x != null || this.x != null) x.equals(null) - if (x != null || this.x != null) x.propT - if (x != null || this.x != null) x.propAny - if (x != null || this.x != null) x.propNullableT - if (x != null || this.x != null) x.propNullableAny - if (x != null || this.x != null) x.funT() - if (x != null || this.x != null) x.funAny() - if (x != null || this.x != null) x.funNullableT() - if (x != null || this.x != null) x.funNullableAny() - if (x != null || this.x != null) x + if (this.x != null) x.equals(null) + if (this.x != null) x.propT + if (this.x != null) x.propAny + if (this.x != null) x.propNullableT + if (this.x != null) x.propNullableAny + if (this.x != null) x.funT() + if (this.x != null) x.funAny() + if (this.x != null) x.funNullableT() + if (this.x != null) x.funNullableAny() + if (this.x != null) x + if (x != null || this.x != null) x.equals(null) + if (x != null || this.x != null) x.propT + if (x != null || this.x != null) x.propAny + if (x != null || this.x != null) x.propNullableT + if (x != null || this.x != null) x.propNullableAny + if (x != null || this.x != null) x.funT() + if (x != null || this.x != null) x.funAny() + if (x != null || this.x != null) x.funNullableT() + if (x != null || this.x != null) x.funNullableAny() + if (x != null || this.x != null) x if (x != null || this.x != null) this.x.equals(null) if (x != null || this.x != null) this.x.propT if (x != null || this.x != null) this.x.propAny @@ -3806,24 +3806,24 @@ object Case32 { if (x != null || this.x != null) this.x.funNullableAny() if (x != null || this.x != null) this.x - if (y != null) y.equals(null) + if (y != null) y.equals(null) - if (y != null) y.propT + if (y != null) y.propT - if (y != null) y.propAny + if (y != null) y.propAny - if (y != null) y.propNullableT + if (y != null) y.propNullableT - if (y != null) y.propNullableAny + if (y != null) y.propNullableAny - if (y != null) y.funT() + if (y != null) y.funT() - if (y != null) y.funAny() + if (y != null) y.funAny() - if (y != null) y.funNullableT() + if (y != null) y.funNullableT() - if (y != null) y.funNullableAny() - if (y != null) y + if (y != null) y.funNullableAny() + if (y != null) y if (this.y != null) this.y.equals(null) if (this.y != null) this.y.propT if (this.y != null) this.y.propAny @@ -3834,16 +3834,16 @@ object Case32 { if (this.y != null) this.y.funNullableT() if (this.y != null) this.y.funNullableAny() if (this.y != null) this.y - if (this.y != null) y.equals(null) - if (this.y != null) y.propT - if (this.y != null) y.propAny - if (this.y != null) y.propNullableT - if (this.y != null) y.propNullableAny - if (this.y != null) y.funT() - if (this.y != null) y.funAny() - if (this.y != null) y.funNullableT() - if (this.y != null) y.funNullableAny() - if (this.y != null) y + if (this.y != null) y.equals(null) + if (this.y != null) y.propT + if (this.y != null) y.propAny + if (this.y != null) y.propNullableT + if (this.y != null) y.propNullableAny + if (this.y != null) y.funT() + if (this.y != null) y.funAny() + if (this.y != null) y.funNullableT() + if (this.y != null) y.funNullableAny() + if (this.y != null) y if (y != null) this.y.equals(null) if (y != null) this.y.propT if (y != null) this.y.propAny @@ -3854,16 +3854,16 @@ object Case32 { if (y != null) this.y.funNullableT() if (y != null) this.y.funNullableAny() if (y != null) this.y - if (y != null || this.y != null) y.equals(null) - if (y != null || this.y != null) y.propT - if (y != null || this.y != null) y.propAny - if (y != null || this.y != null) y.propNullableT - if (y != null || this.y != null) y.propNullableAny - if (y != null || this.y != null) y.funT() - if (y != null || this.y != null) y.funAny() - if (y != null || this.y != null) y.funNullableT() - if (y != null || this.y != null) y.funNullableAny() - if (y != null || this.y != null) y + if (y != null || this.y != null) y.equals(null) + if (y != null || this.y != null) y.propT + if (y != null || this.y != null) y.propAny + if (y != null || this.y != null) y.propNullableT + if (y != null || this.y != null) y.propNullableAny + if (y != null || this.y != null) y.funT() + if (y != null || this.y != null) y.funAny() + if (y != null || this.y != null) y.funNullableT() + if (y != null || this.y != null) y.funNullableAny() + if (y != null || this.y != null) y if (y != null || this.y != null) this.y.equals(null) if (y != null || this.y != null) this.y.propT if (y != null || this.y != null) this.y.propAny @@ -3875,24 +3875,24 @@ object Case32 { if (y != null || this.y != null) this.y.funNullableAny() if (y != null || this.y != null) this.y - if (u != null) u.equals(null) + if (u != null) u.equals(null) - if (u != null) u.propT + if (u != null) u.propT - if (u != null) u.propAny + if (u != null) u.propAny - if (u != null) u.propNullableT + if (u != null) u.propNullableT - if (u != null) u.propNullableAny + if (u != null) u.propNullableAny - if (u != null) u.funT() + if (u != null) u.funT() - if (u != null) u.funAny() + if (u != null) u.funAny() - if (u != null) u.funNullableT() + if (u != null) u.funNullableT() - if (u != null) u.funNullableAny() - if (u != null) u + if (u != null) u.funNullableAny() + if (u != null) u if (this.u != null) this.u.equals(null) if (this.u != null) this.u.propT if (this.u != null) this.u.propAny @@ -3903,16 +3903,16 @@ object Case32 { if (this.u != null) this.u.funNullableT() if (this.u != null) this.u.funNullableAny() if (this.u != null) this.u - if (this.u != null) u.equals(null) - if (this.u != null) u.propT - if (this.u != null) u.propAny - if (this.u != null) u.propNullableT - if (this.u != null) u.propNullableAny - if (this.u != null) u.funT() - if (this.u != null) u.funAny() - if (this.u != null) u.funNullableT() - if (this.u != null) u.funNullableAny() - if (this.u != null) u + if (this.u != null) u.equals(null) + if (this.u != null) u.propT + if (this.u != null) u.propAny + if (this.u != null) u.propNullableT + if (this.u != null) u.propNullableAny + if (this.u != null) u.funT() + if (this.u != null) u.funAny() + if (this.u != null) u.funNullableT() + if (this.u != null) u.funNullableAny() + if (this.u != null) u if (u != null) this.u.equals(null) if (u != null) this.u.propT if (u != null) this.u.propAny @@ -3923,16 +3923,16 @@ object Case32 { if (u != null) this.u.funNullableT() if (u != null) this.u.funNullableAny() if (u != null) this.u - if (u != null || this.u != null) u.equals(null) - if (u != null || this.u != null) u.propT - if (u != null || this.u != null) u.propAny - if (u != null || this.u != null) u.propNullableT - if (u != null || this.u != null) u.propNullableAny - if (u != null || this.u != null) u.funT() - if (u != null || this.u != null) u.funAny() - if (u != null || this.u != null) u.funNullableT() - if (u != null || this.u != null) u.funNullableAny() - if (u != null || this.u != null) u + if (u != null || this.u != null) u.equals(null) + if (u != null || this.u != null) u.propT + if (u != null || this.u != null) u.propAny + if (u != null || this.u != null) u.propNullableT + if (u != null || this.u != null) u.propNullableAny + if (u != null || this.u != null) u.funT() + if (u != null || this.u != null) u.funAny() + if (u != null || this.u != null) u.funNullableT() + if (u != null || this.u != null) u.funNullableAny() + if (u != null || this.u != null) u if (u != null || this.u != null) this.u.equals(null) if (u != null || this.u != null) this.u.propT if (u != null || this.u != null) this.u.propAny @@ -3945,46 +3945,46 @@ object Case32 { if (u != null || this.u != null) this.u v = 0 - v.equals(null) - v.propT - v.propAny - v.propNullableT - v.propNullableAny - v.funT() - v.funAny() - v.funNullableT() - v.funNullableAny() - v - if (v != null) v.equals(null) - if (v != null) v.propT - if (v != null) v.propAny - if (v != null) v.propNullableT - if (v != null) v.propNullableAny - if (v != null) v.funT() - if (v != null) v.funAny() - if (v != null) v.funNullableT() - if (v != null) v.funNullableAny() - if (v != null) v - if (this.v != null) v.equals(null) - if (this.v != null) v.propT - if (this.v != null) v.propAny - if (this.v != null) v.propNullableT - if (this.v != null) v.propNullableAny - if (this.v != null) v.funT() - if (this.v != null) v.funAny() - if (this.v != null) v.funNullableT() - if (this.v != null) v.funNullableAny() - if (this.v != null) v - if (v != null || this.v != null) v.equals(null) - if (v != null || this.v != null) v.propT - if (v != null || this.v != null) v.propAny - if (v != null || this.v != null) v.propNullableT - if (v != null || this.v != null) v.propNullableAny - if (v != null || this.v != null) v.funT() - if (v != null || this.v != null) v.funAny() - if (v != null || this.v != null) v.funNullableT() - if (v != null || this.v != null) v.funNullableAny() - if (v != null || this.v != null) v + v.equals(null) + v.propT + v.propAny + v.propNullableT + v.propNullableAny + v.funT() + v.funAny() + v.funNullableT() + v.funNullableAny() + v + if (v != null) v.equals(null) + if (v != null) v.propT + if (v != null) v.propAny + if (v != null) v.propNullableT + if (v != null) v.propNullableAny + if (v != null) v.funT() + if (v != null) v.funAny() + if (v != null) v.funNullableT() + if (v != null) v.funNullableAny() + if (v != null) v + if (this.v != null) v.equals(null) + if (this.v != null) v.propT + if (this.v != null) v.propAny + if (this.v != null) v.propNullableT + if (this.v != null) v.propNullableAny + if (this.v != null) v.funT() + if (this.v != null) v.funAny() + if (this.v != null) v.funNullableT() + if (this.v != null) v.funNullableAny() + if (this.v != null) v + if (v != null || this.v != null) v.equals(null) + if (v != null || this.v != null) v.propT + if (v != null || this.v != null) v.propAny + if (v != null || this.v != null) v.propNullableT + if (v != null || this.v != null) v.propNullableAny + if (v != null || this.v != null) v.funT() + if (v != null || this.v != null) v.funAny() + if (v != null || this.v != null) v.funNullableT() + if (v != null || this.v != null) v.funNullableAny() + if (v != null || this.v != null) v if (v != null || this.v != null) this.v.equals(null) if (v != null || this.v != null) this.v.propT if (v != null || this.v != null) this.v.propAny @@ -3997,36 +3997,36 @@ object Case32 { if (v != null || this.v != null) this.v w = if (null != null) 10 else null - if (w != null) w.equals(null) - if (w != null) w.propT - if (w != null) w.propAny - if (w != null) w.propNullableT - if (w != null) w.propNullableAny - if (w != null) w.funT() - if (w != null) w.funAny() - if (w != null) w.funNullableT() - if (w != null) w.funNullableAny() - if (w != null) w - if (this.w != null) w.equals(null) - if (this.w != null) w.propT - if (this.w != null) w.propAny - if (this.w != null) w.propNullableT - if (this.w != null) w.propNullableAny - if (this.w != null) w.funT() - if (this.w != null) w.funAny() - if (this.w != null) w.funNullableT() - if (this.w != null) w.funNullableAny() - if (this.w != null) w - if (w != null || this.w != null) w.equals(null) - if (w != null || this.w != null) w.propT - if (w != null || this.w != null) w.propAny - if (w != null || this.w != null) w.propNullableT - if (w != null || this.w != null) w.propNullableAny - if (w != null || this.w != null) w.funT() - if (w != null || this.w != null) w.funAny() - if (w != null || this.w != null) w.funNullableT() - if (w != null || this.w != null) w.funNullableAny() - if (w != null || this.w != null) w + if (w != null) w.equals(null) + if (w != null) w.propT + if (w != null) w.propAny + if (w != null) w.propNullableT + if (w != null) w.propNullableAny + if (w != null) w.funT() + if (w != null) w.funAny() + if (w != null) w.funNullableT() + if (w != null) w.funNullableAny() + if (w != null) w + if (this.w != null) w.equals(null) + if (this.w != null) w.propT + if (this.w != null) w.propAny + if (this.w != null) w.propNullableT + if (this.w != null) w.propNullableAny + if (this.w != null) w.funT() + if (this.w != null) w.funAny() + if (this.w != null) w.funNullableT() + if (this.w != null) w.funNullableAny() + if (this.w != null) w + if (w != null || this.w != null) w.equals(null) + if (w != null || this.w != null) w.propT + if (w != null || this.w != null) w.propAny + if (w != null || this.w != null) w.propNullableT + if (w != null || this.w != null) w.propNullableAny + if (w != null || this.w != null) w.funT() + if (w != null || this.w != null) w.funAny() + if (w != null || this.w != null) w.funNullableT() + if (w != null || this.w != null) w.funNullableAny() + if (w != null || this.w != null) w if (w != null || this.w != null) this.w.equals(null) if (w != null || this.w != null) this.w.propT if (w != null || this.w != null) this.w.propAny @@ -4041,118 +4041,118 @@ object Case32 { s = null s.hashCode() s - if (s != null) s - if (this.s != null) s - if (s != null || this.s != null) s + if (s != null) s + if (this.s != null) s + if (s != null || this.s != null) s if (s != null || this.s != null) this.s } fun test() { - if (x != null) x.equals(null) - if (x != null) x.propT - if (x != null) x.propAny - if (x != null) x.propNullableT - if (x != null) x.propNullableAny - if (x != null) x.funT() - if (x != null) x.funAny() - if (x != null) x.funNullableT() - if (x != null) x.funNullableAny() - if (x != null) x + if (x != null) x.equals(null) + if (x != null) x.propT + if (x != null) x.propAny + if (x != null) x.propNullableT + if (x != null) x.propNullableAny + if (x != null) x.funT() + if (x != null) x.funAny() + if (x != null) x.funNullableT() + if (x != null) x.funNullableAny() + if (x != null) x - if (y != null) y.equals(null) + if (y != null) y.equals(null) - if (y != null) y.propT + if (y != null) y.propT - if (y != null) y.propAny + if (y != null) y.propAny - if (y != null) y.propNullableT + if (y != null) y.propNullableT - if (y != null) y.propNullableAny + if (y != null) y.propNullableAny - if (y != null) y.funT() + if (y != null) y.funT() - if (y != null) y.funAny() + if (y != null) y.funAny() - if (y != null) y.funNullableT() + if (y != null) y.funNullableT() - if (y != null) y.funNullableAny() - if (y != null) y + if (y != null) y.funNullableAny() + if (y != null) y - if (u != null) u.equals(null) + if (u != null) u.equals(null) - if (u != null) u.propT + if (u != null) u.propT - if (u != null) u.propAny + if (u != null) u.propAny - if (u != null) u.propNullableT + if (u != null) u.propNullableT - if (u != null) u.propNullableAny + if (u != null) u.propNullableAny - if (u != null) u.funT() + if (u != null) u.funT() - if (u != null) u.funAny() + if (u != null) u.funAny() - if (u != null) u.funNullableT() + if (u != null) u.funNullableT() - if (u != null) u.funNullableAny() - if (u != null) u + if (u != null) u.funNullableAny() + if (u != null) u - if (v != null) v.equals(null) + if (v != null) v.equals(null) - if (v != null) v.propT + if (v != null) v.propT - if (v != null) v.propAny + if (v != null) v.propAny - if (v != null) v.propNullableT + if (v != null) v.propNullableT - if (v != null) v.propNullableAny + if (v != null) v.propNullableAny - if (v != null) v.funT() + if (v != null) v.funT() - if (v != null) v.funAny() + if (v != null) v.funAny() - if (v != null) v.funNullableT() + if (v != null) v.funNullableT() - if (v != null) v.funNullableAny() - if (v != null) v + if (v != null) v.funNullableAny() + if (v != null) v - if (w != null) w.equals(null) + if (w != null) w.equals(null) - if (w != null) w.propT + if (w != null) w.propT - if (w != null) w.propAny + if (w != null) w.propAny - if (w != null) w.propNullableT + if (w != null) w.propNullableT - if (w != null) w.propNullableAny + if (w != null) w.propNullableAny - if (w != null) w.funT() + if (w != null) w.funT() - if (w != null) w.funAny() + if (w != null) w.funAny() - if (w != null) w.funNullableT() + if (w != null) w.funNullableT() - if (w != null) w.funNullableAny() - if (w != null) w + if (w != null) w.funNullableAny() + if (w != null) w - if (s != null) s.equals(null) + if (s != null) s.equals(null) - if (s != null) s.propT + if (s != null) s.propT - if (s != null) s.propAny + if (s != null) s.propAny - if (s != null) s.propNullableT + if (s != null) s.propNullableT - if (s != null) s.propNullableAny + if (s != null) s.propNullableAny - if (s != null) s.funT() + if (s != null) s.funT() - if (s != null) s.funAny() + if (s != null) s.funAny() - if (s != null) s.funNullableT() + if (s != null) s.funNullableT() - if (s != null) s.funNullableAny() - if (s != null) s + if (s != null) s.funNullableAny() + if (s != null) s } } @@ -4200,7 +4200,7 @@ fun case_32(a: Case32) { } // TESTCASE NUMBER: 33 -fun case_33(a: Int?, b: Int = if (a != null) a else 0) { +fun case_33(a: Int?, b: Int = if (a != null) a else 0) { a b.equals(null) b.propT diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/10.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/10.fir.kt index 3b0417ad0d5..f6096db5c39 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/10.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/10.fir.kt @@ -7,16 +7,16 @@ fun case_1() { val x = expandInv(Inv(select(10, null))) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -25,16 +25,16 @@ fun case_2() { val x = expandOut(Out(select(10, null))) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -43,16 +43,16 @@ fun case_3() { val x = expandInv(Inv(select(10, null))) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -61,16 +61,16 @@ fun case_4() { val x = expandOut(Out(select(10, null))) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -79,16 +79,16 @@ fun case_5() { val x = expandIn(In()) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -97,16 +97,16 @@ fun case_6() { val x = expandIn(In()) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -117,16 +117,16 @@ fun case_7() { val x = case_7(mutableMapOf(10 to 10)) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -137,16 +137,16 @@ fun case_8() { val x = case_8(mutableMapOf(10 to null)) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -157,16 +157,16 @@ fun case_9() { val x = case_9(mutableMapOf(null to 10)) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -177,16 +177,16 @@ fun case_10() { val x = case_10(mutableMapOf(10 to 10)) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -197,16 +197,16 @@ fun case_11() { val x = case_11(mutableMapOf(10 to 10)) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -217,16 +217,16 @@ fun case_12() { val x = case_12(mutableMapOf(10 to 11)) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -241,28 +241,28 @@ fun case_13() { val x = case_13(Out(), Out()) if (x != null) { - & Out?")!>x - & Out?")!>x.equals(null) - & Out?")!>x.propT - & Out?")!>x.propAny - & Out?")!>x.propNullableT - & Out?")!>x.propNullableAny - & Out?")!>x.funT() - & Out?")!>x.funAny() - & Out?")!>x.funNullableT() - & Out?")!>x.funNullableAny() + ? & Out")!>x + ? & Out")!>x.equals(null) + ? & Out")!>x.propT + ? & Out")!>x.propAny + ? & Out")!>x.propNullableT + ? & Out")!>x.propNullableAny + ? & Out")!>x.funT() + ? & Out")!>x.funAny() + ? & Out")!>x.funNullableT() + ? & Out")!>x.funNullableAny() val y = x.get() if (y != null) { - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() } } } @@ -274,28 +274,28 @@ fun case_14() { val x = case_14(Out(), Out()) if (x != null) { - & Out?")!>x - & Out?")!>x.equals(null) - & Out?")!>x.propT - & Out?")!>x.propAny - & Out?")!>x.propNullableT - & Out?")!>x.propNullableAny - & Out?")!>x.funT() - & Out?")!>x.funAny() - & Out?")!>x.funNullableT() - & Out?")!>x.funNullableAny() + ? & Out")!>x + ? & Out")!>x.equals(null) + ? & Out")!>x.propT + ? & Out")!>x.propAny + ? & Out")!>x.propNullableT + ? & Out")!>x.propNullableAny + ? & Out")!>x.funT() + ? & Out")!>x.funAny() + ? & Out")!>x.funNullableT() + ? & Out")!>x.funNullableAny() val y = x.get() if (y != null) { - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() } } } @@ -307,28 +307,28 @@ fun case_15() { val x = case_15(Out(), Out()) if (x != null) { - & Out?")!>x - & Out?")!>x.equals(null) - & Out?")!>x.propT - & Out?")!>x.propAny - & Out?")!>x.propNullableT - & Out?")!>x.propNullableAny - & Out?")!>x.funT() - & Out?")!>x.funAny() - & Out?")!>x.funNullableT() - & Out?")!>x.funNullableAny() + ? & Out")!>x + ? & Out")!>x.equals(null) + ? & Out")!>x.propT + ? & Out")!>x.propAny + ? & Out")!>x.propNullableT + ? & Out")!>x.propNullableAny + ? & Out")!>x.funT() + ? & Out")!>x.funAny() + ? & Out")!>x.funNullableT() + ? & Out")!>x.funNullableAny() val y = x.get() if (y != null) { - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() } } } @@ -344,28 +344,28 @@ fun case_16() { val x = case_16(Out(), Out()) if (x != null) { - & Out?")!>x - & Out?")!>x.equals(null) - & Out?")!>x.propT - & Out?")!>x.propAny - & Out?")!>x.propNullableT - & Out?")!>x.propNullableAny - & Out?")!>x.funT() - & Out?")!>x.funAny() - & Out?")!>x.funNullableT() - & Out?")!>x.funNullableAny() + ? & Out")!>x + ? & Out")!>x.equals(null) + ? & Out")!>x.propT + ? & Out")!>x.propAny + ? & Out")!>x.propNullableT + ? & Out")!>x.propNullableAny + ? & Out")!>x.funT() + ? & Out")!>x.funAny() + ? & Out")!>x.funNullableT() + ? & Out")!>x.funNullableAny() val y = x.get() if (y != null) { - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() } } } @@ -377,28 +377,28 @@ fun case_17() { val x = case_17(Out(), Out()) if (x != null) { - & Out?")!>x - & Out?")!>x.equals(null) - & Out?")!>x.propT - & Out?")!>x.propAny - & Out?")!>x.propNullableT - & Out?")!>x.propNullableAny - & Out?")!>x.funT() - & Out?")!>x.funAny() - & Out?")!>x.funNullableT() - & Out?")!>x.funNullableAny() + ? & Out")!>x + ? & Out")!>x.equals(null) + ? & Out")!>x.propT + ? & Out")!>x.propAny + ? & Out")!>x.propNullableT + ? & Out")!>x.propNullableAny + ? & Out")!>x.funT() + ? & Out")!>x.funAny() + ? & Out")!>x.funNullableT() + ? & Out")!>x.funNullableAny() val y = x.get() if (y != null) { - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() } } } @@ -425,16 +425,16 @@ fun case_18() { ")!>x.funNullableAny() val y = x.get() if (y != null) { - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() } } @@ -456,16 +456,16 @@ fun case_19() { ")!>x.funNullableAny() val y = x.get() if (y != null) { - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() } } @@ -476,16 +476,16 @@ fun case_20(y: Int?) { val x = case_20(Out(y), Out()) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -496,16 +496,16 @@ fun case_21(y: Int?) { val x = case_21(Out(y), Out()) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -516,16 +516,16 @@ fun case_22(y: Int?) { val x = case_22(Out(y), Out()) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -536,16 +536,16 @@ fun case_23(y: Int?) { val x = case_13(Out(y), Out()) if (x != null) { - & Out?")!>x - & Out?")!>x.equals(null) - & Out?")!>x.propT - & Out?")!>x.propAny - & Out?")!>x.propNullableT - & Out?")!>x.propNullableAny - & Out?")!>x.funT() - & Out?")!>x.funAny() - & Out?")!>x.funNullableT() - & Out?")!>x.funNullableAny() + ? & Out")!>x + ? & Out")!>x.equals(null) + ? & Out")!>x.propT + ? & Out")!>x.propAny + ? & Out")!>x.propNullableT + ? & Out")!>x.propNullableAny + ? & Out")!>x.funT() + ? & Out")!>x.funAny() + ? & Out")!>x.funNullableT() + ? & Out")!>x.funNullableAny() } } @@ -556,16 +556,16 @@ fun case_24(y: Int) { val x = case_13(Out(y), Out()) if (x != null) { - & Out?")!>x - & Out?")!>x.equals(null) - & Out?")!>x.propT - & Out?")!>x.propAny - & Out?")!>x.propNullableT - & Out?")!>x.propNullableAny - & Out?")!>x.funT() - & Out?")!>x.funAny() - & Out?")!>x.funNullableT() - & Out?")!>x.funNullableAny() + ? & Out")!>x + ? & Out")!>x.equals(null) + ? & Out")!>x.propT + ? & Out")!>x.propAny + ? & Out")!>x.propNullableT + ? & Out")!>x.propNullableAny + ? & Out")!>x.funT() + ? & Out")!>x.funAny() + ? & Out")!>x.funNullableT() + ? & Out")!>x.funNullableAny() } } @@ -581,16 +581,16 @@ fun case_25(y: Int) { val x = case_25(Out(Out(Out(Out(Out(y))))), Out(Out(Out(y)))) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -606,15 +606,15 @@ fun case_26(y: Int) { val x = case_26(Out(Out(Out(Out(Out(y))))), Out(Out(Out(y)))) if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.fir.kt index 578a5a62ed9..3fd9b27234c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.fir.kt @@ -9,16 +9,16 @@ fun case_1() { val x = case_1(Out(10), Inv(0.1)) if (x != null) { - & kotlin.Number? & kotlin.Comparable<*>?")!>x - & kotlin.Number? & kotlin.Comparable<*>?")!>x.equals(null) - & kotlin.Number? & kotlin.Comparable<*>?")!>x.propT - & kotlin.Number? & kotlin.Comparable<*>?")!>x.propAny - & kotlin.Number? & kotlin.Comparable<*>?")!>x.propNullableT - & kotlin.Number? & kotlin.Comparable<*>?")!>x.propNullableAny - & kotlin.Number? & kotlin.Comparable<*>?")!>x.funT() - & kotlin.Number? & kotlin.Comparable<*>?")!>x.funAny() - & kotlin.Number? & kotlin.Comparable<*>?")!>x.funNullableT() - & kotlin.Number? & kotlin.Comparable<*>?")!>x.funNullableAny() + ? & kotlin.Number & kotlin.Comparable<*>")!>x + ? & kotlin.Number & kotlin.Comparable<*>")!>x.equals(null) + ? & kotlin.Number & kotlin.Comparable<*>")!>x.propT + ? & kotlin.Number & kotlin.Comparable<*>")!>x.propAny + ? & kotlin.Number & kotlin.Comparable<*>")!>x.propNullableT + ? & kotlin.Number & kotlin.Comparable<*>")!>x.propNullableAny + ? & kotlin.Number & kotlin.Comparable<*>")!>x.funT() + ? & kotlin.Number & kotlin.Comparable<*>")!>x.funAny() + ? & kotlin.Number & kotlin.Comparable<*>")!>x.funNullableT() + ? & kotlin.Number & kotlin.Comparable<*>")!>x.funNullableAny() } } @@ -29,16 +29,16 @@ fun case_2(y: Int) { val x = case_2(Out(y), Inv(0.1)) if (x != null) { - & kotlin.Number? & kotlin.Comparable<*>?")!>x - & kotlin.Number? & kotlin.Comparable<*>?")!>x.equals(null) - & kotlin.Number? & kotlin.Comparable<*>?")!>x.propT - & kotlin.Number? & kotlin.Comparable<*>?")!>x.propAny - & kotlin.Number? & kotlin.Comparable<*>?")!>x.propNullableT - & kotlin.Number? & kotlin.Comparable<*>?")!>x.propNullableAny - & kotlin.Number? & kotlin.Comparable<*>?")!>x.funT() - & kotlin.Number? & kotlin.Comparable<*>?")!>x.funAny() - & kotlin.Number? & kotlin.Comparable<*>?")!>x.funNullableT() - & kotlin.Number? & kotlin.Comparable<*>?")!>x.funNullableAny() + ? & kotlin.Number & kotlin.Comparable<*>")!>x + ? & kotlin.Number & kotlin.Comparable<*>")!>x.equals(null) + ? & kotlin.Number & kotlin.Comparable<*>")!>x.propT + ? & kotlin.Number & kotlin.Comparable<*>")!>x.propAny + ? & kotlin.Number & kotlin.Comparable<*>")!>x.propNullableT + ? & kotlin.Number & kotlin.Comparable<*>")!>x.propNullableAny + ? & kotlin.Number & kotlin.Comparable<*>")!>x.funT() + ? & kotlin.Number & kotlin.Comparable<*>")!>x.funAny() + ? & kotlin.Number & kotlin.Comparable<*>")!>x.funNullableT() + ? & kotlin.Number & kotlin.Comparable<*>")!>x.funNullableAny() } } @@ -54,30 +54,30 @@ fun case_3(a: Int?, b: Float?, c: Double?, d: Boolean?) { }.apply { ?")!>this if (this != null) { - & kotlin.Number? & kotlin.Comparable<*>?")!>this - & kotlin.Number? & kotlin.Comparable<*>?")!>this.equals(null) - & kotlin.Number? & kotlin.Comparable<*>?")!>this.propT - & kotlin.Number? & kotlin.Comparable<*>?")!>this.propAny - & kotlin.Number? & kotlin.Comparable<*>?")!>this.propNullableT - & kotlin.Number? & kotlin.Comparable<*>?")!>this.propNullableAny - & kotlin.Number? & kotlin.Comparable<*>?")!>this.funT() - & kotlin.Number? & kotlin.Comparable<*>?")!>this.funAny() - & kotlin.Number? & kotlin.Comparable<*>?")!>this.funNullableT() - & kotlin.Number? & kotlin.Comparable<*>?")!>this.funNullableAny() + ? & kotlin.Number & kotlin.Comparable<*>")!>this + ? & kotlin.Number & kotlin.Comparable<*>")!>this.equals(null) + ? & kotlin.Number & kotlin.Comparable<*>")!>this.propT + ? & kotlin.Number & kotlin.Comparable<*>")!>this.propAny + ? & kotlin.Number & kotlin.Comparable<*>")!>this.propNullableT + ? & kotlin.Number & kotlin.Comparable<*>")!>this.propNullableAny + ? & kotlin.Number & kotlin.Comparable<*>")!>this.funT() + ? & kotlin.Number & kotlin.Comparable<*>")!>this.funAny() + ? & kotlin.Number & kotlin.Comparable<*>")!>this.funNullableT() + ? & kotlin.Number & kotlin.Comparable<*>")!>this.funNullableAny() } }.let { ?")!>it if (it != null) { - & kotlin.Number? & kotlin.Comparable<*>?")!>it - & kotlin.Number? & kotlin.Comparable<*>?")!>it.equals(null) - & kotlin.Number? & kotlin.Comparable<*>?")!>it.propT - & kotlin.Number? & kotlin.Comparable<*>?")!>it.propAny - & kotlin.Number? & kotlin.Comparable<*>?")!>it.propNullableT - & kotlin.Number? & kotlin.Comparable<*>?")!>it.propNullableAny - & kotlin.Number? & kotlin.Comparable<*>?")!>it.funT() - & kotlin.Number? & kotlin.Comparable<*>?")!>it.funAny() - & kotlin.Number? & kotlin.Comparable<*>?")!>it.funNullableT() - & kotlin.Number? & kotlin.Comparable<*>?")!>it.funNullableAny() + ? & kotlin.Number & kotlin.Comparable<*>")!>it + ? & kotlin.Number & kotlin.Comparable<*>")!>it.equals(null) + ? & kotlin.Number & kotlin.Comparable<*>")!>it.propT + ? & kotlin.Number & kotlin.Comparable<*>")!>it.propAny + ? & kotlin.Number & kotlin.Comparable<*>")!>it.propNullableT + ? & kotlin.Number & kotlin.Comparable<*>")!>it.propNullableAny + ? & kotlin.Number & kotlin.Comparable<*>")!>it.funT() + ? & kotlin.Number & kotlin.Comparable<*>")!>it.funAny() + ? & kotlin.Number & kotlin.Comparable<*>")!>it.funNullableT() + ? & kotlin.Number & kotlin.Comparable<*>")!>it.funNullableAny() } } } @@ -97,31 +97,31 @@ fun case_4(a: Interface1?, b: Interface2?, c: Boolean) { x.apply { this if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() } } x.let { it if (it != null) { - it - it.equals(null) - it.propT - it.propAny - it.propNullableT - it.propNullableAny - it.funT() - it.funAny() - it.funNullableT() - it.funNullableAny() + it + it.equals(null) + it.propT + it.propAny + it.propNullableT + it.propNullableAny + it.funT() + it.funAny() + it.funNullableT() + it.funNullableAny() } } } @@ -140,30 +140,30 @@ fun case_5(a: Interface1?, b: Interface2?, d: Boolean) { x.apply { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() } } x.let { if (it != null) { - it - it.equals(null) - it.propT - it.propAny - it.propNullableT - it.propNullableAny - it.funT() - it.funAny() - it.funNullableT() - it.funNullableAny() + it + it.equals(null) + it.propT + it.propAny + it.propNullableT + it.propNullableAny + it.funT() + it.funAny() + it.funNullableT() + it.funNullableAny() } } } @@ -182,38 +182,38 @@ fun case_6(a: Interface1?, b: Interface2, d: Boolean) { x.apply { this as Interface3 - this + this if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() - this.itest2() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() + this.itest2() } } x.let { it as Interface3 - it + it if (it != null) { - it - it.equals(null) - it.propT - it.propAny - it.propNullableT - it.propNullableAny - it.funT() - it.funAny() - it.funNullableT() - it.funNullableAny() - it.itest1() - it.itest2() + it + it.equals(null) + it.propT + it.propAny + it.propNullableT + it.propNullableAny + it.funT() + it.funAny() + it.funNullableT() + it.funNullableAny() + it.itest1() + it.itest2() } } } @@ -232,38 +232,38 @@ fun case_7(a: Interface1?, b: Interface2?, d: Boolean) { x.apply { this as Interface3? - this + this if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() - this.itest2() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() + this.itest2() } } x.let { it as Interface3? - it + it if (it != null) { - it - it.equals(null) - it.propT - it.propAny - it.propNullableT - it.propNullableAny - it.funT() - it.funAny() - it.funNullableT() - it.funNullableAny() - it.itest1() - it.itest2() + it + it.equals(null) + it.propT + it.propAny + it.propNullableT + it.propNullableAny + it.funT() + it.funAny() + it.funNullableT() + it.funNullableAny() + it.itest1() + it.itest2() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt index 12f5812c047..5f1af413a73 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt @@ -55,32 +55,32 @@ fun T?.case_2() { // TESTCASE NUMBER: 3 fun T.case_3() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() } } // TESTCASE NUMBER: 4 fun T?.case_4() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() } } @@ -88,17 +88,17 @@ fun T?.case_4() { fun T?.case_5() { if (this is Interface1) { if (this != null) { - this - this.equals(null) + this + this.equals(null) this.propT - this.propAny - this.propNullableT - this.propNullableAny + this.propAny + this.propNullableT + this.propNullableAny this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() equals(this) itest1() @@ -148,17 +148,17 @@ fun T?.case_5() { fun T?.case_6() { if (this is Interface1?) { if (this != null) { - this - this.equals(null) + this + this.equals(null) this.propT - this.propAny - this.propNullableT - this.propNullableAny + this.propAny + this.propNullableT + this.propNullableAny this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() equals(this) itest1() @@ -207,17 +207,17 @@ fun T.case_7() { val x = this if (x is Interface1?) { if (x != null) { - x - x.equals(null) + x + x.equals(null) x.propT - x.propAny - x.propNullableT - x.propNullableAny + x.propAny + x.propNullableT + x.propNullableAny x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.itest1() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.itest1() x.apply { this @@ -263,17 +263,17 @@ fun T.case_7() { fun T.case_8() { if (this != null) { if (this is Interface1?) { - this - this.equals(null) + this + this.equals(null) this.propT - this.propAny - this.propNullableT - this.propNullableAny + this.propAny + this.propNullableT + this.propNullableAny this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() equals(this) itest1() @@ -392,17 +392,17 @@ fun T.case_9() { // TESTCASE NUMBER: 10 fun T.case_10() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.toByte() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.toByte() equals(this) toByte() @@ -449,17 +449,17 @@ fun T.case_10() { fun T?.case_11() { if (this is Interface1?) { if (this != null) { - this - this.equals(null) + this + this.equals(null) this.propT - this.propAny - this.propNullableT - this.propNullableAny + this.propAny + this.propNullableT + this.propNullableAny this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() equals(this) itest1() @@ -506,18 +506,18 @@ fun T?.case_11() { // TESTCASE NUMBER: 12 fun T.case_12() where T : Number?, T: Interface1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() - this.toByte() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() + this.toByte() equals(this) itest1() @@ -648,17 +648,17 @@ fun T.case_13() where T : Out<*>?, T: Comparable { */ fun ?> T.case_14() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() equals(this) get() @@ -708,17 +708,17 @@ fun ?> T.case_14() { */ fun ?> T.case_15() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() equals(this) itest1() @@ -768,17 +768,17 @@ fun ?> T.case_15() { */ fun ?> T.case_16() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -828,17 +828,17 @@ fun ?> T.case_16() { */ fun ?> T.case_17() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -890,17 +890,17 @@ fun ?> T.case_18() { val y = this if (y != null) { - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() - y.ip1test1() + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() + y.ip1test1() equals(y) ip1test1() @@ -942,17 +942,17 @@ fun ?> T.case_18() { */ fun ?> T.case_19() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -1002,18 +1002,18 @@ fun ?> T.case_19() { */ fun T.case_20() where T: InterfaceWithTypeParameter1?, T: InterfaceWithTypeParameter2? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() - this.ip1test2() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() + this.ip1test2() equals(this) ip1test1() @@ -1067,19 +1067,19 @@ fun T.case_20() where T: InterfaceWithTypeParameter1?, T: InterfaceWit */ fun T.case_21() where T: InterfaceWithTypeParameter1?, T: InterfaceWithTypeParameter2?, T: InterfaceWithTypeParameter3? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() - this.ip1test2() - this.ip1test3() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() + this.ip1test2() + this.ip1test3() equals(this) ip1test1() @@ -1139,17 +1139,17 @@ fun >?> T.case var y = this if (y != null) { - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() - y.ip1test1() + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() + y.ip1test1() equals(y) ip1test1() @@ -1187,17 +1187,17 @@ fun >?> T.case // TESTCASE NUMBER: 23 fun >?> T.case_23() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -1243,17 +1243,17 @@ fun >?> T.case // TESTCASE NUMBER: 24 fun > InterfaceWithTypeParameter1?.case_24() { if (this != null) { - & InterfaceWithTypeParameter1?")!>this - & InterfaceWithTypeParameter1?")!>this.equals(null) - & InterfaceWithTypeParameter1?")!>this.propT - & InterfaceWithTypeParameter1?")!>this.propAny - & InterfaceWithTypeParameter1?")!>this.propNullableT - & InterfaceWithTypeParameter1?")!>this.propNullableAny - & InterfaceWithTypeParameter1?")!>this.funT() - & InterfaceWithTypeParameter1?")!>this.funAny() - & InterfaceWithTypeParameter1?")!>this.funNullableT() - & InterfaceWithTypeParameter1?")!>this.funNullableAny() - & InterfaceWithTypeParameter1?")!>this.ip1test1() + ? & InterfaceWithTypeParameter1")!>this + ? & InterfaceWithTypeParameter1")!>this.equals(null) + ? & InterfaceWithTypeParameter1")!>this.propT + ? & InterfaceWithTypeParameter1")!>this.propAny + ? & InterfaceWithTypeParameter1")!>this.propNullableT + ? & InterfaceWithTypeParameter1")!>this.propNullableAny + ? & InterfaceWithTypeParameter1")!>this.funT() + ? & InterfaceWithTypeParameter1")!>this.funAny() + ? & InterfaceWithTypeParameter1")!>this.funNullableT() + ? & InterfaceWithTypeParameter1")!>this.funNullableAny() + ? & InterfaceWithTypeParameter1")!>this.ip1test1() equals(this) ip1test1() @@ -1299,17 +1299,17 @@ fun > InterfaceWithTypeParameter1?.case // TESTCASE NUMBER: 25 fun > InterfaceWithTypeParameter1?.case_25() { if (this != null) { - & InterfaceWithTypeParameter1?")!>this - & InterfaceWithTypeParameter1?")!>this.equals(null) - & InterfaceWithTypeParameter1?")!>this.propT - & InterfaceWithTypeParameter1?")!>this.propAny - & InterfaceWithTypeParameter1?")!>this.propNullableT - & InterfaceWithTypeParameter1?")!>this.propNullableAny - & InterfaceWithTypeParameter1?")!>this.funT() - & InterfaceWithTypeParameter1?")!>this.funAny() - & InterfaceWithTypeParameter1?")!>this.funNullableT() - & InterfaceWithTypeParameter1?")!>this.funNullableAny() - & InterfaceWithTypeParameter1?")!>this.ip1test1() + ? & InterfaceWithTypeParameter1")!>this + ? & InterfaceWithTypeParameter1")!>this.equals(null) + ? & InterfaceWithTypeParameter1")!>this.propT + ? & InterfaceWithTypeParameter1")!>this.propAny + ? & InterfaceWithTypeParameter1")!>this.propNullableT + ? & InterfaceWithTypeParameter1")!>this.propNullableAny + ? & InterfaceWithTypeParameter1")!>this.funT() + ? & InterfaceWithTypeParameter1")!>this.funAny() + ? & InterfaceWithTypeParameter1")!>this.funNullableT() + ? & InterfaceWithTypeParameter1")!>this.funNullableAny() + ? & InterfaceWithTypeParameter1")!>this.ip1test1() equals(this) ip1test1() @@ -1355,17 +1355,17 @@ fun > InterfaceWithTypeParameter1?.cas // TESTCASE NUMBER: 26 fun > InterfaceWithTypeParameter1?.case_26() { if (this != null) { - & InterfaceWithTypeParameter1?")!>this - & InterfaceWithTypeParameter1?")!>this.equals(null) - & InterfaceWithTypeParameter1?")!>this.propT - & InterfaceWithTypeParameter1?")!>this.propAny - & InterfaceWithTypeParameter1?")!>this.propNullableT - & InterfaceWithTypeParameter1?")!>this.propNullableAny - & InterfaceWithTypeParameter1?")!>this.funT() - & InterfaceWithTypeParameter1?")!>this.funAny() - & InterfaceWithTypeParameter1?")!>this.funNullableT() - & InterfaceWithTypeParameter1?")!>this.funNullableAny() - & InterfaceWithTypeParameter1?")!>this.ip1test1() + ? & InterfaceWithTypeParameter1")!>this + ? & InterfaceWithTypeParameter1")!>this.equals(null) + ? & InterfaceWithTypeParameter1")!>this.propT + ? & InterfaceWithTypeParameter1")!>this.propAny + ? & InterfaceWithTypeParameter1")!>this.propNullableT + ? & InterfaceWithTypeParameter1")!>this.propNullableAny + ? & InterfaceWithTypeParameter1")!>this.funT() + ? & InterfaceWithTypeParameter1")!>this.funAny() + ? & InterfaceWithTypeParameter1")!>this.funNullableT() + ? & InterfaceWithTypeParameter1")!>this.funNullableAny() + ? & InterfaceWithTypeParameter1")!>this.ip1test1() equals(null) @@ -1427,17 +1427,17 @@ fun > InterfaceWithTypeParameter1?.case // TESTCASE NUMBER: 27 fun > InterfaceWithTypeParameter1?.case_27() { if (this != null) { - & InterfaceWithTypeParameter1?")!>this - & InterfaceWithTypeParameter1?")!>this.equals(null) - & InterfaceWithTypeParameter1?")!>this.propT - & InterfaceWithTypeParameter1?")!>this.propAny - & InterfaceWithTypeParameter1?")!>this.propNullableT - & InterfaceWithTypeParameter1?")!>this.propNullableAny - & InterfaceWithTypeParameter1?")!>this.funT() - & InterfaceWithTypeParameter1?")!>this.funAny() - & InterfaceWithTypeParameter1?")!>this.funNullableT() - & InterfaceWithTypeParameter1?")!>this.funNullableAny() - & InterfaceWithTypeParameter1?")!>this.ip1test1() + ? & InterfaceWithTypeParameter1")!>this + ? & InterfaceWithTypeParameter1")!>this.equals(null) + ? & InterfaceWithTypeParameter1")!>this.propT + ? & InterfaceWithTypeParameter1")!>this.propAny + ? & InterfaceWithTypeParameter1")!>this.propNullableT + ? & InterfaceWithTypeParameter1")!>this.propNullableAny + ? & InterfaceWithTypeParameter1")!>this.funT() + ? & InterfaceWithTypeParameter1")!>this.funAny() + ? & InterfaceWithTypeParameter1")!>this.funNullableT() + ? & InterfaceWithTypeParameter1")!>this.funNullableAny() + ? & InterfaceWithTypeParameter1")!>this.ip1test1() equals(null) @@ -1499,17 +1499,17 @@ fun > InterfaceWithTypeParameter1?.cas // TESTCASE NUMBER: 28 fun > InterfaceWithTypeParameter1?.case_28() { if (this != null) { - & InterfaceWithTypeParameter1?")!>this - & InterfaceWithTypeParameter1?")!>this.equals(null) - & InterfaceWithTypeParameter1?")!>this.propT - & InterfaceWithTypeParameter1?")!>this.propAny - & InterfaceWithTypeParameter1?")!>this.propNullableT - & InterfaceWithTypeParameter1?")!>this.propNullableAny - & InterfaceWithTypeParameter1?")!>this.funT() - & InterfaceWithTypeParameter1?")!>this.funAny() - & InterfaceWithTypeParameter1?")!>this.funNullableT() - & InterfaceWithTypeParameter1?")!>this.funNullableAny() - & InterfaceWithTypeParameter1?")!>this.ip1test1() + ? & InterfaceWithTypeParameter1")!>this + ? & InterfaceWithTypeParameter1")!>this.equals(null) + ? & InterfaceWithTypeParameter1")!>this.propT + ? & InterfaceWithTypeParameter1")!>this.propAny + ? & InterfaceWithTypeParameter1")!>this.propNullableT + ? & InterfaceWithTypeParameter1")!>this.propNullableAny + ? & InterfaceWithTypeParameter1")!>this.funT() + ? & InterfaceWithTypeParameter1")!>this.funAny() + ? & InterfaceWithTypeParameter1")!>this.funNullableT() + ? & InterfaceWithTypeParameter1")!>this.funNullableAny() + ? & InterfaceWithTypeParameter1")!>this.ip1test1() equals(null) @@ -1571,17 +1571,17 @@ fun > InterfaceWithTypeParameter1?. // TESTCASE NUMBER: 29 fun > InterfaceWithTypeParameter1?.case_29() { if (this != null) { - & InterfaceWithTypeParameter1?")!>this - & InterfaceWithTypeParameter1?")!>this.equals(null) - & InterfaceWithTypeParameter1?")!>this.propT - & InterfaceWithTypeParameter1?")!>this.propAny - & InterfaceWithTypeParameter1?")!>this.propNullableT - & InterfaceWithTypeParameter1?")!>this.propNullableAny - & InterfaceWithTypeParameter1?")!>this.funT() - & InterfaceWithTypeParameter1?")!>this.funAny() - & InterfaceWithTypeParameter1?")!>this.funNullableT() - & InterfaceWithTypeParameter1?")!>this.funNullableAny() - & InterfaceWithTypeParameter1?")!>this.ip1test1() + ? & InterfaceWithTypeParameter1")!>this + ? & InterfaceWithTypeParameter1")!>this.equals(null) + ? & InterfaceWithTypeParameter1")!>this.propT + ? & InterfaceWithTypeParameter1")!>this.propAny + ? & InterfaceWithTypeParameter1")!>this.propNullableT + ? & InterfaceWithTypeParameter1")!>this.propNullableAny + ? & InterfaceWithTypeParameter1")!>this.funT() + ? & InterfaceWithTypeParameter1")!>this.funAny() + ? & InterfaceWithTypeParameter1")!>this.funNullableT() + ? & InterfaceWithTypeParameter1")!>this.funNullableAny() + ? & InterfaceWithTypeParameter1")!>this.ip1test1() equals(null) @@ -1643,17 +1643,17 @@ fun > InterfaceWithTypeParameter1?. // TESTCASE NUMBER: 30 fun > InterfaceWithTypeParameter1?.case_30() { if (this != null) { - & InterfaceWithTypeParameter1?")!>this - & InterfaceWithTypeParameter1?")!>this.equals(null) - & InterfaceWithTypeParameter1?")!>this.propT - & InterfaceWithTypeParameter1?")!>this.propAny - & InterfaceWithTypeParameter1?")!>this.propNullableT - & InterfaceWithTypeParameter1?")!>this.propNullableAny - & InterfaceWithTypeParameter1?")!>this.funT() - & InterfaceWithTypeParameter1?")!>this.funAny() - & InterfaceWithTypeParameter1?")!>this.funNullableT() - & InterfaceWithTypeParameter1?")!>this.funNullableAny() - & InterfaceWithTypeParameter1?")!>this.ip1test1() + ? & InterfaceWithTypeParameter1")!>this + ? & InterfaceWithTypeParameter1")!>this.equals(null) + ? & InterfaceWithTypeParameter1")!>this.propT + ? & InterfaceWithTypeParameter1")!>this.propAny + ? & InterfaceWithTypeParameter1")!>this.propNullableT + ? & InterfaceWithTypeParameter1")!>this.propNullableAny + ? & InterfaceWithTypeParameter1")!>this.funT() + ? & InterfaceWithTypeParameter1")!>this.funAny() + ? & InterfaceWithTypeParameter1")!>this.funNullableT() + ? & InterfaceWithTypeParameter1")!>this.funNullableAny() + ? & InterfaceWithTypeParameter1")!>this.ip1test1() equals(null) @@ -1715,17 +1715,17 @@ fun > InterfaceWithTypeParameter1?.c // TESTCASE NUMBER: 31 fun > InterfaceWithTypeParameter1?.case_31() { if (this != null) { - & InterfaceWithTypeParameter1?")!>this - & InterfaceWithTypeParameter1?")!>this.equals(null) - & InterfaceWithTypeParameter1?")!>this.propT - & InterfaceWithTypeParameter1?")!>this.propAny - & InterfaceWithTypeParameter1?")!>this.propNullableT - & InterfaceWithTypeParameter1?")!>this.propNullableAny - & InterfaceWithTypeParameter1?")!>this.funT() - & InterfaceWithTypeParameter1?")!>this.funAny() - & InterfaceWithTypeParameter1?")!>this.funNullableT() - & InterfaceWithTypeParameter1?")!>this.funNullableAny() - & InterfaceWithTypeParameter1?")!>this.ip1test1() + ? & InterfaceWithTypeParameter1")!>this + ? & InterfaceWithTypeParameter1")!>this.equals(null) + ? & InterfaceWithTypeParameter1")!>this.propT + ? & InterfaceWithTypeParameter1")!>this.propAny + ? & InterfaceWithTypeParameter1")!>this.propNullableT + ? & InterfaceWithTypeParameter1")!>this.propNullableAny + ? & InterfaceWithTypeParameter1")!>this.funT() + ? & InterfaceWithTypeParameter1")!>this.funAny() + ? & InterfaceWithTypeParameter1")!>this.funNullableT() + ? & InterfaceWithTypeParameter1")!>this.funNullableAny() + ? & InterfaceWithTypeParameter1")!>this.ip1test1() equals(null) @@ -1787,17 +1787,17 @@ fun > InterfaceWithTypeParameter1? // TESTCASE NUMBER: 32 fun Map?.case_32() { if (this != null) { - & kotlin.collections.Map?")!>this - & kotlin.collections.Map?")!>this.equals(null) - & kotlin.collections.Map?")!>this.propT - & kotlin.collections.Map?")!>this.propAny - & kotlin.collections.Map?")!>this.propNullableT - & kotlin.collections.Map?")!>this.propNullableAny - & kotlin.collections.Map?")!>this.funT() - & kotlin.collections.Map?")!>this.funAny() - & kotlin.collections.Map?")!>this.funNullableT() - & kotlin.collections.Map?")!>this.funNullableAny() - & kotlin.collections.Map?")!>this.isEmpty() + ? & kotlin.collections.Map")!>this + ? & kotlin.collections.Map")!>this.equals(null) + ? & kotlin.collections.Map")!>this.propT + ? & kotlin.collections.Map")!>this.propAny + ? & kotlin.collections.Map")!>this.propNullableT + ? & kotlin.collections.Map")!>this.propNullableAny + ? & kotlin.collections.Map")!>this.funT() + ? & kotlin.collections.Map")!>this.funAny() + ? & kotlin.collections.Map")!>this.funNullableT() + ? & kotlin.collections.Map")!>this.funNullableAny() + ? & kotlin.collections.Map")!>this.isEmpty() equals(null) @@ -1859,17 +1859,17 @@ fun Map?.case_32() { // TESTCASE NUMBER: 33 fun InterfaceWithFiveTypeParameters1?.case_33() { if (this != null) { - & InterfaceWithFiveTypeParameters1?")!>this - & InterfaceWithFiveTypeParameters1?")!>this.equals(null) - & InterfaceWithFiveTypeParameters1?")!>this.propT - & InterfaceWithFiveTypeParameters1?")!>this.propAny - & InterfaceWithFiveTypeParameters1?")!>this.propNullableT - & InterfaceWithFiveTypeParameters1?")!>this.propNullableAny - & InterfaceWithFiveTypeParameters1?")!>this.funT() - & InterfaceWithFiveTypeParameters1?")!>this.funAny() - & InterfaceWithFiveTypeParameters1?")!>this.funNullableT() - & InterfaceWithFiveTypeParameters1?")!>this.funNullableAny() - & InterfaceWithFiveTypeParameters1?")!>this.itest() + ? & InterfaceWithFiveTypeParameters1")!>this + ? & InterfaceWithFiveTypeParameters1")!>this.equals(null) + ? & InterfaceWithFiveTypeParameters1")!>this.propT + ? & InterfaceWithFiveTypeParameters1")!>this.propAny + ? & InterfaceWithFiveTypeParameters1")!>this.propNullableT + ? & InterfaceWithFiveTypeParameters1")!>this.propNullableAny + ? & InterfaceWithFiveTypeParameters1")!>this.funT() + ? & InterfaceWithFiveTypeParameters1")!>this.funAny() + ? & InterfaceWithFiveTypeParameters1")!>this.funNullableT() + ? & InterfaceWithFiveTypeParameters1")!>this.funNullableAny() + ? & InterfaceWithFiveTypeParameters1")!>this.itest() equals(null) @@ -1931,17 +1931,17 @@ fun InterfaceWithFiveTypeParameters1?.case_33() { // TESTCASE NUMBER: 34 fun InterfaceWithTypeParameter1?.case_34() { if (this != null) { - & InterfaceWithTypeParameter1?")!>this - & InterfaceWithTypeParameter1?")!>this.equals(null) - & InterfaceWithTypeParameter1?")!>this.propT - & InterfaceWithTypeParameter1?")!>this.propAny - & InterfaceWithTypeParameter1?")!>this.propNullableT - & InterfaceWithTypeParameter1?")!>this.propNullableAny - & InterfaceWithTypeParameter1?")!>this.funT() - & InterfaceWithTypeParameter1?")!>this.funAny() - & InterfaceWithTypeParameter1?")!>this.funNullableT() - & InterfaceWithTypeParameter1?")!>this.funNullableAny() - & InterfaceWithTypeParameter1?")!>this.ip1test1() + ? & InterfaceWithTypeParameter1")!>this + ? & InterfaceWithTypeParameter1")!>this.equals(null) + ? & InterfaceWithTypeParameter1")!>this.propT + ? & InterfaceWithTypeParameter1")!>this.propAny + ? & InterfaceWithTypeParameter1")!>this.propNullableT + ? & InterfaceWithTypeParameter1")!>this.propNullableAny + ? & InterfaceWithTypeParameter1")!>this.funT() + ? & InterfaceWithTypeParameter1")!>this.funAny() + ? & InterfaceWithTypeParameter1")!>this.funNullableT() + ? & InterfaceWithTypeParameter1")!>this.funNullableAny() + ? & InterfaceWithTypeParameter1")!>this.ip1test1() equals(null) @@ -2003,17 +2003,17 @@ fun InterfaceWithTypeParameter1?.case_34() { // TESTCASE NUMBER: 35 fun InterfaceWithTypeParameter1?.case_35() { if (this != null) { - & InterfaceWithTypeParameter1?")!>this - & InterfaceWithTypeParameter1?")!>this.equals(null) - & InterfaceWithTypeParameter1?")!>this.propT - & InterfaceWithTypeParameter1?")!>this.propAny - & InterfaceWithTypeParameter1?")!>this.propNullableT - & InterfaceWithTypeParameter1?")!>this.propNullableAny - & InterfaceWithTypeParameter1?")!>this.funT() - & InterfaceWithTypeParameter1?")!>this.funAny() - & InterfaceWithTypeParameter1?")!>this.funNullableT() - & InterfaceWithTypeParameter1?")!>this.funNullableAny() - & InterfaceWithTypeParameter1?")!>this.ip1test1() + ? & InterfaceWithTypeParameter1")!>this + ? & InterfaceWithTypeParameter1")!>this.equals(null) + ? & InterfaceWithTypeParameter1")!>this.propT + ? & InterfaceWithTypeParameter1")!>this.propAny + ? & InterfaceWithTypeParameter1")!>this.propNullableT + ? & InterfaceWithTypeParameter1")!>this.propNullableAny + ? & InterfaceWithTypeParameter1")!>this.funT() + ? & InterfaceWithTypeParameter1")!>this.funAny() + ? & InterfaceWithTypeParameter1")!>this.funNullableT() + ? & InterfaceWithTypeParameter1")!>this.funNullableAny() + ? & InterfaceWithTypeParameter1")!>this.ip1test1() equals(null) @@ -2075,17 +2075,17 @@ fun InterfaceWithTypeParameter1?.case_35() { // TESTCASE NUMBER: 36 fun InterfaceWithTypeParameter1?.case_36() { if (this != null) { - & InterfaceWithTypeParameter1?")!>this - & InterfaceWithTypeParameter1?")!>this.equals(null) - & InterfaceWithTypeParameter1?")!>this.propT - & InterfaceWithTypeParameter1?")!>this.propAny - & InterfaceWithTypeParameter1?")!>this.propNullableT - & InterfaceWithTypeParameter1?")!>this.propNullableAny - & InterfaceWithTypeParameter1?")!>this.funT() - & InterfaceWithTypeParameter1?")!>this.funAny() - & InterfaceWithTypeParameter1?")!>this.funNullableT() - & InterfaceWithTypeParameter1?")!>this.funNullableAny() - & InterfaceWithTypeParameter1?")!>this.ip1test1() + ? & InterfaceWithTypeParameter1")!>this + ? & InterfaceWithTypeParameter1")!>this.equals(null) + ? & InterfaceWithTypeParameter1")!>this.propT + ? & InterfaceWithTypeParameter1")!>this.propAny + ? & InterfaceWithTypeParameter1")!>this.propNullableT + ? & InterfaceWithTypeParameter1")!>this.propNullableAny + ? & InterfaceWithTypeParameter1")!>this.funT() + ? & InterfaceWithTypeParameter1")!>this.funAny() + ? & InterfaceWithTypeParameter1")!>this.funNullableT() + ? & InterfaceWithTypeParameter1")!>this.funNullableAny() + ? & InterfaceWithTypeParameter1")!>this.ip1test1() equals(null) @@ -2147,17 +2147,17 @@ fun InterfaceWithTypeParameter1?.case_36() { // TESTCASE NUMBER: 37 fun Map?.case_37() { if (this != null) { - & kotlin.collections.Map?")!>this - & kotlin.collections.Map?")!>this.equals(null) - & kotlin.collections.Map?")!>this.propT - & kotlin.collections.Map?")!>this.propAny - & kotlin.collections.Map?")!>this.propNullableT - & kotlin.collections.Map?")!>this.propNullableAny - & kotlin.collections.Map?")!>this.funT() - & kotlin.collections.Map?")!>this.funAny() - & kotlin.collections.Map?")!>this.funNullableT() - & kotlin.collections.Map?")!>this.funNullableAny() - & kotlin.collections.Map?")!>this.isEmpty() + ? & kotlin.collections.Map")!>this + ? & kotlin.collections.Map")!>this.equals(null) + ? & kotlin.collections.Map")!>this.propT + ? & kotlin.collections.Map")!>this.propAny + ? & kotlin.collections.Map")!>this.propNullableT + ? & kotlin.collections.Map")!>this.propNullableAny + ? & kotlin.collections.Map")!>this.funT() + ? & kotlin.collections.Map")!>this.funAny() + ? & kotlin.collections.Map")!>this.funNullableT() + ? & kotlin.collections.Map")!>this.funNullableAny() + ? & kotlin.collections.Map")!>this.isEmpty() equals(null) @@ -2219,17 +2219,17 @@ fun Map?.case_37() { // TESTCASE NUMBER: 38 fun Map<*, out T>?.case_38() { if (this != null) { - & kotlin.collections.Map<*, out T>?")!>this - & kotlin.collections.Map<*, out T>?")!>this.equals(null) - & kotlin.collections.Map<*, out T>?")!>this.propT - & kotlin.collections.Map<*, out T>?")!>this.propAny - & kotlin.collections.Map<*, out T>?")!>this.propNullableT - & kotlin.collections.Map<*, out T>?")!>this.propNullableAny - & kotlin.collections.Map<*, out T>?")!>this.funT() - & kotlin.collections.Map<*, out T>?")!>this.funAny() - & kotlin.collections.Map<*, out T>?")!>this.funNullableT() - & kotlin.collections.Map<*, out T>?")!>this.funNullableAny() - & kotlin.collections.Map<*, out T>?")!>this.isEmpty() + ? & kotlin.collections.Map<*, out T>")!>this + ? & kotlin.collections.Map<*, out T>")!>this.equals(null) + ? & kotlin.collections.Map<*, out T>")!>this.propT + ? & kotlin.collections.Map<*, out T>")!>this.propAny + ? & kotlin.collections.Map<*, out T>")!>this.propNullableT + ? & kotlin.collections.Map<*, out T>")!>this.propNullableAny + ? & kotlin.collections.Map<*, out T>")!>this.funT() + ? & kotlin.collections.Map<*, out T>")!>this.funAny() + ? & kotlin.collections.Map<*, out T>")!>this.funNullableT() + ? & kotlin.collections.Map<*, out T>")!>this.funNullableAny() + ? & kotlin.collections.Map<*, out T>")!>this.isEmpty() equals(null) @@ -2291,16 +2291,16 @@ fun Map<*, out T>?.case_38() { // TESTCASE NUMBER: 39 fun InterfaceWithTwoTypeParameters?.case_39() { if (this != null) { - & InterfaceWithTwoTypeParameters?")!>this - & InterfaceWithTwoTypeParameters?")!>this.equals(null) - & InterfaceWithTwoTypeParameters?")!>this.propT - & InterfaceWithTwoTypeParameters?")!>this.propAny - & InterfaceWithTwoTypeParameters?")!>this.propNullableT - & InterfaceWithTwoTypeParameters?")!>this.propNullableAny - & InterfaceWithTwoTypeParameters?")!>this.funT() - & InterfaceWithTwoTypeParameters?")!>this.funAny() - & InterfaceWithTwoTypeParameters?")!>this.funNullableT() - & InterfaceWithTwoTypeParameters?")!>this.funNullableAny() + ? & InterfaceWithTwoTypeParameters")!>this + ? & InterfaceWithTwoTypeParameters")!>this.equals(null) + ? & InterfaceWithTwoTypeParameters")!>this.propT + ? & InterfaceWithTwoTypeParameters")!>this.propAny + ? & InterfaceWithTwoTypeParameters")!>this.propNullableT + ? & InterfaceWithTwoTypeParameters")!>this.propNullableAny + ? & InterfaceWithTwoTypeParameters")!>this.funT() + ? & InterfaceWithTwoTypeParameters")!>this.funAny() + ? & InterfaceWithTwoTypeParameters")!>this.funNullableT() + ? & InterfaceWithTwoTypeParameters")!>this.funNullableAny() equals(null) @@ -2358,16 +2358,16 @@ fun InterfaceWithTwoTypeParameters?.case_39() { // TESTCASE NUMBER: 40 fun InterfaceWithTwoTypeParameters?.case_40() { if (this != null) { - & InterfaceWithTwoTypeParameters?")!>this - & InterfaceWithTwoTypeParameters?")!>this.equals(null) - & InterfaceWithTwoTypeParameters?")!>this.propT - & InterfaceWithTwoTypeParameters?")!>this.propAny - & InterfaceWithTwoTypeParameters?")!>this.propNullableT - & InterfaceWithTwoTypeParameters?")!>this.propNullableAny - & InterfaceWithTwoTypeParameters?")!>this.funT() - & InterfaceWithTwoTypeParameters?")!>this.funAny() - & InterfaceWithTwoTypeParameters?")!>this.funNullableT() - & InterfaceWithTwoTypeParameters?")!>this.funNullableAny() + ? & InterfaceWithTwoTypeParameters")!>this + ? & InterfaceWithTwoTypeParameters")!>this.equals(null) + ? & InterfaceWithTwoTypeParameters")!>this.propT + ? & InterfaceWithTwoTypeParameters")!>this.propAny + ? & InterfaceWithTwoTypeParameters")!>this.propNullableT + ? & InterfaceWithTwoTypeParameters")!>this.propNullableAny + ? & InterfaceWithTwoTypeParameters")!>this.funT() + ? & InterfaceWithTwoTypeParameters")!>this.funAny() + ? & InterfaceWithTwoTypeParameters")!>this.funNullableT() + ? & InterfaceWithTwoTypeParameters")!>this.funNullableAny() equals(null) @@ -2425,17 +2425,17 @@ fun InterfaceWithTwoTypeParameters?.case_40() { // TESTCASE NUMBER: 41 fun Map?.case_41() { if (this != null) { - & kotlin.collections.Map?")!>this - & kotlin.collections.Map?")!>this.equals(null) - & kotlin.collections.Map?")!>this.propT - & kotlin.collections.Map?")!>this.propAny - & kotlin.collections.Map?")!>this.propNullableT - & kotlin.collections.Map?")!>this.propNullableAny - & kotlin.collections.Map?")!>this.funT() - & kotlin.collections.Map?")!>this.funAny() - & kotlin.collections.Map?")!>this.funNullableT() - & kotlin.collections.Map?")!>this.funNullableAny() - & kotlin.collections.Map?")!>this.isEmpty() + ? & kotlin.collections.Map")!>this + ? & kotlin.collections.Map")!>this.equals(null) + ? & kotlin.collections.Map")!>this.propT + ? & kotlin.collections.Map")!>this.propAny + ? & kotlin.collections.Map")!>this.propNullableT + ? & kotlin.collections.Map")!>this.propNullableAny + ? & kotlin.collections.Map")!>this.funT() + ? & kotlin.collections.Map")!>this.funAny() + ? & kotlin.collections.Map")!>this.funNullableT() + ? & kotlin.collections.Map")!>this.funNullableAny() + ? & kotlin.collections.Map")!>this.isEmpty() equals(null) @@ -2497,17 +2497,17 @@ fun Map?.case_41() { // TESTCASE NUMBER: 42 fun Map?.case_42() { if (this != null) { - & kotlin.collections.Map?")!>this - & kotlin.collections.Map?")!>this.equals(null) - & kotlin.collections.Map?")!>this.propT - & kotlin.collections.Map?")!>this.propAny - & kotlin.collections.Map?")!>this.propNullableT - & kotlin.collections.Map?")!>this.propNullableAny - & kotlin.collections.Map?")!>this.funT() - & kotlin.collections.Map?")!>this.funAny() - & kotlin.collections.Map?")!>this.funNullableT() - & kotlin.collections.Map?")!>this.funNullableAny() - & kotlin.collections.Map?")!>this.isEmpty() + ? & kotlin.collections.Map")!>this + ? & kotlin.collections.Map")!>this.equals(null) + ? & kotlin.collections.Map")!>this.propT + ? & kotlin.collections.Map")!>this.propAny + ? & kotlin.collections.Map")!>this.propNullableT + ? & kotlin.collections.Map")!>this.propNullableAny + ? & kotlin.collections.Map")!>this.funT() + ? & kotlin.collections.Map")!>this.funAny() + ? & kotlin.collections.Map")!>this.funNullableT() + ? & kotlin.collections.Map")!>this.funNullableAny() + ? & kotlin.collections.Map")!>this.isEmpty() equals(null) @@ -2569,17 +2569,17 @@ fun Map?.case_42() { // TESTCASE NUMBER: 43 fun Map?.case_43() { if (this != null) { - & kotlin.collections.Map?")!>this - & kotlin.collections.Map?")!>this.equals(null) - & kotlin.collections.Map?")!>this.propT - & kotlin.collections.Map?")!>this.propAny - & kotlin.collections.Map?")!>this.propNullableT - & kotlin.collections.Map?")!>this.propNullableAny - & kotlin.collections.Map?")!>this.funT() - & kotlin.collections.Map?")!>this.funAny() - & kotlin.collections.Map?")!>this.funNullableT() - & kotlin.collections.Map?")!>this.funNullableAny() - & kotlin.collections.Map?")!>this.isEmpty() + ? & kotlin.collections.Map")!>this + ? & kotlin.collections.Map")!>this.equals(null) + ? & kotlin.collections.Map")!>this.propT + ? & kotlin.collections.Map")!>this.propAny + ? & kotlin.collections.Map")!>this.propNullableT + ? & kotlin.collections.Map")!>this.propNullableAny + ? & kotlin.collections.Map")!>this.funT() + ? & kotlin.collections.Map")!>this.funAny() + ? & kotlin.collections.Map")!>this.funNullableT() + ? & kotlin.collections.Map")!>this.funNullableAny() + ? & kotlin.collections.Map")!>this.isEmpty() equals(null) @@ -2641,17 +2641,17 @@ fun Map?.case_43() { // TESTCASE NUMBER: 44 fun InterfaceWithFiveTypeParameters1?.case_44() { if (this != null) { - & InterfaceWithFiveTypeParameters1?")!>this - & InterfaceWithFiveTypeParameters1?")!>this.equals(null) - & InterfaceWithFiveTypeParameters1?")!>this.propT - & InterfaceWithFiveTypeParameters1?")!>this.propAny - & InterfaceWithFiveTypeParameters1?")!>this.propNullableT - & InterfaceWithFiveTypeParameters1?")!>this.propNullableAny - & InterfaceWithFiveTypeParameters1?")!>this.funT() - & InterfaceWithFiveTypeParameters1?")!>this.funAny() - & InterfaceWithFiveTypeParameters1?")!>this.funNullableT() - & InterfaceWithFiveTypeParameters1?")!>this.funNullableAny() - & InterfaceWithFiveTypeParameters1?")!>this.itest() + ? & InterfaceWithFiveTypeParameters1")!>this + ? & InterfaceWithFiveTypeParameters1")!>this.equals(null) + ? & InterfaceWithFiveTypeParameters1")!>this.propT + ? & InterfaceWithFiveTypeParameters1")!>this.propAny + ? & InterfaceWithFiveTypeParameters1")!>this.propNullableT + ? & InterfaceWithFiveTypeParameters1")!>this.propNullableAny + ? & InterfaceWithFiveTypeParameters1")!>this.funT() + ? & InterfaceWithFiveTypeParameters1")!>this.funAny() + ? & InterfaceWithFiveTypeParameters1")!>this.funNullableT() + ? & InterfaceWithFiveTypeParameters1")!>this.funNullableAny() + ? & InterfaceWithFiveTypeParameters1")!>this.itest() equals(null) @@ -2713,18 +2713,18 @@ fun InterfaceWithFiveTypeParameters1?.case_44() { // TESTCASE NUMBER: 45 fun T.case_45() where T : Number?, T: Comparable? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.toByte() - this.compareTo(this) + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.toByte() + this.compareTo(this) equals(this) toByte() @@ -2774,19 +2774,19 @@ fun T.case_45() where T : Number?, T: Comparable? { // TESTCASE NUMBER: 46 fun T.case_46() where T : CharSequence?, T: Comparable?, T: Iterable<*>? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.compareTo(this) - this.get(0) - this.iterator() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.compareTo(this) + this.get(0) + this.iterator() equals(this) compareTo(this) @@ -2844,18 +2844,18 @@ fun T.case_46() where T : CharSequence?, T: Comparable?, T: Iterable<*>? */ fun T?.case_47() where T : Inv, T: Comparable<*>?, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -2900,7 +2900,7 @@ fun T?.case_47() where T : Inv, T: Comparable<*>?, T: InterfaceWithTypePa it.ip1test1() } - this.compareTo(return) + this.compareTo(return) compareTo(return) apply { @@ -2921,18 +2921,18 @@ fun T?.case_47() where T : Inv, T: Comparable<*>?, T: InterfaceWithTypePa */ fun T?.case_48() where T : Inv, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -2986,18 +2986,18 @@ fun T?.case_48() where T : Inv, T: InterfaceWithTypeParameter1? */ fun T?.case_49() where T : Inv, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3051,18 +3051,18 @@ fun T?.case_49() where T : Inv, T: InterfaceWithTypeParameter1? */ fun T?.case_50() where T : Inv, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3116,18 +3116,18 @@ fun T?.case_50() where T : Inv, T: InterfaceWithTypeParameter1 */ fun T?.case_51() where T : Inv, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3177,18 +3177,18 @@ fun T?.case_51() where T : Inv, T: InterfaceWithTypeParameter1? { // TESTCASE NUMBER: 52 fun T?.case_52() where T : Inv, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3242,18 +3242,18 @@ fun T?.case_52() where T : Inv, T: InterfaceWithTypeParameter1? { */ fun T?.case_53() where T : Inv, T: InterfaceWithTypeParameter1<*>? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3307,18 +3307,18 @@ fun T?.case_53() where T : Inv, T: InterfaceWithTypeParameter1<*>? { */ fun T?.case_54() where T : Inv<*>, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3368,18 +3368,18 @@ fun T?.case_54() where T : Inv<*>, T: InterfaceWithTypeParameter1? { // TESTCASE NUMBER: 55 fun T?.case_55() where T : Inv<*>, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3429,18 +3429,18 @@ fun T?.case_55() where T : Inv<*>, T: InterfaceWithTypeParameter1? { // TESTCASE NUMBER: 56 fun T.case_56() where T : Number?, T: Interface1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest() - this.toByte() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest() + this.toByte() equals(this) itest() @@ -3571,17 +3571,17 @@ fun T.case_57() where T : Out<*>?, T: Comparable { // TESTCASE NUMBER: 58 fun >>>>>>>>>?> T.case_59() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -3631,19 +3631,19 @@ fun T.case_59() where T: InterfaceWithFiveTypeParameters1?, T: InterfaceWithFiveTypeParameters2?, T: InterfaceWithFiveTypeParameters3? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() - this.itest2() - this.itest3() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() + this.itest2() + this.itest3() equals(this) itest1() @@ -3701,17 +3701,17 @@ fun T.case_59() where T: InterfaceWithFiveTypeParameters1?> T.case_60() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -3766,10 +3766,10 @@ class Case61_3: InterfaceWithTypeParameter1, Case61_1, Case61_2 { fun T.case_61() where T : InterfaceWithTypeParameter1?, T: Case61_3?, T: Case61_1?, T: Case61_2? { if (this != null) { - this.test1() - this.test2() - this.ip1test1() - this.test4() + this.test1() + this.test2() + this.ip1test1() + this.test4() test1() test2() @@ -3799,8 +3799,8 @@ fun T.case_61() where T : InterfaceWithTypeParameter1?, T: Case61_3?, // TESTCASE NUMBER: 62 fun Nothing?.case_62() { if (this != null) { - this - this.hashCode() + this + this.hashCode() hashCode() apply { @@ -3840,8 +3840,8 @@ fun Nothing.case_63() { */ fun T.case_64() { if (this != null) { - this - this.hashCode() + this + this.hashCode() hashCode() apply { @@ -3865,16 +3865,16 @@ fun T.case_65() { if (this is Interface1?) { if (this is Interface2?) { if (this != null) { - this - this.equals(null) + this + this.equals(null) this.propT - this.propAny - this.propNullableT - this.propNullableAny + this.propAny + this.propNullableT + this.propNullableAny this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() + this.funAny() + this.funNullableT() + this.funNullableAny() apply { this this.equals(null) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt index e26b99a1e6c..48459ac32c3 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt @@ -75,32 +75,32 @@ fun case_2(x: T?, y: Nothing?) { // TESTCASE NUMBER: 3 fun case_3(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } // TESTCASE NUMBER: 4 fun case_4(x: T?) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -108,36 +108,36 @@ fun case_4(x: T?) { fun case_5(x: T?) { if (x is Interface1) { if (x != null) { - x - x.equals(null) + x + x.equals(null) x.propT - x.propAny - x.propNullableT - x.propNullableAny + x.propAny + x.propNullableT + x.propNullableAny x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.itest() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.itest() - x.equals(null) + x.equals(null) x.propT - x.propAny + x.propAny - x.propNullableT + x.propNullableT - x.propNullableAny + x.propNullableAny x.funT() - x.funAny() + x.funAny() - x.funNullableT() + x.funNullableT() - x.funNullableAny() - x.itest() + x.funNullableAny() + x.itest() x.apply { this this @@ -184,17 +184,17 @@ fun case_5(x: T?) { fun case_6(x: T?) { if (x is Interface1?) { if (x != null) { - x - x.equals(null) + x + x.equals(null) x.propT - x.propAny - x.propNullableT - x.propNullableAny + x.propAny + x.propNullableT + x.propNullableAny x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.itest() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.itest() x.equals(null) @@ -259,17 +259,17 @@ fun case_7(y: T) { val x = y if (x is Interface1?) { if (x != null) { - x - x.equals(null) + x + x.equals(null) x.propT - x.propAny - x.propNullableT - x.propNullableAny + x.propAny + x.propNullableT + x.propNullableAny x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.itest() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.itest() x.apply { this @@ -315,17 +315,17 @@ fun case_7(y: T) { fun case_8(x: T) { if (x != null) { if (x is Interface1?) { - x - x.equals(null) + x + x.equals(null) x.propT - x.propAny - x.propNullableT - x.propNullableAny + x.propAny + x.propNullableT + x.propNullableAny x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.itest() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.itest() x.equals(null) @@ -460,17 +460,17 @@ fun case_9(x: T) { // TESTCASE NUMBER: 10 fun case_10(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.toByte() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.toByte() x.equals(null) @@ -533,17 +533,17 @@ fun case_10(x: T) { fun case_11(x: T?) { if (x is Interface1?) { if (x != null) { - x - x.equals(null) + x + x.equals(null) x.propT - x.propAny - x.propNullableT - x.propNullableAny + x.propAny + x.propNullableT + x.propNullableAny x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.itest() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.itest() x.equals(null) @@ -606,18 +606,18 @@ fun case_11(x: T?) { // TESTCASE NUMBER: 12 fun case_12(x: T) where T : Number?, T: Interface1? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.itest() - x.toByte() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.itest() + x.toByte() x.equals(null) @@ -763,17 +763,17 @@ fun case_13(x: T) where T : Out<*>?, T: Comparable { */ fun ?> case_14(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.get() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.get() x.equals(null) @@ -838,17 +838,17 @@ fun ?> case_14(x: T) { */ fun ?> case_15(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.itest() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.itest() x.equals(null) @@ -913,17 +913,17 @@ fun ?> case_15(x: T) { */ fun ?> case_16(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.ip1test1() x.equals(null) @@ -988,17 +988,17 @@ fun ?> case_16(x: T) { */ fun ?> case_17(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.ip1test1() x.equals(null) @@ -1065,17 +1065,17 @@ fun ?> case_18(x: T) { val y = x if (y != null) { - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() - y.ip1test1() + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() + y.ip1test1() x.equals(null) @@ -1140,17 +1140,17 @@ fun ?> case_18(x: T) { */ fun ?> case_19(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.ip1test1() x.equals(null) @@ -1215,18 +1215,18 @@ fun ?> case_19(x: T) { */ fun case_20(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceWithTypeParameter2? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.ip1test1() - x.ip1test2() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.ip1test1() + x.ip1test2() x.equals(null) @@ -1295,19 +1295,19 @@ fun case_20(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceW */ fun case_21(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceWithTypeParameter2?, T: InterfaceWithTypeParameter3? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.ip1test1() - x.ip1test2() - x.ip1test3() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.ip1test1() + x.ip1test2() + x.ip1test3() x.equals(null) @@ -1383,17 +1383,17 @@ fun >?> case_2 var y = x if (y != null) { - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() - y.ip1test1() + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() + y.ip1test1() x.equals(null) @@ -1447,17 +1447,17 @@ fun >?> case_2 // TESTCASE NUMBER: 23 fun >?> case_23(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.ip1test1() x.equals(null) @@ -1519,17 +1519,17 @@ fun >?> case_2 // TESTCASE NUMBER: 24 fun > case_24(x: InterfaceWithTypeParameter1?) { if (x != null) { - & InterfaceWithTypeParameter1?")!>x - & InterfaceWithTypeParameter1?")!>x.equals(null) - & InterfaceWithTypeParameter1?")!>x.propT - & InterfaceWithTypeParameter1?")!>x.propAny - & InterfaceWithTypeParameter1?")!>x.propNullableT - & InterfaceWithTypeParameter1?")!>x.propNullableAny - & InterfaceWithTypeParameter1?")!>x.funT() - & InterfaceWithTypeParameter1?")!>x.funAny() - & InterfaceWithTypeParameter1?")!>x.funNullableT() - & InterfaceWithTypeParameter1?")!>x.funNullableAny() - & InterfaceWithTypeParameter1?")!>x.ip1test1() + ? & InterfaceWithTypeParameter1")!>x + ? & InterfaceWithTypeParameter1")!>x.equals(null) + ? & InterfaceWithTypeParameter1")!>x.propT + ? & InterfaceWithTypeParameter1")!>x.propAny + ? & InterfaceWithTypeParameter1")!>x.propNullableT + ? & InterfaceWithTypeParameter1")!>x.propNullableAny + ? & InterfaceWithTypeParameter1")!>x.funT() + ? & InterfaceWithTypeParameter1")!>x.funAny() + ? & InterfaceWithTypeParameter1")!>x.funNullableT() + ? & InterfaceWithTypeParameter1")!>x.funNullableAny() + ? & InterfaceWithTypeParameter1")!>x.ip1test1() x.equals(null) @@ -1591,17 +1591,17 @@ fun > case_24(x: InterfaceWithTypeParamete // TESTCASE NUMBER: 25 fun > case_25(x: InterfaceWithTypeParameter1?) { if (x != null) { - & InterfaceWithTypeParameter1?")!>x - & InterfaceWithTypeParameter1?")!>x.equals(null) - & InterfaceWithTypeParameter1?")!>x.propT - & InterfaceWithTypeParameter1?")!>x.propAny - & InterfaceWithTypeParameter1?")!>x.propNullableT - & InterfaceWithTypeParameter1?")!>x.propNullableAny - & InterfaceWithTypeParameter1?")!>x.funT() - & InterfaceWithTypeParameter1?")!>x.funAny() - & InterfaceWithTypeParameter1?")!>x.funNullableT() - & InterfaceWithTypeParameter1?")!>x.funNullableAny() - & InterfaceWithTypeParameter1?")!>x.ip1test1() + ? & InterfaceWithTypeParameter1")!>x + ? & InterfaceWithTypeParameter1")!>x.equals(null) + ? & InterfaceWithTypeParameter1")!>x.propT + ? & InterfaceWithTypeParameter1")!>x.propAny + ? & InterfaceWithTypeParameter1")!>x.propNullableT + ? & InterfaceWithTypeParameter1")!>x.propNullableAny + ? & InterfaceWithTypeParameter1")!>x.funT() + ? & InterfaceWithTypeParameter1")!>x.funAny() + ? & InterfaceWithTypeParameter1")!>x.funNullableT() + ? & InterfaceWithTypeParameter1")!>x.funNullableAny() + ? & InterfaceWithTypeParameter1")!>x.ip1test1() x.equals(null) @@ -1663,17 +1663,17 @@ fun > case_25(x: InterfaceWithTypeParamet // TESTCASE NUMBER: 26 fun > case_26(x: InterfaceWithTypeParameter1?) { if (x != null) { - & InterfaceWithTypeParameter1?")!>x - & InterfaceWithTypeParameter1?")!>x.equals(null) - & InterfaceWithTypeParameter1?")!>x.propT - & InterfaceWithTypeParameter1?")!>x.propAny - & InterfaceWithTypeParameter1?")!>x.propNullableT - & InterfaceWithTypeParameter1?")!>x.propNullableAny - & InterfaceWithTypeParameter1?")!>x.funT() - & InterfaceWithTypeParameter1?")!>x.funAny() - & InterfaceWithTypeParameter1?")!>x.funNullableT() - & InterfaceWithTypeParameter1?")!>x.funNullableAny() - & InterfaceWithTypeParameter1?")!>x.ip1test1() + ? & InterfaceWithTypeParameter1")!>x + ? & InterfaceWithTypeParameter1")!>x.equals(null) + ? & InterfaceWithTypeParameter1")!>x.propT + ? & InterfaceWithTypeParameter1")!>x.propAny + ? & InterfaceWithTypeParameter1")!>x.propNullableT + ? & InterfaceWithTypeParameter1")!>x.propNullableAny + ? & InterfaceWithTypeParameter1")!>x.funT() + ? & InterfaceWithTypeParameter1")!>x.funAny() + ? & InterfaceWithTypeParameter1")!>x.funNullableT() + ? & InterfaceWithTypeParameter1")!>x.funNullableAny() + ? & InterfaceWithTypeParameter1")!>x.ip1test1() x.equals(null) @@ -1735,17 +1735,17 @@ fun > case_26(x: InterfaceWithTypeParameter1< // TESTCASE NUMBER: 27 fun > case_27(x: InterfaceWithTypeParameter1?) { if (x != null) { - & InterfaceWithTypeParameter1?")!>x - & InterfaceWithTypeParameter1?")!>x.equals(null) - & InterfaceWithTypeParameter1?")!>x.propT - & InterfaceWithTypeParameter1?")!>x.propAny - & InterfaceWithTypeParameter1?")!>x.propNullableT - & InterfaceWithTypeParameter1?")!>x.propNullableAny - & InterfaceWithTypeParameter1?")!>x.funT() - & InterfaceWithTypeParameter1?")!>x.funAny() - & InterfaceWithTypeParameter1?")!>x.funNullableT() - & InterfaceWithTypeParameter1?")!>x.funNullableAny() - & InterfaceWithTypeParameter1?")!>x.ip1test1() + ? & InterfaceWithTypeParameter1")!>x + ? & InterfaceWithTypeParameter1")!>x.equals(null) + ? & InterfaceWithTypeParameter1")!>x.propT + ? & InterfaceWithTypeParameter1")!>x.propAny + ? & InterfaceWithTypeParameter1")!>x.propNullableT + ? & InterfaceWithTypeParameter1")!>x.propNullableAny + ? & InterfaceWithTypeParameter1")!>x.funT() + ? & InterfaceWithTypeParameter1")!>x.funAny() + ? & InterfaceWithTypeParameter1")!>x.funNullableT() + ? & InterfaceWithTypeParameter1")!>x.funNullableAny() + ? & InterfaceWithTypeParameter1")!>x.ip1test1() x.equals(null) @@ -1807,17 +1807,17 @@ fun > case_27(x: InterfaceWithTypeParameter1< // TESTCASE NUMBER: 28 fun > case_28(x: InterfaceWithTypeParameter1?) { if (x != null) { - & InterfaceWithTypeParameter1?")!>x - & InterfaceWithTypeParameter1?")!>x.equals(null) - & InterfaceWithTypeParameter1?")!>x.propT - & InterfaceWithTypeParameter1?")!>x.propAny - & InterfaceWithTypeParameter1?")!>x.propNullableT - & InterfaceWithTypeParameter1?")!>x.propNullableAny - & InterfaceWithTypeParameter1?")!>x.funT() - & InterfaceWithTypeParameter1?")!>x.funAny() - & InterfaceWithTypeParameter1?")!>x.funNullableT() - & InterfaceWithTypeParameter1?")!>x.funNullableAny() - & InterfaceWithTypeParameter1?")!>x.ip1test1() + ? & InterfaceWithTypeParameter1")!>x + ? & InterfaceWithTypeParameter1")!>x.equals(null) + ? & InterfaceWithTypeParameter1")!>x.propT + ? & InterfaceWithTypeParameter1")!>x.propAny + ? & InterfaceWithTypeParameter1")!>x.propNullableT + ? & InterfaceWithTypeParameter1")!>x.propNullableAny + ? & InterfaceWithTypeParameter1")!>x.funT() + ? & InterfaceWithTypeParameter1")!>x.funAny() + ? & InterfaceWithTypeParameter1")!>x.funNullableT() + ? & InterfaceWithTypeParameter1")!>x.funNullableAny() + ? & InterfaceWithTypeParameter1")!>x.ip1test1() x.equals(null) @@ -1879,17 +1879,17 @@ fun > case_28(x: InterfaceWithTypeParamete // TESTCASE NUMBER: 29 fun > case_29(x: InterfaceWithTypeParameter1?) { if (x != null) { - & InterfaceWithTypeParameter1?")!>x - & InterfaceWithTypeParameter1?")!>x.equals(null) - & InterfaceWithTypeParameter1?")!>x.propT - & InterfaceWithTypeParameter1?")!>x.propAny - & InterfaceWithTypeParameter1?")!>x.propNullableT - & InterfaceWithTypeParameter1?")!>x.propNullableAny - & InterfaceWithTypeParameter1?")!>x.funT() - & InterfaceWithTypeParameter1?")!>x.funAny() - & InterfaceWithTypeParameter1?")!>x.funNullableT() - & InterfaceWithTypeParameter1?")!>x.funNullableAny() - & InterfaceWithTypeParameter1?")!>x.ip1test1() + ? & InterfaceWithTypeParameter1")!>x + ? & InterfaceWithTypeParameter1")!>x.equals(null) + ? & InterfaceWithTypeParameter1")!>x.propT + ? & InterfaceWithTypeParameter1")!>x.propAny + ? & InterfaceWithTypeParameter1")!>x.propNullableT + ? & InterfaceWithTypeParameter1")!>x.propNullableAny + ? & InterfaceWithTypeParameter1")!>x.funT() + ? & InterfaceWithTypeParameter1")!>x.funAny() + ? & InterfaceWithTypeParameter1")!>x.funNullableT() + ? & InterfaceWithTypeParameter1")!>x.funNullableAny() + ? & InterfaceWithTypeParameter1")!>x.ip1test1() x.equals(null) @@ -1951,17 +1951,17 @@ fun > case_29(x: InterfaceWithTypeParamet // TESTCASE NUMBER: 30 fun > case_30(x: InterfaceWithTypeParameter1?) { if (x != null) { - & InterfaceWithTypeParameter1?")!>x - & InterfaceWithTypeParameter1?")!>x.equals(null) - & InterfaceWithTypeParameter1?")!>x.propT - & InterfaceWithTypeParameter1?")!>x.propAny - & InterfaceWithTypeParameter1?")!>x.propNullableT - & InterfaceWithTypeParameter1?")!>x.propNullableAny - & InterfaceWithTypeParameter1?")!>x.funT() - & InterfaceWithTypeParameter1?")!>x.funAny() - & InterfaceWithTypeParameter1?")!>x.funNullableT() - & InterfaceWithTypeParameter1?")!>x.funNullableAny() - & InterfaceWithTypeParameter1?")!>x.ip1test1() + ? & InterfaceWithTypeParameter1")!>x + ? & InterfaceWithTypeParameter1")!>x.equals(null) + ? & InterfaceWithTypeParameter1")!>x.propT + ? & InterfaceWithTypeParameter1")!>x.propAny + ? & InterfaceWithTypeParameter1")!>x.propNullableT + ? & InterfaceWithTypeParameter1")!>x.propNullableAny + ? & InterfaceWithTypeParameter1")!>x.funT() + ? & InterfaceWithTypeParameter1")!>x.funAny() + ? & InterfaceWithTypeParameter1")!>x.funNullableT() + ? & InterfaceWithTypeParameter1")!>x.funNullableAny() + ? & InterfaceWithTypeParameter1")!>x.ip1test1() x.equals(null) @@ -2023,17 +2023,17 @@ fun > case_30(x: InterfaceWithTypeParamete // TESTCASE NUMBER: 31 fun > case_31(x: InterfaceWithTypeParameter1?) { if (x != null) { - & InterfaceWithTypeParameter1?")!>x - & InterfaceWithTypeParameter1?")!>x.equals(null) - & InterfaceWithTypeParameter1?")!>x.propT - & InterfaceWithTypeParameter1?")!>x.propAny - & InterfaceWithTypeParameter1?")!>x.propNullableT - & InterfaceWithTypeParameter1?")!>x.propNullableAny - & InterfaceWithTypeParameter1?")!>x.funT() - & InterfaceWithTypeParameter1?")!>x.funAny() - & InterfaceWithTypeParameter1?")!>x.funNullableT() - & InterfaceWithTypeParameter1?")!>x.funNullableAny() - & InterfaceWithTypeParameter1?")!>x.ip1test1() + ? & InterfaceWithTypeParameter1")!>x + ? & InterfaceWithTypeParameter1")!>x.equals(null) + ? & InterfaceWithTypeParameter1")!>x.propT + ? & InterfaceWithTypeParameter1")!>x.propAny + ? & InterfaceWithTypeParameter1")!>x.propNullableT + ? & InterfaceWithTypeParameter1")!>x.propNullableAny + ? & InterfaceWithTypeParameter1")!>x.funT() + ? & InterfaceWithTypeParameter1")!>x.funAny() + ? & InterfaceWithTypeParameter1")!>x.funNullableT() + ? & InterfaceWithTypeParameter1")!>x.funNullableAny() + ? & InterfaceWithTypeParameter1")!>x.ip1test1() x.equals(null) @@ -2095,17 +2095,17 @@ fun > case_31(x: InterfaceWithTypeParamet // TESTCASE NUMBER: 32 fun case_32(x: Map?) { if (x != null) { - & kotlin.collections.Map?")!>x - & kotlin.collections.Map?")!>x.equals(null) - & kotlin.collections.Map?")!>x.propT - & kotlin.collections.Map?")!>x.propAny - & kotlin.collections.Map?")!>x.propNullableT - & kotlin.collections.Map?")!>x.propNullableAny - & kotlin.collections.Map?")!>x.funT() - & kotlin.collections.Map?")!>x.funAny() - & kotlin.collections.Map?")!>x.funNullableT() - & kotlin.collections.Map?")!>x.funNullableAny() - & kotlin.collections.Map?")!>x.isEmpty() + ? & kotlin.collections.Map")!>x + ? & kotlin.collections.Map")!>x.equals(null) + ? & kotlin.collections.Map")!>x.propT + ? & kotlin.collections.Map")!>x.propAny + ? & kotlin.collections.Map")!>x.propNullableT + ? & kotlin.collections.Map")!>x.propNullableAny + ? & kotlin.collections.Map")!>x.funT() + ? & kotlin.collections.Map")!>x.funAny() + ? & kotlin.collections.Map")!>x.funNullableT() + ? & kotlin.collections.Map")!>x.funNullableAny() + ? & kotlin.collections.Map")!>x.isEmpty() x.equals(null) @@ -2167,17 +2167,17 @@ fun case_32(x: Map?) { // TESTCASE NUMBER: 33 fun case_33(x: InterfaceWithFiveTypeParameters1?) { if (x != null) { - & InterfaceWithFiveTypeParameters1?")!>x - & InterfaceWithFiveTypeParameters1?")!>x.equals(null) - & InterfaceWithFiveTypeParameters1?")!>x.propT - & InterfaceWithFiveTypeParameters1?")!>x.propAny - & InterfaceWithFiveTypeParameters1?")!>x.propNullableT - & InterfaceWithFiveTypeParameters1?")!>x.propNullableAny - & InterfaceWithFiveTypeParameters1?")!>x.funT() - & InterfaceWithFiveTypeParameters1?")!>x.funAny() - & InterfaceWithFiveTypeParameters1?")!>x.funNullableT() - & InterfaceWithFiveTypeParameters1?")!>x.funNullableAny() - & InterfaceWithFiveTypeParameters1?")!>x.itest() + ? & InterfaceWithFiveTypeParameters1")!>x + ? & InterfaceWithFiveTypeParameters1")!>x.equals(null) + ? & InterfaceWithFiveTypeParameters1")!>x.propT + ? & InterfaceWithFiveTypeParameters1")!>x.propAny + ? & InterfaceWithFiveTypeParameters1")!>x.propNullableT + ? & InterfaceWithFiveTypeParameters1")!>x.propNullableAny + ? & InterfaceWithFiveTypeParameters1")!>x.funT() + ? & InterfaceWithFiveTypeParameters1")!>x.funAny() + ? & InterfaceWithFiveTypeParameters1")!>x.funNullableT() + ? & InterfaceWithFiveTypeParameters1")!>x.funNullableAny() + ? & InterfaceWithFiveTypeParameters1")!>x.itest() x.equals(null) @@ -2239,17 +2239,17 @@ fun case_33(x: InterfaceWithFiveTypeParameters1?) { // TESTCASE NUMBER: 34 fun case_34(x: InterfaceWithTypeParameter1?) { if (x != null) { - & InterfaceWithTypeParameter1?")!>x - & InterfaceWithTypeParameter1?")!>x.equals(null) - & InterfaceWithTypeParameter1?")!>x.propT - & InterfaceWithTypeParameter1?")!>x.propAny - & InterfaceWithTypeParameter1?")!>x.propNullableT - & InterfaceWithTypeParameter1?")!>x.propNullableAny - & InterfaceWithTypeParameter1?")!>x.funT() - & InterfaceWithTypeParameter1?")!>x.funAny() - & InterfaceWithTypeParameter1?")!>x.funNullableT() - & InterfaceWithTypeParameter1?")!>x.funNullableAny() - & InterfaceWithTypeParameter1?")!>x.ip1test1() + ? & InterfaceWithTypeParameter1")!>x + ? & InterfaceWithTypeParameter1")!>x.equals(null) + ? & InterfaceWithTypeParameter1")!>x.propT + ? & InterfaceWithTypeParameter1")!>x.propAny + ? & InterfaceWithTypeParameter1")!>x.propNullableT + ? & InterfaceWithTypeParameter1")!>x.propNullableAny + ? & InterfaceWithTypeParameter1")!>x.funT() + ? & InterfaceWithTypeParameter1")!>x.funAny() + ? & InterfaceWithTypeParameter1")!>x.funNullableT() + ? & InterfaceWithTypeParameter1")!>x.funNullableAny() + ? & InterfaceWithTypeParameter1")!>x.ip1test1() x.equals(null) @@ -2311,17 +2311,17 @@ fun case_34(x: InterfaceWithTypeParameter1?) { // TESTCASE NUMBER: 35 fun case_35(x: InterfaceWithTypeParameter1?) { if (x != null) { - & InterfaceWithTypeParameter1?")!>x - & InterfaceWithTypeParameter1?")!>x.equals(null) - & InterfaceWithTypeParameter1?")!>x.propT - & InterfaceWithTypeParameter1?")!>x.propAny - & InterfaceWithTypeParameter1?")!>x.propNullableT - & InterfaceWithTypeParameter1?")!>x.propNullableAny - & InterfaceWithTypeParameter1?")!>x.funT() - & InterfaceWithTypeParameter1?")!>x.funAny() - & InterfaceWithTypeParameter1?")!>x.funNullableT() - & InterfaceWithTypeParameter1?")!>x.funNullableAny() - & InterfaceWithTypeParameter1?")!>x.ip1test1() + ? & InterfaceWithTypeParameter1")!>x + ? & InterfaceWithTypeParameter1")!>x.equals(null) + ? & InterfaceWithTypeParameter1")!>x.propT + ? & InterfaceWithTypeParameter1")!>x.propAny + ? & InterfaceWithTypeParameter1")!>x.propNullableT + ? & InterfaceWithTypeParameter1")!>x.propNullableAny + ? & InterfaceWithTypeParameter1")!>x.funT() + ? & InterfaceWithTypeParameter1")!>x.funAny() + ? & InterfaceWithTypeParameter1")!>x.funNullableT() + ? & InterfaceWithTypeParameter1")!>x.funNullableAny() + ? & InterfaceWithTypeParameter1")!>x.ip1test1() x.equals(null) @@ -2383,17 +2383,17 @@ fun case_35(x: InterfaceWithTypeParameter1?) { // TESTCASE NUMBER: 36 fun case_36(x: InterfaceWithTypeParameter1?) { if (x != null) { - & InterfaceWithTypeParameter1?")!>x - & InterfaceWithTypeParameter1?")!>x.equals(null) - & InterfaceWithTypeParameter1?")!>x.propT - & InterfaceWithTypeParameter1?")!>x.propAny - & InterfaceWithTypeParameter1?")!>x.propNullableT - & InterfaceWithTypeParameter1?")!>x.propNullableAny - & InterfaceWithTypeParameter1?")!>x.funT() - & InterfaceWithTypeParameter1?")!>x.funAny() - & InterfaceWithTypeParameter1?")!>x.funNullableT() - & InterfaceWithTypeParameter1?")!>x.funNullableAny() - & InterfaceWithTypeParameter1?")!>x.ip1test1() + ? & InterfaceWithTypeParameter1")!>x + ? & InterfaceWithTypeParameter1")!>x.equals(null) + ? & InterfaceWithTypeParameter1")!>x.propT + ? & InterfaceWithTypeParameter1")!>x.propAny + ? & InterfaceWithTypeParameter1")!>x.propNullableT + ? & InterfaceWithTypeParameter1")!>x.propNullableAny + ? & InterfaceWithTypeParameter1")!>x.funT() + ? & InterfaceWithTypeParameter1")!>x.funAny() + ? & InterfaceWithTypeParameter1")!>x.funNullableT() + ? & InterfaceWithTypeParameter1")!>x.funNullableAny() + ? & InterfaceWithTypeParameter1")!>x.ip1test1() x.equals(null) @@ -2455,17 +2455,17 @@ fun case_36(x: InterfaceWithTypeParameter1?) { // TESTCASE NUMBER: 37 fun case_37(x: Map?) { if (x != null) { - & kotlin.collections.Map?")!>x - & kotlin.collections.Map?")!>x.equals(null) - & kotlin.collections.Map?")!>x.propT - & kotlin.collections.Map?")!>x.propAny - & kotlin.collections.Map?")!>x.propNullableT - & kotlin.collections.Map?")!>x.propNullableAny - & kotlin.collections.Map?")!>x.funT() - & kotlin.collections.Map?")!>x.funAny() - & kotlin.collections.Map?")!>x.funNullableT() - & kotlin.collections.Map?")!>x.funNullableAny() - & kotlin.collections.Map?")!>x.isEmpty() + ? & kotlin.collections.Map")!>x + ? & kotlin.collections.Map")!>x.equals(null) + ? & kotlin.collections.Map")!>x.propT + ? & kotlin.collections.Map")!>x.propAny + ? & kotlin.collections.Map")!>x.propNullableT + ? & kotlin.collections.Map")!>x.propNullableAny + ? & kotlin.collections.Map")!>x.funT() + ? & kotlin.collections.Map")!>x.funAny() + ? & kotlin.collections.Map")!>x.funNullableT() + ? & kotlin.collections.Map")!>x.funNullableAny() + ? & kotlin.collections.Map")!>x.isEmpty() x.equals(null) @@ -2527,17 +2527,17 @@ fun case_37(x: Map?) { // TESTCASE NUMBER: 38 fun case_38(x: Map<*, out T>?) { if (x != null) { - & kotlin.collections.Map<*, out T>?")!>x - & kotlin.collections.Map<*, out T>?")!>x.equals(null) - & kotlin.collections.Map<*, out T>?")!>x.propT - & kotlin.collections.Map<*, out T>?")!>x.propAny - & kotlin.collections.Map<*, out T>?")!>x.propNullableT - & kotlin.collections.Map<*, out T>?")!>x.propNullableAny - & kotlin.collections.Map<*, out T>?")!>x.funT() - & kotlin.collections.Map<*, out T>?")!>x.funAny() - & kotlin.collections.Map<*, out T>?")!>x.funNullableT() - & kotlin.collections.Map<*, out T>?")!>x.funNullableAny() - & kotlin.collections.Map<*, out T>?")!>x.isEmpty() + ? & kotlin.collections.Map<*, out T>")!>x + ? & kotlin.collections.Map<*, out T>")!>x.equals(null) + ? & kotlin.collections.Map<*, out T>")!>x.propT + ? & kotlin.collections.Map<*, out T>")!>x.propAny + ? & kotlin.collections.Map<*, out T>")!>x.propNullableT + ? & kotlin.collections.Map<*, out T>")!>x.propNullableAny + ? & kotlin.collections.Map<*, out T>")!>x.funT() + ? & kotlin.collections.Map<*, out T>")!>x.funAny() + ? & kotlin.collections.Map<*, out T>")!>x.funNullableT() + ? & kotlin.collections.Map<*, out T>")!>x.funNullableAny() + ? & kotlin.collections.Map<*, out T>")!>x.isEmpty() x.equals(null) @@ -2599,16 +2599,16 @@ fun case_38(x: Map<*, out T>?) { // TESTCASE NUMBER: 39 fun case_39(x: InterfaceWithTwoTypeParameters?) { if (x != null) { - & InterfaceWithTwoTypeParameters?")!>x - & InterfaceWithTwoTypeParameters?")!>x.equals(null) - & InterfaceWithTwoTypeParameters?")!>x.propT - & InterfaceWithTwoTypeParameters?")!>x.propAny - & InterfaceWithTwoTypeParameters?")!>x.propNullableT - & InterfaceWithTwoTypeParameters?")!>x.propNullableAny - & InterfaceWithTwoTypeParameters?")!>x.funT() - & InterfaceWithTwoTypeParameters?")!>x.funAny() - & InterfaceWithTwoTypeParameters?")!>x.funNullableT() - & InterfaceWithTwoTypeParameters?")!>x.funNullableAny() + ? & InterfaceWithTwoTypeParameters")!>x + ? & InterfaceWithTwoTypeParameters")!>x.equals(null) + ? & InterfaceWithTwoTypeParameters")!>x.propT + ? & InterfaceWithTwoTypeParameters")!>x.propAny + ? & InterfaceWithTwoTypeParameters")!>x.propNullableT + ? & InterfaceWithTwoTypeParameters")!>x.propNullableAny + ? & InterfaceWithTwoTypeParameters")!>x.funT() + ? & InterfaceWithTwoTypeParameters")!>x.funAny() + ? & InterfaceWithTwoTypeParameters")!>x.funNullableT() + ? & InterfaceWithTwoTypeParameters")!>x.funNullableAny() x.equals(null) @@ -2666,16 +2666,16 @@ fun case_39(x: InterfaceWithTwoTypeParameters?) { // TESTCASE NUMBER: 40 fun case_40(x: InterfaceWithTwoTypeParameters?) { if (x != null) { - & InterfaceWithTwoTypeParameters?")!>x - & InterfaceWithTwoTypeParameters?")!>x.equals(null) - & InterfaceWithTwoTypeParameters?")!>x.propT - & InterfaceWithTwoTypeParameters?")!>x.propAny - & InterfaceWithTwoTypeParameters?")!>x.propNullableT - & InterfaceWithTwoTypeParameters?")!>x.propNullableAny - & InterfaceWithTwoTypeParameters?")!>x.funT() - & InterfaceWithTwoTypeParameters?")!>x.funAny() - & InterfaceWithTwoTypeParameters?")!>x.funNullableT() - & InterfaceWithTwoTypeParameters?")!>x.funNullableAny() + ? & InterfaceWithTwoTypeParameters")!>x + ? & InterfaceWithTwoTypeParameters")!>x.equals(null) + ? & InterfaceWithTwoTypeParameters")!>x.propT + ? & InterfaceWithTwoTypeParameters")!>x.propAny + ? & InterfaceWithTwoTypeParameters")!>x.propNullableT + ? & InterfaceWithTwoTypeParameters")!>x.propNullableAny + ? & InterfaceWithTwoTypeParameters")!>x.funT() + ? & InterfaceWithTwoTypeParameters")!>x.funAny() + ? & InterfaceWithTwoTypeParameters")!>x.funNullableT() + ? & InterfaceWithTwoTypeParameters")!>x.funNullableAny() x.equals(null) @@ -2733,17 +2733,17 @@ fun case_40(x: InterfaceWithTwoTypeParameters?) { // TESTCASE NUMBER: 41 fun case_41(x: Map?) { if (x != null) { - & kotlin.collections.Map?")!>x - & kotlin.collections.Map?")!>x.equals(null) - & kotlin.collections.Map?")!>x.propT - & kotlin.collections.Map?")!>x.propAny - & kotlin.collections.Map?")!>x.propNullableT - & kotlin.collections.Map?")!>x.propNullableAny - & kotlin.collections.Map?")!>x.funT() - & kotlin.collections.Map?")!>x.funAny() - & kotlin.collections.Map?")!>x.funNullableT() - & kotlin.collections.Map?")!>x.funNullableAny() - & kotlin.collections.Map?")!>x.isEmpty() + ? & kotlin.collections.Map")!>x + ? & kotlin.collections.Map")!>x.equals(null) + ? & kotlin.collections.Map")!>x.propT + ? & kotlin.collections.Map")!>x.propAny + ? & kotlin.collections.Map")!>x.propNullableT + ? & kotlin.collections.Map")!>x.propNullableAny + ? & kotlin.collections.Map")!>x.funT() + ? & kotlin.collections.Map")!>x.funAny() + ? & kotlin.collections.Map")!>x.funNullableT() + ? & kotlin.collections.Map")!>x.funNullableAny() + ? & kotlin.collections.Map")!>x.isEmpty() x.equals(null) @@ -2805,17 +2805,17 @@ fun case_41(x: Map?) { // TESTCASE NUMBER: 42 fun case_42(x: Map?) { if (x != null) { - & kotlin.collections.Map?")!>x - & kotlin.collections.Map?")!>x.equals(null) - & kotlin.collections.Map?")!>x.propT - & kotlin.collections.Map?")!>x.propAny - & kotlin.collections.Map?")!>x.propNullableT - & kotlin.collections.Map?")!>x.propNullableAny - & kotlin.collections.Map?")!>x.funT() - & kotlin.collections.Map?")!>x.funAny() - & kotlin.collections.Map?")!>x.funNullableT() - & kotlin.collections.Map?")!>x.funNullableAny() - & kotlin.collections.Map?")!>x.isEmpty() + ? & kotlin.collections.Map")!>x + ? & kotlin.collections.Map")!>x.equals(null) + ? & kotlin.collections.Map")!>x.propT + ? & kotlin.collections.Map")!>x.propAny + ? & kotlin.collections.Map")!>x.propNullableT + ? & kotlin.collections.Map")!>x.propNullableAny + ? & kotlin.collections.Map")!>x.funT() + ? & kotlin.collections.Map")!>x.funAny() + ? & kotlin.collections.Map")!>x.funNullableT() + ? & kotlin.collections.Map")!>x.funNullableAny() + ? & kotlin.collections.Map")!>x.isEmpty() x.equals(null) @@ -2877,17 +2877,17 @@ fun case_42(x: Map?) { // TESTCASE NUMBER: 43 fun case_43(x: Map?) { if (x != null) { - & kotlin.collections.Map?")!>x - & kotlin.collections.Map?")!>x.equals(null) - & kotlin.collections.Map?")!>x.propT - & kotlin.collections.Map?")!>x.propAny - & kotlin.collections.Map?")!>x.propNullableT - & kotlin.collections.Map?")!>x.propNullableAny - & kotlin.collections.Map?")!>x.funT() - & kotlin.collections.Map?")!>x.funAny() - & kotlin.collections.Map?")!>x.funNullableT() - & kotlin.collections.Map?")!>x.funNullableAny() - & kotlin.collections.Map?")!>x.isEmpty() + ? & kotlin.collections.Map")!>x + ? & kotlin.collections.Map")!>x.equals(null) + ? & kotlin.collections.Map")!>x.propT + ? & kotlin.collections.Map")!>x.propAny + ? & kotlin.collections.Map")!>x.propNullableT + ? & kotlin.collections.Map")!>x.propNullableAny + ? & kotlin.collections.Map")!>x.funT() + ? & kotlin.collections.Map")!>x.funAny() + ? & kotlin.collections.Map")!>x.funNullableT() + ? & kotlin.collections.Map")!>x.funNullableAny() + ? & kotlin.collections.Map")!>x.isEmpty() x.equals(null) @@ -2949,17 +2949,17 @@ fun case_43(x: Map?) { // TESTCASE NUMBER: 44 fun case_44(x: InterfaceWithFiveTypeParameters1?) { if (x != null) { - & InterfaceWithFiveTypeParameters1?")!>x - & InterfaceWithFiveTypeParameters1?")!>x.equals(null) - & InterfaceWithFiveTypeParameters1?")!>x.propT - & InterfaceWithFiveTypeParameters1?")!>x.propAny - & InterfaceWithFiveTypeParameters1?")!>x.propNullableT - & InterfaceWithFiveTypeParameters1?")!>x.propNullableAny - & InterfaceWithFiveTypeParameters1?")!>x.funT() - & InterfaceWithFiveTypeParameters1?")!>x.funAny() - & InterfaceWithFiveTypeParameters1?")!>x.funNullableT() - & InterfaceWithFiveTypeParameters1?")!>x.funNullableAny() - & InterfaceWithFiveTypeParameters1?")!>x.itest() + ? & InterfaceWithFiveTypeParameters1")!>x + ? & InterfaceWithFiveTypeParameters1")!>x.equals(null) + ? & InterfaceWithFiveTypeParameters1")!>x.propT + ? & InterfaceWithFiveTypeParameters1")!>x.propAny + ? & InterfaceWithFiveTypeParameters1")!>x.propNullableT + ? & InterfaceWithFiveTypeParameters1")!>x.propNullableAny + ? & InterfaceWithFiveTypeParameters1")!>x.funT() + ? & InterfaceWithFiveTypeParameters1")!>x.funAny() + ? & InterfaceWithFiveTypeParameters1")!>x.funNullableT() + ? & InterfaceWithFiveTypeParameters1")!>x.funNullableAny() + ? & InterfaceWithFiveTypeParameters1")!>x.itest() x.equals(null) @@ -3021,18 +3021,18 @@ fun case_44(x: InterfaceWithFiveTypeParameters1?) { // TESTCASE NUMBER: 45 fun case_45(x: T) where T : Number?, T: Comparable? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.toByte() - x.compareTo(x) + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.toByte() + x.compareTo(x) x.equals(null) @@ -3098,19 +3098,19 @@ fun case_45(x: T) where T : Number?, T: Comparable? { // TESTCASE NUMBER: 46 fun case_46(x: T) where T : CharSequence?, T: Comparable?, T: Iterable<*>? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.compareTo(x) - x.get(0) - x.iterator() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.compareTo(x) + x.get(0) + x.iterator() x.equals(null) @@ -3183,18 +3183,18 @@ fun case_46(x: T) where T : CharSequence?, T: Comparable?, T: Iterable<*> */ fun case_47(x: T?) where T : Inv, T: Comparable<*>?, T: InterfaceWithTypeParameter1? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test() + x.ip1test1() x.equals(null) @@ -3255,7 +3255,7 @@ fun case_47(x: T?) where T : Inv, T: Comparable<*>?, T: InterfaceWithType it.ip1test1() } - x.compareTo(return) + x.compareTo(return) x.compareTo(return) x.apply { @@ -3275,18 +3275,18 @@ fun case_47(x: T?) where T : Inv, T: Comparable<*>?, T: InterfaceWithType */ fun case_48(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test() + x.ip1test1() x.equals(null) @@ -3355,18 +3355,18 @@ fun case_48(x: T?) where T : Inv, T: InterfaceWithTypeParameter1 case_49(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test() + x.ip1test1() x.equals(null) @@ -3435,18 +3435,18 @@ fun case_49(x: T?) where T : Inv, T: InterfaceWithTypeParameter1 */ fun case_50(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test() + x.ip1test1() x.equals(null) @@ -3515,18 +3515,18 @@ fun case_50(x: T?) where T : Inv, T: InterfaceWithTypeParameter1 case_51(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test() + x.ip1test1() x.equals(null) @@ -3592,18 +3592,18 @@ fun case_51(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? // TESTCASE NUMBER: 52 fun case_52(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test() + x.ip1test1() x.equals(null) @@ -3672,18 +3672,18 @@ fun case_52(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? { */ fun case_53(x: T?) where T : Inv, T: InterfaceWithTypeParameter1<*>? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test() + x.ip1test1() x.equals(null) @@ -3752,18 +3752,18 @@ fun case_53(x: T?) where T : Inv, T: InterfaceWithTypeParameter1<*>? { */ fun case_54(x: T?) where T : Inv<*>, T: InterfaceWithTypeParameter1? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test() + x.ip1test1() x.equals(null) @@ -3829,18 +3829,18 @@ fun case_54(x: T?) where T : Inv<*>, T: InterfaceWithTypeParameter1? // TESTCASE NUMBER: 55 fun case_55(x: T?) where T : Inv<*>, T: InterfaceWithTypeParameter1? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test() + x.ip1test1() x.equals(null) @@ -3906,18 +3906,18 @@ fun case_55(x: T?) where T : Inv<*>, T: InterfaceWithTypeParameter1? { // TESTCASE NUMBER: 56 fun case_56(x: T) where T : Number?, T: Interface1? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.itest() - x.toByte() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.itest() + x.toByte() x.equals(null) @@ -4064,17 +4064,17 @@ fun case_57(x: T) where T : Out<*>?, T: Comparable { // TESTCASE NUMBER: 58 fun >>>>>>>>>?> case_59(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.ip1test1() x.equals(null) @@ -4139,19 +4139,19 @@ fun case_59(x: T) where T: InterfaceWithFiveTypeParameters1?, T: InterfaceWithFiveTypeParameters2?, T: InterfaceWithFiveTypeParameters3? { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.itest1() - x.itest2() - x.itest3() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.itest1() + x.itest2() + x.itest3() x.equals(null) @@ -4224,17 +4224,17 @@ fun case_59(x: T) where T: InterfaceWithFiveTypeParameters1?> case_60(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.ip1test1() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.ip1test1() x.equals(null) @@ -4305,10 +4305,10 @@ class Case61_3: InterfaceWithTypeParameter1, Case61_1, Case61_2 { fun T.case_61(x: T) where T : InterfaceWithTypeParameter1?, T: Case61_3?, T: Case61_1?, T: Case61_2? { if (x != null) { - x.ip1test1() - x.test2() - x.ip1test1() - x.test4() + x.ip1test1() + x.test2() + x.ip1test1() + x.test4() x.ip1test1() x.test2() @@ -4341,8 +4341,8 @@ fun T.case_61(x: T) where T : InterfaceWithTypeParameter1?, T: Case61_3 case_62(x: T) { if (x != null) { - x - x.hashCode() + x + x.hashCode() x.hashCode() x.apply { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt index da8354f4c68..30b8dec3d50 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt @@ -14,15 +14,15 @@ fun case_1(vararg x: Int?) { fun case_2(vararg x: Int?) { x[0].apply { if (this != null) { - this - this.inv() + this + this.inv() } } x[0].also { if (it != null) { - it - it.inv() + it + it.inv() } } } @@ -39,15 +39,15 @@ fun case_3(vararg x: T?) { fun case_4(vararg x: T?) { x[0].apply { if (this != null) { - this - this.toByte() + this + this.toByte() } } x[0].also { if (it != null) { - it - it.toByte() + it + it.toByte() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.fir.kt index 86675992589..6c011ad70cc 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.fir.kt @@ -10,19 +10,19 @@ fun case_1() { val a = select(Case1_1(), Case1_2(), null) if (a != null) { - & InterfaceWithTypeParameter1<*>?")!>a - val b = & InterfaceWithTypeParameter1<*>?")!>a.ip1test1() + ? & InterfaceWithTypeParameter1<*>")!>a + val b = ? & InterfaceWithTypeParameter1<*>")!>a.ip1test1() if (b != null) { - b - b.equals(null) - b.propT - b.propAny - b.propNullableT - b.propNullableAny - b.funT() - b.funAny() - b.funNullableT() - b.funNullableAny() + b + b.equals(null) + b.propT + b.propAny + b.propNullableT + b.propNullableAny + b.funT() + b.funAny() + b.funNullableT() + b.funNullableAny() } } } @@ -35,8 +35,8 @@ fun case_2() { val x = select(Case2_1(), Case2_2(), null) if (x != null) { - & Interface3? & InterfaceWithTypeParameter1<*>?")!>x - & Interface3? & InterfaceWithTypeParameter1<*>?")!>x.ip1test1() + ? & Interface3 & InterfaceWithTypeParameter1<*>")!>x + ? & Interface3 & InterfaceWithTypeParameter1<*>")!>x.ip1test1() } } @@ -48,9 +48,9 @@ fun case_3() { val x = select(Case3_1(), Case3_2(), null) if (x != null) { - & InterfaceWithTypeParameter2<*> & Interface3? & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x - & InterfaceWithTypeParameter2<*> & Interface3? & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x.ip1test1() - & InterfaceWithTypeParameter2<*> & Interface3? & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x.ip1test2() + ? & InterfaceWithTypeParameter2<*>? & Interface3 & InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>")!>x + ? & InterfaceWithTypeParameter2<*>? & Interface3 & InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>")!>x.ip1test1() + ? & InterfaceWithTypeParameter2<*>? & Interface3 & InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>")!>x.ip1test2() } } @@ -62,9 +62,9 @@ fun case_4() { val x = select(Case4_1(), Case4_2(), null) if (x != null) { - & InterfaceWithTypeParameter2<*> & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x - & InterfaceWithTypeParameter2<*> & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x.ip1test1() - & InterfaceWithTypeParameter2<*> & InterfaceWithTypeParameter1<*>? & InterfaceWithTypeParameter2<*>?")!>x.ip1test2() + ? & InterfaceWithTypeParameter2<*>? & InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>")!>x + ? & InterfaceWithTypeParameter2<*>? & InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>")!>x.ip1test1() + ? & InterfaceWithTypeParameter2<*>? & InterfaceWithTypeParameter1<*> & InterfaceWithTypeParameter2<*>")!>x.ip1test2() } } @@ -76,9 +76,9 @@ fun case_5() { val x = select(Case5_1(), Case5_2(), null) if (x != null) { - > & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter1>? & InterfaceWithTypeParameter2>?")!>x - > & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter1>? & InterfaceWithTypeParameter2>?")!>x.ip1test1() - > & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter1>? & InterfaceWithTypeParameter2>?")!>x.ip1test2() + >? & InterfaceWithTypeParameter2>? & InterfaceWithTypeParameter1> & InterfaceWithTypeParameter2>")!>x + >? & InterfaceWithTypeParameter2>? & InterfaceWithTypeParameter1> & InterfaceWithTypeParameter2>")!>x.ip1test1() + >? & InterfaceWithTypeParameter2>? & InterfaceWithTypeParameter1> & InterfaceWithTypeParameter2>")!>x.ip1test2() } } @@ -90,9 +90,9 @@ fun case_6() { val x = select(Case6_1(), Case6_2(), null) if (x != null) { - >> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>> & InterfaceWithTypeParameter1>>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>?")!>x - >> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>> & InterfaceWithTypeParameter1>>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>?")!>x.ip1test1() - >> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>> & InterfaceWithTypeParameter1>>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>?")!>x.ip1test2() + >>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>? & InterfaceWithTypeParameter1>> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>")!>x + >>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>? & InterfaceWithTypeParameter1>> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>")!>x.ip1test1() + >>? & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>? & InterfaceWithTypeParameter1>> & InterfaceWithTypeParameter2> & InterfaceWithTypeParameter2<*>>>")!>x.ip1test2() } } @@ -104,8 +104,8 @@ fun case_7() { val x = select(Case7_1(), Case7_2(), null) if (x != null) { - & java.io.Serializable>, out Inv & java.io.Serializable>> & InterfaceWithTwoTypeParameters & java.io.Serializable>, out Inv & java.io.Serializable>>?")!>x - & java.io.Serializable>, out Inv & java.io.Serializable>> & InterfaceWithTwoTypeParameters & java.io.Serializable>, out Inv & java.io.Serializable>>?")!>x.ip2test() + & java.io.Serializable>, out Inv & java.io.Serializable>>? & InterfaceWithTwoTypeParameters & java.io.Serializable>, out Inv & java.io.Serializable>>")!>x + & java.io.Serializable>, out Inv & java.io.Serializable>>? & InterfaceWithTwoTypeParameters & java.io.Serializable>, out Inv & java.io.Serializable>>")!>x.ip2test() } } @@ -117,24 +117,24 @@ fun case_8() { val x = select(Case8_1(), Case8_2(), null) if (x != null) { - & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable>?")!>x - & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable>?")!>x.test1() - val y = & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable>?")!>x.test2() + & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable>? & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable>")!>x + & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable>? & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable>")!>x.test1() + val y = & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable>? & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>, out kotlin.Comparable<*> & java.io.Serializable>")!>x.test2() if (y != null) { - & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>?")!>y - & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>?")!>y.test1() - val z = & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable> & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>?")!>y.test2() + & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>? & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>")!>y + & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>? & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>")!>y.test1() + val z = & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>? & ClassWithTwoTypeParameters & java.io.Serializable, out kotlin.Comparable<*> & java.io.Serializable>")!>y.test2() if (z != null) { - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.equals(null) - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.propT - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.propAny - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.propNullableT - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.propNullableAny - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.funT() - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.funAny() - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.funNullableT() - & java.io.Serializable & kotlin.Comparable<*>? & java.io.Serializable?")!>z.funNullableAny() + ? & java.io.Serializable? & kotlin.Comparable<*> & java.io.Serializable")!>z + ? & java.io.Serializable? & kotlin.Comparable<*> & java.io.Serializable")!>z.equals(null) + ? & java.io.Serializable? & kotlin.Comparable<*> & java.io.Serializable")!>z.propT + ? & java.io.Serializable? & kotlin.Comparable<*> & java.io.Serializable")!>z.propAny + ? & java.io.Serializable? & kotlin.Comparable<*> & java.io.Serializable")!>z.propNullableT + ? & java.io.Serializable? & kotlin.Comparable<*> & java.io.Serializable")!>z.propNullableAny + ? & java.io.Serializable? & kotlin.Comparable<*> & java.io.Serializable")!>z.funT() + ? & java.io.Serializable? & kotlin.Comparable<*> & java.io.Serializable")!>z.funAny() + ? & java.io.Serializable? & kotlin.Comparable<*> & java.io.Serializable")!>z.funNullableT() + ? & java.io.Serializable? & kotlin.Comparable<*> & java.io.Serializable")!>z.funNullableAny() } } } @@ -148,21 +148,21 @@ fun case_9() { val x = select(Case9_1(), Case9_2(), null) if (x != null) { - & ClassWithTwoTypeParameters<*, *>?")!>x - & ClassWithTwoTypeParameters<*, *>?")!>x.test1() + ? & ClassWithTwoTypeParameters<*, *>")!>x + ? & ClassWithTwoTypeParameters<*, *>")!>x.test1() val y = x.test2() if (y != null) { - y - y - y.equals(null) - y.propT - y.propAny - y.propNullableT - y.propNullableAny - y.funT() - y.funAny() - y.funNullableT() - y.funNullableAny() + y + y + y.equals(null) + y.propT + y.propAny + y.propNullableT + y.propNullableAny + y.funT() + y.funAny() + y.funNullableT() + y.funNullableAny() } } } @@ -175,15 +175,15 @@ fun case_10() = run { val x = select(object : Case10_1() {}, object : Case10_2() {}, null) if (x != null) { - > & Interface3? & InterfaceWithOutParameter>?")!>x - > & Interface3? & InterfaceWithOutParameter>?")!>x.equals(null) - > & Interface3? & InterfaceWithOutParameter>?")!>x.propT - > & Interface3? & InterfaceWithOutParameter>?")!>x.propAny - > & Interface3? & InterfaceWithOutParameter>?")!>x.propNullableT - > & Interface3? & InterfaceWithOutParameter>?")!>x.propNullableAny - > & Interface3? & InterfaceWithOutParameter>?")!>x.funT() - > & Interface3? & InterfaceWithOutParameter>?")!>x.funAny() - > & Interface3? & InterfaceWithOutParameter>?")!>x.funNullableT() - > & Interface3? & InterfaceWithOutParameter>?")!>x.funNullableAny() + >? & Interface3 & InterfaceWithOutParameter>")!>x + >? & Interface3 & InterfaceWithOutParameter>")!>x.equals(null) + >? & Interface3 & InterfaceWithOutParameter>")!>x.propT + >? & Interface3 & InterfaceWithOutParameter>")!>x.propAny + >? & Interface3 & InterfaceWithOutParameter>")!>x.propNullableT + >? & Interface3 & InterfaceWithOutParameter>")!>x.propNullableAny + >? & Interface3 & InterfaceWithOutParameter>")!>x.funT() + >? & Interface3 & InterfaceWithOutParameter>")!>x.funAny() + >? & Interface3 & InterfaceWithOutParameter>")!>x.funNullableT() + >? & Interface3 & InterfaceWithOutParameter>")!>x.funNullableAny() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/16.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/16.fir.kt index 09d9d05c8b6..22df4206a0d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/16.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/16.fir.kt @@ -5,45 +5,45 @@ // TESTCASE NUMBER: 1 fun case_1(x: Int?) { if (x == null) return - x - x.inv() + x + x.inv() } // TESTCASE NUMBER: 2 fun case_2(x: Unit?) { if (x === null) return - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 3 fun case_3(x: Nothing?) { if (x != null) else return - x - x.hashCode() + x + x.hashCode() } // TESTCASE NUMBER: 4 fun case_4(x: Number?) { if (x !== null) else { return } - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 5 @@ -116,76 +116,76 @@ fun case_9(x: String?) { // TESTCASE NUMBER: 10 fun case_10(x: Float?) { if (true && true && true && x !== null) else return - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 11 fun case_11(x: Out<*>?) { if (x == null) return - & Out<*>?")!>x - & Out<*>?")!>x.equals(null) - & Out<*>?")!>x.propT - & Out<*>?")!>x.propAny - & Out<*>?")!>x.propNullableT - & Out<*>?")!>x.propNullableAny - & Out<*>?")!>x.funT() - & Out<*>?")!>x.funAny() - & Out<*>?")!>x.funNullableT() - & Out<*>?")!>x.funNullableAny() + ? & Out<*>")!>x + ? & Out<*>")!>x.equals(null) + ? & Out<*>")!>x.propT + ? & Out<*>")!>x.propAny + ? & Out<*>")!>x.propNullableT + ? & Out<*>")!>x.propNullableAny + ? & Out<*>")!>x.funT() + ? & Out<*>")!>x.funAny() + ? & Out<*>")!>x.funNullableT() + ? & Out<*>")!>x.funNullableAny() } // TESTCASE NUMBER: 12 fun case_12(x: Map?) { if (x === null) return - & kotlin.collections.Map?")!>x - & kotlin.collections.Map?")!>x.equals(null) - & kotlin.collections.Map?")!>x.propT - & kotlin.collections.Map?")!>x.propAny - & kotlin.collections.Map?")!>x.propNullableT - & kotlin.collections.Map?")!>x.propNullableAny - & kotlin.collections.Map?")!>x.funT() - & kotlin.collections.Map?")!>x.funAny() - & kotlin.collections.Map?")!>x.funNullableT() - & kotlin.collections.Map?")!>x.funNullableAny() + ? & kotlin.collections.Map")!>x + ? & kotlin.collections.Map")!>x.equals(null) + ? & kotlin.collections.Map")!>x.propT + ? & kotlin.collections.Map")!>x.propAny + ? & kotlin.collections.Map")!>x.propNullableT + ? & kotlin.collections.Map")!>x.propNullableAny + ? & kotlin.collections.Map")!>x.funT() + ? & kotlin.collections.Map")!>x.funAny() + ? & kotlin.collections.Map")!>x.funNullableT() + ? & kotlin.collections.Map")!>x.funNullableAny() } // TESTCASE NUMBER: 13 fun case_13(x: Map?) { if (x != null) else return - & kotlin.collections.Map?")!>x - & kotlin.collections.Map?")!>x.equals(null) - & kotlin.collections.Map?")!>x.propT - & kotlin.collections.Map?")!>x.propAny - & kotlin.collections.Map?")!>x.propNullableT - & kotlin.collections.Map?")!>x.propNullableAny - & kotlin.collections.Map?")!>x.funT() - & kotlin.collections.Map?")!>x.funAny() - & kotlin.collections.Map?")!>x.funNullableT() - & kotlin.collections.Map?")!>x.funNullableAny() + ? & kotlin.collections.Map")!>x + ? & kotlin.collections.Map")!>x.equals(null) + ? & kotlin.collections.Map")!>x.propT + ? & kotlin.collections.Map")!>x.propAny + ? & kotlin.collections.Map")!>x.propNullableT + ? & kotlin.collections.Map")!>x.propNullableAny + ? & kotlin.collections.Map")!>x.funT() + ? & kotlin.collections.Map")!>x.funAny() + ? & kotlin.collections.Map")!>x.funNullableT() + ? & kotlin.collections.Map")!>x.funNullableAny() } // TESTCASE NUMBER: 14 fun case_14(x: MutableCollection?) { if (x !== null) else { return } - & kotlin.collections.MutableCollection?")!>x - & kotlin.collections.MutableCollection?")!>x.equals(null) - & kotlin.collections.MutableCollection?")!>x.propT - & kotlin.collections.MutableCollection?")!>x.propAny - & kotlin.collections.MutableCollection?")!>x.propNullableT - & kotlin.collections.MutableCollection?")!>x.propNullableAny - & kotlin.collections.MutableCollection?")!>x.funT() - & kotlin.collections.MutableCollection?")!>x.funAny() - & kotlin.collections.MutableCollection?")!>x.funNullableT() - & kotlin.collections.MutableCollection?")!>x.funNullableAny() + ? & kotlin.collections.MutableCollection")!>x + ? & kotlin.collections.MutableCollection")!>x.equals(null) + ? & kotlin.collections.MutableCollection")!>x.propT + ? & kotlin.collections.MutableCollection")!>x.propAny + ? & kotlin.collections.MutableCollection")!>x.propNullableT + ? & kotlin.collections.MutableCollection")!>x.propNullableAny + ? & kotlin.collections.MutableCollection")!>x.funT() + ? & kotlin.collections.MutableCollection")!>x.funAny() + ? & kotlin.collections.MutableCollection")!>x.funNullableT() + ? & kotlin.collections.MutableCollection")!>x.funNullableAny() } // TESTCASE NUMBER: 15 @@ -258,61 +258,61 @@ fun case_19(x: Inv>>>>>>?) { // TESTCASE NUMBER: 20 fun case_20(x: Inv>>>>>>?) { if (true && true && true && x !== null) else return - >>>>>> & Inv>>>>>>?")!>x - >>>>>> & Inv>>>>>>?")!>x.equals(null) - >>>>>> & Inv>>>>>>?")!>x.propT - >>>>>> & Inv>>>>>>?")!>x.propAny - >>>>>> & Inv>>>>>>?")!>x.propNullableT - >>>>>> & Inv>>>>>>?")!>x.propNullableAny - >>>>>> & Inv>>>>>>?")!>x.funT() - >>>>>> & Inv>>>>>>?")!>x.funAny() - >>>>>> & Inv>>>>>>?")!>x.funNullableT() - >>>>>> & Inv>>>>>>?")!>x.funNullableAny() + >>>>>>? & Inv>>>>>>")!>x + >>>>>>? & Inv>>>>>>")!>x.equals(null) + >>>>>>? & Inv>>>>>>")!>x.propT + >>>>>>? & Inv>>>>>>")!>x.propAny + >>>>>>? & Inv>>>>>>")!>x.propNullableT + >>>>>>? & Inv>>>>>>")!>x.propNullableAny + >>>>>>? & Inv>>>>>>")!>x.funT() + >>>>>>? & Inv>>>>>>")!>x.funAny() + >>>>>>? & Inv>>>>>>")!>x.funNullableT() + >>>>>>? & Inv>>>>>>")!>x.funNullableAny() } // TESTCASE NUMBER: 21 fun case_21(x: T) { if (x == null) return - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 22 fun case_22(x: T?) { if (x === null) return - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 23 fun case_23(x: Inv?) { if (x !== null) else return - & Inv?")!>x - & Inv?")!>x.equals(null) - & Inv?")!>x.propT - & Inv?")!>x.propAny - & Inv?")!>x.propNullableT - & Inv?")!>x.propNullableAny - & Inv?")!>x.funT() - & Inv?")!>x.funAny() - & Inv?")!>x.funNullableT() - & Inv?")!>x.funNullableAny() + ? & Inv")!>x + ? & Inv")!>x.equals(null) + ? & Inv")!>x.propT + ? & Inv")!>x.propAny + ? & Inv")!>x.propNullableT + ? & Inv")!>x.propNullableAny + ? & Inv")!>x.funT() + ? & Inv")!>x.funAny() + ? & Inv")!>x.funNullableT() + ? & Inv")!>x.funNullableAny() } // TESTCASE NUMBER: 24 @@ -334,8 +334,8 @@ fun case_24(x: Inv?, y: Nothing?) { fun case_25(x: Int?) { val x = (l@ { if (x == null) return@l - x - x.inv() + x + x.inv() })() } @@ -343,40 +343,40 @@ fun case_25(x: Int?) { fun case_26(x: Unit?, y: List<*>) { y.forEach l@ { if (x === null) return@l - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } // TESTCASE NUMBER: 27 fun case_27(x: Nothing?) = (l@ { if (x != null) else return@l - x - x.hashCode() + x + x.hashCode() })() // TESTCASE NUMBER: 28 fun case_28(x: Number?) { {(l@ { if (x !== null) else { return@l } - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() })()}() } @@ -467,28 +467,28 @@ fun case_33(x: Any?) { fun case_34(x: Float?) { (l@ { if (true && true && true && x !== null) else return@l - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() }).equals(l@ { if (true && true && true && x !== null) else return@l - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() }) } @@ -496,16 +496,16 @@ fun case_34(x: Float?) { fun case_35(x: Any?) { case_35 l@ { if (x == null) return@l - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -513,32 +513,32 @@ fun case_35(x: Any?) { fun case_36(x: Any?) { case_36 l@ { if (x === null) return@l - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } // TESTCASE NUMBER: 37 fun case_37(x: Any?): Any? = case_37 l@ { if (x === null) return@l - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 38 @@ -548,16 +548,16 @@ fun case_39(x: MutableCollection?) { if (x !== null) else { return@l2 } - & kotlin.collections.MutableCollection?")!>x - & kotlin.collections.MutableCollection?")!>x.equals(null) - & kotlin.collections.MutableCollection?")!>x.propT - & kotlin.collections.MutableCollection?")!>x.propAny - & kotlin.collections.MutableCollection?")!>x.propNullableT - & kotlin.collections.MutableCollection?")!>x.propNullableAny - & kotlin.collections.MutableCollection?")!>x.funT() - & kotlin.collections.MutableCollection?")!>x.funAny() - & kotlin.collections.MutableCollection?")!>x.funNullableT() - & kotlin.collections.MutableCollection?")!>x.funNullableAny() + ? & kotlin.collections.MutableCollection")!>x + ? & kotlin.collections.MutableCollection")!>x.equals(null) + ? & kotlin.collections.MutableCollection")!>x.propT + ? & kotlin.collections.MutableCollection")!>x.propAny + ? & kotlin.collections.MutableCollection")!>x.propNullableT + ? & kotlin.collections.MutableCollection")!>x.propNullableAny + ? & kotlin.collections.MutableCollection")!>x.funT() + ? & kotlin.collections.MutableCollection")!>x.funAny() + ? & kotlin.collections.MutableCollection")!>x.funNullableT() + ? & kotlin.collections.MutableCollection")!>x.funNullableAny() })() })() } @@ -643,16 +643,16 @@ fun case_43(x: Inv>>>>>>?): An fun case_44(x: Inv>>>>>>?) { (l@ { if (true && true && true && x !== null) else return@l - >>>>>> & Inv>>>>>>?")!>x - >>>>>> & Inv>>>>>>?")!>x.equals(null) - >>>>>> & Inv>>>>>>?")!>x.propT - >>>>>> & Inv>>>>>>?")!>x.propAny - >>>>>> & Inv>>>>>>?")!>x.propNullableT - >>>>>> & Inv>>>>>>?")!>x.propNullableAny - >>>>>> & Inv>>>>>>?")!>x.funT() - >>>>>> & Inv>>>>>>?")!>x.funAny() - >>>>>> & Inv>>>>>>?")!>x.funNullableT() - >>>>>> & Inv>>>>>>?")!>x.funNullableAny() + >>>>>>? & Inv>>>>>>")!>x + >>>>>>? & Inv>>>>>>")!>x.equals(null) + >>>>>>? & Inv>>>>>>")!>x.propT + >>>>>>? & Inv>>>>>>")!>x.propAny + >>>>>>? & Inv>>>>>>")!>x.propNullableT + >>>>>>? & Inv>>>>>>")!>x.propNullableAny + >>>>>>? & Inv>>>>>>")!>x.funT() + >>>>>>? & Inv>>>>>>")!>x.funAny() + >>>>>>? & Inv>>>>>>")!>x.funNullableT() + >>>>>>? & Inv>>>>>>")!>x.funNullableAny() }).invoke() } @@ -660,16 +660,16 @@ fun case_44(x: Inv>> fun case_45(x: T) { val y = (l@ { if (x == null) return@l - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() })() } @@ -677,16 +677,16 @@ fun case_45(x: T) { fun case_46(x: T?) { (l@ { if (x === null) return@l - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() })() } @@ -694,16 +694,16 @@ fun case_46(x: T?) { fun case_47(x: Inv?) { val y = l@ { if (x !== null) else return@l - & Inv?")!>x - & Inv?")!>x.equals(null) - & Inv?")!>x.propT - & Inv?")!>x.propAny - & Inv?")!>x.propNullableT - & Inv?")!>x.propNullableAny - & Inv?")!>x.funT() - & Inv?")!>x.funAny() - & Inv?")!>x.funNullableT() - & Inv?")!>x.funNullableAny() + ? & Inv")!>x + ? & Inv")!>x.equals(null) + ? & Inv")!>x.propT + ? & Inv")!>x.propAny + ? & Inv")!>x.propNullableT + ? & Inv")!>x.propNullableAny + ? & Inv")!>x.funT() + ? & Inv")!>x.funAny() + ? & Inv")!>x.funNullableT() + ? & Inv")!>x.funNullableAny() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/17.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/17.fir.kt index 51074a4fb91..c95a4d6dad6 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/17.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/17.fir.kt @@ -5,44 +5,44 @@ // TESTCASE NUMBER: 1 fun case_1(x: Int?) { if (x == null) throw Exception() - x - x.inv() + x + x.inv() } // TESTCASE NUMBER: 2 fun case_2(x: Unit?) { if (x === null) throw Exception() - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 3 fun case_3(x: Nothing?) { if (x != null) else throw Exception() - x + x } // TESTCASE NUMBER: 4 fun case_4(x: Number?) { if (x !== null) else { throw Exception() } - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 5 @@ -115,76 +115,76 @@ fun case_9(x: String?) { // TESTCASE NUMBER: 10 fun case_10(x: Float?) { if (true && true && true && x !== null) else throw Exception() - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 11 fun case_11(x: Out<*>?) { if (x == null) throw Exception() - & Out<*>?")!>x - & Out<*>?")!>x.equals(null) - & Out<*>?")!>x.propT - & Out<*>?")!>x.propAny - & Out<*>?")!>x.propNullableT - & Out<*>?")!>x.propNullableAny - & Out<*>?")!>x.funT() - & Out<*>?")!>x.funAny() - & Out<*>?")!>x.funNullableT() - & Out<*>?")!>x.funNullableAny() + ? & Out<*>")!>x + ? & Out<*>")!>x.equals(null) + ? & Out<*>")!>x.propT + ? & Out<*>")!>x.propAny + ? & Out<*>")!>x.propNullableT + ? & Out<*>")!>x.propNullableAny + ? & Out<*>")!>x.funT() + ? & Out<*>")!>x.funAny() + ? & Out<*>")!>x.funNullableT() + ? & Out<*>")!>x.funNullableAny() } // TESTCASE NUMBER: 12 fun case_12(x: Map?) { if (x === null) throw Exception() - & kotlin.collections.Map?")!>x - & kotlin.collections.Map?")!>x.equals(null) - & kotlin.collections.Map?")!>x.propT - & kotlin.collections.Map?")!>x.propAny - & kotlin.collections.Map?")!>x.propNullableT - & kotlin.collections.Map?")!>x.propNullableAny - & kotlin.collections.Map?")!>x.funT() - & kotlin.collections.Map?")!>x.funAny() - & kotlin.collections.Map?")!>x.funNullableT() - & kotlin.collections.Map?")!>x.funNullableAny() + ? & kotlin.collections.Map")!>x + ? & kotlin.collections.Map")!>x.equals(null) + ? & kotlin.collections.Map")!>x.propT + ? & kotlin.collections.Map")!>x.propAny + ? & kotlin.collections.Map")!>x.propNullableT + ? & kotlin.collections.Map")!>x.propNullableAny + ? & kotlin.collections.Map")!>x.funT() + ? & kotlin.collections.Map")!>x.funAny() + ? & kotlin.collections.Map")!>x.funNullableT() + ? & kotlin.collections.Map")!>x.funNullableAny() } // TESTCASE NUMBER: 13 fun case_13(x: Map?) { if (x != null) else throw Exception() - & kotlin.collections.Map?")!>x - & kotlin.collections.Map?")!>x.equals(null) - & kotlin.collections.Map?")!>x.propT - & kotlin.collections.Map?")!>x.propAny - & kotlin.collections.Map?")!>x.propNullableT - & kotlin.collections.Map?")!>x.propNullableAny - & kotlin.collections.Map?")!>x.funT() - & kotlin.collections.Map?")!>x.funAny() - & kotlin.collections.Map?")!>x.funNullableT() - & kotlin.collections.Map?")!>x.funNullableAny() + ? & kotlin.collections.Map")!>x + ? & kotlin.collections.Map")!>x.equals(null) + ? & kotlin.collections.Map")!>x.propT + ? & kotlin.collections.Map")!>x.propAny + ? & kotlin.collections.Map")!>x.propNullableT + ? & kotlin.collections.Map")!>x.propNullableAny + ? & kotlin.collections.Map")!>x.funT() + ? & kotlin.collections.Map")!>x.funAny() + ? & kotlin.collections.Map")!>x.funNullableT() + ? & kotlin.collections.Map")!>x.funNullableAny() } // TESTCASE NUMBER: 14 fun case_14(x: MutableCollection?) { if (x !== null) else { throw Exception() } - & kotlin.collections.MutableCollection?")!>x - & kotlin.collections.MutableCollection?")!>x.equals(null) - & kotlin.collections.MutableCollection?")!>x.propT - & kotlin.collections.MutableCollection?")!>x.propAny - & kotlin.collections.MutableCollection?")!>x.propNullableT - & kotlin.collections.MutableCollection?")!>x.propNullableAny - & kotlin.collections.MutableCollection?")!>x.funT() - & kotlin.collections.MutableCollection?")!>x.funAny() - & kotlin.collections.MutableCollection?")!>x.funNullableT() - & kotlin.collections.MutableCollection?")!>x.funNullableAny() + ? & kotlin.collections.MutableCollection")!>x + ? & kotlin.collections.MutableCollection")!>x.equals(null) + ? & kotlin.collections.MutableCollection")!>x.propT + ? & kotlin.collections.MutableCollection")!>x.propAny + ? & kotlin.collections.MutableCollection")!>x.propNullableT + ? & kotlin.collections.MutableCollection")!>x.propNullableAny + ? & kotlin.collections.MutableCollection")!>x.funT() + ? & kotlin.collections.MutableCollection")!>x.funAny() + ? & kotlin.collections.MutableCollection")!>x.funNullableT() + ? & kotlin.collections.MutableCollection")!>x.funNullableAny() } // TESTCASE NUMBER: 15 @@ -257,61 +257,61 @@ fun case_19(x: Inv>>>>>>?) { // TESTCASE NUMBER: 20 fun case_20(x: Inv>>>>>>?) { if (true && true && true && x !== null) else throw Exception() - >>>>>> & Inv>>>>>>?")!>x - >>>>>> & Inv>>>>>>?")!>x.equals(null) - >>>>>> & Inv>>>>>>?")!>x.propT - >>>>>> & Inv>>>>>>?")!>x.propAny - >>>>>> & Inv>>>>>>?")!>x.propNullableT - >>>>>> & Inv>>>>>>?")!>x.propNullableAny - >>>>>> & Inv>>>>>>?")!>x.funT() - >>>>>> & Inv>>>>>>?")!>x.funAny() - >>>>>> & Inv>>>>>>?")!>x.funNullableT() - >>>>>> & Inv>>>>>>?")!>x.funNullableAny() + >>>>>>? & Inv>>>>>>")!>x + >>>>>>? & Inv>>>>>>")!>x.equals(null) + >>>>>>? & Inv>>>>>>")!>x.propT + >>>>>>? & Inv>>>>>>")!>x.propAny + >>>>>>? & Inv>>>>>>")!>x.propNullableT + >>>>>>? & Inv>>>>>>")!>x.propNullableAny + >>>>>>? & Inv>>>>>>")!>x.funT() + >>>>>>? & Inv>>>>>>")!>x.funAny() + >>>>>>? & Inv>>>>>>")!>x.funNullableT() + >>>>>>? & Inv>>>>>>")!>x.funNullableAny() } // TESTCASE NUMBER: 21 fun case_21(x: T) { if (x == null) throw Exception() - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 22 fun case_22(x: T?) { if (x === null) throw Exception() - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } // TESTCASE NUMBER: 23 fun case_23(x: Inv?) { if (x !== null) else throw Exception() - & Inv?")!>x - & Inv?")!>x.equals(null) - & Inv?")!>x.propT - & Inv?")!>x.propAny - & Inv?")!>x.propNullableT - & Inv?")!>x.propNullableAny - & Inv?")!>x.funT() - & Inv?")!>x.funAny() - & Inv?")!>x.funNullableT() - & Inv?")!>x.funNullableAny() + ? & Inv")!>x + ? & Inv")!>x.equals(null) + ? & Inv")!>x.propT + ? & Inv")!>x.propAny + ? & Inv")!>x.propNullableT + ? & Inv")!>x.propNullableAny + ? & Inv")!>x.funT() + ? & Inv")!>x.funAny() + ? & Inv")!>x.funNullableT() + ? & Inv")!>x.funNullableAny() } // TESTCASE NUMBER: 24 diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt index 8a24df69d6c..9d52ae3f312 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt @@ -6,8 +6,8 @@ fun case_1(x: Int?) { while (true) { if (x == null) break - x - x.inv() + x + x.inv() } } @@ -15,16 +15,16 @@ fun case_1(x: Int?) { fun case_2(x: Unit?) { while (true) { if (x === null) continue - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -32,7 +32,7 @@ fun case_2(x: Unit?) { fun case_3(x: Nothing?, f: Boolean) { do { if (x != null) else break - x.hashCode() + x.hashCode() } while (f) } @@ -40,16 +40,16 @@ fun case_3(x: Nothing?, f: Boolean) { fun case_4(x: Number?) { for (i in 0..10) { if (x !== null) else { break } - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -143,16 +143,16 @@ fun case_10(x: Float?) { fun case_11(x: Out<*>?, list: List) { for (element in list) { if (x == null) continue - & Out<*>?")!>x - & Out<*>?")!>x.equals(null) - & Out<*>?")!>x.propT - & Out<*>?")!>x.propAny - & Out<*>?")!>x.propNullableT - & Out<*>?")!>x.propNullableAny - & Out<*>?")!>x.funT() - & Out<*>?")!>x.funAny() - & Out<*>?")!>x.funNullableT() - & Out<*>?")!>x.funNullableAny() + ? & Out<*>")!>x + ? & Out<*>")!>x.equals(null) + ? & Out<*>")!>x.propT + ? & Out<*>")!>x.propAny + ? & Out<*>")!>x.propNullableT + ? & Out<*>")!>x.propNullableAny + ? & Out<*>")!>x.funT() + ? & Out<*>")!>x.funAny() + ? & Out<*>")!>x.funNullableT() + ? & Out<*>")!>x.funNullableAny() } } @@ -160,8 +160,8 @@ fun case_11(x: Out<*>?, list: List) { fun case_12(list: List) { for (element in list) { if (element === null) continue - element - element.inv() + element + element.inv() } } @@ -169,16 +169,16 @@ fun case_12(list: List) { fun case_13(x: Map?) { do { if (x != null) else continue - & kotlin.collections.Map?")!>x - & kotlin.collections.Map?")!>x.equals(null) - & kotlin.collections.Map?")!>x.propT - & kotlin.collections.Map?")!>x.propAny - & kotlin.collections.Map?")!>x.propNullableT - & kotlin.collections.Map?")!>x.propNullableAny - & kotlin.collections.Map?")!>x.funT() - & kotlin.collections.Map?")!>x.funAny() - & kotlin.collections.Map?")!>x.funNullableT() - & kotlin.collections.Map?")!>x.funNullableAny() + ? & kotlin.collections.Map")!>x + ? & kotlin.collections.Map")!>x.equals(null) + ? & kotlin.collections.Map")!>x.propT + ? & kotlin.collections.Map")!>x.propAny + ? & kotlin.collections.Map")!>x.propNullableT + ? & kotlin.collections.Map")!>x.propNullableAny + ? & kotlin.collections.Map")!>x.funT() + ? & kotlin.collections.Map")!>x.funAny() + ? & kotlin.collections.Map")!>x.funNullableT() + ? & kotlin.collections.Map")!>x.funNullableAny() } while (false) } @@ -186,16 +186,16 @@ fun case_13(x: Map?) { fun case_14(x: MutableCollection?, r: IntRange) { for (i in r) { if (x !== null) else { break } - & kotlin.collections.MutableCollection?")!>x - & kotlin.collections.MutableCollection?")!>x.equals(null) - & kotlin.collections.MutableCollection?")!>x.propT - & kotlin.collections.MutableCollection?")!>x.propAny - & kotlin.collections.MutableCollection?")!>x.propNullableT - & kotlin.collections.MutableCollection?")!>x.propNullableAny - & kotlin.collections.MutableCollection?")!>x.funT() - & kotlin.collections.MutableCollection?")!>x.funAny() - & kotlin.collections.MutableCollection?")!>x.funNullableT() - & kotlin.collections.MutableCollection?")!>x.funNullableAny() + ? & kotlin.collections.MutableCollection")!>x + ? & kotlin.collections.MutableCollection")!>x.equals(null) + ? & kotlin.collections.MutableCollection")!>x.propT + ? & kotlin.collections.MutableCollection")!>x.propAny + ? & kotlin.collections.MutableCollection")!>x.propNullableT + ? & kotlin.collections.MutableCollection")!>x.propNullableAny + ? & kotlin.collections.MutableCollection")!>x.funT() + ? & kotlin.collections.MutableCollection")!>x.funAny() + ? & kotlin.collections.MutableCollection")!>x.funNullableT() + ? & kotlin.collections.MutableCollection")!>x.funNullableAny() } } @@ -287,26 +287,26 @@ fun case_19(map: MutableMap, y: Nothing?) { fun case_20(map: MutableMap) { for ((k, v) in map) { if (true && true && true && k !== null && v != null && true) else continue - k - k.equals(null) - k.propT - k.propAny - k.propNullableT - k.propNullableAny - k.funT() - k.funAny() - k.funNullableT() - k.funNullableAny() - v - v.equals(null) - v.propT - v.propAny - v.propNullableT - v.propNullableAny - v.funT() - v.funAny() - v.funNullableT() - v.funNullableAny() + k + k.equals(null) + k.propT + k.propAny + k.propNullableT + k.propNullableAny + k.funT() + k.funAny() + k.funNullableT() + k.funNullableAny() + v + v.equals(null) + v.propT + v.propAny + v.propNullableT + v.propNullableAny + v.funT() + v.funAny() + v.funNullableT() + v.funNullableAny() } } @@ -315,26 +315,26 @@ fun case_21(map: MutableMap) { for ((k, v) in map) { if (k == null) continue if (v === null || false) break - k - k.equals(null) - k.propT - k.propAny - k.propNullableT - k.propNullableAny - k.funT() - k.funAny() - k.funNullableT() - k.funNullableAny() - v - v.equals(null) - v.propT - v.propAny - v.propNullableT - v.propNullableAny - v.funT() - v.funAny() - v.funNullableT() - v.funNullableAny() + k + k.equals(null) + k.propT + k.propAny + k.propNullableT + k.propNullableAny + k.funT() + k.funAny() + k.funNullableT() + k.funNullableAny() + v + v.equals(null) + v.propT + v.propAny + v.propNullableT + v.propNullableAny + v.funT() + v.funAny() + v.funNullableT() + v.funNullableAny() } } @@ -342,16 +342,16 @@ fun case_21(map: MutableMap) { fun case_22(x: T?) { while (true) { if (x === null) break - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -359,16 +359,16 @@ fun case_22(x: T?) { fun case_23(x: Inv?) { for (i in -10..10) { if (x !== null) else continue - & Inv?")!>x - & Inv?")!>x.equals(null) - & Inv?")!>x.propT - & Inv?")!>x.propAny - & Inv?")!>x.propNullableT - & Inv?")!>x.propNullableAny - & Inv?")!>x.funT() - & Inv?")!>x.funAny() - & Inv?")!>x.funNullableT() - & Inv?")!>x.funNullableAny() + ? & Inv")!>x + ? & Inv")!>x.equals(null) + ? & Inv")!>x.propT + ? & Inv")!>x.propAny + ? & Inv")!>x.propNullableT + ? & Inv")!>x.propNullableAny + ? & Inv")!>x.funT() + ? & Inv")!>x.funAny() + ? & Inv")!>x.funNullableT() + ? & Inv")!>x.funNullableAny() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/19.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/19.fir.kt index 5489e3b118f..843dd80e246 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/19.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/19.fir.kt @@ -5,89 +5,89 @@ // TESTCASE NUMBER: 1 fun case_1(x: Any?) { if (x is Int) { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 2 fun case_2(x: Any) { if (x is Unit) { - x - x.toString() + x + x.toString() } } // TESTCASE NUMBER: 3 fun case_3(x: Any?) { if (x !is Class) else { - x - x.prop_1 + x + x.prop_1 } } // TESTCASE NUMBER: 4 fun case_4(x: Any) { if (x !is EnumClass) else { - x - x.fun_1() + x + x.fun_1() } } // TESTCASE NUMBER: 5 fun case_5(x: Any?) { if (!(x !is Class.NestedClass?)) { - x - x?.prop_4 + x + x?.prop_4 } } // TESTCASE NUMBER: 6 fun case_6(x: Any?) { if (!(x !is Object)) { - x - x.prop_1 + x + x.prop_1 } } // TESTCASE NUMBER: 7 fun case_7(x: Any) { if (!(x is DeepObject.A.B.C.D.E.F.G.J)) else { - x - x.prop_1 + x + x.prop_1 } } // TESTCASE NUMBER: 8 fun case_8(x: Any?) { if (!(x is Int?)) else { - x - x?.inv() + x + x?.inv() } } // TESTCASE NUMBER: 9 fun case_9(x: Any?) { if (!!(x !is TypealiasNullableStringIndirect?)) else { - x - x?.get(0) + x + x?.get(0) } } // TESTCASE NUMBER: 10 fun case_10(x: Any?) { if (!!(x !is Interface3)) else { - x - x.itest() - x.itest3() + x + x.itest() + x.itest3() } } // TESTCASE NUMBER: 11 fun case_11(x: Any?) { if (x is SealedMixedChildObject1?) { - x - x?.prop_1 - x?.prop_2 + x + x?.prop_1 + x?.prop_2 } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/2.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/2.fir.kt index 5dd3f3ab3e1..8f5762dbd85 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/2.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/2.fir.kt @@ -159,16 +159,16 @@ fun case_7(a: DeepObject.A.B.C.D.E.F.G.J?) { val g = false if (a != null && g) { - a - a.equals(null) - a.propT - a.propAny - a.propNullableT - a.propNullableAny - a.funT() - a.funAny() - a.funNullableT() - a.funNullableAny() + a + a.equals(null) + a.propT + a.propAny + a.propNullableT + a.propNullableAny + a.funT() + a.funAny() + a.funNullableT() + a.funNullableAny() } } @@ -229,16 +229,16 @@ fun case_9(x: Any?) { if (x == null || false || false || false || false || false || false) { } else { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -298,7 +298,7 @@ fun case_12(a: ((Float) -> Int?)?, b: Float?, c: Boolean?) { if (true && a == null == true || b == null == true) { } else { - val x = a(b) + val x = a(b) ?")!>a.equals(null) ?")!>a.propT ?")!>a.propAny @@ -308,28 +308,28 @@ fun case_12(a: ((Float) -> Int?)?, b: Float?, c: Boolean?) { ?")!>a.funAny() ?")!>a.funNullableT() ?")!>a.funNullableAny() - b.equals(null) - b.propT - b.propAny - b.propNullableT - b.propNullableAny - b.funT() - b.funAny() - b.funNullableT() - b.funNullableAny() + b.equals(null) + b.propT + b.propAny + b.propNullableT + b.propNullableAny + b.funT() + b.funAny() + b.funNullableT() + b.funNullableAny() if (x == null == true || (c != null && !c)) { } else { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -467,7 +467,7 @@ fun case_16(b: Boolean, c: Boolean?) { } // TESTCASE NUMBER: 17 -fun case_17(a: Int?, b: Int = if (a != null) a else 0) { +fun case_17(a: Int?, b: Int = if (a != null) a else 0) { a b b.equals(null) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/21.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/21.fir.kt index ae097c8456f..ba97a374d81 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/21.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/21.fir.kt @@ -5,8 +5,8 @@ // TESTCASE NUMBER: 1 fun case_1(x: Any?) { if (x is Int == true) { - x - x.inv() + x + x.inv() } } @@ -17,40 +17,40 @@ fun case_1(x: Any?) { */ fun case_2(x: Any) { if (x is Int === true) { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 3 fun case_3(x: Any?) { if (x !is Class == true == true == true == true == true) else { - x - x.prop_1 + x + x.prop_1 } } // TESTCASE NUMBER: 4 fun case_4(x: Any) { if (x !is EnumClass != false) else { - x - x.fun_1() + x + x.fun_1() } } // TESTCASE NUMBER: 5 fun case_5(x: Any?) { if (!(x !is Class.NestedClass?) != false == true) { - x - x?.prop_4 + x + x?.prop_4 } } // TESTCASE NUMBER: 6 fun case_6(x: Any?) { if (!(x !is Object) != false != false != false) { - x - x.prop_1 + x + x.prop_1 } } @@ -61,8 +61,8 @@ fun case_6(x: Any?) { */ fun case_7(x: Any) { if (!(x is DeepObject.A.B.C.D.E.F.G.J) !== false) else { - x - x.prop_1 + x + x.prop_1 } } @@ -73,8 +73,8 @@ fun case_7(x: Any) { */ fun case_8(x: Any?) { if (!(x is Int?) !== false !== false !== false) else { - x - x?.inv() + x + x?.inv() } } @@ -85,8 +85,8 @@ fun case_8(x: Any?) { */ fun case_9(x: Any?) { if (!!(x !is TypealiasNullableStringIndirect?) !== false === true) else { - x - x?.get(0) + x + x?.get(0) } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/22.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/22.fir.kt index d28ba6808ac..581c261d041 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/22.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/22.fir.kt @@ -6,8 +6,8 @@ fun case_1(x: Any?) { if (x is Int) { if (x !is Int) { - x - x.inv() + x + x.inv() } } } @@ -16,8 +16,8 @@ fun case_1(x: Any?) { fun case_2(x: Any) { if (x !is Unit) { if (x is Unit) { - x - x.toString() + x + x.toString() } } } @@ -26,8 +26,8 @@ fun case_2(x: Any) { fun case_3(x: Any?) { if (x !is Class) { if (x !is Class) else { - x - x.prop_1 + x + x.prop_1 } } } @@ -36,8 +36,8 @@ fun case_3(x: Any?) { fun case_4(x: Any) { if (x !is EnumClass) else { if (x !is EnumClass) { - x - x.fun_1() + x + x.fun_1() } } } @@ -46,8 +46,8 @@ fun case_4(x: Any) { fun case_5(x: Any?) { if (!(x !is Class.NestedClass?)) { if (!!(x !is Class.NestedClass?)) { - x - x?.prop_4 + x + x?.prop_4 } } } @@ -56,8 +56,8 @@ fun case_5(x: Any?) { fun case_6(x: Any?) { if (!(x is Object)) { if (!(x !is Object)) { - x - x.prop_1 + x + x.prop_1 } } } @@ -66,8 +66,8 @@ fun case_6(x: Any?) { fun case_7(x: Any) { if (!(x is DeepObject.A.B.C.D.E.F.G.J)) { if (!(x is DeepObject.A.B.C.D.E.F.G.J)) else { - x - x.prop_1 + x + x.prop_1 } } } @@ -76,8 +76,8 @@ fun case_7(x: Any) { fun case_8(x: Any?) { if (!!!!(x is Int?)) else { if (!(x is Int?)) else { - x - x?.inv() + x + x?.inv() } } } @@ -86,8 +86,8 @@ fun case_8(x: Any?) { fun case_9(x: Any?) { if (!!!(x !is TypealiasNullableStringIndirect?)) else { if (!!(x !is TypealiasNullableStringIndirect?)) else { - x - x?.get(0) + x + x?.get(0) } } } @@ -96,9 +96,9 @@ fun case_9(x: Any?) { fun case_10(x: Any?) { if (!!(x is Interface3)) else { if (!!(x !is Interface3)) else { - x - x.itest() - x.itest3() + x + x.itest() + x.itest3() } } } @@ -107,9 +107,9 @@ fun case_10(x: Any?) { fun case_11(x: Any?) { if (x is SealedMixedChildObject1?) { if (x is SealedMixedChildObject1?) { - x - x?.prop_1 - x?.prop_2 + x + x?.prop_1 + x?.prop_2 } } } @@ -118,7 +118,7 @@ fun case_11(x: Any?) { inline fun case_12(x: Any?) { if (x is T) { if (x is T is K) { - x + x } } } @@ -127,7 +127,7 @@ inline fun case_12(x: Any?) { inline fun case_13(x: Any?) { if (x is T) { if (x is K) { - x + x } } } @@ -136,7 +136,7 @@ inline fun case_13(x: Any?) { inline fun case_14(x: Any?) { if (x is T) { if (x !is T) { - x + x } } } @@ -145,7 +145,7 @@ inline fun case_14(x: Any?) { inline fun case_15(x: Any?) { if (x !is T) { if (x is T) { - x + x } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/23.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/23.fir.kt index cce4c0e55f0..afcff329124 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/23.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/23.fir.kt @@ -6,9 +6,9 @@ class Case1 { inline fun case_1(x: Any?) { if (x is T) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } } @@ -18,10 +18,10 @@ fun case_2() where T: CharSequence, T: Number { class Case1 where K : T { inline fun case_1(x: Any?) { if (x is T) { - x - x.toByte() - x.length - x.get(0) + x + x.toByte() + x.length + x.get(0) } } } @@ -32,10 +32,10 @@ fun case_3(x: Any?) where T: CharSequence, T: Number { class Case1 where K : T { inline fun case_1() { if (x is T) { - x - x.toByte() - x.length - x.get(0) + x + x.toByte() + x.length + x.get(0) } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/24.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/24.fir.kt index f576821b144..b01f2236ef5 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/24.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/24.fir.kt @@ -8,9 +8,9 @@ fun case_1(x: Any?) where T: CharSequence { class Case1 where K : T { inline fun case_1() { if (x is T) { - x.toByte() - x.length - x.get(0) + x.toByte() + x.length + x.get(0) } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/25.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/25.fir.kt index 22bca72ead5..fbcc4cc42e4 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/25.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/25.fir.kt @@ -14,13 +14,13 @@ open class Case1 { x as L x as K if (x is T) { - x - x.toByte() - x.length - x.get(0) - x.size - x.isEmpty() - x[null] + x + x.toByte() + x.length + x.get(0) + x.size + x.isEmpty() + x[null] } } } @@ -31,9 +31,9 @@ open class Case1 { inline fun case_2(x: Any?) { x as T if (x !is T) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } @@ -41,9 +41,9 @@ inline fun case_2(x: Any?) { inline fun case_3(x: Any?) { x as T? if (x is T) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } @@ -51,9 +51,9 @@ inline fun case_3(x: Any?) { inline fun case_4(x: Any?) { (x as? T)!! if (x is T?) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } @@ -61,9 +61,9 @@ inline fun case_4(x: Any?) { inline fun case_5(x: Any?) { if (x as? T != null) { if (x is T?) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/26.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/26.fir.kt index 22bca72ead5..fbcc4cc42e4 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/26.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/26.fir.kt @@ -14,13 +14,13 @@ open class Case1 { x as L x as K if (x is T) { - x - x.toByte() - x.length - x.get(0) - x.size - x.isEmpty() - x[null] + x + x.toByte() + x.length + x.get(0) + x.size + x.isEmpty() + x[null] } } } @@ -31,9 +31,9 @@ open class Case1 { inline fun case_2(x: Any?) { x as T if (x !is T) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } @@ -41,9 +41,9 @@ inline fun case_2(x: Any?) { inline fun case_3(x: Any?) { x as T? if (x is T) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } @@ -51,9 +51,9 @@ inline fun case_3(x: Any?) { inline fun case_4(x: Any?) { (x as? T)!! if (x is T?) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } @@ -61,9 +61,9 @@ inline fun case_4(x: Any?) { inline fun case_5(x: Any?) { if (x as? T != null) { if (x is T?) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/27.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/27.fir.kt index 22bca72ead5..fbcc4cc42e4 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/27.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/27.fir.kt @@ -14,13 +14,13 @@ open class Case1 { x as L x as K if (x is T) { - x - x.toByte() - x.length - x.get(0) - x.size - x.isEmpty() - x[null] + x + x.toByte() + x.length + x.get(0) + x.size + x.isEmpty() + x[null] } } } @@ -31,9 +31,9 @@ open class Case1 { inline fun case_2(x: Any?) { x as T if (x !is T) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } @@ -41,9 +41,9 @@ inline fun case_2(x: Any?) { inline fun case_3(x: Any?) { x as T? if (x is T) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } @@ -51,9 +51,9 @@ inline fun case_3(x: Any?) { inline fun case_4(x: Any?) { (x as? T)!! if (x is T?) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } @@ -61,9 +61,9 @@ inline fun case_4(x: Any?) { inline fun case_5(x: Any?) { if (x as? T != null) { if (x is T?) { - x - x.length - x.get(0) + x + x.length + x.get(0) } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/28.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/28.fir.kt index c80bf9ecb71..1f17fa4759c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/28.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/28.fir.kt @@ -5,72 +5,72 @@ // TESTCASE NUMBER: 1 fun case_1(x: Int?) { if (x?.inv() != null) { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 2 fun case_2(x: Int?) { if (x?.inv() == null) else if (true) {} else { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 3 fun case_3(x: Boolean?) { if (x?.not() == null) else { - x - x.not() + x + x.not() } } // TESTCASE NUMBER: 4 fun case_4(x: EnumClass?) { if (x?.fun_1() !== null) { - x - x.fun_1() + x + x.fun_1() } } // TESTCASE NUMBER: 5 fun case_5(x: Class.NestedClass?) { if (x?.prop_4 != null) { - x - x.prop_4 + x + x.prop_4 } } // TESTCASE NUMBER: 6 fun case_6(x: Class.NestedClass?) { if (!(x?.prop_4 == null)) { - x - x.prop_4 + x + x.prop_4 } } // TESTCASE NUMBER: 7 fun case_7(x: DeepObject.A.B.C.D.E.F.G.J?) { if (!!(x?.prop_1 != null)) { - x - x.prop_1 + x + x.prop_1 } } // TESTCASE NUMBER: 8 fun case_8(x: Any?) { if (x?.equals(10) === null) else { - x - x.equals(10) + x + x.equals(10) } } // TESTCASE NUMBER: 9 fun case_9(x: Any?) { if (x?.equals(10) !== null) { - x - x.equals(10) + x + x.equals(10) } } @@ -81,9 +81,9 @@ fun case_9(x: Any?) { */ fun case_10(x: Interface3?) { if (x?.itest() == null == true) else { - x - x.itest() - x.itest3() + x + x.itest() + x.itest3() } } @@ -94,41 +94,41 @@ fun case_10(x: Interface3?) { */ fun case_11(x: SealedMixedChildObject1?) { if (x?.prop_1 != null == true) { - x - x.prop_1 - x.prop_2 + x + x.prop_1 + x.prop_2 } } // TESTCASE NUMBER: 12 inline fun case_12(x: Any?) { if (x?.equals(10) != null) { - x - x.equals(10) + x + x.equals(10) } } // TESTCASE NUMBER: 13 inline fun case_13(x: Any?) { if (x?.equals(10) == null) {} else { - x - x.equals(10) + x + x.equals(10) } } // TESTCASE NUMBER: 14 inline fun case_14(x: Any?) { if (x?.equals(10) === null) else { - x - x.equals(10) + x + x.equals(10) } } // TESTCASE NUMBER: 15 inline fun case_15(x: Any?) { if (x?.equals(10) !== null) { - x - x.equals(10) + x + x.equals(10) } } @@ -139,8 +139,8 @@ inline fun case_15(x: Any?) { */ inline fun case_16(x: Any?) { if (x?.equals(10) === null == true) else { - x - x.equals(10) + x + x.equals(10) } } @@ -151,8 +151,8 @@ inline fun case_16(x: Any?) { */ inline fun case_17(x: Any?) { if (x?.equals(10) !== null == true) { - x - x.equals(10) + x + x.equals(10) } } @@ -163,8 +163,8 @@ inline fun case_17(x: Any?) { */ inline fun case_18(x: Any?) { if (x?.equals(10) === null === true) else { - x - x.equals(10) + x + x.equals(10) } } @@ -175,8 +175,8 @@ inline fun case_18(x: Any?) { */ inline fun case_19(x: Any?) { if (x?.equals(10) !== null === true) { - x - x.equals(10) + x + x.equals(10) } } @@ -187,8 +187,8 @@ inline fun case_19(x: Any?) { */ inline fun case_20(x: Any?) { if (x?.equals(10) === null !== false) else { - x - x.equals(10) + x + x.equals(10) } } @@ -199,8 +199,8 @@ inline fun case_20(x: Any?) { */ inline fun case_21(x: Any?) { if (x?.equals(10) !== null !== false) { - x - x.equals(10) + x + x.equals(10) } } @@ -211,8 +211,8 @@ inline fun case_21(x: Any?) { */ inline fun case_22(x: Any?) { if (x?.equals(10) !== null !== true) else { - x - x.equals(10) + x + x.equals(10) } } @@ -223,8 +223,8 @@ inline fun case_22(x: Any?) { */ inline fun case_23(x: Any?) { if (x?.equals(10) === null === false) { - x - x.equals(10) + x + x.equals(10) } } @@ -235,8 +235,8 @@ inline fun case_23(x: Any?) { */ inline fun case_24(x: Any?) { if (x?.equals(10) !== null != true) else { - x - x.equals(10) + x + x.equals(10) } } @@ -247,8 +247,8 @@ inline fun case_24(x: Any?) { */ inline fun case_25(x: Any?) { if (x?.equals(10) === null == false) { - x - x.equals(10) + x + x.equals(10) } } @@ -259,8 +259,8 @@ inline fun case_25(x: Any?) { */ inline fun case_26(x: Any?) { if (x?.equals(10) != null === false) else { - x - x.equals(10) + x + x.equals(10) } } @@ -271,8 +271,8 @@ inline fun case_26(x: Any?) { */ inline fun case_27(x: Any?) { if (x?.equals(10) == null === false) { - x - x.equals(10) + x + x.equals(10) } } @@ -283,8 +283,8 @@ inline fun case_27(x: Any?) { */ inline fun case_28(x: Any?) { if (x?.equals(10) != null == false) else { - x - x.equals(10) + x + x.equals(10) } } @@ -295,8 +295,8 @@ inline fun case_28(x: Any?) { */ inline fun case_29(x: Any?) { if (x?.equals(10) == null == false) { - x - x.equals(10) + x + x.equals(10) } } @@ -307,8 +307,8 @@ inline fun case_29(x: Any?) { */ fun case_30(x: Class.NestedClass?) { if (x?.prop_4 != null == true) { - x - x.prop_4 + x + x.prop_4 } } @@ -319,8 +319,8 @@ fun case_30(x: Class.NestedClass?) { */ fun case_31(x: Class.NestedClass?) { if (!(x?.prop_4 == null) != false) { - x - x.prop_4 + x + x.prop_4 } } @@ -331,8 +331,8 @@ fun case_31(x: Class.NestedClass?) { */ fun case_32(x: Class.NestedClass?) { if (x?.prop_4 == null == false) { - x - x.prop_4 + x + x.prop_4 } } @@ -343,7 +343,7 @@ fun case_32(x: Class.NestedClass?) { */ fun case_33(x: Class.NestedClass?) { if (!(x?.prop_4 != null) != true) { - x - x.prop_4 + x + x.prop_4 } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/29.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/29.fir.kt index ac4996d23b6..67f12f4b2df 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/29.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/29.fir.kt @@ -5,33 +5,33 @@ // TESTCASE NUMBER: 1 fun case_1(x: Class?) { if (x?.prop_8?.prop_8?.prop_8?.prop_8 != null) { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } // TESTCASE NUMBER: 2 fun case_2(x: Class?) { if (x?.prop_8?.prop_8?.prop_8?.prop_8 !== null) { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } // TESTCASE NUMBER: 3 fun case_3(x: Class?) { if (x?.prop_8?.prop_8?.prop_8?.prop_8 == null) else { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } @@ -42,18 +42,18 @@ fun case_3(x: Class?) { */ fun case_4(x: Class?) { if (x?.prop_8?.prop_8?.prop_8?.prop_8 == null == true) else { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } // TESTCASE NUMBER: 5 fun case_5(x: T) { if (x?.propNullableT != null) { - x + x } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/3.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/3.fir.kt index 64b2dd1929c..8ee33236b69 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/3.fir.kt @@ -60,7 +60,7 @@ fun case_6(x: EmptyClass?) { // TESTCASE NUMBER: 7 fun case_7() { - if (nullableStringProperty == null || nullableStringProperty == null) { + if (nullableStringProperty == null || nullableStringProperty == null) { nullableStringProperty } } @@ -259,7 +259,7 @@ fun case_23(a: ((Float) -> Int?)?, b: Float?) { ?")!>a b if (a != null) { - & kotlin.Function1?")!>a + ? & kotlin.Function1")!>a } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt index a2070fc7221..fab49cb5607 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt @@ -9,11 +9,11 @@ */ fun case_1(x: Class?) { if (x!!.prop_8?.prop_8?.prop_8?.prop_8 != null) { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } @@ -24,11 +24,11 @@ fun case_1(x: Class?) { */ fun case_2(x: Class?) { if (x?.prop_8!!.prop_8?.prop_8?.prop_8 !== null) { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } @@ -39,11 +39,11 @@ fun case_2(x: Class?) { */ fun case_3(x: Class?) { if (x?.prop_8?.prop_8?.prop_8!!.prop_8 == null) else { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8.prop_8 } } @@ -54,11 +54,11 @@ fun case_3(x: Class?) { */ fun case_4(x: Class?) { if (x!!?.prop_8?.prop_8?.prop_8?.prop_8 == null == true) else { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } @@ -69,11 +69,11 @@ fun case_4(x: Class?) { */ fun case_5(x: Class?) { if (x?.prop_8!!?.prop_8?.prop_8?.prop_8 == null == true) else { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } @@ -84,11 +84,11 @@ fun case_5(x: Class?) { */ fun case_6(x: Class?) { if (x?.prop_8?.prop_8?.prop_8!!?.prop_8 == null == true) else { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8.prop_8 } } @@ -124,7 +124,7 @@ fun case_8(x: Class) { // TESTCASE NUMBER: 9 fun case_9(x: T) { if (x!!.propNullableT != null) { - x + x x.propNullableT } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/31.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/31.fir.kt index f27996473ae..8becfa46a9d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/31.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/31.fir.kt @@ -9,11 +9,11 @@ */ fun case_1(x: Any?) { if ((x as Class).prop_8?.prop_8?.prop_8?.prop_8 != null) { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } @@ -24,11 +24,11 @@ fun case_1(x: Any?) { */ fun case_2(x: Class?) { if ((x as Class).prop_8?.prop_8?.prop_8?.prop_8 !== null) { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } @@ -39,11 +39,11 @@ fun case_2(x: Class?) { */ fun case_3(x: Any?) { if ((x as Class?)?.prop_8?.prop_8?.prop_8?.prop_8 == null) else { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8.prop_8 } } @@ -54,11 +54,11 @@ fun case_3(x: Any?) { */ fun case_4(x: Any?) { if ((x as Class?)!!.prop_8?.prop_8?.prop_8?.prop_8 == null) else { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8.prop_8 } } @@ -69,11 +69,11 @@ fun case_4(x: Any?) { */ fun case_5(x: Class?) { if ((x?.prop_8 as Class).prop_8?.prop_8?.prop_8 == null == true) else { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } @@ -84,18 +84,18 @@ fun case_5(x: Class?) { */ fun case_6(x: Class?) { if ((x?.prop_8?.prop_8?.prop_8 as Class?)?.prop_8 == null == true) else { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8.prop_8 } } // TESTCASE NUMBER: 5 fun case_5(x: T) { if ((x as Any).propNullableT != null) { - x + x } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/32.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/32.fir.kt index d92d04b74a1..7088ae32666 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/32.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/32.fir.kt @@ -6,9 +6,9 @@ fun case_1(x: T?, y: K?) { x as T y as K - val z = x ?: y + val z = x ?: y - x.equals(10) + x.equals(10) z z.equals(10) } @@ -17,6 +17,6 @@ fun case_1(x: T?, y: K?) { inline fun case_2(y: K?) { y as K - y - y.equals(10) + y + y.equals(10) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/33.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/33.fir.kt index 8695a0ed03e..76c42bfb6a0 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/33.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/33.fir.kt @@ -12,8 +12,8 @@ fun case_1() { x = 42 } - x - x.inv() + x + x.inv() } // TESTCASE NUMBER: 2 @@ -26,8 +26,8 @@ fun case_2() { x = 42.0 } - & kotlin.Any?")!>x - & kotlin.Any?")!>x.equals(10) + ")!>x + ")!>x.equals(10) } // TESTCASE NUMBER: 3 @@ -40,8 +40,8 @@ fun case_3() { x = ClassLevel3() } - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 4 @@ -54,8 +54,8 @@ fun case_4() { x = 42.0 } - x - x.minus(10.0) + x + x.minus(10.0) } // TESTCASE NUMBER: 5 @@ -68,8 +68,8 @@ fun case_5() { x = 42.0 } - x - x.minus(10.0) + x + x.minus(10.0) } /* diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt index bdda892a162..356c3d93f92 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/34.fir.kt @@ -6,11 +6,11 @@ fun case_1() { var a: Any? = null if (a == null) return - val b = select(a) - val c = a + val b = select(a) + val c = a b - c - c.equals(10) + c + c.equals(10) b.equals(10) } @@ -18,8 +18,8 @@ fun case_1() { fun case_2(a: Any?) { if (a is String) { val b = a - b - b.length + b + b.length } } @@ -30,8 +30,8 @@ fun case_3(a: Any?) { val c = b val d = c val e = d - e - e.length + e + e.length } } @@ -46,12 +46,12 @@ fun case_4(a: Any?) { if (d is ClassLevel4) { val e = d if (e is ClassLevel5) { - e - e.test1() - e.test2() - e.test3() - e.test4() - e.test5() + e + e.test1() + e.test2() + e.test3() + e.test4() + e.test5() } } } @@ -81,12 +81,12 @@ fun case_5(a: Any?) { && if (true) {e = d;false} else {e = d;true} && if (true) {e as? ClassLevel5 ?: e as ClassLevel5;true} else {e as? ClassLevel5 ?: e as ClassLevel5;false} ) { - e - e.test1() - e.test2() - e.test3() - e.test4() - e.test5() + e + e.test1() + e.test2() + e.test3() + e.test4() + e.test5() } } @@ -104,18 +104,18 @@ fun case_6() { when (if (true) {d.test2(); e = d; e as ClassLevel3} else {d.test2(); e = d; e as ClassLevel3}) { else -> ClassLevel2() } -> { - e - println(e.inv()) - println(e.test1()) - println(e.test2()) - println(e.test3()) + e + println(e.inv()) + println(e.test1()) + println(e.test2()) + println(e.test3()) } else -> { - e - println(e.inv()) - println(e.test1()) - println(e.test2()) - println(e.test3()) + e + println(e.inv()) + println(e.test1()) + println(e.test2()) + println(e.test3()) } } } @@ -133,7 +133,7 @@ fun case_7() { e as ClassLevel2 e = d - e - e.test1() - e.test2() + e + e.test1() + e.test2() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/35.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/35.fir.kt index 45d1ac8ac5d..07ebf4bbfa7 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/35.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/35.fir.kt @@ -20,7 +20,7 @@ fun case_1(x: Any?) { fun case_2(x: Any?) { while (true) { x ?: return - x + x } x @@ -34,7 +34,7 @@ fun case_2(x: Any?) { */ fun case_3(x: Any?) { while (true) { - x ?: return ?: x + x ?: return ?: x } x @@ -45,8 +45,8 @@ fun case_3(x: Any?) { fun case_4(x: Any?) { while (true) { x ?: break - x - x.equals(10) + x + x.equals(10) } x @@ -56,8 +56,8 @@ fun case_4(x: Any?) { fun case_5(x: Any?) { while (true) { x ?: continue - x - x.equals(10) + x + x.equals(10) } x @@ -67,19 +67,19 @@ fun case_5(x: Any?) { fun case_6(x: Any?) { do { x ?: continue - x - x.equals(10) + x + x.equals(10) } while (false) - x + x } // TESTCASE NUMBER: 7 fun case_7(x: Any?) { do { x ?: break - x - x.equals(10) + x + x.equals(10) } while (false) x diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt index 80abecf96f6..0444125e669 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/36.fir.kt @@ -13,17 +13,17 @@ fun case_1() { b b.equals(10) - c - c.equals(10) + c + c.equals(10) } // TESTCASE NUMBER: 2 fun case_2(x: Any) { if (x is String) { val y = x - x - y - y.length + x + y + y.length } } @@ -33,11 +33,11 @@ fun case_3(x: Any?) { var y = x if (y == null) throw Exception() var z = y - x - y - z - y.toByte() - z.toByte() + x + y + z + y.toByte() + z.toByte() } } @@ -47,11 +47,11 @@ fun case_4(x: Any?) { var y = x while (true && y != null) { var z = y - x - y - z - y.toByte() - z.toByte() + x + y + z + y.toByte() + z.toByte() } } } @@ -62,10 +62,10 @@ fun case_5(x: Any?) { while (false || y != null) { if (y is Number) { val z = select(y) - x - y + x + y z - y.toByte() + y.toByte() z.toByte() } } @@ -139,7 +139,7 @@ fun case_11(x: Any?, z: Any, b: Boolean?) { while (true) { var y = x ?: if (b == true) continue!! else if (!(b != false)) return else break ?: break::class z !== y && if (b == true) return else if (b === false) null!!else throw Exception() - x + x y y.equals(10) } @@ -162,10 +162,10 @@ fun case_13(x: Any?) { var y = select(select(select(select(select(select(x)))))) if (y == null) throw Exception() var z = select(select(select(select(y), select(y)), select(select(y), select(y))), select(select(select(y), select(y)), select(select(y), select(y)))) - x - y + x + y z - y.toByte() + y.toByte() z.toByte() } } @@ -174,7 +174,7 @@ fun case_13(x: Any?) { fun case_14(x: Any?) { if (x is Number?) { var y = removeNullable(x) - x + x y y.toByte() } @@ -186,10 +186,10 @@ fun case_15(x: Any?) { var y = removeNullable(removeNullable(removeNullable(removeNullable(x), removeNullable(x)), removeNullable(removeNullable(x), removeNullable(x))), removeNullable(removeNullable(removeNullable(x), removeNullable(x)), removeNullable(removeNullable(x), removeNullable(x)))) if (y !is Int) throw Exception() var z = select(select(select(select(y), select(y)), select(select(y), select(y))), select(select(select(y), select(y)), select(select(y), select(y)))) - x - y + x + y z - y.inv() + y.inv() z.inv() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/37.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/37.fir.kt index 532eb88281a..ec11d464e77 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/37.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/37.fir.kt @@ -34,7 +34,7 @@ fun case_2(a: Any?) { */ fun case_3(x: Int?) { while (true) { - x ?: return ?: x + x ?: return ?: x } x @@ -89,8 +89,8 @@ fun case_7(x: Boolean?) { fun case_8(x: Boolean?) { while (x ?: return) - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 9 @@ -98,8 +98,8 @@ fun case_9(x: Boolean?) { while (x ?: return) while (x == null) - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 10 @@ -121,8 +121,8 @@ fun case_11(x: Boolean?) { x } - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 12 @@ -132,8 +132,8 @@ fun case_12(x: Boolean?) { break && x } - x - x.equals(10) + x + x.equals(10) } /* @@ -160,8 +160,8 @@ fun case_14(x: Boolean?) { x ?: return } while(false) - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 15 @@ -171,8 +171,8 @@ fun case_15(x: Boolean?) { println(1) } while(false) - x - x.equals(10) + x + x.equals(10) } /* @@ -185,8 +185,8 @@ fun case_16(x: Boolean?) { x ?: x!! } while(false) - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 17 @@ -206,6 +206,6 @@ fun case_17(x: Boolean?, y: Boolean?) { break@loop } - x - x.not() + x + x.not() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/38.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/38.fir.kt index 5d062eb2e9c..244235a5b1a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/38.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/38.fir.kt @@ -5,8 +5,8 @@ // TESTCASE NUMBER: 1 fun case_1(x: Comparable<*>?) { if (x is Byte?) { - ?")!>x - ?")!>x?.equals(10) + ? & kotlin.Byte?")!>x + ? & kotlin.Byte?")!>x?.equals(10) x!!.dec() } } @@ -14,40 +14,40 @@ fun case_1(x: Comparable<*>?) { // TESTCASE NUMBER: 2 fun case_2(x: ClassWithThreeTypeParameters<*, *, *>?) { if (x is InterfaceWithTwoTypeParameters<*, *>?) { - ? & ClassWithThreeTypeParameters<*, *, *>? & ClassWithThreeTypeParameters<*, *, *>?")!>x - ? & ClassWithThreeTypeParameters<*, *, *>? & ClassWithThreeTypeParameters<*, *, *>?")!>x?.x + ? & InterfaceWithTwoTypeParameters<*, *>? & ClassWithThreeTypeParameters<*, *, *>?")!>x + ? & InterfaceWithTwoTypeParameters<*, *>? & ClassWithThreeTypeParameters<*, *, *>?")!>x?.x x?.y x?.z & ClassWithThreeTypeParameters<*, *, *>")!>x!!.ip2test() - & ClassWithThreeTypeParameters<*, *, *> & ClassWithThreeTypeParameters<*, *, *>?")!>x - & ClassWithThreeTypeParameters<*, *, *> & ClassWithThreeTypeParameters<*, *, *>?")!>x.x + ? & InterfaceWithTwoTypeParameters<*, *> & ClassWithThreeTypeParameters<*, *, *>")!>x + ? & InterfaceWithTwoTypeParameters<*, *> & ClassWithThreeTypeParameters<*, *, *>")!>x.x } } // TESTCASE NUMBER: 3 fun case_3(x: ClassWithThreeTypeParameters<*, *, *>) { if (x is InterfaceWithTwoTypeParameters<*, *>?) { - & ClassWithThreeTypeParameters<*, *, *> & ClassWithThreeTypeParameters<*, *, *>")!>x - & ClassWithThreeTypeParameters<*, *, *> & ClassWithThreeTypeParameters<*, *, *>")!>x.x + & InterfaceWithTwoTypeParameters<*, *> & ClassWithThreeTypeParameters<*, *, *>")!>x + & InterfaceWithTwoTypeParameters<*, *> & ClassWithThreeTypeParameters<*, *, *>")!>x.x x.y x.z & ClassWithThreeTypeParameters<*, *, *>")!>x!!.ip2test() - & ClassWithThreeTypeParameters<*, *, *> & ClassWithThreeTypeParameters<*, *, *>")!>x - & ClassWithThreeTypeParameters<*, *, *> & ClassWithThreeTypeParameters<*, *, *>")!>x.x + & InterfaceWithTwoTypeParameters<*, *> & ClassWithThreeTypeParameters<*, *, *>")!>x + & InterfaceWithTwoTypeParameters<*, *> & ClassWithThreeTypeParameters<*, *, *>")!>x.x } } // TESTCASE NUMBER: 4 fun case_4(x: ClassWithSixTypeParameters<*, *, *, *, *, *>?) { if (x is InterfaceWithTwoTypeParameters<*, *>) { - & ClassWithSixTypeParameters<*, *, *, *, *, *> & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>x - & ClassWithSixTypeParameters<*, *, *, *, *, *> & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>x.x + ? & InterfaceWithTwoTypeParameters<*, *> & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>x + ? & InterfaceWithTwoTypeParameters<*, *> & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>x.x x.y x.z x.u & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>x!!.ip2test() - & ClassWithSixTypeParameters<*, *, *, *, *, *> & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>x - & ClassWithSixTypeParameters<*, *, *, *, *, *> & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>x.x + ? & InterfaceWithTwoTypeParameters<*, *> & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>x + ? & InterfaceWithTwoTypeParameters<*, *> & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>x.x } } @@ -55,13 +55,13 @@ fun case_4(x: ClassWithSixTypeParameters<*, *, *, *, *, *>?) { fun case_5(x: ClassWithThreeTypeParameters<*, *, *>?) { if (x is InterfaceWithTwoTypeParameters<*, *>?) { if (x === null) return - & ClassWithThreeTypeParameters<*, *, *> & ClassWithThreeTypeParameters<*, *, *>?")!>x - & ClassWithThreeTypeParameters<*, *, *> & ClassWithThreeTypeParameters<*, *, *>?")!>x.x + ? & InterfaceWithTwoTypeParameters<*, *> & ClassWithThreeTypeParameters<*, *, *>")!>x + ? & InterfaceWithTwoTypeParameters<*, *> & ClassWithThreeTypeParameters<*, *, *>")!>x.x x.y x.z - & ClassWithThreeTypeParameters<*, *, *> & ClassWithThreeTypeParameters<*, *, *>?")!>x.ip2test() - & ClassWithThreeTypeParameters<*, *, *> & ClassWithThreeTypeParameters<*, *, *>?")!>x - & ClassWithThreeTypeParameters<*, *, *> & ClassWithThreeTypeParameters<*, *, *>?")!>x.x + ? & InterfaceWithTwoTypeParameters<*, *> & ClassWithThreeTypeParameters<*, *, *>")!>x.ip2test() + ? & InterfaceWithTwoTypeParameters<*, *> & ClassWithThreeTypeParameters<*, *, *>")!>x + ? & InterfaceWithTwoTypeParameters<*, *> & ClassWithThreeTypeParameters<*, *, *>")!>x.x } } @@ -70,13 +70,13 @@ fun case_5(x: Any?) { if (x is ClassWithThreeTypeParameters<*, *, *>?) { if (x is InterfaceWithTwoTypeParameters<*, *>?) { if (x === null) return - & InterfaceWithTwoTypeParameters<*, *> & kotlin.Any?")!>x - & InterfaceWithTwoTypeParameters<*, *> & kotlin.Any?")!>x.x + & InterfaceWithTwoTypeParameters<*, *>")!>x + & InterfaceWithTwoTypeParameters<*, *>")!>x.x x.y x.z - & InterfaceWithTwoTypeParameters<*, *> & kotlin.Any?")!>x.ip2test() - & InterfaceWithTwoTypeParameters<*, *> & kotlin.Any?")!>x - & InterfaceWithTwoTypeParameters<*, *> & kotlin.Any?")!>x.x + & InterfaceWithTwoTypeParameters<*, *>")!>x.ip2test() + & InterfaceWithTwoTypeParameters<*, *>")!>x + & InterfaceWithTwoTypeParameters<*, *>")!>x.x } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/39.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/39.fir.kt index 3f005ff06ce..106ef6aa8b7 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/39.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/39.fir.kt @@ -21,8 +21,8 @@ fun case_2(x: Number) { val y: Int? = null if (x === y) { - x - x.inv() + x + x.inv() } } @@ -31,8 +31,8 @@ fun case_3(x: Number) { var y: Int? = null if (x === y) { - x - x.inv() + x + x.inv() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/40.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/40.fir.kt index e94d4d0792b..15de9326010 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/40.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/40.fir.kt @@ -42,7 +42,7 @@ fun case_4(x: Any?) { fun case_5(x: Any?) { x!! if (x is Int?) { - x.inv() + x.inv() select(x).inv() } } @@ -53,7 +53,7 @@ fun case_5(x: Any?) { */ fun case_6(x: Any?) { if (x is Boolean? && x!!) { - x.not() + x.not() select(x).not() } } @@ -61,7 +61,7 @@ fun case_6(x: Any?) { // TESTCASE NUMBER: 7 fun case_7(x: Boolean?) { if (x != null && x!!) { - x.not() + x.not() select(x).not() } } @@ -69,7 +69,7 @@ fun case_7(x: Boolean?) { // TESTCASE NUMBER: 8 fun case_8(x: Any?) { if (x != null && x is Boolean?) { - x.not() + x.not() select(x).not() } } @@ -77,7 +77,7 @@ fun case_8(x: Any?) { // TESTCASE NUMBER: 9 fun case_9(x: Any?) { if (x is Boolean? && x != null) { - x.not() + x.not() select(x).not() } } @@ -85,7 +85,7 @@ fun case_9(x: Any?) { // TESTCASE NUMBER: 10 fun case_10(x: Any?) { if (x as Boolean) { - x.not() + x.not() select(x).not() } } @@ -97,7 +97,7 @@ fun case_10(x: Any?) { */ fun case_11(x: Any?) { if ((x as Boolean?)!!) { - x.not() + x.not() select(x).not() } } @@ -109,7 +109,7 @@ fun case_11(x: Any?) { */ fun case_12(x: Any?) { if (x!! as Boolean?) { - x.not() + x.not() select(x).not() } } @@ -121,7 +121,7 @@ fun case_12(x: Any?) { */ fun case_13(x: Any?) { if (x as Boolean? ?: x!!) { - x.not() + x.not() select(x).not() } } @@ -136,7 +136,7 @@ fun case_14(x: Any?) { x x?.equals(10) x!!.equals(10) - x.equals(10) + x.equals(10) } } @@ -150,7 +150,7 @@ fun case_15(x: Any?) { x x?.equals(10) x!!.equals(10) - x.equals(10) + x.equals(10) } } @@ -163,5 +163,5 @@ fun case_16(x: Nothing?) { x x?.equals(10) x!!.equals(10) - x.equals(10) + x.equals(10) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/41.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/41.fir.kt index 5ff72bfa270..6533aebbcb4 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/41.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/41.fir.kt @@ -9,10 +9,10 @@ fun case_1(x: Any) { if (x is Interface1) { if (x is Interface2) { - x - x.itest() - x.itest1() - x.itest2() + x + x.itest() + x.itest1() + x.itest2() } } } @@ -24,8 +24,8 @@ fun case_1(x: Any) { fun case_2(x: Any) { if (x is Interface2) { if (x is Interface1) { - x - x.itest0() + x + x.itest0() } } } @@ -37,8 +37,8 @@ fun case_2(x: Any) { fun case_3(x: Any) { if (x is Interface1) { if (x is Interface2) { - x - x.itest000() + x + x.itest000() } } } @@ -50,8 +50,8 @@ fun case_3(x: Any) { fun case_4(x: Any) { if (x is Interface2) { if (x is Interface1) { - x - x.itest0000() + x + x.itest0000() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/42.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/42.fir.kt index 687d6a252fd..95b720d3919 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/42.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/42.fir.kt @@ -14,8 +14,8 @@ fun case_1() { val x: Int? x = 10 } - x - x.equals(10) + x + x.equals(10) } /* @@ -30,8 +30,8 @@ fun case_2() { var x: Int? = 10 x = 10 } - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 3 @@ -41,6 +41,6 @@ fun case_3() { val y = { var x: Int? = 10 } - x - x.equals(10) + x + x.equals(10) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/43.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/43.fir.kt index 066d1299019..7a6dc84293a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/43.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/43.fir.kt @@ -11,9 +11,9 @@ fun case_1(a: Interface1?, b: Interface2?) { a as Interface2? val c = select(a, b) if (c != null) { - c.itest() - c.itest1() - c.itest2() + c.itest() + c.itest1() + c.itest2() } } @@ -90,9 +90,9 @@ fun case_6(a: Interface1?, b: Interface2?) { val c = select(a, b) c ?: return - c.itest() - c.itest1() - c.itest2() + c.itest() + c.itest1() + c.itest2() } /* @@ -107,9 +107,9 @@ fun case_7(a: Interface1?, b: Interface2?) { val bar = l2@ fun() { val c = select(a, b) c ?: return@l2 - c.itest() - c.itest1() - c.itest2() + c.itest() + c.itest1() + c.itest2() } return bar } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/44.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/44.fir.kt index 7535afb3fb3..04581dc3f46 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/44.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/44.fir.kt @@ -10,8 +10,8 @@ fun Int?.case_1() { val x = this if (x != null) { - this - this.inv() + this + this.inv() } } @@ -23,8 +23,8 @@ fun Int?.case_1() { fun Int?.case_2() { val x = this if (this != null) { - x - x.inv() + x + x.inv() } } @@ -36,8 +36,8 @@ fun Int?.case_2() { fun Int?.case_3() { val x = this this!! - x - x.inv() + x + x.inv() } /* @@ -48,6 +48,6 @@ fun Int?.case_3() { fun Int?.case_4() { val x = this x!! - this - this.inv() + this + this.inv() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/45.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/45.fir.kt index cf471ff4ad1..eddc8c93038 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/45.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/45.fir.kt @@ -12,8 +12,8 @@ fun case_1() { val y: Int? y = x if (y != null) { - x - x.inv() + x + x.inv() } } @@ -27,8 +27,8 @@ fun case_2() { val y: Int? y = x y!! - x - x.inv() + x + x.inv() } /* @@ -41,8 +41,8 @@ fun case_3() { val y: Int? y = x y!! - x - x.inv() + x + x.inv() } /* @@ -55,8 +55,8 @@ fun case_4() { var y: Int? y = x if (y != null) { - x - x.inv() + x + x.inv() } } @@ -66,8 +66,8 @@ fun case_5() { val y: Int? x = 10;y = x if (y != null) { - x - x.inv() + x + x.inv() } } @@ -77,8 +77,8 @@ fun case_6() { val y: Int? x = 10;y = x if (y != null) { - x - x.inv() + x + x.inv() } } @@ -88,8 +88,8 @@ fun case_7() { var y: Int? x = 10;y = x if (y != null) { - x - x.inv() + x + x.inv() } } @@ -99,7 +99,7 @@ fun case_8() { var y: Int? x = 10;y = x if (y != null) { - x - x.inv() + x + x.inv() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/46.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/46.fir.kt index 002be3a9d40..e9bf1c14270 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/46.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/46.fir.kt @@ -37,8 +37,8 @@ fun case_2(x: Int?) { */ fun case_3(x: Int?) { if (x == funWithoutArgs() == true) { - x - x.inv() + x + x.inv() } } @@ -108,7 +108,7 @@ fun case_7(x: Int?) { */ fun case_8(x: KClass?) { if (x == EmptyObject::class == true) { - & kotlin.reflect.KClass?")!>x - & kotlin.reflect.KClass?")!>x.java + ? & kotlin.reflect.KClass")!>x + ? & kotlin.reflect.KClass")!>x.java } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/47.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/47.fir.kt index cec39be3dbd..a828ccd41c3 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/47.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/47.fir.kt @@ -9,8 +9,8 @@ fun case_1(a: Any?) { if (true) break } - a - a.equals(10) + a + a.equals(10) } /* @@ -23,8 +23,8 @@ fun case_2(a: Any?) { if (true) break } - a - a.equals(10) + a + a.equals(10) } // TESTCASE NUMBER: 3 @@ -34,8 +34,8 @@ fun case_3(a: Any?) { if (true) break } - a - a.equals(10) + a + a.equals(10) } // TESTCASE NUMBER: 4 @@ -45,8 +45,8 @@ fun case_4(a: Any?) { break } - a - a.equals(10) + a + a.equals(10) } // TESTCASE NUMBER: 5 @@ -56,8 +56,8 @@ fun case_5(a: Any?) { if (true) break } - a - a.equals(10) + a + a.equals(10) } // TESTCASE NUMBER: 6 @@ -67,6 +67,6 @@ fun case_6(a: Any?) { break } - a - a.equals(10) + a + a.equals(10) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/48.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/48.fir.kt index e94a1a98baf..350c26fadb8 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/48.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/48.fir.kt @@ -9,10 +9,10 @@ */ fun case_1(x: Any?, y: Any?) { if (x!! === y) { - x - x.equals(10) - y - y.equals(10) + x + x.equals(10) + y + y.equals(10) } } @@ -23,10 +23,10 @@ fun case_1(x: Any?, y: Any?) { */ fun case_2(x: Any?, y: Any?) { if (x as Int === y) { - x - x.inv(10) - y - y.inv(10) + x + x.inv(10) + y + y.inv(10) } } @@ -37,10 +37,10 @@ fun case_2(x: Any?, y: Any?) { */ fun case_3(x: Any?, y: Any?) { if (y === x!!) { - x - x.equals(10) - y - y.equals(10) + x + x.equals(10) + y + y.equals(10) } } @@ -51,9 +51,9 @@ fun case_3(x: Any?, y: Any?) { */ fun case_4(x: Any?, y: Any?) { if (y === x as Int) { - x - x.inv(10) - y - y.inv(10) + x + x.inv(10) + y + y.inv(10) } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/49.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/49.fir.kt index d7703419e5c..31a712b525e 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/49.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/49.fir.kt @@ -9,8 +9,8 @@ */ fun case_1(x: Any?) { if (x is Int == @RetentionSourceAndTargetExpression true) { - x - x.inv() + x + x.inv() } } @@ -21,8 +21,8 @@ fun case_1(x: Any?) { */ fun case_2(x: Int?) { if (x != @RetentionSourceAndTargetExpression null == true) { - x - x.inv() + x + x.inv() } } @@ -33,8 +33,8 @@ fun case_2(x: Int?) { */ fun case_3(x: Int?, y: Int) { if (x == y == @RetentionSourceAndTargetExpression true) { - x - x.inv() + x + x.inv() } } @@ -45,7 +45,7 @@ fun case_3(x: Int?, y: Int) { */ fun case_4(x: Int?, y: Int) { if (@RetentionSourceAndTargetExpression !!(x == y)) { - x - x.inv() + x + x.inv() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/5.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/5.fir.kt index fe826fa59ae..84b0a273a07 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/5.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/5.fir.kt @@ -7,16 +7,16 @@ fun case_1(x: Any?) { if (x is Number?) { if (x !== null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -24,16 +24,16 @@ fun case_1(x: Any?) { // TESTCASE NUMBER: 2 fun case_2(x: Any?) { if (x is Number? && x is Int? && x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -42,16 +42,16 @@ fun case_3(x: Any?) { if (x is Number?) { if (x !== null) { if (x is Int?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -62,16 +62,16 @@ fun case_4(x: Any?) { if (x != null) { if (x is Number) { if (x is Int?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -85,21 +85,21 @@ fun case_5(x: Any?) { if (x is ClassLevel4?) { if (x is ClassLevel5?) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test1() - x.test2() - x.test3() - x.test4() - x.test5() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test1() + x.test2() + x.test3() + x.test4() + x.test5() } } } @@ -115,21 +115,21 @@ fun case_6(x: Any?) { if (x is ClassLevel3?) { if (x != null && x is ClassLevel4?) { if (x is ClassLevel5?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test1() - x.test2() - x.test3() - x.test4() - x.test5() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test1() + x.test2() + x.test3() + x.test4() + x.test5() } } } @@ -141,21 +141,21 @@ fun case_6(x: Any?) { fun case_7(x: Any?) { if (x is ClassLevel1? && x is ClassLevel2? && x is ClassLevel3?) { if (x is ClassLevel4? && x != null && x is ClassLevel5?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test1() - x.test2() - x.test3() - x.test4() - x.test5() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test1() + x.test2() + x.test3() + x.test4() + x.test5() } } } @@ -164,21 +164,21 @@ fun case_7(x: Any?) { fun case_8(x: Any?) { if (x is ClassLevel1? && x is ClassLevel2? && x is ClassLevel3?) { if (x is ClassLevel4? && x != null && x is ClassLevel5?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test1() - x.test2() - x.test3() - x.test4() - x.test5() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test1() + x.test2() + x.test3() + x.test4() + x.test5() } } } @@ -186,21 +186,21 @@ fun case_8(x: Any?) { // TESTCASE NUMBER: 9 fun case_9(x: Any?) { if (x is ClassLevel1? && x is ClassLevel2? && x is ClassLevel3? && x is ClassLevel4? && x != null && x is ClassLevel5?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test1() - x.test2() - x.test3() - x.test4() - x.test5() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test1() + x.test2() + x.test3() + x.test4() + x.test5() } } @@ -210,38 +210,38 @@ fun case_10(x: Any?) { if (x is ClassLevel4?) { } else if (x is ClassLevel5? && x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test1() - x.test2() - x.test3() - x.test4() - x.test5() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test1() + x.test2() + x.test3() + x.test4() + x.test5() } } else if (x is ClassLevel4? && x != null && x is ClassLevel5?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.test1() - x.test2() - x.test3() - x.test4() - x.test5() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.test1() + x.test2() + x.test3() + x.test4() + x.test5() } } @@ -255,11 +255,11 @@ fun case_11(x: Any?) { if (x is Interface1?) { if (x is Interface2?) { if (x != null) { - x - x.itest1() - x.itest2() + x + x.itest1() + x.itest2() - x.let { it.itest1(); it.itest2() } + x.let { it.itest1(); it.itest2() } } } } @@ -273,11 +273,11 @@ fun case_11(x: Any?) { */ fun case_12(x: Any?) { if (x is Interface1? && x != null && x is Interface2?) { - x - x.itest1() - x.itest2() + x + x.itest1() + x.itest2() - x.let { it.itest1(); it.itest2() } + x.let { it.itest1(); it.itest2() } } } @@ -293,12 +293,12 @@ fun case_13(x: Any?) { if (x is ClassLevel2? && x is Interface1?) { if (x !is Interface3?) {} else if (false) { if (x != null) { - x - x.itest1() - x.itest2() - x.itest3() - x.test1() - x.test2() + x + x.itest1() + x.itest2() + x.itest3() + x.test1() + x.test2() } } } @@ -318,12 +318,12 @@ fun case_14(x: Any?) { if (x == null || x !is Interface1?) else { if (x is ClassLevel2?) { if (x is Interface3?) { - x - x.itest1() - x.itest2() - x.itest3() - x.test1() - x.test2() + x + x.itest1() + x.itest2() + x.itest3() + x.test1() + x.test2() } } } @@ -341,19 +341,19 @@ fun case_15(x: Any?) { if (x !is ClassLevel2? || x !is ClassLevel1?) else { if (x === null || x !is Interface1?) else { if (x !is Interface2? || x !is Interface3?) {} else { - x - x.itest2() - x.itest1() - x.itest3() - x.test1() - x.test2() + x + x.itest2() + x.itest1() + x.itest3() + x.test1() + x.test2() } } } } // TESTCASE NUMBER: 16 -fun case_16(a: Any?, b: Int = if (a is Number? && a is Int? && a !== null) a else 0) { +fun case_16(a: Any?, b: Int = if (a is Number? && a is Int? && a !== null) a else 0) { a b b.equals(null) @@ -368,7 +368,7 @@ fun case_16(a: Any?, b: Int = if (a is Number? && a is Int? && a !== null) a) { +fun case_17(a: Any?, b: Int = if (a !is Number? || a !is Int? || a == null) 0 else a) { a b b.equals(null) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.fir.kt index 033dd38d297..d7a2dde3c16 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.fir.kt @@ -5,9 +5,9 @@ // TESTCASE NUMBER: 1 fun Any.case_1() { if (this is Inv<*>) { - & kotlin.Any")!>this.test() - & kotlin.Any")!>this.prop_4 - & kotlin.Any")!>this.prop_4.inv() + ")!>this.test() + ")!>this.prop_4 + ")!>this.prop_4.inv() prop_4 prop_4.inv() } @@ -16,9 +16,9 @@ fun Any.case_1() { // TESTCASE NUMBER: 2 fun Any.case_2() { if (this is ClassWithSixTypeParameters<*, *, *, *, *, *>) { - & kotlin.Any")!>this.test() - & kotlin.Any")!>this.x - & kotlin.Any")!>this.y + ")!>this.test() + ")!>this.x + ")!>this.y x y } @@ -27,9 +27,9 @@ fun Any.case_2() { // TESTCASE NUMBER: 3 fun T.case_3() { if (this is Inv<*>) { - & T!! & T")!>this.test() - & T!! & T")!>this.prop_4 - & T!! & T")!>this.prop_4.inv() + & T!!")!>this.test() + & T!!")!>this.prop_4 + & T!!")!>this.prop_4.inv() prop_4 prop_4.inv() } @@ -38,9 +38,9 @@ fun T.case_3() { // TESTCASE NUMBER: 4 fun T?.case_4() { if (this is ClassWithSixTypeParameters<*, *, *, *, *, *>) { - & T?!! & T?")!>this.test() - & T?!! & T?")!>this.x - & T?!! & T?")!>this.y + & T?!!")!>this.test() + & T?!!")!>this.x + & T?!!")!>this.y x y } @@ -49,11 +49,11 @@ fun T?.case_4() { // TESTCASE NUMBER: 5 fun ClassWithSixTypeParameters.case_5() { if (this is InterfaceWithFiveTypeParameters1<*, *, *, *, *>) { - & ClassWithSixTypeParameters & ClassWithSixTypeParameters")!>this.itest1() + & InterfaceWithFiveTypeParameters1<*, *, *, *, *> & ClassWithSixTypeParameters")!>this.itest1() itest1() - & ClassWithSixTypeParameters & ClassWithSixTypeParameters")!>this.test() - & ClassWithSixTypeParameters & ClassWithSixTypeParameters")!>this.x - & ClassWithSixTypeParameters & ClassWithSixTypeParameters")!>this.y + & InterfaceWithFiveTypeParameters1<*, *, *, *, *> & ClassWithSixTypeParameters")!>this.test() + & InterfaceWithFiveTypeParameters1<*, *, *, *, *> & ClassWithSixTypeParameters")!>this.x + & InterfaceWithFiveTypeParameters1<*, *, *, *, *> & ClassWithSixTypeParameters")!>this.y x y } @@ -78,8 +78,8 @@ fun Inv.case_7() { if (this.prop_3 is MutableList<*>) { this.prop_3 this.prop_3[0] - & T!! & T")!>prop_3 - & T!! & T")!>prop_3[0] + & T!!")!>prop_3 + & T!!")!>prop_3[0] } } @@ -98,8 +98,8 @@ fun T.case_8() { */ fun T.case_9() { if (this is String) { - this - this.length + this + this.length length } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/51.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/51.fir.kt index b45c9f2272e..f896873e262 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/51.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/51.fir.kt @@ -6,7 +6,7 @@ fun case_1(x: Any?) { val y = run { if (x is Class) - return@run x + return@run x Class() } y @@ -17,7 +17,7 @@ fun case_1(x: Any?) { fun case_2(x: Class?) { val y = run { x!! - return@run x + return@run x } y y.fun_1() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/53.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/53.fir.kt index 62fe5e84f83..501fe32d597 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/53.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/53.fir.kt @@ -8,7 +8,7 @@ fun case_1(x: Int?) = 10 fun case_1() { var x: Int? = 10 if (x != null) { - val z = case_1(x) + val z = case_1(x) z } } @@ -20,7 +20,7 @@ fun case_2() { var x: Int? = 10 var y = { x = null } if (x != null) { - val z = case_2(x) + val z = case_2(x) z } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt index 6f4aaf0c91d..3d2ce654e6e 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/54.fir.kt @@ -11,12 +11,12 @@ fun case_1() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (a is String) { b = a - b - b.length + b + b.length } b @@ -33,12 +33,12 @@ fun case_2() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (true) { b = a - b - b.length + b + b.length } b @@ -55,16 +55,16 @@ fun case_3() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length do { b = a - b - b.length + b + b.length } while (true) - b - b.length + b + b.length } } @@ -77,16 +77,16 @@ fun case_4() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length do { b = a - b - b.length + b + b.length } while (false) - b - b.length + b + b.length } } @@ -99,12 +99,12 @@ fun case_5() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length for (i in 0..10) { b = a - b - b.length + b + b.length } b @@ -117,16 +117,16 @@ fun case_6() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length if (a is String) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -135,14 +135,14 @@ fun case_7() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length when (true) { true -> b = a } - b - b.length + b + b.length } } @@ -155,16 +155,16 @@ fun case_8() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { b = a - b - b.length + b + b.length } catch (e: Exception) { } - b - b.length + b + b.length } } @@ -173,18 +173,18 @@ fun case_9() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { } catch (e: Exception) { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -193,18 +193,18 @@ fun case_10() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { b = a - b - b.length + b + b.length } finally { } - b - b.length + b + b.length } } @@ -213,18 +213,18 @@ fun case_11() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length try { } finally { b = a - b - b.length + b + b.length } - b - b.length + b + b.length } } @@ -237,8 +237,8 @@ fun case_12() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (if (true) { b = a; true } else true) { b b.length @@ -254,12 +254,12 @@ fun case_13() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length a.plus(if (true) { b = a; true } else true) - b - b.length + b + b.length } } @@ -272,8 +272,8 @@ fun case_14() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (true) { if (true) { b = a; } else 3 b @@ -287,12 +287,12 @@ fun case_15() { var a: Any = 4 if (a is String) { var b = a - b - b.length + b + b.length while (true) { if (true) { b = a; } else { b = a; } - b - b.length + b + b.length } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/55.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/55.fir.kt index 3a08d52de94..00304fc6200 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/55.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/55.fir.kt @@ -9,7 +9,7 @@ fun case_1(x: Any) { if (x is String) { x!!.length - x + x } } @@ -20,7 +20,7 @@ fun case_1(x: Any) { fun case_2(x: Any?) { if (x is String?) { x!!.length - x + x } } @@ -31,7 +31,7 @@ fun case_2(x: Any?) { fun case_3(x: Any) { if (x is Map.Entry<*, *>) { ")!>x!!.key - & kotlin.Any")!>x + ")!>x } } @@ -42,6 +42,6 @@ fun case_3(x: Any) { fun case_4(x: Any?) { if (x is Map.Entry<*, *>?) { ")!>x!!.value - & kotlin.Any?")!>x + ")!>x } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt index 887757f5a7e..be9cc1ac040 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/57.fir.kt @@ -8,9 +8,9 @@ */ fun case_1(x: Any?) { if (x is String) { - x + x val y = if (true) Class::fun_1 else Class::fun_1 - x + x val z: String = x } } @@ -21,13 +21,13 @@ fun case_1(x: Any?) { */ fun case_2(x: Any?, b: Boolean?) { x!! - x + x val y = when (b) { true -> Class::fun_1 false -> Class::fun_2 null -> Class::fun_3 } - x + x val z: Any = x } @@ -37,22 +37,22 @@ fun case_2(x: Any?, b: Boolean?) { */ fun case_3(x: Any?, b: Boolean?) { x as Int - x + x val y = when (b) { else -> Class::fun_1 } - x + x val z: Int = x } // TESTCASE NUMBER: 4 fun case_4(x: Any?, b: Boolean?) { x as Int - x + x if (b!!) { val m = Class::fun_1 } - x + x val z: Int = x } @@ -62,9 +62,9 @@ fun case_4(x: Any?, b: Boolean?) { */ fun case_5(x: Any?, b: Class) { x as Int - x + x val y = if (true) b::fun_1 else b::fun_1 - x + x val z: Int = x } @@ -75,10 +75,10 @@ fun case_5(x: Any?, b: Class) { fun case_6(x: Any?, b: Class) { x as Int val z1 = x - x + x val y = if (true) b::fun_1 else b::fun_1 - x - z1 + x + z1 val z2: Int = z1 } @@ -89,9 +89,9 @@ fun case_6(x: Any?, b: Class) { fun case_7_1() {} fun case_7(x: Any?) { if (x is String) { - x + x val y = if (true) ::case_7_1 else ::case_7_1 - x + x val z: String = x } } @@ -100,13 +100,13 @@ fun case_7(x: Any?) { fun case_8_1() {} fun case_8(x: Any?) { if (x is String) { - x + x val m = try { ::case_8_1 } catch (e: Exception) { ::case_8_1 } - x + x val z: String = x } } @@ -114,13 +114,13 @@ fun case_8(x: Any?) { // TESTCASE NUMBER: 9 fun case_9(x: Any?) { if (x is String) { - x + x val m = try { Class::fun_1 } finally { Class::fun_1 } - x + x val z: String = x } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt index 794488afdde..c781c9b3103 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/59.fir.kt @@ -34,7 +34,7 @@ fun case_2() { fun case_3() { var x: Any? = null while (x != null) { - x + x x = x.equals(10) } } @@ -43,7 +43,7 @@ fun case_3() { fun case_4() { var x: Any? = null while (x !== null) { - x + x x = x.equals(10) } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt index df90a41a8e8..8afba637062 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/6.fir.kt @@ -282,16 +282,16 @@ fun case_14() { fun case_15(x: TypealiasNullableString) { val y = null val z = if (x === null || y == x && x === y || null === x) "" else { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -651,7 +651,7 @@ fun case_33(a: ((Float) -> Int?)?, b: Float?, c: Boolean?) { if (true && a == z == true || b == null == true) { } else { - val x = a(b) + val x = a(b) if (x == z == true && x === z || (c != z && !c)) { } else { @@ -1066,16 +1066,16 @@ fun case_60(b: Boolean) { fun case_61(x: Any?) { if (x is Number?) { if (x !== implicitNullableNothingProperty) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -1084,16 +1084,16 @@ fun case_61(x: Any?) { fun case_62(x: Any?) { var z = null if (x is Number? && x is Int? && x != z) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -1106,16 +1106,16 @@ fun case_63(x: Any?, b: Boolean) { if (x is Number?) { if (x !== when (b) { true -> z1; false -> z2; else -> z3 }) { if (x is Int?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -1126,16 +1126,16 @@ fun case_64(x: Any?) { if (x != try {implicitNullableNothingProperty} finally {}) { if (x is Number) { if (x is Int?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -1149,16 +1149,16 @@ fun case_65(x: Any?, z: Nothing?) { if (x is ClassLevel4?) { if (x is ClassLevel5?) { if (x != z) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -1177,16 +1177,16 @@ fun case_66(x: Any?, z1: Nothing?, z2: Nothing?, b: Boolean) { if (x is ClassLevel3?) { if (x != if (b) { z1 } else { z2 } && x is ClassLevel4?) { if (x is ClassLevel5?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -1200,16 +1200,16 @@ fun case_67(x: Any?) { if (x is ClassLevel1? && x is ClassLevel2? && x is ClassLevel3?) { if (x is ClassLevel4? && x != (fun (): Nothing? { return z })() && x is ClassLevel5?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -1218,16 +1218,16 @@ fun case_67(x: Any?) { fun case_68(x: Any?, z: Nothing?) { if (x is ClassLevel1? && x is ClassLevel2? && x is ClassLevel3?) { if (x is ClassLevel4? && x != (fun (): Nothing? { return z })() && x is ClassLevel5?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -1238,16 +1238,16 @@ fun case_68(x: Any?, z: Nothing?) { */ fun case_69(x: Any?, z: Nothing?) { if (x is ClassLevel1? && x is ClassLevel2? && x is ClassLevel3? && x is ClassLevel4? && x != try { z } catch (e: Exception) { z } && x is ClassLevel5?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -1257,28 +1257,28 @@ fun case_70(x: Any?) { if (x is ClassLevel4?) { } else if (x is ClassLevel5? && x != nullableNothingProperty || x != implicitNullableNothingProperty) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } else if (x is ClassLevel4? && x !== nullableNothingProperty && x is ClassLevel5?) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -1295,12 +1295,12 @@ fun case_71(t: Any?) { if (t is Interface1?) { if (t is Interface2?) { if (t != z2) { - t - t.itest1() - t.itest2() - t.itest() + t + t.itest1() + t.itest2() + t.itest() - t.let { it.itest1(); it.itest2() } + t.let { it.itest1(); it.itest2() } } } } @@ -1317,12 +1317,12 @@ fun case_72(t: Any?, z1: Nothing?) { var z2 = null if (t is Interface1? && t != z1 ?: z2 && t is Interface2?) { - t - t.itest1() - t.itest2() - t.itest() + t + t.itest1() + t.itest2() + t.itest() - t.let { it.itest1(); it.itest2() } + t.let { it.itest1(); it.itest2() } } } @@ -1341,12 +1341,12 @@ fun case_73(t: Any?) { if (t is ClassLevel2? && t is Interface1?) { if (t !is Interface3?) {} else if (false) { if (t != `null`) { - t.itest2() - t.itest1() - t.itest() - t.test1() - t.test2() - t + t.itest2() + t.itest1() + t.itest() + t.test1() + t.test2() + t } } } @@ -1366,12 +1366,12 @@ fun case_74(t: Any?) { if (t == implicitNullableNothingProperty || t === implicitNullableNothingProperty || t !is Interface1?) else { if (t is ClassLevel2?) { if (t is Interface3?) { - t.itest2() - t.itest1() - t.itest() - t.test1() - t.test2() - t + t.itest2() + t.itest1() + t.itest() + t.test1() + t.test2() + t } } } @@ -1389,19 +1389,19 @@ fun case_75(t: Any?, z: Nothing?) { if (t !is ClassLevel2? || t !is ClassLevel1?) else { if (t === ((((((z)))))) || t !is Interface1?) else { if (t !is Interface2? || t !is Interface3?) {} else { - t.itest2() - t.itest1() - t.itest() - t.test1() - t.test2() - t + t.itest2() + t.itest1() + t.itest() + t.test1() + t.test2() + t } } } } // TESTCASE NUMBER: 76 -fun case_76(a: Any?, b: Int = if (a !is Number? === true || a !is Int? == true || a != null == false == true) 0 else a) { +fun case_76(a: Any?, b: Int = if (a !is Number? === true || a !is Int? == true || a != null == false == true) 0 else a) { a b b.equals(null) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/60.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/60.fir.kt index b65a81990b3..f43dabe635c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/60.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/60.fir.kt @@ -10,7 +10,7 @@ fun case_1() { inner@ do { x = null } while (x == null) - x - x.length + x + x.length } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/61.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/61.fir.kt index 005379fe2c6..845ade6e46a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/61.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/61.fir.kt @@ -11,8 +11,8 @@ class Case1 { init { var y: String? = "xyz" if (y != null) { - y - y.length + y + y.length } } constructor() @@ -23,8 +23,8 @@ class Case2 { init { var y: String? = "xyz" if (y != null) { - y - y.length + y + y.length } } } @@ -34,8 +34,8 @@ class Case3 { init { var y: String? = "xyz" if (y != null) { - y - y.length + y + y.length } } init { } @@ -50,8 +50,8 @@ class Case4 { init { var y: String? = "xyz" if (y != null) { - y - y.length + y + y.length } } constructor(y: Int?) { @@ -64,8 +64,8 @@ class Case5() { init { var y: String? = "xyz" if (y != null) { - y - y.length + y + y.length } } constructor(y: Int?) : this() { @@ -78,8 +78,8 @@ class Case6() { init { var y: String? = "xyz" if (y != null) { - y - y.length + y + y.length } } } @@ -89,8 +89,8 @@ class Case7() { init { var y: String? = "xyz" if (y != null) { - y - y.length + y + y.length } } constructor(y: Int?) : this() { @@ -110,8 +110,8 @@ class Case8 { init { var y: String? = "xyz" y!! - y - y.length + y + y.length } constructor() } @@ -125,8 +125,8 @@ class Case9 { init { var y: String? = "xyz" if (y == null) throw Exception() - y - y.length + y + y.length } constructor() } @@ -140,8 +140,8 @@ class Case10 { init { var y: String? = "xyz" y ?: throw Exception() - y - y.length + y + y.length } constructor() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/63.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/63.fir.kt index eeb2b8b04c0..2a7943a7a4a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/63.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/63.fir.kt @@ -11,8 +11,8 @@ fun case_1(x: String?) { when { x == null -> return } - x - x.length + x + x.length } // TESTCASE NUMBER: 2 @@ -21,8 +21,8 @@ fun case_2(x: String?) { x == null -> return else -> println(1) } - x - x.length + x + x.length } /* @@ -34,8 +34,8 @@ fun case_3(x: String?) { when (x) { null -> return } - x - x.length + x + x.length } // TESTCASE NUMBER: 4 @@ -44,8 +44,8 @@ fun case_4(x: String?) { null -> return else -> println(1) } - x - x.length + x + x.length } // TESTCASE NUMBER: 5 @@ -54,8 +54,8 @@ fun case_5(x: String?) { null -> throw Exception() else -> println(1) } - x - x.length + x + x.length } /* @@ -67,6 +67,6 @@ fun case_6(x: String?) { when (x) { null -> throw Exception() } - x - x.length + x + x.length } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt index 21ed46acb38..d2e5de161c9 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt @@ -31,8 +31,8 @@ class Case2 { if (x == null) { x = getInt() } - x - x.equals(10) + x + x.equals(10) return x } } @@ -49,7 +49,7 @@ class Case3 { fun get(): T { var x = getTN() x = x ?: getT() - x + x return x } } @@ -62,8 +62,8 @@ class Case4 { fun get(): Int { var x = getIntN() x = x ?: getInt() - x - x.equals(10) + x + x.equals(10) return x } } @@ -76,7 +76,7 @@ class Case5 { fun get(): T { var x = getTN() x = if (x == null) getT() else x - x + x return x } } @@ -89,8 +89,8 @@ class Case6 { fun get(): Int { var x = getIntN() x = if (x == null) getInt() else x - x - x.equals(10) + x + x.equals(10) return x } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/65.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/65.fir.kt index f45741f0723..8eddc40995f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/65.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/65.fir.kt @@ -12,8 +12,8 @@ fun case_1(x: Class) { // TESTCASE NUMBER: 2 fun case_2(x: Any?) { if (x !is String) return - x - x.length + x + x.length } // TESTCASE NUMBER: 3 @@ -26,8 +26,8 @@ fun case_3(x: Class) { // TESTCASE NUMBER: 4 fun case_4(x: Any?) { if (x !is String) throw Exception() - x - x.length + x + x.length } // TESTCASE NUMBER: 5 @@ -40,22 +40,22 @@ fun case_5(x: Class) { // TESTCASE NUMBER: 6 fun case_6(x: Any?) { if (x !is String?) throw Exception() - x - x?.length + x + x?.length } // TESTCASE NUMBER: 7 fun case_7(x: Any?) { if (x !is Pair<*, *>) throw Exception() - & kotlin.Any?")!>x - & kotlin.Any?")!>x.first + ")!>x + ")!>x.first } // TESTCASE NUMBER: 8 fun case_8(x: Any?) { if (x !is Pair<*, *>?) return - ? & kotlin.Any?")!>x - ? & kotlin.Any?")!>x?.first + ?")!>x + ?")!>x?.first } // TESTCASE NUMBER: 9 @@ -63,12 +63,12 @@ fun case_9(x: Any?) { when (x) { !is Pair<*, *> -> throw Exception() else -> { - & kotlin.Any?")!>x - & kotlin.Any?")!>x.first + ")!>x + ")!>x.first } } - & kotlin.Any?")!>x - & kotlin.Any?")!>x.first + ")!>x + ")!>x.first } // TESTCASE NUMBER: 10 @@ -76,12 +76,12 @@ fun case_10(x: Any?) { when (x) { !is Pair<*, *>? -> return else -> { - ? & kotlin.Any?")!>x - ? & kotlin.Any?")!>x?.first + ?")!>x + ?")!>x?.first } } - ? & kotlin.Any?")!>x - ? & kotlin.Any?")!>x?.first + ?")!>x + ?")!>x?.first } // TESTCASE NUMBER: 11 @@ -89,12 +89,12 @@ fun case_11(x: Any?) { when { x !is Pair<*, *> -> throw Exception() else -> { - & kotlin.Any?")!>x - & kotlin.Any?")!>x.first + ")!>x + ")!>x.first } } - & kotlin.Any?")!>x - & kotlin.Any?")!>x.first + ")!>x + ")!>x.first } // TESTCASE NUMBER: 12 @@ -102,10 +102,10 @@ fun case_12(x: Any?) { when { x !is Pair<*, *>? -> return else -> { - ? & kotlin.Any?")!>x - ? & kotlin.Any?")!>x?.first + ?")!>x + ?")!>x?.first } } - ? & kotlin.Any?")!>x - ? & kotlin.Any?")!>x?.first + ?")!>x + ?")!>x?.first } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt index 1b28a337f52..09ba8fc695b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt @@ -9,8 +9,8 @@ */ fun case_1(x: Any?) { if (x !is Nothing?) { - x - x.equals(10) + x + x.equals(10) } } @@ -61,13 +61,13 @@ fun case_4(x: Pair<*, *>?) { fun case_5(x: Pair<*, *>?) { when (x) { !is Nothing? -> { - & kotlin.Pair<*, *>?")!>x - & kotlin.Pair<*, *>?")!>x.equals(10) + ? & kotlin.Pair<*, *>")!>x + ? & kotlin.Pair<*, *>")!>x.equals(10) } else -> return } - & kotlin.Pair<*, *>?")!>x - & kotlin.Pair<*, *>?")!>x.equals(10) + ? & kotlin.Pair<*, *>")!>x + ? & kotlin.Pair<*, *>")!>x.equals(10) } /* diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/67.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/67.fir.kt index e54696ae2ea..2c9c1cf71b6 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/67.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/67.fir.kt @@ -6,35 +6,35 @@ fun case_1(x: Any?) { when (x) { is Any -> { - x - x.equals(10) + x + x.equals(10) } else -> return } - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 2 inline fun case_2(x: Any?) { when (x) { is T -> { - x - x.equals(10) + x + x.equals(10) } else -> return } - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 3 inline fun case_3(x: Any?) { if (x is T) { - x - x.equals(10) + x + x.equals(10) } else throw Exception() - x - x.equals(10) + x + x.equals(10) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/68.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/68.fir.kt index a56cc5ccb1d..5256453fa6f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/68.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/68.fir.kt @@ -5,61 +5,61 @@ // TESTCASE NUMBER: 1 fun case_1(x: Any?) { if (x!! is Int) { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 2 fun case_2(x: Any?) { (x as Nothing?)!! - x - x.inv() + x + x.inv() } // TESTCASE NUMBER: 3 fun case_3(x: Any?) { if (x as Number? is Int) { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 4 fun case_4(x: Any?) { if (x as Class? is Class) { - x - x.prop_1 + x + x.prop_1 } } // TESTCASE NUMBER: 5 fun case_5(x: Any?) { if (x as Nothing? is Nothing) { - x - x.inv() + x + x.inv() } } // TESTCASE NUMBER: 6 fun case_6(x: Any?) { (x as String?)!! - x - x.length + x + x.length } // TESTCASE NUMBER: 7 fun case_7(x: Any?) { if (x as String? != null) { - x - x.length + x + x.length } } // TESTCASE NUMBER: 8 fun case_8(x: Any?) { if (x as String? == null) { - x - x.length + x + x.length } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt index 491a877b8cd..24ad68a1d8d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt @@ -5,31 +5,31 @@ // TESTCASE NUMBER: 1 fun test1(x: ClassLevel1?) { if (x!! is ClassLevel2) { - x - x.test2() + x + x.test2() } } // TESTCASE NUMBER: 2 fun case_2(x: Any?) { (x as ClassLevel1?)!! - x - x.test1() + x + x.test1() } // TESTCASE NUMBER: 3 fun case_3(x: Any?) { if (x as ClassLevel1? is ClassLevel1) { - x - x.test1() + x + x.test1() } } // TESTCASE NUMBER: 4 fun case_4(x: Any?) { if ((x as Class).prop_8 != null) { - x - x.prop_8.prop_8 + x + x.prop_8.prop_8 } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt index 076f229c9ff..76b0c3c5964 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt @@ -19,16 +19,16 @@ import orherpackage.* // TESTCASE NUMBER: 1 fun case_1(x: Any?) { if (x != null || x != null || x != null || x != null || x != null || x != null || x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -63,16 +63,16 @@ fun case_3() { // TESTCASE NUMBER: 4 fun case_4(x: Char?) { if (x != null && true || x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -81,16 +81,16 @@ fun case_5() { val x: Unit? = null if (x !== null || x !== null && x !== null || x !== null && x !== null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -116,16 +116,16 @@ fun case_6(x: Class?) { fun case_7() { val x: EmptyObject? = null if (x != null || x != null || x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -151,16 +151,16 @@ fun case_9(x: TypealiasNullableString?) { } else if (x === null || x === null) { } else if (false) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -195,16 +195,16 @@ fun case_11(x: TypealiasNullableString?, y: TypealiasNullableString) { if (y != null || y != null) { if (stringProperty == null && nullableNothingProperty == null) { if (t != null || t != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -215,16 +215,16 @@ fun case_11(x: TypealiasNullableString?, y: TypealiasNullableString) { // TESTCASE NUMBER: 12 fun case_12(x: TypealiasNullableString, y: TypealiasNullableString) = if (x == null) "1" else if (y === null || y === null) { - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x } else "-1" // TESTCASE NUMBER: 13 @@ -232,16 +232,16 @@ fun case_13(x: orherpackage.EmptyClass13?, y: Nothing?) = if (x == null || x === y) { throw Exception() } else { - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x } // TESTCASE NUMBER: 14 @@ -265,16 +265,16 @@ fun case_14() { fun case_15(x: TypealiasString?) { var y = null val t = if (x === null || x == y && x === y) "" else { - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x } } @@ -291,16 +291,16 @@ fun case_16() { // TESTCASE NUMBER: 17 val case_17 = if (nullableIntProperty == null || nullableNothingProperty === nullableIntProperty) 0 else { - nullableIntProperty.equals(null) - nullableIntProperty.propT - nullableIntProperty.propAny - nullableIntProperty.propNullableT - nullableIntProperty.propNullableAny - nullableIntProperty.funT() - nullableIntProperty.funAny() - nullableIntProperty.funNullableT() - nullableIntProperty.funNullableAny() - nullableIntProperty + nullableIntProperty.equals(null) + nullableIntProperty.propT + nullableIntProperty.propAny + nullableIntProperty.propNullableT + nullableIntProperty.propNullableAny + nullableIntProperty.funT() + nullableIntProperty.funAny() + nullableIntProperty.funNullableT() + nullableIntProperty.funNullableAny() + nullableIntProperty } /* @@ -478,16 +478,16 @@ fun case_25(b: Boolean) { val z = ?")!>y() if (z != null) { - & ?")!>z.a - & ?")!>z.equals(null) - & ?")!>z.propT - & ?")!>z.propAny - & ?")!>z.propNullableT - & ?")!>z.propNullableAny - & ?")!>z.funT() - & ?")!>z.funAny() - & ?")!>z.funNullableT() - & ?")!>z.funNullableAny() + ? & ")!>z.a + ? & ")!>z.equals(null) + ? & ")!>z.propT + ? & ")!>z.propAny + ? & ")!>z.propNullableT + ? & ")!>z.propNullableAny + ? & ")!>z.funT() + ? & ")!>z.funAny() + ? & ")!>z.funNullableT() + ? & ")!>z.funNullableAny() } } } @@ -500,16 +500,16 @@ fun case_26(a: ((Float) -> Int?)?, b: Float?) { if (a != null == true && b != null == true || c != a == true && b != c == true) { val x = a(b) if (x != null == true) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } } @@ -534,16 +534,16 @@ fun case_27(y: Nothing?) { //TESTCASE NUMBER: 28 fun case_28(a: DeepObject.A.B.C.D.E.F.G.J?) = if (a != null == true == false == false == false == true == false == true == false == false == true == true && a.x !== nullableNothingProperty) { - a.x - a.equals(null) - a.propT - a.propAny - a.propNullableT - a.propNullableAny - a.funT() - a.funAny() - a.funNullableT() - a.funNullableAny() + a.x + a.equals(null) + a.propT + a.propAny + a.propNullableT + a.propNullableAny + a.funT() + a.funAny() + a.funNullableT() + a.funNullableAny() } else -1 // TESTCASE NUMBER: 29 diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/70.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/70.fir.kt index b94a96eb72f..d32762d5c7d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/70.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/70.fir.kt @@ -10,8 +10,8 @@ fun case_1(): Int? { val x: Int? = null return when (x != null) { true -> { - x - x.inv() + x + x.inv() } else -> null } @@ -39,7 +39,7 @@ fun case_3(): Int? { val x: Int? = null return when (x == null) { false -> { - x + x } else -> null } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt index 595073bb314..f10b4dc77aa 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt @@ -11,7 +11,7 @@ fun case_1() { run { var unit: Unit? = Unit while (unit != null) { - unit + unit consume(unit) unit = null } @@ -20,7 +20,7 @@ fun case_1() { run { var unit: Unit? = Unit while (unit != null) { - unit + unit consume(unit) unit = null } @@ -36,7 +36,7 @@ fun case_2(): Int { fun b(): Int { var c: Int? = null if (c == null || 0 < c) c = 0 - c + c return c ?: 0 } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/72.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/72.fir.kt index 4076e05dfac..f2e83290499 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/72.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/72.fir.kt @@ -12,6 +12,6 @@ fun case_1() { val ints = list as MutableList val strs = list as MutableList strs.add("two") - & kotlin.collections.MutableList & kotlin.collections.MutableList")!>list - val s: String = & kotlin.collections.MutableList & kotlin.collections.MutableList")!>list[0] + & kotlin.collections.MutableList & kotlin.collections.MutableList")!>list + val s: String = & kotlin.collections.MutableList & kotlin.collections.MutableList")!>list[0] } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/73.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/73.fir.kt index 2b31c481330..ab26341d5ef 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/73.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/73.fir.kt @@ -9,8 +9,8 @@ */ fun case_1(x: Any?) { x is ClassLevel1 || return - x - x.test1() + x + x.test1() } /* @@ -20,8 +20,8 @@ fun case_1(x: Any?) { */ fun case_2(x: Any?) { x !is ClassLevel1 && return - x - x.test1() + x + x.test1() } /* @@ -30,6 +30,6 @@ fun case_2(x: Any?) { */ fun case_3(x: Any?) { x as? ClassLevel1 ?: return - x - x.test1() + x + x.test1() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt index eab764412c4..14f935ba289 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/8.fir.kt @@ -5,44 +5,44 @@ // TESTCASE NUMBER: 1 fun case_1(x: Inv?) { if (x != null) { - & Inv?")!>x - & Inv?")!>x.equals(null) - & Inv?")!>x.propT - & Inv?")!>x.propAny - & Inv?")!>x.propNullableT - & Inv?")!>x.propNullableAny - & Inv?")!>x.funT() - & Inv?")!>x.funAny() - & Inv?")!>x.funNullableT() - & Inv?")!>x.funNullableAny() + ? & Inv")!>x + ? & Inv")!>x.equals(null) + ? & Inv")!>x.propT + ? & Inv")!>x.propAny + ? & Inv")!>x.propNullableT + ? & Inv")!>x.propNullableAny + ? & Inv")!>x.funT() + ? & Inv")!>x.funAny() + ? & Inv")!>x.funNullableT() + ? & Inv")!>x.funNullableAny() } } // TESTCASE NUMBER: 2 fun case_2(a: Inv?>?>?>?>?>?) { if (a != null) { - val b = ?>?>?>?>?> & Inv?>?>?>?>?>?")!>a.get() + val b = ?>?>?>?>?>? & Inv?>?>?>?>?>")!>a.get() if (b != null) { - val c = ?>?>?>?> & Inv?>?>?>?>?")!>b.get() + val c = ?>?>?>?>? & Inv?>?>?>?>")!>b.get() if (c != null) { - val d = ?>?>?> & Inv?>?>?>?")!>c.get() + val d = ?>?>?>? & Inv?>?>?>")!>c.get() if (d != null) { - val e = ?>?> & Inv?>?>?")!>d.get() + val e = ?>?>? & Inv?>?>")!>d.get() if (e != null) { - val f = ?> & Inv?>?")!>e.get() + val f = ?>? & Inv?>")!>e.get() if (f != null) { - val g = & Inv?")!>f.get() + val g = ? & Inv")!>f.get() if (g != null) { - g - g.equals(null) - g.propT - g.propAny - g.propNullableT - g.propNullableAny - g.funT() - g.funAny() - g.funNullableT() - g.funNullableAny() + g + g.equals(null) + g.propT + g.propAny + g.propNullableT + g.propNullableAny + g.funT() + g.funAny() + g.funNullableT() + g.funNullableAny() } } } @@ -57,22 +57,22 @@ fun case_3(a: Inv?) { if (a != null) { val b = a if (a == null) { - & Inv?")!>b - & Inv?")!>b.equals(null) - & Inv?")!>b.propT - & Inv?")!>b.propAny - & Inv?")!>b.propNullableT - & Inv?")!>b.propNullableAny - & Inv?")!>b.funT() - & Inv?")!>b.funAny() - & Inv?")!>b.funNullableT() - & Inv?")!>b.funNullableAny() + ? & Inv")!>b + ? & Inv")!>b.equals(null) + ? & Inv")!>b.propT + ? & Inv")!>b.propAny + ? & Inv")!>b.propNullableT + ? & Inv")!>b.propNullableAny + ? & Inv")!>b.funT() + ? & Inv")!>b.funAny() + ? & Inv")!>b.funNullableT() + ? & Inv")!>b.funNullableAny() } } } // TESTCASE NUMBER: 4 -fun case_4(a: Inv?, b: Inv = if (a != null) & Inv?")!>a else Inv()) { +fun case_4(a: Inv?, b: Inv = if (a != null) ? & Inv")!>a else Inv()) { ?")!>a ")!>b ")!>b.equals(null) @@ -89,16 +89,16 @@ fun case_4(a: Inv?, b: Inv = if (a != null) & Out?")!>nullableOut - & Out?")!>nullableOut.equals(null) - & Out?")!>nullableOut.propT - & Out?")!>nullableOut.propAny - & Out?")!>nullableOut.propNullableT - & Out?")!>nullableOut.propNullableAny - & Out?")!>nullableOut.funT() - & Out?")!>nullableOut.funAny() - & Out?")!>nullableOut.funNullableT() - & Out?")!>nullableOut.funNullableAny() + ? & Out")!>nullableOut + ? & Out")!>nullableOut.equals(null) + ? & Out")!>nullableOut.propT + ? & Out")!>nullableOut.propAny + ? & Out")!>nullableOut.propNullableT + ? & Out")!>nullableOut.propNullableAny + ? & Out")!>nullableOut.funT() + ? & Out")!>nullableOut.funAny() + ? & Out")!>nullableOut.funNullableT() + ? & Out")!>nullableOut.funNullableAny() } } @@ -107,16 +107,16 @@ fun case_6() { val x: Inv? = null if (x != null) { - & Inv?")!>x - & Inv?")!>x.equals(null) - & Inv?")!>x.propT - & Inv?")!>x.propAny - & Inv?")!>x.propNullableT - & Inv?")!>x.propNullableAny - & Inv?")!>x.funT() - & Inv?")!>x.funAny() - & Inv?")!>x.funNullableT() - & Inv?")!>x.funNullableAny() + ? & Inv")!>x + ? & Inv")!>x.equals(null) + ? & Inv")!>x.propT + ? & Inv")!>x.propAny + ? & Inv")!>x.propNullableT + ? & Inv")!>x.propNullableAny + ? & Inv")!>x.funT() + ? & Inv")!>x.funAny() + ? & Inv")!>x.funNullableT() + ? & Inv")!>x.funNullableAny() } } @@ -125,32 +125,32 @@ fun case_7() { var x: Inv? = null if (x != null) { - & Inv?")!>x - & Inv?")!>x.equals(null) - & Inv?")!>x.propT - & Inv?")!>x.propAny - & Inv?")!>x.propNullableT - & Inv?")!>x.propNullableAny - & Inv?")!>x.funT() - & Inv?")!>x.funAny() - & Inv?")!>x.funNullableT() - & Inv?")!>x.funNullableAny() + ? & Inv")!>x + ? & Inv")!>x.equals(null) + ? & Inv")!>x.propT + ? & Inv")!>x.propAny + ? & Inv")!>x.propNullableT + ? & Inv")!>x.propNullableAny + ? & Inv")!>x.funT() + ? & Inv")!>x.funAny() + ? & Inv")!>x.funNullableT() + ? & Inv")!>x.funNullableAny() } } // TESTCASE NUMBER: 8 fun case_8(x: ClassWithThreeTypeParameters?>?) { if (x != null) { - ?> & ClassWithThreeTypeParameters?>?")!>x - ?> & ClassWithThreeTypeParameters?>?")!>x.equals(null) - ?> & ClassWithThreeTypeParameters?>?")!>x.propT - ?> & ClassWithThreeTypeParameters?>?")!>x.propAny - ?> & ClassWithThreeTypeParameters?>?")!>x.propNullableT - ?> & ClassWithThreeTypeParameters?>?")!>x.propNullableAny - ?> & ClassWithThreeTypeParameters?>?")!>x.funT() - ?> & ClassWithThreeTypeParameters?>?")!>x.funAny() - ?> & ClassWithThreeTypeParameters?>?")!>x.funNullableT() - ?> & ClassWithThreeTypeParameters?>?")!>x.funNullableAny() + ?>? & ClassWithThreeTypeParameters?>")!>x + ?>? & ClassWithThreeTypeParameters?>")!>x.equals(null) + ?>? & ClassWithThreeTypeParameters?>")!>x.propT + ?>? & ClassWithThreeTypeParameters?>")!>x.propAny + ?>? & ClassWithThreeTypeParameters?>")!>x.propNullableT + ?>? & ClassWithThreeTypeParameters?>")!>x.propNullableAny + ?>? & ClassWithThreeTypeParameters?>")!>x.funT() + ?>? & ClassWithThreeTypeParameters?>")!>x.funAny() + ?>? & ClassWithThreeTypeParameters?>")!>x.funNullableT() + ?>? & ClassWithThreeTypeParameters?>")!>x.funNullableAny() if (x.x != null) { x.x x.x.equals(null) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt index 59bd9a60449..f6479804ae3 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/9.fir.kt @@ -5,16 +5,16 @@ // TESTCASE NUMBER: 1 fun case_1(x: Out?) { if (x != null) { - & Out?")!>x - & Out?")!>x.equals(null) - & Out?")!>x.propT - & Out?")!>x.propAny - & Out?")!>x.propNullableT - & Out?")!>x.propNullableAny - & Out?")!>x.funT() - & Out?")!>x.funAny() - & Out?")!>x.funNullableT() - & Out?")!>x.funNullableAny() + ? & Out")!>x + ? & Out")!>x.equals(null) + ? & Out")!>x.propT + ? & Out")!>x.propAny + ? & Out")!>x.propNullableT + ? & Out")!>x.propNullableAny + ? & Out")!>x.funT() + ? & Out")!>x.funAny() + ? & Out")!>x.funNullableT() + ? & Out")!>x.funNullableAny() } } @@ -25,28 +25,28 @@ fun case_1(x: Out?) { */ fun case_2(a: Out?>?>?>?>?>?) { if (a != null) { - val b = ?>?>?>?>?> & Out?>?>?>?>?>?")!>a.get() + val b = ?>?>?>?>?>? & Out?>?>?>?>?>")!>a.get() if (b != null) { - val c = ?>?>?>?> & Out?>?>?>?>?")!>b.get() + val c = ?>?>?>?>? & Out?>?>?>?>")!>b.get() if (c != null) { - val d = ?>?>?> & Out?>?>?>?")!>c.get() + val d = ?>?>?>? & Out?>?>?>")!>c.get() if (d != null) { - val e = ?>?> & Out?>?>?")!>d.get() + val e = ?>?>? & Out?>?>")!>d.get() if (e != null) { - val f = ?> & Out?>?")!>e.get() + val f = ?>? & Out?>")!>e.get() if (f != null) { - val g = & Out?")!>f.get() + val g = ? & Out")!>f.get() if (g != null) { - g - g.equals(null) - g.propT - g.propAny - g.propNullableT - g.propNullableAny - g.funT() - g.funAny() - g.funNullableT() - g.funNullableAny() + g + g.equals(null) + g.propT + g.propAny + g.propNullableT + g.propNullableAny + g.funT() + g.funAny() + g.funNullableT() + g.funNullableAny() } } } @@ -61,21 +61,21 @@ fun case_3(a: Inv?) { if (a != null) { val b = a if (a == null) - & Inv?")!>b - & Inv?")!>b.equals(null) - & Inv?")!>b.propT - & Inv?")!>b.propAny - & Inv?")!>b.propNullableT - & Inv?")!>b.propNullableAny - & Inv?")!>b.funT() - & Inv?")!>b.funAny() - & Inv?")!>b.funNullableT() - & Inv?")!>b.funNullableAny() + ? & Inv")!>b + ? & Inv")!>b.equals(null) + ? & Inv")!>b.propT + ? & Inv")!>b.propAny + ? & Inv")!>b.propNullableT + ? & Inv")!>b.propNullableAny + ? & Inv")!>b.funT() + ? & Inv")!>b.funAny() + ? & Inv")!>b.funNullableT() + ? & Inv")!>b.funNullableAny() } } // TESTCASE NUMBER: 4 -fun case_4(a: Out?, b: Out = if (a != null) & Out?")!>a else Out()) { +fun case_4(a: Out?, b: Out = if (a != null) ? & Out")!>a else Out()) { ?")!>a ")!>b ")!>b.equals(null) @@ -94,16 +94,16 @@ val x: Out? = null fun case_5() { if (x != null) { - & Out?")!>x - & Out?")!>x.equals(null) - & Out?")!>x.propT - & Out?")!>x.propAny - & Out?")!>x.propNullableT - & Out?")!>x.propNullableAny - & Out?")!>x.funT() - & Out?")!>x.funAny() - & Out?")!>x.funNullableT() - & Out?")!>x.funNullableAny() + ? & Out")!>x + ? & Out")!>x.equals(null) + ? & Out")!>x.propT + ? & Out")!>x.propAny + ? & Out")!>x.propNullableT + ? & Out")!>x.propNullableAny + ? & Out")!>x.funT() + ? & Out")!>x.funAny() + ? & Out")!>x.funNullableT() + ? & Out")!>x.funNullableAny() } } @@ -112,16 +112,16 @@ fun case_6() { val x: Inv? = null if (x != null) { - & Inv?")!>x - & Inv?")!>x.equals(null) - & Inv?")!>x.propT - & Inv?")!>x.propAny - & Inv?")!>x.propNullableT - & Inv?")!>x.propNullableAny - & Inv?")!>x.funT() - & Inv?")!>x.funAny() - & Inv?")!>x.funNullableT() - & Inv?")!>x.funNullableAny() + ? & Inv")!>x + ? & Inv")!>x.equals(null) + ? & Inv")!>x.propT + ? & Inv")!>x.propAny + ? & Inv")!>x.propNullableT + ? & Inv")!>x.propNullableAny + ? & Inv")!>x.funT() + ? & Inv")!>x.funAny() + ? & Inv")!>x.funNullableT() + ? & Inv")!>x.funNullableAny() } } @@ -130,16 +130,16 @@ fun case_7() { var x: Out? = null if (x != null) { - & Out?")!>x - & Out?")!>x.equals(null) - & Out?")!>x.propT - & Out?")!>x.propAny - & Out?")!>x.propNullableT - & Out?")!>x.propNullableAny - & Out?")!>x.funT() - & Out?")!>x.funAny() - & Out?")!>x.funNullableT() - & Out?")!>x.funNullableAny() + ? & Out")!>x + ? & Out")!>x.equals(null) + ? & Out")!>x.propT + ? & Out")!>x.propAny + ? & Out")!>x.propNullableT + ? & Out")!>x.propNullableAny + ? & Out")!>x.funT() + ? & Out")!>x.funAny() + ? & Out")!>x.funNullableT() + ? & Out")!>x.funNullableAny() } } @@ -150,16 +150,16 @@ fun case_7() { */ fun case_8(x: ClassWithThreeTypeParameters?>?) { if (x != null) { - ?> & ClassWithThreeTypeParameters?>?")!>x - ?> & ClassWithThreeTypeParameters?>?")!>x.equals(null) - ?> & ClassWithThreeTypeParameters?>?")!>x.propT - ?> & ClassWithThreeTypeParameters?>?")!>x.propAny - ?> & ClassWithThreeTypeParameters?>?")!>x.propNullableT - ?> & ClassWithThreeTypeParameters?>?")!>x.propNullableAny - ?> & ClassWithThreeTypeParameters?>?")!>x.funT() - ?> & ClassWithThreeTypeParameters?>?")!>x.funAny() - ?> & ClassWithThreeTypeParameters?>?")!>x.funNullableT() - ?> & ClassWithThreeTypeParameters?>?")!>x.funNullableAny() + ?>? & ClassWithThreeTypeParameters?>")!>x + ?>? & ClassWithThreeTypeParameters?>")!>x.equals(null) + ?>? & ClassWithThreeTypeParameters?>")!>x.propT + ?>? & ClassWithThreeTypeParameters?>")!>x.propAny + ?>? & ClassWithThreeTypeParameters?>")!>x.propNullableT + ?>? & ClassWithThreeTypeParameters?>")!>x.propNullableAny + ?>? & ClassWithThreeTypeParameters?>")!>x.funT() + ?>? & ClassWithThreeTypeParameters?>")!>x.funAny() + ?>? & ClassWithThreeTypeParameters?>")!>x.funNullableT() + ?>? & ClassWithThreeTypeParameters?>")!>x.funNullableAny() if (x.x != null) { x.x x.x.equals(null) @@ -238,16 +238,16 @@ fun case_9(a: (Inv) -> Inv?, b: Inv?) { if (b != null) { val c = a(b) if (c != null) { - & Inv?")!>c - & Inv?")!>c.equals(null) - & Inv?")!>c.propT - & Inv?")!>c.propAny - & Inv?")!>c.propNullableT - & Inv?")!>c.propNullableAny - & Inv?")!>c.funT() - & Inv?")!>c.funAny() - & Inv?")!>c.funNullableT() - & Inv?")!>c.funNullableAny() + ? & Inv")!>c + ? & Inv")!>c.equals(null) + ? & Inv")!>c.propT + ? & Inv")!>c.propAny + ? & Inv")!>c.propNullableT + ? & Inv")!>c.propNullableAny + ? & Inv")!>c.funT() + ? & Inv")!>c.funAny() + ? & Inv")!>c.funNullableT() + ? & Inv")!>c.funNullableAny() } } } @@ -255,16 +255,16 @@ fun case_9(a: (Inv) -> Inv?, b: Inv?) { // TESTCASE NUMBER: 10 fun case_9(a: Inv<*>?) { if (a != null) { - & Inv<*>?")!>a - & Inv<*>?")!>a.equals(null) - & Inv<*>?")!>a.propT - & Inv<*>?")!>a.propAny - & Inv<*>?")!>a.propNullableT - & Inv<*>?")!>a.propNullableAny - & Inv<*>?")!>a.funT() - & Inv<*>?")!>a.funAny() - & Inv<*>?")!>a.funNullableT() - & Inv<*>?")!>a.funNullableAny() + ? & Inv<*>")!>a + ? & Inv<*>")!>a.equals(null) + ? & Inv<*>")!>a.propT + ? & Inv<*>")!>a.propAny + ? & Inv<*>")!>a.propNullableT + ? & Inv<*>")!>a.propNullableAny + ? & Inv<*>")!>a.funT() + ? & Inv<*>")!>a.funAny() + ? & Inv<*>")!>a.funNullableT() + ? & Inv<*>")!>a.funNullableAny() } } @@ -273,16 +273,16 @@ fun case_10() { val a10: Out<*>? = null if (a10 != null) { - & Out<*>?")!>a10 - & Out<*>?")!>a10.equals(null) - & Out<*>?")!>a10.propT - & Out<*>?")!>a10.propAny - & Out<*>?")!>a10.propNullableT - & Out<*>?")!>a10.propNullableAny - & Out<*>?")!>a10.funT() - & Out<*>?")!>a10.funAny() - & Out<*>?")!>a10.funNullableT() - & Out<*>?")!>a10.funNullableAny() + ? & Out<*>")!>a10 + ? & Out<*>")!>a10.equals(null) + ? & Out<*>")!>a10.propT + ? & Out<*>")!>a10.propAny + ? & Out<*>")!>a10.propNullableT + ? & Out<*>")!>a10.propNullableAny + ? & Out<*>")!>a10.funT() + ? & Out<*>")!>a10.funAny() + ? & Out<*>")!>a10.funNullableT() + ? & Out<*>")!>a10.funNullableAny() } } @@ -291,48 +291,48 @@ fun case_11() { val a: In<*>? = null if (a != null) { - & In<*>?")!>a - & In<*>?")!>a.equals(null) - & In<*>?")!>a.propT - & In<*>?")!>a.propAny - & In<*>?")!>a.propNullableT - & In<*>?")!>a.propNullableAny - & In<*>?")!>a.funT() - & In<*>?")!>a.funAny() - & In<*>?")!>a.funNullableT() - & In<*>?")!>a.funNullableAny() + ? & In<*>")!>a + ? & In<*>")!>a.equals(null) + ? & In<*>")!>a.propT + ? & In<*>")!>a.propAny + ? & In<*>")!>a.propNullableT + ? & In<*>")!>a.propNullableAny + ? & In<*>")!>a.funT() + ? & In<*>")!>a.funAny() + ? & In<*>")!>a.funNullableT() + ? & In<*>")!>a.funNullableAny() } } // TESTCASE NUMBER: 13 fun case_13(a: ClassWithSixTypeParameters<*, *, *, *, *, *>?) { if (a != null) { - & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>a - & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>a.equals(null) - & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>a.propT - & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>a.propAny - & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>a.propNullableT - & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>a.propNullableAny - & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>a.funT() - & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>a.funAny() - & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>a.funNullableT() - & ClassWithSixTypeParameters<*, *, *, *, *, *>?")!>a.funNullableAny() + ? & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>a + ? & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>a.equals(null) + ? & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>a.propT + ? & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>a.propAny + ? & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>a.propNullableT + ? & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>a.propNullableAny + ? & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>a.funT() + ? & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>a.funAny() + ? & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>a.funNullableT() + ? & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>a.funNullableAny() } } // TESTCASE NUMBER: 14 fun case_14(a: ClassWithSixTypeParameters<*, Int, *, Out<*>, *, Map>>?) { if (a != null) { - , *, kotlin.collections.Map>> & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>?")!>a - , *, kotlin.collections.Map>> & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>?")!>a.equals(null) - , *, kotlin.collections.Map>> & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>?")!>a.propT - , *, kotlin.collections.Map>> & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>?")!>a.propAny - , *, kotlin.collections.Map>> & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>?")!>a.propNullableT - , *, kotlin.collections.Map>> & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>?")!>a.propNullableAny - , *, kotlin.collections.Map>> & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>?")!>a.funT() - , *, kotlin.collections.Map>> & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>?")!>a.funAny() - , *, kotlin.collections.Map>> & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>?")!>a.funNullableT() - , *, kotlin.collections.Map>> & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>?")!>a.funNullableAny() + , *, kotlin.collections.Map>>? & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>")!>a + , *, kotlin.collections.Map>>? & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>")!>a.equals(null) + , *, kotlin.collections.Map>>? & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>")!>a.propT + , *, kotlin.collections.Map>>? & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>")!>a.propAny + , *, kotlin.collections.Map>>? & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>")!>a.propNullableT + , *, kotlin.collections.Map>>? & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>")!>a.propNullableAny + , *, kotlin.collections.Map>>? & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>")!>a.funT() + , *, kotlin.collections.Map>>? & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>")!>a.funAny() + , *, kotlin.collections.Map>>? & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>")!>a.funNullableT() + , *, kotlin.collections.Map>>? & ClassWithSixTypeParameters<*, kotlin.Int, *, Out<*>, *, kotlin.collections.Map>>")!>a.funNullableAny() } } @@ -341,15 +341,15 @@ fun case_15(a: Any?) { if (a is ClassWithSixTypeParameters<*, *, *, *, *, *>?) { if (a != null) { a - & kotlin.Any?")!>a.equals(null) - & kotlin.Any?")!>a.propT - & kotlin.Any?")!>a.propAny - & kotlin.Any?")!>a.propNullableT - & kotlin.Any?")!>a.propNullableAny - & kotlin.Any?")!>a.funT() - & kotlin.Any?")!>a.funAny() - & kotlin.Any?")!>a.funNullableT() - & kotlin.Any?")!>a.funNullableAny() + ")!>a.equals(null) + ")!>a.propT + ")!>a.propAny + ")!>a.propNullableT + ")!>a.propNullableAny + ")!>a.funT() + ")!>a.funAny() + ")!>a.funNullableT() + ")!>a.funNullableAny() } } } @@ -360,16 +360,16 @@ fun case_16(a: Any?) { } else { if (a !is ClassWithSixTypeParameters<*, *, *, *, *, *>?) { } else { - & kotlin.Any?")!>a - & kotlin.Any?")!>a.equals(null) - & kotlin.Any?")!>a.propT - & kotlin.Any?")!>a.propAny - & kotlin.Any?")!>a.propNullableT - & kotlin.Any?")!>a.propNullableAny - & kotlin.Any?")!>a.funT() - & kotlin.Any?")!>a.funAny() - & kotlin.Any?")!>a.funNullableT() - & kotlin.Any?")!>a.funNullableAny() + ")!>a + ")!>a.equals(null) + ")!>a.propT + ")!>a.propAny + ")!>a.propNullableT + ")!>a.propNullableAny + ")!>a.funT() + ")!>a.funAny() + ")!>a.funNullableT() + ")!>a.funNullableAny() } } } @@ -381,28 +381,28 @@ fun case_16(a: Any?) { */ fun case_17(a: Inv?>?>?>?>?>?) { if (a != null) { - val b = ?>?>?>?>?> & Inv?>?>?>?>?>?")!>a.get() + val b = ?>?>?>?>?>? & Inv?>?>?>?>?>")!>a.get() if (b != null) { - val c = ?>?>?>?> & Out?>?>?>?>?")!>b.get() + val c = ?>?>?>?>? & Out?>?>?>?>")!>b.get() if (c != null) { - val d = ?>?>?> & Out?>?>?>?")!>c.get() + val d = ?>?>?>? & Out?>?>?>")!>c.get() if (d != null) { - val e = ?>?> & Out?>?>?")!>d.get() + val e = ?>?>? & Out?>?>")!>d.get() if (e != null) { - val f = ?> & Out?>?")!>e.get() + val f = ?>? & Out?>")!>e.get() if (f != null) { - val g = & Out?")!>f.get() + val g = ? & Out")!>f.get() if (g != null) { - g - g.equals(null) - g.propT - g.propAny - g.propNullableT - g.propNullableAny - g.funT() - g.funAny() - g.funNullableT() - g.funNullableAny() + g + g.equals(null) + g.propT + g.propAny + g.propNullableT + g.propNullableAny + g.funT() + g.funAny() + g.funNullableT() + g.funNullableAny() } } } @@ -622,16 +622,16 @@ fun case_30() { val b = a.getWithUpperBoundT(10) if (b != null) { - b - b.equals(null) - b.propT - b.propAny - b.propNullableT - b.propNullableAny - b.funT() - b.funAny() - b.funNullableT() - b.funNullableAny() + b + b.equals(null) + b.propT + b.propAny + b.propNullableT + b.propNullableAny + b.funT() + b.funAny() + b.funNullableT() + b.funNullableAny() } } @@ -640,16 +640,16 @@ fun case_31(y: Inv) { val x = y.get() if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -658,16 +658,16 @@ fun case_32(y: Inv) { val x = y.getNullable() if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -676,16 +676,16 @@ fun case_33(y: Inv) { val x = y.getNullable() if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -694,15 +694,15 @@ fun case_34(y: Inv) { val x = y.getNullable() if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } From dfcff132fdec73e70f22a17699677c10cc1ccb33 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 15 Feb 2021 17:23:16 +0300 Subject: [PATCH 194/368] [FIR] Fix false-positive smartcast on receiver in rhs of elvis #KT-44942 Fixed --- .../FirBlackBoxCodegenTestGenerated.java | 6 ++++++ .../fir/resolve/dfa/FirDataFlowAnalyzer.kt | 14 ++++++++------ .../codegen/box/smartCasts/kt44942.kt | 19 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../LightAnalysisModeTestGenerated.java | 5 +++++ .../IrJsCodegenBoxES6TestGenerated.java | 5 +++++ .../IrJsCodegenBoxTestGenerated.java | 5 +++++ .../semantics/JsCodegenBoxTestGenerated.java | 5 +++++ .../IrCodegenBoxWasmTestGenerated.java | 5 +++++ 10 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 compiler/testData/codegen/box/smartCasts/kt44942.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 60503ce7e00..8982f076273 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -37452,6 +37452,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); } + @Test + @TestMetadata("kt44942.kt") + public void testKt44942() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44942.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt index 260f375901e..5960fc3ca1a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt @@ -1136,12 +1136,6 @@ abstract class FirDataFlowAnalyzer( lhsExitNode.mergeIncomingFlow() val flow = lhsExitNode.flow val lhsVariable = variableStorage.getOrCreateVariable(flow, elvisExpression.lhs) - rhsEnterNode.flow = logicSystem.approveStatementsInsideFlow( - flow, - lhsVariable eq null, - shouldForkFlow = true, - shouldRemoveSynthetics = false - ) lhsIsNotNullNode.flow = logicSystem.approveStatementsInsideFlow( flow, lhsVariable notEq null, @@ -1152,6 +1146,14 @@ abstract class FirDataFlowAnalyzer( it.addTypeStatement(lhsVariable typeEq any) } } + rhsEnterNode.flow = logicSystem.approveStatementsInsideFlow( + flow, + lhsVariable eq null, + shouldForkFlow = true, + shouldRemoveSynthetics = false + ).also { + logicSystem.updateAllReceivers(it) + } } fun exitElvis(elvisExpression: FirElvisExpression) { diff --git a/compiler/testData/codegen/box/smartCasts/kt44942.kt b/compiler/testData/codegen/box/smartCasts/kt44942.kt new file mode 100644 index 00000000000..9289788a54d --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/kt44942.kt @@ -0,0 +1,19 @@ +// ISSUE: KT-44942 + +abstract class A { + abstract fun foo(): String +} + +class B : A() { + override fun foo(): String = "fail" + + fun bar() = "fail" +} + +class C : A() { + override fun foo(): String = "OK" +} + +fun A.test() = (this as? B)?.bar() ?: foo() + +fun box() = C().test() diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 291a14d1ad9..32dfc2c6864 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -37452,6 +37452,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); } + @Test + @TestMetadata("kt44942.kt") + public void testKt44942() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44942.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index f5ffd7be0e1..11c8ae6dd32 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -37452,6 +37452,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); } + @Test + @TestMetadata("kt44942.kt") + public void testKt44942() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44942.kt"); + } + @Test @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 0125295a2e4..3163f01223c 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -29926,6 +29926,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); } + @TestMetadata("kt44942.kt") + public void testKt44942() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44942.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index a2c682d5817..ce88f8a2ccd 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -25537,6 +25537,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); } + @TestMetadata("kt44942.kt") + public void testKt44942() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44942.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 8e9184a794f..421555239ab 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -25022,6 +25022,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); } + @TestMetadata("kt44942.kt") + public void testKt44942() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44942.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 49d053060d1..4c83fd5c74c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -24982,6 +24982,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); } + @TestMetadata("kt44942.kt") + public void testKt44942() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44942.kt"); + } + @TestMetadata("lambdaArgumentWithoutType.kt") public void testLambdaArgumentWithoutType() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 278e24bee54..ed5098f8259 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -13599,6 +13599,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/smartCasts/kt44932.kt"); } + @TestMetadata("kt44942.kt") + public void testKt44942() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44942.kt"); + } + @TestMetadata("multipleSmartCast.kt") public void testMultipleSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/multipleSmartCast.kt"); From 83ed67546b615d8a2f6f1bfad8b7b2a2ae87d450 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 16 Feb 2021 12:35:31 +0300 Subject: [PATCH 195/368] [Test] Support WITH_STDLIB directive in js box tests --- js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt index 66329a57297..51ccaf457f2 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt @@ -133,7 +133,7 @@ abstract class BasicBoxTest( fileContent = fileContent.replace("COROUTINES_PACKAGE", coroutinesPackage) } - val needsFullIrRuntime = KJS_WITH_FULL_RUNTIME.matcher(fileContent).find() || WITH_RUNTIME.matcher(fileContent).find() + val needsFullIrRuntime = KJS_WITH_FULL_RUNTIME.matcher(fileContent).find() || WITH_RUNTIME.matcher(fileContent).find() || WITH_STDLIB.matcher(fileContent).find() val actualMainCallParameters = if (CALL_MAIN_PATTERN.matcher(fileContent).find()) @@ -1090,6 +1090,7 @@ abstract class BasicBoxTest( private val CALL_MAIN_PATTERN = Pattern.compile("^// *CALL_MAIN *$", Pattern.MULTILINE) private val KJS_WITH_FULL_RUNTIME = Pattern.compile("^// *KJS_WITH_FULL_RUNTIME *\$", Pattern.MULTILINE) private val WITH_RUNTIME = Pattern.compile("^// *WITH_RUNTIME *\$", Pattern.MULTILINE) + private val WITH_STDLIB = Pattern.compile("^// *WITH_STDLIB *\$", Pattern.MULTILINE) private val EXPECT_ACTUAL_LINKER = Pattern.compile("^// EXPECT_ACTUAL_LINKER *$", Pattern.MULTILINE) private val SKIP_DCE_DRIVEN = Pattern.compile("^// *SKIP_DCE_DRIVEN *$", Pattern.MULTILINE) private val SPLIT_PER_MODULE = Pattern.compile("^// *SPLIT_PER_MODULE *$", Pattern.MULTILINE) From 56a104dda91ff9ae8bd3736b147f8bc540649c0d Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 16 Feb 2021 17:47:11 +0300 Subject: [PATCH 196/368] JVM_IR KT-44974 fix SAM-converted capturing extension lambda --- .../FirBlackBoxCodegenTestGenerated.java | 6 ++ .../jvm/lower/FunctionReferenceLowering.kt | 22 ++++-- .../jvm/lower/LambdaMetafactoryArguments.kt | 72 ++++++++++++++++--- .../backend/jvm/lower/TypeOperatorLowering.kt | 5 +- .../annotatedLambda/samFunExpression.kt | 2 +- .../annotatedLambda/samFunReference.kt | 2 +- .../sam/samExtFunWithCapturingLambda.kt | 15 ++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++ .../LightAnalysisModeTestGenerated.java | 5 ++ 10 files changed, 121 insertions(+), 20 deletions(-) create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/samExtFunWithCapturingLambda.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 8982f076273..6e398a6e9af 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -19987,6 +19987,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionOnFunctionReference.kt"); } + @Test + @TestMetadata("samExtFunWithCapturingLambda.kt") + public void testSamExtFunWithCapturingLambda() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/samExtFunWithCapturingLambda.kt"); + } + @Test @TestMetadata("simpleFunInterfaceConstructor.kt") public void testSimpleFunInterfaceConstructor() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt index 3d8f437d579..98a807e89a6 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt @@ -134,6 +134,8 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) return super.visitTypeOperator(expression) } + val samSuperType = expression.typeOperand + val invokable = expression.argument val reference = if (invokable is IrFunctionReference) { invokable @@ -145,8 +147,6 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) } reference.transformChildrenVoid() - val samSuperType = expression.typeOperand - if (shouldGenerateIndySamConversions) { val lambdaMetafactoryArguments = LambdaMetafactoryArgumentsBuilder(context, crossinlineLambdas) @@ -169,15 +169,23 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) wrapWithIndySamConversion(samType, lambdaMetafactoryArguments) } is IrBlock -> { - val indySamConversion = wrapWithIndySamConversion(samType, lambdaMetafactoryArguments) - argument.statements[argument.statements.size - 1] = indySamConversion - argument.type = indySamConversion.type - return argument + wrapFunctionReferenceInsideBlockWithIndySamConversion(samType, lambdaMetafactoryArguments, argument) } else -> throw AssertionError("Block or function reference expected: ${expression.render()}") } } + private fun wrapFunctionReferenceInsideBlockWithIndySamConversion( + samType: IrType, + lambdaMetafactoryArguments: LambdaMetafactoryArguments, + block: IrBlock + ): IrExpression { + val indySamConversion = wrapWithIndySamConversion(samType, lambdaMetafactoryArguments) + block.statements[block.statements.size - 1] = indySamConversion + block.type = indySamConversion.type + return block + } + private val jvmIndyLambdaMetafactoryIntrinsic = context.ir.symbols.indyLambdaMetafactoryIntrinsic private val specialNullabilityAnnotationsFqNames = @@ -690,3 +698,5 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) declaration.parent.let { it is IrClass && it.isFileClass } } } + + diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/LambdaMetafactoryArguments.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/LambdaMetafactoryArguments.kt index ba6396c3f79..8411de1f7ae 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/LambdaMetafactoryArguments.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/LambdaMetafactoryArguments.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.backend.jvm.lower import org.jetbrains.kotlin.backend.common.ir.allOverridden +import org.jetbrains.kotlin.backend.common.lower.VariableRemapper import org.jetbrains.kotlin.backend.common.lower.parents import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound @@ -14,13 +15,19 @@ import org.jetbrains.kotlin.backend.jvm.ir.isCompiledToJvmDefault import org.jetbrains.kotlin.builtins.functions.BuiltInFunctionArity import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.ir.builders.declarations.buildClass +import org.jetbrains.kotlin.ir.builders.declarations.buildValueParameter import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.IrFunctionReference import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionReferenceImpl import org.jetbrains.kotlin.ir.overrides.buildFakeOverrideMember import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl import org.jetbrains.kotlin.ir.types.* -import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.ir.util.dump +import org.jetbrains.kotlin.ir.util.functions +import org.jetbrains.kotlin.ir.util.getInlineClassUnderlyingType +import org.jetbrains.kotlin.ir.util.render +import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid import org.jetbrains.kotlin.name.Name class LambdaMetafactoryArguments( @@ -192,10 +199,12 @@ class LambdaMetafactoryArgumentsBuilder( adaptLambdaSignature(implLambda, fakeInstanceMethod, signatureAdaptationConstraints) + val newReference = remapExtensionLambda(implLambda, reference) + if (samMethod.isFakeOverride && nonFakeOverriddenFuns.size == 1) { - return LambdaMetafactoryArguments(nonFakeOverriddenFuns.single(), fakeInstanceMethod, reference, listOf()) + return LambdaMetafactoryArguments(nonFakeOverriddenFuns.single(), fakeInstanceMethod, newReference, listOf()) } - return LambdaMetafactoryArguments(samMethod, fakeInstanceMethod, reference, nonFakeOverriddenFuns) + return LambdaMetafactoryArguments(samMethod, fakeInstanceMethod, newReference, nonFakeOverriddenFuns) } private fun adaptLambdaSignature( @@ -223,8 +232,51 @@ class LambdaMetafactoryArgumentsBuilder( if (constraints.returnType == TypeAdaptationConstraint.FORCE_BOXING) { lambda.returnType = lambda.returnType.makeNullable() } + } + private fun remapExtensionLambda(lambda: IrSimpleFunction, reference: IrFunctionReference): IrFunctionReference { + val oldExtensionReceiver = lambda.extensionReceiverParameter + ?: return reference + + val newValueParameters = ArrayList() + val oldToNew = HashMap() + var newParameterIndex = 0 + + newValueParameters.add( + oldExtensionReceiver.copy(lambda, newParameterIndex++, Name.identifier("\$receiver")).also { + oldToNew[oldExtensionReceiver] = it + } + ) + + lambda.valueParameters.mapTo(newValueParameters) { oldParameter -> + oldParameter.copy(lambda, newParameterIndex++).also { + oldToNew[oldParameter] = it + } + } + + lambda.body?.transformChildrenVoid(VariableRemapper(oldToNew)) + + lambda.extensionReceiverParameter = null + lambda.valueParameters = newValueParameters + + return IrFunctionReferenceImpl( + reference.startOffset, reference.endOffset, reference.type, + lambda.symbol, + typeArgumentsCount = 0, + valueArgumentsCount = newValueParameters.size, + reflectionTarget = null, + origin = reference.origin + ) + } + + private fun IrValueParameter.copy(parent: IrSimpleFunction, newIndex: Int, newName: Name = this.name): IrValueParameter = + buildValueParameter(parent) { + updateFrom(this@copy) + index = newIndex + name = newName + } + private fun adaptFakeInstanceMethodSignature(fakeInstanceMethod: IrSimpleFunction, constraints: SignatureAdaptationConstraints) { for ((valueParameter, constraint) in constraints.valueParameters) { if (valueParameter.parent != fakeInstanceMethod) @@ -406,13 +458,13 @@ class LambdaMetafactoryArgumentsBuilder( private fun IrType.isJvmPrimitiveType() = isBoolean() || isChar() || isByte() || isShort() || isInt() || isLong() || isFloat() || isDouble() +} - private fun collectValueParameters(irFun: IrFunction): List { - if (irFun.extensionReceiverParameter == null) - return irFun.valueParameters - return ArrayList().apply { - add(irFun.extensionReceiverParameter!!) - addAll(irFun.valueParameters) - } +fun collectValueParameters(irFun: IrFunction): List { + if (irFun.extensionReceiverParameter == null) + return irFun.valueParameters + return ArrayList().apply { + add(irFun.extensionReceiverParameter!!) + addAll(irFun.valueParameters) } } \ No newline at end of file diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt index bc52a44af97..0622b0ec63c 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt @@ -299,13 +299,14 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil dynamicCallArguments.add(extensionReceiver) } - val samMethodValueParametersCount = samMethod.valueParameters.size + val samMethodValueParametersCount = samMethod.valueParameters.size + + if (samMethod.extensionReceiverParameter != null && irFunRef.extensionReceiver == null) 1 else 0 val targetFunValueParametersCount = targetFun.valueParameters.size for (i in 0 until targetFunValueParametersCount - samMethodValueParametersCount) { val targetFunValueParameter = targetFun.valueParameters[i] addValueParameter("p${syntheticParameterIndex++}", targetFunValueParameter.type) val capturedValueArgument = irFunRef.getValueArgument(i) - ?: fail("Captured value argument #$i (${targetFunValueParameter.name} not provided") + ?: fail("Captured value argument #$i (${targetFunValueParameter.name}) not provided") dynamicCallArguments.add(capturedValueArgument) } } diff --git a/compiler/testData/codegen/box/annotations/annotatedLambda/samFunExpression.kt b/compiler/testData/codegen/box/annotations/annotatedLambda/samFunExpression.kt index c34c8dd2ca3..2f7d53cb650 100644 --- a/compiler/testData/codegen/box/annotations/annotatedLambda/samFunExpression.kt +++ b/compiler/testData/codegen/box/annotations/annotatedLambda/samFunExpression.kt @@ -17,7 +17,7 @@ class Test { } } -// FILE: test.kt +// FILE: samFunExpression.kt import java.lang.reflect.Method import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt b/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt index ed9a9b9b7c4..74ea0405d94 100644 --- a/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt +++ b/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt @@ -17,7 +17,7 @@ class Test { } } -// FILE: test.kt +// FILE: samFunReference.kt import java.lang.reflect.Method import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/invokedynamic/sam/samExtFunWithCapturingLambda.kt b/compiler/testData/codegen/box/invokedynamic/sam/samExtFunWithCapturingLambda.kt new file mode 100644 index 00000000000..1f3a26e780b --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/samExtFunWithCapturingLambda.kt @@ -0,0 +1,15 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface IExtFun { + fun String.foo(s: String) : String +} + +fun box(): String { + val oChar = 'O' + val iExtFun = IExtFun { this + oChar.toString() + it } + return with(iExtFun) { + "".foo("K") + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 32dfc2c6864..f3680f868a8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -19987,6 +19987,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionOnFunctionReference.kt"); } + @Test + @TestMetadata("samExtFunWithCapturingLambda.kt") + public void testSamExtFunWithCapturingLambda() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/samExtFunWithCapturingLambda.kt"); + } + @Test @TestMetadata("simpleFunInterfaceConstructor.kt") public void testSimpleFunInterfaceConstructor() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 11c8ae6dd32..c64b6b797c2 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -19987,6 +19987,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionOnFunctionReference.kt"); } + @Test + @TestMetadata("samExtFunWithCapturingLambda.kt") + public void testSamExtFunWithCapturingLambda() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/samExtFunWithCapturingLambda.kt"); + } + @Test @TestMetadata("simpleFunInterfaceConstructor.kt") public void testSimpleFunInterfaceConstructor() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 3163f01223c..1d9ecf0f2f0 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -16758,6 +16758,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionOnFunctionReference.kt"); } + @TestMetadata("samExtFunWithCapturingLambda.kt") + public void testSamExtFunWithCapturingLambda() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/samExtFunWithCapturingLambda.kt"); + } + @TestMetadata("simpleFunInterfaceConstructor.kt") public void testSimpleFunInterfaceConstructor() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/simpleFunInterfaceConstructor.kt"); From bad197e07599cbca1841bea4b9abc1d27b6bb7c2 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Mon, 15 Feb 2021 12:43:56 +0100 Subject: [PATCH 197/368] Raise RESERVED_VAR_PROPERTY_OF_VALUE_CLASS to error --- .../frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java | 2 +- .../memberExtVarDelegationWithInlineClassParameterTypes.kt | 3 +++ .../call/inlineClasses/nonOverridingVarOfInlineClass.kt | 4 ++++ .../call/inlineClasses/overridingVarOfInlineClass.kt | 4 ++++ .../codegen/box/reflection/call/inlineClasses/properties.kt | 2 ++ .../codegen/box/reflection/callBy/inlineClassMembers.kt | 2 ++ 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index cb864463d37..ee4c986f88d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -356,7 +356,7 @@ public interface Errors { DiagnosticFactory0 INLINE_CLASS_CONSTRUCTOR_WRONG_PARAMETERS_SIZE = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 PROPERTY_WITH_BACKING_FIELD_INSIDE_INLINE_CLASS = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE); - DiagnosticFactory0 RESERVED_VAR_PROPERTY_OF_VALUE_CLASS = DiagnosticFactory0.create(WARNING); + DiagnosticFactory0 RESERVED_VAR_PROPERTY_OF_VALUE_CLASS = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 DELEGATED_PROPERTY_INSIDE_INLINE_CLASS = DiagnosticFactory0.create(ERROR); DiagnosticFactory1 INLINE_CLASS_HAS_INAPPLICABLE_PARAMETER_TYPE = DiagnosticFactory1.create(ERROR); DiagnosticFactory0 INLINE_CLASS_CANNOT_IMPLEMENT_INTERFACE_BY_DELEGATION = DiagnosticFactory0.create(ERROR); diff --git a/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberExtVarDelegationWithInlineClassParameterTypes.kt b/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberExtVarDelegationWithInlineClassParameterTypes.kt index 7808a26a6ab..7691a5028f9 100644 --- a/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberExtVarDelegationWithInlineClassParameterTypes.kt +++ b/compiler/testData/codegen/box/inlineClasses/interfaceDelegation/memberExtVarDelegationWithInlineClassParameterTypes.kt @@ -6,6 +6,7 @@ import kotlin.test.assertEquals inline class S(val xs: Array) interface IFoo { + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var S.extVar: String } @@ -14,12 +15,14 @@ interface GFoo { } object FooImpl : IFoo { + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") override var S.extVar: String get() = xs[0] set(value) { xs[0] = value } } object GFooImpl : GFoo { + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") override var S.extVar: String get() = xs[0] set(value) { xs[0] = value } diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt index e365dff5fc0..fce0d470e46 100644 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/nonOverridingVarOfInlineClass.kt @@ -6,6 +6,7 @@ import kotlin.test.assertEquals var global = S("") inline class Z(val x: Int) { + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var test: S get() = S("${global.x}$x") set(value) { @@ -14,6 +15,7 @@ inline class Z(val x: Int) { } inline class L(val x: Long) { + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var test: S get() = S("${global.x}$x") set(value) { @@ -22,6 +24,7 @@ inline class L(val x: Long) { } inline class S(val x: String) { + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var test: S get() = S("${global.x}$x") set(value) { @@ -30,6 +33,7 @@ inline class S(val x: String) { } inline class A(val x: Any) { + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var test: S get() = S("${global.x}$x") set(value) { diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt index fff7c09b21d..acadf3164a9 100644 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/overridingVarOfInlineClass.kt @@ -10,6 +10,7 @@ interface ITest { } inline class Z(val x: Int) : ITest { + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") override var test: S get() = S("${global.x}$x") set(value) { @@ -18,6 +19,7 @@ inline class Z(val x: Int) : ITest { } inline class L(val x: Long) : ITest { + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") override var test: S get() = S("${global.x}$x") set(value) { @@ -26,6 +28,7 @@ inline class L(val x: Long) : ITest { } inline class S(val x: String) : ITest { + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") override var test: S get() = S("${global.x}$x") set(value) { @@ -34,6 +37,7 @@ inline class S(val x: String) : ITest { } inline class A(val x: Any) : ITest { + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") override var test: S get() = S("${global.x}$x") set(value) { diff --git a/compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt b/compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt index 919589dc174..82bcd915d99 100644 --- a/compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt +++ b/compiler/testData/codegen/box/reflection/call/inlineClasses/properties.kt @@ -13,6 +13,7 @@ class C { var member: S = S("") private var suffix = S("") + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var S.memExt: S get() = this + suffix set(value) { suffix = this + value } @@ -21,6 +22,7 @@ class C { var topLevel: S = S("") private var suffix = S("") +@Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var S.ext: S get() = this + suffix set(value) { suffix = this + value } diff --git a/compiler/testData/codegen/box/reflection/callBy/inlineClassMembers.kt b/compiler/testData/codegen/box/reflection/callBy/inlineClassMembers.kt index c6c099e1bf6..79b875e724e 100644 --- a/compiler/testData/codegen/box/reflection/callBy/inlineClassMembers.kt +++ b/compiler/testData/codegen/box/reflection/callBy/inlineClassMembers.kt @@ -15,6 +15,7 @@ inline class Z(val x: Int) : IFoo { override fun fooFun(z: Z): Z = Z(z.x + x) + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") override var fooVar: Z get() = Z(global.x + x) set(value) { @@ -23,6 +24,7 @@ inline class Z(val x: Int) : IFoo { fun barFun(z: Z): Z = Z(z.x * 100 + x) + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var barVar: Z get() = Z(global.x * 100 + x) set(value) { From ec569a4c893f1397e533c1a767282ab59c9a4a7e Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Tue, 16 Feb 2021 20:38:46 +0100 Subject: [PATCH 198/368] Minor. Suppress errors in tests --- .../inlineClasses/inlineClassMembersVisibility.kt | 6 ++++++ .../inlineClasses/inlineClassMembersVisibility.txt | 6 ++++++ .../inlineClasses/inlineClassWithManyKindsOfMembers.kt | 4 ++++ .../nullabilityAnnotationsOnInlineClassMembers.kt | 2 ++ .../nullabilityAnnotationsOnInlineClassMembers.txt | 2 ++ 5 files changed, 20 insertions(+) diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassMembersVisibility.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassMembersVisibility.kt index 8e29c2d58cc..0d067866f50 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassMembersVisibility.kt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassMembersVisibility.kt @@ -21,22 +21,28 @@ inline class Z(val x: Int) { internal val String.internalExtensionVal: Int get() = x private val String.privateExtensionVal: Int get() = x + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var publicVar: Int get() = x set(v) {} + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") internal var internalVar: Int get() = x set(v) {} + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") private var privateVar: Int get() = x set(v) {} + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var String.publicExtensionVar: Int get() = x set(v) {} + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") internal var String.internalExtensionVar: Int get() = x set(v) {} + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") private var String.privateExtensionVar: Int get() = x set(v) {} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassMembersVisibility.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassMembersVisibility.txt index bce676386de..63aaa0efb40 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassMembersVisibility.txt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassMembersVisibility.txt @@ -13,16 +13,22 @@ public final class Z { public static method equals-impl(p0: int, p1: java.lang.Object): boolean public final static method equals-impl0(p0: int, p1: int): boolean public final static method getInternalExtensionVal-impl$test_module(p0: int, @org.jetbrains.annotations.NotNull p1: java.lang.String): int + public synthetic deprecated static method getInternalExtensionVar$test_module$annotations(p0: java.lang.String): void public final static method getInternalExtensionVar-impl$test_module(p0: int, @org.jetbrains.annotations.NotNull p1: java.lang.String): int public final static method getInternalVal-impl$test_module(p0: int): int + public synthetic deprecated static method getInternalVar$test_module$annotations(): void public final static method getInternalVar-impl$test_module(p0: int): int private final static method getPrivateExtensionVal-impl(p0: int, p1: java.lang.String): int + private synthetic deprecated static method getPrivateExtensionVar$annotations(p0: java.lang.String): void private final static method getPrivateExtensionVar-impl(p0: int, p1: java.lang.String): int private final static method getPrivateVal-impl(p0: int): int + private synthetic deprecated static method getPrivateVar$annotations(): void private final static method getPrivateVar-impl(p0: int): int public final static method getPublicExtensionVal-impl(p0: int, @org.jetbrains.annotations.NotNull p1: java.lang.String): int + public synthetic deprecated static method getPublicExtensionVar$annotations(p0: java.lang.String): void public final static method getPublicExtensionVar-impl(p0: int, @org.jetbrains.annotations.NotNull p1: java.lang.String): int public final static method getPublicVal-impl(p0: int): int + public synthetic deprecated static method getPublicVar$annotations(): void public final static method getPublicVar-impl(p0: int): int public final method getX(): int public method hashCode(): int diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassWithManyKindsOfMembers.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassWithManyKindsOfMembers.kt index 4122d2f2a58..2ba27ac39ed 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassWithManyKindsOfMembers.kt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineClassWithManyKindsOfMembers.kt @@ -41,6 +41,7 @@ inline class Z(@get:AGet val x: Int) : IFoo { override val overridingVal: Int get() = x + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") @A @get:AGet @set:ASet @setparam:ASetParam override var overridingVar: Int get() = x @@ -50,6 +51,7 @@ inline class Z(@get:AGet val x: Int) : IFoo { override val @receiver:AReceiver String.overridingExtVal: Int get() = x + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") @A @get:AGet @set:ASet @setparam:ASetParam override var @receiver:AReceiver String.overridingExtVar: Int get() = x @@ -64,6 +66,7 @@ inline class Z(@get:AGet val x: Int) : IFoo { @A @get:AGet val nonOverridingVal: Int get() = x + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") @A @get:AGet @set:ASet @setparam:ASetParam var nonOverridingVar: Int get() = x @@ -73,6 +76,7 @@ inline class Z(@get:AGet val x: Int) : IFoo { val @receiver:AReceiver String.nonOverridingExtVal: Int get() = x + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") @A @get:AGet @set:ASet @setparam:ASetParam var @receiver:AReceiver String.nonOverridingExtVar: Int get() = x diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/nullabilityAnnotationsOnInlineClassMembers.kt b/compiler/testData/codegen/bytecodeListing/inlineClasses/nullabilityAnnotationsOnInlineClassMembers.kt index bfb5140ff61..e3e3a602299 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/nullabilityAnnotationsOnInlineClassMembers.kt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/nullabilityAnnotationsOnInlineClassMembers.kt @@ -9,10 +9,12 @@ inline class Test(val s: String) { val String.memberExtVal get() = s + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var memberVar get() = s set(value) {} + @Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") var String.memberExtVar get() = s set(value) {} diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/nullabilityAnnotationsOnInlineClassMembers.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/nullabilityAnnotationsOnInlineClassMembers.txt index e7824b55a7f..04b81de6e65 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/nullabilityAnnotationsOnInlineClassMembers.txt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/nullabilityAnnotationsOnInlineClassMembers.txt @@ -10,8 +10,10 @@ public final class Test { public static method equals-impl(p0: java.lang.String, p1: java.lang.Object): boolean public final static method equals-impl0(p0: java.lang.String, p1: java.lang.String): boolean public final static @org.jetbrains.annotations.NotNull method getMemberExtVal-impl(p0: java.lang.String, @org.jetbrains.annotations.NotNull p1: java.lang.String): java.lang.String + public synthetic deprecated static method getMemberExtVar$annotations(p0: java.lang.String): void public final static @org.jetbrains.annotations.NotNull method getMemberExtVar-impl(p0: java.lang.String, @org.jetbrains.annotations.NotNull p1: java.lang.String): java.lang.String public final static @org.jetbrains.annotations.NotNull method getMemberVal-impl(p0: java.lang.String): java.lang.String + public synthetic deprecated static method getMemberVar$annotations(): void public final static @org.jetbrains.annotations.NotNull method getMemberVar-impl(p0: java.lang.String): java.lang.String public final @org.jetbrains.annotations.NotNull method getS(): java.lang.String public method hashCode(): int From ec89cb23135ae80c9657e4e792e558b1a4a44fb5 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 17 Feb 2021 00:23:43 +0300 Subject: [PATCH 199/368] Ignore hanging KotlinAndroid36GradleIT.testAndroidMppSourceSets() Ignore till the proper investigation. Probably caused in https://github.com/JetBrains/kotlin/compare/b262d09a81bf20ffd71db18a0c24ac4f61fa151c...5c7aadece929f79a39bf0ad20549e30d5e391a7c. --- .../jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt index a1b4662008a..674d1f61ef3 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt @@ -6,6 +6,7 @@ import org.gradle.util.GradleVersion import org.jetbrains.kotlin.gradle.util.* import org.jetbrains.kotlin.test.util.KtTestUtil import org.junit.Assume +import org.junit.Ignore import org.junit.Test import java.io.File import kotlin.test.assertEquals @@ -23,6 +24,7 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() { override val defaultGradleVersion: GradleVersionRequired get() = GradleVersionRequired.AtLeast("6.0") + @Ignore @Test fun testAndroidMppSourceSets(): Unit = with( Project("new-mpp-android-source-sets") From 1310a65f0cc6e39d32bb52fe9e636c8ae42bfa63 Mon Sep 17 00:00:00 2001 From: pyos Date: Wed, 3 Feb 2021 14:52:14 +0100 Subject: [PATCH 200/368] JVM: rename this$0 when regenerating nested objects too In the old backend, this was unnecessary because nested objects would reference their lambdas' captures through the original this$0. On JVM_IR, using loose capture fields means a name/descriptor clash can occur on any level of nesting, not just the top. --- .../inline/AnonymousObjectTransformer.kt | 94 ++++++++----------- ...FirBlackBoxInlineCodegenTestGenerated.java | 12 +++ .../twoCapturedReceivers/kt8668_nested.kt | 14 +++ .../twoCapturedReceivers/kt8668_nested_2.kt | 14 +++ .../BlackBoxInlineCodegenTestGenerated.java | 12 +++ ...otlinAgainstInlineKotlinTestGenerated.java | 12 +++ .../IrBlackBoxInlineCodegenTestGenerated.java | 12 +++ ...otlinAgainstInlineKotlinTestGenerated.java | 12 +++ ...JvmIrAgainstOldBoxInlineTestGenerated.java | 12 +++ ...JvmOldAgainstIrBoxInlineTestGenerated.java | 12 +++ .../IrJsCodegenInlineES6TestGenerated.java | 10 ++ .../IrJsCodegenInlineTestGenerated.java | 10 ++ .../JsCodegenInlineTestGenerated.java | 10 ++ 13 files changed, 180 insertions(+), 56 deletions(-) create mode 100644 compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt create mode 100644 compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.kt index c4a846e2db7..e1f3d2d917d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.kt @@ -462,6 +462,29 @@ class AnonymousObjectTransformer( val indexToFunctionalArgument = transformationInfo.functionalArguments val capturedParams = HashSet() + // Possible cases where we need to add each lambda's captures separately: + // + // 1. Top-level object in an inline lambda that is *not* being inlined into another object. In this case, we + // have no choice but to add a separate field for each captured variable. `capturedLambdas` is either empty + // (already have the fields) or contains the parent lambda object (captures used to be read from it, but + // the object will be removed and its contents inlined). + // + // 2. Top-level object in a named inline function. Again, there's no option but to add separate fields. + // `capturedLambdas` contains all lambdas used by this object and nested objects. + // + // 3. Nested object, either in an inline lambda or an inline function. This case has two subcases: + // * The object's captures are passed as separate arguments (e.g. KT-28064 style object that used to be in a lambda); + // we *could* group them into `this$0` now, but choose not to. Lambdas are replaced by their captures to match. + // * The object's captures are already grouped into `this$0`; this includes captured lambda parameters (for objects in + // inline functions) and a reference to the outer object or lambda (for objects in lambdas), so `capturedLambdas` is + // empty anyway. + // + // The only remaining case is a top-level object inside a (crossinline) lambda that is inlined into another object. + // Then, the reference to the soon-to-be-removed lambda class containing the captures (and it exists, or else the object + // would not have needed regeneration in the first place) is simply replaced with a reference to the outer object, and + // that object will contain loose fields for everything we need to capture. + val topLevelInCrossinlineLambda = parentFieldRemapper is InlinedLambdaRemapper && !parentFieldRemapper.parent!!.isRoot + //load captured parameters and patch instruction list // NB: there is also could be object fields val toDelete = arrayListOf() @@ -470,10 +493,12 @@ class AnonymousObjectTransformer( val parameterAload = fieldNode.previous as VarInsnNode val varIndex = parameterAload.`var` val functionalArgument = indexToFunctionalArgument[varIndex] - val newFieldName = if (isThis0(fieldName) && shouldRenameThis0(parentFieldRemapper, indexToFunctionalArgument.values)) - getNewFieldName(fieldName, true) - else - fieldName + // If an outer `this` is already captured by this object, rename it if any inline lambda will capture + // one of the same type, causing the code below to create a clash. Note that the values can be different. + // TODO: this is only really necessary if there will be a name *and* type clash. + val shouldRename = !topLevelInCrossinlineLambda && isThis0(fieldName) && + indexToFunctionalArgument.values.any { it is LambdaInfo && it.capturedVars.any { it.fieldName == fieldName } } + val newFieldName = if (shouldRename) addUniqueField(fieldName + INLINE_FUN_THIS_0_SUFFIX) else fieldName val info = capturedParamBuilder.addCapturedParam( Type.getObjectType(transformationInfo.oldClassName), fieldName, newFieldName, Type.getType(fieldNode.desc), functionalArgument is LambdaInfo, null @@ -508,35 +533,17 @@ class AnonymousObjectTransformer( //For all inlined lambdas add their captured parameters //TODO: some of such parameters could be skipped - we should perform additional analysis val allRecapturedParameters = ArrayList() - if (parentFieldRemapper !is InlinedLambdaRemapper || parentFieldRemapper.parent!!.isRoot) { - // Possible cases: - // - // 1. Top-level object in an inline lambda that is *not* being inlined into another object. In this case, we - // have no choice but to add a separate field for each captured variable. `capturedLambdas` is either empty - // (already have the fields) or contains the parent lambda object (captures used to be read from it, but - // the object will be removed and its contents inlined). - // - // 2. Top-level object in a named inline function. Again, there's no option but to add separate fields. - // `capturedLambdas` contains all lambdas used by this object and nested objects. - // - // 3. Nested object, either in an inline lambda or an inline function. This case has two subcases: - // * The object's captures are passed as separate arguments (e.g. KT-28064 style object that used to be in a lambda); - // we could group them into `this$0` now, but choose not to. Lambdas are replaced by their captures. - // * The object's captures are already grouped into `this$0`; this includes captured lambda parameters (for objects in - // inline functions) and a reference to the outer object or lambda (for objects in lambdas), so `capturedLambdas` is - // empty and the choice doesn't matter. - // - val alreadyAdded = HashMap() + if (!topLevelInCrossinlineLambda) { + val capturedOuterThisTypes = mutableSetOf() for (info in capturedLambdas) { for (desc in info.capturedVars) { - val key = desc.fieldName + "$$$" + desc.type.className - val alreadyAddedParam = alreadyAdded[key] - - val recapturedParamInfo = capturedParamBuilder.addCapturedParam( - desc, - alreadyAddedParam?.newFieldName ?: getNewFieldName(desc.fieldName, false), - alreadyAddedParam != null - ) + // Merge all outer `this` of the same type captured by inlined lambdas, since they have to be the same + // object. Outer `this` captured by the original object itself should have been renamed above, + // and can have a different value even if the same type is captured by a lambda. + val recapturedParamInfo = if (isThis0(desc.fieldName)) + capturedParamBuilder.addCapturedParam(desc, desc.fieldName, !capturedOuterThisTypes.add(desc.type.className)) + else + capturedParamBuilder.addCapturedParam(desc, addUniqueField(desc.fieldName + INLINE_TRANSFORMATION_SUFFIX), false) if (info is ExpressionLambda && info.isCapturedSuspend(desc)) { recapturedParamInfo.functionalArgument = NonInlineableArgumentForInlineableParameterCalledInSuspend } @@ -551,10 +558,6 @@ class AnonymousObjectTransformer( allRecapturedParameters.add(desc) constructorParamBuilder.addCapturedParam(recapturedParamInfo, recapturedParamInfo.newFieldName).remapValue = composed - - if (isThis0(desc.fieldName)) { - alreadyAdded.put(key, recapturedParamInfo) - } } } } else if (capturedLambdas.isNotEmpty()) { @@ -579,24 +582,6 @@ class AnonymousObjectTransformer( return constructorAdditionalFakeParams } - private fun shouldRenameThis0(parentFieldRemapper: FieldRemapper, values: Collection): Boolean { - return if (isFirstDeclSiteLambdaFieldRemapper(parentFieldRemapper)) { - values.any { it is LambdaInfo && it.capturedVars.any { isThis0(it.fieldName) } } - } else false - } - - private fun getNewFieldName(oldName: String, originalField: Boolean): String { - if (AsmUtil.CAPTURED_THIS_FIELD == oldName) { - return if (!originalField) { - oldName - } else { - //rename original 'this$0' in declaration site lambda (inside inline function) to use this$0 only for outer lambda/object access on call site - addUniqueField(oldName + INLINE_FUN_THIS_0_SUFFIX) - } - } - return addUniqueField(oldName + INLINE_TRANSFORMATION_SUFFIX) - } - private fun addUniqueField(name: String): String { val existNames = fieldNames.getOrPut(name) { LinkedList() } val suffix = if (existNames.isEmpty()) "" else "$" + existNames.size @@ -604,7 +589,4 @@ class AnonymousObjectTransformer( existNames.add(newName) return newName } - - private fun isFirstDeclSiteLambdaFieldRemapper(parentRemapper: FieldRemapper): Boolean = - parentRemapper !is RegeneratedLambdaFieldRemapper && parentRemapper !is InlinedLambdaRemapper } diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java index 64e8d4ad4a3..3e8f3abdd24 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java @@ -647,6 +647,18 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_3.kt"); } + @Test + @TestMetadata("kt8668_nested.kt") + public void testKt8668_nested() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt"); + } + + @Test + @TestMetadata("kt8668_nested_2.kt") + public void testKt8668_nested_2() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt"); + } + @Test @TestMetadata("twoDifferentDispatchReceivers.kt") public void testTwoDifferentDispatchReceivers() throws Exception { diff --git a/compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt b/compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt new file mode 100644 index 00000000000..7c6b9c68918 --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt @@ -0,0 +1,14 @@ +// FILE: 1.kt +package test + +class C(val x: String) { + fun f(y: String) = C(y).g { x } + + inline fun g(crossinline h: () -> String) = + { { h() + x }() }() +} + +// FILE: 2.kt +import test.* + +fun box() = C("O").f("K") diff --git a/compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt b/compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt new file mode 100644 index 00000000000..2cf776c3eed --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt @@ -0,0 +1,14 @@ +// FILE: 1.kt +package test + +class C(val x: String) { + inline fun f(crossinline h: () -> String) = C("").g { x + h() } + + inline fun g(crossinline h: () -> String) = + { { h() + x }() }() +} + +// FILE: 2.kt +import test.* + +fun box() = C("O").f { "K" } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java index c5518687452..4bbf6aaa6cf 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -647,6 +647,18 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_3.kt"); } + @Test + @TestMetadata("kt8668_nested.kt") + public void testKt8668_nested() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt"); + } + + @Test + @TestMetadata("kt8668_nested_2.kt") + public void testKt8668_nested_2() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt"); + } + @Test @TestMetadata("twoDifferentDispatchReceivers.kt") public void testTwoDifferentDispatchReceivers() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 5e2563c6f44..cd25eee936b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -647,6 +647,18 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_3.kt"); } + @Test + @TestMetadata("kt8668_nested.kt") + public void testKt8668_nested() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt"); + } + + @Test + @TestMetadata("kt8668_nested_2.kt") + public void testKt8668_nested_2() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt"); + } + @Test @TestMetadata("twoDifferentDispatchReceivers.kt") public void testTwoDifferentDispatchReceivers() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java index 923d5b8216d..8489888393a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java @@ -647,6 +647,18 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_3.kt"); } + @Test + @TestMetadata("kt8668_nested.kt") + public void testKt8668_nested() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt"); + } + + @Test + @TestMetadata("kt8668_nested_2.kt") + public void testKt8668_nested_2() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt"); + } + @Test @TestMetadata("twoDifferentDispatchReceivers.kt") public void testTwoDifferentDispatchReceivers() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 77a112550c6..d1a19baf1e7 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -647,6 +647,18 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_3.kt"); } + @Test + @TestMetadata("kt8668_nested.kt") + public void testKt8668_nested() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt"); + } + + @Test + @TestMetadata("kt8668_nested_2.kt") + public void testKt8668_nested_2() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt"); + } + @Test @TestMetadata("twoDifferentDispatchReceivers.kt") public void testTwoDifferentDispatchReceivers() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java index fc5e88ed307..ce4ed6b602c 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -647,6 +647,18 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_3.kt"); } + @Test + @TestMetadata("kt8668_nested.kt") + public void testKt8668_nested() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt"); + } + + @Test + @TestMetadata("kt8668_nested_2.kt") + public void testKt8668_nested_2() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt"); + } + @Test @TestMetadata("twoDifferentDispatchReceivers.kt") public void testTwoDifferentDispatchReceivers() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java index 0595eeddb3f..3b646a4262f 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -647,6 +647,18 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_3.kt"); } + @Test + @TestMetadata("kt8668_nested.kt") + public void testKt8668_nested() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt"); + } + + @Test + @TestMetadata("kt8668_nested_2.kt") + public void testKt8668_nested_2() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt"); + } + @Test @TestMetadata("twoDifferentDispatchReceivers.kt") public void testTwoDifferentDispatchReceivers() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java index cfbea859cb2..47fd9bacfb7 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java @@ -506,6 +506,16 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_3.kt"); } + @TestMetadata("kt8668_nested.kt") + public void testKt8668_nested() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt"); + } + + @TestMetadata("kt8668_nested_2.kt") + public void testKt8668_nested_2() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt"); + } + @TestMetadata("twoDifferentDispatchReceivers.kt") public void testTwoDifferentDispatchReceivers() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/twoDifferentDispatchReceivers.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index edacdee1ae3..022c5e3c219 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -506,6 +506,16 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_3.kt"); } + @TestMetadata("kt8668_nested.kt") + public void testKt8668_nested() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt"); + } + + @TestMetadata("kt8668_nested_2.kt") + public void testKt8668_nested_2() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt"); + } + @TestMetadata("twoDifferentDispatchReceivers.kt") public void testTwoDifferentDispatchReceivers() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/twoDifferentDispatchReceivers.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index edf8a2f4844..c6ceb1eb10d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -506,6 +506,16 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_3.kt"); } + @TestMetadata("kt8668_nested.kt") + public void testKt8668_nested() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested.kt"); + } + + @TestMetadata("kt8668_nested_2.kt") + public void testKt8668_nested_2() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/kt8668_nested_2.kt"); + } + @TestMetadata("twoDifferentDispatchReceivers.kt") public void testTwoDifferentDispatchReceivers() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/twoCapturedReceivers/twoDifferentDispatchReceivers.kt"); From 8a0ce20d4395262377499d00d8fd1a25859bf6bb Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Wed, 21 Oct 2020 22:38:38 +0300 Subject: [PATCH 201/368] PIR: minor restructuring --- .../persistent/PersistentIrDeclarationBase.kt | 16 +- .../PersistentIrErrorDeclaration.kt | 4 +- .../persistent/PersistentIrFunction.kt | 171 +--------------- .../persistent/PersistentIrFunctionCommon.kt | 182 ++++++++++++++++++ .../persistent/PersistentIrProperty.kt | 105 +--------- .../persistent/PersistentIrPropertyCommon.kt | 103 ++++++++++ ...rCarrier.kt => ErrorDeclarationCarrier.kt} | 10 +- 7 files changed, 299 insertions(+), 292 deletions(-) create mode 100644 compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt create mode 100644 compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt rename compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/{ErrorCarrier.kt => ErrorDeclarationCarrier.kt} (68%) diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrDeclarationBase.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrDeclarationBase.kt index ee6c3eea510..c9b93bc9073 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrDeclarationBase.kt +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrDeclarationBase.kt @@ -1,19 +1,9 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2020 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.ir.declarations.persistent import org.jetbrains.kotlin.ir.IrElement diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt index e474cc26e43..949698978fd 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.declarations.IrErrorDeclaration import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier -import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ErrorCarrier +import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ErrorDeclarationCarrier import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor import org.jetbrains.kotlin.ir.expressions.IrConstructorCall @@ -32,7 +32,7 @@ internal class PersistentIrErrorDeclaration( override val startOffset: Int, override val endOffset: Int, private val _descriptor: DeclarationDescriptor? -) : PersistentIrDeclarationBase, IrErrorDeclaration(), ErrorCarrier { +) : PersistentIrDeclarationBase, IrErrorDeclaration(), ErrorDeclarationCarrier { override val descriptor: DeclarationDescriptor get() = _descriptor ?: this.toIrBasedDescriptor() diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunction.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunction.kt index e75fef79067..9cf6f61b6ab 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunction.kt +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunction.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2020 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. */ @@ -10,181 +10,12 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier -import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FunctionCarrier import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor -import org.jetbrains.kotlin.ir.expressions.IrBody -import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType -import org.jetbrains.kotlin.ir.types.impl.ReturnTypeIsNotInitializedException import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource -internal abstract class PersistentIrFunctionCommon( - override val startOffset: Int, - override val endOffset: Int, - origin: IrDeclarationOrigin, - override val name: Name, - visibility: DescriptorVisibility, - returnType: IrType, - override val isInline: Boolean, - isExternal: Boolean, - override val isTailrec: Boolean, - override val isSuspend: Boolean, - override val isOperator: Boolean, - override val isInfix: Boolean, - override val isExpect: Boolean, - override val containerSource: DeserializedContainerSource? = null -) : IrSimpleFunction(), - PersistentIrDeclarationBase, - FunctionCarrier { - - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage - override var values: Array? = null - override val createdOn: Int = stageController.currentStage - - override var parentField: IrDeclarationParent? = null - override var originField: IrDeclarationOrigin = origin - override var removedOn: Int = Int.MAX_VALUE - override var annotationsField: List = emptyList() - - override var returnTypeFieldField: IrType = returnType - - private var returnTypeField: IrType - get() = getCarrier().returnTypeFieldField - set(v) { - if (returnTypeField !== v) { - setCarrier().returnTypeFieldField = v - } - } - - final override var returnType: IrType - get() = returnTypeField.let { - if (it !== IrUninitializedType) it else throw ReturnTypeIsNotInitializedException(this) - } - set(c) { - returnTypeField = c - } - - override var typeParametersField: List = emptyList() - - override var typeParameters: List - get() = getCarrier().typeParametersField - set(v) { - if (typeParameters !== v) { - setCarrier().typeParametersField = v - } - } - - override var dispatchReceiverParameterField: IrValueParameter? = null - - override var dispatchReceiverParameter: IrValueParameter? - get() = getCarrier().dispatchReceiverParameterField - set(v) { - if (dispatchReceiverParameter !== v) { - setCarrier().dispatchReceiverParameterField = v - } - } - - override var extensionReceiverParameterField: IrValueParameter? = null - - override var extensionReceiverParameter: IrValueParameter? - get() = getCarrier().extensionReceiverParameterField - set(v) { - if (extensionReceiverParameter !== v) { - setCarrier().extensionReceiverParameterField = v - } - } - - override var valueParametersField: List = emptyList() - - override var valueParameters: List - get() = getCarrier().valueParametersField - set(v) { - if (valueParameters !== v) { - setCarrier().valueParametersField = v - } - } - - override var bodyField: IrBody? = null - - final override var body: IrBody? - get() = getCarrier().bodyField - set(v) { - if (body !== v) { - if (v is PersistentIrBodyBase<*>) { - v.container = this - } - setCarrier().bodyField = v - } - } - - override var metadataField: MetadataSource? = null - - override var metadata: MetadataSource? - get() = getCarrier().metadataField - set(v) { - if (metadata !== v) { - setCarrier().metadataField = v - } - } - - override var visibilityField: DescriptorVisibility = visibility - - override var visibility: DescriptorVisibility - get() = getCarrier().visibilityField - set(v) { - if (visibility !== v) { - setCarrier().visibilityField = v - } - } - - override var overriddenSymbolsField: List = emptyList() - - override var overriddenSymbols: List - get() = getCarrier().overriddenSymbolsField - set(v) { - if (overriddenSymbols !== v) { - setCarrier().overriddenSymbolsField = v - } - } - - @Suppress("LeakingThis") - override var attributeOwnerIdField: IrAttributeContainer = this - - override var attributeOwnerId: IrAttributeContainer - get() = getCarrier().attributeOwnerIdField - set(v) { - if (attributeOwnerId !== v) { - setCarrier().attributeOwnerIdField = v - } - } - - override var correspondingPropertySymbolField: IrPropertySymbol? = null - - override var correspondingPropertySymbol: IrPropertySymbol? - get() = getCarrier().correspondingPropertySymbolField - set(v) { - if (correspondingPropertySymbol !== v) { - setCarrier().correspondingPropertySymbolField = v - } - } - - override var isExternalField: Boolean = isExternal - - override var isExternal: Boolean - get() = getCarrier().isExternalField - set(v) { - if (isExternal != v) { - setCarrier().isExternalField = v - } - } -} - internal class PersistentIrFunction( startOffset: Int, endOffset: Int, diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt new file mode 100644 index 00000000000..56a5a612bec --- /dev/null +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt @@ -0,0 +1,182 @@ +/* + * Copyright 2010-2020 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.ir.declarations.persistent + +import org.jetbrains.kotlin.descriptors.DescriptorVisibility +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier +import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FunctionCarrier +import org.jetbrains.kotlin.ir.expressions.IrBody +import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType +import org.jetbrains.kotlin.ir.types.impl.ReturnTypeIsNotInitializedException +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource + +internal abstract class PersistentIrFunctionCommon( + override val startOffset: Int, + override val endOffset: Int, + origin: IrDeclarationOrigin, + override val name: Name, + visibility: DescriptorVisibility, + returnType: IrType, + override val isInline: Boolean, + isExternal: Boolean, + override val isTailrec: Boolean, + override val isSuspend: Boolean, + override val isOperator: Boolean, + override val isInfix: Boolean, + override val isExpect: Boolean, + override val containerSource: DeserializedContainerSource? = null +) : IrSimpleFunction(), + PersistentIrDeclarationBase, + FunctionCarrier { + + override var lastModified: Int = stageController.currentStage + override var loweredUpTo: Int = stageController.currentStage + override var values: Array? = null + override val createdOn: Int = stageController.currentStage + + override var parentField: IrDeclarationParent? = null + override var originField: IrDeclarationOrigin = origin + override var removedOn: Int = Int.MAX_VALUE + override var annotationsField: List = emptyList() + + override var returnTypeFieldField: IrType = returnType + + private var returnTypeField: IrType + get() = getCarrier().returnTypeFieldField + set(v) { + if (returnTypeField !== v) { + setCarrier().returnTypeFieldField = v + } + } + + final override var returnType: IrType + get() = returnTypeField.let { + if (it !== IrUninitializedType) it else throw ReturnTypeIsNotInitializedException(this) + } + set(c) { + returnTypeField = c + } + + override var typeParametersField: List = emptyList() + + override var typeParameters: List + get() = getCarrier().typeParametersField + set(v) { + if (typeParameters !== v) { + setCarrier().typeParametersField = v + } + } + + override var dispatchReceiverParameterField: IrValueParameter? = null + + override var dispatchReceiverParameter: IrValueParameter? + get() = getCarrier().dispatchReceiverParameterField + set(v) { + if (dispatchReceiverParameter !== v) { + setCarrier().dispatchReceiverParameterField = v + } + } + + override var extensionReceiverParameterField: IrValueParameter? = null + + override var extensionReceiverParameter: IrValueParameter? + get() = getCarrier().extensionReceiverParameterField + set(v) { + if (extensionReceiverParameter !== v) { + setCarrier().extensionReceiverParameterField = v + } + } + + override var valueParametersField: List = emptyList() + + override var valueParameters: List + get() = getCarrier().valueParametersField + set(v) { + if (valueParameters !== v) { + setCarrier().valueParametersField = v + } + } + + override var bodyField: IrBody? = null + + final override var body: IrBody? + get() = getCarrier().bodyField + set(v) { + if (body !== v) { + if (v is PersistentIrBodyBase<*>) { + v.container = this + } + setCarrier().bodyField = v + } + } + + override var metadataField: MetadataSource? = null + + override var metadata: MetadataSource? + get() = getCarrier().metadataField + set(v) { + if (metadata !== v) { + setCarrier().metadataField = v + } + } + + override var visibilityField: DescriptorVisibility = visibility + + override var visibility: DescriptorVisibility + get() = getCarrier().visibilityField + set(v) { + if (visibility !== v) { + setCarrier().visibilityField = v + } + } + + override var overriddenSymbolsField: List = emptyList() + + override var overriddenSymbols: List + get() = getCarrier().overriddenSymbolsField + set(v) { + if (overriddenSymbols !== v) { + setCarrier().overriddenSymbolsField = v + } + } + + @Suppress("LeakingThis") + override var attributeOwnerIdField: IrAttributeContainer = this + + override var attributeOwnerId: IrAttributeContainer + get() = getCarrier().attributeOwnerIdField + set(v) { + if (attributeOwnerId !== v) { + setCarrier().attributeOwnerIdField = v + } + } + + override var correspondingPropertySymbolField: IrPropertySymbol? = null + + override var correspondingPropertySymbol: IrPropertySymbol? + get() = getCarrier().correspondingPropertySymbolField + set(v) { + if (correspondingPropertySymbol !== v) { + setCarrier().correspondingPropertySymbolField = v + } + } + + override var isExternalField: Boolean = isExternal + + override var isExternal: Boolean + get() = getCarrier().isExternalField + set(v) { + if (isExternal != v) { + setCarrier().isExternalField = v + } + } +} diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrProperty.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrProperty.kt index c9383041931..eba7bdafa13 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrProperty.kt +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrProperty.kt @@ -1,19 +1,9 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2020 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.ir.declarations.persistent import org.jetbrains.kotlin.descriptors.Modality @@ -29,95 +19,6 @@ import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource -internal abstract class PersistentIrPropertyCommon( - override val startOffset: Int, - override val endOffset: Int, - origin: IrDeclarationOrigin, - override val name: Name, - override var visibility: DescriptorVisibility, - override val isVar: Boolean, - override val isConst: Boolean, - override val isLateinit: Boolean, - override val isDelegated: Boolean, - isExternal: Boolean, - override val isExpect: Boolean, - override val containerSource: DeserializedContainerSource?, -) : IrProperty(), - PersistentIrDeclarationBase, - PropertyCarrier { - - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage - override var values: Array? = null - override val createdOn: Int = stageController.currentStage - - override var parentField: IrDeclarationParent? = null - override var originField: IrDeclarationOrigin = origin - override var removedOn: Int = Int.MAX_VALUE - override var annotationsField: List = emptyList() - - override var backingFieldField: IrField? = null - - override var backingField: IrField? - get() = getCarrier().backingFieldField - set(v) { - if (backingField !== v) { - setCarrier().backingFieldField = v - } - } - - override var getterField: IrSimpleFunction? = null - - override var getter: IrSimpleFunction? - get() = getCarrier().getterField - set(v) { - if (getter !== v) { - setCarrier().getterField = v - } - } - - override var setterField: IrSimpleFunction? = null - - override var setter: IrSimpleFunction? - get() = getCarrier().setterField - set(v) { - if (setter !== v) { - setCarrier().setterField = v - } - } - - override var metadataField: MetadataSource? = null - - override var metadata: MetadataSource? - get() = getCarrier().metadataField - set(v) { - if (metadata !== v) { - setCarrier().metadataField = v - } - } - - @Suppress("LeakingThis") - override var attributeOwnerIdField: IrAttributeContainer = this - - override var attributeOwnerId: IrAttributeContainer - get() = getCarrier().attributeOwnerIdField - set(v) { - if (attributeOwnerId !== v) { - setCarrier().attributeOwnerIdField = v - } - } - - override var isExternalField: Boolean = isExternal - - override var isExternal: Boolean - get() = getCarrier().isExternalField - set(v) { - if (isExternal != v) { - setCarrier().isExternalField = v - } - } -} - internal class PersistentIrProperty( startOffset: Int, endOffset: Int, diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt new file mode 100644 index 00000000000..d43fe79bf49 --- /dev/null +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt @@ -0,0 +1,103 @@ +/* + * Copyright 2010-2020 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.ir.declarations.persistent + +import org.jetbrains.kotlin.descriptors.DescriptorVisibility +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier +import org.jetbrains.kotlin.ir.declarations.persistent.carriers.PropertyCarrier +import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource + +internal abstract class PersistentIrPropertyCommon( + override val startOffset: Int, + override val endOffset: Int, + origin: IrDeclarationOrigin, + override val name: Name, + override var visibility: DescriptorVisibility, + override val isVar: Boolean, + override val isConst: Boolean, + override val isLateinit: Boolean, + override val isDelegated: Boolean, + isExternal: Boolean, + override val isExpect: Boolean, + override val containerSource: DeserializedContainerSource?, +) : IrProperty(), + PersistentIrDeclarationBase, + PropertyCarrier { + + override var lastModified: Int = stageController.currentStage + override var loweredUpTo: Int = stageController.currentStage + override var values: Array? = null + override val createdOn: Int = stageController.currentStage + + override var parentField: IrDeclarationParent? = null + override var originField: IrDeclarationOrigin = origin + override var removedOn: Int = Int.MAX_VALUE + override var annotationsField: List = emptyList() + + override var backingFieldField: IrField? = null + + override var backingField: IrField? + get() = getCarrier().backingFieldField + set(v) { + if (backingField !== v) { + setCarrier().backingFieldField = v + } + } + + override var getterField: IrSimpleFunction? = null + + override var getter: IrSimpleFunction? + get() = getCarrier().getterField + set(v) { + if (getter !== v) { + setCarrier().getterField = v + } + } + + override var setterField: IrSimpleFunction? = null + + override var setter: IrSimpleFunction? + get() = getCarrier().setterField + set(v) { + if (setter !== v) { + setCarrier().setterField = v + } + } + + override var metadataField: MetadataSource? = null + + override var metadata: MetadataSource? + get() = getCarrier().metadataField + set(v) { + if (metadata !== v) { + setCarrier().metadataField = v + } + } + + @Suppress("LeakingThis") + override var attributeOwnerIdField: IrAttributeContainer = this + + override var attributeOwnerId: IrAttributeContainer + get() = getCarrier().attributeOwnerIdField + set(v) { + if (attributeOwnerId !== v) { + setCarrier().attributeOwnerIdField = v + } + } + + override var isExternalField: Boolean = isExternal + + override var isExternal: Boolean + get() = getCarrier().isExternalField + set(v) { + if (isExternal != v) { + setCarrier().isExternalField = v + } + } +} diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorCarrier.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorDeclarationCarrier.kt similarity index 68% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorCarrier.kt rename to compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorDeclarationCarrier.kt index 936c123b002..94a251b04f4 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorCarrier.kt +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorDeclarationCarrier.kt @@ -9,15 +9,15 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -internal interface ErrorCarrier : DeclarationCarrier { - override fun clone(): ErrorCarrier { - return ErrorCarrierImpl(lastModified, parentField, originField, annotationsField) +internal interface ErrorDeclarationCarrier : DeclarationCarrier { + override fun clone(): ErrorDeclarationCarrier { + return ErrorDeclarationCarrierImpl(lastModified, parentField, originField, annotationsField) } } -internal class ErrorCarrierImpl( +internal class ErrorDeclarationCarrierImpl( override val lastModified: Int, override var parentField: IrDeclarationParent?, override var originField: IrDeclarationOrigin, override var annotationsField: List -) : ErrorCarrier +) : ErrorDeclarationCarrier From 97080c49fcb4a9d6b3189afa20e3b4b81f86747d Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Wed, 9 Sep 2020 18:42:55 +0300 Subject: [PATCH 202/368] Persistent IR generator Goal: - avoid hand-writing the boilerplate - easier PIR evolution Output is reasonably close the hand-writtern version --- .../ir/ir.tree.persistent/build.gradle.kts | 5 +- .../PersistentIrAnonymousInitializer.kt | 17 +- .../persistent/PersistentIrClass.kt | 36 +- .../persistent/PersistentIrConstructor.kt | 25 +- .../persistent/PersistentIrEnumEntry.kt | 23 +- .../PersistentIrErrorDeclaration.kt | 21 +- .../persistent/PersistentIrField.kt | 25 +- .../persistent/PersistentIrFunctionCommon.kt | 15 +- .../PersistentIrLocalDelegatedProperty.kt | 17 +- .../persistent/PersistentIrPropertyCommon.kt | 15 +- .../persistent/PersistentIrTypeAlias.kt | 12 +- .../persistent/PersistentIrTypeParameter.kt | 17 +- .../persistent/PersistentIrValueParameter.kt | 17 +- .../carriers/AnonymousInitializerCarrier.kt | 8 +- .../persistent/carriers/ClassCarrier.kt | 19 +- .../persistent/carriers/ConstructorCarrier.kt | 28 +- .../persistent/carriers/EnumEntryCarrier.kt | 8 +- .../carriers/ErrorDeclarationCarrier.kt | 16 +- .../persistent/carriers/FieldCarrier.kt | 10 +- .../persistent/carriers/FunctionCarrier.kt | 28 +- .../carriers/LocalDelegatedPropertyCarrier.kt | 12 +- .../persistent/carriers/PropertyCarrier.kt | 17 +- .../persistent/carriers/TypeAliasCarrier.kt | 8 +- .../carriers/TypeParameterCarrier.kt | 18 +- .../carriers/ValueParameterCarrier.kt | 18 +- .../generator/build.gradle.kts | 15 + .../AnonymousInitializer.kt | 35 ++ .../kotlin/ir/persistentIrGenerator/Class.kt | 91 +++++ .../ir/persistentIrGenerator/Constructor.kt | 80 +++++ .../ir/persistentIrGenerator/EnumEntry.kt | 42 +++ .../persistentIrGenerator/ErrorDeclaration.kt | 45 +++ .../kotlin/ir/persistentIrGenerator/Field.kt | 55 +++ .../ir/persistentIrGenerator/Function.kt | 99 ++++++ .../LocalDelegatedProperty.kt | 53 +++ .../kotlin/ir/persistentIrGenerator/Main.kt | 23 ++ .../PersistentIrGenerator.kt | 315 ++++++++++++++++++ .../ir/persistentIrGenerator/Property.kt | 61 ++++ .../ir/persistentIrGenerator/TypeAlias.kt | 45 +++ .../ir/persistentIrGenerator/TypeParameter.kt | 41 +++ .../persistentIrGenerator/ValueParameter.kt | 51 +++ .../carriers/FunctionBaseCarrier.kt | 25 -- settings.gradle | 2 + 42 files changed, 1308 insertions(+), 205 deletions(-) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrAnonymousInitializer.kt (78%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrClass.kt (79%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrConstructor.kt (87%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrEnumEntry.kt (77%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt (68%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrField.kt (83%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt (89%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrLocalDelegatedProperty.kt (81%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt (81%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeAlias.kt (82%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeParameter.kt (78%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrValueParameter.kt (83%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/AnonymousInitializerCarrier.kt (74%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ClassCarrier.kt (69%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ConstructorCarrier.kt (55%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/EnumEntryCarrier.kt (74%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorDeclarationCarrier.kt (51%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FieldCarrier.kt (78%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FunctionCarrier.kt (62%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/LocalDelegatedPropertyCarrier.kt (73%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/PropertyCarrier.kt (61%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeAliasCarrier.kt (79%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeParameterCarrier.kt (51%) rename compiler/ir/ir.tree.persistent/{src => gen}/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ValueParameterCarrier.kt (59%) create mode 100644 compiler/ir/ir.tree.persistent/generator/build.gradle.kts create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/AnonymousInitializer.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Class.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Constructor.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/EnumEntry.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ErrorDeclaration.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Field.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Function.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/LocalDelegatedProperty.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/PersistentIrGenerator.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Property.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeAlias.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeParameter.kt create mode 100644 compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ValueParameter.kt delete mode 100644 compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FunctionBaseCarrier.kt diff --git a/compiler/ir/ir.tree.persistent/build.gradle.kts b/compiler/ir/ir.tree.persistent/build.gradle.kts index c4a6e3034f2..c8d9f2a1c72 100644 --- a/compiler/ir/ir.tree.persistent/build.gradle.kts +++ b/compiler/ir/ir.tree.persistent/build.gradle.kts @@ -8,6 +8,9 @@ dependencies { } sourceSets { - "main" { projectDefault() } + "main" { + projectDefault() + this.java.srcDir("gen") + } "test" {} } diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrAnonymousInitializer.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrAnonymousInitializer.kt similarity index 78% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrAnonymousInitializer.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrAnonymousInitializer.kt index e724238189f..b051c05adbf 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrAnonymousInitializer.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrAnonymousInitializer.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.ir.declarations.persistent @@ -28,6 +17,8 @@ import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrAnonymousInitializerSymbol +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + internal class PersistentIrAnonymousInitializer( override val startOffset: Int, override val endOffset: Int, diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrClass.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrClass.kt similarity index 79% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrClass.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrClass.kt index 67a8b24fa40..e62208b4947 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrClass.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrClass.kt @@ -1,31 +1,35 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.ir.declarations.persistent -import org.jetbrains.kotlin.descriptors.* +import java.util.ArrayList +import java.util.Collections +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.descriptors.DescriptorVisibility +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer +import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.ir.declarations.IrDeclaration +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrTypeParameter +import org.jetbrains.kotlin.ir.declarations.IrValueParameter +import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ClassCarrier +import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.name.Name -import java.util.* + +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! internal class PersistentIrClass( override val startOffset: Int, diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrConstructor.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrConstructor.kt similarity index 87% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrConstructor.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrConstructor.kt index 05c22b2bc46..d44f6daeb74 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrConstructor.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrConstructor.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.ir.declarations.persistent @@ -19,9 +8,15 @@ package org.jetbrains.kotlin.ir.declarations.persistent import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor import org.jetbrains.kotlin.descriptors.DescriptorVisibility import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrConstructor +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrTypeParameter +import org.jetbrains.kotlin.ir.declarations.IrValueParameter +import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ConstructorCarrier +import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol @@ -31,6 +26,8 @@ import org.jetbrains.kotlin.ir.types.impl.ReturnTypeIsNotInitializedException import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + internal class PersistentIrConstructor( override val startOffset: Int, override val endOffset: Int, diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrEnumEntry.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrEnumEntry.kt similarity index 77% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrEnumEntry.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrEnumEntry.kt index 33243e7d488..a681c2a9844 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrEnumEntry.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrEnumEntry.kt @@ -1,31 +1,26 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.ir.declarations.persistent import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrEnumEntry import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.EnumEntryCarrier +import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol import org.jetbrains.kotlin.name.Name +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + internal class PersistentIrEnumEntry( override val startOffset: Int, override val endOffset: Int, diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt similarity index 68% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt index 949698978fd..9611f86ab7f 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.ir.declarations.persistent @@ -27,12 +16,16 @@ import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor import org.jetbrains.kotlin.ir.expressions.IrConstructorCall +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + @OptIn(ObsoleteDescriptorBasedAPI::class) internal class PersistentIrErrorDeclaration( override val startOffset: Int, override val endOffset: Int, private val _descriptor: DeclarationDescriptor? -) : PersistentIrDeclarationBase, IrErrorDeclaration(), ErrorDeclarationCarrier { +) : IrErrorDeclaration(), + PersistentIrDeclarationBase, + ErrorDeclarationCarrier { override val descriptor: DeclarationDescriptor get() = _descriptor ?: this.toIrBasedDescriptor() diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrField.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrField.kt similarity index 83% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrField.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrField.kt index 0a3b2db6dff..1c222461f04 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrField.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrField.kt @@ -1,27 +1,20 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.ir.declarations.persistent -import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.DescriptorVisibility +import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrField +import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FieldCarrier +import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol @@ -29,6 +22,8 @@ import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.name.Name +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + internal class PersistentIrField( override val startOffset: Int, override val endOffset: Int, diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt similarity index 89% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt index 56a5a612bec..a6327bdf99d 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt @@ -1,14 +1,21 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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.ir.declarations.persistent import org.jetbrains.kotlin.descriptors.DescriptorVisibility -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction +import org.jetbrains.kotlin.ir.declarations.IrTypeParameter +import org.jetbrains.kotlin.ir.declarations.IrValueParameter +import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FunctionCarrier +import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol @@ -19,6 +26,8 @@ import org.jetbrains.kotlin.ir.types.impl.ReturnTypeIsNotInitializedException import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + internal abstract class PersistentIrFunctionCommon( override val startOffset: Int, override val endOffset: Int, @@ -108,7 +117,7 @@ internal abstract class PersistentIrFunctionCommon( override var bodyField: IrBody? = null - final override var body: IrBody? + override var body: IrBody? get() = getCarrier().bodyField set(v) { if (body !== v) { diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrLocalDelegatedProperty.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrLocalDelegatedProperty.kt similarity index 81% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrLocalDelegatedProperty.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrLocalDelegatedProperty.kt index 39691ae9e8f..77e87a25393 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrLocalDelegatedProperty.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrLocalDelegatedProperty.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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. */ @@ -7,14 +7,22 @@ package org.jetbrains.kotlin.ir.declarations.persistent import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrLocalDelegatedProperty +import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction +import org.jetbrains.kotlin.ir.declarations.IrVariable +import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.LocalDelegatedPropertyCarrier +import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrLocalDelegatedPropertySymbol import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.name.Name +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + // TODO make not persistent internal class PersistentIrLocalDelegatedProperty( override val startOffset: Int, @@ -24,9 +32,8 @@ internal class PersistentIrLocalDelegatedProperty( override val name: Name, type: IrType, override val isVar: Boolean -) : +) : IrLocalDelegatedProperty(), PersistentIrDeclarationBase, - IrLocalDelegatedProperty(), LocalDelegatedPropertyCarrier { init { @@ -52,7 +59,7 @@ internal class PersistentIrLocalDelegatedProperty( override var type: IrType get() = getCarrier().typeField set(v) { - if (getCarrier().typeField !== v) { + if (type !== v) { setCarrier().typeField = v } } diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt similarity index 81% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt index d43fe79bf49..b86f839f78a 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt @@ -1,18 +1,27 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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.ir.declarations.persistent import org.jetbrains.kotlin.descriptors.DescriptorVisibility -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrField +import org.jetbrains.kotlin.ir.declarations.IrProperty +import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction +import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.PropertyCarrier +import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + internal abstract class PersistentIrPropertyCommon( override val startOffset: Int, override val endOffset: Int, @@ -25,7 +34,7 @@ internal abstract class PersistentIrPropertyCommon( override val isDelegated: Boolean, isExternal: Boolean, override val isExpect: Boolean, - override val containerSource: DeserializedContainerSource?, + override val containerSource: DeserializedContainerSource? ) : IrProperty(), PersistentIrDeclarationBase, PropertyCarrier { diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeAlias.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeAlias.kt similarity index 82% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeAlias.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeAlias.kt index a37ba1dd1ec..fc7860e0eba 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeAlias.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeAlias.kt @@ -1,21 +1,27 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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.ir.declarations.persistent -import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor import org.jetbrains.kotlin.descriptors.DescriptorVisibility +import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrTypeAlias +import org.jetbrains.kotlin.ir.declarations.IrTypeParameter import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.TypeAliasCarrier +import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrTypeAliasSymbol import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.name.Name +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + internal class PersistentIrTypeAlias( override val startOffset: Int, override val endOffset: Int, diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeParameter.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeParameter.kt similarity index 78% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeParameter.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeParameter.kt index 4de9e93a666..0fa5b40fbb2 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeParameter.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeParameter.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.ir.declarations.persistent @@ -30,6 +19,8 @@ import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.Variance +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + internal class PersistentIrTypeParameter( override val startOffset: Int, override val endOffset: Int, diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrValueParameter.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrValueParameter.kt similarity index 83% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrValueParameter.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrValueParameter.kt index 84a10bee4c8..241521ee85e 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrValueParameter.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrValueParameter.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.ir.declarations.persistent @@ -30,6 +19,8 @@ import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.name.Name +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + internal class PersistentIrValueParameter( override val startOffset: Int, override val endOffset: Int, diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/AnonymousInitializerCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/AnonymousInitializerCarrier.kt similarity index 74% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/AnonymousInitializerCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/AnonymousInitializerCarrier.kt index afd78d2f0c7..21ca57fd70e 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/AnonymousInitializerCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/AnonymousInitializerCarrier.kt @@ -1,6 +1,6 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2021 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.ir.declarations.persistent.carriers @@ -10,7 +10,9 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -internal interface AnonymousInitializerCarrier : DeclarationCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface AnonymousInitializerCarrier : DeclarationCarrier{ var bodyField: IrBlockBody? override fun clone(): AnonymousInitializerCarrier { diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ClassCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ClassCarrier.kt similarity index 69% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ClassCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ClassCarrier.kt index 46732248661..bb6799b1a88 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ClassCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ClassCarrier.kt @@ -1,25 +1,32 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2021 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.ir.declarations.persistent.carriers -import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.DescriptorVisibility -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrTypeParameter +import org.jetbrains.kotlin.ir.declarations.IrValueParameter +import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.types.IrType -internal interface ClassCarrier : DeclarationCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface ClassCarrier : DeclarationCarrier{ var thisReceiverField: IrValueParameter? var metadataField: MetadataSource? var visibilityField: DescriptorVisibility var modalityField: Modality - var isExternalField: Boolean var attributeOwnerIdField: IrAttributeContainer var typeParametersField: List var superTypesField: List + var isExternalField: Boolean override fun clone(): ClassCarrier { return ClassCarrierImpl( diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ConstructorCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ConstructorCarrier.kt similarity index 55% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ConstructorCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ConstructorCarrier.kt index 85ee79cea81..dbbd6510eab 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ConstructorCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ConstructorCarrier.kt @@ -1,17 +1,33 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2021 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.ir.declarations.persistent.carriers import org.jetbrains.kotlin.descriptors.DescriptorVisibility -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrTypeParameter +import org.jetbrains.kotlin.ir.declarations.IrValueParameter +import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.types.IrType -internal interface ConstructorCarrier : FunctionBaseCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface ConstructorCarrier : DeclarationCarrier{ + var returnTypeFieldField: IrType + var dispatchReceiverParameterField: IrValueParameter? + var extensionReceiverParameterField: IrValueParameter? + var bodyField: IrBody? + var metadataField: MetadataSource? + var visibilityField: DescriptorVisibility + var typeParametersField: List + var valueParametersField: List + var isExternalField: Boolean + override fun clone(): ConstructorCarrier { return ConstructorCarrierImpl( lastModified, @@ -26,7 +42,7 @@ internal interface ConstructorCarrier : FunctionBaseCarrier { visibilityField, typeParametersField, valueParametersField, - isExternalField, + isExternalField ) } } @@ -44,5 +60,5 @@ internal class ConstructorCarrierImpl( override var visibilityField: DescriptorVisibility, override var typeParametersField: List, override var valueParametersField: List, - override var isExternalField: Boolean, + override var isExternalField: Boolean ) : ConstructorCarrier diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/EnumEntryCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/EnumEntryCarrier.kt similarity index 74% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/EnumEntryCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/EnumEntryCarrier.kt index 94e2257f7c8..93f43407551 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/EnumEntryCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/EnumEntryCarrier.kt @@ -1,6 +1,6 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2021 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.ir.declarations.persistent.carriers @@ -11,7 +11,9 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrExpressionBody -internal interface EnumEntryCarrier : DeclarationCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface EnumEntryCarrier : DeclarationCarrier{ var correspondingClassField: IrClass? var initializerExpressionField: IrExpressionBody? diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorDeclarationCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorDeclarationCarrier.kt similarity index 51% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorDeclarationCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorDeclarationCarrier.kt index 94a251b04f4..53724237328 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorDeclarationCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ErrorDeclarationCarrier.kt @@ -1,6 +1,6 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2021 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.ir.declarations.persistent.carriers @@ -9,9 +9,17 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -internal interface ErrorDeclarationCarrier : DeclarationCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface ErrorDeclarationCarrier : DeclarationCarrier{ + override fun clone(): ErrorDeclarationCarrier { - return ErrorDeclarationCarrierImpl(lastModified, parentField, originField, annotationsField) + return ErrorDeclarationCarrierImpl( + lastModified, + parentField, + originField, + annotationsField + ) } } diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FieldCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FieldCarrier.kt similarity index 78% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FieldCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FieldCarrier.kt index 8da09c3fd20..1e86540c981 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FieldCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FieldCarrier.kt @@ -1,6 +1,6 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2021 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.ir.declarations.persistent.carriers @@ -13,7 +13,9 @@ import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol import org.jetbrains.kotlin.ir.types.IrType -internal interface FieldCarrier : DeclarationCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface FieldCarrier : DeclarationCarrier{ var typeField: IrType var initializerField: IrExpressionBody? var correspondingPropertySymbolField: IrPropertySymbol? @@ -30,7 +32,7 @@ internal interface FieldCarrier : DeclarationCarrier { initializerField, correspondingPropertySymbolField, metadataField, - isExternalField, + isExternalField ) } } diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FunctionCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FunctionCarrier.kt similarity index 62% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FunctionCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FunctionCarrier.kt index 80b113997fb..38cd86ca15f 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FunctionCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FunctionCarrier.kt @@ -1,22 +1,38 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2021 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.ir.declarations.persistent.carriers import org.jetbrains.kotlin.descriptors.DescriptorVisibility -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrTypeParameter +import org.jetbrains.kotlin.ir.declarations.IrValueParameter +import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.types.IrType -internal interface FunctionCarrier : FunctionBaseCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface FunctionCarrier : DeclarationCarrier{ + var returnTypeFieldField: IrType + var dispatchReceiverParameterField: IrValueParameter? + var extensionReceiverParameterField: IrValueParameter? + var bodyField: IrBody? + var metadataField: MetadataSource? + var visibilityField: DescriptorVisibility + var typeParametersField: List + var valueParametersField: List var correspondingPropertySymbolField: IrPropertySymbol? var overriddenSymbolsField: List var attributeOwnerIdField: IrAttributeContainer + var isExternalField: Boolean override fun clone(): FunctionCarrier { return FunctionCarrierImpl( @@ -35,7 +51,7 @@ internal interface FunctionCarrier : FunctionBaseCarrier { correspondingPropertySymbolField, overriddenSymbolsField, attributeOwnerIdField, - isExternalField, + isExternalField ) } } @@ -56,5 +72,5 @@ internal class FunctionCarrierImpl( override var correspondingPropertySymbolField: IrPropertySymbol?, override var overriddenSymbolsField: List, override var attributeOwnerIdField: IrAttributeContainer, - override var isExternalField: Boolean, + override var isExternalField: Boolean ) : FunctionCarrier diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/LocalDelegatedPropertyCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/LocalDelegatedPropertyCarrier.kt similarity index 73% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/LocalDelegatedPropertyCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/LocalDelegatedPropertyCarrier.kt index 12d76ac24e1..523da1fa329 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/LocalDelegatedPropertyCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/LocalDelegatedPropertyCarrier.kt @@ -1,15 +1,21 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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.ir.declarations.persistent.carriers -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction +import org.jetbrains.kotlin.ir.declarations.IrVariable +import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.types.IrType -internal interface LocalDelegatedPropertyCarrier : DeclarationCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface LocalDelegatedPropertyCarrier : DeclarationCarrier{ var typeField: IrType var delegateField: IrVariable? var getterField: IrSimpleFunction? diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/PropertyCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/PropertyCarrier.kt similarity index 61% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/PropertyCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/PropertyCarrier.kt index 17dc84fc51e..1f723f65d8d 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/PropertyCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/PropertyCarrier.kt @@ -1,14 +1,21 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2021 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.ir.declarations.persistent.carriers -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer +import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin +import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent +import org.jetbrains.kotlin.ir.declarations.IrField +import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction +import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -internal interface PropertyCarrier : DeclarationCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface PropertyCarrier : DeclarationCarrier{ var backingFieldField: IrField? var getterField: IrSimpleFunction? var setterField: IrSimpleFunction? @@ -27,7 +34,7 @@ internal interface PropertyCarrier : DeclarationCarrier { setterField, metadataField, attributeOwnerIdField, - isExternalField, + isExternalField ) } } diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeAliasCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeAliasCarrier.kt similarity index 79% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeAliasCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeAliasCarrier.kt index 80518218da4..8a820c9eaf0 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeAliasCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeAliasCarrier.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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. */ @@ -11,7 +11,9 @@ import org.jetbrains.kotlin.ir.declarations.IrTypeParameter import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.types.IrType -internal interface TypeAliasCarrier : DeclarationCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface TypeAliasCarrier : DeclarationCarrier{ var typeParametersField: List var expandedTypeField: IrType @@ -33,5 +35,5 @@ internal class TypeAliasCarrierImpl( override var originField: IrDeclarationOrigin, override var annotationsField: List, override var typeParametersField: List, - override var expandedTypeField: IrType, + override var expandedTypeField: IrType ) : TypeAliasCarrier diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeParameterCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeParameterCarrier.kt similarity index 51% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeParameterCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeParameterCarrier.kt index 2b10ca10f5a..18ec9a07390 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeParameterCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/TypeParameterCarrier.kt @@ -1,6 +1,6 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2021 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.ir.declarations.persistent.carriers @@ -10,11 +10,19 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.types.IrType -internal interface TypeParameterCarrier : DeclarationCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface TypeParameterCarrier : DeclarationCarrier{ var superTypesField: List override fun clone(): TypeParameterCarrier { - return TypeParameterCarrierImpl(lastModified, parentField, originField, annotationsField, superTypesField) + return TypeParameterCarrierImpl( + lastModified, + parentField, + originField, + annotationsField, + superTypesField + ) } } @@ -23,5 +31,5 @@ internal class TypeParameterCarrierImpl( override var parentField: IrDeclarationParent?, override var originField: IrDeclarationOrigin, override var annotationsField: List, - override var superTypesField: List, + override var superTypesField: List ) : TypeParameterCarrier diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ValueParameterCarrier.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ValueParameterCarrier.kt similarity index 59% rename from compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ValueParameterCarrier.kt rename to compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ValueParameterCarrier.kt index d1541a6a4f3..072377b43c2 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ValueParameterCarrier.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/carriers/ValueParameterCarrier.kt @@ -1,6 +1,6 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the license/LICENSE.txt file. + * Copyright 2010-2021 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.ir.declarations.persistent.carriers @@ -11,14 +11,22 @@ import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.types.IrType -internal interface ValueParameterCarrier : DeclarationCarrier { +// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT! + +internal interface ValueParameterCarrier : DeclarationCarrier{ var defaultValueField: IrExpressionBody? var typeField: IrType var varargElementTypeField: IrType? override fun clone(): ValueParameterCarrier { return ValueParameterCarrierImpl( - lastModified, parentField, originField, annotationsField, defaultValueField, typeField, varargElementTypeField + lastModified, + parentField, + originField, + annotationsField, + defaultValueField, + typeField, + varargElementTypeField ) } } @@ -30,5 +38,5 @@ internal class ValueParameterCarrierImpl( override var annotationsField: List, override var defaultValueField: IrExpressionBody?, override var typeField: IrType, - override var varargElementTypeField: IrType?, + override var varargElementTypeField: IrType? ) : ValueParameterCarrier diff --git a/compiler/ir/ir.tree.persistent/generator/build.gradle.kts b/compiler/ir/ir.tree.persistent/generator/build.gradle.kts new file mode 100644 index 00000000000..940650ad670 --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + kotlin("jvm") + id("jps-compatible") +} + +dependencies { + implementation(kotlinStdlib()) +} + +sourceSets { + "main" { projectDefault() } + "test" {} +} + +val generatePir by generator("org.jetbrains.kotlin.ir.persistentIrGenerator.MainKt", mainSourceSet) \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/AnonymousInitializer.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/AnonymousInitializer.kt new file mode 100644 index 00000000000..0790f993898 --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/AnonymousInitializer.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +internal fun PersistentIrGenerator.generateAnonymousInitializer() { + val body = Field("body", IrBlockBody, lateinit = true) + + writeFile("PersistentIrAnonymousInitializer.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"internal class PersistentIrAnonymousInitializer(", + arrayOf( + startOffset, + endOffset, + origin, + +"override val symbol: " + IrAnonymousInitializerSymbol, + isStatic + " = false", + ).join(separator = ",\n").indent(), + +") : " + baseClasses("AnonymousInitializer") + " " + blockSpaced( + initBlock, + commonFields, + descriptor(ClassDescriptor), + body.toBody(), + ), + id, + )() + }) + + writeFile("carriers/AnonymousInitializerCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers("AnonymousInitializer", body)() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Class.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Class.kt new file mode 100644 index 00000000000..870379a130c --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Class.kt @@ -0,0 +1,91 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +internal fun PersistentIrGenerator.generateClass() { + val visibilityField = Field("visibility", descriptorType("DescriptorVisibility")) + val thisReceiverField = Field("thisReceiver", irDeclaration("IrValueParameter") + "?") + val typeParametersField = Field("typeParameters", +"List<" + irDeclaration("IrTypeParameter") + ">") + val superTypesField = Field("superTypes", +"List<" + import("IrType", "org.jetbrains.kotlin.ir.types") + ">") + val metadataField = Field("metadata", irDeclaration("MetadataSource") + "?") + val modalityField = Field("modality", descriptorType("Modality")) + val attributeOwnerIdField = Field("attributeOwnerId", IrAttributeContainer) + val isExternalField = Field("isExternal", +"Boolean", notEq = "!=") + + writeFile("PersistentIrClass.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"internal class PersistentIrClass(", + arrayOf( + startOffset, + endOffset, + origin, + +"override val symbol: " + IrClassSymbol, + name, + kind, + visibility, + modality, + isCompanion, + isInner, + isData, + isExternal + " = false", + isInline + " = false", + isExpect + " = false", + isFun, + source, + ).join(separator = ",\n").indent(), + +") : " + baseClasses("Class") + " " + blockSpaced( + initBlock, + commonFields, + descriptor(ClassDescriptor), + visibilityField.toPersistentField(+"visibility"), + thisReceiverField.toPersistentField(+"null"), + lines( + +"private var initialDeclarations: MutableList<" + IrDeclaration + ">? = null", + id, + +"override val declarations: MutableList = " + import("ArrayList", "java.util") + "()", + lines( + +"get() " + block( + +"if (createdOn < stageController.currentStage && initialDeclarations == null) " + block( + +"initialDeclarations = " + import("Collections", "java.util") + ".unmodifiableList(ArrayList(field))" + ), + id, + +""" + return if (stageController.canAccessDeclarationsOf(this)) { + ensureLowered() + field + } else { + initialDeclarations ?: field + } + """.trimIndent() + ) + ).indent() + ), + typeParametersField.toPersistentField(+"emptyList()"), + superTypesField.toPersistentField(+"emptyList()"), + metadataField.toPersistentField(+"null"), + modalityField.toPersistentField(+"modality"), + isExternalField.toPersistentField(+"isExternal"), + attributeOwnerIdField.toPersistentField(+"this"), + ), + id, + )() + }) + + writeFile("carriers/ClassCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers( + "Class", + thisReceiverField, + metadataField, + visibilityField, + modalityField, + attributeOwnerIdField, + typeParametersField, + superTypesField, + isExternalField, + )() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Constructor.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Constructor.kt new file mode 100644 index 00000000000..a75134ab61d --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Constructor.kt @@ -0,0 +1,80 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +internal fun PersistentIrGenerator.generateConstructor() { + val returnTypeFieldField = Field("returnTypeField", IrType) + val typeParametersField = Field("typeParameters", +"List<" + IrTypeParameter + ">") + val dispatchReceiverParameterField = Field("dispatchReceiverParameter", IrValueParameter + "?") + val extensionReceiverParameterField = Field("extensionReceiverParameter", IrValueParameter + "?") + val valueParametersField = Field("valueParameters", +"List<" + IrValueParameter + ">") + val bodyField = Field("body", IrBody + "?") + val metadataField = Field("metadata", MetadataSource + "?") + val visibilityField = Field("visibility", DescriptorVisibility) + val isExternalField = Field("isExternal", +"Boolean", notEq = "!=") + + writeFile("PersistentIrConstructor.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"internal class PersistentIrConstructor(", + arrayOf( + startOffset, + endOffset, + origin, + +"override val symbol: " + irSymbol("IrConstructorSymbol"), + name, + visibility, + returnType, + isInline, + isExternal, + isPrimary, + isExpect, + containerSource, + ).join(separator = ",\n").indent(), + +") : " + baseClasses("Constructor") + " " + blockSpaced( + initBlock, + commonFields, + returnTypeFieldField.toPersistentField(+"returnType", modifier = "private"), + lines( + +"override var returnType: IrType", + lines( + +"get() = returnTypeField.let " + block( + +"if (it !== " + import("IrUninitializedType", "org.jetbrains.kotlin.ir.types.impl") + ") it else throw " + import("ReturnTypeIsNotInitializedException", "org.jetbrains.kotlin.ir.types.impl") + "(this)" + ), + +"set(c) " + block( + +"returnTypeField = c" + ) + ).indent() + ), + typeParametersField.toPersistentField(+"emptyList()"), + dispatchReceiverParameterField.toPersistentField(+"null"), + extensionReceiverParameterField.toPersistentField(+"null"), + valueParametersField.toPersistentField(+"emptyList()"), + bodyField.toBody(), + metadataField.toPersistentField(+"null"), + visibilityField.toPersistentField(+"visibility"), + isExternalField.toPersistentField(+"isExternal"), + descriptor(ClassConstructorDescriptor) + ), + id, + )() + }) + + writeFile("carriers/ConstructorCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers( + "Constructor", + returnTypeFieldField, + dispatchReceiverParameterField, + extensionReceiverParameterField, + bodyField, + metadataField, + visibilityField, + typeParametersField, + valueParametersField, + isExternalField, + )() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/EnumEntry.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/EnumEntry.kt new file mode 100644 index 00000000000..1346b4e6c1a --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/EnumEntry.kt @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +internal fun PersistentIrGenerator.generateEnumEntry() { + val correspondingClassField = Field("correspondingClass", IrClass + "?") + val initializerExpressionField = Field("initializerExpression", IrExpressionBody + "?") + + writeFile("PersistentIrEnumEntry.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"internal class PersistentIrEnumEntry(", + arrayOf( + startOffset, + endOffset, + origin, + +"override val symbol: " + irSymbol("IrEnumEntrySymbol"), + name, + ).join(separator = ",\n").indent(), + +") : " + baseClasses("EnumEntry") + " " + blockSpaced( + initBlock, + commonFields, + descriptor(ClassDescriptor), + + correspondingClassField.toPersistentField(+"null"), + initializerExpressionField.toBody() + ), + id, + )() + }) + + writeFile("carriers/EnumEntryCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers( + "EnumEntry", + correspondingClassField, + initializerExpressionField, + )() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ErrorDeclaration.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ErrorDeclaration.kt new file mode 100644 index 00000000000..9f5bc61d59a --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ErrorDeclaration.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + + +internal fun PersistentIrGenerator.generateErrorDeclaration() { + writeFile("PersistentIrErrorDeclaration.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"@OptIn(" + ObsoleteDescriptorBasedAPI + "::class)", + +"internal class PersistentIrErrorDeclaration(", + arrayOf( + startOffset, + endOffset, + +"private val _descriptor: " + DeclarationDescriptor + "?" + ).join(separator = ",\n").indent(), + +") : " + baseClasses("ErrorDeclaration") + " " + block( + lines( + +"override val descriptor: " + DeclarationDescriptor, + +" get() = _descriptor ?: this." + import("toIrBasedDescriptor", "org.jetbrains.kotlin.ir.descriptors") + "()" + ), + id, + lastModified, + loweredUpTo, + values, + createdOn, + id, + parentField, + +"override var originField: " + IrDeclarationOrigin + " = IrDeclarationOrigin.DEFINED", + removedOn, + annotationsField, + ), + id, + )() + }) + + writeFile("carriers/ErrorDeclarationCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers( + "ErrorDeclaration", + )() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Field.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Field.kt new file mode 100644 index 00000000000..f440e7d0324 --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Field.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +internal fun PersistentIrGenerator.generateField() { + val initializerField = Field("initializer", IrExpressionBody + "?") + val correspondingPropertySymbolField = Field("correspondingPropertySymbol", IrPropertySymbol + "?") + val metadataField = Field("metadata", MetadataSource + "?") + val typeField = Field("type", IrType) + val isExternalField = Field("isExternal", +"Boolean", notEq = "!=") + + writeFile("PersistentIrField.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"internal class PersistentIrField(", + arrayOf( + startOffset, + endOffset, + origin, + +"override val symbol: " + irSymbol("IrFieldSymbol"), + name, + +"type: " + IrType, + +"override var " + visibility, + isFinal, + isExternal, + isStatic, + ).join(separator = ",\n").indent(), + +") : " + baseClasses("Field") + " " + blockSpaced( + initBlock, + commonFields, + descriptor(descriptorType("PropertyDescriptor")), + initializerField.toBody(), + correspondingPropertySymbolField.toPersistentField(+"null"), + metadataField.toPersistentField(+"null"), + typeField.toPersistentField(+"type"), + isExternalField.toPersistentField(+"isExternal"), + ), + id, + )() + }) + + writeFile("carriers/FieldCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers( + "Field", + typeField, + initializerField, + correspondingPropertySymbolField, + metadataField, + isExternalField, + )() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Function.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Function.kt new file mode 100644 index 00000000000..0d3d21c20db --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Function.kt @@ -0,0 +1,99 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +internal fun PersistentIrGenerator.generateFunction() { + + val returnTypeFieldField = Field("returnTypeField", IrType) + val typeParametersField = Field("typeParameters", +"List<" + IrTypeParameter + ">") + val dispatchReceiverParameterField = Field("dispatchReceiverParameter", IrValueParameter + "?") + val extensionReceiverParameterField = Field("extensionReceiverParameter", IrValueParameter + "?") + val valueParametersField = Field("valueParameters", +"List<" + IrValueParameter + ">") + val bodyField = Field("body", IrBody + "?") + val metadataField = Field("metadata", MetadataSource + "?") + val visibilityField = Field("visibility", DescriptorVisibility) + val overriddenSymbolsField = Field("overriddenSymbols", +"List<" + irSymbol("IrSimpleFunctionSymbol") + ">") + val attributeOwnerIdField = Field("attributeOwnerId", IrAttributeContainer) + val correspondingPropertySymbolField = Field("correspondingPropertySymbol", IrPropertySymbol + "?") + val isExternalField = Field("isExternal", +"Boolean", notEq = "!=") + + writeFile("PersistentIrFunctionCommon.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"internal abstract class PersistentIrFunctionCommon(", + arrayOf( + startOffset, + endOffset, + origin, + name, + visibility, + returnType, + isInline, + isExternal, + +"override val isTailrec: Boolean", + +"override val isSuspend: Boolean", + +"override val isOperator: Boolean", + +"override val isInfix: Boolean", + isExpect, + containerSource + " = null", + ).join(separator = ",\n").indent(), + +") : " + baseClasses("Function", baseClass = "IrSimpleFunction") + " " + blockSpaced( + commonFields, + returnTypeFieldField.toPersistentField(+"returnType", modifier = "private"), + lines( + +"final override var returnType: IrType", + lines( + +"get() = returnTypeField.let " + block( + +"if (it !== " + import( + "IrUninitializedType", + "org.jetbrains.kotlin.ir.types.impl" + ) + ") it else throw " + import( + "ReturnTypeIsNotInitializedException", + "org.jetbrains.kotlin.ir.types.impl" + ) + "(this)" + ), + +"set(c) " + block( + +"returnTypeField = c" + ) + ).indent() + ), + typeParametersField.toPersistentField(+"emptyList()"), + dispatchReceiverParameterField.toPersistentField(+"null"), + extensionReceiverParameterField.toPersistentField(+"null"), + valueParametersField.toPersistentField(+"emptyList()"), + bodyField.toBody(), + metadataField.toPersistentField(+"null"), + visibilityField.toPersistentField(+"visibility"), + overriddenSymbolsField.toPersistentField(+"emptyList()"), + lines( + +"@Suppress(\"LeakingThis\")", + attributeOwnerIdField.toPersistentField(+"this"), + ), + correspondingPropertySymbolField.toPersistentField(+"null"), + isExternalField.toPersistentField(+"isExternal") + ), + id, + )() + }) + + writeFile("carriers/FunctionCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers( + "Function", + returnTypeFieldField, + dispatchReceiverParameterField, + extensionReceiverParameterField, + bodyField, + metadataField, + visibilityField, + typeParametersField, + valueParametersField, + correspondingPropertySymbolField, + overriddenSymbolsField, + attributeOwnerIdField, + isExternalField, + )() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/LocalDelegatedProperty.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/LocalDelegatedProperty.kt new file mode 100644 index 00000000000..468cfbaa17a --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/LocalDelegatedProperty.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +internal fun PersistentIrGenerator.generateLocalDelegatedProperty() { + val typeField = Field("type", IrType) + val delegateField = Field("delegate", irDeclaration("IrVariable"), lateinit = true) + val getterField = Field("getter", irDeclaration("IrSimpleFunction"), lateinit = true) + val setterField = Field("setter", irDeclaration("IrSimpleFunction") + "?") + val metadataField = Field("metadata", MetadataSource + "?") + + writeFile("PersistentIrLocalDelegatedProperty.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"// TODO make not persistent", + +"internal class PersistentIrLocalDelegatedProperty(", + arrayOf( + startOffset, + endOffset, + origin, + +"override val symbol: " + irSymbol("IrLocalDelegatedPropertySymbol"), + name, + +"type: " + IrType, + +"override val isVar: Boolean", + ).join(separator = ",\n").indent(), + +") : " + baseClasses("LocalDelegatedProperty") + " " + blockSpaced( + initBlock, + commonFields, + descriptor(descriptorType("VariableDescriptorWithAccessors")), + typeField.toPersistentField(+"type"), + delegateField.toPersistentField(+"null"), + getterField.toPersistentField(+"null"), + setterField.toPersistentField(+"null"), + metadataField.toPersistentField(+"null"), + ), + id, + )() + }) + + writeFile("carriers/LocalDelegatedPropertyCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers( + "LocalDelegatedProperty", + typeField, + delegateField, + getterField, + setterField, + metadataField, + )() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt new file mode 100644 index 00000000000..5932c5b8e82 --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +fun main() { + PersistentIrGenerator.run { + generateAnonymousInitializer() + generateClass() + generateConstructor() + generateEnumEntry() + generateErrorDeclaration() + generateField() + generateFunction() + generateLocalDelegatedProperty() + generateProperty() + generateTypeAlias() + generateTypeParameter() + generateValueParameter() + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/PersistentIrGenerator.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/PersistentIrGenerator.kt new file mode 100644 index 00000000000..7b2dad9d8d1 --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/PersistentIrGenerator.kt @@ -0,0 +1,315 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +import java.io.File +import java.lang.StringBuilder +import java.time.Year + +internal interface R { + fun text(t: String): R + + fun indent(fn: R.() -> Unit): R + + fun import(fqn: String): R +} + +internal typealias E = R.() -> R + +internal class Field(val name: String, val type: E, val lateinit: Boolean = false, val notEq: String = "!==") + +internal object PersistentIrGenerator { + + // Imports + + val ClassDescriptor: E = descriptorType("ClassDescriptor") + val DeclarationDescriptor: E = descriptorType("DeclarationDescriptor") + val ClassConstructorDescriptor: E = descriptorType("ClassConstructorDescriptor") + val DescriptorVisibility = descriptorType("DescriptorVisibility") + + val IrDeclaration = irDeclaration("IrDeclaration") + val IrDeclarationOrigin = irDeclaration("IrDeclarationOrigin") + val IrDeclarationParent = irDeclaration("IrDeclarationParent") + val IrAnonymousInitializer = irDeclaration("IrAnonymousInitializer") + val IrClass = irDeclaration("IrClass") + val IrTypeParameter = irDeclaration("IrTypeParameter") + val IrValueParameter = irDeclaration("IrValueParameter") + val MetadataSource = irDeclaration("MetadataSource") + val IrAttributeContainer = irDeclaration("IrAttributeContainer") + + val IrConstructorCall = irExpression("IrConstructorCall") + val IrBody = irExpression("IrBody") + val IrBlockBody = irExpression("IrBlockBody") + val IrExpressionBody = irExpression("IrExpressionBody") + + val IrAnonymousInitializerSymbol = irSymbol("IrAnonymousInitializerSymbol") + val IrClassSymbol = irSymbol("IrClassSymbol") + + val AnonymousInitializerCarrier = irCarrier("AnonymousInitializerCarrier") + val Carrier = irCarrier("Carrier") + + val ObsoleteDescriptorBasedAPI = import("ObsoleteDescriptorBasedAPI", "org.jetbrains.kotlin.ir") + + val stageController = import("stageController", "org.jetbrains.kotlin.ir.declarations") + + val IrType = import("IrType", "org.jetbrains.kotlin.ir.types") + + val IrPropertySymbol = irSymbol("IrPropertySymbol") + + // Constructor parameters + + val startOffset = +"override val startOffset: Int" + val endOffset = +"override val endOffset: Int" + val origin = +"origin: " + IrDeclarationOrigin + val isStatic = +"override val isStatic: Boolean" + val name = +"override val name: " + import("Name", "org.jetbrains.kotlin.name") + val kind = +"override val kind: " + descriptorType("ClassKind") + val visibility = +"visibility: " + DescriptorVisibility + val modality = +"modality: " + descriptorType("Modality") + val isCompanion = +"override val isCompanion: Boolean = false" + val isInner = +"override val isInner: Boolean = false" + val isData = +"override val isData: Boolean = false" + val isExternal = +"isExternal: Boolean" + val isFinal = +"override val isFinal: Boolean" + val isInline = +"override val isInline: Boolean" + val isExpect = +"override val isExpect: Boolean" + val isFun = +"override val isFun: Boolean = false" + val source = +"override val source: " + descriptorType("SourceElement") + " = SourceElement.NO_SOURCE" + val returnType = +"returnType: " + IrType + val isPrimary = +"override val isPrimary: Boolean" + val containerSource = +"override val containerSource: " + import("DeserializedContainerSource", "org.jetbrains.kotlin.serialization.deserialization.descriptors") + "?" + + val initBlock = +"init " + block( + +"symbol.bind(this)" + ) + + // Fields + val lastModified = +"override var lastModified: Int = " + stageController + ".currentStage" + val loweredUpTo = +"override var loweredUpTo: Int = " + stageController + ".currentStage" + val values = +"override var values: Array<" + Carrier + ">? = null" + val createdOn = +"override val createdOn: Int = " + stageController + ".currentStage" + + val parentField = +"override var parentField: " + IrDeclarationParent + "? = null" + val originField = +"override var originField: " + IrDeclarationOrigin + " = origin" + val removedOn = +"override var removedOn: Int = Int.MAX_VALUE" + val annotationsField = +"override var annotationsField: List<" + IrConstructorCall + "> = emptyList()" + + val commonFields = lines( + lastModified, + loweredUpTo, + values, + createdOn, + id, + parentField, + originField, + removedOn, + annotationsField, + ) + + fun Field.toPersistentField(initializer: E, modifier: String = "override") = + persistentField(name, type, initializer, lateinit, modifier, notEq = notEq) + + fun Field.toBody() = body(type, lateinit, name) + + // Helpers + + fun baseClasses(name: String, baseClass: String = "Ir$name"): E = lines( + irDeclaration(baseClass) + "(),", + +" PersistentIrDeclarationBase<" + irCarrier("${name}Carrier") + ">,", + +" ${name}Carrier", + ) + + fun persistentField( + name: String, + type: E, + initializer: E, + lateinit: Boolean = false, + modifier: String = "override", + isBody: Boolean = false, + notEq: String = "!==", + ): E = lines( + +"override var ${name}Field: " + type + "${if (lateinit) "?" else ""} = " + initializer, + id, + +"$modifier var $name: " + type, + lines( + +"get() = getCarrier().${name}Field${if (lateinit) "!!" else ""}", + +"set(v) " + block( + +"if (${if (lateinit) "getCarrier().${name}Field" else name} $notEq v) " + block( + (if (isBody) lines( + +"if (v is PersistentIrBodyBase<*>) " + block( + +"v.container = this" + ), + id + ) else id) + "setCarrier().${name}Field = v" + ) + ) + ).indent() + ) + + fun body(bodyType: E, lateinit: Boolean = false, fieldName: String = "body"): E = + persistentField(fieldName, bodyType, initializer = +"null", lateinit, isBody = true) + + fun descriptor(type: E) = lines( + +"@" + ObsoleteDescriptorBasedAPI, + +"override val descriptor: " + type, + +" get() = symbol.descriptor" + ) + + fun carriers(name: String, vararg fields: Field): E = lines( + id, + +"internal interface ${name}Carrier : DeclarationCarrier" + block( + *(fields.map { +"var ${it.name}Field: " + it.type + if (it.lateinit) "?" else "" }.toTypedArray()), + id, + +"override fun clone(): ${name}Carrier " + block( + +"return ${name}CarrierImpl(", + arrayOf( + +"lastModified", + +"parentField", + +"originField", + +"annotationsField", + *(fields.map { +"${it.name}Field" }.toTypedArray()) + ).join(separator = ",\n").indent(), + +")", + ) + ), + id, + +"internal class ${name}CarrierImpl(", + arrayOf( + +"override val lastModified: Int", + +"override var parentField: " + IrDeclarationParent + "?", + +"override var originField: " + IrDeclarationOrigin, + +"override var annotationsField: List<" + IrConstructorCall + ">", + *(fields.map { +"override var ${it.name}Field: " + it.type + if (it.lateinit) "?" else "" }.toTypedArray()), + ).join(separator = ",\n").indent(), + +") : ${name}Carrier", + id, + ) + + fun lines(vararg fn: E): E = fn.join(separator = "\n") + + fun block(vararg fn: E): E = lines(+"{", { indent { lines(*fn)() } }, +"}") + + fun blockSpaced(vararg fn: E): E { + return block(*(fn.flatMap { listOf(id, it) }.toTypedArray())) + } + + fun import(name: String, pkg: String): E = { import("$pkg.$name").text(name) } + + fun descriptorType(name: String): E = import(name, "org.jetbrains.kotlin.descriptors") + + fun irDeclaration(name: String): E = import(name, "org.jetbrains.kotlin.ir.declarations") + + fun irExpression(name: String): E = import(name, "org.jetbrains.kotlin.ir.expressions") + + fun irCarrier(name: String): E = import(name, "org.jetbrains.kotlin.ir.declarations.persistent.carriers") + + fun irSymbol(name: String): E = import(name, "org.jetbrains.kotlin.ir.symbols") + + infix operator fun E.plus(e: E?): E = { this@plus(); e.safe()() } + + infix operator fun E.plus(e: String): E = this + (+e) + + operator fun String.unaryPlus(): E = { text(this@unaryPlus) } + + val id: E get() = { this } + + fun E?.safe(): E = this ?: id + + fun Array.join(prefix: String = "", separator: String = "", suffix: String = ""): E = + join(+prefix, +separator, +suffix) + + fun Array.join(prefix: E = id, separator: E = id, suffix: E = id): E { + if (this.isEmpty()) return id + return prefix + interleaveWith(separator) + suffix + } + + fun Array.interleaveWith(b: E): E { + return { + this@interleaveWith.forEachIndexed { i, e -> + if (i != 0) b() + e() + } + this + } + } + + fun Boolean.ifTrue(s: String): E = if (this) +s else id + + fun type(name: E, vararg parameters: E, isNullable: Boolean = false): E = + name + parameters.join("<", ", ", ">") + isNullable.ifTrue("?") + + fun E.indent(): E = { + val self = this@indent + indent { + self() + } + } + + fun renderFile(pkg: String, fn: R.() -> R): String { + val sb = StringBuilder() + val imports: MutableSet = mutableSetOf() + + val renderer = object : R { + var currentIndent = "" + + var atLineStart = true + + override fun text(t: String): R { + if (t.isEmpty()) return this + + if (atLineStart) { + sb.append(currentIndent) + atLineStart = false + } + + val cr = t.indexOf('\n') + if (cr >= 0) { + sb.append(t.substring(0, cr + 1)) + atLineStart = true + text(t.substring(cr + 1)) + } else { + sb.append(t) + } + + return this + } + + override fun indent(fn: R.() -> Unit): R { + val oldIndent = currentIndent + currentIndent = "$oldIndent " + fn() + currentIndent = oldIndent + + return this + } + + override fun import(fqn: String): R { + imports += fqn + + return this + } + } + + renderer.fn() + + var result = File("license/COPYRIGHT_HEADER.txt").readText() + "\n\n" + "package $pkg\n\n" + + result += imports.map { "import $it" }.sorted().joinToString(separator = "\n") + result += "\n\n" + result += "// Auto-generated by compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Main.kt. DO NOT EDIT!\n" + result += sb.toString() + + result = result.lines().map { if (it.isBlank()) "" else it }.joinToString(separator = "\n") + + return result + } + + private val prefix = "compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/" + + fun writeFile(path: String, content: String) { + File(prefix + path).writeText(content) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Property.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Property.kt new file mode 100644 index 00000000000..462726a92ed --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Property.kt @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +internal fun PersistentIrGenerator.generateProperty() { + val backingFieldField = Field("backingField", irDeclaration("IrField") + "?") + val getterField = Field("getter", irDeclaration("IrSimpleFunction") + "?") + val setterField = Field("setter", irDeclaration("IrSimpleFunction") + "?") + val metadataField = Field("metadata", MetadataSource + "?") + val attributeOwnerIdField = Field("attributeOwnerId", IrAttributeContainer) + val isExternalField = Field("isExternal", +"Boolean", notEq = "!=") + + writeFile("PersistentIrPropertyCommon.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"internal abstract class PersistentIrPropertyCommon(", + arrayOf( + startOffset, + endOffset, + origin, + name, + +"override var " + visibility, // TODO non-persisted state + +"override val isVar: Boolean", + +"override val isConst: Boolean", + +"override val isLateinit: Boolean", + +"override val isDelegated: Boolean", + isExternal, + isExpect, + containerSource + ).join(separator = ",\n").indent(), + +") : " + baseClasses("Property") + " " + blockSpaced( + commonFields, + backingFieldField.toPersistentField(+"null"), + getterField.toPersistentField(+"null"), + setterField.toPersistentField(+"null"), + metadataField.toPersistentField(+"null"), + lines( + +"@Suppress(\"LeakingThis\")", + attributeOwnerIdField.toPersistentField(+"this"), + ), + isExternalField.toPersistentField(+"isExternal"), + ), + id, + )() + }) + + writeFile("carriers/PropertyCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers( + "Property", + backingFieldField, + getterField, + setterField, + metadataField, + attributeOwnerIdField, + isExternalField, + )() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeAlias.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeAlias.kt new file mode 100644 index 00000000000..6bfa5dcabd9 --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeAlias.kt @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +internal fun PersistentIrGenerator.generateTypeAlias() { + val typeParametersField = Field("typeParameters", +"List<" + IrTypeParameter + ">") + val expandedTypeField = Field("expandedType", IrType) + + writeFile("PersistentIrTypeAlias.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"internal class PersistentIrTypeAlias(", + arrayOf( + startOffset, + endOffset, + +"override val symbol: " + irSymbol("IrTypeAliasSymbol"), + name, + +"override var " + visibility, + +"expandedType: " + IrType, + +"override val isActual: Boolean", + origin, + ).join(separator = ",\n").indent(), + +") : " + baseClasses("TypeAlias") + " " + blockSpaced( + initBlock, + commonFields, + descriptor(descriptorType("TypeAliasDescriptor")), + + typeParametersField.toPersistentField(+"emptyList()"), + expandedTypeField.toPersistentField(+"expandedType"), + ), + id, + )() + }) + + writeFile("carriers/TypeAliasCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers( + "TypeAlias", + typeParametersField, + expandedTypeField, + )() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeParameter.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeParameter.kt new file mode 100644 index 00000000000..dd03e385006 --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeParameter.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +internal fun PersistentIrGenerator.generateTypeParameter() { + val superTypesField = Field("superTypes", +"List<" + IrType + ">") + + writeFile("PersistentIrTypeParameter.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"internal class PersistentIrTypeParameter(", + arrayOf( + startOffset, + endOffset, + origin, + +"override val symbol: " + irSymbol("IrTypeParameterSymbol"), + name, + +"override val index: Int", + +"override val isReified: Boolean", + +"override val variance: " + import("Variance", "org.jetbrains.kotlin.types") + ).join(separator = ",\n").indent(), + +") : " + baseClasses("TypeParameter") + " " + blockSpaced( + initBlock, + commonFields, + descriptor(descriptorType("TypeParameterDescriptor")), + superTypesField.toPersistentField(+"emptyList()"), + ), + id, + )() + }) + + writeFile("carriers/TypeParameterCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers( + "TypeParameter", + superTypesField, + )() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ValueParameter.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ValueParameter.kt new file mode 100644 index 00000000000..703a4c8b11d --- /dev/null +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ValueParameter.kt @@ -0,0 +1,51 @@ +/* + * Copyright 2010-2020 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.ir.persistentIrGenerator + +internal fun PersistentIrGenerator.generateValueParameter() { + + val defaultValueField = Field("defaultValue", IrExpressionBody + "?") + val typeField = Field("type", IrType) + val varargElementTypeField = Field("varargElementType", IrType + "?") + + writeFile("PersistentIrValueParameter.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") { + lines( + id, + +"internal class PersistentIrValueParameter(", + arrayOf( + startOffset, + endOffset, + origin, + +"override val symbol: " + irSymbol("IrValueParameterSymbol"), + name, + +"override val index: Int", + +"type: " + IrType, + +"varargElementType: " + IrType + "?", + +"override val isCrossinline: Boolean", + +"override val isNoinline: Boolean", + +"override val isHidden: Boolean", + +"override val isAssignable: Boolean" + ).join(separator = ",\n").indent(), + +") : " + baseClasses("ValueParameter") + " " + blockSpaced( + descriptor(descriptorType("ParameterDescriptor")), + initBlock, + commonFields, + defaultValueField.toBody(), + typeField.toPersistentField(+"type"), + varargElementTypeField.toPersistentField(+"varargElementType"), + ), + id, + )() + }) + writeFile("carriers/ValueParameterCarrier.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent.carriers") { + carriers( + "ValueParameter", + defaultValueField, + typeField, + varargElementTypeField, + )() + }) +} \ No newline at end of file diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FunctionBaseCarrier.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FunctionBaseCarrier.kt deleted file mode 100644 index b2f27879fa2..00000000000 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/carriers/FunctionBaseCarrier.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. 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.ir.declarations.persistent.carriers - -import org.jetbrains.kotlin.descriptors.DescriptorVisibility -import org.jetbrains.kotlin.ir.declarations.IrTypeParameter -import org.jetbrains.kotlin.ir.declarations.IrValueParameter -import org.jetbrains.kotlin.ir.declarations.MetadataSource -import org.jetbrains.kotlin.ir.expressions.IrBody -import org.jetbrains.kotlin.ir.types.IrType - -internal interface FunctionBaseCarrier : DeclarationCarrier { - var returnTypeFieldField: IrType - var dispatchReceiverParameterField: IrValueParameter? - var extensionReceiverParameterField: IrValueParameter? - var bodyField: IrBody? - var metadataField: MetadataSource? - var visibilityField: DescriptorVisibility - var typeParametersField: List - var valueParametersField: List - var isExternalField: Boolean -} diff --git a/settings.gradle b/settings.gradle index 9ae697f5a7e..0d56a3fe779 100644 --- a/settings.gradle +++ b/settings.gradle @@ -95,6 +95,7 @@ include ":benchmarks", ":compiler:ir.tree", ":compiler:ir.tree.impl", ":compiler:ir.tree.persistent", + ":compiler:ir.tree.persistent:generator", ":compiler:ir.psi2ir", ":compiler:ir.ir2cfg", ":compiler:ir.backend.common", @@ -474,6 +475,7 @@ project(':kotlin-ant').projectDir = "$rootDir/ant" as File project(':compiler:ir.tree').projectDir = "$rootDir/compiler/ir/ir.tree" as File project(':compiler:ir.tree.impl').projectDir = "$rootDir/compiler/ir/ir.tree.impl" as File project(':compiler:ir.tree.persistent').projectDir = "$rootDir/compiler/ir/ir.tree.persistent" as File +project(':compiler:ir.tree.persistent:generator').projectDir = "$rootDir/compiler/ir/ir.tree.persistent/generator" as File project(':compiler:ir.psi2ir').projectDir = "$rootDir/compiler/ir/ir.psi2ir" as File project(':compiler:ir.ir2cfg').projectDir = "$rootDir/compiler/ir/ir.ir2cfg" as File project(':compiler:ir.backend.common').projectDir = "$rootDir/compiler/ir/backend.common" as File From c06b345f3c281d97f093a9d07f789a7041d6bae5 Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Thu, 5 Nov 2020 14:42:48 +0300 Subject: [PATCH 203/368] Hide `stageController` into the IrFactory --- .../cli/cli-js-klib/src/GenerateJsIrKlib.kt | 2 +- .../jetbrains/kotlin/cli/js/K2JsIrCompiler.kt | 2 +- .../jetbrains/kotlin/backend/common/Lower.kt | 8 ++-- .../kotlin/backend/common/ir/IrUtils.kt | 2 +- .../common/lower/InnerClassesLowering.kt | 2 +- .../org/jetbrains/kotlin/ir/backend/js/Dce.kt | 6 +-- .../kotlin/ir/backend/js/JsIntrinsics.kt | 16 +++---- .../ir/backend/js/JsIrBackendContext.kt | 8 ++-- .../kotlin/ir/backend/js/JsMapping.kt | 6 +-- .../kotlin/ir/backend/js/compiler.kt | 12 +++--- .../js/lower/BlockDecomposerLowering.kt | 2 +- .../ir/backend/js/lower/EnumClassLowering.kt | 4 +- .../js/lower/ExternalEnumUsagesLowering.kt | 2 +- .../lower/JsSingleAbstractMethodLowering.kt | 2 +- .../js/lower/PrimaryConstructorLowering.kt | 4 +- .../js/lower/PropertyLazyInitLowering.kt | 2 +- .../kotlin/backend/wasm/WasmBackendContext.kt | 4 +- .../ir/declarations/impl/IrFactoryImpl.kt | 2 + .../PersistentIrAnonymousInitializer.kt | 10 ++--- .../persistent/PersistentIrClass.kt | 14 +++--- .../persistent/PersistentIrConstructor.kt | 10 ++--- .../persistent/PersistentIrEnumEntry.kt | 10 ++--- .../PersistentIrErrorDeclaration.kt | 10 ++--- .../persistent/PersistentIrField.kt | 10 ++--- .../persistent/PersistentIrFunctionCommon.kt | 10 ++--- .../PersistentIrLocalDelegatedProperty.kt | 10 ++--- .../persistent/PersistentIrPropertyCommon.kt | 10 ++--- .../persistent/PersistentIrTypeAlias.kt | 10 ++--- .../persistent/PersistentIrTypeParameter.kt | 10 ++--- .../persistent/PersistentIrValueParameter.kt | 10 ++--- .../AnonymousInitializer.kt | 1 + .../kotlin/ir/persistentIrGenerator/Class.kt | 5 ++- .../ir/persistentIrGenerator/Constructor.kt | 1 + .../ir/persistentIrGenerator/EnumEntry.kt | 1 + .../persistentIrGenerator/ErrorDeclaration.kt | 3 +- .../kotlin/ir/persistentIrGenerator/Field.kt | 1 + .../ir/persistentIrGenerator/Function.kt | 1 + .../LocalDelegatedProperty.kt | 1 + .../PersistentIrGenerator.kt | 10 ++--- .../ir/persistentIrGenerator/Property.kt | 3 +- .../ir/persistentIrGenerator/TypeAlias.kt | 1 + .../ir/persistentIrGenerator/TypeParameter.kt | 3 +- .../persistentIrGenerator/ValueParameter.kt | 3 +- .../persistent/PersistentIrDeclarationBase.kt | 26 +++++------ .../persistent/PersistentIrFactory.kt | 43 +++++++++++-------- .../persistent/PersistentIrFunction.kt | 8 ++-- .../persistent/PersistentIrProperty.kt | 6 ++- .../persistent/PersistentIrBlockBody.kt | 14 +++--- .../persistent/PersistentIrExpressionBody.kt | 22 ++++------ .../kotlin/ir/declarations/IrFactory.kt | 2 + .../kotlin/ir/declarations/PersistentApi.kt | 12 +----- .../ir/declarations/impl/IrScriptImpl.kt | 6 +-- .../ir/declarations/lazy/IrLazyTypeAlias.kt | 6 +-- .../declarations/lazy/IrLazyTypeParameter.kt | 8 ++-- .../kotlin/ir/declarations/lazy/lazyUtil.kt | 3 +- .../ir/util/DeepCopyIrTreeWithSymbols.kt | 3 +- .../jetbrains/kotlin/ir/util/SymbolTable.kt | 2 +- .../kotlin/benchmarks/GenerateIrRuntime.kt | 8 ++-- .../kotlin/js/test/BasicIrBoxTest.kt | 4 +- 59 files changed, 209 insertions(+), 208 deletions(-) diff --git a/compiler/cli/cli-js-klib/src/GenerateJsIrKlib.kt b/compiler/cli/cli-js-klib/src/GenerateJsIrKlib.kt index 44586cd43cc..6eedb3d3519 100644 --- a/compiler/cli/cli-js-klib/src/GenerateJsIrKlib.kt +++ b/compiler/cli/cli-js-klib/src/GenerateJsIrKlib.kt @@ -88,7 +88,7 @@ fun buildKLib( configuration = configuration, allDependencies = allDependencies, friendDependencies = emptyList(), - irFactory = PersistentIrFactory, + irFactory = PersistentIrFactory(), // TODO: IrFactoryImpl? outputKlibPath = outputPath, nopack = true ) diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt index a359dc22cf1..9d08c4548bd 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt @@ -199,7 +199,7 @@ class K2JsIrCompiler : CLICompiler() { configuration = config.configuration, allDependencies = resolvedLibraries, friendDependencies = friendDependencies, - irFactory = PersistentIrFactory, + irFactory = PersistentIrFactory(), // TODO IrFactoryImpl? outputKlibPath = outputFile.path, nopack = arguments.irProduceKlibDir ) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Lower.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Lower.kt index 34932c56eab..c10fc4cfa06 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Lower.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Lower.kt @@ -19,8 +19,10 @@ package org.jetbrains.kotlin.backend.common import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.expressions.IrStatementContainer +import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.util.transformFlat import org.jetbrains.kotlin.ir.util.transformSubsetFlat import org.jetbrains.kotlin.ir.visitors.IrElementVisitor @@ -151,8 +153,8 @@ private class BodyLoweringVisitor( if (allowDeclarationModification) { loweringPass.lower(body, data!!) } else { - stageController.bodyLowering { - loweringPass.lower(body, data!!) + data!!.factory.stageController.bodyLowering { + loweringPass.lower(body, data) } } } @@ -178,7 +180,7 @@ interface DeclarationTransformer : FileLoweringPass { } private fun transformFlatRestricted(declaration: IrDeclaration): List? { - return stageController.restrictTo(declaration) { + return declaration.factory.stageController.restrictTo(declaration) { transformFlat(declaration) } } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt index ccc4a17a685..b45bab06a28 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt @@ -355,7 +355,7 @@ fun IrType.remapTypeParameters( /* Copied from K/N */ fun IrDeclarationContainer.addChild(declaration: IrDeclaration) { - stageController.unrestrictDeclarationListsAccess { + declaration.factory.stageController.unrestrictDeclarationListsAccess { this.declarations += declaration } declaration.setDeclarationsParent(this) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt index 8b19b60b57f..255d82e1f82 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt @@ -35,7 +35,7 @@ class InnerClassesLowering(val context: BackendContext, private val innerClasses override fun transformFlat(declaration: IrDeclaration): List? { if (declaration is IrClass && declaration.isInner) { - stageController.unrestrictDeclarationListsAccess { + context.irFactory.stageController.unrestrictDeclarationListsAccess { declaration.declarations += innerClassesSupport.getOuterThisField(declaration) } } else if (declaration is IrConstructor) { diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt index a07ba642801..282cc71884e 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt @@ -29,11 +29,11 @@ fun eliminateDeadDeclarations( context: JsIrBackendContext ) { - val allRoots = stageController.withInitialIr { buildRoots(modules, context) } + val allRoots = context.irFactory.stageController.withInitialIr { buildRoots(modules, context) } val usefulDeclarations = usefulDeclarations(allRoots, context) - stageController.unrestrictDeclarationListsAccess { + context.irFactory.stageController.unrestrictDeclarationListsAccess { removeUselessDeclarations(modules, usefulDeclarations) } } @@ -169,7 +169,7 @@ fun usefulDeclarations(roots: Iterable, context: JsIrBackendConte } // use withInitialIr to avoid ConcurrentModificationException in dce-driven lowering when adding roots' nested declarations (members) - stageController.withInitialIr { + context.irFactory.stageController.withInitialIr { // Add roots roots.forEach { it.enqueue(null, null, altFromFqn = "") diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt index 1bac938a8c6..6ba799b9622 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt @@ -204,12 +204,12 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC val anyConstructorSymbol = anyClassSymbol.constructors.single() val jsObjectClassSymbol = getInternalClassWithoutPackage("kotlin.js.JsObject") - val jsObjectConstructorSymbol by lazy2 { jsObjectClassSymbol.constructors.single() } + val jsObjectConstructorSymbol by context.lazy2 { jsObjectClassSymbol.constructors.single() } - val uByteClassSymbol by lazy2 { getInternalClassWithoutPackage("kotlin.UByte") } - val uShortClassSymbol by lazy2 { getInternalClassWithoutPackage("kotlin.UShort") } - val uIntClassSymbol by lazy2 { getInternalClassWithoutPackage("kotlin.UInt") } - val uLongClassSymbol by lazy2 { getInternalClassWithoutPackage("kotlin.ULong") } + val uByteClassSymbol by context.lazy2 { getInternalClassWithoutPackage("kotlin.UByte") } + val uShortClassSymbol by context.lazy2 { getInternalClassWithoutPackage("kotlin.UShort") } + val uIntClassSymbol by context.lazy2 { getInternalClassWithoutPackage("kotlin.UInt") } + val uLongClassSymbol by context.lazy2 { getInternalClassWithoutPackage("kotlin.ULong") } val unreachable = defineUnreachableIntrinsic() @@ -285,16 +285,16 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC // TODO move CharSequence-related stiff to IntrinsifyCallsLowering val charSequenceClassSymbol = context.symbolTable.referenceClass(context.getClass(FqName("kotlin.CharSequence"))) - val charSequenceLengthPropertyGetterSymbol by lazy2 { + val charSequenceLengthPropertyGetterSymbol by context.lazy2 { with(charSequenceClassSymbol.owner.declarations) { filterIsInstance().firstOrNull { it.name.asString() == "length" }?.getter ?: filterIsInstance().first { it.name.asString() == "" } }.symbol } - val charSequenceGetFunctionSymbol by lazy2 { + val charSequenceGetFunctionSymbol by context.lazy2 { charSequenceClassSymbol.owner.declarations.filterIsInstance().single { it.name.asString() == "get" }.symbol } - val charSequenceSubSequenceFunctionSymbol by lazy2 { + val charSequenceSubSequenceFunctionSymbol by context.lazy2 { charSequenceClassSymbol.owner.declarations.filterIsInstance().single { it.name.asString() == "subSequence" }.symbol } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt index 07a6285df25..799cfe84db2 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt @@ -115,7 +115,7 @@ class JsIrBackendContext( val testRoots: Map get() = testContainerFuns - override val mapping = JsMapping() + override val mapping = JsMapping(irFactory) override val inlineClassesUtils = JsInlineClassesUtils(this) @@ -362,7 +362,7 @@ class JsIrBackendContext( /*TODO*/ print(message) } -} -// TODO: investigate if it could be removed -fun lazy2(fn: () -> T) = lazy { stageController.withInitialIr(fn) } \ No newline at end of file + // TODO: investigate if it could be removed + fun lazy2(fn: () -> T) = lazy { irFactory.stageController.withInitialIr(fn) } +} \ No newline at end of file diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsMapping.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsMapping.kt index 344820b5b88..1879b045266 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsMapping.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsMapping.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.backend.common.DefaultMapping import org.jetbrains.kotlin.backend.common.Mapping import org.jetbrains.kotlin.ir.declarations.* -class JsMapping : DefaultMapping() { +class JsMapping(private val irFactory: IrFactory) : DefaultMapping() { val outerThisFieldSymbols = newMapping() val innerClassConstructors = newMapping() val originalInnerClassPrimaryConstructorByClass = newMapping() @@ -35,12 +35,12 @@ class JsMapping : DefaultMapping() { private val map: MutableMap = mutableMapOf() override operator fun get(key: K): V? { - stageController.lazyLower(key) + irFactory.stageController.lazyLower(key) return map[key] } override operator fun set(key: K, value: V?) { - stageController.lazyLower(key) + irFactory.stageController.lazyLower(key) if (value == null) { map.remove(key) } else { diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt index ccc1d64bf62..8801d53a744 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt @@ -18,7 +18,6 @@ import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.declarations.StageController import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator import org.jetbrains.kotlin.ir.util.noUnboundLeft import org.jetbrains.kotlin.library.KotlinLibrary @@ -51,9 +50,7 @@ fun compile( relativeRequirePath: Boolean = false, propertyLazyInitialization: Boolean, ): CompilerResult { - stageController = StageController() - - val irFactory = if (dceDriven) PersistentIrFactory else IrFactoryImpl + val irFactory = if (dceDriven) PersistentIrFactory() else IrFactoryImpl val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer) = loadIr(project, mainModule, analyzer, configuration, allDependencies, friendDependencies, irFactory) @@ -93,14 +90,15 @@ fun compile( if (dceDriven) { val controller = MutableController(context, pirLowerings) - stageController = controller + + check(irFactory is PersistentIrFactory) + irFactory.stageController = controller controller.currentStage = controller.lowerings.size + 1 eliminateDeadDeclarations(allModules, context) - // TODO investigate whether this is needed anymore - stageController = StageController(controller.currentStage) + irFactory.stageController = StageController(controller.currentStage) val transformer = IrModuleToJsTransformer( context, diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt index fb41a8dc6c1..7f790cee076 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt @@ -72,7 +72,7 @@ abstract class AbstractBlockDecomposerLowering( val lastStatement = newBody.statements.last() val actualParent = if (newBody.statements.size > 1 || lastStatement !is IrReturn || lastStatement.value != expression) { expression = JsIrBuilder.buildCall(initFunction.symbol, expression.type) - stageController.unrestrictDeclarationListsAccess { + context.irFactory.stageController.unrestrictDeclarationListsAccess { (container.parent as IrDeclarationContainer).declarations += initFunction } initFunction diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt index 18fb7306805..059ad88674d 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/EnumClassLowering.kt @@ -353,7 +353,7 @@ class EnumClassCreateInitializerLowering(val context: JsCommonBackendContext) : // TODO Why not move to upper level? // TODO Also doesn't fit the transformFlat-ish API - stageController.unrestrictDeclarationListsAccess { + context.irFactory.stageController.unrestrictDeclarationListsAccess { declaration.declarations += entryInstancesInitializedVar declaration.declarations += initEntryInstancesFun } @@ -414,7 +414,7 @@ class EnumEntryCreateGetInstancesFunsLowering(val context: JsCommonBackendContex // TODO prettify entryGetInstanceFun.parent = irClass.parent - stageController.unrestrictDeclarationListsAccess { + context.irFactory.stageController.unrestrictDeclarationListsAccess { (irClass.parent as IrDeclarationContainer).declarations += entryGetInstanceFun } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExternalEnumUsagesLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExternalEnumUsagesLowering.kt index 3c0cf4559c9..b9970eb41e4 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExternalEnumUsagesLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExternalEnumUsagesLowering.kt @@ -53,7 +53,7 @@ class ExternalEnumUsagesLowering(val context: JsIrBackendContext) : BodyLowering it.parent = irClass // TODO need a way to emerge local declarations from BodyLoweringPass - stageController.unrestrictDeclarationListsAccess { + context.irFactory.stageController.unrestrictDeclarationListsAccess { irClass.declarations += it } } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsSingleAbstractMethodLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsSingleAbstractMethodLowering.kt index 5ebede73f40..a55fecdfb78 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsSingleAbstractMethodLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsSingleAbstractMethodLowering.kt @@ -45,7 +45,7 @@ class JsSingleAbstractMethodLowering(context: JsIrBackendContext) : SingleAbstra for (wrapper in cachedImplementations.values + inlineCachedImplementations.values) { val parentClass = wrapper.parent as IrDeclarationContainer - stageController.unrestrictDeclarationListsAccess { + context.irFactory.stageController.unrestrictDeclarationListsAccess { parentClass.declarations += wrapper } } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrimaryConstructorLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrimaryConstructorLowering.kt index 4319416ea54..37f24e09f39 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrimaryConstructorLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrimaryConstructorLowering.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid // Create primary constructor if it doesn't exist -class PrimaryConstructorLowering(context: JsCommonBackendContext) : DeclarationTransformer { +class PrimaryConstructorLowering(val context: JsCommonBackendContext) : DeclarationTransformer { private var IrClass.syntheticPrimaryConstructor by context.mapping.classToSyntheticPrimaryConstructor @@ -44,7 +44,7 @@ class PrimaryConstructorLowering(context: JsCommonBackendContext) : DeclarationT private fun createPrimaryConstructor(irClass: IrClass): IrConstructor { // TODO better API for declaration creation. This case doesn't fit the usual transformFlat-like API. - val declaration = stageController.unrestrictDeclarationListsAccess { + val declaration = context.irFactory.stageController.unrestrictDeclarationListsAccess { irClass.addConstructor { origin = SYNTHETIC_PRIMARY_CONSTRUCTOR isPrimary = true diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PropertyLazyInitLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PropertyLazyInitLowering.kt index 9bf85282574..2985400d775 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PropertyLazyInitLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PropertyLazyInitLowering.kt @@ -296,7 +296,7 @@ private val IrDeclaration.correspondingProperty: IrProperty? } private fun IrDeclaration.propertyWithPersistentSafe(transform: IrDeclaration.() -> IrProperty?): IrProperty? = - if (((this as? PersistentIrElementBase<*>)?.createdOn ?: 0) <= stageController.currentStage) { + if (this !is PersistentIrElementBase<*> || this.createdOn <= this.factory.stageController.currentStage) { transform() } else null diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt index 5a346fc52c9..a73569d759b 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt @@ -37,7 +37,7 @@ class WasmBackendContext( @Suppress("UNUSED_PARAMETER") symbolTable: SymbolTable, @Suppress("UNUSED_PARAMETER") irModuleFragment: IrModuleFragment, val additionalExportedDeclarations: Set, - override val configuration: CompilerConfiguration + override val configuration: CompilerConfiguration, ) : JsCommonBackendContext { override val builtIns = module.builtIns override var inVerbosePhase: Boolean = false @@ -55,7 +55,7 @@ class WasmBackendContext( ) } - override val mapping = JsMapping() + override val mapping = JsMapping(irFactory) val innerClassesSupport = JsInnerClassesSupport(mapping, irFactory) diff --git a/compiler/ir/ir.tree.impl/src/org/jetbrains/kotlin/ir/declarations/impl/IrFactoryImpl.kt b/compiler/ir/ir.tree.impl/src/org/jetbrains/kotlin/ir/declarations/impl/IrFactoryImpl.kt index f1939e4a0ae..68a6a1917ea 100644 --- a/compiler/ir/ir.tree.impl/src/org/jetbrains/kotlin/ir/declarations/impl/IrFactoryImpl.kt +++ b/compiler/ir/ir.tree.impl/src/org/jetbrains/kotlin/ir/declarations/impl/IrFactoryImpl.kt @@ -20,6 +20,8 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ import org.jetbrains.kotlin.types.Variance object IrFactoryImpl : IrFactory { + override val stageController: StageController = StageController() + override fun createAnonymousInitializer( startOffset: Int, endOffset: Int, diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrAnonymousInitializer.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrAnonymousInitializer.kt index b051c05adbf..04328f0b3fe 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrAnonymousInitializer.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrAnonymousInitializer.kt @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.declarations.persistent.carriers.AnonymousInitializerCarrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrAnonymousInitializerSymbol @@ -24,7 +23,8 @@ internal class PersistentIrAnonymousInitializer( override val endOffset: Int, origin: IrDeclarationOrigin, override val symbol: IrAnonymousInitializerSymbol, - override val isStatic: Boolean = false + override val isStatic: Boolean = false, + override val factory: PersistentIrFactory ) : IrAnonymousInitializer(), PersistentIrDeclarationBase, AnonymousInitializerCarrier { @@ -33,10 +33,10 @@ internal class PersistentIrAnonymousInitializer( symbol.bind(this) } - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = origin diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrClass.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrClass.kt index e62208b4947..ac0b04f8a0f 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrClass.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrClass.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.ir.declarations.IrValueParameter import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ClassCarrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.types.IrType @@ -47,7 +46,8 @@ internal class PersistentIrClass( override val isInline: Boolean = false, override val isExpect: Boolean = false, override val isFun: Boolean = false, - override val source: SourceElement = SourceElement.NO_SOURCE + override val source: SourceElement = SourceElement.NO_SOURCE, + override val factory: PersistentIrFactory ) : IrClass(), PersistentIrDeclarationBase, ClassCarrier { @@ -56,10 +56,10 @@ internal class PersistentIrClass( symbol.bind(this) } - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = origin @@ -94,11 +94,11 @@ internal class PersistentIrClass( override val declarations: MutableList = ArrayList() get() { - if (createdOn < stageController.currentStage && initialDeclarations == null) { + if (createdOn < factory.stageController.currentStage && initialDeclarations == null) { initialDeclarations = Collections.unmodifiableList(ArrayList(field)) } - return if (stageController.canAccessDeclarationsOf(this)) { + return if (factory.stageController.canAccessDeclarationsOf(this)) { ensureLowered() field } else { diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrConstructor.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrConstructor.kt index d44f6daeb74..6781318e5f3 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrConstructor.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrConstructor.kt @@ -16,7 +16,6 @@ import org.jetbrains.kotlin.ir.declarations.IrValueParameter import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ConstructorCarrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol @@ -40,7 +39,8 @@ internal class PersistentIrConstructor( isExternal: Boolean, override val isPrimary: Boolean, override val isExpect: Boolean, - override val containerSource: DeserializedContainerSource? + override val containerSource: DeserializedContainerSource?, + override val factory: PersistentIrFactory ) : IrConstructor(), PersistentIrDeclarationBase, ConstructorCarrier { @@ -49,10 +49,10 @@ internal class PersistentIrConstructor( symbol.bind(this) } - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = origin diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrEnumEntry.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrEnumEntry.kt index a681c2a9844..a450d50985e 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrEnumEntry.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrEnumEntry.kt @@ -13,7 +13,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.declarations.IrEnumEntry import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.EnumEntryCarrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol @@ -26,7 +25,8 @@ internal class PersistentIrEnumEntry( override val endOffset: Int, origin: IrDeclarationOrigin, override val symbol: IrEnumEntrySymbol, - override val name: Name + override val name: Name, + override val factory: PersistentIrFactory ) : IrEnumEntry(), PersistentIrDeclarationBase, EnumEntryCarrier { @@ -35,10 +35,10 @@ internal class PersistentIrEnumEntry( symbol.bind(this) } - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = origin diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt index 9611f86ab7f..6c4c6958959 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrErrorDeclaration.kt @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.declarations.IrErrorDeclaration import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ErrorDeclarationCarrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor import org.jetbrains.kotlin.ir.expressions.IrConstructorCall @@ -22,17 +21,18 @@ import org.jetbrains.kotlin.ir.expressions.IrConstructorCall internal class PersistentIrErrorDeclaration( override val startOffset: Int, override val endOffset: Int, - private val _descriptor: DeclarationDescriptor? + private val _descriptor: DeclarationDescriptor?, + override val factory: PersistentIrFactory ) : IrErrorDeclaration(), PersistentIrDeclarationBase, ErrorDeclarationCarrier { override val descriptor: DeclarationDescriptor get() = _descriptor ?: this.toIrBasedDescriptor() - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = IrDeclarationOrigin.DEFINED diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrField.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrField.kt index 1c222461f04..179a13850e3 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrField.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrField.kt @@ -14,7 +14,6 @@ import org.jetbrains.kotlin.ir.declarations.IrField import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FieldCarrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol @@ -34,7 +33,8 @@ internal class PersistentIrField( override var visibility: DescriptorVisibility, override val isFinal: Boolean, isExternal: Boolean, - override val isStatic: Boolean + override val isStatic: Boolean, + override val factory: PersistentIrFactory ) : IrField(), PersistentIrDeclarationBase, FieldCarrier { @@ -43,10 +43,10 @@ internal class PersistentIrField( symbol.bind(this) } - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = origin diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt index a6327bdf99d..10abfab2522 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunctionCommon.kt @@ -15,7 +15,6 @@ import org.jetbrains.kotlin.ir.declarations.IrValueParameter import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.FunctionCarrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol @@ -42,15 +41,16 @@ internal abstract class PersistentIrFunctionCommon( override val isOperator: Boolean, override val isInfix: Boolean, override val isExpect: Boolean, - override val containerSource: DeserializedContainerSource? = null + override val containerSource: DeserializedContainerSource? = null, + override val factory: PersistentIrFactory ) : IrSimpleFunction(), PersistentIrDeclarationBase, FunctionCarrier { - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = origin diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrLocalDelegatedProperty.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrLocalDelegatedProperty.kt index 77e87a25393..479c2ade98f 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrLocalDelegatedProperty.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrLocalDelegatedProperty.kt @@ -15,7 +15,6 @@ import org.jetbrains.kotlin.ir.declarations.IrVariable import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.LocalDelegatedPropertyCarrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrLocalDelegatedPropertySymbol import org.jetbrains.kotlin.ir.types.IrType @@ -31,7 +30,8 @@ internal class PersistentIrLocalDelegatedProperty( override val symbol: IrLocalDelegatedPropertySymbol, override val name: Name, type: IrType, - override val isVar: Boolean + override val isVar: Boolean, + override val factory: PersistentIrFactory ) : IrLocalDelegatedProperty(), PersistentIrDeclarationBase, LocalDelegatedPropertyCarrier { @@ -40,10 +40,10 @@ internal class PersistentIrLocalDelegatedProperty( symbol.bind(this) } - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = origin diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt index b86f839f78a..79c3c00383c 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrPropertyCommon.kt @@ -15,7 +15,6 @@ import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction import org.jetbrains.kotlin.ir.declarations.MetadataSource import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.PropertyCarrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource @@ -34,15 +33,16 @@ internal abstract class PersistentIrPropertyCommon( override val isDelegated: Boolean, isExternal: Boolean, override val isExpect: Boolean, - override val containerSource: DeserializedContainerSource? + override val containerSource: DeserializedContainerSource?, + override val factory: PersistentIrFactory ) : IrProperty(), PersistentIrDeclarationBase, PropertyCarrier { - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = origin diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeAlias.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeAlias.kt index fc7860e0eba..a6635d84b22 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeAlias.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeAlias.kt @@ -14,7 +14,6 @@ import org.jetbrains.kotlin.ir.declarations.IrTypeAlias import org.jetbrains.kotlin.ir.declarations.IrTypeParameter import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.TypeAliasCarrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrTypeAliasSymbol import org.jetbrains.kotlin.ir.types.IrType @@ -30,7 +29,8 @@ internal class PersistentIrTypeAlias( override var visibility: DescriptorVisibility, expandedType: IrType, override val isActual: Boolean, - origin: IrDeclarationOrigin + origin: IrDeclarationOrigin, + override val factory: PersistentIrFactory ) : IrTypeAlias(), PersistentIrDeclarationBase, TypeAliasCarrier { @@ -39,10 +39,10 @@ internal class PersistentIrTypeAlias( symbol.bind(this) } - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = origin diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeParameter.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeParameter.kt index 0fa5b40fbb2..dead2eb5d89 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeParameter.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrTypeParameter.kt @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.declarations.IrTypeParameter import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.TypeParameterCarrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol import org.jetbrains.kotlin.ir.types.IrType @@ -29,7 +28,8 @@ internal class PersistentIrTypeParameter( override val name: Name, override val index: Int, override val isReified: Boolean, - override val variance: Variance + override val variance: Variance, + override val factory: PersistentIrFactory ) : IrTypeParameter(), PersistentIrDeclarationBase, TypeParameterCarrier { @@ -38,10 +38,10 @@ internal class PersistentIrTypeParameter( symbol.bind(this) } - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = origin diff --git a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrValueParameter.kt b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrValueParameter.kt index 241521ee85e..b8702386221 100644 --- a/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrValueParameter.kt +++ b/compiler/ir/ir.tree.persistent/gen/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrValueParameter.kt @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.declarations.IrValueParameter import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier import org.jetbrains.kotlin.ir.declarations.persistent.carriers.ValueParameterCarrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol @@ -33,7 +32,8 @@ internal class PersistentIrValueParameter( override val isCrossinline: Boolean, override val isNoinline: Boolean, override val isHidden: Boolean, - override val isAssignable: Boolean + override val isAssignable: Boolean, + override val factory: PersistentIrFactory ) : IrValueParameter(), PersistentIrDeclarationBase, ValueParameterCarrier { @@ -46,10 +46,10 @@ internal class PersistentIrValueParameter( symbol.bind(this) } - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var parentField: IrDeclarationParent? = null override var originField: IrDeclarationOrigin = origin diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/AnonymousInitializer.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/AnonymousInitializer.kt index 0790f993898..62caa036963 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/AnonymousInitializer.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/AnonymousInitializer.kt @@ -18,6 +18,7 @@ internal fun PersistentIrGenerator.generateAnonymousInitializer() { origin, +"override val symbol: " + IrAnonymousInitializerSymbol, isStatic + " = false", + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("AnonymousInitializer") + " " + blockSpaced( initBlock, diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Class.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Class.kt index 870379a130c..8705859e10f 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Class.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Class.kt @@ -36,6 +36,7 @@ internal fun PersistentIrGenerator.generateClass() { isExpect + " = false", isFun, source, + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("Class") + " " + blockSpaced( initBlock, @@ -49,12 +50,12 @@ internal fun PersistentIrGenerator.generateClass() { +"override val declarations: MutableList = " + import("ArrayList", "java.util") + "()", lines( +"get() " + block( - +"if (createdOn < stageController.currentStage && initialDeclarations == null) " + block( + +"if (createdOn < factory.stageController.currentStage && initialDeclarations == null) " + block( +"initialDeclarations = " + import("Collections", "java.util") + ".unmodifiableList(ArrayList(field))" ), id, +""" - return if (stageController.canAccessDeclarationsOf(this)) { + return if (factory.stageController.canAccessDeclarationsOf(this)) { ensureLowered() field } else { diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Constructor.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Constructor.kt index a75134ab61d..f6588ffc7dd 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Constructor.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Constructor.kt @@ -33,6 +33,7 @@ internal fun PersistentIrGenerator.generateConstructor() { isPrimary, isExpect, containerSource, + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("Constructor") + " " + blockSpaced( initBlock, diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/EnumEntry.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/EnumEntry.kt index 1346b4e6c1a..8481431a91f 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/EnumEntry.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/EnumEntry.kt @@ -19,6 +19,7 @@ internal fun PersistentIrGenerator.generateEnumEntry() { origin, +"override val symbol: " + irSymbol("IrEnumEntrySymbol"), name, + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("EnumEntry") + " " + blockSpaced( initBlock, diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ErrorDeclaration.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ErrorDeclaration.kt index 9f5bc61d59a..3a39539dbc2 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ErrorDeclaration.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ErrorDeclaration.kt @@ -15,7 +15,8 @@ internal fun PersistentIrGenerator.generateErrorDeclaration() { arrayOf( startOffset, endOffset, - +"private val _descriptor: " + DeclarationDescriptor + "?" + +"private val _descriptor: " + DeclarationDescriptor + "?", + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("ErrorDeclaration") + " " + block( lines( diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Field.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Field.kt index f440e7d0324..8c913d57b18 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Field.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Field.kt @@ -27,6 +27,7 @@ internal fun PersistentIrGenerator.generateField() { isFinal, isExternal, isStatic, + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("Field") + " " + blockSpaced( initBlock, diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Function.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Function.kt index 0d3d21c20db..1940f5c32e0 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Function.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Function.kt @@ -39,6 +39,7 @@ internal fun PersistentIrGenerator.generateFunction() { +"override val isInfix: Boolean", isExpect, containerSource + " = null", + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("Function", baseClass = "IrSimpleFunction") + " " + blockSpaced( commonFields, diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/LocalDelegatedProperty.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/LocalDelegatedProperty.kt index 468cfbaa17a..6ff921d3ea0 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/LocalDelegatedProperty.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/LocalDelegatedProperty.kt @@ -25,6 +25,7 @@ internal fun PersistentIrGenerator.generateLocalDelegatedProperty() { name, +"type: " + IrType, +"override val isVar: Boolean", + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("LocalDelegatedProperty") + " " + blockSpaced( initBlock, diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/PersistentIrGenerator.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/PersistentIrGenerator.kt index 7b2dad9d8d1..7aca1583594 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/PersistentIrGenerator.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/PersistentIrGenerator.kt @@ -53,8 +53,6 @@ internal object PersistentIrGenerator { val ObsoleteDescriptorBasedAPI = import("ObsoleteDescriptorBasedAPI", "org.jetbrains.kotlin.ir") - val stageController = import("stageController", "org.jetbrains.kotlin.ir.declarations") - val IrType = import("IrType", "org.jetbrains.kotlin.ir.types") val IrPropertySymbol = irSymbol("IrPropertySymbol") @@ -82,15 +80,17 @@ internal object PersistentIrGenerator { val isPrimary = +"override val isPrimary: Boolean" val containerSource = +"override val containerSource: " + import("DeserializedContainerSource", "org.jetbrains.kotlin.serialization.deserialization.descriptors") + "?" + val irFactory = +"override val factory: PersistentIrFactory" + val initBlock = +"init " + block( +"symbol.bind(this)" ) // Fields - val lastModified = +"override var lastModified: Int = " + stageController + ".currentStage" - val loweredUpTo = +"override var loweredUpTo: Int = " + stageController + ".currentStage" + val lastModified = +"override var lastModified: Int = factory.stageController.currentStage" + val loweredUpTo = +"override var loweredUpTo: Int = factory.stageController.currentStage" val values = +"override var values: Array<" + Carrier + ">? = null" - val createdOn = +"override val createdOn: Int = " + stageController + ".currentStage" + val createdOn = +"override val createdOn: Int = factory.stageController.currentStage" val parentField = +"override var parentField: " + IrDeclarationParent + "? = null" val originField = +"override var originField: " + IrDeclarationOrigin + " = origin" diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Property.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Property.kt index 462726a92ed..58fe12d906a 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Property.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/Property.kt @@ -29,7 +29,8 @@ internal fun PersistentIrGenerator.generateProperty() { +"override val isDelegated: Boolean", isExternal, isExpect, - containerSource + containerSource, + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("Property") + " " + blockSpaced( commonFields, diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeAlias.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeAlias.kt index 6bfa5dcabd9..d7c5fda0839 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeAlias.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeAlias.kt @@ -22,6 +22,7 @@ internal fun PersistentIrGenerator.generateTypeAlias() { +"expandedType: " + IrType, +"override val isActual: Boolean", origin, + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("TypeAlias") + " " + blockSpaced( initBlock, diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeParameter.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeParameter.kt index dd03e385006..ff04267b62a 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeParameter.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/TypeParameter.kt @@ -20,7 +20,8 @@ internal fun PersistentIrGenerator.generateTypeParameter() { name, +"override val index: Int", +"override val isReified: Boolean", - +"override val variance: " + import("Variance", "org.jetbrains.kotlin.types") + +"override val variance: " + import("Variance", "org.jetbrains.kotlin.types"), + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("TypeParameter") + " " + blockSpaced( initBlock, diff --git a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ValueParameter.kt b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ValueParameter.kt index 703a4c8b11d..395f1ee1635 100644 --- a/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ValueParameter.kt +++ b/compiler/ir/ir.tree.persistent/generator/src/org/jetbrains/kotlin/ir/persistentIrGenerator/ValueParameter.kt @@ -27,7 +27,8 @@ internal fun PersistentIrGenerator.generateValueParameter() { +"override val isCrossinline: Boolean", +"override val isNoinline: Boolean", +"override val isHidden: Boolean", - +"override val isAssignable: Boolean" + +"override val isAssignable: Boolean", + irFactory, ).join(separator = ",\n").indent(), +") : " + baseClasses("ValueParameter") + " " + blockSpaced( descriptor(descriptorType("ParameterDescriptor")), diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrDeclarationBase.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrDeclarationBase.kt index c9b93bc9073..9d6b42a6f79 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrDeclarationBase.kt +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrDeclarationBase.kt @@ -17,9 +17,6 @@ import org.jetbrains.kotlin.ir.expressions.IrConstructorCall interface PersistentIrDeclarationBase : PersistentIrElementBase, IrDeclaration, DeclarationCarrier { var removedOn: Int - override val factory: IrFactory - get() = PersistentIrFactory - // TODO reduce boilerplate override var parent: IrDeclarationParent get() = getCarrier().parentField ?: throw UninitializedPropertyAccessException("Parent not initialized: $this") @@ -46,13 +43,16 @@ interface PersistentIrDeclarationBase : PersistentIrElem } override fun ensureLowered() { - if (stageController.currentStage > loweredUpTo) { - stageController.lazyLower(this) + if (factory.stageController.currentStage > loweredUpTo) { + factory.stageController.lazyLower(this) } } } interface PersistentIrElementBase : IrElement, Carrier { + + val factory: PersistentIrFactory + override var lastModified: Int var loweredUpTo: Int @@ -66,7 +66,7 @@ interface PersistentIrElementBase : IrElement, Carrier { @Suppress("UNCHECKED_CAST") fun getCarrier(): T { - stageController.currentStage.let { stage -> + factory.stageController.currentStage.let { stage -> ensureLowered() if (stage >= lastModified) return this as T @@ -97,11 +97,11 @@ interface PersistentIrElementBase : IrElement, Carrier { // TODO naming? e.g. `mutableCarrier` @Suppress("UNCHECKED_CAST") fun setCarrier(): T { - val stage = stageController.currentStage + val stage = factory.stageController.currentStage ensureLowered() - if (!stageController.canModify(this)) { + if (!factory.stageController.canModify(this)) { error("Cannot modify this element!") } @@ -136,7 +136,7 @@ interface PersistentIrBodyBase> : PersistentIrElemen } fun checkEnabled(fn: () -> T): T { - if (!stageController.bodiesEnabled) error("Bodies disabled!") + if (!factory.stageController.bodiesEnabled) error("Bodies disabled!") ensureLowered() return fn() } @@ -145,14 +145,14 @@ interface PersistentIrBodyBase> : PersistentIrElemen override fun ensureLowered() { initializer?.let { initFn -> initializer = null - stageController.withStage(createdOn) { - stageController.bodyLowering { + factory.stageController.withStage(createdOn) { + factory.stageController.bodyLowering { initFn.invoke(this as B) } } } - if (loweredUpTo + 1 < stageController.currentStage) { - stageController.lazyLower(this as IrBody) + if (loweredUpTo + 1 < factory.stageController.currentStage) { + factory.stageController.lazyLower(this as IrBody) } } } diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFactory.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFactory.kt index 1cbbd63941c..64ed078cbb9 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFactory.kt +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFactory.kt @@ -19,7 +19,10 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource import org.jetbrains.kotlin.types.Variance -object PersistentIrFactory : IrFactory { +class PersistentIrFactory : IrFactory { + + override var stageController = StageController() + override fun createAnonymousInitializer( startOffset: Int, endOffset: Int, @@ -27,7 +30,7 @@ object PersistentIrFactory : IrFactory { symbol: IrAnonymousInitializerSymbol, isStatic: Boolean, ): IrAnonymousInitializer = - PersistentIrAnonymousInitializer(startOffset, endOffset, origin, symbol, isStatic) + PersistentIrAnonymousInitializer(startOffset, endOffset, origin, symbol, isStatic, this) override fun createClass( startOffset: Int, @@ -50,6 +53,7 @@ object PersistentIrFactory : IrFactory { PersistentIrClass( startOffset, endOffset, origin, symbol, name, kind, visibility, modality, isCompanion, isInner, isData, isExternal, isInline, isExpect, isFun, source, + this ) override fun createConstructor( @@ -68,7 +72,7 @@ object PersistentIrFactory : IrFactory { ): IrConstructor = PersistentIrConstructor( startOffset, endOffset, origin, symbol, name, visibility, returnType, isInline, isExternal, isPrimary, isExpect, - containerSource, + containerSource, this ) override fun createEnumEntry( @@ -78,14 +82,14 @@ object PersistentIrFactory : IrFactory { symbol: IrEnumEntrySymbol, name: Name, ): IrEnumEntry = - PersistentIrEnumEntry(startOffset, endOffset, origin, symbol, name) + PersistentIrEnumEntry(startOffset, endOffset, origin, symbol, name, this) override fun createErrorDeclaration( startOffset: Int, endOffset: Int, descriptor: DeclarationDescriptor?, ): IrErrorDeclaration = - PersistentIrErrorDeclaration(startOffset, endOffset, descriptor) + PersistentIrErrorDeclaration(startOffset, endOffset, descriptor, this) override fun createField( startOffset: Int, @@ -99,7 +103,7 @@ object PersistentIrFactory : IrFactory { isExternal: Boolean, isStatic: Boolean, ): IrField = - PersistentIrField(startOffset, endOffset, origin, symbol, name, type, visibility, isFinal, isExternal, isStatic) + PersistentIrField(startOffset, endOffset, origin, symbol, name, type, visibility, isFinal, isExternal, isStatic, this) override fun createFunction( startOffset: Int, @@ -123,7 +127,7 @@ object PersistentIrFactory : IrFactory { PersistentIrFunction( startOffset, endOffset, origin, symbol, name, visibility, modality, returnType, isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect, isFakeOverride, - containerSource + containerSource, this ) override fun createFakeOverrideFunction( @@ -144,7 +148,7 @@ object PersistentIrFactory : IrFactory { ): IrSimpleFunction = PersistentIrFakeOverrideFunction( startOffset, endOffset, origin, name, visibility, modality, returnType, - isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect, + isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect, this ) override fun createLocalDelegatedProperty( @@ -157,7 +161,7 @@ object PersistentIrFactory : IrFactory { isVar: Boolean, ): IrLocalDelegatedProperty = PersistentIrLocalDelegatedProperty( - startOffset, endOffset, origin, symbol, name, type, isVar + startOffset, endOffset, origin, symbol, name, type, isVar, this ) override fun createProperty( @@ -180,7 +184,7 @@ object PersistentIrFactory : IrFactory { PersistentIrProperty( startOffset, endOffset, origin, symbol, name, visibility, modality, isVar, isConst, isLateinit, isDelegated, isExternal, isExpect, isFakeOverride, - containerSource + containerSource, this ) override fun createFakeOverrideProperty( @@ -200,6 +204,7 @@ object PersistentIrFactory : IrFactory { PersistentIrFakeOverrideProperty( startOffset, endOffset, origin, name, visibility, modality, isVar, isConst, isLateinit, isDelegated, isExternal, isExpect, + this ) override fun createTypeAlias( @@ -212,7 +217,7 @@ object PersistentIrFactory : IrFactory { isActual: Boolean, origin: IrDeclarationOrigin, ): IrTypeAlias = - PersistentIrTypeAlias(startOffset, endOffset, symbol, name, visibility, expandedType, isActual, origin) + PersistentIrTypeAlias(startOffset, endOffset, symbol, name, visibility, expandedType, isActual, origin, this) override fun createTypeParameter( startOffset: Int, @@ -224,7 +229,7 @@ object PersistentIrFactory : IrFactory { isReified: Boolean, variance: Variance, ): IrTypeParameter = - PersistentIrTypeParameter(startOffset, endOffset, origin, symbol, name, index, isReified, variance) + PersistentIrTypeParameter(startOffset, endOffset, origin, symbol, name, index, isReified, variance, this) override fun createValueParameter( startOffset: Int, @@ -241,7 +246,7 @@ object PersistentIrFactory : IrFactory { isAssignable: Boolean ): IrValueParameter = PersistentIrValueParameter( - startOffset, endOffset, origin, symbol, name, index, type, varargElementType, isCrossinline, isNoinline, isHidden, isAssignable + startOffset, endOffset, origin, symbol, name, index, type, varargElementType, isCrossinline, isNoinline, isHidden, isAssignable, this ) override fun createExpressionBody( @@ -249,37 +254,37 @@ object PersistentIrFactory : IrFactory { endOffset: Int, initializer: IrExpressionBody.() -> Unit, ): IrExpressionBody = - PersistentIrExpressionBody(startOffset, endOffset, initializer) + PersistentIrExpressionBody(startOffset, endOffset, this, initializer) override fun createExpressionBody( startOffset: Int, endOffset: Int, expression: IrExpression, ): IrExpressionBody = - PersistentIrExpressionBody(startOffset, endOffset, expression) + PersistentIrExpressionBody(startOffset, endOffset, expression, this) override fun createExpressionBody( expression: IrExpression, ): IrExpressionBody = - PersistentIrExpressionBody(expression) + PersistentIrExpressionBody(expression, this) override fun createBlockBody( startOffset: Int, endOffset: Int, ): IrBlockBody = - PersistentIrBlockBody(startOffset, endOffset) + PersistentIrBlockBody(startOffset, endOffset, this) override fun createBlockBody( startOffset: Int, endOffset: Int, statements: List, ): IrBlockBody = - PersistentIrBlockBody(startOffset, endOffset, statements) + PersistentIrBlockBody(startOffset, endOffset, statements, this) override fun createBlockBody( startOffset: Int, endOffset: Int, initializer: IrBlockBody.() -> Unit, ): IrBlockBody = - PersistentIrBlockBody(startOffset, endOffset, initializer) + PersistentIrBlockBody(startOffset, endOffset, this, initializer) } diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunction.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunction.kt index 9cf6f61b6ab..f84fa22c18c 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunction.kt +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrFunction.kt @@ -33,11 +33,12 @@ internal class PersistentIrFunction( isInfix: Boolean, isExpect: Boolean, override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE, - containerSource: DeserializedContainerSource? + containerSource: DeserializedContainerSource?, + factory: PersistentIrFactory, ) : PersistentIrFunctionCommon( startOffset, endOffset, origin, name, visibility, returnType, isInline, isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect, - containerSource + containerSource, factory ) { @ObsoleteDescriptorBasedAPI override val descriptor: FunctionDescriptor @@ -63,9 +64,10 @@ internal class PersistentIrFakeOverrideFunction( isOperator: Boolean, isInfix: Boolean, isExpect: Boolean, + factory: PersistentIrFactory, ) : PersistentIrFunctionCommon( startOffset, endOffset, origin, name, visibility, returnType, isInline, - isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect, + isExternal, isTailrec, isSuspend, isOperator, isInfix, isExpect, factory = factory ), IrFakeOverrideFunction { override val isFakeOverride: Boolean get() = true diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrProperty.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrProperty.kt index eba7bdafa13..9f2f8eb6e2d 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrProperty.kt +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/declarations/persistent/PersistentIrProperty.kt @@ -35,9 +35,10 @@ internal class PersistentIrProperty( isExpect: Boolean = false, override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE, containerSource: DeserializedContainerSource?, + factory: PersistentIrFactory, ) : PersistentIrPropertyCommon( startOffset, endOffset, origin, name, visibility, isVar, isConst, isLateinit, isDelegated, isExternal, isExpect, - containerSource, + containerSource, factory ) { init { symbol.bind(this) @@ -61,10 +62,11 @@ internal class PersistentIrFakeOverrideProperty( isDelegated: Boolean, isExternal: Boolean, isExpect: Boolean, + factory: PersistentIrFactory, ) : PersistentIrPropertyCommon( startOffset, endOffset, origin, name, visibility, isVar, isConst, isLateinit, isDelegated, isExternal, isExpect, - containerSource = null, + containerSource = null, factory ), IrFakeOverrideProperty { override val isFakeOverride: Boolean get() = true diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/expressions/persistent/PersistentIrBlockBody.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/expressions/persistent/PersistentIrBlockBody.kt index cf82524f88e..15b82da46d9 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/expressions/persistent/PersistentIrBlockBody.kt +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/expressions/persistent/PersistentIrBlockBody.kt @@ -18,26 +18,25 @@ package org.jetbrains.kotlin.ir.expressions.persistent import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.IrDeclaration -import org.jetbrains.kotlin.ir.declarations.IrFactory import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrBodyBase import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrBlockBody internal class PersistentIrBlockBody( override val startOffset: Int, override val endOffset: Int, + override val factory: PersistentIrFactory, override var initializer: (PersistentIrBlockBody.() -> Unit)? = null ) : IrBlockBody(), PersistentIrBodyBase { - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var containerField: IrDeclaration? = null - constructor(startOffset: Int, endOffset: Int, statements: List) : this(startOffset, endOffset) { + constructor(startOffset: Int, endOffset: Int, statements: List, factory: PersistentIrFactory) : this(startOffset, endOffset, factory) { statementsField.addAll(statements) } @@ -45,7 +44,4 @@ internal class PersistentIrBlockBody( override val statements: MutableList get() = checkEnabled { statementsField } - - override val factory: IrFactory - get() = PersistentIrFactory } diff --git a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/expressions/persistent/PersistentIrExpressionBody.kt b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/expressions/persistent/PersistentIrExpressionBody.kt index 9bb3540d55a..aed229f8ea3 100644 --- a/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/expressions/persistent/PersistentIrExpressionBody.kt +++ b/compiler/ir/ir.tree.persistent/src/org/jetbrains/kotlin/ir/expressions/persistent/PersistentIrExpressionBody.kt @@ -17,40 +17,36 @@ package org.jetbrains.kotlin.ir.expressions.persistent import org.jetbrains.kotlin.ir.declarations.IrDeclaration -import org.jetbrains.kotlin.ir.declarations.IrFactory import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrBodyBase import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory import org.jetbrains.kotlin.ir.declarations.persistent.carriers.Carrier -import org.jetbrains.kotlin.ir.declarations.stageController import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrExpressionBody internal class PersistentIrExpressionBody private constructor( override val startOffset: Int, override val endOffset: Int, + override val factory: PersistentIrFactory, private var expressionField: IrExpression? = null, - override var initializer: (PersistentIrExpressionBody.() -> Unit)? = null + override var initializer: (PersistentIrExpressionBody.() -> Unit)? = null, ) : IrExpressionBody(), PersistentIrBodyBase { - override var lastModified: Int = stageController.currentStage - override var loweredUpTo: Int = stageController.currentStage + override var lastModified: Int = factory.stageController.currentStage + override var loweredUpTo: Int = factory.stageController.currentStage override var values: Array? = null - override val createdOn: Int = stageController.currentStage + override val createdOn: Int = factory.stageController.currentStage override var containerField: IrDeclaration? = null - constructor(expression: IrExpression) : this(expression.startOffset, expression.endOffset, expression, null) + constructor(expression: IrExpression, factory: PersistentIrFactory) : this(expression.startOffset, expression.endOffset, factory, expression, null) - constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset, expression, null) + constructor(startOffset: Int, endOffset: Int, expression: IrExpression,factory: PersistentIrFactory) : this(startOffset, endOffset, factory, expression, null) - constructor(startOffset: Int, endOffset: Int, initializer: IrExpressionBody.() -> Unit) : - this(startOffset, endOffset, null, initializer) + constructor(startOffset: Int, endOffset: Int, factory: PersistentIrFactory, initializer: IrExpressionBody.() -> Unit) : + this(startOffset, endOffset, factory, null, initializer) override var expression: IrExpression get() = checkEnabled { expressionField!! } set(e) { checkEnabled { expressionField = e } } - - override val factory: IrFactory - get() = PersistentIrFactory } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFactory.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFactory.kt index 2735fa12fc8..3d7b8b93a58 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFactory.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFactory.kt @@ -17,6 +17,8 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ import org.jetbrains.kotlin.types.Variance interface IrFactory { + val stageController: StageController + fun createAnonymousInitializer( startOffset: Int, endOffset: Int, diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/PersistentApi.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/PersistentApi.kt index fa1834ec5d5..423906922db 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/PersistentApi.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/PersistentApi.kt @@ -8,11 +8,6 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.expressions.IrBody -// TODO threadlocal -// TODO make a IrDeclarationBase field? (requires IR factory) -var stageController: StageController = StageController() - -// TODO make a class open class StageController(open val currentStage: Int = 0) { open fun lazyLower(declaration: IrDeclaration) {} @@ -33,9 +28,4 @@ open class StageController(open val currentStage: Int = 0) { open fun unrestrictDeclarationListsAccess(fn: () -> T): T = fn() open fun canAccessDeclarationsOf(irClass: IrClass): Boolean = true -} - -@Suppress("NOTHING_TO_INLINE") -inline fun withInitialIr(noinline fn: () -> T): T { - return stageController.withInitialIr(fn) -} +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrScriptImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrScriptImpl.kt index f72b8e59e3b..b91e299bd8e 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrScriptImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrScriptImpl.kt @@ -24,7 +24,8 @@ private val SCRIPT_ORIGIN = object : IrDeclarationOriginImpl("SCRIPT") {} class IrScriptImpl( override val symbol: IrScriptSymbol, - override val name: Name + override val name: Name, + override val factory: IrFactory, ) : IrScript() { override val startOffset: Int get() = UNDEFINED_OFFSET override val endOffset: Int get() = UNDEFINED_OFFSET @@ -55,9 +56,6 @@ class IrScriptImpl( override val descriptor: ScriptDescriptor get() = symbol.descriptor - override val factory: IrFactory - get() = error("Create IrScriptImpl directly") - init { symbol.bind(this) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyTypeAlias.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyTypeAlias.kt index ac2c36ec6af..51fcdb47ed4 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyTypeAlias.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyTypeAlias.kt @@ -44,10 +44,8 @@ class IrLazyTypeAlias( } override var expandedType: IrType by lazyVar { - withInitialIr { - typeTranslator.buildWithScope(this) { - descriptor.expandedType.toIrType() - } + typeTranslator.buildWithScope(this) { + descriptor.expandedType.toIrType() } } } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyTypeParameter.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyTypeParameter.kt index 11be239e09f..ab1c7c2a586 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyTypeParameter.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyTypeParameter.kt @@ -39,11 +39,9 @@ class IrLazyTypeParameter( override var annotations: List by createLazyAnnotations() override var superTypes: List by lazyVar { - withInitialIr { - typeTranslator.buildWithScope(this.parent as IrTypeParametersContainer) { - val descriptor = symbol.descriptor - descriptor.upperBounds.mapTo(arrayListOf()) { it.toIrType() } - } + typeTranslator.buildWithScope(this.parent as IrTypeParametersContainer) { + val descriptor = symbol.descriptor + descriptor.upperBounds.mapTo(arrayListOf()) { it.toIrType() } } } } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/lazyUtil.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/lazyUtil.kt index 39836138eb8..79d9135a90f 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/lazyUtil.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/lazyUtil.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.ir.declarations.lazy -import org.jetbrains.kotlin.ir.declarations.withInitialIr import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty @@ -19,7 +18,7 @@ private class UnsafeLazyVar(initializer: () -> T) : ReadWriteProperty scriptCopy.thisReceiver = declaration.thisReceiver.transform() declaration.statements.mapTo(scriptCopy.statements) { it.transform() } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt index 83582141539..d2eb45738d0 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt @@ -362,7 +362,7 @@ class SymbolTable( fun declareScript( descriptor: ScriptDescriptor, scriptFactory: (IrScriptSymbol) -> IrScript = { symbol: IrScriptSymbol -> - IrScriptImpl(symbol, nameProvider.nameForDeclaration(descriptor)) + IrScriptImpl(symbol, nameProvider.nameForDeclaration(descriptor), irFactory) } ): IrScript { return scriptSymbolTable.declare( diff --git a/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt b/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt index d6d220ad8b9..e8b655ecf24 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/benchmarks/GenerateIrRuntime.kt @@ -447,7 +447,7 @@ class GenerateIrRuntime { private fun doPsi2Ir(files: List, analysisResult: AnalysisResult): IrModuleFragment { val psi2Ir = Psi2IrTranslator(languageVersionSettings, Psi2IrConfiguration()) - val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), PersistentIrFactory) + val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), PersistentIrFactory()) val psi2IrContext = psi2Ir.createGeneratorContext(analysisResult.moduleDescriptor, analysisResult.bindingContext, symbolTable) val irBuiltIns = psi2IrContext.irBuiltIns @@ -510,7 +510,7 @@ class GenerateIrRuntime { private fun doDeserializeIrModule(moduleDescriptor: ModuleDescriptorImpl): DeserializedModuleInfo { val mangler = JsManglerDesc val signaturer = IdSignatureDescriptor(mangler) - val symbolTable = SymbolTable(signaturer, PersistentIrFactory) + val symbolTable = SymbolTable(signaturer, PersistentIrFactory()) val typeTranslator = TypeTranslator(symbolTable, languageVersionSettings, moduleDescriptor.builtIns).also { it.constantValueGenerator = ConstantValueGenerator(moduleDescriptor, symbolTable) } @@ -539,7 +539,7 @@ class GenerateIrRuntime { val moduleDescriptor = doDeserializeModuleMetadata(moduleRef) val mangler = JsManglerDesc val signaturer = IdSignatureDescriptor(mangler) - val symbolTable = SymbolTable(signaturer, PersistentIrFactory) + val symbolTable = SymbolTable(signaturer, PersistentIrFactory()) val typeTranslator = TypeTranslator(symbolTable, languageVersionSettings, moduleDescriptor.builtIns).also { it.constantValueGenerator = ConstantValueGenerator(moduleDescriptor, symbolTable) } @@ -567,7 +567,7 @@ class GenerateIrRuntime { private fun doBackEnd(module: IrModuleFragment, symbolTable: SymbolTable, irBuiltIns: IrBuiltIns, jsLinker: JsIrLinker): CompilerResult { - val context = JsIrBackendContext(module.descriptor, irBuiltIns, symbolTable, module, emptySet(), configuration) + val context = JsIrBackendContext(module.descriptor, irBuiltIns, symbolTable, module, emptySet(), configuration, irFactory = PersistentIrFactory()) ExternalDependenciesGenerator(symbolTable, listOf(jsLinker)).generateUnboundSymbolsAsDependencies() diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt index 8456dbd2f6e..3d72e268468 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicIrBoxTest.kt @@ -12,7 +12,7 @@ import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.js.messageCollectorLogger import org.jetbrains.kotlin.ir.backend.js.* -import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory +import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl import org.jetbrains.kotlin.js.config.JSConfigurationKeys import org.jetbrains.kotlin.js.config.JsConfig import org.jetbrains.kotlin.js.facade.MainCallParameters @@ -183,7 +183,7 @@ abstract class BasicIrBoxTest( configuration = config.configuration, allDependencies = resolvedLibraries, friendDependencies = emptyList(), - irFactory = PersistentIrFactory, + irFactory = IrFactoryImpl, outputKlibPath = actualOutputFile, nopack = true ) From bea5d955d4d5af080d52c5df200e50400535450e Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Tue, 20 Oct 2020 18:28:03 +0300 Subject: [PATCH 204/368] JVM_IR: perform file lowerings in parallel Selected by -Xir-run-lowerings-in-paralled compiler flag. --- .../arguments/K2JVMCompilerArguments.kt | 6 +++ .../jetbrains/kotlin/cli/jvm/jvmArguments.kt | 2 + .../kotlin/config/CommonConfigurationKeys.kt | 4 ++ .../backend/common/phaser/PhaseBuilders.kt | 37 ++++++++++++++++++- compiler/testData/cli/jvm/extraHelp.out | 1 + 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index 2690da7b26f..bb910106471 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -114,6 +114,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { ) var doNotClearBindingContext: Boolean by FreezableVar(false) + @Argument( + value = "-Xir-run-lowerings-in-parallel", + description = "When using the IR backend, run lowerings for each file in parallel" + ) + var runLoweringsInParallel: Boolean by FreezableVar(false) + @Argument(value = "-Xmodule-path", valueDescription = "", description = "Paths where to find Java 9+ modules") var javaModulePath: String? by NullableStringFreezableVar(null) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt index 84ab300d7db..196e5915734 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt @@ -291,6 +291,8 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr } arguments.declarationsOutputPath?.let { put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, it) } + + put(CommonConfigurationKeys.RUN_LOWERINGS_IN_PARALLEL, arguments.runLoweringsInParallel) } fun CompilerConfiguration.configureKlibPaths(arguments: K2JVMCompilerArguments) { diff --git a/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt b/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt index a26f51a3eae..f3eddf8e8ae 100644 --- a/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt +++ b/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt @@ -50,6 +50,10 @@ object CommonConfigurationKeys { @JvmField val USE_FIR_EXTENDED_CHECKERS = CompilerConfigurationKey.create("fir extended checkers") + + @JvmField + val RUN_LOWERINGS_IN_PARALLEL = + CompilerConfigurationKey.create("When using the IR backend, run lowerings for each file in parallel") } var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt index 6924d2f019c..1d0dd9bdb48 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt @@ -9,9 +9,11 @@ import org.jetbrains.kotlin.backend.common.CodegenUtil import org.jetbrains.kotlin.backend.common.CommonBackendContext import org.jetbrains.kotlin.backend.common.FileLoweringPass import org.jetbrains.kotlin.backend.common.lower +import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment +import kotlin.concurrent.thread // Phase composition. private class CompositePhase( @@ -113,12 +115,23 @@ private class PerformByIrFilePhase( private val lower: List> ) : SameTypeCompilerPhase { override fun invoke( + phaseConfig: PhaseConfig, + phaserState: PhaserState, + context: Context, + input: IrModuleFragment + ): IrModuleFragment = if (context.configuration.getBoolean(CommonConfigurationKeys.RUN_LOWERINGS_IN_PARALLEL)) + invokeParallel(phaseConfig, phaserState, context, input) + else + invokeSequential(phaseConfig, phaserState, context, input) + + private fun invokeSequential( phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: IrModuleFragment ): IrModuleFragment { for (irFile in input.files) { try { + val filePhaserState = phaserState.changeType() for (phase in lower) { - phase.invoke(phaseConfig, phaserState.changeType(), context, irFile) + phase.invoke(phaseConfig, filePhaserState, context, irFile) } } catch (e: Throwable) { CodegenUtil.reportBackendException(e, "IR lowering", irFile.fileEntry.name) @@ -129,6 +142,28 @@ private class PerformByIrFilePhase( return input } + private fun invokeParallel( + phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: IrModuleFragment + ): IrModuleFragment { + val threads = input.files.map { irFile -> + thread { + try { + val filePhaserState = state.changeType() + for (phase in lower) { + phase.invoke(phaseConfig, filePhaserState, context, irFile) + } + } catch (e: Throwable) { + CodegenUtil.reportBackendException(e, "IR lowering", irFile.fileEntry.name) + } + } + } + + threads.forEach { it.join() } + + // TODO: no guarantee that module identity is preserved by `lower` + return input + } + override fun getNamedSubphases(startDepth: Int): List>> = lower.flatMap { it.getNamedSubphases(startDepth) } } diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index 374d9ca8499..836d1d04734 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -99,6 +99,7 @@ where advanced options include: -Xsam-conversions={class|indy} Select code generation scheme for SAM conversions. -Xsam-conversions=indy Generate SAM conversions using `invokedynamic` with `LambdaMetafactory.metafactory`. Requires `-jvm-target 1.8` or greater. -Xsam-conversions=class Generate SAM conversions as explicit classes + -Xir-run-lowerings-in-parallel When using the IR backend, run lowerings for each file in parallel -Xsanitize-parentheses Transform '(' and ')' in method names to some other character sequence. This mode can BREAK BINARY COMPATIBILITY and is only supposed to be used to workaround problems with parentheses in identifiers on certain platforms From eae416d7394c2cef9f6139cbd62eb9b683d4ad34 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Sat, 31 Oct 2020 15:11:21 +0300 Subject: [PATCH 205/368] IR: Handle exceptions from by-file lowering thread --- .../backend/common/phaser/PhaseBuilders.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt index 1d0dd9bdb48..a9385ff7f24 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment +import java.lang.IllegalStateException import kotlin.concurrent.thread // Phase composition. @@ -145,7 +146,14 @@ private class PerformByIrFilePhase( private fun invokeParallel( phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: IrModuleFragment ): IrModuleFragment { - val threads = input.files.map { irFile -> + if (input.files.isEmpty()) return input + + // We can only report one exception through ISE + var thrownFromThread: Throwable? = null + + // Each thread needs its own copy of phaserState.alreadyDone + val filesAndStates = input.files.map { it to phaserState.clone() } + val threads = filesAndStates.map { (irFile, state) -> thread { try { val filePhaserState = state.changeType() @@ -153,13 +161,18 @@ private class PerformByIrFilePhase( phase.invoke(phaseConfig, filePhaserState, context, irFile) } } catch (e: Throwable) { - CodegenUtil.reportBackendException(e, "IR lowering", irFile.fileEntry.name) + thrownFromThread = e } } } threads.forEach { it.join() } + if (thrownFromThread != null) throw IllegalStateException("Exception in file lowering", thrownFromThread) + + // Presumably each thread has run through the same list of phases. + phaserState.alreadyDone.addAll(filesAndStates[0].second.alreadyDone) + // TODO: no guarantee that module identity is preserved by `lower` return input } From 52b3cb362bbe3173515857aae17e82714c19cad1 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Thu, 5 Nov 2020 09:59:38 +0300 Subject: [PATCH 206/368] IR: thread pool in PerformByIrFilePhase --- .../arguments/K2JVMCompilerArguments.kt | 7 ++-- .../jetbrains/kotlin/cli/jvm/jvmArguments.kt | 2 +- .../kotlin/config/CommonConfigurationKeys.kt | 4 +-- .../backend/common/phaser/PhaseBuilders.kt | 36 +++++++++++-------- compiler/testData/cli/jvm/extraHelp.out | 4 ++- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index bb910106471..926e80406d6 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -115,10 +115,11 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { var doNotClearBindingContext: Boolean by FreezableVar(false) @Argument( - value = "-Xir-run-lowerings-in-parallel", - description = "When using the IR backend, run lowerings for each file in parallel" + value = "-Xir-threads-for-file-lowerings", + description = "When using the IR backend, run lowerings by file in N parallel threads.\n" + + "Default value is 1" ) - var runLoweringsInParallel: Boolean by FreezableVar(false) + var threadsForFileLowerings: String by FreezableVar("1") @Argument(value = "-Xmodule-path", valueDescription = "", description = "Paths where to find Java 9+ modules") var javaModulePath: String? by NullableStringFreezableVar(null) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt index 196e5915734..932a6482b19 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt @@ -292,7 +292,7 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr arguments.declarationsOutputPath?.let { put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, it) } - put(CommonConfigurationKeys.RUN_LOWERINGS_IN_PARALLEL, arguments.runLoweringsInParallel) + put(CommonConfigurationKeys.THREADS_FOR_FILE_LOWERINGS, arguments.threadsForFileLowerings.toIntOrNull() ?: 1) } fun CompilerConfiguration.configureKlibPaths(arguments: K2JVMCompilerArguments) { diff --git a/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt b/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt index f3eddf8e8ae..9e77280ee7a 100644 --- a/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt +++ b/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt @@ -52,8 +52,8 @@ object CommonConfigurationKeys { val USE_FIR_EXTENDED_CHECKERS = CompilerConfigurationKey.create("fir extended checkers") @JvmField - val RUN_LOWERINGS_IN_PARALLEL = - CompilerConfigurationKey.create("When using the IR backend, run lowerings for each file in parallel") + val THREADS_FOR_FILE_LOWERINGS = + CompilerConfigurationKey.create("When using the IR backend, run lowerings by file in N parallel threads") } var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt index a9385ff7f24..89e0b3b50b2 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt @@ -13,8 +13,9 @@ import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment -import java.lang.IllegalStateException -import kotlin.concurrent.thread +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicReference // Phase composition. private class CompositePhase( @@ -120,10 +121,13 @@ private class PerformByIrFilePhase( phaserState: PhaserState, context: Context, input: IrModuleFragment - ): IrModuleFragment = if (context.configuration.getBoolean(CommonConfigurationKeys.RUN_LOWERINGS_IN_PARALLEL)) - invokeParallel(phaseConfig, phaserState, context, input) - else - invokeSequential(phaseConfig, phaserState, context, input) + ): IrModuleFragment { + val nThreads = context.configuration.get(CommonConfigurationKeys.THREADS_FOR_FILE_LOWERINGS) ?: 1 + return if (nThreads > 1) + invokeParallel(phaseConfig, phaserState, context, input, nThreads) + else + invokeSequential(phaseConfig, phaserState, context, input) + } private fun invokeSequential( phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: IrModuleFragment @@ -144,31 +148,35 @@ private class PerformByIrFilePhase( } private fun invokeParallel( - phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: IrModuleFragment + phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: IrModuleFragment, nThreads: Int ): IrModuleFragment { if (input.files.isEmpty()) return input // We can only report one exception through ISE - var thrownFromThread: Throwable? = null + val thrownFromThread = AtomicReference?>(null) // Each thread needs its own copy of phaserState.alreadyDone val filesAndStates = input.files.map { it to phaserState.clone() } - val threads = filesAndStates.map { (irFile, state) -> - thread { + + val executor = Executors.newFixedThreadPool(nThreads) + for ((irFile, state) in filesAndStates) { + executor.execute { try { val filePhaserState = state.changeType() for (phase in lower) { phase.invoke(phaseConfig, filePhaserState, context, irFile) } } catch (e: Throwable) { - thrownFromThread = e + thrownFromThread.set(Pair(e, irFile)) } } } + executor.shutdown() + executor.awaitTermination(1, TimeUnit.DAYS) // Wait long enough - threads.forEach { it.join() } - - if (thrownFromThread != null) throw IllegalStateException("Exception in file lowering", thrownFromThread) + thrownFromThread.get()?.let { (e, irFile) -> + CodegenUtil.reportBackendException(e, "IrLowering", irFile.fileEntry.name) + } // Presumably each thread has run through the same list of phases. phaserState.alreadyDone.addAll(filesAndStates[0].second.alreadyDone) diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index 836d1d04734..374d825bcbd 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -99,7 +99,6 @@ where advanced options include: -Xsam-conversions={class|indy} Select code generation scheme for SAM conversions. -Xsam-conversions=indy Generate SAM conversions using `invokedynamic` with `LambdaMetafactory.metafactory`. Requires `-jvm-target 1.8` or greater. -Xsam-conversions=class Generate SAM conversions as explicit classes - -Xir-run-lowerings-in-parallel When using the IR backend, run lowerings for each file in parallel -Xsanitize-parentheses Transform '(' and ')' in method names to some other character sequence. This mode can BREAK BINARY COMPATIBILITY and is only supposed to be used to workaround problems with parentheses in identifiers on certain platforms @@ -123,6 +122,9 @@ where advanced options include: Suppress deprecation warning about deprecated JVM target versions -Xsuppress-missing-builtins-error Suppress the "cannot access built-in declaration" error (useful with -no-stdlib) + -Xir-threads-for-file-lowerings + When using the IR backend, run lowerings by file in N parallel threads. + Default value is 1 -Xuse-ir Use the IR backend -Xuse-javac Use javac for Java source and class files analysis -Xuse-old-backend Use the old JVM backend From 103f82c95c39b8cf5e6e559a7d0dd05593bc77d9 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Fri, 6 Nov 2020 13:56:48 +0300 Subject: [PATCH 207/368] IR: an option to automatically select the number of lowering threads --- .../kotlin/cli/common/arguments/K2JVMCompilerArguments.kt | 7 ++++--- .../cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt | 4 +++- .../org/jetbrains/kotlin/config/CommonConfigurationKeys.kt | 2 +- .../kotlin/backend/common/phaser/PhaseBuilders.kt | 2 +- compiler/testData/cli/jvm/extraHelp.out | 7 ++++--- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index 926e80406d6..f04ab6e41f2 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -115,11 +115,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { var doNotClearBindingContext: Boolean by FreezableVar(false) @Argument( - value = "-Xir-threads-for-file-lowerings", + value = "-Xparallel-backend-threads", description = "When using the IR backend, run lowerings by file in N parallel threads.\n" + - "Default value is 1" + "0 means use a thread per processor core.\n" + + "Default value is 1" ) - var threadsForFileLowerings: String by FreezableVar("1") + var parallelBackendThreads: String by FreezableVar("1") @Argument(value = "-Xmodule-path", valueDescription = "", description = "Paths where to find Java 9+ modules") var javaModulePath: String? by NullableStringFreezableVar(null) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt index 932a6482b19..609b21a19bc 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/jvmArguments.kt @@ -292,7 +292,9 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr arguments.declarationsOutputPath?.let { put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, it) } - put(CommonConfigurationKeys.THREADS_FOR_FILE_LOWERINGS, arguments.threadsForFileLowerings.toIntOrNull() ?: 1) + val nThreadsRaw = arguments.parallelBackendThreads.toIntOrNull() ?: 1 + val nThreads = if (nThreadsRaw == 0) Runtime.getRuntime().availableProcessors() else nThreadsRaw + put(CommonConfigurationKeys.PARALLEL_BACKEND_THREADS, nThreads) } fun CompilerConfiguration.configureKlibPaths(arguments: K2JVMCompilerArguments) { diff --git a/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt b/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt index 9e77280ee7a..2f4518f87f5 100644 --- a/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt +++ b/compiler/config/src/org/jetbrains/kotlin/config/CommonConfigurationKeys.kt @@ -52,7 +52,7 @@ object CommonConfigurationKeys { val USE_FIR_EXTENDED_CHECKERS = CompilerConfigurationKey.create("fir extended checkers") @JvmField - val THREADS_FOR_FILE_LOWERINGS = + val PARALLEL_BACKEND_THREADS = CompilerConfigurationKey.create("When using the IR backend, run lowerings by file in N parallel threads") } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt index 89e0b3b50b2..a860fb8f1a8 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt @@ -122,7 +122,7 @@ private class PerformByIrFilePhase( context: Context, input: IrModuleFragment ): IrModuleFragment { - val nThreads = context.configuration.get(CommonConfigurationKeys.THREADS_FOR_FILE_LOWERINGS) ?: 1 + val nThreads = context.configuration.get(CommonConfigurationKeys.PARALLEL_BACKEND_THREADS) ?: 1 return if (nThreads > 1) invokeParallel(phaseConfig, phaserState, context, input, nThreads) else diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index 374d825bcbd..f70bdbf39b3 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -90,6 +90,9 @@ where advanced options include: -Xno-receiver-assertions Don't generate not-null assertion for extension receiver arguments of platform types -Xno-reset-jar-timestamps Do not reset jar entry timestamps to a fixed date -Xno-unified-null-checks Use pre-1.4 exception types in null checks instead of java.lang.NPE. See KT-22275 for more details + -Xparallel-backend-threads When using the IR backend, run lowerings by file in N parallel threads. + 0 means use a thread per processor core. + Default value is 1 -Xprofile= Debug option: Run compiler with async profiler, save snapshots to outputDir, command is passed to async-profiler on start You'll have to provide async-profiler.jar on classpath to use this @@ -122,9 +125,6 @@ where advanced options include: Suppress deprecation warning about deprecated JVM target versions -Xsuppress-missing-builtins-error Suppress the "cannot access built-in declaration" error (useful with -no-stdlib) - -Xir-threads-for-file-lowerings - When using the IR backend, run lowerings by file in N parallel threads. - Default value is 1 -Xuse-ir Use the IR backend -Xuse-javac Use javac for Java source and class files analysis -Xuse-old-backend Use the old JVM backend @@ -193,3 +193,4 @@ where advanced options include: Advanced options are non-standard and may be changed or removed without any notice. OK + From d154c8d8e67b9fbc49b2b888e36863c1cc4f3373 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Mon, 14 Dec 2020 20:15:41 +0300 Subject: [PATCH 208/368] IR: copy each file before lowering. Avoid inter-file dependencies while lowering. --- .../backend/common/CommonBackendContext.kt | 9 +- .../kotlin/backend/common/Mappings.kt | 9 ++ .../backend/common/phaser/CompilerPhase.kt | 4 +- .../backend/common/phaser/PhaseBuilders.kt | 95 ++++++++++++++++++- .../kotlin/ir/backend/js/JsMapping.kt | 6 ++ .../kotlin/backend/jvm/JvmBackendContext.kt | 19 ++++ .../kotlin/ir/util/DeepCopySavingMetadata.kt | 63 ++++++++++++ 7 files changed, 201 insertions(+), 4 deletions(-) create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySavingMetadata.kt diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CommonBackendContext.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CommonBackendContext.kt index 8ac18d2a9fe..29168b8309a 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CommonBackendContext.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CommonBackendContext.kt @@ -13,7 +13,8 @@ import org.jetbrains.kotlin.ir.builders.irCall import org.jetbrains.kotlin.ir.builders.irString import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.util.IdSignature +import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol interface LoggingContext { var inVerbosePhase: Boolean @@ -36,4 +37,10 @@ interface CommonBackendContext : BackendContext, LoggingContext { } val mapping: Mapping + + // Adjust internal structures after a deep copy of some declarations. + fun handleDeepCopy( + classSymbolMap: MutableMap, + functionSymbolMap: MutableMap + ) {} } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Mappings.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Mappings.kt index 96ec8335702..0823832b910 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Mappings.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Mappings.kt @@ -29,6 +29,9 @@ interface Mapping { operator fun setValue(thisRef: K, desc: KProperty<*>, value: V?) { set(thisRef, value) } + + abstract val keys: Set + abstract val values: Collection } } @@ -57,6 +60,12 @@ open class DefaultMapping : Mapping { map[key] = value } } + + override val keys: Set + get() = map.keys + + override val values: Collection + get() = map.values } } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/CompilerPhase.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/CompilerPhase.kt index 4fe63a52b75..35676cdedec 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/CompilerPhase.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/CompilerPhase.kt @@ -13,7 +13,9 @@ class PhaserState( var depth: Int = 0, var phaseCount: Int = 0, val stickyPostconditions: MutableSet> = mutableSetOf() -) +) { + fun copyOf() = PhaserState(alreadyDone.toMutableSet(), depth, phaseCount, stickyPostconditions) +} // Copy state, forgetting the sticky postconditions (which will not be applicable to the new type) fun PhaserState.changeType() = PhaserState(alreadyDone, depth, phaseCount, mutableSetOf()) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt index a860fb8f1a8..5d5c3f73bab 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt @@ -13,6 +13,17 @@ import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment +import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl +import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper +import org.jetbrains.kotlin.ir.util.copyTypeAndValueArgumentsFrom +import org.jetbrains.kotlin.ir.util.deepCopySavingMetadata +import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid +import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid import java.util.concurrent.Executors import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicReference @@ -142,7 +153,7 @@ private class PerformByIrFilePhase( CodegenUtil.reportBackendException(e, "IR lowering", irFile.fileEntry.name) } } - + // TODO: no guarantee that module identity is preserved by `lower` return input } @@ -155,8 +166,13 @@ private class PerformByIrFilePhase( // We can only report one exception through ISE val thrownFromThread = AtomicReference?>(null) + val remappedFunctions = mutableMapOf() + val remappedClasses = mutableMapOf() + // Each thread needs its own copy of phaserState.alreadyDone - val filesAndStates = input.files.map { it to phaserState.clone() } + val filesAndStates = input.files.map { + it.copySavingMappings(remappedFunctions, remappedClasses) to phaserState.copyOf() + } val executor = Executors.newFixedThreadPool(nThreads) for ((irFile, state) in filesAndStates) { @@ -181,6 +197,13 @@ private class PerformByIrFilePhase( // Presumably each thread has run through the same list of phases. phaserState.alreadyDone.addAll(filesAndStates[0].second.alreadyDone) + input.files.clear() + input.files.addAll(filesAndStates.map { (irFile, _) -> irFile }.toMutableList()) + + adjustDefaultArgumentStubs(context, remappedFunctions) + input.transformChildrenVoid(CrossFileCallAdjuster(remappedFunctions)) + context.handleDeepCopy(remappedClasses, remappedFunctions) + // TODO: no guarantee that module identity is preserved by `lower` return input } @@ -256,3 +279,71 @@ fun transform(op: (OldData) - object : CompilerPhase { override fun invoke(phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: OldData) = op(input) } + +// We need to remap inline function calls after lowering files + +fun IrFile.copySavingMappings( + remappedFunctions: MutableMap, + remappedClasses: MutableMap, +): IrFile { + val symbolRemapper = DeepCopySymbolRemapperSavingFunctions() + + val newIrFile = deepCopySavingMetadata(symbolRemapper = symbolRemapper) + + for (function in symbolRemapper.declaredFunctions) { + remappedFunctions[function] = symbolRemapper.getReferencedSimpleFunction(function) + } + for (klass in symbolRemapper.declaredClasses) { + remappedClasses[klass] = symbolRemapper.getReferencedClass(klass) + } + + return newIrFile +} + +private class DeepCopySymbolRemapperSavingFunctions : DeepCopySymbolRemapper() { + val declaredFunctions = mutableSetOf() + val declaredClasses = mutableSetOf() + + override fun getDeclaredFunction(symbol: IrSimpleFunctionSymbol): IrSimpleFunctionSymbol { + declaredFunctions.add(symbol) + return super.getDeclaredFunction(symbol) + } + + override fun getDeclaredClass(symbol: IrClassSymbol): IrClassSymbol { + declaredClasses.add(symbol) + return super.getDeclaredClass(symbol) + } +} + +fun adjustDefaultArgumentStubs( + context: CommonBackendContext, + remappedFunctions: MutableMap, +) { + for (defaultStub in context.mapping.defaultArgumentsOriginalFunction.keys) { + if (defaultStub !is IrSimpleFunction) continue + val original = context.mapping.defaultArgumentsOriginalFunction[defaultStub] as? IrSimpleFunction ?: continue + val originalNew = remappedFunctions[original.symbol]?.owner ?: continue + val defaultStubNew = context.mapping.defaultArgumentsDispatchFunction[originalNew] ?: continue + remappedFunctions[defaultStub.symbol] = defaultStubNew.symbol as IrSimpleFunctionSymbol + } +} + +private class CrossFileCallAdjuster( + val remappedFunctions: Map +) : IrElementTransformerVoid() { + override fun visitCall(expression: IrCall): IrExpression { + expression.transformChildrenVoid(this) + return remappedFunctions[expression.symbol]?.let { newSymbol -> + with(expression) { + IrCallImpl( + startOffset, endOffset, type, + newSymbol, + typeArgumentsCount, valueArgumentsCount, origin, + superQualifierSymbol // TODO + ).apply { + copyTypeAndValueArgumentsFrom(expression) + } + } + } ?: expression + } +} \ No newline at end of file diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsMapping.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsMapping.kt index 1879b045266..4345f89156a 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsMapping.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsMapping.kt @@ -47,5 +47,11 @@ class JsMapping(private val irFactory: IrFactory) : DefaultMapping() { map[key] = value } } + + override val keys: Set + get() = map.keys + + override val values: Collection + get() = map.values } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt index c46c3929030..766bbe9965c 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt @@ -154,6 +154,25 @@ class JvmBackendContext( +irThrow(irNull()) } + override fun handleDeepCopy( + classSymbolMap: MutableMap, + functionSymbolMap: MutableMap + ) { + val oldClassesWithNameOverride = classNameOverride.keys.toList() + for (klass in oldClassesWithNameOverride) { + classSymbolMap[klass.symbol]?.let { newSymbol -> + classNameOverride[newSymbol.owner] = classNameOverride[klass]!! + } + } + for (multifileFacade in multifileFacadesToAdd) { + val oldPartClasses = multifileFacade.value + val newPartClasses = oldPartClasses.map { classSymbolMap[it.symbol]?.owner ?: it } + multifileFacade.setValue(newPartClasses.toMutableList()) + } + + super.handleDeepCopy(classSymbolMap, functionSymbolMap) + } + inner class JvmIr( irModuleFragment: IrModuleFragment, symbolTable: SymbolTable diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySavingMetadata.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySavingMetadata.kt new file mode 100644 index 00000000000..8e0c641fba2 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySavingMetadata.kt @@ -0,0 +1,63 @@ +/* + * Copyright 2010-2020 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.ir.util + +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.visitors.acceptVoid + +fun T.deepCopySavingMetadata( + initialParent: IrDeclarationParent? = null, + symbolRemapper: DeepCopySymbolRemapper = DeepCopySymbolRemapper() +): T { + acceptVoid(symbolRemapper) + val typeRemapper = DeepCopyTypeRemapper(symbolRemapper) + @Suppress("UNCHECKED_CAST") + return transform(DeepCopySavingMetadata(symbolRemapper, typeRemapper, SymbolRenamer.DEFAULT), null) + .patchDeclarationParents(initialParent) as T +} + +private class DeepCopySavingMetadata( + symbolRemapper: SymbolRemapper, + typeRemapper: TypeRemapper, + symbolRenamer: SymbolRenamer +) : DeepCopyIrTreeWithSymbols(symbolRemapper, typeRemapper, symbolRenamer) { + override fun visitFile(declaration: IrFile): IrFile = + super.visitFile(declaration).apply { + metadata = declaration.metadata + } + + override fun visitClass(declaration: IrClass): IrClass = + super.visitClass(declaration).apply { + metadata = declaration.metadata + + } + + override fun visitConstructor(declaration: IrConstructor): IrConstructor = + super.visitConstructor(declaration).apply { + metadata = declaration.metadata + } + + override fun visitSimpleFunction(declaration: IrSimpleFunction): IrSimpleFunction = + super.visitSimpleFunction(declaration).apply { + metadata = declaration.metadata + } + + override fun visitProperty(declaration: IrProperty): IrProperty = + super.visitProperty(declaration).apply { + metadata = declaration.metadata + } + + override fun visitField(declaration: IrField): IrField = + super.visitField(declaration).apply { + metadata = declaration.metadata + } + + override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty): IrLocalDelegatedProperty = + super.visitLocalDelegatedProperty(declaration).apply { + metadata = declaration.metadata + } +} \ No newline at end of file From 54a76977dbe8876c5bef4e0e64a9647e5f7d0efb Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Sun, 10 Jan 2021 13:51:16 +0300 Subject: [PATCH 209/368] IR: fix fake override computation Due to IR copying in performByIrFile, we need to only distinguish overrides up to their fqName. --- .../kotlin/ir/util/IrFakeOverrideUtils.kt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrFakeOverrideUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrFakeOverrideUtils.kt index 5639181114c..02e4499893c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrFakeOverrideUtils.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrFakeOverrideUtils.kt @@ -55,7 +55,12 @@ fun Collection.collectAndFilterRealOverrides( ): Set { val visited = mutableSetOf() - val realOverrides = mutableSetOf() + val realOverrides = mutableMapOf() + + /* + Due to IR copying in performByIrFile, overrides should only be distinguished up to their fqNames. + */ + fun IrOverridableMember.toKey(): Any = fqNameWhenAvailable ?: this fun overriddenSymbols(declaration: IrOverridableMember) = when (declaration) { is IrSimpleFunction -> declaration.overriddenSymbols @@ -69,7 +74,7 @@ fun Collection.collectAndFilterRealOverrides( if (!visited.add(member) || filter(member)) return if (member.isReal && !toSkip(member)) { - realOverrides += member + realOverrides[member.toKey()] = member } else { overriddenSymbols(member).forEach { collectRealOverrides(it.owner as IrOverridableMember) } } @@ -81,15 +86,16 @@ fun Collection.collectAndFilterRealOverrides( if (!visited.add(member)) return overriddenSymbols(member).forEach { - realOverrides.remove(it.owner) - excludeRepeated(it.owner as IrOverridableMember) + val owner = it.owner as IrOverridableMember + realOverrides.remove(owner.toKey()) + excludeRepeated(owner) } } visited.clear() - realOverrides.toList().forEach { excludeRepeated(it) } + realOverrides.toList().forEach { excludeRepeated(it.second) } - return realOverrides + return realOverrides.values.toSet() } // TODO: use this implementation instead of any other From 23da2bde679ab327da3234f90e5780b9d65a039f Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Tue, 12 Jan 2021 17:33:15 +0300 Subject: [PATCH 210/368] IR: fixes for IR by-file copying --- .../backend/common/CommonBackendContext.kt | 2 ++ .../backend/common/phaser/PhaseBuilders.kt | 16 +++++++-- .../kotlin/backend/jvm/JvmBackendContext.kt | 33 ++++++++++++++++++- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CommonBackendContext.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CommonBackendContext.kt index 29168b8309a..170fdf380e3 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CommonBackendContext.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/CommonBackendContext.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.ir.builders.irString import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrFileSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol interface LoggingContext { @@ -40,6 +41,7 @@ interface CommonBackendContext : BackendContext, LoggingContext { // Adjust internal structures after a deep copy of some declarations. fun handleDeepCopy( + fileSymbolMap: MutableMap, classSymbolMap: MutableMap, functionSymbolMap: MutableMap ) {} diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt index 5d5c3f73bab..f9f676401df 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.backend.common.FileLoweringPass import org.jetbrains.kotlin.backend.common.lower import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction @@ -18,6 +19,7 @@ import org.jetbrains.kotlin.ir.expressions.IrCall import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrFileSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper import org.jetbrains.kotlin.ir.util.copyTypeAndValueArgumentsFrom @@ -166,12 +168,13 @@ private class PerformByIrFilePhase( // We can only report one exception through ISE val thrownFromThread = AtomicReference?>(null) + val remappedFiles = mutableMapOf() val remappedFunctions = mutableMapOf() val remappedClasses = mutableMapOf() // Each thread needs its own copy of phaserState.alreadyDone val filesAndStates = input.files.map { - it.copySavingMappings(remappedFunctions, remappedClasses) to phaserState.copyOf() + it.copySavingMappings(remappedFiles, remappedFunctions, remappedClasses) to phaserState.copyOf() } val executor = Executors.newFixedThreadPool(nThreads) @@ -201,8 +204,8 @@ private class PerformByIrFilePhase( input.files.addAll(filesAndStates.map { (irFile, _) -> irFile }.toMutableList()) adjustDefaultArgumentStubs(context, remappedFunctions) + context.handleDeepCopy(remappedFiles, remappedClasses, remappedFunctions) input.transformChildrenVoid(CrossFileCallAdjuster(remappedFunctions)) - context.handleDeepCopy(remappedClasses, remappedFunctions) // TODO: no guarantee that module identity is preserved by `lower` return input @@ -283,6 +286,7 @@ fun transform(op: (OldData) - // We need to remap inline function calls after lowering files fun IrFile.copySavingMappings( + remappedFiles: MutableMap, remappedFunctions: MutableMap, remappedClasses: MutableMap, ): IrFile { @@ -297,6 +301,8 @@ fun IrFile.copySavingMappings( remappedClasses[klass] = symbolRemapper.getReferencedClass(klass) } + remappedFiles[symbol] = newIrFile.symbol + return newIrFile } @@ -331,6 +337,12 @@ fun adjustDefaultArgumentStubs( private class CrossFileCallAdjuster( val remappedFunctions: Map ) : IrElementTransformerVoid() { + + override fun visitSimpleFunction(declaration: IrSimpleFunction): IrStatement { + declaration.overriddenSymbols = declaration.overriddenSymbols.map { remappedFunctions[it] ?: it } + return super.visitSimpleFunction(declaration) + } + override fun visitCall(expression: IrCall): IrExpression { expression.transformChildrenVoid(this) return remappedFunctions[expression.symbol]?.let { newSymbol -> diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt index 766bbe9965c..420c40dd8e1 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt @@ -155,9 +155,18 @@ class JvmBackendContext( } override fun handleDeepCopy( + fileSymbolMap: MutableMap, classSymbolMap: MutableMap, functionSymbolMap: MutableMap ) { + for ((oldFileSymbol, newFileSymbol) in fileSymbolMap) { + val psiFileEntry = psiSourceManager.getFileEntry(oldFileSymbol.owner) as? PsiSourceManager.PsiFileEntry ?: continue + psiSourceManager.putFileEntry( + newFileSymbol.owner, + psiFileEntry + ) + } + val oldClassesWithNameOverride = classNameOverride.keys.toList() for (klass in oldClassesWithNameOverride) { classSymbolMap[klass.symbol]?.let { newSymbol -> @@ -170,7 +179,29 @@ class JvmBackendContext( multifileFacade.setValue(newPartClasses.toMutableList()) } - super.handleDeepCopy(classSymbolMap, functionSymbolMap) + for ((staticReplacement, original) in inlineClassReplacements.originalFunctionForStaticReplacement) { + val newOriginal = functionSymbolMap[original.symbol]?.owner ?: continue + val newStaticReplacement = inlineClassReplacements.getReplacementFunction(newOriginal) ?: continue + staticReplacement as IrSimpleFunction + functionSymbolMap[staticReplacement.symbol] = newStaticReplacement.symbol + } + + for ((original, suspendView) in suspendFunctionOriginalToView) { + val newOriginal = functionSymbolMap[original.symbol]?.owner ?: continue + val newSuspendView = suspendFunctionOriginalToView[newOriginal] ?: continue + suspendView as? IrSimpleFunction ?: continue + newSuspendView as? IrSimpleFunction ?: continue + functionSymbolMap[suspendView.symbol] = newSuspendView.symbol + } + + for ((nonStaticDefaultSymbol, staticDefault) in staticDefaultStubs) { + val staticDefaultSymbol = staticDefault.symbol + val newNonStaticDefaultSymbol = functionSymbolMap[nonStaticDefaultSymbol] ?: continue + val newStaticDefaultSymbol = staticDefaultStubs[newNonStaticDefaultSymbol]?.symbol ?: continue + functionSymbolMap[staticDefaultSymbol] = newStaticDefaultSymbol + } + + super.handleDeepCopy(fileSymbolMap, classSymbolMap, functionSymbolMap) } inner class JvmIr( From 4e9bedc2fc8c7b68bb17bbbd8dd455e65497a384 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Wed, 13 Jan 2021 16:41:09 +0300 Subject: [PATCH 211/368] JVM_IR: use ConcurrentHashMap Replace mutable maps and sets accessed from by-file lowerings with ConcurrentHashMap, so that lowerings can operate on them in parallel. --- .../kotlin/backend/common/Mappings.kt | 3 ++- .../kotlin/backend/jvm/JvmBackendContext.kt | 21 ++++++++++--------- .../backend/jvm/JvmCachedDeclarations.kt | 15 ++++++------- .../jvm/codegen/MethodSignatureMapper.kt | 2 +- .../backend/jvm/lower/BridgeLowering.kt | 3 ++- .../jvm/lower/CollectionStubMethodLowering.kt | 3 ++- .../jvm/lower/JvmInnerClassesSupport.kt | 7 ++++--- .../jvm/lower/SyntheticAccessorLowering.kt | 2 +- .../MemoizedInlineClassReplacements.kt | 5 +++-- 9 files changed, 34 insertions(+), 27 deletions(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Mappings.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Mappings.kt index 0823832b910..eae0583d05f 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Mappings.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/Mappings.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.backend.common import org.jetbrains.kotlin.ir.declarations.* +import java.util.concurrent.ConcurrentHashMap import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty @@ -47,7 +48,7 @@ open class DefaultMapping : Mapping { override val reflectedNameAccessor: Mapping.Delegate = newMapping() protected open fun newMapping() = object : Mapping.Delegate() { - private val map: MutableMap = mutableMapOf() + private val map: MutableMap = ConcurrentHashMap() override operator fun get(key: K): V? { return map[key] diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt index 420c40dd8e1..a6fc57809b4 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt @@ -39,6 +39,7 @@ import org.jetbrains.kotlin.psi2ir.PsiErrorBuilder import org.jetbrains.kotlin.psi2ir.PsiSourceManager import org.jetbrains.kotlin.resolve.jvm.JvmClassName import org.jetbrains.org.objectweb.asm.Type +import java.util.concurrent.ConcurrentHashMap class JvmBackendContext( val state: GenerationState, @@ -55,7 +56,7 @@ class JvmBackendContext( val classNameOverride: MutableMap get() = generatorExtensions.classNameOverride - override val extractedLocalClasses: MutableSet = hashSetOf() + override val extractedLocalClasses: MutableSet = ConcurrentHashMap.newKeySet() override val irFactory: IrFactory = IrFactoryImpl @@ -78,7 +79,7 @@ class JvmBackendContext( val irIntrinsics by lazy { IrIntrinsicMethods(irBuiltIns, ir.symbols) } - private val localClassType = mutableMapOf() + private val localClassType = ConcurrentHashMap() internal fun getLocalClassType(container: IrAttributeContainer): Type? = localClassType[container.attributeOwnerId] @@ -87,18 +88,18 @@ class JvmBackendContext( localClassType[container.attributeOwnerId] = value } - internal val isEnclosedInConstructor = mutableSetOf() + internal val isEnclosedInConstructor = ConcurrentHashMap.newKeySet() internal val classCodegens = mutableMapOf() - val localDelegatedProperties = mutableMapOf>() + val localDelegatedProperties = ConcurrentHashMap>() internal val multifileFacadesToAdd = mutableMapOf>() val multifileFacadeForPart = mutableMapOf() internal val multifileFacadeClassForPart = mutableMapOf() internal val multifileFacadeMemberToPartMember = mutableMapOf() - internal val hiddenConstructors = mutableMapOf() + internal val hiddenConstructors = ConcurrentHashMap() internal val collectionStubComputer = CollectionStubComputer(this) @@ -112,19 +113,19 @@ class JvmBackendContext( overridesWithoutStubs.getOrElse(function) { function.overriddenSymbols } internal val bridgeLoweringCache = BridgeLowering.BridgeLoweringCache(this) - internal val functionsWithSpecialBridges: MutableSet = HashSet() + internal val functionsWithSpecialBridges: MutableSet = ConcurrentHashMap.newKeySet() - override var inVerbosePhase: Boolean = false + override var inVerbosePhase: Boolean = false // TODO: needs parallelizing override val configuration get() = state.configuration override val internalPackageFqn = FqName("kotlin.jvm") - val suspendLambdaToOriginalFunctionMap = mutableMapOf() - val suspendFunctionOriginalToView = mutableMapOf() + val suspendLambdaToOriginalFunctionMap = ConcurrentHashMap() + val suspendFunctionOriginalToView = ConcurrentHashMap() val fakeContinuation: IrExpression = createFakeContinuation(this) - val staticDefaultStubs = mutableMapOf() + val staticDefaultStubs = ConcurrentHashMap() val inlineClassReplacements = MemoizedInlineClassReplacements(state.functionsWithInlineClassReturnTypesMangled, irFactory, this) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt index 5b6c9931e6f..8058b1f6813 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt @@ -30,19 +30,20 @@ import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver +import java.util.concurrent.ConcurrentHashMap class JvmCachedDeclarations( private val context: JvmBackendContext, private val languageVersionSettings: LanguageVersionSettings ) { - private val singletonFieldDeclarations = HashMap() - private val interfaceCompanionFieldDeclarations = HashMap() - private val staticBackingFields = HashMap() + private val singletonFieldDeclarations = ConcurrentHashMap() + private val interfaceCompanionFieldDeclarations = ConcurrentHashMap() + private val staticBackingFields = ConcurrentHashMap() - private val defaultImplsMethods = HashMap() - private val defaultImplsClasses = HashMap() - private val defaultImplsRedirections = HashMap() - private val defaultImplsOriginalMethods = HashMap() + private val defaultImplsMethods = ConcurrentHashMap() + private val defaultImplsClasses = ConcurrentHashMap() + private val defaultImplsRedirections = ConcurrentHashMap() + private val defaultImplsOriginalMethods = ConcurrentHashMap() fun getFieldForEnumEntry(enumEntry: IrEnumEntry): IrField = singletonFieldDeclarations.getOrPut(enumEntry) { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt index 09fb473e718..bc16a88365f 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt @@ -124,7 +124,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { private fun IrSimpleFunction.isInvisibleInMultifilePart(): Boolean = name.asString() != "" && - (parent as? IrClass)?.attributeOwnerId in context.multifileFacadeForPart && + (parent as? IrClass)?.attributeOwnerId in context.multifileFacadeForPart.keys && (DescriptorVisibilities.isPrivate(suspendFunctionOriginal().visibility) || originalForDefaultAdapter?.isInvisibleInMultifilePart() == true) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt index ccbb511e39d..07f17809ae1 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt @@ -37,6 +37,7 @@ import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.Method +import java.util.concurrent.ConcurrentHashMap /* * Generate bridge methods to fix virtual dispatch after type erasure and to adapt Kotlin collections to @@ -595,7 +596,7 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass // It might benefit performance, but can lead to confusing behavior if some declarations are changed along the way. // For example, adding an override for a declaration whose signature is already cached can result in incorrect signature // if its return type is a primitive type, and the new override's return type is an object type. - private val signatureCache = hashMapOf() + private val signatureCache = ConcurrentHashMap() fun computeJvmMethod(function: IrFunction): Method = signatureCache.getOrPut(function.symbol) { context.methodSignatureMapper.mapAsmMethod(function) } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt index 2dbd3e9f69e..c80dd401a2d 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.AbstractTypeChecker import org.jetbrains.kotlin.types.AbstractTypeCheckerContext import org.jetbrains.kotlin.utils.addToStdlib.cast +import java.util.concurrent.ConcurrentHashMap internal val collectionStubMethodLowering = makeIrFilePhase( ::CollectionStubMethodLowering, @@ -469,7 +470,7 @@ internal class CollectionStubComputer(val context: JvmBackendContext) { } } - private val stubsCache = mutableMapOf>() + private val stubsCache = ConcurrentHashMap>() fun stubsForCollectionClasses(irClass: IrClass): List = stubsCache.getOrPut(irClass) { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInnerClassesSupport.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInnerClassesSupport.kt index 75467772513..9a45c70db44 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInnerClassesSupport.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInnerClassesSupport.kt @@ -23,11 +23,12 @@ import org.jetbrains.kotlin.ir.util.dump import org.jetbrains.kotlin.ir.util.parentAsClass import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities import org.jetbrains.kotlin.name.Name +import java.util.concurrent.ConcurrentHashMap class JvmInnerClassesSupport(private val irFactory: IrFactory) : InnerClassesSupport { - private val outerThisDeclarations = HashMap() - private val innerClassConstructors = HashMap() - private val originalInnerClassPrimaryConstructorByClass = HashMap() + private val outerThisDeclarations = ConcurrentHashMap() + private val innerClassConstructors = ConcurrentHashMap() + private val originalInnerClassPrimaryConstructorByClass = ConcurrentHashMap() override fun getOuterThisField(innerClass: IrClass): IrField = outerThisDeclarations.getOrPut(innerClass) { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt index bccad36e16c..7077b5aa87e 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt @@ -217,7 +217,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle private val IrConstructor.isOrShouldBeHidden: Boolean get() { - if (this in context.hiddenConstructors) + if (this in context.hiddenConstructors.keys) return true if (origin == IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER || diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt index 5f85b89f619..1fe8815e2bf 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.InlineClassDescriptorResolver import org.jetbrains.kotlin.storage.LockBasedStorageManager import org.jetbrains.kotlin.utils.addToStdlib.safeAs +import java.util.concurrent.ConcurrentHashMap /** * Keeps track of replacement functions and inline class box/unbox functions. @@ -45,9 +46,9 @@ class MemoizedInlineClassReplacements( private val context: JvmBackendContext ) { private val storageManager = LockBasedStorageManager("inline-class-replacements") - private val propertyMap = mutableMapOf() + private val propertyMap = ConcurrentHashMap() - internal val originalFunctionForStaticReplacement: MutableMap = HashMap() + internal val originalFunctionForStaticReplacement: MutableMap = ConcurrentHashMap() /** * Get a replacement for a function or a constructor. From 57167922e22c67698cfb1c0dfdb2d4e770e1dc62 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Wed, 13 Jan 2021 17:59:52 +0300 Subject: [PATCH 212/368] IR: make lazyVar synchronized --- .../kotlin/ir/declarations/lazy/lazyUtil.kt | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/lazyUtil.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/lazyUtil.kt index 79d9135a90f..7551d6f9205 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/lazyUtil.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/lazyUtil.kt @@ -8,22 +8,30 @@ package org.jetbrains.kotlin.ir.declarations.lazy import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty -fun lazyVar(initializer: () -> T): ReadWriteProperty = UnsafeLazyVar(initializer) +fun lazyVar(initializer: () -> T): ReadWriteProperty = SynchronizedLazyVar(initializer) -private class UnsafeLazyVar(initializer: () -> T) : ReadWriteProperty { +private class SynchronizedLazyVar(initializer: () -> T) : ReadWriteProperty { + @Volatile private var isInitialized = false + private var initializer: (() -> T)? = initializer + + @Volatile private var _value: Any? = null private val value: T get() { - if (!isInitialized) { - _value = initializer!!() - isInitialized = true - initializer = null - } @Suppress("UNCHECKED_CAST") - return _value as T + if (isInitialized) return _value as T + synchronized(this) { + if (!isInitialized) { + _value = initializer!!() + isInitialized = true + initializer = null + } + @Suppress("UNCHECKED_CAST") + return _value as T + } } override fun toString(): String = if (isInitialized) value.toString() else "Lazy value not initialized yet." @@ -31,7 +39,9 @@ private class UnsafeLazyVar(initializer: () -> T) : ReadWriteProperty): T = value override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { - this._value = value - isInitialized = true + synchronized(this) { + this._value = value + isInitialized = true + } } } From 56a26113cdd2eb92832d0e05e6ae400742d3d170 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Thu, 19 Nov 2020 21:39:47 +0300 Subject: [PATCH 213/368] IR: threadLocal To be used for per-file state in global structures during parallel lowering. --- .../org/jetbrains/kotlin/utils/threadLocal.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 compiler/util/src/org/jetbrains/kotlin/utils/threadLocal.kt diff --git a/compiler/util/src/org/jetbrains/kotlin/utils/threadLocal.kt b/compiler/util/src/org/jetbrains/kotlin/utils/threadLocal.kt new file mode 100644 index 00000000000..078bbcdb1ae --- /dev/null +++ b/compiler/util/src/org/jetbrains/kotlin/utils/threadLocal.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2020 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.utils + +import java.util.concurrent.ConcurrentHashMap +import kotlin.properties.ReadWriteProperty +import kotlin.reflect.KProperty + +fun threadLocal(initializer: () -> T): ReadWriteProperty = ThreadLocalDelegate(initializer) + +private class ThreadLocalDelegate(private val initializer: () -> T) : ReadWriteProperty { + private val map = ConcurrentHashMap() + + override operator fun getValue(thisRef: Any?, property: KProperty<*>): T { + return map.getOrPut(Thread.currentThread()) { + initializer() + } + } + + override operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { + map[Thread.currentThread()] = value + } +} \ No newline at end of file From c9d0448fd15f3022887583d88b01b8925766d15b Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Thu, 14 Jan 2021 22:39:27 +0300 Subject: [PATCH 214/368] IR: use threadLocal --- .../ir/util/DeclarationStubGenerator.kt | 2 +- .../jetbrains/kotlin/ir/util/SymbolTable.kt | 19 ++++++++++++++----- .../kotlin/ir/util/TypeTranslator.kt | 5 ++++- .../signature/IdSignatureDescriptor.kt | 6 ++---- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt index 88ce9378197..509a8946974 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeclarationStubGenerator.kt @@ -59,7 +59,7 @@ class DeclarationStubGenerator( lazyTable, languageVersionSettings, moduleDescriptor.builtIns, - LazyScopedTypeParametersResolver(lazyTable), + { LazyScopedTypeParametersResolver(lazyTable) }, true, extensions ) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt index d2eb45738d0..5bc6ef41aca 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.ir.symbols.impl.* import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal +import org.jetbrains.kotlin.utils.threadLocal interface ReferenceSymbolTable { fun referenceClass(descriptor: ClassDescriptor): IrClassSymbol @@ -327,13 +328,21 @@ class SymbolTable( private val typeAliasSymbolTable = FlatSymbolTable() private val globalTypeParameterSymbolTable = FlatSymbolTable() - private val scopedTypeParameterSymbolTable = ScopedSymbolTable() - private val valueParameterSymbolTable = ScopedSymbolTable() - private val variableSymbolTable = ScopedSymbolTable() - private val localDelegatedPropertySymbolTable = + private val scopedTypeParameterSymbolTable by threadLocal { + ScopedSymbolTable() + } + private val valueParameterSymbolTable by threadLocal { + ScopedSymbolTable() + } + private val variableSymbolTable by threadLocal { + ScopedSymbolTable() + } + private val localDelegatedPropertySymbolTable by threadLocal { ScopedSymbolTable() - private val scopedSymbolTables = + } + private val scopedSymbolTables by threadLocal { listOf(valueParameterSymbolTable, variableSymbolTable, scopedTypeParameterSymbolTable, localDelegatedPropertySymbolTable) + } fun referenceExternalPackageFragment(descriptor: PackageFragmentDescriptor) = externalPackageFragmentTable.referenced(descriptor) { IrExternalPackageFragmentSymbolImpl(descriptor) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt index 89b31166083..2d5e2fa39b9 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.types.impl.* import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections import org.jetbrains.kotlin.types.typesApproximation.approximateCapturedTypes +import org.jetbrains.kotlin.utils.threadLocal import java.util.* @OptIn(ObsoleteDescriptorBasedAPI::class) @@ -30,11 +31,13 @@ class TypeTranslator( private val symbolTable: ReferenceSymbolTable, val languageVersionSettings: LanguageVersionSettings, builtIns: KotlinBuiltIns, - private val typeParametersResolver: TypeParametersResolver = ScopedTypeParametersResolver(), + typeParametersResolverBuilder: () -> TypeParametersResolver = { ScopedTypeParametersResolver() }, private val enterTableScope: Boolean = false, private val extensions: StubGeneratorExtensions = StubGeneratorExtensions.EMPTY ) { + private val typeParametersResolver by threadLocal { typeParametersResolverBuilder() } + private val erasureStack = Stack() private val typeApproximatorForNI = TypeApproximator(builtIns) diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/signature/IdSignatureDescriptor.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/signature/IdSignatureDescriptor.kt index 059f80b18bf..d483cc5a28c 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/signature/IdSignatureDescriptor.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/signature/IdSignatureDescriptor.kt @@ -105,17 +105,15 @@ open class IdSignatureDescriptor(private val mangler: KotlinMangler.DescriptorMa reportUnexpectedDescriptor(descriptor) } - private val composer by lazy { createSignatureBuilder() } - override fun composeSignature(descriptor: DeclarationDescriptor): IdSignature? { return if (mangler.run { descriptor.isExported() }) { - composer.buildSignature(descriptor) + createSignatureBuilder().buildSignature(descriptor) } else null } override fun composeEnumEntrySignature(descriptor: ClassDescriptor): IdSignature? { return if (mangler.run { descriptor.isExportEnumEntry() }) { - composer.buildSignature(descriptor) + createSignatureBuilder().buildSignature(descriptor) } else null } } \ No newline at end of file From ec2dc9c0fa7f424e627dfb407cc5bc2225cf0b73 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Fri, 15 Jan 2021 14:17:41 +0300 Subject: [PATCH 215/368] IR: synchronize on SymbolTable operations --- .../jetbrains/kotlin/ir/util/SymbolTable.kt | 154 ++++++++++-------- 1 file changed, 83 insertions(+), 71 deletions(-) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt index 5bc6ef41aca..5178f5cbe76 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/SymbolTable.kt @@ -76,101 +76,113 @@ class SymbolTable( abstract fun get(sig: IdSignature): S? inline fun declare(d: D, createSymbol: () -> S, createOwner: (S) -> B): B { - @Suppress("UNCHECKED_CAST") - val d0 = d.original as D - assert(d0 === d) { - "Non-original descriptor in declaration: $d\n\tExpected: $d0" + synchronized(this) { + @Suppress("UNCHECKED_CAST") + val d0 = d.original as D + assert(d0 === d) { + "Non-original descriptor in declaration: $d\n\tExpected: $d0" + } + val existing = get(d0) + val symbol = if (existing == null) { + val new = createSymbol() + set(new) + new + } else { + unboundSymbols.remove(existing) + existing + } + return createOwner(symbol) } - val existing = get(d0) - val symbol = if (existing == null) { - val new = createSymbol() - set(new) - new - } else { - unboundSymbols.remove(existing) - existing - } - return createOwner(symbol) } @OptIn(ObsoleteDescriptorBasedAPI::class) inline fun declare(sig: IdSignature, createSymbol: () -> S, createOwner: (S) -> B): B { - val existing = get(sig) - val symbol = if (existing == null) { - createSymbol() - } else { - unboundSymbols.remove(existing) - existing + synchronized(this) { + val existing = get(sig) + val symbol = if (existing == null) { + createSymbol() + } else { + unboundSymbols.remove(existing) + existing + } + val result = createOwner(symbol) + // TODO: try to get rid of this + set(symbol) + return result } - val result = createOwner(symbol) - // TODO: try to get rid of this - set(symbol) - return result } inline fun declareIfNotExists(d: D, createSymbol: () -> S, createOwner: (S) -> B): B { - @Suppress("UNCHECKED_CAST") - val d0 = d.original as D - assert(d0 === d) { - "Non-original descriptor in declaration: $d\n\tExpected: $d0" + synchronized(this) { + @Suppress("UNCHECKED_CAST") + val d0 = d.original as D + assert(d0 === d) { + "Non-original descriptor in declaration: $d\n\tExpected: $d0" + } + val existing = get(d0) + val symbol = if (existing == null) { + val new = createSymbol() + set(new) + new + } else { + if (!existing.isBound) unboundSymbols.remove(existing) + existing + } + return if (symbol.isBound) symbol.owner else createOwner(symbol) } - val existing = get(d0) - val symbol = if (existing == null) { - val new = createSymbol() - set(new) - new - } else { - if (!existing.isBound) unboundSymbols.remove(existing) - existing - } - return if (symbol.isBound) symbol.owner else createOwner(symbol) } inline fun declare(sig: IdSignature, d: D?, createSymbol: () -> S, createOwner: (S) -> B): B { - @Suppress("UNCHECKED_CAST") - val d0 = d?.original as D - assert(d0 === d) { - "Non-original descriptor in declaration: $d\n\tExpected: $d0" + synchronized(this) { + @Suppress("UNCHECKED_CAST") + val d0 = d?.original as D + assert(d0 === d) { + "Non-original descriptor in declaration: $d\n\tExpected: $d0" + } + val existing = get(sig) + val symbol = if (existing == null) { + val new = createSymbol() + set(new) + new + } else { + unboundSymbols.remove(existing) + existing + } + return createOwner(symbol) } - val existing = get(sig) - val symbol = if (existing == null) { - val new = createSymbol() - set(new) - new - } else { - unboundSymbols.remove(existing) - existing - } - return createOwner(symbol) } inline fun referenced(d: D, orElse: () -> S): S { - @Suppress("UNCHECKED_CAST") - val d0 = d.original as D - assert(d0 === d) { - "Non-original descriptor in declaration: $d\n\tExpected: $d0" - } - val s = get(d0) - if (s == null) { - val new = orElse() - assert(unboundSymbols.add(new)) { - "Symbol for $new was already referenced" + synchronized(this) { + @Suppress("UNCHECKED_CAST") + val d0 = d.original as D + assert(d0 === d) { + "Non-original descriptor in declaration: $d\n\tExpected: $d0" } - set(new) - return new + val s = get(d0) + if (s == null) { + val new = orElse() + assert(unboundSymbols.add(new)) { + "Symbol for $new was already referenced" + } + set(new) + return new + } + return s } - return s } @OptIn(ObsoleteDescriptorBasedAPI::class) inline fun referenced(sig: IdSignature, orElse: () -> S): S { - return get(sig) ?: run { - val new = orElse() - assert(unboundSymbols.add(new)) { - "Symbol for ${new.signature} was already referenced" + synchronized(this) { + return get(sig) ?: run { + val new = orElse() + assert(unboundSymbols.add(new)) { + "Symbol for ${new.signature} was already referenced" + } + set(new) + new } - set(new) - new } } } From 9cdad272de00cf2340e3b01be7c22c71502f37eb Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Fri, 15 Jan 2021 14:43:15 +0300 Subject: [PATCH 216/368] Fir threadLocal --- .../jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 8e876b364cc..5b57f3a4a54 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -51,6 +51,7 @@ import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource +import org.jetbrains.kotlin.utils.threadLocal @OptIn(ObsoleteDescriptorBasedAPI::class) class Fir2IrDeclarationStorage( @@ -81,7 +82,7 @@ class Fir2IrDeclarationStorage( private val fieldCache = mutableMapOf() - private val localStorage = Fir2IrLocalStorage() + private val localStorage by threadLocal { Fir2IrLocalStorage() } private val delegatedMemberGenerator = DelegatedMemberGenerator(components) From c081bc8d7e2694aa364ee75865b7007fec13e01c Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Fri, 15 Jan 2021 14:45:43 +0300 Subject: [PATCH 217/368] Fir concurrent maps --- .../fir/backend/Fir2IrDeclarationStorage.kt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 5b57f3a4a54..14cff99b06a 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -52,6 +52,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource import org.jetbrains.kotlin.utils.threadLocal +import java.util.concurrent.ConcurrentHashMap @OptIn(ObsoleteDescriptorBasedAPI::class) class Fir2IrDeclarationStorage( @@ -61,26 +62,26 @@ class Fir2IrDeclarationStorage( private val firProvider = session.firProvider - private val fragmentCache = mutableMapOf() + private val fragmentCache = ConcurrentHashMap() - private val builtInsFragmentCache = mutableMapOf() + private val builtInsFragmentCache = ConcurrentHashMap() - private val fileCache = mutableMapOf() + private val fileCache = ConcurrentHashMap() - private val functionCache = mutableMapOf, IrSimpleFunction>() + private val functionCache = ConcurrentHashMap, IrSimpleFunction>() - private val constructorCache = mutableMapOf() + private val constructorCache = ConcurrentHashMap() - private val initializerCache = mutableMapOf() + private val initializerCache = ConcurrentHashMap() - private val propertyCache = mutableMapOf() + private val propertyCache = ConcurrentHashMap() // For pure fields (from Java) only - private val fieldToPropertyCache = mutableMapOf() + private val fieldToPropertyCache = ConcurrentHashMap() - private val delegatedReverseCache = mutableMapOf() + private val delegatedReverseCache = ConcurrentHashMap() - private val fieldCache = mutableMapOf() + private val fieldCache = ConcurrentHashMap() private val localStorage by threadLocal { Fir2IrLocalStorage() } From 445f6eac3dcf92ccc1590b72d8b5ad17743a662b Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Tue, 19 Jan 2021 16:29:10 +0300 Subject: [PATCH 218/368] IR: IrBasedDescriptor fix --- .../org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt index 121ca21ad57..fa875cbd9d6 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt @@ -358,7 +358,7 @@ open class IrBasedVariableDescriptorWithAccessor(owner: IrLocalDelegatedProperty override fun isConst(): Boolean = false - override fun getContainingDeclaration() = (owner.parent as IrFunction).toIrBasedDescriptor() + override fun getContainingDeclaration() = (owner.parent as IrDeclaration).toIrBasedDescriptor() override fun isLateInit(): Boolean = false From 4c701cf44c16bb42df2a1f83fc0f46d19eda5587 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Mon, 1 Feb 2021 13:48:56 +0300 Subject: [PATCH 219/368] IR: make extractedLocalClasses a JS-only field --- .../kotlin/backend/common/BackendContext.kt | 1 - .../common/lower/LocalClassPopupLowering.kt | 24 +++----------- .../common/lower/inline/LocalClasses.kt | 5 ++- .../ir/backend/js/JsIrBackendContext.kt | 2 +- .../kotlin/ir/backend/js/JsLoweringPhases.kt | 5 +-- .../inline/JsRecordExtractedLocalClasses.kt | 32 +++++++++++++++++++ .../kotlin/backend/jvm/JvmBackendContext.kt | 2 -- .../kotlin/backend/wasm/WasmBackendContext.kt | 1 - 8 files changed, 45 insertions(+), 27 deletions(-) create mode 100644 compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/JsRecordExtractedLocalClasses.kt diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/BackendContext.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/BackendContext.kt index d73998a3b67..f9a77c53e0b 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/BackendContext.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/BackendContext.kt @@ -30,6 +30,5 @@ interface BackendContext { val irBuiltIns: IrBuiltIns val sharedVariablesManager: SharedVariablesManager val internalPackageFqn: FqName - val extractedLocalClasses: MutableSet val irFactory: IrFactory } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalClassPopupLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalClassPopupLowering.kt index 39452721e20..48ee707d20e 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalClassPopupLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalClassPopupLowering.kt @@ -8,18 +8,17 @@ package org.jetbrains.kotlin.backend.common.lower import org.jetbrains.kotlin.backend.common.* import org.jetbrains.kotlin.backend.common.ir.addChild import org.jetbrains.kotlin.backend.common.ir.setDeclarationsParent -import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.expressions.IrStatementContainer import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl -import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid -import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid -import org.jetbrains.kotlin.ir.visitors.acceptVoid //This lower takes part of old LocalDeclarationLowering job to pop up local classes from functions -open class LocalClassPopupLowering(val context: BackendContext) : BodyLoweringPass { +open class LocalClassPopupLowering( + val context: BackendContext, + val recordExtractedLocalClasses: BackendContext.(IrClass) -> Unit = {}, +) : BodyLoweringPass { override fun lower(irFile: IrFile) { runOnFilePostfix(irFile, withLocalDeclarations = true, allowDeclarationModification = true) } @@ -78,20 +77,7 @@ open class LocalClassPopupLowering(val context: BackendContext) : BodyLoweringPa } else -> error("Inexpected container type $newContainer") } - - local.acceptVoid(object : IrElementVisitorVoid { - override fun visitElement(element: IrElement) { - element.acceptChildrenVoid(this) - } - - override fun visitBody(body: IrBody) { - } - - override fun visitClass(declaration: IrClass) { - super.visitClass(declaration) - context.extractedLocalClasses += declaration - } - }) + context.recordExtractedLocalClasses(local) } } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/LocalClasses.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/LocalClasses.kt index 938c9a2a823..925b8e7011f 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/LocalClasses.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/LocalClasses.kt @@ -125,7 +125,10 @@ class LocalClassesInInlineFunctionsLowering(val context: CommonBackendContext) : } } -class LocalClassesExtractionFromInlineFunctionsLowering(context: CommonBackendContext) : LocalClassPopupLowering(context) { +class LocalClassesExtractionFromInlineFunctionsLowering( + context: CommonBackendContext, + recordExtractedLocalClasses: BackendContext.(IrClass) -> Unit = {}, +) : LocalClassPopupLowering(context, recordExtractedLocalClasses) { private val classesToExtract = mutableSetOf() override fun lower(irBody: IrBody, container: IrDeclaration) { diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt index 799cfe84db2..d0fd5431ce2 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt @@ -50,7 +50,7 @@ class JsIrBackendContext( val fileToInitializationFuns: MutableMap = mutableMapOf() val fileToInitializerPureness: MutableMap = mutableMapOf() - override val extractedLocalClasses: MutableSet = hashSetOf() + val extractedLocalClasses: MutableSet = hashSetOf() override val builtIns = module.builtIns diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt index f4852f3c3e5..3e0854fa1ba 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsLoweringPhases.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.ir.backend.js.lower.calls.CallsLowering import org.jetbrains.kotlin.ir.backend.js.lower.cleanup.CleanupLowering import org.jetbrains.kotlin.ir.backend.js.lower.coroutines.JsSuspendFunctionsLowering import org.jetbrains.kotlin.ir.backend.js.lower.inline.CopyInlineFunctionBodyLowering +import org.jetbrains.kotlin.ir.backend.js.lower.inline.jsRecordExtractedLocalClasses import org.jetbrains.kotlin.ir.backend.js.lower.inline.RemoveInlineDeclarationsWithReifiedTypeParametersLowering import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment @@ -217,7 +218,7 @@ private val localClassesInInlineFunctionsPhase = makeBodyLoweringPhase( ) private val localClassesExtractionFromInlineFunctionsPhase = makeBodyLoweringPhase( - ::LocalClassesExtractionFromInlineFunctionsLowering, + { context -> LocalClassesExtractionFromInlineFunctionsLowering(context, BackendContext::jsRecordExtractedLocalClasses) }, name = "localClassesExtractionFromInlineFunctionsPhase", description = "Move local classes from inline functions into nearest declaration container", prerequisite = setOf(localClassesInInlineFunctionsPhase) @@ -404,7 +405,7 @@ private val localDeclarationsLoweringPhase = makeBodyLoweringPhase( ) private val localClassExtractionPhase = makeBodyLoweringPhase( - ::LocalClassPopupLowering, + { context -> LocalClassPopupLowering(context, BackendContext::jsRecordExtractedLocalClasses) }, name = "LocalClassExtractionPhase", description = "Move local declarations into nearest declaration container", prerequisite = setOf(localDeclarationsLoweringPhase) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/JsRecordExtractedLocalClasses.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/JsRecordExtractedLocalClasses.kt new file mode 100644 index 00000000000..8c66f3158d2 --- /dev/null +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/JsRecordExtractedLocalClasses.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2021 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.ir.backend.js.lower.inline + +import org.jetbrains.kotlin.backend.common.BackendContext +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext +import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.ir.expressions.IrBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid +import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid +import org.jetbrains.kotlin.ir.visitors.acceptVoid + +fun BackendContext.jsRecordExtractedLocalClasses(irClass: IrClass) { + val context = this as JsIrBackendContext + irClass.acceptVoid(object : IrElementVisitorVoid { + override fun visitElement(element: IrElement) { + element.acceptChildrenVoid(this) + } + + override fun visitBody(body: IrBody) { + } + + override fun visitClass(declaration: IrClass) { + super.visitClass(declaration) + context.extractedLocalClasses += declaration + } + }) +} diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt index a6fc57809b4..c70bc9cacad 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt @@ -56,8 +56,6 @@ class JvmBackendContext( val classNameOverride: MutableMap get() = generatorExtensions.classNameOverride - override val extractedLocalClasses: MutableSet = ConcurrentHashMap.newKeySet() - override val irFactory: IrFactory = IrFactoryImpl override val scriptMode: Boolean = false diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt index a73569d759b..437571d3524 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt @@ -42,7 +42,6 @@ class WasmBackendContext( override val builtIns = module.builtIns override var inVerbosePhase: Boolean = false override val scriptMode = false - override val extractedLocalClasses: MutableSet = hashSetOf() override val irFactory: IrFactory = IrFactoryImpl // Place to store declarations excluded from code generation From cacfe530650b87114b7921fc3b83b65a6973371c Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Mon, 1 Feb 2021 15:52:05 +0300 Subject: [PATCH 220/368] IR: move performByIrFile to a separate .kt --- .../backend/common/phaser/PhaseBuilders.kt | 194 ----------------- .../backend/common/phaser/performByIrFile.kt | 204 ++++++++++++++++++ 2 files changed, 204 insertions(+), 194 deletions(-) create mode 100644 compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/performByIrFile.kt diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt index f9f676401df..feee4277c2e 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/PhaseBuilders.kt @@ -5,30 +5,12 @@ package org.jetbrains.kotlin.backend.common.phaser -import org.jetbrains.kotlin.backend.common.CodegenUtil import org.jetbrains.kotlin.backend.common.CommonBackendContext import org.jetbrains.kotlin.backend.common.FileLoweringPass import org.jetbrains.kotlin.backend.common.lower -import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment -import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction -import org.jetbrains.kotlin.ir.expressions.IrCall -import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl -import org.jetbrains.kotlin.ir.symbols.IrClassSymbol -import org.jetbrains.kotlin.ir.symbols.IrFileSymbol -import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper -import org.jetbrains.kotlin.ir.util.copyTypeAndValueArgumentsFrom -import org.jetbrains.kotlin.ir.util.deepCopySavingMetadata -import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid -import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid -import java.util.concurrent.Executors -import java.util.concurrent.TimeUnit -import java.util.concurrent.atomic.AtomicReference // Phase composition. private class CompositePhase( @@ -116,105 +98,6 @@ fun namedOpUnitPhase( } ) -fun performByIrFile( - name: String = "PerformByIrFile", - description: String = "Perform phases by IrFile", - lower: List> -): NamedCompilerPhase = - NamedCompilerPhase( - name, description, emptySet(), PerformByIrFilePhase(lower), emptySet(), emptySet(), emptySet(), - setOf(defaultDumper), nlevels = 1, - ) - -private class PerformByIrFilePhase( - private val lower: List> -) : SameTypeCompilerPhase { - override fun invoke( - phaseConfig: PhaseConfig, - phaserState: PhaserState, - context: Context, - input: IrModuleFragment - ): IrModuleFragment { - val nThreads = context.configuration.get(CommonConfigurationKeys.PARALLEL_BACKEND_THREADS) ?: 1 - return if (nThreads > 1) - invokeParallel(phaseConfig, phaserState, context, input, nThreads) - else - invokeSequential(phaseConfig, phaserState, context, input) - } - - private fun invokeSequential( - phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: IrModuleFragment - ): IrModuleFragment { - for (irFile in input.files) { - try { - val filePhaserState = phaserState.changeType() - for (phase in lower) { - phase.invoke(phaseConfig, filePhaserState, context, irFile) - } - } catch (e: Throwable) { - CodegenUtil.reportBackendException(e, "IR lowering", irFile.fileEntry.name) - } - } - - // TODO: no guarantee that module identity is preserved by `lower` - return input - } - - private fun invokeParallel( - phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: IrModuleFragment, nThreads: Int - ): IrModuleFragment { - if (input.files.isEmpty()) return input - - // We can only report one exception through ISE - val thrownFromThread = AtomicReference?>(null) - - val remappedFiles = mutableMapOf() - val remappedFunctions = mutableMapOf() - val remappedClasses = mutableMapOf() - - // Each thread needs its own copy of phaserState.alreadyDone - val filesAndStates = input.files.map { - it.copySavingMappings(remappedFiles, remappedFunctions, remappedClasses) to phaserState.copyOf() - } - - val executor = Executors.newFixedThreadPool(nThreads) - for ((irFile, state) in filesAndStates) { - executor.execute { - try { - val filePhaserState = state.changeType() - for (phase in lower) { - phase.invoke(phaseConfig, filePhaserState, context, irFile) - } - } catch (e: Throwable) { - thrownFromThread.set(Pair(e, irFile)) - } - } - } - executor.shutdown() - executor.awaitTermination(1, TimeUnit.DAYS) // Wait long enough - - thrownFromThread.get()?.let { (e, irFile) -> - CodegenUtil.reportBackendException(e, "IrLowering", irFile.fileEntry.name) - } - - // Presumably each thread has run through the same list of phases. - phaserState.alreadyDone.addAll(filesAndStates[0].second.alreadyDone) - - input.files.clear() - input.files.addAll(filesAndStates.map { (irFile, _) -> irFile }.toMutableList()) - - adjustDefaultArgumentStubs(context, remappedFunctions) - context.handleDeepCopy(remappedFiles, remappedClasses, remappedFunctions) - input.transformChildrenVoid(CrossFileCallAdjuster(remappedFunctions)) - - // TODO: no guarantee that module identity is preserved by `lower` - return input - } - - override fun getNamedSubphases(startDepth: Int): List>> = - lower.flatMap { it.getNamedSubphases(startDepth) } -} - fun makeIrFilePhase( lowering: (Context) -> FileLoweringPass, name: String, @@ -282,80 +165,3 @@ fun transform(op: (OldData) - object : CompilerPhase { override fun invoke(phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: OldData) = op(input) } - -// We need to remap inline function calls after lowering files - -fun IrFile.copySavingMappings( - remappedFiles: MutableMap, - remappedFunctions: MutableMap, - remappedClasses: MutableMap, -): IrFile { - val symbolRemapper = DeepCopySymbolRemapperSavingFunctions() - - val newIrFile = deepCopySavingMetadata(symbolRemapper = symbolRemapper) - - for (function in symbolRemapper.declaredFunctions) { - remappedFunctions[function] = symbolRemapper.getReferencedSimpleFunction(function) - } - for (klass in symbolRemapper.declaredClasses) { - remappedClasses[klass] = symbolRemapper.getReferencedClass(klass) - } - - remappedFiles[symbol] = newIrFile.symbol - - return newIrFile -} - -private class DeepCopySymbolRemapperSavingFunctions : DeepCopySymbolRemapper() { - val declaredFunctions = mutableSetOf() - val declaredClasses = mutableSetOf() - - override fun getDeclaredFunction(symbol: IrSimpleFunctionSymbol): IrSimpleFunctionSymbol { - declaredFunctions.add(symbol) - return super.getDeclaredFunction(symbol) - } - - override fun getDeclaredClass(symbol: IrClassSymbol): IrClassSymbol { - declaredClasses.add(symbol) - return super.getDeclaredClass(symbol) - } -} - -fun adjustDefaultArgumentStubs( - context: CommonBackendContext, - remappedFunctions: MutableMap, -) { - for (defaultStub in context.mapping.defaultArgumentsOriginalFunction.keys) { - if (defaultStub !is IrSimpleFunction) continue - val original = context.mapping.defaultArgumentsOriginalFunction[defaultStub] as? IrSimpleFunction ?: continue - val originalNew = remappedFunctions[original.symbol]?.owner ?: continue - val defaultStubNew = context.mapping.defaultArgumentsDispatchFunction[originalNew] ?: continue - remappedFunctions[defaultStub.symbol] = defaultStubNew.symbol as IrSimpleFunctionSymbol - } -} - -private class CrossFileCallAdjuster( - val remappedFunctions: Map -) : IrElementTransformerVoid() { - - override fun visitSimpleFunction(declaration: IrSimpleFunction): IrStatement { - declaration.overriddenSymbols = declaration.overriddenSymbols.map { remappedFunctions[it] ?: it } - return super.visitSimpleFunction(declaration) - } - - override fun visitCall(expression: IrCall): IrExpression { - expression.transformChildrenVoid(this) - return remappedFunctions[expression.symbol]?.let { newSymbol -> - with(expression) { - IrCallImpl( - startOffset, endOffset, type, - newSymbol, - typeArgumentsCount, valueArgumentsCount, origin, - superQualifierSymbol // TODO - ).apply { - copyTypeAndValueArgumentsFrom(expression) - } - } - } ?: expression - } -} \ No newline at end of file diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/performByIrFile.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/performByIrFile.kt new file mode 100644 index 00000000000..1d803aea687 --- /dev/null +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/performByIrFile.kt @@ -0,0 +1,204 @@ +/* + * Copyright 2010-2021 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.backend.common.phaser + +import org.jetbrains.kotlin.backend.common.CodegenUtil +import org.jetbrains.kotlin.backend.common.CommonBackendContext +import org.jetbrains.kotlin.config.CommonConfigurationKeys +import org.jetbrains.kotlin.ir.IrStatement +import org.jetbrains.kotlin.ir.declarations.IrFile +import org.jetbrains.kotlin.ir.declarations.IrModuleFragment +import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl +import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrFileSymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper +import org.jetbrains.kotlin.ir.util.copyTypeAndValueArgumentsFrom +import org.jetbrains.kotlin.ir.util.deepCopySavingMetadata +import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid +import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicReference + +fun performByIrFile( + name: String = "PerformByIrFile", + description: String = "Perform phases by IrFile", + lower: List> +): NamedCompilerPhase = + NamedCompilerPhase( + name, description, emptySet(), PerformByIrFilePhase(lower), emptySet(), emptySet(), emptySet(), + setOf(defaultDumper), nlevels = 1, + ) + +private class PerformByIrFilePhase( + private val lower: List> +) : SameTypeCompilerPhase { + override fun invoke( + phaseConfig: PhaseConfig, + phaserState: PhaserState, + context: Context, + input: IrModuleFragment + ): IrModuleFragment { + val nThreads = context.configuration.get(CommonConfigurationKeys.PARALLEL_BACKEND_THREADS) ?: 1 + return if (nThreads > 1) + invokeParallel(phaseConfig, phaserState, context, input, nThreads) + else + invokeSequential(phaseConfig, phaserState, context, input) + } + + private fun invokeSequential( + phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: IrModuleFragment + ): IrModuleFragment { + for (irFile in input.files) { + try { + val filePhaserState = phaserState.changeType() + for (phase in lower) { + phase.invoke(phaseConfig, filePhaserState, context, irFile) + } + } catch (e: Throwable) { + CodegenUtil.reportBackendException(e, "IR lowering", irFile.fileEntry.name) + } + } + + // TODO: no guarantee that module identity is preserved by `lower` + return input + } + + private fun invokeParallel( + phaseConfig: PhaseConfig, phaserState: PhaserState, context: Context, input: IrModuleFragment, nThreads: Int + ): IrModuleFragment { + if (input.files.isEmpty()) return input + + // We can only report one exception through ISE + val thrownFromThread = AtomicReference?>(null) + + val remappedFiles = mutableMapOf() + val remappedFunctions = mutableMapOf() + val remappedClasses = mutableMapOf() + + // Each thread needs its own copy of phaserState.alreadyDone + val filesAndStates = input.files.map { + it.copySavingMappings(remappedFiles, remappedFunctions, remappedClasses) to phaserState.copyOf() + } + + val executor = Executors.newFixedThreadPool(nThreads) + for ((irFile, state) in filesAndStates) { + executor.execute { + try { + val filePhaserState = state.changeType() + for (phase in lower) { + phase.invoke(phaseConfig, filePhaserState, context, irFile) + } + } catch (e: Throwable) { + thrownFromThread.set(Pair(e, irFile)) + } + } + } + executor.shutdown() + executor.awaitTermination(1, TimeUnit.DAYS) // Wait long enough + + thrownFromThread.get()?.let { (e, irFile) -> + CodegenUtil.reportBackendException(e, "Experimental parallel IR backend", irFile.fileEntry.name) + } + + // Presumably each thread has run through the same list of phases. + phaserState.alreadyDone.addAll(filesAndStates[0].second.alreadyDone) + + input.files.clear() + input.files.addAll(filesAndStates.map { (irFile, _) -> irFile }.toMutableList()) + + adjustDefaultArgumentStubs(context, remappedFunctions) + context.handleDeepCopy(remappedFiles, remappedClasses, remappedFunctions) + input.transformChildrenVoid(CrossFileCallAdjuster(remappedFunctions)) + + // TODO: no guarantee that module identity is preserved by `lower` + return input + } + + override fun getNamedSubphases(startDepth: Int): List>> = + lower.flatMap { it.getNamedSubphases(startDepth) } +} + +// We need to remap inline function calls after lowering files + +fun IrFile.copySavingMappings( + remappedFiles: MutableMap, + remappedFunctions: MutableMap, + remappedClasses: MutableMap, +): IrFile { + val symbolRemapper = DeepCopySymbolRemapperSavingFunctions() + + val newIrFile = deepCopySavingMetadata(symbolRemapper = symbolRemapper) + + for (function in symbolRemapper.declaredFunctions) { + remappedFunctions[function] = symbolRemapper.getReferencedSimpleFunction(function) + } + for (klass in symbolRemapper.declaredClasses) { + remappedClasses[klass] = symbolRemapper.getReferencedClass(klass) + } + + remappedFiles[symbol] = newIrFile.symbol + + return newIrFile +} + +private class DeepCopySymbolRemapperSavingFunctions : DeepCopySymbolRemapper() { + val declaredFunctions = mutableSetOf() + val declaredClasses = mutableSetOf() + + override fun getDeclaredFunction(symbol: IrSimpleFunctionSymbol): IrSimpleFunctionSymbol { + declaredFunctions.add(symbol) + return super.getDeclaredFunction(symbol) + } + + override fun getDeclaredClass(symbol: IrClassSymbol): IrClassSymbol { + declaredClasses.add(symbol) + return super.getDeclaredClass(symbol) + } +} + +private fun adjustDefaultArgumentStubs( + context: CommonBackendContext, + remappedFunctions: MutableMap, +) { + for (defaultStub in context.mapping.defaultArgumentsOriginalFunction.keys) { + if (defaultStub !is IrSimpleFunction) continue + val original = context.mapping.defaultArgumentsOriginalFunction[defaultStub] as? IrSimpleFunction ?: continue + val originalNew = remappedFunctions[original.symbol]?.owner ?: continue + val defaultStubNew = context.mapping.defaultArgumentsDispatchFunction[originalNew] ?: continue + remappedFunctions[defaultStub.symbol] = defaultStubNew.symbol as IrSimpleFunctionSymbol + } +} + +private class CrossFileCallAdjuster( + val remappedFunctions: Map +) : IrElementTransformerVoid() { + + override fun visitSimpleFunction(declaration: IrSimpleFunction): IrStatement { + declaration.overriddenSymbols = declaration.overriddenSymbols.map { remappedFunctions[it] ?: it } + return super.visitSimpleFunction(declaration) + } + + override fun visitCall(expression: IrCall): IrExpression { + expression.transformChildrenVoid(this) + return remappedFunctions[expression.symbol]?.let { newSymbol -> + with(expression) { + IrCallImpl( + startOffset, endOffset, type, + newSymbol, + typeArgumentsCount, valueArgumentsCount, origin, + superQualifierSymbol // TODO + ).apply { + copyTypeAndValueArgumentsFrom(expression) + } + } + } ?: expression + } +} \ No newline at end of file From db18ffc764029aad6a01ea685d5e14c5adea7d39 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Sat, 13 Feb 2021 13:54:04 +0300 Subject: [PATCH 221/368] IR: only worry about threads in JvmIrSignatureDescriptor General IdSignatureDescriptor is used from other backends, which have no multi-threaded backend for now and do not need to carry the associated runtime costs. So IdSignatureDescriptor keeps the thread-unsafe caching of signature builder. --- .../kotlin/fir/analysis/FirAnalyzerFacade.kt | 3 ++- .../signature/IdSignatureDescriptor.kt | 6 ++++-- .../jvm/serialization/JvmIdSignatureDescriptor.kt | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/analysis/FirAnalyzerFacade.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/analysis/FirAnalyzerFacade.kt index e098d1093d7..eb85554d70d 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/analysis/FirAnalyzerFacade.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/analysis/FirAnalyzerFacade.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.analysis import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDescriptor +import org.jetbrains.kotlin.backend.jvm.serialization.JvmIdSignatureDescriptor import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.analysis.collectors.FirDiagnosticsCollector @@ -83,7 +84,7 @@ class FirAnalyzerFacade( fun convertToIr(extensions: GeneratorExtensions): Fir2IrResult { if (scopeSession == null) runResolution() - val signaturer = IdSignatureDescriptor(JvmManglerDesc()) + val signaturer = JvmIdSignatureDescriptor(JvmManglerDesc()) return Fir2IrConverter.createModuleFragment( session, scopeSession!!, firFiles!!, diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/signature/IdSignatureDescriptor.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/signature/IdSignatureDescriptor.kt index d483cc5a28c..059f80b18bf 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/signature/IdSignatureDescriptor.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/signature/IdSignatureDescriptor.kt @@ -105,15 +105,17 @@ open class IdSignatureDescriptor(private val mangler: KotlinMangler.DescriptorMa reportUnexpectedDescriptor(descriptor) } + private val composer by lazy { createSignatureBuilder() } + override fun composeSignature(descriptor: DeclarationDescriptor): IdSignature? { return if (mangler.run { descriptor.isExported() }) { - createSignatureBuilder().buildSignature(descriptor) + composer.buildSignature(descriptor) } else null } override fun composeEnumEntrySignature(descriptor: ClassDescriptor): IdSignature? { return if (mangler.run { descriptor.isExportEnumEntry() }) { - createSignatureBuilder().buildSignature(descriptor) + composer.buildSignature(descriptor) } else null } } \ No newline at end of file diff --git a/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/JvmIdSignatureDescriptor.kt b/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/JvmIdSignatureDescriptor.kt index 05372774c96..bad10b5d8e9 100644 --- a/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/JvmIdSignatureDescriptor.kt +++ b/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/backend/jvm/serialization/JvmIdSignatureDescriptor.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.backend.jvm.serialization import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDescriptor import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.incremental.components.NoLookupLocation +import org.jetbrains.kotlin.ir.util.IdSignature import org.jetbrains.kotlin.ir.util.KotlinMangler import org.jetbrains.kotlin.load.java.descriptors.JavaForKotlinOverridePropertyDescriptor import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe @@ -95,4 +96,18 @@ class JvmIdSignatureDescriptor(private val mangler: KotlinMangler.DescriptorMang } override fun createSignatureBuilder(): DescriptorBasedSignatureBuilder = JvmDescriptorBasedSignatureBuilder(mangler) + + /* In multi-threaded environment, we cannot afford to cache a signature builder, as in IdSignatureBuilder. */ + + override fun composeSignature(descriptor: DeclarationDescriptor): IdSignature? { + return if (mangler.run { descriptor.isExported() }) { + createSignatureBuilder().buildSignature(descriptor) + } else null + } + + override fun composeEnumEntrySignature(descriptor: ClassDescriptor): IdSignature? { + return if (mangler.run { descriptor.isExportEnumEntry() }) { + createSignatureBuilder().buildSignature(descriptor) + } else null + } } \ No newline at end of file From 68cabba698798e41459454faf7d9120e3a7e2673 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Mon, 15 Feb 2021 14:07:33 +0300 Subject: [PATCH 222/368] IR: preserve signatures when copying IrFiles in performByIrFile --- .../backend/common/phaser/performByIrFile.kt | 4 +- .../kotlin/ir/util/DeepCopySymbolRemapper.kt | 30 +++++------ ...pCopySymbolRemapperPreservingSignatures.kt | 54 +++++++++++++++++++ .../kotlin/ir/util/IrFakeOverrideUtils.kt | 4 +- 4 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapperPreservingSignatures.kt diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/performByIrFile.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/performByIrFile.kt index 1d803aea687..9c270533b62 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/performByIrFile.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/phaser/performByIrFile.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrFileSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper +import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapperPreservingSignatures import org.jetbrains.kotlin.ir.util.copyTypeAndValueArgumentsFrom import org.jetbrains.kotlin.ir.util.deepCopySavingMetadata import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid @@ -149,7 +149,7 @@ fun IrFile.copySavingMappings( return newIrFile } -private class DeepCopySymbolRemapperSavingFunctions : DeepCopySymbolRemapper() { +private class DeepCopySymbolRemapperSavingFunctions : DeepCopySymbolRemapperPreservingSignatures() { val declaredFunctions = mutableSetOf() val declaredClasses = mutableSetOf() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt index 2bca5a2e8fa..1abe0783069 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapper.kt @@ -32,21 +32,21 @@ open class DeepCopySymbolRemapper( private val descriptorsRemapper: DescriptorsRemapper = NullDescriptorsRemapper ) : IrElementVisitorVoid, SymbolRemapper { - private val classes = hashMapOf() - private val scripts = hashMapOf() - private val constructors = hashMapOf() - private val enumEntries = hashMapOf() - private val externalPackageFragments = hashMapOf() - private val fields = hashMapOf() - private val files = hashMapOf() - private val functions = hashMapOf() - private val properties = hashMapOf() - private val returnableBlocks = hashMapOf() - private val typeParameters = hashMapOf() - private val valueParameters = hashMapOf() - private val variables = hashMapOf() - private val localDelegatedProperties = hashMapOf() - private val typeAliases = hashMapOf() + protected val classes = hashMapOf() + protected val scripts = hashMapOf() + protected val constructors = hashMapOf() + protected val enumEntries = hashMapOf() + protected val externalPackageFragments = hashMapOf() + protected val fields = hashMapOf() + protected val files = hashMapOf() + protected val functions = hashMapOf() + protected val properties = hashMapOf() + protected val returnableBlocks = hashMapOf() + protected val typeParameters = hashMapOf() + protected val valueParameters = hashMapOf() + protected val variables = hashMapOf() + protected val localDelegatedProperties = hashMapOf() + protected val typeAliases = hashMapOf() override fun visitElement(element: IrElement) { element.acceptChildrenVoid(this) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapperPreservingSignatures.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapperPreservingSignatures.kt new file mode 100644 index 00000000000..ba8aa38f0b2 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopySymbolRemapperPreservingSignatures.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2021 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.ir.util + +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.symbols.impl.* +import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid + +open class DeepCopySymbolRemapperPreservingSignatures : DeepCopySymbolRemapper() { + override fun visitClass(declaration: IrClass) { + remapSymbol(classes, declaration) { symbol -> + symbol.signature?.let { sig -> IrClassPublicSymbolImpl(sig) } ?: IrClassSymbolImpl() + } + declaration.acceptChildrenVoid(this) + } + + override fun visitConstructor(declaration: IrConstructor) { + remapSymbol(constructors, declaration) { symbol -> + symbol.signature?.let { sig -> IrConstructorPublicSymbolImpl(sig) } ?: IrConstructorSymbolImpl() + } + declaration.acceptChildrenVoid(this) + } + + override fun visitEnumEntry(declaration: IrEnumEntry) { + remapSymbol(enumEntries, declaration) { symbol -> + symbol.signature?.let { sig -> IrEnumEntryPublicSymbolImpl(sig) } ?: IrEnumEntrySymbolImpl() + } + declaration.acceptChildrenVoid(this) + } + + override fun visitSimpleFunction(declaration: IrSimpleFunction) { + remapSymbol(functions, declaration) { symbol -> + symbol.signature?.let { sig -> IrSimpleFunctionPublicSymbolImpl(sig) } ?: IrSimpleFunctionSymbolImpl() + } + declaration.acceptChildrenVoid(this) + } + + override fun visitProperty(declaration: IrProperty) { + remapSymbol(properties, declaration) { symbol -> + symbol.signature?.let { sig -> IrPropertyPublicSymbolImpl(sig) } ?: IrPropertySymbolImpl() + } + declaration.acceptChildrenVoid(this) + } + + override fun visitTypeAlias(declaration: IrTypeAlias) { + remapSymbol(typeAliases, declaration) { symbol -> + symbol.signature?.let { sig -> IrTypeAliasPublicSymbolImpl(sig) } ?: IrTypeAliasSymbolImpl() + } + declaration.acceptChildrenVoid(this) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrFakeOverrideUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrFakeOverrideUtils.kt index 02e4499893c..4e60955a217 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrFakeOverrideUtils.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrFakeOverrideUtils.kt @@ -58,9 +58,9 @@ fun Collection.collectAndFilterRealOverrides( val realOverrides = mutableMapOf() /* - Due to IR copying in performByIrFile, overrides should only be distinguished up to their fqNames. + Due to IR copying in performByIrFile, overrides should only be distinguished up to their signatures. */ - fun IrOverridableMember.toKey(): Any = fqNameWhenAvailable ?: this + fun IrOverridableMember.toKey(): Any = symbol.signature ?: this fun overriddenSymbols(declaration: IrOverridableMember) = when (declaration) { is IrSimpleFunction -> declaration.overriddenSymbols From 83343f3a7a2f4d380759f7f82855be1a3df0aeb9 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Tue, 16 Feb 2021 18:21:22 +0300 Subject: [PATCH 223/368] IR: get rid of some type checks in JvmBackendContext --- .../kotlin/backend/jvm/JvmBackendContext.kt | 6 ++-- .../jvm/lower/AddContinuationLowering.kt | 28 +++++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt index c70bc9cacad..b74feeaab0b 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmBackendContext.kt @@ -120,7 +120,7 @@ class JvmBackendContext( override val internalPackageFqn = FqName("kotlin.jvm") val suspendLambdaToOriginalFunctionMap = ConcurrentHashMap() - val suspendFunctionOriginalToView = ConcurrentHashMap() + val suspendFunctionOriginalToView = ConcurrentHashMap() val fakeContinuation: IrExpression = createFakeContinuation(this) val staticDefaultStubs = ConcurrentHashMap() @@ -179,17 +179,15 @@ class JvmBackendContext( } for ((staticReplacement, original) in inlineClassReplacements.originalFunctionForStaticReplacement) { + if (staticReplacement !is IrSimpleFunction) continue val newOriginal = functionSymbolMap[original.symbol]?.owner ?: continue val newStaticReplacement = inlineClassReplacements.getReplacementFunction(newOriginal) ?: continue - staticReplacement as IrSimpleFunction functionSymbolMap[staticReplacement.symbol] = newStaticReplacement.symbol } for ((original, suspendView) in suspendFunctionOriginalToView) { val newOriginal = functionSymbolMap[original.symbol]?.owner ?: continue val newSuspendView = suspendFunctionOriginalToView[newOriginal] ?: continue - suspendView as? IrSimpleFunction ?: continue - newSuspendView as? IrSimpleFunction ?: continue functionSymbolMap[suspendView.symbol] = newSuspendView.symbol } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt index 45f1a89fdeb..c44bc3d8a26 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt @@ -334,20 +334,23 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower // Transform `suspend fun foo(params): RetType` into `fun foo(params, $completion: Continuation): Any?` // the result is called 'view', just to be consistent with old backend. -private fun IrFunction.suspendFunctionViewOrStub(context: JvmBackendContext): IrFunction { +private fun IrSimpleFunction.suspendFunctionViewOrStub(context: JvmBackendContext): IrFunction { if (!isSuspend) return this return context.suspendFunctionOriginalToView.getOrPut(suspendFunctionOriginal()) { createSuspendFunctionStub(context) } } -internal fun IrFunction.suspendFunctionOriginal(): IrFunction = - if (this is IrSimpleFunction && isSuspend && +internal fun IrSimpleFunction.suspendFunctionOriginal(): IrSimpleFunction = + if (isSuspend && !isStaticInlineClassReplacement && !isOrOverridesDefaultParameterStub() && parentAsClass.origin != JvmLoweredDeclarationOrigin.DEFAULT_IMPLS ) - attributeOwnerId as IrFunction + attributeOwnerId as IrSimpleFunction else this +internal fun IrFunction.suspendFunctionOriginal(): IrFunction = + (this as? IrSimpleFunction)?.suspendFunctionOriginal() ?: this + private fun IrSimpleFunction.isOrOverridesDefaultParameterStub(): Boolean = // Cannot use resolveFakeOverride here because of KT-36188. DFS.ifAny( @@ -356,8 +359,8 @@ private fun IrSimpleFunction.isOrOverridesDefaultParameterStub(): Boolean = { it.origin == IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER } ) -private fun IrFunction.createSuspendFunctionStub(context: JvmBackendContext): IrFunction { - require(this.isSuspend && this is IrSimpleFunction) +private fun IrSimpleFunction.createSuspendFunctionStub(context: JvmBackendContext): IrSimpleFunction { + require(this.isSuspend) return factory.buildFun { updateFrom(this@createSuspendFunctionStub) name = this@createSuspendFunctionStub.name @@ -414,12 +417,13 @@ private fun > T.retargetToSuspend copyWithTargetSymbol: T.(IrSimpleFunctionSymbol) -> T ): T { // Calls inside continuation are already generated with continuation parameter as well as calls to suspendImpls - if (!symbol.owner.isSuspend || caller?.isInvokeSuspendOfContinuation() == true - || symbol.owner.origin == JvmLoweredDeclarationOrigin.SUSPEND_IMPL_STATIC_FUNCTION - || symbol.owner.continuationParameter() != null + val owner = symbol.owner + if (owner !is IrSimpleFunction || !owner.isSuspend || caller?.isInvokeSuspendOfContinuation() == true + || owner.origin == JvmLoweredDeclarationOrigin.SUSPEND_IMPL_STATIC_FUNCTION + || owner.continuationParameter() != null ) return this - val view = symbol.owner.suspendFunctionViewOrStub(context) - if (view == symbol.owner) return this + val view = owner.suspendFunctionViewOrStub(context) + if (view == owner) return this // While the new callee technically returns ` | COROUTINE_SUSPENDED`, the latter case is handled // by a method visitor so at an IR overview we don't need to consider it. @@ -439,7 +443,7 @@ private fun > T.retargetToSuspend else IrGetValueImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, caller.continuationParameter()?.symbol - ?: throw AssertionError("${caller.render()} has no continuation; can't call ${symbol.owner.render()}") + ?: throw AssertionError("${caller.render()} has no continuation; can't call ${owner.render()}") ) it.putValueArgument(continuationIndex, continuation) } From 8521d844e245101ae2375fc54aac30ee5fecea70 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 16 Feb 2021 15:16:35 +0300 Subject: [PATCH 224/368] Advance bootstrap to 1.5.20-dev-814 --- gradle.properties | 2 +- libraries/stdlib/api/js-v1/kotlin.kt | 4 +++- libraries/stdlib/api/js/kotlin.kt | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index dca4c7278db..992e2980aad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ kotlin.build.useIR=true #maven.repository.mirror=http://repository.jetbrains.com/remote-repos/ #bootstrap.kotlin.repo=https://dl.bintray.com/kotlin/kotlin-dev #bootstrap.kotlin.version=1.1.50-dev-1451 -bootstrap.kotlin.default.version=1.5.0-dev-2205 +bootstrap.kotlin.default.version=1.5.20-dev-814 kotlin.build.publishing.attempts=20 #signingRequired=true diff --git a/libraries/stdlib/api/js-v1/kotlin.kt b/libraries/stdlib/api/js-v1/kotlin.kt index 8590a2ab5bc..b171cf91d52 100644 --- a/libraries/stdlib/api/js-v1/kotlin.kt +++ b/libraries/stdlib/api/js-v1/kotlin.kt @@ -1061,6 +1061,8 @@ public final class DeepRecursiveFunction { @kotlin.SinceKotlin(version = "1.4") @kotlin.ExperimentalStdlibApi public sealed class DeepRecursiveScope { + protected constructor DeepRecursiveScope() + public abstract suspend fun callRecursive(value: T): R public abstract suspend fun kotlin.DeepRecursiveFunction.callRecursive(value: U): S @@ -2969,4 +2971,4 @@ public final annotation class UseExperimental : kotlin.Annotation { public constructor UseExperimental(vararg markerClass: kotlin.reflect.KClass) public final val markerClass: kotlin.Array> { get; } -} \ No newline at end of file +} diff --git a/libraries/stdlib/api/js/kotlin.kt b/libraries/stdlib/api/js/kotlin.kt index bf897984b45..5651e59e50d 100644 --- a/libraries/stdlib/api/js/kotlin.kt +++ b/libraries/stdlib/api/js/kotlin.kt @@ -1032,6 +1032,8 @@ public final class DeepRecursiveFunction { @kotlin.SinceKotlin(version = "1.4") @kotlin.ExperimentalStdlibApi public sealed class DeepRecursiveScope { + protected constructor DeepRecursiveScope() + public abstract suspend fun callRecursive(value: T): R public abstract suspend fun kotlin.DeepRecursiveFunction.callRecursive(value: U): S @@ -2970,4 +2972,4 @@ public final annotation class UseExperimental : kotlin.Annotation { public constructor UseExperimental(vararg markerClass: kotlin.reflect.KClass) public final val markerClass: kotlin.Array> { get; } -} \ No newline at end of file +} From cdf7de5524a0a4e1ec3f3c64b29054199306504d Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 16 Feb 2021 12:43:25 +0300 Subject: [PATCH 225/368] [FE] Change message for sealed interfaces with language target < 1.5 --- .../kotlin/resolve/checkers/SealedInterfaceAllowedChecker.kt | 2 +- compiler/testData/cli/jvm/internalArgDisableLanguageFeature.out | 2 +- .../tests/sealed/interfaces/sealedInterfacesDisabled.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInterfaceAllowedChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInterfaceAllowedChecker.kt index ae9f92c84a8..e8da70a6617 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInterfaceAllowedChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInterfaceAllowedChecker.kt @@ -18,6 +18,6 @@ object SealedInterfaceAllowedChecker : DeclarationChecker { if (descriptor !is ClassDescriptor) return if (descriptor.kind != ClassKind.INTERFACE) return val keyword = declaration.modifierList?.getModifier(KtTokens.SEALED_KEYWORD) ?: return - context.trace.report(Errors.WRONG_MODIFIER_TARGET.on(keyword, KtTokens.SEALED_KEYWORD, KotlinTarget.INTERFACE.description)) + context.trace.report(Errors.UNSUPPORTED_FEATURE.on(keyword, LanguageFeature.SealedInterfaces to context.languageVersionSettings)) } } diff --git a/compiler/testData/cli/jvm/internalArgDisableLanguageFeature.out b/compiler/testData/cli/jvm/internalArgDisableLanguageFeature.out index a3fd0e1c992..9620adcd8e7 100644 --- a/compiler/testData/cli/jvm/internalArgDisableLanguageFeature.out +++ b/compiler/testData/cli/jvm/internalArgDisableLanguageFeature.out @@ -7,7 +7,7 @@ This mode is not recommended for production use, as no stability/compatibility guarantees are given on compiler or generated code. Use it at your own risk! -compiler/testData/cli/jvm/internalArgDisableLanguageFeature.kt:1:1: error: modifier 'sealed' is not applicable to 'interface' +compiler/testData/cli/jvm/internalArgDisableLanguageFeature.kt:1:1: error: the feature "sealed interfaces" is disabled sealed interface A ^ COMPILATION_ERROR diff --git a/compiler/testData/diagnostics/tests/sealed/interfaces/sealedInterfacesDisabled.kt b/compiler/testData/diagnostics/tests/sealed/interfaces/sealedInterfacesDisabled.kt index 2ba0a7ccbd9..171b49ff4c2 100644 --- a/compiler/testData/diagnostics/tests/sealed/interfaces/sealedInterfacesDisabled.kt +++ b/compiler/testData/diagnostics/tests/sealed/interfaces/sealedInterfacesDisabled.kt @@ -2,4 +2,4 @@ // !LANGUAGE: -SealedInterfaces // !DIAGNOSTICS: -UNUSED_VARIABLE -sealed interface Base +sealed interface Base From 5ce36a528ec50cb00ff7a6ef77c3b5ba5232a220 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 16 Feb 2021 12:50:51 +0300 Subject: [PATCH 226/368] [FE] Prohibit sealed fun interfaces #KT-44947 Fixed --- ...irOldFrontendDiagnosticsTestGenerated.java | 6 ++++ .../checkers/SealedInterfaceAllowedChecker.kt | 10 ++++-- .../interfaces/sealedFunInterface.fir.kt | 15 ++++++++ .../sealed/interfaces/sealedFunInterface.kt | 15 ++++++++ .../sealed/interfaces/sealedFunInterface.txt | 34 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 ++++ 6 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.fir.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 72dfb47b790..76568acc0cd 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -24496,6 +24496,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.kt"); } + @Test + @TestMetadata("sealedFunInterface.kt") + public void testSealedFunInterface() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.kt"); + } + @Test @TestMetadata("sealedInterfacesDisabled.kt") public void testSealedInterfacesDisabled() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInterfaceAllowedChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInterfaceAllowedChecker.kt index e8da70a6617..c2d661947c8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInterfaceAllowedChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInterfaceAllowedChecker.kt @@ -14,10 +14,16 @@ import org.jetbrains.kotlin.psi.KtDeclaration object SealedInterfaceAllowedChecker : DeclarationChecker { override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { - if (context.languageVersionSettings.supportsFeature(LanguageFeature.SealedInterfaces)) return if (descriptor !is ClassDescriptor) return if (descriptor.kind != ClassKind.INTERFACE) return val keyword = declaration.modifierList?.getModifier(KtTokens.SEALED_KEYWORD) ?: return - context.trace.report(Errors.UNSUPPORTED_FEATURE.on(keyword, LanguageFeature.SealedInterfaces to context.languageVersionSettings)) + val diagnostic = if (context.languageVersionSettings.supportsFeature(LanguageFeature.SealedInterfaces)) { + if (descriptor.isFun) { + Errors.UNSUPPORTED.on(keyword, "sealed fun interfaces") + } else return + } else { + Errors.UNSUPPORTED_FEATURE.on(keyword, LanguageFeature.SealedInterfaces to context.languageVersionSettings) + } + context.trace.report(diagnostic) } } diff --git a/compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.fir.kt b/compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.fir.kt new file mode 100644 index 00000000000..d6f8dbd57e9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.fir.kt @@ -0,0 +1,15 @@ +sealed fun interface A { // error + fun foo() +} + +sealed interface Base { + sealed fun interface Derived : Base { // error + fun foo() + } +} + +sealed interface IBase { + fun interface IDerived : IBase { // OK + fun foo() + } +} diff --git a/compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.kt b/compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.kt new file mode 100644 index 00000000000..ba4ae885b42 --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.kt @@ -0,0 +1,15 @@ +sealed fun interface A { // error + fun foo() +} + +sealed interface Base { + sealed fun interface Derived : Base { // error + fun foo() + } +} + +sealed interface IBase { + fun interface IDerived : IBase { // OK + fun foo() + } +} diff --git a/compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.txt b/compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.txt new file mode 100644 index 00000000000..6c7a6f55aba --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.txt @@ -0,0 +1,34 @@ +package + +public sealed fun interface A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public sealed interface Base { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public sealed fun interface Derived : Base { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public sealed interface IBase { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public fun interface IDerived : IBase { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 4c1b71b8aba..6e7bb6e4ed0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -24586,6 +24586,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.kt"); } + @Test + @TestMetadata("sealedFunInterface.kt") + public void testSealedFunInterface() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/interfaces/sealedFunInterface.kt"); + } + @Test @TestMetadata("sealedInterfacesDisabled.kt") public void testSealedInterfacesDisabled() throws Exception { From 373bc578fb345dfbae2756e2dc2f7b67c8615589 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 3 Feb 2021 11:44:55 +0300 Subject: [PATCH 227/368] [FIR] Implement capturing of cone types same as for kotlin types --- .../kotlin/fir/symbols/StandardClassIds.kt | 21 +++ .../kotlin/fir/resolve/dfa/LogicSystem.kt | 2 +- .../types/ConeFlexibleTypeBoundsChecker.kt | 41 +++++ .../kotlin/fir/types/ConeInferenceContext.kt | 4 - .../kotlin/fir/types/ConeTypeContext.kt | 63 +------ .../jetbrains/kotlin/fir/types/TypeUtils.kt | 159 ++++++++++++++++++ .../overloadConflicts/withVariance.fir.kt | 2 +- .../diagnostics/notLinked/dfa/pos/13.fir.kt | 12 +- .../diagnostics/notLinked/dfa/pos/18.fir.kt | 12 +- 9 files changed, 243 insertions(+), 73 deletions(-) create mode 100644 compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeFlexibleTypeBoundsChecker.kt diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt index 3e6a7f66f4c..6b66168a79a 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt @@ -14,10 +14,12 @@ object StandardClassIds { val BASE_KOTLIN_PACKAGE = FqName("kotlin") val BASE_REFLECT_PACKAGE = BASE_KOTLIN_PACKAGE.child(Name.identifier("reflect")) + val BASE_COLLECTIONS_PACKAGE = BASE_KOTLIN_PACKAGE.child(Name.identifier("collections")) private fun String.baseId() = ClassId(BASE_KOTLIN_PACKAGE, Name.identifier(this)) private fun ClassId.unsignedId() = ClassId(BASE_KOTLIN_PACKAGE, Name.identifier("U" + shortClassName.identifier)) private fun String.reflectId() = ClassId(BASE_REFLECT_PACKAGE, Name.identifier(this)) private fun Name.primitiveArrayId() = ClassId(Array.packageFqName, Name.identifier(identifier + Array.shortClassName.identifier)) + private fun String.collectionsId() = ClassId(BASE_COLLECTIONS_PACKAGE, Name.identifier(this)) val Nothing = "Nothing".baseId() val Unit = "Unit".baseId() @@ -85,6 +87,25 @@ object StandardClassIds { return "Function$n".baseId() } + val Iterator = "Iterator".collectionsId() + val Iterable = "Iterable".collectionsId() + val Collection = "Collection".collectionsId() + val List = "List".collectionsId() + val ListIterator = "ListIterator".collectionsId() + val Set = "Set".collectionsId() + val Map = "Map".collectionsId() + val MutableIterator = "MutableIterator".collectionsId() + + val MutableIterable = "MutableIterable".collectionsId() + val MutableCollection = "MutableCollection".collectionsId() + val MutableList = "MutableList".collectionsId() + val MutableListIterator = "MutableListIterator".collectionsId() + val MutableSet = "MutableSet".collectionsId() + val MutableMap = "MutableMap".collectionsId() + + val MapEntry = Map.createNestedClassId(Name.identifier("Entry")) + val MutableMapEntry = MutableMap.createNestedClassId(Name.identifier("MutableEntry")) + val Suppress = "Suppress".baseId() } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt index 5b3b04c16a3..ed7d56fdac6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt @@ -143,7 +143,7 @@ abstract class LogicSystem(protected val context: ConeInferenceCont if (types.any { it.isEmpty() }) return mutableSetOf() val intersectedTypes = types.map { if (it.size > 1) { - context.intersectTypes(it.toList()) as ConeKotlinType + context.intersectTypes(it.toList()) } else { assert(it.size == 1) { "We've already checked each set of types is not empty." } it.single() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeFlexibleTypeBoundsChecker.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeFlexibleTypeBoundsChecker.kt new file mode 100644 index 00000000000..675bd2f8cf0 --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeFlexibleTypeBoundsChecker.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2021 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.fir.types + +import org.jetbrains.kotlin.builtins.StandardNames +import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.name.ClassId + +object ConeFlexibleTypeBoundsChecker { + private val fqNames = StandardNames.FqNames + private val baseTypesToMutableEquivalent = mapOf( + StandardClassIds.Iterable to StandardClassIds.MutableIterable, + StandardClassIds.Iterator to StandardClassIds.MutableIterator, + StandardClassIds.ListIterator to StandardClassIds.MutableListIterator, + StandardClassIds.List to StandardClassIds.MutableList, + StandardClassIds.Collection to StandardClassIds.MutableCollection, + StandardClassIds.Set to StandardClassIds.MutableSet, + StandardClassIds.Map to StandardClassIds.MutableMap, + StandardClassIds.MapEntry to StandardClassIds.MutableMapEntry + ) + private val mutableToBaseMap = baseTypesToMutableEquivalent.entries.associateBy({ it.value }) { it.key } + + fun areTypesMayBeLowerAndUpperBoundsOfSameFlexibleTypeByMutability(a: ConeKotlinType, b: ConeKotlinType): Boolean { + val classId = a.classId ?: return false + val possiblePairBound = (baseTypesToMutableEquivalent[classId] ?: mutableToBaseMap[classId]) ?: return false + + return possiblePairBound == b.classId + } + + // We consider base bounds as not mutable collections + fun getBaseBoundFqNameByMutability(a: ConeKotlinType): ClassId? { + val classId = a.classId ?: return null + + if (classId in baseTypesToMutableEquivalent) return classId + + return mutableToBaseMap[classId] + } +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt index 4c2c0a9c5c3..b70a0b5a4a5 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt @@ -340,10 +340,6 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo return false } - override fun captureFromExpression(type: KotlinTypeMarker): KotlinTypeMarker? { - return type - } - override fun createErrorType(debugName: String): ConeClassErrorType { return ConeClassErrorType(ConeIntermediateDiagnostic(debugName)) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt index e424d75d3ab..4fec0ecf1af 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt @@ -228,9 +228,8 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty private fun TypeConstructorMarker.toClassLikeSymbol(): FirClassLikeSymbol<*>? = (this as? ConeClassLikeLookupTag)?.toSymbol(session) - override fun TypeConstructorMarker.supertypes(): Collection { + override fun TypeConstructorMarker.supertypes(): Collection { if (this is ErrorTypeConstructor) return emptyList() - //require(this is ConeSymbol) return when (this) { is ConeTypeVariableTypeConstructor -> emptyList() is ConeTypeParameterLookupTag -> symbol.fir.bounds.map { it.coneType } @@ -307,56 +306,14 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty fir.classKind != ClassKind.ANNOTATION_CLASS } + override fun captureFromExpression(type: KotlinTypeMarker): KotlinTypeMarker? { + require(type is ConeKotlinType) + return captureFromExpressionInternal(type) + } + override fun captureFromArguments(type: SimpleTypeMarker, status: CaptureStatus): SimpleTypeMarker? { require(type is ConeKotlinType) - val argumentsCount = type.typeArguments.size - if (argumentsCount == 0) return null - - val typeConstructor = type.typeConstructor() - if (argumentsCount != typeConstructor.parametersCount()) return null - - if (type.typeArguments.all { it !is ConeStarProjection && it.kind == ProjectionKind.INVARIANT }) return null - - val newArguments = Array(argumentsCount) { index -> - val argument = type.typeArguments[index] - if (argument !is ConeStarProjection && argument.kind == ProjectionKind.INVARIANT) return@Array argument - - val lowerType = if (argument !is ConeStarProjection && argument.getVariance() == TypeVariance.IN) { - (argument as ConeKotlinTypeProjection).type - } else { - null - } - - ConeCapturedType(status, lowerType, argument, typeConstructor.getParameter(index)) - } - - val substitutor = substitutorByMap((0 until argumentsCount).map { index -> - (typeConstructor.getParameter(index) as ConeTypeParameterLookupTag).symbol to (newArguments[index] as ConeKotlinType) - }.toMap()) - - for (index in 0 until argumentsCount) { - val oldArgument = type.typeArguments[index] - val newArgument = newArguments[index] - - if (oldArgument !is ConeStarProjection && oldArgument.kind == ProjectionKind.INVARIANT) continue - - val parameter = typeConstructor.getParameter(index) - val upperBounds = (0 until parameter.upperBoundCount()).mapTo(mutableListOf()) { paramIndex -> - substitutor.safeSubstitute( - this as TypeSystemInferenceExtensionContext, parameter.getUpperBound(paramIndex) - ) - } - - if (!oldArgument.isStarProjection() && oldArgument.getVariance() == TypeVariance.OUT) { - upperBounds += oldArgument.getType() - } - - require(newArgument is ConeCapturedType) - @Suppress("UNCHECKED_CAST") - newArgument.constructor.supertypes = upperBounds as List - } - - return type.withArguments(newArguments) + return captureFromArgumentsInternal(type, status) as SimpleTypeMarker? } override fun SimpleTypeMarker.asArgumentList(): TypeArgumentListMarker { @@ -392,10 +349,6 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty typeConstructor is ConeTypeParameterLookupTag } - override fun captureFromExpression(type: KotlinTypeMarker): KotlinTypeMarker? { - TODO("not implemented") - } - override fun SimpleTypeMarker.isPrimitiveType(): Boolean { if (this is ConeClassLikeType) { return StandardClassIds.primitiveTypes.contains(this.lookupTag.classId) @@ -417,7 +370,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty return ConeTypeIntersector.intersectTypes(this as ConeInferenceContext, types as List) as SimpleTypeMarker } - override fun intersectTypes(types: List): KotlinTypeMarker { + override fun intersectTypes(types: List): ConeKotlinType { @Suppress("UNCHECKED_CAST") return ConeTypeIntersector.intersectTypes(this as ConeInferenceContext, types as List) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt index b43f0ee261d..3a18b53a1f4 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt @@ -11,8 +11,10 @@ import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.classId import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic import org.jetbrains.kotlin.fir.resolve.fullyExpandedType +import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLookupTagWithFixedSymbol import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef @@ -22,6 +24,7 @@ import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator import org.jetbrains.kotlin.types.AbstractStrictEqualityTypeChecker import org.jetbrains.kotlin.types.AbstractTypeApproximator import org.jetbrains.kotlin.types.TypeApproximatorConfiguration +import org.jetbrains.kotlin.types.model.* fun ConeInferenceContext.commonSuperTypeOrNull(types: List): ConeKotlinType? { return when (types.size) { @@ -322,3 +325,159 @@ private fun FirTypeRef.hideLocalTypeIfNeeded( return this } +fun ConeTypeContext.captureFromArgumentsInternal(type: ConeKotlinType, status: CaptureStatus): ConeKotlinType? { + val capturedArguments = captureArguments(type, status) ?: return null + return if (type is ConeFlexibleType) { + ConeFlexibleType( + type.lowerBound.withArguments(capturedArguments), + type.upperBound.withArguments(capturedArguments), + ) + } else { + type.withArguments(capturedArguments) + } +} + +private fun ConeTypeContext.captureArguments(type: ConeKotlinType, status: CaptureStatus): Array? { + val argumentsCount = type.typeArguments.size + if (argumentsCount == 0) return null + + val typeConstructor = type.typeConstructor() + if (argumentsCount != typeConstructor.parametersCount()) return null + + if (type.typeArguments.all { it !is ConeStarProjection && it.kind == ProjectionKind.INVARIANT }) return null + + val newArguments = Array(argumentsCount) { index -> + val argument = type.typeArguments[index] + if (argument !is ConeStarProjection && argument.kind == ProjectionKind.INVARIANT) return@Array argument + + val lowerType = if (argument !is ConeStarProjection && argument.getVariance() == TypeVariance.IN) { + (argument as ConeKotlinTypeProjection).type + } else { + null + } + + ConeCapturedType(status, lowerType, argument, typeConstructor.getParameter(index)) + } + + val substitutor = substitutorByMap((0 until argumentsCount).map { index -> + (typeConstructor.getParameter(index) as ConeTypeParameterLookupTag).symbol to (newArguments[index] as ConeKotlinType) + }.toMap()) + + for (index in 0 until argumentsCount) { + val oldArgument = type.typeArguments[index] + val newArgument = newArguments[index] + + if (oldArgument !is ConeStarProjection && oldArgument.kind == ProjectionKind.INVARIANT) continue + + val parameter = typeConstructor.getParameter(index) + val upperBounds = (0 until parameter.upperBoundCount()).mapTo(mutableListOf()) { paramIndex -> + substitutor.safeSubstitute( + this as TypeSystemInferenceExtensionContext, parameter.getUpperBound(paramIndex) + ) + } + + if (!oldArgument.isStarProjection() && oldArgument.getVariance() == TypeVariance.OUT) { + upperBounds += oldArgument.getType() + } + + require(newArgument is ConeCapturedType) + @Suppress("UNCHECKED_CAST") + newArgument.constructor.supertypes = upperBounds as List + } + return newArguments +} + +fun ConeTypeContext.captureFromExpressionInternal(type: ConeKotlinType): ConeKotlinType? { + if (type !is ConeIntersectionType && type !is ConeFlexibleType) { + return captureFromArgumentsInternal(type, CaptureStatus.FROM_EXPRESSION) + } + /* + * We capture arguments in the intersection types in specific way: + * 1) Firstly, we create captured arguments for all type arguments grouped by a type constructor* and a type argument's type. + * It means, that we create only one captured argument for two types `Foo<*>` and `Foo<*>?` within a flexible type, for instance. + * * In addition to grouping by type constructors, we look at possibility locating of two types in different bounds of the same flexible type. + * This is necessary in order to create the same captured arguments, + * for example, for `MutableList` in the lower bound of the flexible type and for `List` in the upper one. + * Example: MutableList<*>..List<*>? -> MutableList..List?, Captured1(*) and Captured2(*) are the same. + * 2) Secondly, we replace type arguments with captured arguments by given a type constructor and type arguments. + */ + val capturedArgumentsByComponents = captureArgumentsForIntersectionType(type) ?: return null + + // We reuse `TypeToCapture` for some types, suitability to reuse defines by `isSuitableForType` + fun findCorrespondingCapturedArgumentsForType(type: ConeKotlinType) = + capturedArgumentsByComponents.find { typeToCapture -> typeToCapture.isSuitableForType(type, this) }?.capturedArguments + + fun replaceArgumentsWithCapturedArgumentsByIntersectionComponents(typeToReplace: ConeKotlinType): List { + return if (typeToReplace is ConeIntersectionType) { + typeToReplace.intersectedTypes.map { componentType -> + val capturedArguments = findCorrespondingCapturedArgumentsForType(componentType) + ?: return@map componentType + componentType.withArguments(capturedArguments) + } + } else { + val capturedArguments = findCorrespondingCapturedArgumentsForType(typeToReplace) + ?: return listOf(typeToReplace) + listOf(typeToReplace.withArguments(capturedArguments)) + } + } + + return if (type is ConeFlexibleType) { + val lowerIntersectedType = intersectTypes(replaceArgumentsWithCapturedArgumentsByIntersectionComponents(type.lowerBound)) + .withNullability(type.lowerBound.isMarkedNullable) as ConeKotlinType + val upperIntersectedType = intersectTypes(replaceArgumentsWithCapturedArgumentsByIntersectionComponents(type.upperBound)) + .withNullability(type.upperBound.isMarkedNullable) as ConeKotlinType + + ConeFlexibleType(lowerIntersectedType, upperIntersectedType) + } else { + intersectTypes(replaceArgumentsWithCapturedArgumentsByIntersectionComponents(type)).withNullability(type.isMarkedNullable) as ConeKotlinType + } +} + +private fun ConeTypeContext.captureArgumentsForIntersectionType(type: ConeKotlinType): List? { + // It's possible to have one of the bounds as non-intersection type + fun getTypesToCapture(type: ConeKotlinType) = + if (type is ConeIntersectionType) type.intersectedTypes else listOf(type) + + val filteredTypesToCapture = + when (type) { + is ConeFlexibleType -> { + val typesToCapture = getTypesToCapture(type.lowerBound) + getTypesToCapture(type.upperBound) + typesToCapture.distinctBy { + (ConeFlexibleTypeBoundsChecker.getBaseBoundFqNameByMutability(it) ?: it.typeConstructor(this)) to it.typeArguments + } + } + is ConeIntersectionType -> type.intersectedTypes + else -> error("Should not be here") + } + + var changed = false + + val capturedArgumentsByTypes = filteredTypesToCapture.mapNotNull { typeToCapture -> + val capturedArguments = captureArguments(typeToCapture, CaptureStatus.FROM_EXPRESSION) + ?: return@mapNotNull null + changed = true + CapturedArguments(capturedArguments, originalType = typeToCapture) + } + + if (!changed) return null + + return capturedArgumentsByTypes +} + +private class CapturedArguments(val capturedArguments: Array, private val originalType: ConeKotlinType) { + fun isSuitableForType(type: ConeKotlinType, context: ConeTypeContext): Boolean { + val areArgumentsMatched = type.typeArguments.withIndex().all { (i, typeArgumentsType) -> + originalType.typeArguments.size > i && typeArgumentsType == originalType.typeArguments[i] + } + + if (!areArgumentsMatched) return false + + val areConstructorsMatched = originalType.typeConstructor(context) == type.typeConstructor(context) + || ConeFlexibleTypeBoundsChecker.areTypesMayBeLowerAndUpperBoundsOfSameFlexibleTypeByMutability(originalType, type) + + if (!areConstructorsMatched) return false + + return true + } +} + diff --git a/compiler/testData/diagnostics/tests/resolve/overloadConflicts/withVariance.fir.kt b/compiler/testData/diagnostics/tests/resolve/overloadConflicts/withVariance.fir.kt index 9a0af8f0569..b02cbaad936 100644 --- a/compiler/testData/diagnostics/tests/resolve/overloadConflicts/withVariance.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/overloadConflicts/withVariance.fir.kt @@ -7,4 +7,4 @@ class A fun A.foo() = X1 fun A.foo() = X2 -fun A.test() = foo() // TODO fix constraint system +fun A.test() = foo() // TODO fix constraint system diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt index 48459ac32c3..23c7c7c13e9 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt @@ -10,29 +10,29 @@ fun case_1(x: T) { x x.equals(null) x.propT - x.propAny + x.propAny x.propNullableT x.propNullableAny x.funT() - x.funAny() + x.funAny() x.funNullableT() x.funNullableAny() x.apply { equals(null) } x.apply { propT } - x.apply { propAny } + x.apply { propAny } x.apply { propNullableT } x.apply { propNullableAny } x.apply { funT() } - x.apply { funAny() } + x.apply { funAny() } x.apply { funNullableT() } x.apply { funNullableAny(); x.equals(null) } x.also { it.equals(null) } x.also { it.propT } - x.also { it.propAny } + x.also { it.propAny } x.also { it.propNullableT } x.also { it.propNullableAny } x.also { it.funT() } - x.also { it.funAny() } + x.also { it.funAny() } x.also { it.funNullableT() } x.also { it.funNullableAny() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt index 9d52ae3f312..e7c9655bddf 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/18.fir.kt @@ -246,11 +246,11 @@ fun case_18(x: T, f: Boolean) { x x.equals(null) x.propT - x.propAny + x.propAny x.propNullableT x.propNullableAny x.funT() - x.funAny() + x.funAny() x.funNullableT() x.funNullableAny() } @@ -263,21 +263,21 @@ fun case_19(map: MutableMap, y: Nothing?) { k k.equals(null) k.propT - k.propAny + k.propAny k.propNullableT k.propNullableAny k.funT() - k.funAny() + k.funAny() k.funNullableT() k.funNullableAny() v v.equals(null) v.propT - v.propAny + v.propAny v.propNullableT v.propNullableAny v.funT() - v.funAny() + v.funAny() v.funNullableT() v.funNullableAny() } From 57d29009eefb01c06d89dbaa99aaf6ca691c7e78 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 3 Feb 2021 12:25:50 +0300 Subject: [PATCH 228/368] [FIR] Fix TODOs and cleanup ConeTypeContext and ConeInferenceContext --- .../fir/declarations/InlineClassesUtils.kt | 31 +++++++++++ .../fir/resolve/substitution/Substitutors.kt | 16 ++++++ .../jetbrains/kotlin/fir/types/ArrayUtils.kt | 2 +- .../kotlin/fir/types/ConeInferenceContext.kt | 33 ++++------- .../kotlin/fir/types/ConeTypeContext.kt | 55 ++++++++++--------- 5 files changed, 86 insertions(+), 51 deletions(-) create mode 100644 compiler/fir/resolve/src/org/jetbrains/kotlin/fir/declarations/InlineClassesUtils.kt diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/declarations/InlineClassesUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/declarations/InlineClassesUtils.kt new file mode 100644 index 00000000000..a461821e11a --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/declarations/InlineClassesUtils.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2021 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.fir.declarations + +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.resolve.fullyExpandedType +import org.jetbrains.kotlin.fir.resolve.substitution.createTypeSubstitutorByTypeConstructor +import org.jetbrains.kotlin.fir.resolve.toSymbol +import org.jetbrains.kotlin.fir.resolve.transformers.ensureResolved +import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.types.model.typeConstructor + +fun ConeKotlinType.substitutedUnderlyingTypeForInlineClass(session: FirSession, context: ConeTypeContext): ConeKotlinType? { + val symbol = (this.fullyExpandedType(session) as? ConeLookupTagBasedType) + ?.lookupTag + ?.toSymbol(session) as? FirRegularClassSymbol + ?: return null + symbol.ensureResolved(FirResolvePhase.STATUS, session) + val firClass = symbol.fir + if (!firClass.status.isInline) return null + val constructor = firClass.declarations.singleOrNull { it is FirConstructor && it.isPrimary } as FirConstructor? ?: return null + val valueParameter = constructor.valueParameters.singleOrNull() ?: return null + val unsubstitutedType = valueParameter.returnTypeRef.coneType + + val substitutor = createTypeSubstitutorByTypeConstructor(mapOf(this.typeConstructor(context) to this), context) + return substitutor.substituteOrNull(unsubstitutedType) +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/Substitutors.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/Substitutors.kt index 9f79646b701..2305d17099f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/Substitutors.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/Substitutors.kt @@ -10,6 +10,10 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.types.TypeApproximatorConfiguration +import org.jetbrains.kotlin.types.model.KotlinTypeMarker +import org.jetbrains.kotlin.types.model.TypeConstructorMarker +import org.jetbrains.kotlin.types.model.TypeSubstitutorMarker +import org.jetbrains.kotlin.types.model.typeConstructor abstract class AbstractConeSubstitutor : ConeSubstitutor() { private fun wrapProjection(old: ConeTypeProjection, newType: ConeKotlinType): ConeTypeProjection { @@ -162,3 +166,15 @@ data class ConeSubstitutorByMap(val substitution: Map, context: ConeTypeContext): ConeSubstitutor { + if (map.isEmpty()) return ConeSubstitutor.Empty + return object : AbstractConeSubstitutor(), + TypeSubstitutorMarker { + override fun substituteType(type: ConeKotlinType): ConeKotlinType? { + if (type !is ConeLookupTagBasedType && type !is ConeStubType) return null + val new = map[type.typeConstructor(context)] ?: return null + return new.approximateIntegerLiteralType().updateNullabilityIfNeeded(type) + } + } +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ArrayUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ArrayUtils.kt index 499f40ed57b..757442b9144 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ArrayUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ArrayUtils.kt @@ -11,7 +11,7 @@ fun ConeKotlinType.createOutArrayType(nullable: Boolean = false): ConeKotlinType return ConeKotlinTypeProjectionOut(this).createArrayType(nullable) } -fun ConeTypeProjection.createArrayType(nullable: Boolean = false): ConeKotlinType { +fun ConeTypeProjection.createArrayType(nullable: Boolean = false): ConeClassLikeType { if (this is ConeKotlinTypeProjection) { val type = type.lowerBoundIfFlexible() if (type is ConeClassLikeType && type.nullability != ConeNullability.NULLABLE) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt index b70a0b5a4a5..875fef476b1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt @@ -13,8 +13,8 @@ import org.jetbrains.kotlin.fir.resolve.calls.NoSubstitutor import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType import org.jetbrains.kotlin.fir.resolve.inference.isSuspendFunctionType import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider -import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor +import org.jetbrains.kotlin.fir.resolve.substitution.createTypeSubstitutorByTypeConstructor import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.fir.symbols.StandardClassIds @@ -32,19 +32,19 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo val symbolProvider: FirSymbolProvider get() = session.symbolProvider override fun nullableNothingType(): SimpleTypeMarker { - return session.builtinTypes.nullableNothingType.type//StandardClassIds.Nothing(symbolProvider).constructType(emptyArray(), true) + return session.builtinTypes.nullableNothingType.type } override fun nullableAnyType(): SimpleTypeMarker { - return session.builtinTypes.nullableAnyType.type//StandardClassIds.Any(symbolProvider).constructType(emptyArray(), true) + return session.builtinTypes.nullableAnyType.type } override fun nothingType(): SimpleTypeMarker { - return session.builtinTypes.nothingType.type//StandardClassIds.Nothing(symbolProvider).constructType(emptyArray(), false) + return session.builtinTypes.nothingType.type } override fun anyType(): SimpleTypeMarker { - return session.builtinTypes.anyType.type//StandardClassIds.Any(symbolProvider).constructType(emptyArray(), false) + return session.builtinTypes.anyType.type } override fun createFlexibleType(lowerBound: SimpleTypeMarker, upperBound: SimpleTypeMarker): KotlinTypeMarker { @@ -102,14 +102,13 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo override fun KotlinTypeMarker.canHaveUndefinedNullability(): Boolean { require(this is ConeKotlinType) - return this is ConeCapturedType /*|| this is ConeTypeVariable // TODO */ + return this is ConeCapturedType || this is ConeTypeVariableType || this is ConeTypeParameterType } - // TODO: implement checking for extension function override fun SimpleTypeMarker.isExtensionFunction(): Boolean { require(this is ConeKotlinType) - return false + return this.isExtensionFunctionType } override fun KotlinTypeMarker.typeDepth() = when (this) { @@ -151,11 +150,6 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo if (this == null) return false if (!visited.add(this)) return false - /* - TODO:? - UnwrappedType unwrappedType = type.unwrap(); - */ - if (predicate(this)) return true val flexibleType = this as? ConeFlexibleType @@ -300,15 +294,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo } override fun typeSubstitutorByTypeConstructor(map: Map): ConeSubstitutor { - if (map.isEmpty()) return createEmptySubstitutor() - return object : AbstractConeSubstitutor(), - TypeSubstitutorMarker { - override fun substituteType(type: ConeKotlinType): ConeKotlinType? { - if (type !is ConeLookupTagBasedType && type !is ConeStubType) return null - val new = map[type.typeConstructor()] ?: return null - return (new as ConeKotlinType).approximateIntegerLiteralType().updateNullabilityIfNeeded(type) - } - } + @Suppress("UNCHECKED_CAST") + return createTypeSubstitutorByTypeConstructor(map as Map, this) } override fun createEmptySubstitutor(): ConeSubstitutor { @@ -328,7 +315,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo } override fun KotlinTypeMarker.isSpecial(): Boolean { - // TODO + // Cone type system doesn't have special types return false } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt index 4fec0ecf1af..2097cc95621 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt @@ -17,7 +17,6 @@ import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe import org.jetbrains.kotlin.fir.resolve.transformers.ensureResolved -import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.fir.symbols.StandardClassIds @@ -100,7 +99,6 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty } override fun SimpleTypeMarker.asCapturedType(): CapturedTypeMarker? { - //require(this is ConeLookupTagBasedType) return this as? ConeCapturedType } @@ -124,7 +122,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty is ConeClassLikeType -> lookupTag is ConeTypeParameterType -> lookupTag is ConeCapturedType -> constructor - is ConeTypeVariableType -> lookupTag as ConeTypeVariableTypeConstructor // TODO: WTF + is ConeTypeVariableType -> lookupTag is ConeIntersectionType -> this is ConeStubType -> variable.typeConstructor is ConeDefinitelyNotNullType -> original.typeConstructor() @@ -150,20 +148,16 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun KotlinTypeMarker.argumentsCount(): Int { require(this is ConeKotlinType) - return this.typeArguments.size } override fun KotlinTypeMarker.getArgument(index: Int): TypeArgumentMarker { require(this is ConeKotlinType) - - return this.typeArguments.getOrNull(index) - ?: session.builtinTypes.anyType.type//StandardClassIds.Any(session.firSymbolProvider).constructType(emptyArray(), false) // TODO wtf + return this.typeArguments.getOrNull(index) ?: ConeStarProjection } override fun KotlinTypeMarker.asTypeArgument(): TypeArgumentMarker { require(this is ConeKotlinType) - return this } @@ -196,7 +190,6 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty } override fun TypeConstructorMarker.parametersCount(): Int { - //require(this is ConeSymbol) return when (this) { is ConeTypeParameterLookupTag, is ConeCapturedTypeConstructor, @@ -204,7 +197,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty is ConeTypeVariableTypeConstructor, is ConeIntersectionType -> 0 is ConeClassLikeLookupTag -> { - when(val symbol = toSymbol(session)) { + when (val symbol = toSymbol(session)) { is FirAnonymousObjectSymbol -> symbol.fir.typeParameters.size is FirRegularClassSymbol -> symbol.fir.typeParameters.size is FirTypeAliasSymbol -> symbol.fir.typeParameters.size @@ -212,12 +205,11 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty } } is ConeIntegerLiteralType -> 0 - else -> error("?!:10") + else -> unknownConstructorError() } } override fun TypeConstructorMarker.getParameter(index: Int): TypeParameterMarker { - //require(this is ConeSymbol) return when (val symbol = toClassLikeSymbol()) { is FirAnonymousObjectSymbol -> symbol.fir.typeParameters[index].symbol.toLookupTag() is FirRegularClassSymbol -> symbol.fir.typeParameters[index].symbol.toLookupTag() @@ -243,7 +235,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty is ConeCapturedTypeConstructor -> supertypes!! is ConeIntersectionType -> intersectedTypes is ConeIntegerLiteralType -> supertypes - else -> error("?!:13") + else -> unknownConstructorError() } } @@ -252,7 +244,6 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty } override fun TypeConstructorMarker.isClassTypeConstructor(): Boolean { - //assert(this is ConeSymbol) return this is ConeClassLikeLookupTag } @@ -278,21 +269,21 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun areEqualTypeConstructors(c1: TypeConstructorMarker, c2: TypeConstructorMarker): Boolean { if (c1 is ErrorTypeConstructor || c2 is ErrorTypeConstructor) return false - - //assert(c1 is ConeSymbol) - //assert(c2 is ConeSymbol) return c1 == c2 } override fun TypeConstructorMarker.isDenotable(): Boolean { - //TODO return when (this) { + is ConeClassLikeLookupTag, + is ConeTypeParameterLookupTag -> true + is ConeCapturedTypeConstructor, + is ErrorTypeConstructor, is ConeTypeVariableTypeConstructor, - is ConeIntersectionType, - is ConeIntegerLiteralType -> false - is AbstractFirBasedSymbol<*> -> true - else -> true + is ConeIntegerLiteralType, + is ConeIntersectionType -> false + + else -> unknownConstructorError() } } @@ -413,9 +404,12 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty return toClassLikeSymbol()?.fir as? FirRegularClass } - override fun nullableAnyType(): SimpleTypeMarker = TODO("not implemented") + override fun nullableAnyType(): SimpleTypeMarker = session.builtinTypes.nullableAnyType.type - override fun arrayType(componentType: KotlinTypeMarker): SimpleTypeMarker = TODO("not implemented") + override fun arrayType(componentType: KotlinTypeMarker): SimpleTypeMarker { + require(componentType is ConeKotlinType) + return componentType.createArrayType(nullable = false) + } override fun KotlinTypeMarker.isArrayOrNullableArray(): Boolean { require(this is ConeKotlinType) @@ -459,8 +453,8 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty } override fun KotlinTypeMarker.getSubstitutedUnderlyingType(): KotlinTypeMarker? { - // TODO: support inline classes - return null + require(this is ConeKotlinType) + return substitutedUnderlyingTypeForInlineClass(session, this@ConeTypeContext) } override fun TypeConstructorMarker.getPrimitiveType() = @@ -479,7 +473,10 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun TypeParameterMarker.getName() = (this as ConeTypeParameterLookupTag).name - override fun TypeParameterMarker.isReified(): Boolean = TODO("not implemented") + override fun TypeParameterMarker.isReified(): Boolean { + require(this is ConeTypeParameterLookupTag) + return typeParameterSymbol.fir.isReified + } override fun KotlinTypeMarker.isInterfaceOrAnnotationClass(): Boolean { val classKind = typeConstructor().toFirRegularClass()?.classKind ?: return false @@ -489,6 +486,10 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun TypeConstructorMarker.isError(): Boolean { return this is ErrorTypeConstructor } + + private fun TypeConstructorMarker.unknownConstructorError(): Nothing { + error("Unknown type constructor: ${this::class}") + } } class ConeTypeCheckerContext( From e5ab6841272f044d416ac3ecb11390b66a248dd7 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 3 Feb 2021 13:15:27 +0300 Subject: [PATCH 229/368] [FIR] Support methods of cone type contexts with annotation markers --- .../fir/types/CompilerConeAttributes.kt | 11 ++++++ .../kotlin/fir/types/ConeAttributes.kt | 10 +++++- .../fir/resolve/inference/InferenceUtils.kt | 18 ++++++---- .../kotlin/fir/types/ConeInferenceContext.kt | 34 +++++++++++++------ .../kotlin/fir/types/ConeTypeContext.kt | 31 ++++++++++++++--- 5 files changed, 81 insertions(+), 23 deletions(-) diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt index 13fef591dc8..bd90bcb7298 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt @@ -82,6 +82,17 @@ object CompilerConeAttributes { override fun toString(): String = "@UnsafeVariance" } + + val compilerAttributeByClassId: Map> = mapOf( + Exact.ANNOTATION_CLASS_ID to Exact, + NoInfer.ANNOTATION_CLASS_ID to NoInfer, + EnhancedNullability.ANNOTATION_CLASS_ID to EnhancedNullability, + ExtensionFunctionType.ANNOTATION_CLASS_ID to ExtensionFunctionType, + FlexibleNullability.ANNOTATION_CLASS_ID to FlexibleNullability, + UnsafeVariance.ANNOTATION_CLASS_ID to UnsafeVariance + ) + + val compilerAttributeByFqName: Map> = compilerAttributeByClassId.mapKeys { it.key.asSingleFqName() } } val ConeAttributes.exact: CompilerConeAttributes.Exact? by ConeAttributes.attributeAccessor() diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt index a2779ca5cba..a7c79829d64 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt @@ -9,11 +9,12 @@ import org.jetbrains.kotlin.fir.utils.AttributeArrayOwner import org.jetbrains.kotlin.fir.utils.Protected import org.jetbrains.kotlin.fir.utils.TypeRegistry import org.jetbrains.kotlin.fir.utils.isEmpty +import org.jetbrains.kotlin.types.model.AnnotationMarker import org.jetbrains.kotlin.utils.addIfNotNull import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KClass -abstract class ConeAttribute> { +abstract class ConeAttribute> : AnnotationMarker { abstract fun union(other: @UnsafeVariance T?): T? abstract fun intersect(other: @UnsafeVariance T?): T? abstract fun isSubtypeOf(other: @UnsafeVariance T?): Boolean @@ -69,6 +70,13 @@ class ConeAttributes private constructor(attributes: List>) : A return perform(other) { this.intersect(it) } } + fun remove(attribute: ConeAttribute<*>): ConeAttributes { + if (arrayMap.isEmpty()) return this + val attributes = arrayMap.filter { it != attribute } + if (attributes.size == arrayMap.size) return this + return create(attributes) + } + override fun iterator(): Iterator> { return arrayMap.iterator() } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt index e2f3f91a66d..340bee9b6ad 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.scopes.FakeOverrideTypeCalculator import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.processOverriddenFunctions import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol @@ -45,16 +46,15 @@ fun ConeKotlinType.isKMutableProperty(session: FirSession): Boolean { } private fun ConeKotlinType.functionClassKind(session: FirSession): FunctionClassKind? { - val classId = classId(session) ?: return null - return FunctionClassKind.byClassNamePrefix(classId.packageFqName, classId.relativeClassName.asString()) + return classId(session)?.toFunctionClassKind() +} + +private fun ClassId.toFunctionClassKind(): FunctionClassKind? { + return FunctionClassKind.byClassNamePrefix(packageFqName, relativeClassName.asString()) } fun ConeKotlinType.isBuiltinFunctionalType(session: FirSession): Boolean { - val kind = functionClassKind(session) ?: return false - return kind == FunctionClassKind.Function || - kind == FunctionClassKind.KFunction || - kind == FunctionClassKind.SuspendFunction || - kind == FunctionClassKind.KSuspendFunction + return functionClassKind(session) != null } fun ConeKotlinType.isFunctionalType(session: FirSession): Boolean { @@ -62,6 +62,10 @@ fun ConeKotlinType.isFunctionalType(session: FirSession): Boolean { return kind == FunctionClassKind.Function } +fun ConeClassLikeLookupTag.isBuiltinFunctionalType(): Boolean { + return classId.toFunctionClassKind() != null +} + fun ConeKotlinType.isSuspendFunctionType(session: FirSession): Boolean { val kind = functionClassKind(session) ?: return false return kind == FunctionClassKind.SuspendFunction || diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt index 875fef476b1..7906f64405f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.isPrimitiveNumberOrUnsignedNumberType import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.NoSubstitutor import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType +import org.jetbrains.kotlin.fir.resolve.inference.isFunctionalType import org.jetbrains.kotlin.fir.resolve.inference.isSuspendFunctionType import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor @@ -59,11 +60,23 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo arguments: List, nullable: Boolean, isExtensionFunction: Boolean, - annotations: List? // TODO: process annotations + annotations: List? ): SimpleTypeMarker { - val attributes = if (isExtensionFunction) // TODO: assert correct type constructor - ConeAttributes.WithExtensionFunctionType - else ConeAttributes.Empty + val attributesList = annotations?.filterIsInstanceTo, MutableList>>(mutableListOf()) + val attributes: ConeAttributes = if (isExtensionFunction) { + require(constructor is ConeClassLikeLookupTag && constructor.isBuiltinFunctionalType()) + // We don't want to create new instance of ConeAttributes which + // contains only CompilerConeAttributes.ExtensionFunctionType + // to avoid memory consumption + if (attributesList != null) { + attributesList += CompilerConeAttributes.ExtensionFunctionType + ConeAttributes.create(attributesList) + } else { + ConeAttributes.WithExtensionFunctionType + } + } else { + attributesList?.let { ConeAttributes.create(it) } ?: ConeAttributes.Empty + } @Suppress("UNCHECKED_CAST") return when (constructor) { is ConeClassLikeLookupTag -> ConeClassLikeTypeImpl( @@ -74,7 +87,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo ) is ConeTypeParameterLookupTag -> ConeTypeParameterTypeImpl( constructor, - nullable + nullable, + attributes ) else -> error("!") } @@ -245,7 +259,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo } override fun KotlinTypeMarker.removeAnnotations(): KotlinTypeMarker { - return this // TODO + require(this is ConeKotlinType) + return withAttributes(ConeAttributes.Empty) } override fun SimpleTypeMarker.replaceArguments(newArguments: List): SimpleTypeMarker { @@ -349,8 +364,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo } override fun KotlinTypeMarker.removeExactAnnotation(): KotlinTypeMarker { - // TODO - return this + require(this is ConeKotlinType) + return withAttributes(attributes.remove(CompilerConeAttributes.Exact)) } override fun TypeConstructorMarker.toErrorType(): SimpleTypeMarker { @@ -384,8 +399,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo this, { // FIXME supertypes of type constructor contain unsubstituted arguments - @Suppress("UNCHECKED_CAST") - it.typeConstructor().supertypes() as Collection + it.typeConstructor().supertypes() }, DFS.VisitedWithSet(), object : DFS.AbstractNodeHandler() { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt index 2097cc95621..647d20f8c14 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt @@ -10,6 +10,10 @@ import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.expressions.FirConstExpression +import org.jetbrains.kotlin.fir.expressions.FirNamedArgumentExpression +import org.jetbrains.kotlin.fir.expressions.FirVarargArgumentsExpression +import org.jetbrains.kotlin.fir.expressions.arguments import org.jetbrains.kotlin.fir.resolve.correspondingSupertypesCache import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor @@ -349,7 +353,7 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty override fun KotlinTypeMarker.getAnnotations(): List { require(this is ConeKotlinType) - return emptyList() // TODO + return attributes.arrayMap.toList() } override fun SimpleTypeMarker.isStubType(): Boolean { @@ -425,13 +429,30 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty } override fun KotlinTypeMarker.hasAnnotation(fqName: FqName): Boolean { - // TODO support annotations - return false + require(this is ConeKotlinType) + val compilerAttribute = CompilerConeAttributes.compilerAttributeByFqName[fqName] + if (compilerAttribute != null) { + return compilerAttribute in attributes + } + val customAnnotations = attributes.customAnnotations + return customAnnotations.any { + it.typeRef.coneTypeSafe()?.fullyExpandedType(session)?.classId?.asSingleFqName() == fqName + } } override fun KotlinTypeMarker.getAnnotationFirstArgumentValue(fqName: FqName): Any? { - // TODO support annotations - return null + require(this is ConeKotlinType) + // We don't check for compiler attributes because all of them doesn't have parameters + val customAnnotations = attributes.customAnnotations + val annotationCall = customAnnotations.firstOrNull { + it.typeRef.coneTypeSafe()?.fullyExpandedType(session)?.classId?.asSingleFqName() == fqName + } ?: return null + val argument = when (val argument = annotationCall.arguments.firstOrNull() ?: return null) { + is FirVarargArgumentsExpression -> argument.arguments.firstOrNull() + is FirNamedArgumentExpression -> argument.expression + else -> argument + } ?: return null + return (argument as? FirConstExpression<*>)?.value } override fun TypeConstructorMarker.getTypeParameterClassifier(): TypeParameterMarker? { From 0b22c30ab1a0341a548ea2dd46bb553e3ada1afc Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 3 Feb 2021 13:28:19 +0300 Subject: [PATCH 230/368] [FIR] Fix dispatch receiver type for members of builtin functional types --- .../fir/resolve/providers/impl/FirBuiltinSymbolProvider.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirBuiltinSymbolProvider.kt b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirBuiltinSymbolProvider.kt index b7d97c6ca06..0b933862dbe 100644 --- a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirBuiltinSymbolProvider.kt +++ b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirBuiltinSymbolProvider.kt @@ -220,7 +220,7 @@ class FirBuiltinSymbolProvider(session: FirSession, val kotlinScopeProvider: Kot isVararg = false } } - dispatchReceiverType = classId.defaultType(typeParameters.map { it.symbol }) + dispatchReceiverType = classId.defaultType(this@klass.typeParameters.map { it.symbol }) } ) } From df428688741b15b46b1b992caa3e005bdc8378a1 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 3 Feb 2021 17:49:18 +0300 Subject: [PATCH 231/368] [Inference] Fix subtyping on classes with same FQN but with different number of arguments Such situations may appear if there are multiple classes with same names from different modules in dependencies --- .../diagnostics/tests/cast/bare/FromErrorType.fir.kt | 4 ++-- .../differentGenericArgumentsReversed.fir.kt | 2 +- .../duplicateClass/genericSuperClass.fir.kt | 4 ++-- .../jetbrains/kotlin/types/AbstractTypeChecker.kt | 12 ++++++++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.fir.kt index ad882c18bc9..32da7c8aecb 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/FromErrorType.fir.kt @@ -4,5 +4,5 @@ class G fun foo(p: P) { val v = p as G? - checkSubtype>(v!!) -} \ No newline at end of file + checkSubtype>(v!!) +} diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/differentGenericArgumentsReversed.fir.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/differentGenericArgumentsReversed.fir.kt index 2b2f8bdf6a8..97610c28a91 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/differentGenericArgumentsReversed.fir.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/differentGenericArgumentsReversed.fir.kt @@ -26,4 +26,4 @@ import p.* fun test() { foo(M1().a) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericSuperClass.fir.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericSuperClass.fir.kt index a90aa734312..9de45048e8f 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericSuperClass.fir.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericSuperClass.fir.kt @@ -37,6 +37,6 @@ import p.* fun test() { a(M1().b) // Type arguments do not match - c(M1().b) // Type arguments do not match + c(M1().b) // Type arguments do not match d(M1().b) // Type arguments do match -} \ No newline at end of file +} diff --git a/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt b/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt index ddba646ece2..27fdc02b77c 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/types/AbstractTypeChecker.kt @@ -367,9 +367,17 @@ object AbstractTypeChecker { // No way to check, as no index sometimes //if (capturedSubArguments === superType.arguments) return true - //val parameters = superType.constructor.parameters val superTypeConstructor = superType.typeConstructor() - for (index in 0 until superTypeConstructor.parametersCount()) { + + // Sometimes we can get two classes from different modules with different counts of type parameters + // So for such situations we assume that those types are not sub type of each other + val argumentsCount = capturedSubArguments.size() + val parametersCount = superTypeConstructor.parametersCount() + if (argumentsCount != parametersCount || argumentsCount != superType.argumentsCount()) { + return false + } + + for (index in 0 until parametersCount) { val superProjection = superType.getArgument(index) // todo error index if (superProjection.isStarProjection()) continue // A <: A<*> From aaecb87d1bad167a35acf1f4c96f14136054dcdb Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 5 Feb 2021 19:02:23 +0100 Subject: [PATCH 232/368] Tests: compute runtime classpath for JVM box tests manually Taking just the `jvmClasspathRoots` is not correct because it also contains stuff needed for resolve to work correctly, such as JDK (full or mock), stdlib (full or mock), reflect. JDK is obviously not needed in the classpath, and stdlib/reflect are available via the parent class loader, which is specifically reused across all tests to make them run faster. Also, don't try to create class loader for Java-only modules in `JvmBoxRunner.processModule`. This happens, for example, for all tests which were moved from `boxAgainstJava`. --- .../jetbrains/kotlin/test/model/Modules.kt | 5 +++ .../test/backend/handlers/JvmBoxRunner.kt | 39 ++++++++++++++----- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt index f040006446d..f5dba1c8080 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt @@ -23,6 +23,11 @@ data class TestModule( val directives: RegisteredDirectives, val languageVersionSettings: LanguageVersionSettings ) { + override fun equals(other: Any?): Boolean = + other is TestModule && name == other.name + + override fun hashCode(): Int = name.hashCode() + override fun toString(): String { return buildString { appendLine("Module: $name") diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt index cd93e51eea3..52c5f61c4fd 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt @@ -7,7 +7,6 @@ package org.jetbrains.kotlin.test.backend.handlers import junit.framework.TestCase import org.jetbrains.kotlin.backend.common.CodegenUtil.getMemberDeclarationsToGenerate -import org.jetbrains.kotlin.cli.jvm.config.jvmClasspathRoots import org.jetbrains.kotlin.codegen.* import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil.getFileClassInfoNoResolve @@ -15,11 +14,14 @@ import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.test.clientserver.TestProxy import org.jetbrains.kotlin.test.directives.CodegenTestDirectives import org.jetbrains.kotlin.test.model.BinaryArtifacts +import org.jetbrains.kotlin.test.model.DependencyKind import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.compilerConfigurationProvider import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator.Companion.TEST_CONFIGURATION_KIND_KEY +import org.jetbrains.kotlin.test.services.dependencyProvider import org.jetbrains.kotlin.test.services.jvm.compiledClassesManager +import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.runIf import java.io.File import java.lang.reflect.Method @@ -40,7 +42,7 @@ class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testSe } override fun processModule(module: TestModule, info: BinaryArtifacts.Jvm) { - val ktFiles = info.classFileFactory.inputFiles + val ktFiles = info.classFileFactory.inputFiles.ifEmpty { return } val reportProblems = module.targetBackend !in module.directives[CodegenTestDirectives.IGNORE_BACKEND] val classLoader = createAndVerifyClassLoader(module, info.classFileFactory, reportProblems) try { @@ -162,21 +164,38 @@ class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testSe return classLoader } - @OptIn(ExperimentalStdlibApi::class) private fun createClassLoader(module: TestModule, classFileFactory: ClassFileFactory): GeneratedClassLoader { val configuration = testServices.compilerConfigurationProvider.getCompilerConfiguration(module) - val urls = buildList { - addAll(configuration.jvmClasspathRoots) - testServices.compiledClassesManager.getCompiledJavaDirForModule(module)?.let { - add(it) - } - }.map { it.toURI().toURL() } val parentClassLoader = if (configuration[TEST_CONFIGURATION_KIND_KEY]?.withReflection == true) { ForTestCompileRuntime.runtimeAndReflectJarClassLoader() } else { ForTestCompileRuntime.runtimeJarClassLoader() } - return GeneratedClassLoader(classFileFactory, parentClassLoader, *urls.toTypedArray()) + val classpath = computeRuntimeClasspath(module) + return GeneratedClassLoader(classFileFactory, parentClassLoader, *classpath.map { it.toURI().toURL() }.toTypedArray()) + } + + private fun computeRuntimeClasspath(rootModule: TestModule): List { + val visited = mutableSetOf() + val result = mutableListOf() + + fun computeClasspath(module: TestModule, isRoot: Boolean) { + if (!visited.add(module)) return + + if (!isRoot) { + result.add(testServices.compiledClassesManager.getCompiledKotlinDirForModule(module)) + } + result.addIfNotNull(testServices.compiledClassesManager.getCompiledJavaDirForModule(module)) + + for (dependency in module.dependencies + module.friends) { + if (dependency.kind == DependencyKind.Binary) { + computeClasspath(testServices.dependencyProvider.getTestModule(dependency.moduleName), false) + } + } + } + + computeClasspath(rootModule, true) + return result } private fun KtFile.getFacadeFqName(): String? { From 4d9cffccf2354bf292bff0fa7b61cde064f21733 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 8 Feb 2021 11:41:15 +0100 Subject: [PATCH 233/368] Support structural equals/hashCode for type constructors of type parameters Use the same logic as for type constructors of classes, based on the fully-qualified name of the classifier, with special cases for error types and local declarations, with an additional check that the type constructors' declaration descriptors are structurally equal via `DescriptorEquivalenceForOverrides`. The latter is required because type parameters of overloaded functions must be different, even though their full FQ name is the same. This (hopefully) has no effect for the compiler, but is useful for kotlin-reflect where `KType.equals` runs the type checker on the underlying `KotlinType` instances, which eventually ends up comparing type constructors. Descriptors and types in kotlin-reflect are cached on soft references, so they may be suddenly garbage-collected and recomputed, and we want copies of the same type parameter to be equal to each other. This fixes flaky codegen tests which started to fail after migration to the new test infrastructure, where tests are now run in parallel in the same process, thus with higher memory pressure and more soft references being GC'd: * `codegen/box/reflection/types/createType/typeParameter.kt` * `codegen/box/reflection/supertypes/genericSubstitution.kt` Also, add a new test to check that we do the instanceof check in overrides of `AbstractTypeConstructor.isSameClassifier`. #KT-44850 Fixed --- .../FirBlackBoxCodegenTestGenerated.java | 6 ++ .../ir/descriptors/IrBasedDescriptors.kt | 2 + ...sForClassAndTypeParameterWithSameFqName.kt | 27 +++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++ .../LightAnalysisModeTestGenerated.java | 5 ++ .../impl/AbstractTypeParameterDescriptor.java | 11 +++ .../DescriptorEquivalenceForOverrides.kt | 3 +- .../types/AbstractClassTypeConstructor.java | 80 ++----------------- .../kotlin/types/AbstractTypeConstructor.kt | 68 +++++++++++++++- 10 files changed, 136 insertions(+), 78 deletions(-) create mode 100644 compiler/testData/codegen/box/reflection/types/equalsForClassAndTypeParameterWithSameFqName.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 6e398a6e9af..d11440a7e7e 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -35387,6 +35387,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/reflection/types/classifiersOfBuiltInTypes.kt"); } + @Test + @TestMetadata("equalsForClassAndTypeParameterWithSameFqName.kt") + public void testEqualsForClassAndTypeParameterWithSameFqName() throws Exception { + runTest("compiler/testData/codegen/box/reflection/types/equalsForClassAndTypeParameterWithSameFqName.kt"); + } + @Test @TestMetadata("innerGenericArguments.kt") public void testInnerGenericArguments() throws Exception { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt index fa875cbd9d6..30ed8469043 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBasedDescriptors.kt @@ -266,6 +266,8 @@ open class IrBasedTypeParameterDescriptor(owner: IrTypeParameter) : TypeParamete override fun getDeclarationDescriptor() = this@IrBasedTypeParameterDescriptor override fun getBuiltIns() = module.builtIns + + override fun isSameClassifier(classifier: ClassifierDescriptor): Boolean = declarationDescriptor === classifier } } diff --git a/compiler/testData/codegen/box/reflection/types/equalsForClassAndTypeParameterWithSameFqName.kt b/compiler/testData/codegen/box/reflection/types/equalsForClassAndTypeParameterWithSameFqName.kt new file mode 100644 index 00000000000..deeb33142ed --- /dev/null +++ b/compiler/testData/codegen/box/reflection/types/equalsForClassAndTypeParameterWithSameFqName.kt @@ -0,0 +1,27 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +// FIR incorrectly resolves typeParameterType's return type to the nested class `A.T`. +// IGNORE_BACKEND_FIR: JVM_IR + +package test + +class A { + class T + + fun typeParameterType(): T? = null + fun nestedClassType(): A.T? = null +} + +fun box(): String { + val typeParameterType = A<*>::typeParameterType.returnType + val classType = A<*>::nestedClassType.returnType + + if (typeParameterType == classType) + return "Fail 1: type parameter's type constructor shouldn't be equal to the class with the same FQ name" + + if (classType == typeParameterType) + return "Fail 2: class' type constructor shouldn't be equal to the type parameter with the same FQ name" + + return "OK" +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index f3680f868a8..960be73cd2a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -35387,6 +35387,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/reflection/types/classifiersOfBuiltInTypes.kt"); } + @Test + @TestMetadata("equalsForClassAndTypeParameterWithSameFqName.kt") + public void testEqualsForClassAndTypeParameterWithSameFqName() throws Exception { + runTest("compiler/testData/codegen/box/reflection/types/equalsForClassAndTypeParameterWithSameFqName.kt"); + } + @Test @TestMetadata("innerGenericArguments.kt") public void testInnerGenericArguments() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index c64b6b797c2..096f5e8e728 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -35387,6 +35387,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/reflection/types/classifiersOfBuiltInTypes.kt"); } + @Test + @TestMetadata("equalsForClassAndTypeParameterWithSameFqName.kt") + public void testEqualsForClassAndTypeParameterWithSameFqName() throws Exception { + runTest("compiler/testData/codegen/box/reflection/types/equalsForClassAndTypeParameterWithSameFqName.kt"); + } + @Test @TestMetadata("innerGenericArguments.kt") public void testInnerGenericArguments() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 1d9ecf0f2f0..035e1085ce9 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -28135,6 +28135,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/reflection/types/classifiersOfBuiltInTypes.kt"); } + @TestMetadata("equalsForClassAndTypeParameterWithSameFqName.kt") + public void testEqualsForClassAndTypeParameterWithSameFqName() throws Exception { + runTest("compiler/testData/codegen/box/reflection/types/equalsForClassAndTypeParameterWithSameFqName.kt"); + } + @TestMetadata("innerGenericArguments.kt") public void testInnerGenericArguments() throws Exception { runTest("compiler/testData/codegen/box/reflection/types/innerGenericArguments.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java index 112f4ad0754..32fc433d24d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; +import org.jetbrains.kotlin.resolve.DescriptorEquivalenceForOverrides; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; import org.jetbrains.kotlin.resolve.scopes.LazyScopeAdapter; import org.jetbrains.kotlin.resolve.scopes.MemberScope; @@ -222,5 +223,15 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip protected KotlinType defaultSupertypeIfEmpty() { return ErrorUtils.createErrorType("Cyclic upper bounds"); } + + @Override + protected boolean isSameClassifier(@NotNull ClassifierDescriptor classifier) { + return classifier instanceof TypeParameterDescriptor && + DescriptorEquivalenceForOverrides.INSTANCE.areTypeParametersEquivalent( + AbstractTypeParameterDescriptor.this, + (TypeParameterDescriptor) classifier, + true + ); + } } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorEquivalenceForOverrides.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorEquivalenceForOverrides.kt index dd7504e2946..b215106c057 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorEquivalenceForOverrides.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorEquivalenceForOverrides.kt @@ -56,7 +56,8 @@ object DescriptorEquivalenceForOverrides { return a.typeConstructor == b.typeConstructor } - private fun areTypeParametersEquivalent( + @JvmOverloads + fun areTypeParametersEquivalent( a: TypeParameterDescriptor, b: TypeParameterDescriptor, allowCopiesFromTheSameDeclaration: Boolean, diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java index 44065e42bf2..b05e7d20bda 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java @@ -19,8 +19,10 @@ package org.jetbrains.kotlin.types; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.resolve.DescriptorUtils; +import org.jetbrains.kotlin.descriptors.ClassDescriptor; +import org.jetbrains.kotlin.descriptors.ClassifierDescriptor; +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; +import org.jetbrains.kotlin.descriptors.ModalityUtilsKt; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; import org.jetbrains.kotlin.storage.StorageManager; import org.jetbrains.kotlin.utils.SmartList; @@ -29,28 +31,10 @@ import java.util.Collection; import java.util.Collections; public abstract class AbstractClassTypeConstructor extends AbstractTypeConstructor implements TypeConstructor { - private int hashCode = 0; - public AbstractClassTypeConstructor(@NotNull StorageManager storageManager) { super(storageManager); } - @Override - public final int hashCode() { - int currentHashCode = hashCode; - if (currentHashCode != 0) return currentHashCode; - - ClassifierDescriptor descriptor = getDeclarationDescriptor(); - if (hasMeaningfulFqName(descriptor)) { - currentHashCode = DescriptorUtils.getFqName(descriptor).hashCode(); - } - else { - currentHashCode = System.identityHashCode(this); - } - hashCode = currentHashCode; - return currentHashCode; - } - @NotNull @Override public abstract ClassDescriptor getDeclarationDescriptor(); @@ -68,60 +52,8 @@ public abstract class AbstractClassTypeConstructor extends AbstractTypeConstruct } @Override - public final boolean equals(Object other) { - if (this == other) return true; - if (!(other instanceof TypeConstructor)) return false; - - // performance optimization: getFqName is slow method - if (other.hashCode() != hashCode()) return false; - - // Sometimes we can get two classes from different modules with different counts of type parameters. - // To avoid problems in type checker we suppose that it is different type constructors. - if (((TypeConstructor) other).getParameters().size() != getParameters().size()) return false; - - ClassifierDescriptor myDescriptor = getDeclarationDescriptor(); - ClassifierDescriptor otherDescriptor = ((TypeConstructor) other).getDeclarationDescriptor(); - - if (!hasMeaningfulFqName(myDescriptor) || - otherDescriptor != null && !hasMeaningfulFqName(otherDescriptor)) { - // All error types and local classes have the same descriptor, - // but we've already checked identity equality in the beginning of the method - return false; - } - - if (otherDescriptor instanceof ClassDescriptor) { - return areFqNamesEqual(((ClassDescriptor) myDescriptor), ((ClassDescriptor) otherDescriptor)); - } - - return false; - } - - private static boolean areFqNamesEqual(ClassDescriptor first, ClassDescriptor second) { - if (!first.getName().equals(second.getName())) return false; - - DeclarationDescriptor a = first.getContainingDeclaration(); - DeclarationDescriptor b = second.getContainingDeclaration(); - while (a != null && b != null) { - if (a instanceof ModuleDescriptor) return b instanceof ModuleDescriptor; - if (b instanceof ModuleDescriptor) return false; - - if (a instanceof PackageFragmentDescriptor) { - return b instanceof PackageFragmentDescriptor && - ((PackageFragmentDescriptor) a).getFqName().equals(((PackageFragmentDescriptor) b).getFqName()); - } - if (b instanceof PackageFragmentDescriptor) return false; - - if (!a.getName().equals(b.getName())) return false; - - a = a.getContainingDeclaration(); - b = b.getContainingDeclaration(); - } - return true; - } - - private static boolean hasMeaningfulFqName(@NotNull ClassifierDescriptor descriptor) { - return !ErrorUtils.isError(descriptor) && - !DescriptorUtils.isLocal(descriptor); + protected boolean isSameClassifier(@NotNull ClassifierDescriptor classifier) { + return classifier instanceof ClassDescriptor && areFqNamesEqual(getDeclarationDescriptor(), classifier); } @NotNull diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractTypeConstructor.kt b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractTypeConstructor.kt index eaa3c5b2e25..d3a4e02c62f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractTypeConstructor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractTypeConstructor.kt @@ -17,15 +17,16 @@ package org.jetbrains.kotlin.types import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.descriptors.ClassifierDescriptor -import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner import org.jetbrains.kotlin.types.checker.refineTypes import org.jetbrains.kotlin.types.refinement.TypeRefinement abstract class AbstractTypeConstructor(storageManager: StorageManager) : TypeConstructor { + private var hashCode = 0 + override fun getSupertypes() = supertypes().supertypesWithoutCycles abstract override fun getDeclarationDescriptor(): ClassifierDescriptor @@ -132,4 +133,65 @@ abstract class AbstractTypeConstructor(storageManager: StorageManager) : TypeCon // Only for debugging fun renderAdditionalDebugInformation(): String = "supertypes=${supertypes.renderDebugInformation()}" + + override fun hashCode(): Int { + val cachedHashCode = hashCode + if (cachedHashCode != 0) return cachedHashCode + + val descriptor = declarationDescriptor + val computedHashCode = if (hasMeaningfulFqName(descriptor)) { + DescriptorUtils.getFqName(descriptor).hashCode() + } else { + System.identityHashCode(this) + } + + return computedHashCode.also { hashCode = it } + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is TypeConstructor) return false + + // performance optimization: getFqName is slow method + if (other.hashCode() != hashCode()) return false + + // Sometimes we can get two classes from different modules with different counts of type parameters. + // To avoid problems in type checker we suppose that it is different type constructors. + if (other.parameters.size != parameters.size) return false + + val myDescriptor = declarationDescriptor + val otherDescriptor = other.declarationDescriptor ?: return false + if (!hasMeaningfulFqName(myDescriptor) || !hasMeaningfulFqName(otherDescriptor)) { + // All error types and local classes have the same descriptor, + // but we've already checked identity equality in the beginning of the method + return false + } + + return isSameClassifier(otherDescriptor) + } + + protected abstract fun isSameClassifier(classifier: ClassifierDescriptor): Boolean + + protected fun areFqNamesEqual(first: ClassifierDescriptor, second: ClassifierDescriptor): Boolean { + if (first.name != second.name) return false + var a: DeclarationDescriptor? = first.containingDeclaration + var b: DeclarationDescriptor? = second.containingDeclaration + while (a != null && b != null) { + when { + a is ModuleDescriptor -> return b is ModuleDescriptor + b is ModuleDescriptor -> return false + a is PackageFragmentDescriptor -> return b is PackageFragmentDescriptor && a.fqName == b.fqName + b is PackageFragmentDescriptor -> return false + a.name != b.name -> return false + else -> { + a = a.containingDeclaration + b = b.containingDeclaration + } + } + } + return true + } + + private fun hasMeaningfulFqName(descriptor: ClassifierDescriptor): Boolean = + !ErrorUtils.isError(descriptor) && !DescriptorUtils.isLocal(descriptor) } From 67e91b7ebdc5d3627e2892c2e156989b6e5be732 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 17 Feb 2021 16:39:19 +0100 Subject: [PATCH 234/368] Minor, add workaround for KT-45008 --- .../src/org/jetbrains/kotlin/types/AbstractTypeConstructor.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractTypeConstructor.kt b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractTypeConstructor.kt index d3a4e02c62f..b77c41f87a0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractTypeConstructor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractTypeConstructor.kt @@ -153,7 +153,8 @@ abstract class AbstractTypeConstructor(storageManager: StorageManager) : TypeCon if (other !is TypeConstructor) return false // performance optimization: getFqName is slow method - if (other.hashCode() != hashCode()) return false + // Cast to Any is needed as a workaround for KT-45008. + if ((other as Any).hashCode() != hashCode()) return false // Sometimes we can get two classes from different modules with different counts of type parameters. // To avoid problems in type checker we suppose that it is different type constructors. From 66f00a2eb5d2964725c8cfdcb8d056269236a689 Mon Sep 17 00:00:00 2001 From: Tianyu Geng Date: Tue, 16 Feb 2021 09:47:21 -0800 Subject: [PATCH 235/368] FIR IDE: move AddFunctionBodyFix to fe-independent --- .../kotlin/idea/quickfix/AddFunctionBodyFix.kt | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) rename idea/{ => idea-frontend-independent}/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt (64%) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt similarity index 64% rename from idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt rename to idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt index e043c07c2b2..683f81c2078 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2021 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.idea.quickfix @@ -25,7 +14,7 @@ import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.KtPsiFactory import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType -class AddFunctionBodyFix(element: KtFunction) : KotlinQuickFixAction(element) { +class AddFunctionBodyFix(element: KtFunction) : KotlinPsiOnlyQuickFixAction(element) { override fun getFamilyName() = KotlinBundle.message("fix.add.function.body") override fun getText() = familyName From de06a69b1286a2193a8062333cdb14bc93016edb Mon Sep 17 00:00:00 2001 From: Sergey Shanshin Date: Wed, 17 Feb 2021 20:16:34 +0300 Subject: [PATCH 236/368] Added external serializers in serialization plugin for IR backend - added fallback support of external serializers in IR - implemented calculations of properties default values in IR - swapped check of shouldEncodeElementDefault and comparing the property with default value in IR. Now default value calculated only of shouldEncodeElementDefault returns false --- .../backend/common/SerializableCodegen.kt | 40 ---- .../compiler/backend/ir/GeneratorHelpers.kt | 194 ++++++++++++++++-- .../backend/ir/SerializableIrGenerator.kt | 152 +++++--------- .../backend/ir/SerializerIrGenerator.kt | 157 +++++++++++--- .../backend/jvm/SerializableCodegenImpl.kt | 18 +- .../resolve/SerializableProperties.kt | 28 +++ 6 files changed, 399 insertions(+), 190 deletions(-) diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/common/SerializableCodegen.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/common/SerializableCodegen.kt index 9ee3b134375..d81b491452c 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/common/SerializableCodegen.kt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/common/SerializableCodegen.kt @@ -5,14 +5,11 @@ package org.jetbrains.kotlinx.serialization.compiler.backend.common -import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.descriptorUtil.module import org.jetbrains.kotlin.resolve.descriptorUtil.secondaryConstructors -import org.jetbrains.kotlinx.serialization.compiler.diagnostic.VersionReader import org.jetbrains.kotlinx.serialization.compiler.resolve.* abstract class SerializableCodegen( @@ -22,9 +19,6 @@ abstract class SerializableCodegen( protected val properties = bindingContext.serializablePropertiesFor(serializableDescriptor) protected val staticDescriptor = serializableDescriptor.declaredTypeParameters.isEmpty() - private val fieldMissingOptimizationVersion = ApiVersion.parse("1.1")!! - protected val useFieldMissingOptimization = canUseFieldMissingOptimization() - fun generate() { generateSyntheticInternalConstructor() generateSyntheticMethods() @@ -49,40 +43,6 @@ abstract class SerializableCodegen( } } - protected fun getGoldenMask(): Int { - var goldenMask = 0 - var requiredBit = 1 - for (property in properties.serializableProperties) { - if (!property.optional) { - goldenMask = goldenMask or requiredBit - } - requiredBit = requiredBit shl 1 - } - return goldenMask - } - - protected fun getGoldenMaskList(): List { - val maskSlotCount = properties.serializableProperties.bitMaskSlotCount() - val goldenMaskList = MutableList(maskSlotCount) { 0 } - - for (i in properties.serializableProperties.indices) { - if (!properties.serializableProperties[i].optional) { - val slotNumber = i / 32 - val bitInSlot = i % 32 - goldenMaskList[slotNumber] = goldenMaskList[slotNumber] or (1 shl bitInSlot) - } - } - return goldenMaskList - } - - private fun canUseFieldMissingOptimization(): Boolean { - val implementationVersion = VersionReader.getVersionsForCurrentModuleFromContext( - serializableDescriptor.module, - bindingContext - )?.implementationVersion - return if (implementationVersion != null) implementationVersion >= fieldMissingOptimizationVersion else false - } - protected abstract fun generateInternalConstructor(constructorDescriptor: ClassConstructorDescriptor) protected open fun generateWriteSelfMethod(methodDescriptor: FunctionDescriptor) { diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt index 9a20342f7f8..f2dfc60ab42 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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. */ @@ -21,10 +21,12 @@ import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.platform.jvm.isJvm +import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.descriptorUtil.classId import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal @@ -34,6 +36,7 @@ import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.isTypeParameter import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.types.typeUtil.representativeUpperBound +import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlinx.serialization.compiler.backend.common.* import org.jetbrains.kotlinx.serialization.compiler.backend.jvm.* import org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationPluginContext @@ -42,10 +45,20 @@ import org.jetbrains.kotlinx.serialization.compiler.resolve.* interface IrBuilderExtension { val compilerContext: SerializationPluginContext + private val throwMissedFieldExceptionFunc + get() = compilerContext.referenceFunctions(SerialEntityNames.SINGLE_MASK_FIELD_MISSING_FUNC_FQ).singleOrNull() + + private val throwMissedFieldExceptionArrayFunc + get() = compilerContext.referenceFunctions(SerialEntityNames.ARRAY_MASK_FIELD_MISSING_FUNC_FQ).singleOrNull() + private inline fun IrClass.searchForDeclaration(descriptor: DeclarationDescriptor): T? { return declarations.singleOrNull { it.descriptor == descriptor } as? T } + fun useFieldMissingOptimization(): Boolean { + return throwMissedFieldExceptionFunc != null && throwMissedFieldExceptionArrayFunc != null + } + fun IrClass.contributeFunction(descriptor: FunctionDescriptor, bodyGen: IrBlockBodyBuilder.(IrFunction) -> Unit) { val f: IrSimpleFunction = searchForDeclaration(descriptor) ?: compilerContext.symbolTable.referenceSimpleFunction(descriptor).owner // TODO: default parameters @@ -214,14 +227,62 @@ interface IrBuilderExtension { // note: this method should be used only for properties from current module. Fields from other modules are private and inaccessible. val SerializableProperty.irField: IrField get() = compilerContext.symbolTable.referenceField(this.descriptor).owner - fun SerializableProperty.getIrPropertyFrom(thisClass: IrClass): IrProperty { - val desc = this.descriptor + fun IrClass.searchForProperty(descriptor: PropertyDescriptor): IrProperty { // this API is used to reference both current module descriptors and external ones (because serializable class can be in any of them), // so we use descriptor api for current module because it is not possible to obtain FQname for e.g. local classes. - return thisClass.searchForDeclaration(desc) ?: if (desc.module == compilerContext.moduleDescriptor) { - compilerContext.symbolTable.referenceProperty(desc).owner + return searchForDeclaration(descriptor) ?: if (descriptor.module == compilerContext.moduleDescriptor) { + compilerContext.symbolTable.referenceProperty(descriptor).owner } else { - compilerContext.referenceProperties(desc.fqNameSafe).single().owner + compilerContext.referenceProperties(descriptor.fqNameSafe).single().owner + } + } + + fun SerializableProperty.getIrPropertyFrom(thisClass: IrClass): IrProperty { + return thisClass.searchForProperty(descriptor) + } + + + /* + Create a function that creates `get property value expressions` for given corresponded constructor's param + (constructor_params) -> get_property_value_expression + */ + fun IrBuilderWithScope.createPropertyByParamReplacer( + irClass: IrClass, + serialProperties: List, + instance: IrValueParameter, + bindingContext: BindingContext + ): (ValueParameterDescriptor) -> IrExpression? { + fun SerializableProperty.irGet(): IrExpression { + val ownerType = instance.symbol.owner.type + return getProperty( + irGet( + type = ownerType, + variable = instance.symbol + ), getIrPropertyFrom(irClass) + ) + } + + val serialPropertiesMap = serialProperties.associateBy { it.descriptor } + + val transientPropertiesMap = + irClass.declarations.asSequence() + .filterIsInstance() + .filter { it.backingField != null }.filter { !serialPropertiesMap.containsKey(it.descriptor) } + .associateBy { it.symbol.descriptor } + + return { + val propertyDescriptor = bindingContext[BindingContext.VALUE_PARAMETER_AS_PROPERTY, it] + if (propertyDescriptor != null) { + val value = serialPropertiesMap[propertyDescriptor] + value?.irGet() ?: transientPropertiesMap[propertyDescriptor]?.let { prop -> + getProperty( + irGet(instance), + prop + ) + } + } else { + null + } } } @@ -257,6 +318,78 @@ interface IrBuilderExtension { } } + fun IrBlockBodyBuilder.generateGoldenMaskCheck( + seenVars: List, + properties: SerializableProperties, + serialDescriptor: IrExpression + ) { + val fieldsMissedTest: IrExpression + val throwErrorExpr: IrExpression + + val maskSlotCount = seenVars.size + if (maskSlotCount == 1) { + val goldenMask = properties.goldenMask + + + throwErrorExpr = irInvoke( + null, + throwMissedFieldExceptionFunc!!, + irGet(seenVars[0]), + irInt(goldenMask), + serialDescriptor, + typeHint = compilerContext.irBuiltIns.unitType + ) + + fieldsMissedTest = irNotEquals( + irInt(goldenMask), + irBinOp( + OperatorNameConventions.AND, + irInt(goldenMask), + irGet(seenVars[0]) + ) + ) + } else { + val goldenMaskList = properties.goldenMaskList + + var compositeExpression: IrExpression? = null + for (i in goldenMaskList.indices) { + val singleCheckExpr = irNotEquals( + irInt(goldenMaskList[i]), + irBinOp( + OperatorNameConventions.AND, + irInt(goldenMaskList[i]), + irGet(seenVars[i]) + ) + ) + + compositeExpression = if (compositeExpression == null) { + singleCheckExpr + } else { + irBinOp( + OperatorNameConventions.OR, + compositeExpression, + singleCheckExpr + ) + } + } + + fieldsMissedTest = compositeExpression!! + + throwErrorExpr = irBlock { + +irInvoke( + null, + throwMissedFieldExceptionArrayFunc!!, + createPrimitiveArrayOfExpression(compilerContext.irBuiltIns.intType, goldenMaskList.indices.map { irGet(seenVars[it]) }), + createPrimitiveArrayOfExpression(compilerContext.irBuiltIns.intType, goldenMaskList.map { irInt(it) }), + serialDescriptor, + typeHint = compilerContext.irBuiltIns.unitType + ) + } + } + + +irIfThen(compilerContext.irBuiltIns.unitType, fieldsMissedTest, throwErrorExpr) + } + fun generateSimplePropertyWithBackingField( propertyDescriptor: PropertyDescriptor, propertyParent: IrClass, @@ -485,18 +618,45 @@ interface IrBuilderExtension { return defaultsMap + extractDefaultValuesFromConstructor(irClass.getSuperClassNotAny()) } - fun buildInitializersRemapping(irClass: IrClass): (IrField) -> IrExpression? { - val defaultsMap = extractDefaultValuesFromConstructor(irClass) - return fun(f: IrField): IrExpression? { - val i = f.initializer?.expression ?: return null - val irExpression = - if (i is IrGetValueImpl && i.origin == IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER) { - // this is a primary constructor property, use corresponding default of value parameter - defaultsMap.getValue(i.symbol.descriptor as ParameterDescriptor) - } else { - i + /* + Creates an initializer adapter function that can replace IR expressions of getting constructor parameter value by some other expression. + Also adapter may replace IR expression of getting `this` value by another expression. + */ + fun createInitializerAdapter( + irClass: IrClass, + paramGetReplacer: (ValueParameterDescriptor) -> IrExpression?, + thisGetReplacer: Pair IrExpression>? = null + ): (IrExpressionBody) -> IrExpression { + val initializerTransformer = object : IrElementTransformerVoid() { + // try to replace `get some value` expression + override fun visitGetValue(expression: IrGetValue): IrExpression { + val symbol = expression.symbol + if (thisGetReplacer != null && thisGetReplacer.first == symbol) { + // replace `get this value` expression + return thisGetReplacer.second() } - return irExpression?.deepCopyWithVariables() + + val descriptor = symbol.descriptor + if (descriptor is ValueParameterDescriptor) { + // replace `get parameter value` expression + paramGetReplacer(descriptor)?.let { return it } + } + + // otherwise leave expression as it is + return super.visitGetValue(expression) + } + } + val defaultsMap = extractDefaultValuesFromConstructor(irClass) + return fun(initializer: IrExpressionBody): IrExpression { + val rawExpression = initializer.expression + val expression = + if (rawExpression is IrGetValueImpl && rawExpression.origin == IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER) { + // this is a primary constructor property, use corresponding default of value parameter + defaultsMap.getValue(rawExpression.symbol.descriptor as ParameterDescriptor)!! + } else { + rawExpression + } + return expression.deepCopyWithVariables().transform(initializerTransformer, null) } } diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt index bd2a5650413..6ce4ca31c27 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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. */ @@ -9,10 +9,12 @@ import org.jetbrains.kotlin.backend.common.deepCopyWithVariables import org.jetbrains.kotlin.backend.common.lower.irThrow import org.jetbrains.kotlin.codegen.CompilationException import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.builders.* import org.jetbrains.kotlin.ir.builders.declarations.addField import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImpl import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.types.* @@ -23,15 +25,14 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.module import org.jetbrains.kotlin.util.OperatorNameConventions +import org.jetbrains.kotlin.utils.getOrPutNullable import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializableCodegen import org.jetbrains.kotlinx.serialization.compiler.backend.common.serialName import org.jetbrains.kotlinx.serialization.compiler.diagnostic.serializableAnnotationIsUseless import org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationPluginContext import org.jetbrains.kotlinx.serialization.compiler.resolve.* -import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames.ARRAY_MASK_FIELD_MISSING_FUNC_FQ import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames.MISSING_FIELD_EXC import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames.SERIAL_DESC_FIELD -import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames.SINGLE_MASK_FIELD_MISSING_FUNC_FQ import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames.initializedDescriptorFieldName class SerializableIrGenerator( @@ -50,11 +51,6 @@ class SerializableIrGenerator( private val addElementFun = serialDescImplClass.findFunctionSymbol(CallingConventions.addElement) - val throwMissedFieldExceptionFunc = - if (useFieldMissingOptimization) compilerContext.referenceFunctions(SINGLE_MASK_FIELD_MISSING_FUNC_FQ).single() else null - val throwMissedFieldExceptionArrayFunc = - if (useFieldMissingOptimization) compilerContext.referenceFunctions(ARRAY_MASK_FIELD_MISSING_FUNC_FQ).single() else null - private fun IrClass.hasSerializableAnnotationWithoutArgs(): Boolean { val annot = getAnnotation(SerializationAnnotations.serializableAnnotationFqName) ?: return false @@ -69,7 +65,40 @@ class SerializableIrGenerator( override fun generateInternalConstructor(constructorDescriptor: ClassConstructorDescriptor) = irClass.contributeConstructor(constructorDescriptor) { ctor -> - val transformFieldInitializer = buildInitializersRemapping(irClass) + val thiz = irClass.thisReceiver!! + val serializableProperties = properties.serializableProperties + + val serialDescs = serializableProperties.map { it.descriptor }.toSet() + + val propertyByParamReplacer: (ValueParameterDescriptor) -> IrExpression? = + createPropertyByParamReplacer(irClass, serializableProperties, thiz, bindingContext) + + val initializerAdapter: (IrExpressionBody) -> IrExpression = createInitializerAdapter(irClass, propertyByParamReplacer) + + + var current: PropertyDescriptor? = null + val statementsAfterSerializableProperty: MutableMap> = mutableMapOf() + irClass.declarations.asSequence().forEach { + when { + // only properties with backing field + it is IrProperty && it.backingField != null -> { + if (it.descriptor in serialDescs) { + current = it.descriptor + } else if (it.backingField?.initializer != null) { + // skip transient lateinit or deferred properties (with null initializer) + val expression = initializerAdapter(it.backingField!!.initializer!!) + + statementsAfterSerializableProperty.getOrPutNullable(current, { mutableListOf() }) + .add(irSetField(irGet(thiz), it.backingField!!, expression)) + } + } + it is IrAnonymousInitializer -> { + val statements = it.body.deepCopyWithVariables().statements + statementsAfterSerializableProperty.getOrPutNullable(current, { mutableListOf() }) + .addAll(statements) + } + } + } // Missing field exception parts val exceptionFqn = getSerializationPackageFqn(MISSING_FIELD_EXC) @@ -77,16 +106,19 @@ class SerializableIrGenerator( .single { it.owner.valueParameters.singleOrNull()?.type?.isString() == true } val exceptionType = exceptionCtorRef.owner.returnType - val serializableProperties = properties.serializableProperties val seenVarsOffset = serializableProperties.bitMaskSlotCount() val seenVars = (0 until seenVarsOffset).map { ctor.valueParameters[it] } - val thiz = irClass.thisReceiver!! + val superClass = irClass.getSuperClassOrAny() var startPropOffset: Int = 0 - if (useFieldMissingOptimization) { - generateOptimizedGoldenMaskCheck(seenVars) + + if (useFieldMissingOptimization() && + // for abstract classes fields MUST BE checked in child classes + !serializableDescriptor.isAbstractSerializableClass() && !serializableDescriptor.isSealedSerializableClass() + ) { + generateGoldenMaskCheck(seenVars, properties, getSerialDescriptorExpr()) } when { superClass.symbol == compilerContext.irBuiltIns.anyClass -> generateAnySuperConstructorCall(toBuilder = this@contributeConstructor) @@ -96,6 +128,7 @@ class SerializableIrGenerator( else -> generateSuperNonSerializableCall(superClass) } + statementsAfterSerializableProperty[null]?.forEach { +it } for (index in startPropOffset until serializableProperties.size) { val prop = serializableProperties[index] val paramRef = ctor.valueParameters[index + seenVarsOffset] @@ -106,13 +139,14 @@ class SerializableIrGenerator( val ifNotSeenExpr: IrExpression = if (prop.optional) { val initializerBody = - requireNotNull(transformFieldInitializer(prop.irField)) { "Optional value without an initializer" } // todo: filter abstract here + requireNotNull(initializerAdapter(prop.irField.initializer!!)) { "Optional value without an initializer" } // todo: filter abstract here irSetField(irGet(thiz), backingFieldToAssign, initializerBody) } else { // property required - if (useFieldMissingOptimization) { + if (useFieldMissingOptimization()) { // field definitely not empty as it's checked before - no need another IF, only assign property from param +assignParamExpr + statementsAfterSerializableProperty[prop.descriptor]?.forEach { +it } continue } else { irThrow(irInvoke(null, exceptionCtorRef, irString(prop.name), typeHint = exceptionType)) @@ -130,97 +164,11 @@ class SerializableIrGenerator( ) +irIfThenElse(compilerContext.irBuiltIns.unitType, propNotSeenTest, ifNotSeenExpr, assignParamExpr) - } - // remaining initializers of variables - val serialDescs = serializableProperties.map { it.descriptor }.toSet() - irClass.declarations.asSequence() - .filterIsInstance() - .filter { it.descriptor !in serialDescs } - .filter { it.backingField != null } - .mapNotNull { prop -> transformFieldInitializer(prop.backingField!!)?.let { prop to it } } - .forEach { (prop, expr) -> +irSetField(irGet(thiz), prop.backingField!!, expr) } - - // init blocks - irClass.declarations.asSequence() - .filterIsInstance() - .forEach { initializer -> - initializer.body.deepCopyWithVariables().statements.forEach { +it } - } - } - - private fun IrBlockBodyBuilder.generateOptimizedGoldenMaskCheck(seenVars: List) { - if (serializableDescriptor.isAbstractSerializableClass() || serializableDescriptor.isSealedSerializableClass()) { - // for abstract classes fields MUST BE checked in child classes - return - } - - val fieldsMissedTest: IrExpression - val throwErrorExpr: IrExpression - - val maskSlotCount = seenVars.size - if (maskSlotCount == 1) { - val goldenMask = getGoldenMask() - - throwErrorExpr = irInvoke( - null, - throwMissedFieldExceptionFunc!!, - irGet(seenVars[0]), - irInt(goldenMask), - getSerialDescriptorExpr(), - typeHint = compilerContext.irBuiltIns.unitType - ) - - fieldsMissedTest = irNotEquals( - irInt(goldenMask), - irBinOp( - OperatorNameConventions.AND, - irInt(goldenMask), - irGet(seenVars[0]) - ) - ) - } else { - val goldenMaskList = getGoldenMaskList() - - var compositeExpression: IrExpression? = null - for (i in goldenMaskList.indices) { - val singleCheckExpr = irNotEquals( - irInt(goldenMaskList[i]), - irBinOp( - OperatorNameConventions.AND, - irInt(goldenMaskList[i]), - irGet(seenVars[i]) - ) - ) - - compositeExpression = if (compositeExpression == null) { - singleCheckExpr - } else { - irBinOp( - OperatorNameConventions.OR, - compositeExpression, - singleCheckExpr - ) - } - } - - fieldsMissedTest = compositeExpression!! - - throwErrorExpr = irBlock { - +irInvoke( - null, - throwMissedFieldExceptionArrayFunc!!, - createPrimitiveArrayOfExpression(compilerContext.irBuiltIns.intType, goldenMaskList.indices.map { irGet(seenVars[it]) }), - createPrimitiveArrayOfExpression(compilerContext.irBuiltIns.intType, goldenMaskList.map { irInt(it) }), - getSerialDescriptorExpr(), - typeHint = compilerContext.irBuiltIns.unitType - ) + statementsAfterSerializableProperty[prop.descriptor]?.forEach { +it } } } - +irIfThen(compilerContext.irBuiltIns.unitType, fieldsMissedTest, throwErrorExpr) - } - private fun IrBlockBodyBuilder.getSerialDescriptorExpr(): IrExpression { return if (serializableDescriptor.shouldHaveGeneratedSerializer && staticDescriptor) { val serializer = serializableDescriptor.classSerializer!! diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializerIrGenerator.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializerIrGenerator.kt index b6d23e642e4..f91c9a8cddb 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializerIrGenerator.kt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializerIrGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 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. */ @@ -12,10 +12,8 @@ import org.jetbrains.kotlin.backend.common.lower.irThrow import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.ir.builders.* import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.expressions.IrConstructorCall -import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.* -import org.jetbrains.kotlin.ir.expressions.mapValueParametersIndexed import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrAnonymousInitializerSymbolImpl @@ -23,13 +21,12 @@ import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.platform.jvm.isJvm import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.calls.components.hasDefaultValue import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerialTypeInfo import org.jetbrains.kotlinx.serialization.compiler.backend.common.SerializerCodegen import org.jetbrains.kotlinx.serialization.compiler.backend.common.getSerialTypeInfo -import org.jetbrains.kotlinx.serialization.compiler.backend.jvm.SerializerCodegenImpl -import org.jetbrains.kotlinx.serialization.compiler.backend.jvm.SerializerForEnumsCodegen import org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationDescriptorSerializerPlugin import org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationPluginContext import org.jetbrains.kotlinx.serialization.compiler.resolve.* @@ -243,9 +240,6 @@ open class SerializerIrGenerator( override fun generateSave(function: FunctionDescriptor) = irClass.contributeFunction(function) { saveFunc -> - val fieldInitializer: (SerializableProperty) -> IrExpression? = - buildInitializersRemapping(serializableIrClass).run { { invoke(it.irField) } } - fun irThis(): IrExpression = IrGetValueImpl(startOffset, endOffset, saveFunc.dispatchReceiverParameter!!.symbol) @@ -280,16 +274,22 @@ open class SerializerIrGenerator( // Ignore comparing to default values of properties from superclass, // because we do not have access to their fields (and initializers), if superclass is in another module. // In future, IR analogue of JVM's write$Self should be implemented. - val superClass = irClass.getSuperClassOrAny().descriptor + val superClass = serializableIrClass.getSuperClassOrAny().descriptor val ignoreIndexTo = if (superClass.isInternalSerializable) { bindingContext.serializablePropertiesFor(superClass).size } else { -1 } + val propertyByParamReplacer: (ValueParameterDescriptor) -> IrExpression? = + createPropertyByParamReplacer(serializableIrClass, serializableProperties, objectToSerialize, bindingContext) + + val thisSymbol = serializableIrClass.thisReceiver!!.symbol + val initializerAdapter: (IrExpressionBody) -> IrExpression = + createInitializerAdapter(serializableIrClass, propertyByParamReplacer, thisSymbol to { irGet(objectToSerialize) }) // internal serialization via virtual calls? - for ((index, property) in serializableProperties.filter { !it.transient }.withIndex()) { + for ((index, property) in serializableProperties.withIndex()) { // output.writeXxxElementValue(classDesc, index, value) val elementCall = formEncodeDecodePropertyCall(irGet(localOutput), saveFunc.dispatchReceiverParameter!!, property, {innerSerial, sti -> val f = @@ -314,11 +314,12 @@ open class SerializerIrGenerator( +elementCall } else { // emit check: - // if (obj.prop != DEFAULT_VALUE || output.shouldEncodeElementDefault(this.descriptor, i)) + // if ( if (output.shouldEncodeElementDefault(this.descriptor, i)) true else {obj.prop != DEFAULT_VALUE} ) { // output.encodeIntElement(this.descriptor, i, obj.prop) + // block {obj.prop != DEFAULT_VALUE} may contain several statements val shouldEncodeFunc = kOutputClass.referenceMethod(CallingConventions.shouldEncodeDefault) - val partA = irNotEquals(property.irGet(), fieldInitializer(property)!!) - val partB = irInvoke(irGet(localOutput), shouldEncodeFunc, irGet(localSerialDesc), irInt(index)) + val partA = irInvoke(irGet(localOutput), shouldEncodeFunc, irGet(localSerialDesc), irInt(index)) + val partB = irNotEquals(property.irGet(), initializerAdapter(property.irField.initializer!!)) // Ir infrastructure does not have dedicated symbol for ||, so // `a || b == if (a) true else b`, see org.jetbrains.kotlin.ir.builders.PrimitivesKt.oror val condition = irIfThenElse(compilerContext.irBuiltIns.booleanType, partA, irTrue(), partB) @@ -354,8 +355,8 @@ open class SerializerIrGenerator( } // returns null: Any? for boxed types and 0: for primitives - private fun IrBuilderWithScope.defaultValueAndType(prop: SerializableProperty): Pair { - val kType = prop.descriptor.returnType!! + private fun IrBuilderWithScope.defaultValueAndType(descriptor: PropertyDescriptor): Pair { + val kType = descriptor.returnType!! val T = kType.toIrType() val defaultPrimitive: IrExpression? = when { T.isInt() -> IrConstImpl.int(startOffset, endOffset, T, 0) @@ -397,12 +398,26 @@ open class SerializerIrGenerator( // calculating bit mask vars val blocksCnt = serializableProperties.bitMaskSlotCount() + val serialPropertiesIndexes = serializableProperties + .mapIndexed { i, property -> property to i } + .associate { (p, i) -> p.descriptor to i } + + val transients = serializableIrClass.declarations.asSequence() + .filterIsInstance() + .filter { !serialPropertiesIndexes.containsKey(it.descriptor) } + .filter { it.backingField != null } + // var bitMask0 = 0, bitMask1 = 0... val bitMasks = (0 until blocksCnt).map { irTemporary(irInt(0), "bitMask$it", isMutable = true) } // var local0 = null, local1 = null ... - val localProps = serializableProperties.mapIndexed { i, prop -> - val (expr, type) = defaultValueAndType(prop) - irTemporary(expr, "local$i", type, isMutable = true) + val serialPropertiesMap = serializableProperties.mapIndexed { i, prop -> i to prop.descriptor }.associate { (i, descriptor) -> + val (expr, type) = defaultValueAndType(descriptor) + descriptor to irTemporary(expr, "local$i", type, isMutable = true) + } + // var transient0 = null, transient0 = null ... + val transientsPropertiesMap = transients.mapIndexed { i, prop -> i to prop.descriptor }.associate { (i, descriptor) -> + val (expr, type) = defaultValueAndType(descriptor) + descriptor to irTemporary(expr, "transient$i", type, isMutable = true) } //input = input.beginStructure(...) @@ -423,7 +438,7 @@ open class SerializerIrGenerator( inputClass.referenceMethod( "${CallingConventions.decode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}", {it.valueParameters.size == 4} ) to listOf( - localSerialDesc.get(), irInt(index), innerSerial, localProps[index].get() + localSerialDesc.get(), irInt(index), innerSerial, serialPropertiesMap.getValue(property.descriptor).get() ) }, { inputClass.referenceMethod( @@ -434,7 +449,7 @@ open class SerializerIrGenerator( }, returnTypeHint = property.type.toIrType()) // local$i = localInput.decode...(...) +irSet( - localProps[index].symbol, + serialPropertiesMap.getValue(property.descriptor).symbol, decodeFuncToCall ) // bitMask[i] |= 1 << x @@ -491,17 +506,103 @@ open class SerializerIrGenerator( irGet(localSerialDesc) ) - // todo: set properties in external deserialization - var args: List = localProps.map { it.get() } val typeArgs = (loadFunc.returnType as IrSimpleType).arguments.map { (it as IrTypeProjection).type } - val ctor: IrConstructorSymbol = if (serializableDescriptor.isInternalSerializable) { + if (serializableDescriptor.isInternalSerializable) { + var args: List = serializableProperties.map { serialPropertiesMap.getValue(it.descriptor).get() } args = bitMasks.map { irGet(it) } + args + irNull() - serializableSyntheticConstructor(serializableIrClass) + val ctor: IrConstructorSymbol = serializableSyntheticConstructor(serializableIrClass) + +irReturn(irInvoke(null, ctor, typeArgs, args)) } else { - compilerContext.referenceConstructors(serializableDescriptor.fqNameSafe).single { it.owner.isPrimary } - } + // check properties presence + val serialDescIrProperty = irClass.searchForProperty(generatedSerialDescPropertyDescriptor!!) + val serialDescriptorExpr = irGetField(null, serialDescIrProperty.backingField!!) + generateGoldenMaskCheck(bitMasks, properties, serialDescriptorExpr) - +irReturn(irInvoke(null, ctor, typeArgs, args)) + + val ctor: IrConstructorSymbol = + compilerContext.referenceConstructors(serializableDescriptor.fqNameSafe).single { it.owner.isPrimary } + val params = ctor.owner.valueParameters + + + val variableByParamReplacer: (ValueParameterDescriptor) -> IrExpression? = { + val propertyDescriptor = bindingContext[BindingContext.VALUE_PARAMETER_AS_PROPERTY, it] + if (propertyDescriptor != null) { + val serializable = serialPropertiesMap[propertyDescriptor] + (serializable ?: transientsPropertiesMap[propertyDescriptor])?.get() + } else { + null + } + } + val initializerAdapter: (IrExpressionBody) -> IrExpression = + createInitializerAdapter(serializableIrClass, variableByParamReplacer) + + // constructor args: + val ctorArgs = params.map { parameter -> + val parameterDescriptor = parameter.descriptor as ValueParameterDescriptor + val propertyDescriptor = bindingContext[BindingContext.VALUE_PARAMETER_AS_PROPERTY, parameterDescriptor]!! + val serialProperty = serialPropertiesMap[propertyDescriptor] + + // null if transient + if (serialProperty != null) { + val index = serialPropertiesIndexes.getValue(propertyDescriptor) + if (parameterDescriptor.hasDefaultValue()) { + val propNotSeenTest = + irEquals( + irInt(0), + irBinOp( + OperatorNameConventions.AND, + bitMasks[index / 32].get(), + irInt(1 shl (index % 32)) + ) + ) + + // if(mask$j && propertyMask == 0) local$i = + val defaultValueExp = parameter.defaultValue!! + val expr = initializerAdapter(defaultValueExp) + +irIfThen(propNotSeenTest, irSet(serialProperty.symbol, expr)) + } + serialProperty.get() + } else { + val transientVar = transientsPropertiesMap.getValue(propertyDescriptor) + if (parameterDescriptor.hasDefaultValue()) { + val defaultValueExp = parameter.defaultValue!! + val expr = initializerAdapter(defaultValueExp) + +irSet(transientVar.symbol, expr) + } + transientVar.get() + } + } + + val serializerVar = irTemporary(irInvoke(null, ctor, typeArgs, ctorArgs), "serializable") + generateSetStandaloneProperties(serializerVar, serialPropertiesMap::getValue, serialPropertiesIndexes::getValue, bitMasks) + +irReturn(irGet(serializerVar)) + } + } + + private fun IrBlockBodyBuilder.generateSetStandaloneProperties( + serializableVar: IrVariable, + propVars: (PropertyDescriptor) -> IrVariable, + propIndexes: (PropertyDescriptor) -> Int, + bitMasks: List + ) { + for (property in properties.serializableStandaloneProperties) { + val localPropIndex = propIndexes(property.descriptor) + // generate setter call + val setter = property.getIrPropertyFrom(serializableIrClass).setter!! + val propSeenTest = + irNotEquals( + irInt(0), + irBinOp( + OperatorNameConventions.AND, + irGet(bitMasks[localPropIndex / 32]), + irInt(1 shl (localPropIndex % 32)) + ) + ) + + val setterInvokeExpr = irSet(setter.returnType, irGet(serializableVar), setter.symbol, irGet(propVars(property.descriptor))) + + +irIfThen(propSeenTest, setterInvokeExpr) + } } companion object { diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/jvm/SerializableCodegenImpl.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/jvm/SerializableCodegenImpl.kt index 946c85ee490..98fca4b96f3 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/jvm/SerializableCodegenImpl.kt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/jvm/SerializableCodegenImpl.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. + * Copyright 2010-2021 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.jetbrains.kotlinx.serialization.compiler.backend.jvm import org.jetbrains.kotlin.codegen.* +import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor @@ -30,6 +31,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassOrAny import org.jetbrains.kotlin.resolve.descriptorUtil.module import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin import org.jetbrains.kotlinx.serialization.compiler.backend.common.* +import org.jetbrains.kotlinx.serialization.compiler.diagnostic.VersionReader import org.jetbrains.kotlinx.serialization.compiler.diagnostic.serializableAnnotationIsUseless import org.jetbrains.kotlinx.serialization.compiler.resolve.* import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames.ARRAY_MASK_FIELD_MISSING_FUNC_NAME @@ -45,6 +47,8 @@ class SerializableCodegenImpl( ) : SerializableCodegen(classCodegen.descriptor, classCodegen.bindingContext) { private val thisAsmType = classCodegen.typeMapper.mapClass(serializableDescriptor) + private val fieldMissingOptimizationVersion = ApiVersion.parse("1.1")!! + private val useFieldMissingOptimization = canUseFieldMissingOptimization() companion object { fun generateSerializableExtensions(codegen: ImplementationBodyCodegen) { @@ -289,7 +293,7 @@ class SerializableCodegenImpl( val allPresentsLabel = Label() val maskSlotCount = properties.serializableProperties.bitMaskSlotCount() if (maskSlotCount == 1) { - val goldenMask = getGoldenMask() + val goldenMask = properties.goldenMask iconst(goldenMask) dup() @@ -310,7 +314,7 @@ class SerializableCodegenImpl( } else { val fieldsMissingLabel = Label() - val goldenMaskList = getGoldenMaskList() + val goldenMaskList = properties.goldenMaskList goldenMaskList.forEachIndexed { i, goldenMask -> val maskIndex = maskVar + i // if( (goldenMask & seen) != goldenMask ) @@ -404,4 +408,12 @@ class SerializableCodegenImpl( this.gen(param.defaultValue, mapType) this.v.putfield(thisAsmType.internalName, prop.name.asString(), mapType.descriptor) } + + private fun canUseFieldMissingOptimization(): Boolean { + val implementationVersion = VersionReader.getVersionsForCurrentModuleFromContext( + currentDeclaration.module, + bindingContext + )?.implementationVersion + return if (implementationVersion != null) implementationVersion >= fieldMissingOptimizationVersion else false + } } diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/resolve/SerializableProperties.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/resolve/SerializableProperties.kt index 2382943ebf0..08d13828810 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/resolve/SerializableProperties.kt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/resolve/SerializableProperties.kt @@ -88,6 +88,34 @@ class SerializableProperties(private val serializableClass: ClassDescriptor, val ?.original?.valueParameters?.any { it.declaresDefaultValue() } ?: false } +internal val SerializableProperties.goldenMask: Int + get() { + var goldenMask = 0 + var requiredBit = 1 + for (property in serializableProperties) { + if (!property.optional) { + goldenMask = goldenMask or requiredBit + } + requiredBit = requiredBit shl 1 + } + return goldenMask + } + +internal val SerializableProperties.goldenMaskList: List + get() { + val maskSlotCount = serializableProperties.bitMaskSlotCount() + val goldenMaskList = MutableList(maskSlotCount) { 0 } + + for (i in serializableProperties.indices) { + if (!serializableProperties[i].optional) { + val slotNumber = i / 32 + val bitInSlot = i % 32 + goldenMaskList[slotNumber] = goldenMaskList[slotNumber] or (1 shl bitInSlot) + } + } + return goldenMaskList + } + internal fun List.bitMaskSlotCount() = size / 32 + 1 internal fun bitMaskSlotAt(propertyIndex: Int) = propertyIndex / 32 From 5793f77ece25700f762ab30f7a99212320e7b8d8 Mon Sep 17 00:00:00 2001 From: Tianyu Geng Date: Thu, 11 Feb 2021 15:02:08 -0800 Subject: [PATCH 237/368] FIR IDE: AddModifierFix -> AddModifierFixMpp --- .../idea/inspections/AddModifierFixFactory.kt | 4 ++-- .../idea/inspections/LeakingThisInspection.kt | 4 ++-- .../MemberVisibilityCanBePrivateInspection.kt | 4 ++-- .../idea/quickfix/AddConstModifierFix.kt | 2 +- .../idea/quickfix/AddDataModifierFix.kt | 2 +- .../idea/quickfix/AddInlineModifierFix.kt | 2 +- .../AddInlineToFunctionWithReifiedFix.kt | 2 +- ...AddModifierFix.kt => AddModifierFixMpp.kt} | 10 ++++----- .../AddReifiedToTypeParameterOfFunctionFix.kt | 2 +- .../idea/quickfix/AddSuspendModifierFix.kt | 2 +- ...ypeParameterReifiedAndFunctionInlineFix.kt | 2 +- .../kotlin/idea/quickfix/QuickFixRegistrar.kt | 22 +++++++++---------- .../KotlinElementActionsFactory.kt | 4 ++-- .../nj2k/postProcessing/J2kPostProcessor.kt | 2 +- 14 files changed, 32 insertions(+), 32 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/quickfix/{AddModifierFix.kt => AddModifierFixMpp.kt} (96%) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/AddModifierFixFactory.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/AddModifierFixFactory.kt index 524bad2f994..51439c47ee3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/AddModifierFixFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/AddModifierFixFactory.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.DiagnosticWithParameters2 import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde -import org.jetbrains.kotlin.idea.quickfix.AddModifierFix +import org.jetbrains.kotlin.idea.quickfix.AddModifierFixMpp import org.jetbrains.kotlin.idea.quickfix.CleanupFix import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory import org.jetbrains.kotlin.idea.refactoring.canRefactor @@ -34,7 +34,7 @@ class AddModifierFixFactory(val token: KtModifierKeywordToken) : KotlinSingleInt val target = DescriptorToSourceUtilsIde.getAnyDeclaration(diagnostic.psiFile.project, functionDescriptor) as? KtModifierListOwner ?: return null if (target.canRefactor()) { - return object : AddModifierFix(target, token), CleanupFix {} + return object : AddModifierFixMpp(target, token), CleanupFix {} } return null } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/LeakingThisInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/LeakingThisInspection.kt index f1fd9e7a110..080c6269b7c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/LeakingThisInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/LeakingThisInspection.kt @@ -16,7 +16,7 @@ import org.jetbrains.kotlin.cfg.LeakingThisDescriptor.* import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent -import org.jetbrains.kotlin.idea.quickfix.AddModifierFix +import org.jetbrains.kotlin.idea.quickfix.AddModifierFixMpp import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject @@ -100,7 +100,7 @@ class LeakingThisInspection : AbstractKotlinInspection() { val useScope = declaration.useScope if (DefinitionsScopedSearch.search(declaration, useScope).findFirst() != null) return null if ((declaration.containingClassOrObject as? KtClass)?.isInterface() == true) return null - return IntentionWrapper(AddModifierFix(declaration, KtTokens.FINAL_KEYWORD), declaration.containingFile) + return IntentionWrapper(AddModifierFixMpp(declaration, KtTokens.FINAL_KEYWORD), declaration.containingFile) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/MemberVisibilityCanBePrivateInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/MemberVisibilityCanBePrivateInspection.kt index f5c9e09a000..d4f19abead3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/MemberVisibilityCanBePrivateInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/MemberVisibilityCanBePrivateInspection.kt @@ -38,7 +38,7 @@ import org.jetbrains.kotlin.idea.core.canBePrivate import org.jetbrains.kotlin.idea.core.isInheritable import org.jetbrains.kotlin.idea.core.isOverridable import org.jetbrains.kotlin.idea.core.toDescriptor -import org.jetbrains.kotlin.idea.quickfix.AddModifierFix +import org.jetbrains.kotlin.idea.quickfix.AddModifierFixMpp import org.jetbrains.kotlin.idea.refactoring.isConstructorDeclaredProperty import org.jetbrains.kotlin.idea.search.isCheapEnoughToSearchConsideringOperators import org.jetbrains.kotlin.idea.search.usagesSearch.dataClassComponentFunction @@ -159,7 +159,7 @@ class MemberVisibilityCanBePrivateInspection : AbstractKotlinInspection() { declaration.visibilityModifier() ?: nameElement, KotlinBundle.message("0.1.could.be.private", member, declaration.getName().toString()), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, - IntentionWrapper(AddModifierFix(modifierListOwner, KtTokens.PRIVATE_KEYWORD), declaration.containingKtFile) + IntentionWrapper(AddModifierFixMpp(modifierListOwner, KtTokens.PRIVATE_KEYWORD), declaration.containingKtFile) ) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddConstModifierFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddConstModifierFix.kt index 1adfb8dad31..44e1fd9c9c5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddConstModifierFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddConstModifierFix.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.psi.psiUtil.hasActualModifier import org.jetbrains.kotlin.resolve.checkers.ConstModifierChecker import org.jetbrains.kotlin.resolve.source.PsiSourceElement -class AddConstModifierFix(property: KtProperty) : AddModifierFix(property, KtTokens.CONST_KEYWORD), CleanupFix { +class AddConstModifierFix(property: KtProperty) : AddModifierFixMpp(property, KtTokens.CONST_KEYWORD), CleanupFix { private val pointer = property.createSmartPointer() override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddDataModifierFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddDataModifierFix.kt index 30a54022847..4cc583989b9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddDataModifierFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddDataModifierFix.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall -class AddDataModifierFix(element: KtClass, private val fqName: String) : AddModifierFix(element, KtTokens.DATA_KEYWORD) { +class AddDataModifierFix(element: KtClass, private val fqName: String) : AddModifierFixMpp(element, KtTokens.DATA_KEYWORD) { override fun getText() = KotlinBundle.message("fix.make.data.class", fqName) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddInlineModifierFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddInlineModifierFix.kt index 018a0ad9233..2e4026cffa2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddInlineModifierFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddInlineModifierFix.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType class AddInlineModifierFix( parameter: KtParameter, modifier: KtModifierKeywordToken -) : AddModifierFix(parameter, modifier) { +) : AddModifierFixMpp(parameter, modifier) { override fun getText(): String { val element = this.element diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddInlineToFunctionWithReifiedFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddInlineToFunctionWithReifiedFix.kt index 942a929fd03..bf4903025f8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddInlineToFunctionWithReifiedFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddInlineToFunctionWithReifiedFix.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtNamedFunction import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -class AddInlineToFunctionWithReifiedFix(function: KtNamedFunction) : AddModifierFix(function, KtTokens.INLINE_KEYWORD) { +class AddInlineToFunctionWithReifiedFix(function: KtNamedFunction) : AddModifierFixMpp(function, KtTokens.INLINE_KEYWORD) { companion object Factory : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): IntentionAction? { val element = Errors.REIFIED_TYPE_PARAMETER_NO_INLINE.cast(diagnostic) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFixMpp.kt similarity index 96% rename from idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt rename to idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFixMpp.kt index b1eb3e62438..feff1271644 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFixMpp.kt @@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.TypeUtils -open class AddModifierFix( +open class AddModifierFixMpp( element: KtModifierListOwner, protected val modifier: KtModifierKeywordToken ) : KotlinCrossLanguageQuickFixAction(element), KotlinUniversalQuickFix { @@ -105,7 +105,7 @@ open class AddModifierFix( } } - fun createIfApplicable(modifierListOwner: KtModifierListOwner, modifier: KtModifierKeywordToken): AddModifierFix? { + fun createIfApplicable(modifierListOwner: KtModifierListOwner, modifier: KtModifierKeywordToken): AddModifierFixMpp? { when (modifier) { ABSTRACT_KEYWORD, OPEN_KEYWORD -> { if (modifierListOwner is KtObjectDeclaration) return null @@ -132,7 +132,7 @@ open class AddModifierFix( } } } - return AddModifierFix(modifierListOwner, modifier) + return AddModifierFixMpp(modifierListOwner, modifier) } } @@ -142,7 +142,7 @@ open class AddModifierFix( val typeReference = diagnostic.psiElement as KtTypeReference val declaration = typeReference.classForRefactor() ?: return null if (declaration.isEnum() || declaration.isData()) return null - return AddModifierFix(declaration, OPEN_KEYWORD) + return AddModifierFixMpp(declaration, OPEN_KEYWORD) } } @@ -157,7 +157,7 @@ open class AddModifierFix( if (TypeUtils.isNullableType(type)) return null if (KotlinBuiltIns.isPrimitiveType(type)) return null - return AddModifierFix(property, LATEINIT_KEYWORD) + return AddModifierFixMpp(property, LATEINIT_KEYWORD) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddReifiedToTypeParameterOfFunctionFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddReifiedToTypeParameterOfFunctionFix.kt index 1e5efc6160d..d3736248392 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddReifiedToTypeParameterOfFunctionFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddReifiedToTypeParameterOfFunctionFix.kt @@ -47,7 +47,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType class AddReifiedToTypeParameterOfFunctionFix( typeParameter: KtTypeParameter, function: KtNamedFunction -) : AddModifierFix(typeParameter, KtTokens.REIFIED_KEYWORD) { +) : AddModifierFixMpp(typeParameter, KtTokens.REIFIED_KEYWORD) { private val inlineFix = AddInlineToFunctionWithReifiedFix(function) private val elementName = RemoveModifierFix.getElementName(function) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddSuspendModifierFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddSuspendModifierFix.kt index 25963c792ef..95c68b5586d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddSuspendModifierFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddSuspendModifierFix.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils class AddSuspendModifierFix( element: KtModifierListOwner, private val declarationName: String? -) : AddModifierFix(element, KtTokens.SUSPEND_KEYWORD) { +) : AddModifierFixMpp(element, KtTokens.SUSPEND_KEYWORD) { override fun getText() = when (element) { is KtNamedFunction -> { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeTypeParameterReifiedAndFunctionInlineFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeTypeParameterReifiedAndFunctionInlineFix.kt index 52c34fec6d1..d5778c6b5a1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeTypeParameterReifiedAndFunctionInlineFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeTypeParameterReifiedAndFunctionInlineFix.kt @@ -32,7 +32,7 @@ class MakeTypeParameterReifiedAndFunctionInlineFix( override fun invoke(project: Project, editor: Editor?, file: KtFile) { inlineFix.invoke(project, editor, file) - AddModifierFix(typeParameter, KtTokens.REIFIED_KEYWORD).invoke(project, editor, file) + AddModifierFixMpp(typeParameter, KtTokens.REIFIED_KEYWORD).invoke(project, editor, file) } companion object : KotlinSingleIntentionActionFactory() { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index 0c4d532b0a1..b8410695ca2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -66,7 +66,7 @@ class QuickFixRegistrar : QuickFixContributor { } val removeAbstractModifierFactory = createRemoveModifierFromListOwnerPsiBasedFactory(ABSTRACT_KEYWORD ) - val addAbstractModifierFactory = AddModifierFix.createFactory(ABSTRACT_KEYWORD) + val addAbstractModifierFactory = AddModifierFixMpp.createFactory(ABSTRACT_KEYWORD) ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS.registerFactory(removeAbstractModifierFactory) @@ -83,7 +83,7 @@ class QuickFixRegistrar : QuickFixContributor { MUST_BE_INITIALIZED_OR_BE_ABSTRACT.registerFactory(InitializePropertyQuickFixFactory) MUST_BE_INITIALIZED.registerFactory(InitializePropertyQuickFixFactory) - val addAbstractToClassFactory = AddModifierFix.createFactory(ABSTRACT_KEYWORD, KtClassOrObject::class.java) + val addAbstractToClassFactory = AddModifierFixMpp.createFactory(ABSTRACT_KEYWORD, KtClassOrObject::class.java) ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS.registerFactory(removeAbstractModifierFactory, addAbstractToClassFactory) ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.registerFactory(removeAbstractModifierFactory, addAbstractToClassFactory) @@ -104,7 +104,7 @@ class QuickFixRegistrar : QuickFixContributor { AddFunctionToSupertypeFix, AddPropertyToSupertypeFix ) - VIRTUAL_MEMBER_HIDDEN.registerFactory(AddModifierFix.createFactory(OVERRIDE_KEYWORD)) + VIRTUAL_MEMBER_HIDDEN.registerFactory(AddModifierFixMpp.createFactory(OVERRIDE_KEYWORD)) USELESS_CAST.registerFactory(RemoveUselessCastFix) @@ -128,7 +128,7 @@ class QuickFixRegistrar : QuickFixContributor { val removeOpenModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerPsiBasedFactory(OPEN_KEYWORD) NON_FINAL_MEMBER_IN_FINAL_CLASS.registerFactory( - AddModifierFix.createFactory(OPEN_KEYWORD, KtClass::class.java), + AddModifierFixMpp.createFactory(OPEN_KEYWORD, KtClass::class.java), removeOpenModifierFactory ) NON_FINAL_MEMBER_IN_OBJECT.registerFactory(removeOpenModifierFactory) @@ -138,7 +138,7 @@ class QuickFixRegistrar : QuickFixContributor { SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY.registerFactory(removeModifierFactory) PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY.registerFactory(removeModifierFactory) PRIVATE_SETTER_FOR_OPEN_PROPERTY.registerFactory( - AddModifierFix.createFactory(FINAL_KEYWORD, KtProperty::class.java), + AddModifierFixMpp.createFactory(FINAL_KEYWORD, KtProperty::class.java), removeModifierFactory ) REDUNDANT_MODIFIER_IN_GETTER.registerFactory(removeRedundantModifierFactory) @@ -296,16 +296,16 @@ class QuickFixRegistrar : QuickFixContributor { UNCHECKED_CAST.registerFactory(ChangeToStarProjectionFix) CANNOT_CHECK_FOR_ERASED.registerFactory(ChangeToStarProjectionFix) - INACCESSIBLE_OUTER_CLASS_EXPRESSION.registerFactory(AddModifierFix.createFactory(INNER_KEYWORD, KtClass::class.java)) + INACCESSIBLE_OUTER_CLASS_EXPRESSION.registerFactory(AddModifierFixMpp.createFactory(INNER_KEYWORD, KtClass::class.java)) - FINAL_SUPERTYPE.registerFactory(AddModifierFix.MakeClassOpenFactory) - FINAL_UPPER_BOUND.registerFactory(AddModifierFix.MakeClassOpenFactory) + FINAL_SUPERTYPE.registerFactory(AddModifierFixMpp.MakeClassOpenFactory) + FINAL_UPPER_BOUND.registerFactory(AddModifierFixMpp.MakeClassOpenFactory) OVERRIDING_FINAL_MEMBER.registerFactory(MakeOverriddenMemberOpenFix) PARAMETER_NAME_CHANGED_ON_OVERRIDE.registerFactory(RenameParameterToMatchOverriddenMethodFix) - NESTED_CLASS_NOT_ALLOWED.registerFactory(AddModifierFix.createFactory(INNER_KEYWORD)) + NESTED_CLASS_NOT_ALLOWED.registerFactory(AddModifierFixMpp.createFactory(INNER_KEYWORD)) CONFLICTING_PROJECTION.registerFactory(RemoveModifierFix.createRemoveProjectionFactory(false)) PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT.registerFactory(RemoveModifierFix.createRemoveProjectionFactory(false)) @@ -546,7 +546,7 @@ class QuickFixRegistrar : QuickFixContributor { NO_ACTUAL_FOR_EXPECT.registerFactory(CreateActualFix) NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS.registerFactory(AddActualFix) - ACTUAL_MISSING.registerFactory(AddModifierFix.createFactory(ACTUAL_KEYWORD)) + ACTUAL_MISSING.registerFactory(AddModifierFixMpp.createFactory(ACTUAL_KEYWORD)) CAST_NEVER_SUCCEEDS.registerFactory(ReplacePrimitiveCastWithNumberConversionFix) @@ -569,7 +569,7 @@ class QuickFixRegistrar : QuickFixContributor { CONFLICTING_OVERLOADS.registerFactory(ChangeSuspendInHierarchyFix) - MUST_BE_INITIALIZED_OR_BE_ABSTRACT.registerFactory(AddModifierFix.AddLateinitFactory) + MUST_BE_INITIALIZED_OR_BE_ABSTRACT.registerFactory(AddModifierFixMpp.AddLateinitFactory) RETURN_NOT_ALLOWED.registerFactory(ChangeToLabeledReturnFix) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/crossLanguage/KotlinElementActionsFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/crossLanguage/KotlinElementActionsFactory.kt index 99fb330c1bd..6c307f2aa2c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/crossLanguage/KotlinElementActionsFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/crossLanguage/KotlinElementActionsFactory.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny import org.jetbrains.kotlin.idea.core.ShortenReferences import org.jetbrains.kotlin.idea.core.appendModifier -import org.jetbrains.kotlin.idea.quickfix.AddModifierFix +import org.jetbrains.kotlin.idea.quickfix.AddModifierFixMpp import org.jetbrains.kotlin.idea.quickfix.RemoveModifierFix import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.* import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.CreateCallableFromUsageFix @@ -198,7 +198,7 @@ class KotlinElementActionsFactory : JvmElementActionsFactory() { if (kToken == null) return emptyList() val action = if (shouldPresentMapped) - AddModifierFix.createIfApplicable(kModifierOwner, kToken) + AddModifierFixMpp.createIfApplicable(kModifierOwner, kToken) else RemoveModifierFix(kModifierOwner, kToken, false) return listOfNotNull(action) diff --git a/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/J2kPostProcessor.kt b/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/J2kPostProcessor.kt index 0dde6f9dfb7..721e0d8e395 100644 --- a/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/J2kPostProcessor.kt +++ b/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/J2kPostProcessor.kt @@ -129,7 +129,7 @@ private val errorsFixingDiagnosticBasedPostProcessingGroup = Errors.REDUNDANT_PROJECTION ), diagnosticBasedProcessing( - AddModifierFix.createFactory(KtTokens.OVERRIDE_KEYWORD), + AddModifierFixMpp.createFactory(KtTokens.OVERRIDE_KEYWORD), Errors.VIRTUAL_MEMBER_HIDDEN ), diagnosticBasedProcessing( From 652207dcac21a47fcddd52ad983c771f3918a634 Mon Sep 17 00:00:00 2001 From: Tianyu Geng Date: Thu, 11 Feb 2021 16:24:07 -0800 Subject: [PATCH 238/368] FIR IDE: add AddModifierFix --- .../kotlin/idea/quickfix/AddModifierFix.kt | 114 ++++++++++++++++++ .../kotlin/idea/quickfix/AddModifierFixMpp.kt | 89 ++------------ 2 files changed, 124 insertions(+), 79 deletions(-) create mode 100644 idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt new file mode 100644 index 00000000000..5b38e72357e --- /dev/null +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt @@ -0,0 +1,114 @@ +/* + * Copyright 2010-2021 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.idea.quickfix + +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile +import com.intellij.psi.util.PsiTreeUtil +import org.jetbrains.kotlin.idea.KotlinBundle +import org.jetbrains.kotlin.idea.inspections.KotlinUniversalQuickFix +import org.jetbrains.kotlin.lexer.KtModifierKeywordToken +import org.jetbrains.kotlin.lexer.KtTokens +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.containingClass +import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject + +open class AddModifierFix( + element: KtModifierListOwner, + protected val modifier: KtModifierKeywordToken +) : KotlinCrossLanguageQuickFixAction(element), KotlinUniversalQuickFix { + override fun getText(): String { + val element = element ?: return "" + if (modifier in modalityModifiers || modifier in KtTokens.VISIBILITY_MODIFIERS || modifier == KtTokens.CONST_KEYWORD) { + return KotlinBundle.message("fix.add.modifier.text", RemoveModifierFix.getElementName(element), modifier.value) + } + return KotlinBundle.message("fix.add.modifier.text.generic", modifier.value) + } + + override fun getFamilyName() = KotlinBundle.message("fix.add.modifier.family") + + protected fun invokeOnElement(element: KtModifierListOwner?) { + element?.addModifier(modifier) + + if (modifier == KtTokens.ABSTRACT_KEYWORD && (element is KtProperty || element is KtNamedFunction)) { + element.containingClass()?.run { + if (!hasModifier(KtTokens.ABSTRACT_KEYWORD) && !hasModifier(KtTokens.SEALED_KEYWORD)) { + addModifier(KtTokens.ABSTRACT_KEYWORD) + } + } + } + } + + override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) { + val originalElement = element + invokeOnElement(originalElement) + } + + // TODO: consider checking if this fix is available by testing if the [element] can be refactored by calling + // FIR version of [org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringUtilKt#canRefactor] + override fun isAvailableImpl(project: Project, editor: Editor?, file: PsiFile): Boolean = element != null + + interface Factory { + fun createFactory(modifier: KtModifierKeywordToken): QuickFixesPsiBasedFactory { + return createFactory(modifier, KtModifierListOwner::class.java) + } + + fun createFactory( + modifier: KtModifierKeywordToken, + modifierOwnerClass: Class + ): QuickFixesPsiBasedFactory { + return quickFixesPsiBasedFactory { e -> + val modifierListOwner = + PsiTreeUtil.getParentOfType(e, modifierOwnerClass, false) ?: return@quickFixesPsiBasedFactory emptyList() + listOfNotNull(createIfApplicable(modifierListOwner, modifier)) + } + } + + fun createIfApplicable(modifierListOwner: KtModifierListOwner, modifier: KtModifierKeywordToken): AddModifierFix? { + when (modifier) { + KtTokens.ABSTRACT_KEYWORD, KtTokens.OPEN_KEYWORD -> { + if (modifierListOwner is KtObjectDeclaration) return null + if (modifierListOwner is KtEnumEntry) return null + if (modifierListOwner is KtDeclaration && modifierListOwner !is KtClass) { + val parentClassOrObject = modifierListOwner.containingClassOrObject ?: return null + if (parentClassOrObject is KtObjectDeclaration) return null + if (parentClassOrObject is KtEnumEntry) return null + } + if (modifier == KtTokens.ABSTRACT_KEYWORD + && modifierListOwner is KtClass + && modifierListOwner.hasModifier(KtTokens.INLINE_KEYWORD) + ) return null + } + KtTokens.INNER_KEYWORD -> { + if (modifierListOwner is KtObjectDeclaration) return null + if (modifierListOwner is KtClass) { + if (modifierListOwner.isInterface() || + modifierListOwner.isSealed() || + modifierListOwner.isEnum() || + modifierListOwner.isData() || + modifierListOwner.isAnnotation() + ) return null + } + } + } + return AddModifierFix(modifierListOwner, modifier) + } + + fun createModifierFix( + element: KtModifierListOwner, + modifier: KtModifierKeywordToken + ): T + } + + companion object : Factory { + private val modalityModifiers = setOf(KtTokens.ABSTRACT_KEYWORD, KtTokens.OPEN_KEYWORD, KtTokens.FINAL_KEYWORD) + override fun createModifierFix(element: KtModifierListOwner, modifier: KtModifierKeywordToken): AddModifierFix = + AddModifierFix(element, modifier) + + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFixMpp.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFixMpp.kt index feff1271644..dc98d290348 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFixMpp.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFixMpp.kt @@ -25,48 +25,26 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Errors -import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny -import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil -import org.jetbrains.kotlin.idea.inspections.KotlinUniversalQuickFix import org.jetbrains.kotlin.idea.refactoring.canRefactor import org.jetbrains.kotlin.idea.util.runOnExpectAndAllActuals import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.lexer.KtTokens.* -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.containingClass -import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject +import org.jetbrains.kotlin.psi.KtClass +import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtModifierListOwner +import org.jetbrains.kotlin.psi.KtTypeReference import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.TypeUtils +/** Similar to [AddModifierFix] but with multi-platform support. */ open class AddModifierFixMpp( element: KtModifierListOwner, - protected val modifier: KtModifierKeywordToken -) : KotlinCrossLanguageQuickFixAction(element), KotlinUniversalQuickFix { - override fun getText(): String { - val element = element ?: return "" - if (modifier in modalityModifiers || modifier in VISIBILITY_MODIFIERS || modifier == CONST_KEYWORD) { - return KotlinBundle.message("fix.add.modifier.text", RemoveModifierFix.getElementName(element), modifier.value) - } - return KotlinBundle.message("fix.add.modifier.text.generic", modifier.value) - } - - override fun getFamilyName() = KotlinBundle.message("fix.add.modifier.family") - - private fun invokeOnElement(element: KtModifierListOwner?) { - element?.addModifier(modifier) - - if (modifier == ABSTRACT_KEYWORD && (element is KtProperty || element is KtNamedFunction)) { - element.containingClass()?.run { - if (!hasModifier(ABSTRACT_KEYWORD) && !hasModifier(SEALED_KEYWORD)) { - addModifier(ABSTRACT_KEYWORD) - } - } - } - } + modifier: KtModifierKeywordToken +) : AddModifierFix(element, modifier) { override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) { val originalElement = element @@ -82,59 +60,12 @@ open class AddModifierFixMpp( return element.canRefactor() } - companion object { - + companion object : Factory { private fun KtModifierKeywordToken.isMultiplatformPersistent(): Boolean = this in MODALITY_MODIFIERS || this == INLINE_KEYWORD - private val modalityModifiers = setOf(ABSTRACT_KEYWORD, OPEN_KEYWORD, FINAL_KEYWORD) - - fun createFactory(modifier: KtModifierKeywordToken): KotlinSingleIntentionActionFactory { - return createFactory(modifier, KtModifierListOwner::class.java) - } - - fun createFactory( - modifier: KtModifierKeywordToken, - modifierOwnerClass: Class - ): KotlinSingleIntentionActionFactory { - return object : KotlinSingleIntentionActionFactory() { - public override fun createAction(diagnostic: Diagnostic): IntentionAction? { - val modifierListOwner = QuickFixUtil.getParentElementOfType(diagnostic, modifierOwnerClass) ?: return null - return createIfApplicable(modifierListOwner, modifier) - } - } - } - - fun createIfApplicable(modifierListOwner: KtModifierListOwner, modifier: KtModifierKeywordToken): AddModifierFixMpp? { - when (modifier) { - ABSTRACT_KEYWORD, OPEN_KEYWORD -> { - if (modifierListOwner is KtObjectDeclaration) return null - if (modifierListOwner is KtEnumEntry) return null - if (modifierListOwner is KtDeclaration && modifierListOwner !is KtClass) { - val parentClassOrObject = modifierListOwner.containingClassOrObject ?: return null - if (parentClassOrObject is KtObjectDeclaration) return null - if (parentClassOrObject is KtEnumEntry) return null - } - if (modifier == ABSTRACT_KEYWORD - && modifierListOwner is KtClass - && modifierListOwner.hasModifier(INLINE_KEYWORD) - ) return null - } - INNER_KEYWORD -> { - if (modifierListOwner is KtObjectDeclaration) return null - if (modifierListOwner is KtClass) { - if (modifierListOwner.isInterface() || - modifierListOwner.isSealed() || - modifierListOwner.isEnum() || - modifierListOwner.isData() || - modifierListOwner.isAnnotation() - ) return null - } - } - } - return AddModifierFixMpp(modifierListOwner, modifier) - } - + override fun createModifierFix(element: KtModifierListOwner, modifier: KtModifierKeywordToken): AddModifierFixMpp = + AddModifierFixMpp(element, modifier) } object MakeClassOpenFactory : KotlinSingleIntentionActionFactory() { From 91f1cb88c166733f8e34f1122ccae7c13a3853c7 Mon Sep 17 00:00:00 2001 From: Sergey Shanshin Date: Wed, 17 Feb 2021 20:24:31 +0300 Subject: [PATCH 239/368] Support serialization of java enum classes in IR Fixes Kotlin/kotlinx.serialization#1334 --- .../serialization/compiler/backend/ir/GeneratorHelpers.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt index f2dfc60ab42..adc0c01b8d4 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt @@ -663,8 +663,9 @@ interface IrBuilderExtension { fun findEnumValuesMethod(enumClass: ClassDescriptor): IrFunction { assert(enumClass.kind == ClassKind.ENUM_CLASS) return compilerContext.referenceClass(enumClass.fqNameSafe)?.let { - it.owner.functions.find { it.origin == IrDeclarationOrigin.ENUM_CLASS_SPECIAL_MEMBER && it.name == Name.identifier("values") } - ?: throw AssertionError("Enum class does not have .values() function") + it.owner.functions.singleOrNull { f -> + f.name == Name.identifier("values") && f.valueParameters.isEmpty() && f.extensionReceiverParameter == null + } ?: throw AssertionError("Enum class does not have single .values() function") } ?: error("Couldn't load class $enumClass") } From 61fce74b76b3b5660fb0f65427cda48eaede1090 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Wed, 17 Feb 2021 10:31:44 +0100 Subject: [PATCH 240/368] Support new targets in KotlinBytecodeToolWindow #KT-30222 Fixed --- .../idea/internal/KotlinBytecodeToolWindow.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.kt index dcfd2cdc5a6..ef89ad2391a 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.kt @@ -15,6 +15,7 @@ import com.intellij.openapi.editor.ScrollType import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.ComboBox import com.intellij.openapi.ui.Messages import com.intellij.openapi.util.Computable import com.intellij.openapi.util.Pair @@ -51,9 +52,7 @@ import java.awt.FlowLayout import java.io.PrintWriter import java.io.StringWriter import java.util.* -import javax.swing.JButton -import javax.swing.JCheckBox -import javax.swing.JPanel +import javax.swing.* import kotlin.math.min sealed class BytecodeGenerationResult { @@ -68,7 +67,7 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW private val enableOptimization: JCheckBox private val enableAssertions: JCheckBox private val decompile: JButton - private val jvm8Target: JCheckBox + private val jvmTargets: JComboBox private val ir: JCheckBox private inner class UpdateBytecodeToolWindowTask : LongRunningReadTask(this) { @@ -114,9 +113,7 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW configuration.put(JVMConfigurationKeys.DISABLE_OPTIMIZATION, true) } - if (jvm8Target.isSelected) { - configuration.put(JVMConfigurationKeys.JVM_TARGET, JvmTarget.JVM_1_8) - } + configuration.put(JVMConfigurationKeys.JVM_TARGET, JvmTarget.fromString(jvmTargets.selectedItem as String)!!) if (ir.isSelected) { configuration.put(JVMConfigurationKeys.IR, true) @@ -207,13 +204,16 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW enableInline = JCheckBox(KotlinJvmBundle.message("checkbox.text.inline"), true) enableOptimization = JCheckBox(KotlinJvmBundle.message("checkbox.text.optimization"), true) enableAssertions = JCheckBox(KotlinJvmBundle.message("checkbox.text.assertions"), true) - jvm8Target = JCheckBox(KotlinJvmBundle.message("checkbox.text.jvm.8.target"), false) + jvmTargets = ComboBox(JvmTarget.values().map { it.description }.toTypedArray()) + jvmTargets.selectedItem = JvmTarget.DEFAULT.description ir = JCheckBox(KotlinJvmBundle.message("checkbox.text.ir"), false) optionPanel.add(enableInline) optionPanel.add(enableOptimization) optionPanel.add(enableAssertions) optionPanel.add(ir) - optionPanel.add(jvm8Target) + + optionPanel.add(JLabel("Target:")) + optionPanel.add(jvmTargets) InfinitePeriodicalTask( UPDATE_DELAY.toLong(), From 3d8e8dd3ba9a07cd42c92a960df563ed6eca58a6 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Wed, 17 Feb 2021 13:41:33 +0100 Subject: [PATCH 241/368] Fail on compilation errors in AbstractBytecodeTextTest --- .../propertyAccessorsAreCalledByInlineClass.kt | 1 + .../bytecodeText/mangling/parenthesesNoSanitize.kt | 1 + .../parameterlessMain/dontGenerateOnJvmOverloads.kt | 1 + .../testData/codegen/bytecodeText/statements/labeled.kt | 2 ++ .../codegen/bytecodeText/whenEnumOptimization/whenOr.kt | 2 +- .../test/runners/codegen/AbstractBytecodeTextTest.kt | 4 ++++ .../AbstractCompileKotlinAgainstInlineKotlinTest.kt | 2 +- ...ompileKotlinAgainstKotlinWithDifferentBackendsTest.kt | 3 +-- .../codegen/AbstractJvmBlackBoxCodegenTestBase.kt | 2 +- .../runners/codegen/AbstractJvmIrAgainstOldBoxTest.kt | 2 +- .../test/runners/codegen/BaseCodegenConfiguration.kt | 9 +++++++-- 11 files changed, 21 insertions(+), 8 deletions(-) diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/propertyAccessorsAreCalledByInlineClass.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/propertyAccessorsAreCalledByInlineClass.kt index 6e182314fbf..61063f05a0a 100644 --- a/compiler/testData/codegen/bytecodeText/inlineClasses/propertyAccessorsAreCalledByInlineClass.kt +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/propertyAccessorsAreCalledByInlineClass.kt @@ -1,6 +1,7 @@ // !LANGUAGE: +InlineClasses // FILE: Z.kt +@Suppress("RESERVED_VAR_PROPERTY_OF_VALUE_CLASS") inline class Z(val x: Int) { val aVal: Int get() = x diff --git a/compiler/testData/codegen/bytecodeText/mangling/parenthesesNoSanitize.kt b/compiler/testData/codegen/bytecodeText/mangling/parenthesesNoSanitize.kt index 7e164d29c2f..757c699fa16 100644 --- a/compiler/testData/codegen/bytecodeText/mangling/parenthesesNoSanitize.kt +++ b/compiler/testData/codegen/bytecodeText/mangling/parenthesesNoSanitize.kt @@ -1,3 +1,4 @@ +// IGNORE_DEXING class `(X)` { fun `(Y)`() {} } diff --git a/compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnJvmOverloads.kt b/compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnJvmOverloads.kt index 54e43534fe1..68868536344 100644 --- a/compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnJvmOverloads.kt +++ b/compiler/testData/codegen/bytecodeText/parameterlessMain/dontGenerateOnJvmOverloads.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND: JVM fun main() { println("FAIL") } diff --git a/compiler/testData/codegen/bytecodeText/statements/labeled.kt b/compiler/testData/codegen/bytecodeText/statements/labeled.kt index e916024572a..e6d2ba1e488 100644 --- a/compiler/testData/codegen/bytecodeText/statements/labeled.kt +++ b/compiler/testData/codegen/bytecodeText/statements/labeled.kt @@ -1,3 +1,5 @@ +// IGNORE_BACKEND_FIR: JVM_IR + fun main() { l@ if (2 != 1) "fail 3" diff --git a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/whenOr.kt b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/whenOr.kt index 7814ae5c799..c701b5c8f38 100644 --- a/compiler/testData/codegen/bytecodeText/whenEnumOptimization/whenOr.kt +++ b/compiler/testData/codegen/bytecodeText/whenEnumOptimization/whenOr.kt @@ -1,7 +1,7 @@ // IGNORE_BACKEND: JVM fun test(x: Int): String { - when { + return when { x == 1 || x == 3 || x == 5 -> "135" x == 2 || x == 4 || x == 6 -> "246" else -> "other" diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractBytecodeTextTest.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractBytecodeTextTest.kt index 291492e8a82..898ee7bcaf8 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractBytecodeTextTest.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/codegen/AbstractBytecodeTextTest.kt @@ -10,6 +10,8 @@ import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor import org.jetbrains.kotlin.test.backend.classic.ClassicJvmBackendFacade import org.jetbrains.kotlin.test.backend.handlers.BytecodeTextHandler +import org.jetbrains.kotlin.test.backend.handlers.NoCompilationErrorsHandler +import org.jetbrains.kotlin.test.backend.handlers.NoFirCompilationErrorsHandler import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives @@ -42,6 +44,8 @@ abstract class AbstractBytecodeTextTestBase> TestConfigurationBuilder.commonCon useBackendFacades(backendFacade) } +fun TestConfigurationBuilder.commonHandlersForBoxTest() { + commonHandlersForCodegenTest() + useArtifactsHandlers( + ::JvmBoxRunner + ) +} + fun TestConfigurationBuilder.commonHandlersForCodegenTest() { useFrontendHandlers( ::NoCompilationErrorsHandler, @@ -58,7 +64,6 @@ fun TestConfigurationBuilder.commonHandlersForCodegenTest() { ) useArtifactsHandlers( - ::JvmBoxRunner, ::NoJvmSpecificCompilationErrorsHandler, ::DxCheckerHandler, ) From e3e7e6b740de8e512cdafdf5a4390eb55a896d44 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Wed, 17 Feb 2021 09:21:10 +0100 Subject: [PATCH 242/368] Make `indy-with-constants` default for -jvm-target 9+ #KT-42522 Fixed --- .../src/org/jetbrains/kotlin/codegen/state/GenerationState.kt | 2 +- .../kotlin/cli/common/arguments/K2JVMCompilerArguments.kt | 4 +++- compiler/testData/cli/jvm/extraHelp.out | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt index 5a18ad4958e..ed57f52192a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt @@ -204,7 +204,7 @@ class GenerationState private constructor( val target = configuration.get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT val runtimeStringConcat = if (target.majorVersion >= JvmTarget.JVM_9.majorVersion) - configuration.get(JVMConfigurationKeys.STRING_CONCAT) ?: JvmStringConcat.INLINE + configuration.get(JVMConfigurationKeys.STRING_CONCAT) ?: JvmStringConcat.INDY_WITH_CONSTANTS else JvmStringConcat.INLINE val samConversionsScheme = run { diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index f04ab6e41f2..b7c2ae9731e 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -369,7 +369,9 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { description = """Select code generation scheme for string concatenation. -Xstring-concat=indy-with-constants Concatenate strings using `invokedynamic` `makeConcatWithConstants`. Requires `-jvm-target 9` or greater. -Xstring-concat=indy Concatenate strings using `invokedynamic` `makeConcat`. Requires `-jvm-target 9` or greater. --Xstring-concat=inline Concatenate strings using `StringBuilder`""" +-Xstring-concat=inline Concatenate strings using `StringBuilder` +default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise""" + ) var stringConcat: String? by NullableStringFreezableVar(JvmStringConcat.INLINE.description) diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index f70bdbf39b3..e17c509546c 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -118,6 +118,7 @@ where advanced options include: -Xstring-concat=indy-with-constants Concatenate strings using `invokedynamic` `makeConcatWithConstants`. Requires `-jvm-target 9` or greater. -Xstring-concat=indy Concatenate strings using `invokedynamic` `makeConcat`. Requires `-jvm-target 9` or greater. -Xstring-concat=inline Concatenate strings using `StringBuilder` + default: `indy-with-constants` for JVM target 9 or greater, `inline` otherwise -Xsupport-compatqual-checker-framework-annotations=enable|disable Specify behavior for Checker Framework compatqual annotations (NullableDecl/NonNullDecl). Default value is 'enable' From 134fda8bad8d8e1cd6da49e3d298a9f6e11a6104 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Wed, 17 Feb 2021 11:07:28 +0100 Subject: [PATCH 243/368] Support Unit/V types in string-concat indy calls unitComponent.kt test fails with JVM target 9+ --- .../codegen/FirBytecodeTextTestGenerated.java | 6 ++++ .../backend/jvm/codegen/ExpressionCodegen.kt | 5 ++-- .../stringOperations/concatDynamicUnit.kt | 28 +++++++++++++++++++ .../codegen/BytecodeTextTestGenerated.java | 6 ++++ .../codegen/IrBytecodeTextTestGenerated.java | 6 ++++ 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/codegen/bytecodeText/stringOperations/concatDynamicUnit.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java index 2c1a4d39e5c..85754daa4a0 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java @@ -5080,6 +5080,12 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamicIndyDataClass.kt"); } + @Test + @TestMetadata("concatDynamicUnit.kt") + public void testConcatDynamicUnit() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamicUnit.kt"); + } + @Test @TestMetadata("concatNotDynamic.kt") public void testConcatNotDynamic() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 1ae7b43c724..11790f03c22 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -1283,8 +1283,9 @@ class ExpressionCodegen( generator.putValueOrProcessConstant(StackValue.constant(arg.value, type, null)) } else { val value = arg.accept(this, data) - value.materializeAt(value.type, value.irType) - generator.invokeAppend(value.type) + val generatingType = if (value.type == Type.VOID_TYPE) AsmTypes.UNIT_TYPE else value.type + value.materializeAt(generatingType, value.irType) + generator.invokeAppend(generatingType) } } generator.genToString() diff --git a/compiler/testData/codegen/bytecodeText/stringOperations/concatDynamicUnit.kt b/compiler/testData/codegen/bytecodeText/stringOperations/concatDynamicUnit.kt new file mode 100644 index 00000000000..1d2a5d39a42 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/stringOperations/concatDynamicUnit.kt @@ -0,0 +1,28 @@ +// JVM_TARGET: 9 +data class A(val x: Unit) + +fun test(): Unit {} + +interface B { + fun test() : T { + return null!! + } +} + +class Foo : B { + +} + +fun box(): String { + val a = A(Unit) + + val test = "Test ${a.component1()} ${test()} ${Foo().test()}" + return "OK" +} +// one in data class `toString` and one in `box` method +// 2 INVOKEDYNAMIC makeConcatWithConstants +// 1 makeConcatWithConstants\(Lkotlin/Unit;\) +// 1 makeConcatWithConstants\(Lkotlin/Unit;Lkotlin/Unit;Lkotlin/Unit;\) +// 0 append +// 0 stringPlus + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java index ae3c56d5cfd..8129e3d2031 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java @@ -4948,6 +4948,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamicIndyDataClass.kt"); } + @Test + @TestMetadata("concatDynamicUnit.kt") + public void testConcatDynamicUnit() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamicUnit.kt"); + } + @Test @TestMetadata("concatNotDynamic.kt") public void testConcatNotDynamic() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java index 05696042ddd..e2bc8b6d9f3 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java @@ -5080,6 +5080,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamicIndyDataClass.kt"); } + @Test + @TestMetadata("concatDynamicUnit.kt") + public void testConcatDynamicUnit() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/stringOperations/concatDynamicUnit.kt"); + } + @Test @TestMetadata("concatNotDynamic.kt") public void testConcatNotDynamic() throws Exception { From 6d019d9544b996d73751c6edca921016ed55d137 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 17 Feb 2021 13:44:33 +0300 Subject: [PATCH 244/368] JVM_IR indy-SAM on functional expression --- .../FirBlackBoxCodegenTestGenerated.java | 52 ++++ .../jvm/lower/FunctionReferenceLowering.kt | 38 ++- .../{ => indy}/LambdaMetafactoryArguments.kt | 7 +- .../lower/indy/SamDelegatingLambdaBlock.kt | 234 ++++++++++++++++++ .../annotatedLambda/samFunReference.kt | 1 + .../capturedSamArgument.kt | 15 ++ .../capturingLambda.kt | 14 ++ .../extensionLambda1.kt | 15 ++ .../extensionLambda2.kt | 15 ++ .../functionExpressionArgument/genericSam1.kt | 11 + .../functionExpressionArgument/genericSam2.kt | 13 + .../sam/functionExpressionArgument/simple.kt | 12 + .../box/sam/constructors/sameWrapperClass.kt | 1 + .../codegen/box/sam/inlinedSamWrapper.kt | 1 + compiler/testData/codegen/box/sam/kt17091.kt | 1 + .../testData/codegen/box/sam/kt17091_2.kt | 1 + .../testData/codegen/box/sam/kt17091_3.kt | 1 + .../testData/codegen/box/sam/kt17091_4.kt | 1 + compiler/testData/codegen/box/sam/kt22906.kt | 1 + .../testData/codegen/box/sam/kt22906_2.kt | 1 + .../codegen/box/sam/predicateSamWrapper.kt | 1 + .../samWrapperForNullableInitialization.kt | 2 +- .../codegen/BlackBoxCodegenTestGenerated.java | 52 ++++ .../IrBlackBoxCodegenTestGenerated.java | 52 ++++ .../LightAnalysisModeTestGenerated.java | 48 ++++ .../IrJsCodegenBoxES6TestGenerated.java | 13 + .../IrJsCodegenBoxTestGenerated.java | 13 + .../semantics/JsCodegenBoxTestGenerated.java | 13 + .../IrCodegenBoxWasmTestGenerated.java | 13 + 29 files changed, 634 insertions(+), 8 deletions(-) rename compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/{ => indy}/LambdaMetafactoryArguments.kt (99%) create mode 100644 compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/SamDelegatingLambdaBlock.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index d11440a7e7e..959af81e15f 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -20035,6 +20035,58 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/unboundFunctionReferenceEquality.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestDataPath("$PROJECT_ROOT") + public class FunctionExpressionArgument { + @Test + public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("capturedSamArgument.kt") + public void testCapturedSamArgument() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt"); + } + + @Test + @TestMetadata("capturingLambda.kt") + public void testCapturingLambda() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt"); + } + + @Test + @TestMetadata("extensionLambda1.kt") + public void testExtensionLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt"); + } + + @Test + @TestMetadata("extensionLambda2.kt") + public void testExtensionLambda2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt"); + } + + @Test + @TestMetadata("genericSam1.kt") + public void testGenericSam1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt"); + } + + @Test + @TestMetadata("genericSam2.kt") + public void testGenericSam2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt"); + } + + @Test + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt index 98a807e89a6..1cebd00bcd4 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt @@ -13,6 +13,10 @@ import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.ir.* +import org.jetbrains.kotlin.backend.jvm.lower.indy.LambdaMetafactoryArguments +import org.jetbrains.kotlin.backend.jvm.lower.indy.LambdaMetafactoryArgumentsBuilder +import org.jetbrains.kotlin.backend.jvm.lower.indy.SamDelegatingLambdaBlock +import org.jetbrains.kotlin.backend.jvm.lower.indy.SamDelegatingLambdaBuilder import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.InlineClassAbi import org.jetbrains.kotlin.config.JvmClosureGenerationScheme import org.jetbrains.kotlin.descriptors.DescriptorVisibilities @@ -142,6 +146,14 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) } else if (invokable is IrBlock && invokable.origin.isLambda && invokable.statements.last() is IrFunctionReference) { invokable.statements.dropLast(1).forEach { it.transform(this, null) } invokable.statements.last() as IrFunctionReference + } else if (shouldGenerateIndySamConversions && canGenerateIndySamConversionOnFunctionalExpression(samSuperType, invokable)) { + val lambdaBlock = SamDelegatingLambdaBuilder(context) + .build(invokable, samSuperType, currentScope!!.scope.scopeOwnerSymbol) + val lambdaMetafactoryArguments = LambdaMetafactoryArgumentsBuilder(context, crossinlineLambdas) + .getLambdaMetafactoryArgumentsOrNull(lambdaBlock.ref, samSuperType, false) + ?: return super.visitTypeOperator(expression) + invokable.transformChildrenVoid() + return wrapSamDelegatingLambdaWithIndySamConversion(samSuperType, lambdaBlock, lambdaMetafactoryArguments) } else { return super.visitTypeOperator(expression) } @@ -159,18 +171,36 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) return FunctionReferenceBuilder(reference, samSuperType).build() } + private fun canGenerateIndySamConversionOnFunctionalExpression(samSuperType: IrType, expression: IrExpression): Boolean { + val samClass = samSuperType.classOrNull + ?: throw AssertionError("Class type expected: ${samSuperType.render()}") + if (!samClass.owner.isFromJava()) + return false + if (expression is IrBlock && expression.origin == IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE) + return false + return true + } + + private fun wrapSamDelegatingLambdaWithIndySamConversion( + samSuperType: IrType, + lambdaBlock: SamDelegatingLambdaBlock, + lambdaMetafactoryArguments: LambdaMetafactoryArguments + ): IrExpression { + val indySamConversion = wrapWithIndySamConversion(samSuperType, lambdaMetafactoryArguments) + lambdaBlock.replaceRefWith(indySamConversion) + return lambdaBlock.block + } + private fun wrapSamConversionArgumentWithIndySamConversion( expression: IrTypeOperatorCall, lambdaMetafactoryArguments: LambdaMetafactoryArguments ): IrExpression { val samType = expression.typeOperand return when (val argument = expression.argument) { - is IrFunctionReference -> { + is IrFunctionReference -> wrapWithIndySamConversion(samType, lambdaMetafactoryArguments) - } - is IrBlock -> { + is IrBlock -> wrapFunctionReferenceInsideBlockWithIndySamConversion(samType, lambdaMetafactoryArguments, argument) - } else -> throw AssertionError("Block or function reference expected: ${expression.render()}") } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/LambdaMetafactoryArguments.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt similarity index 99% rename from compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/LambdaMetafactoryArguments.kt rename to compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt index 8411de1f7ae..bcf1aa2ffa5 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/LambdaMetafactoryArguments.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt @@ -3,7 +3,7 @@ * 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.backend.jvm.lower +package org.jetbrains.kotlin.backend.jvm.lower.indy import org.jetbrains.kotlin.backend.common.ir.allOverridden import org.jetbrains.kotlin.backend.common.lower.VariableRemapper @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound import org.jetbrains.kotlin.backend.jvm.ir.getSingleAbstractMethod import org.jetbrains.kotlin.backend.jvm.ir.isCompiledToJvmDefault +import org.jetbrains.kotlin.backend.jvm.lower.findInterfaceImplementation import org.jetbrains.kotlin.builtins.functions.BuiltInFunctionArity import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.ir.builders.declarations.buildClass @@ -30,14 +31,14 @@ import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid import org.jetbrains.kotlin.name.Name -class LambdaMetafactoryArguments( +internal class LambdaMetafactoryArguments( val samMethod: IrSimpleFunction, val fakeInstanceMethod: IrSimpleFunction, val implMethodReference: IrFunctionReference, val extraOverriddenMethods: List ) -class LambdaMetafactoryArgumentsBuilder( +internal class LambdaMetafactoryArgumentsBuilder( private val context: JvmBackendContext, private val crossinlineLambdas: Set ) { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/SamDelegatingLambdaBlock.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/SamDelegatingLambdaBlock.kt new file mode 100644 index 00000000000..0211b355e0a --- /dev/null +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/SamDelegatingLambdaBlock.kt @@ -0,0 +1,234 @@ +/* + * Copyright 2010-2021 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.backend.jvm.lower.indy + +import org.jetbrains.kotlin.backend.jvm.JvmBackendContext +import org.jetbrains.kotlin.backend.jvm.ir.JvmIrBuilder +import org.jetbrains.kotlin.backend.jvm.ir.createJvmIrBuilder +import org.jetbrains.kotlin.backend.jvm.ir.getSingleAbstractMethod +import org.jetbrains.kotlin.descriptors.DescriptorVisibilities +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.ir.builders.* +import org.jetbrains.kotlin.ir.builders.declarations.buildFun +import org.jetbrains.kotlin.ir.builders.declarations.buildValueParameter +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.IrContainerExpression +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.IrFunctionReference +import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionReferenceImpl +import org.jetbrains.kotlin.ir.symbols.IrSymbol +import org.jetbrains.kotlin.ir.types.* +import org.jetbrains.kotlin.ir.util.functions +import org.jetbrains.kotlin.ir.util.render +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.util.OperatorNameConventions + +internal sealed class SamDelegatingLambdaBlock { + abstract val block: IrContainerExpression + abstract val ref: IrFunctionReference + abstract fun replaceRefWith(expression: IrExpression) +} + + +internal class RegularDelegatingLambdaBlock( + override val block: IrContainerExpression, + override val ref: IrFunctionReference +) : SamDelegatingLambdaBlock() { + + override fun replaceRefWith(expression: IrExpression) { + block.statements[block.statements.size - 1] = expression + block.type = expression.type + } +} + + +internal class NullableDelegatingLambdaBlock( + override val block: IrContainerExpression, + override val ref: IrFunctionReference, + private val ifExpr: IrExpression, + private val ifNotNullBlock: IrContainerExpression +) : SamDelegatingLambdaBlock() { + + override fun replaceRefWith(expression: IrExpression) { + ifNotNullBlock.statements[ifNotNullBlock.statements.size - 1] = expression + ifNotNullBlock.type = expression.type + ifExpr.type = expression.type + block.type = expression.type + } +} + + +internal class SamDelegatingLambdaBuilder(private val jvmContext: JvmBackendContext) { + fun build(expression: IrExpression, superType: IrType, scopeSymbol: IrSymbol): SamDelegatingLambdaBlock { + return if (superType.isNullable() && expression.type.isNullable()) + buildNullableDelegatingLambda(expression, superType, scopeSymbol) + else + buildRegularDelegatingLambda(expression, superType, scopeSymbol) + } + + private fun buildRegularDelegatingLambda( + expression: IrExpression, + superType: IrType, + scopeSymbol: IrSymbol + ): SamDelegatingLambdaBlock { + lateinit var ref: IrFunctionReference + val block = jvmContext.createJvmIrBuilder(scopeSymbol, expression.startOffset, expression.endOffset).run { + // { + // val tmp = + // fun ``(p1: T1, ..., pN: TN): R = + // tmp.invoke(p1, ..., pN) + // ::`` + // } + + irBlock(origin = IrStatementOrigin.LAMBDA) { + val tmp = irTemporary(expression) + val lambda = createDelegatingLambda(scopeSymbol, expression, superType, tmp) + .also { +it } + ref = createDelegatingLambdaReference(expression, lambda) + .also { +it } + } + } + block.type = expression.type + return RegularDelegatingLambdaBlock(block, ref) + } + + private fun buildNullableDelegatingLambda( + expression: IrExpression, + superType: IrType, + scopeSymbol: IrSymbol + ): SamDelegatingLambdaBlock { + lateinit var ref: IrFunctionReference + lateinit var ifExpr: IrExpression + lateinit var ifNotNullBlock: IrContainerExpression + val block = jvmContext.createJvmIrBuilder(scopeSymbol, expression.startOffset, expression.endOffset).run { + // { + // val tmp = + // if (tmp == null) + // null + // else { + // fun ``(p1: T1, ..., pN: TN): R = + // tmp.invoke(p1, ..., pN) + // ::`` + // } + // } + + irBlock(origin = IrStatementOrigin.LAMBDA) { + val tmp = irTemporary(expression) + ifNotNullBlock = irBlock { + val lambda = createDelegatingLambda(scopeSymbol, expression, superType, tmp) + .also { +it } + ref = createDelegatingLambdaReference(expression, lambda) + .also { +it } + } + ifExpr = irIfNull(expression.type, irGet(tmp), irNull(), ifNotNullBlock) + .also { +it } + } + } + block.type = expression.type + return NullableDelegatingLambdaBlock(block, ref, ifExpr, ifNotNullBlock) + } + + private fun createDelegatingLambda( + scopeSymbol: IrSymbol, + expression: IrExpression, + superType: IrType, + tmp: IrVariable + ): IrSimpleFunction { + val superMethod = superType.getSingleAbstractMethod() + ?: throw AssertionError("SAM type expected: ${superType.render()}") + val effectiveValueParametersCount = superMethod.valueParameters.size + + if (superMethod.extensionReceiverParameter == null) 0 else 1 + val invocableFunctionClass = + if (superMethod.isSuspend) + jvmContext.ir.symbols.suspendFunctionN(effectiveValueParametersCount).owner + else + jvmContext.ir.symbols.functionN(effectiveValueParametersCount).owner + val invokeFunction = invocableFunctionClass.functions.single { it.name == OperatorNameConventions.INVOKE } + val typeSubstitutor = createTypeSubstitutor(superType) + + return jvmContext.irFactory.buildFun { + name = Name.special("") + returnType = typeSubstitutor.substitute(superMethod.returnType) + visibility = DescriptorVisibilities.LOCAL + modality = Modality.FINAL + origin = IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA + isSuspend = superMethod.isSuspend + }.also { lambda -> + lambda.dispatchReceiverParameter = null + lambda.extensionReceiverParameter = null + lambda.valueParameters = createLambdaValueParameters(superMethod, lambda, typeSubstitutor) + lambda.body = jvmContext.createJvmIrBuilder(lambda.symbol, expression.startOffset, expression.endOffset) + .irBlockBody { + +irReturn( + irCall(invokeFunction).also { invokeCall -> + invokeCall.dispatchReceiver = irGet(tmp) + var parameterIndex = 0 + invokeFunction.extensionReceiverParameter?.let { + invokeCall.extensionReceiver = irGet(lambda.valueParameters[parameterIndex++]) + } + for (argumentIndex in invokeFunction.valueParameters.indices) { + invokeCall.putValueArgument(argumentIndex, irGet(lambda.valueParameters[parameterIndex++])) + } + } + ) + } + lambda.parent = scopeSymbol.owner as IrDeclarationParent + } + } + + private fun createLambdaValueParameters( + superMethod: IrSimpleFunction, + lambda: IrSimpleFunction, + typeSubstitutor: IrTypeSubstitutor + ): List { + val lambdaParameters = ArrayList() + var index = 0 + superMethod.extensionReceiverParameter?.let { superExtensionReceiver -> + lambdaParameters.add(superExtensionReceiver.copySubstituted(lambda, typeSubstitutor, index++, Name.identifier("\$receiver"))) + } + superMethod.valueParameters.mapTo(lambdaParameters) { superValueParameter -> + superValueParameter.copySubstituted(lambda, typeSubstitutor, index++) + } + return lambdaParameters + } + + private fun IrValueParameter.copySubstituted( + function: IrSimpleFunction, + substitutor: IrTypeSubstitutor, + newIndex: Int, + newName: Name = name + ) = + buildValueParameter(function) { + name = newName + index = newIndex + type = substitutor.substitute(this@copySubstituted.type) + } + + private fun JvmIrBuilder.createDelegatingLambdaReference(expression: IrExpression, lambda: IrSimpleFunction): IrFunctionReference { + return IrFunctionReferenceImpl( + startOffset, endOffset, + expression.type, + lambda.symbol, + typeArgumentsCount = 0, + valueArgumentsCount = lambda.valueParameters.size, + reflectionTarget = null, + origin = IrStatementOrigin.LAMBDA + ) + } + + private fun createTypeSubstitutor(irType: IrType): IrTypeSubstitutor { + if (irType !is IrSimpleType) + throw AssertionError("Simple type expected: ${irType.render()}") + val irClassSymbol = irType.classOrNull + ?: throw AssertionError("Class type expected: ${irType.render()}") + return IrTypeSubstitutor( + irClassSymbol.owner.typeParameters.map { it.symbol }, + irType.arguments, + jvmContext.irBuiltIns + ) + } +} diff --git a/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt b/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt index 74ea0405d94..da6f739deda 100644 --- a/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt +++ b/compiler/testData/codegen/box/annotations/annotatedLambda/samFunReference.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// SAM_CONVERSIONS: CLASS // WITH_RUNTIME // FILE: Test.java diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt new file mode 100644 index 00000000000..5577bb6d634 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt @@ -0,0 +1,15 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: capturedSamArgument.kt +fun box(): String { + var lambda = { "OK" } + val sam = Sam(lambda) + lambda = { "Failed" } + return sam.get() +} + +// FILE: Sam.java +public interface Sam { + String get(); +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt new file mode 100644 index 00000000000..3498c335a9f --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: capturingLambda.kt +fun box(): String { + val co = 'O' + val lambda = { co.toString() + "K" } + return Sam(lambda).get() +} + +// FILE: Sam.java +public interface Sam { + String get(); +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt new file mode 100644 index 00000000000..96efac5328e --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt @@ -0,0 +1,15 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: extensionLambda1.kt +fun samExtLambda(ext: String.() -> String) = Sam(ext) + +fun box(): String { + val oChar = 'O' + return samExtLambda { oChar.toString() + this }.get("K") +} + +// FILE: Sam.java +public interface Sam { + String get(String s); +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt new file mode 100644 index 00000000000..0d844f42f48 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt @@ -0,0 +1,15 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: extensionLambda2.kt +fun samExtLambda(ext: String.(String) -> String) = Sam(ext) + +fun box(): String { + val oChar = 'O' + return samExtLambda { oChar.toString() + this + it }.get("", "K") +} + +// FILE: Sam.java +public interface Sam { + String get(String s1, String s2); +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt new file mode 100644 index 00000000000..79a9fee256e --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt @@ -0,0 +1,11 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: genericSam1.kt + +fun box(): String = Sam { "O" + it }.get("K") + +// FILE: Sam.java +public interface Sam { + R get(T x); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt new file mode 100644 index 00000000000..7817b5d6021 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt @@ -0,0 +1,13 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: genericSam2.kt + +fun test(lambda: (FT) -> FR) = Sam(lambda) + +fun box(): String = test { "O" + it }.get("K") + +// FILE: Sam.java +public interface Sam { + R get(T x); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt new file mode 100644 index 00000000000..7c44f655db8 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt @@ -0,0 +1,12 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: simple.kt +val lambda = { "OK" } + +fun box() = Sam(lambda).get() + +// FILE: Sam.java +public interface Sam { + String get(); +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/sam/constructors/sameWrapperClass.kt b/compiler/testData/codegen/box/sam/constructors/sameWrapperClass.kt index 9e678745924..486484f9353 100644 --- a/compiler/testData/codegen/box/sam/constructors/sameWrapperClass.kt +++ b/compiler/testData/codegen/box/sam/constructors/sameWrapperClass.kt @@ -4,6 +4,7 @@ // IGNORE_BACKEND: JS_IR_ES6 // TODO: muted automatically, investigate should it be ran for JS or not // IGNORE_BACKEND: JS, NATIVE +// SAM_CONVERSIONS: CLASS fun box(): String { val f = { } diff --git a/compiler/testData/codegen/box/sam/inlinedSamWrapper.kt b/compiler/testData/codegen/box/sam/inlinedSamWrapper.kt index 6b88883410a..47d04dde445 100644 --- a/compiler/testData/codegen/box/sam/inlinedSamWrapper.kt +++ b/compiler/testData/codegen/box/sam/inlinedSamWrapper.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME +// SAM_CONVERSIONS: CLASS // FILE: MyRunnable.java public interface MyRunnable { public void run(); diff --git a/compiler/testData/codegen/box/sam/kt17091.kt b/compiler/testData/codegen/box/sam/kt17091.kt index b6da586db2a..834ddb369ba 100644 --- a/compiler/testData/codegen/box/sam/kt17091.kt +++ b/compiler/testData/codegen/box/sam/kt17091.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME +// SAM_CONVERSIONS: CLASS // FILE: Foo.kt package foo diff --git a/compiler/testData/codegen/box/sam/kt17091_2.kt b/compiler/testData/codegen/box/sam/kt17091_2.kt index a4fffc0cec0..beb111bf5bf 100644 --- a/compiler/testData/codegen/box/sam/kt17091_2.kt +++ b/compiler/testData/codegen/box/sam/kt17091_2.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME +// SAM_CONVERSIONS: CLASS // FILE: Foo.kt @file:JvmName("testXX") package test diff --git a/compiler/testData/codegen/box/sam/kt17091_3.kt b/compiler/testData/codegen/box/sam/kt17091_3.kt index 2282bfc5444..08c2146c7e6 100644 --- a/compiler/testData/codegen/box/sam/kt17091_3.kt +++ b/compiler/testData/codegen/box/sam/kt17091_3.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME +// SAM_CONVERSIONS: CLASS // FILE: Foo.kt @file:JvmMultifileClass @file:JvmName("testX") diff --git a/compiler/testData/codegen/box/sam/kt17091_4.kt b/compiler/testData/codegen/box/sam/kt17091_4.kt index e41aad8b0de..4ffd660b508 100644 --- a/compiler/testData/codegen/box/sam/kt17091_4.kt +++ b/compiler/testData/codegen/box/sam/kt17091_4.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME +// SAM_CONVERSIONS: CLASS // FILE: Foo.kt @file:JvmMultifileClass @file:JvmName("testX") diff --git a/compiler/testData/codegen/box/sam/kt22906.kt b/compiler/testData/codegen/box/sam/kt22906.kt index 16f799c8a9e..b63b761c3ef 100644 --- a/compiler/testData/codegen/box/sam/kt22906.kt +++ b/compiler/testData/codegen/box/sam/kt22906.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME +// SAM_CONVERSIONS: CLASS // FILE: kt22906_1.kt package test diff --git a/compiler/testData/codegen/box/sam/kt22906_2.kt b/compiler/testData/codegen/box/sam/kt22906_2.kt index 1699464b814..5e212ea834d 100644 --- a/compiler/testData/codegen/box/sam/kt22906_2.kt +++ b/compiler/testData/codegen/box/sam/kt22906_2.kt @@ -1,5 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME +// SAM_CONVERSIONS: CLASS // FILE: kt22906_1.kt package test diff --git a/compiler/testData/codegen/box/sam/predicateSamWrapper.kt b/compiler/testData/codegen/box/sam/predicateSamWrapper.kt index ef7dc3f32ff..1fe7b94a9e4 100644 --- a/compiler/testData/codegen/box/sam/predicateSamWrapper.kt +++ b/compiler/testData/codegen/box/sam/predicateSamWrapper.kt @@ -2,6 +2,7 @@ // WITH_RUNTIME // FULL_JDK // SKIP_JDK6 +// SAM_CONVERSIONS: CLASS // FILE: test.kt // Test that SAM wrappers with type parameters are cached properly. class A { diff --git a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt index 54a2d031fd8..73980bdade3 100644 --- a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt +++ b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt @@ -26,7 +26,7 @@ fun test() { // JVM_IR_TEMPLATES // @TestKt.class -// 1 NEW +// 0 NEW // 1 IFNONNULL // 0 IFNULL // 2 ACONST_NULL diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 960be73cd2a..1261d8e2386 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -20035,6 +20035,58 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/unboundFunctionReferenceEquality.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestDataPath("$PROJECT_ROOT") + public class FunctionExpressionArgument { + @Test + public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("capturedSamArgument.kt") + public void testCapturedSamArgument() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt"); + } + + @Test + @TestMetadata("capturingLambda.kt") + public void testCapturingLambda() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt"); + } + + @Test + @TestMetadata("extensionLambda1.kt") + public void testExtensionLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt"); + } + + @Test + @TestMetadata("extensionLambda2.kt") + public void testExtensionLambda2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt"); + } + + @Test + @TestMetadata("genericSam1.kt") + public void testGenericSam1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt"); + } + + @Test + @TestMetadata("genericSam2.kt") + public void testGenericSam2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt"); + } + + @Test + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 096f5e8e728..6968dda1cf0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -20035,6 +20035,58 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/unboundFunctionReferenceEquality.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestDataPath("$PROJECT_ROOT") + public class FunctionExpressionArgument { + @Test + public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("capturedSamArgument.kt") + public void testCapturedSamArgument() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt"); + } + + @Test + @TestMetadata("capturingLambda.kt") + public void testCapturingLambda() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt"); + } + + @Test + @TestMetadata("extensionLambda1.kt") + public void testExtensionLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt"); + } + + @Test + @TestMetadata("extensionLambda2.kt") + public void testExtensionLambda2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt"); + } + + @Test + @TestMetadata("genericSam1.kt") + public void testGenericSam1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt"); + } + + @Test + @TestMetadata("genericSam2.kt") + public void testGenericSam2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt"); + } + + @Test + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 035e1085ce9..79bd3056596 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -16793,6 +16793,54 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/unboundFunctionReferenceEquality.kt"); } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionExpressionArgument extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("capturedSamArgument.kt") + public void testCapturedSamArgument() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt"); + } + + @TestMetadata("capturingLambda.kt") + public void testCapturingLambda() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt"); + } + + @TestMetadata("extensionLambda1.kt") + public void testExtensionLambda1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt"); + } + + @TestMetadata("extensionLambda2.kt") + public void testExtensionLambda2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt"); + } + + @TestMetadata("genericSam1.kt") + public void testGenericSam1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt"); + } + + @TestMetadata("genericSam2.kt") + public void testGenericSam2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index ce88f8a2ccd..683bca7103b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -14578,6 +14578,19 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionExpressionArgument extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 421555239ab..860b8daad47 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -14063,6 +14063,19 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionExpressionArgument extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 4c83fd5c74c..ffa34fb50c2 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -14128,6 +14128,19 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionExpressionArgument extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index ed5098f8259..bb1aae8e6a8 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -8164,6 +8164,19 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionExpressionArgument extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 4500b6ce74ce613846ff2d581acaa60e8a3c1c80 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 17 Feb 2021 09:33:03 +0100 Subject: [PATCH 245/368] [Commonizer] Implement :native:kotlin-klib-commonizer:api with support for library commonization - Implement new Gradle module ':native:kotlin-klib-commonizer' - Implement new NativeKlibCommonize task - Implement CommonizerTarget.identityString --- build.gradle.kts | 1 + buildSrc/src/main/kotlin/tasks.kt | 3 +- .../kotlin-gradle-plugin/build.gradle.kts | 1 + .../compilerRunner/GradleCliCommonizer.kt | 21 ++ ...kt => KotlinNativeCommonizerToolRunner.kt} | 2 +- .../targets/native/internal/CommonizerTask.kt | 5 +- native/commonizer-api/build.gradle.kts | 44 ++++ .../descriptors/commonizer/CliCommonizer.kt | 61 ++++++ .../descriptors/commonizer/Commonizer.kt | 21 ++ .../commonizer/CommonizerTarget.kt | 100 +++++++++ .../commonizer/TargetLibrariesLayout.kt | 30 +++ .../commonizer/parseCommonizerTarget.kt | 196 ++++++++++++++++++ .../commonizer/CliCommonizerTest.kt | 30 +++ .../commonizer/CommonizeLibcurlTest.kt | 80 +++++++ .../CommonizerTargetIdentityStringTest.kt | 137 ++++++++++++ .../CommonizerTargetPrettyNameTest.kt | 88 ++++++++ .../descriptors/commonizer/utils/konanHome.kt | 14 ++ .../testData/libcurl/linux_arm64/libcurl.klib | Bin 0 -> 40130 bytes .../testData/libcurl/linux_x64/libcurl.klib | Bin 0 -> 40048 bytes native/commonizer/build.gradle.kts | 3 + .../commonizer/CommonizerParameters.kt | 15 +- .../commonizer/CommonizerTarget.kt | 36 ---- .../commonizer/KonanDistribution.kt | 20 ++ .../commonizer/NativeLibraryLoader.kt | 44 ++++ .../descriptors/commonizer/ResultsConsumer.kt | 60 +++++- .../descriptors/commonizer/TargetProvider.kt | 2 +- .../cli/DependencyLibrariesOptionType.kt | 12 ++ .../cli/InputLibrariesOptionType.kt | 12 ++ .../commonizer/cli/LibrariesSetOptionType.kt | 25 +++ .../cli/OutputCommonizerTargetOptionType.kt | 23 ++ .../commonizer/cli/ProgressLogger.kt | 22 ++ .../commonizer/cli/StatsTypeOptionType.kt | 2 +- .../descriptors/commonizer/cli/TaskType.kt | 16 +- .../descriptors/commonizer/cli/nativeTasks.kt | 101 +++++++-- .../commonizer/core/RootCommonizer.kt | 12 +- .../kotlin/descriptors/commonizer/facade.kt | 6 +- ...iesFromKonanDistributionResultsConsumer.kt | 62 ++++++ .../CopyUnconsumedModulesAsIsConsumer.kt | 48 +++++ .../konan/LoggingResultsConsumer.kt | 20 ++ .../commonizer/konan/ModuleSerializer.kt | 56 +++++ .../konan/NativeDistributionCommonizer.kt | 141 ++++--------- .../NativeDistributionModulesProvider.kt | 2 - .../NativeDistributionResultsConsumer.kt | 172 --------------- .../commonizer/konan/NativeLibrary.kt | 23 +- .../konan/NativeSensitiveManifestData.kt | 2 +- .../commonizer/mergedtree/CirTreeMerger.kt | 6 +- .../mergedtree/classifierContainers.kt | 4 +- .../commonizer/repository/FilesRepository.kt | 34 +++ .../repository/KonanDistributionRepository.kt | 37 ++++ .../commonizer/repository/Repository.kt | 32 +++ .../commonizer/stats/StatsCollector.kt | 14 ++ .../AbstractCommonizationFromSourcesTest.kt | 59 +++--- .../commonizer/CommonizerFacadeTest.kt | 26 +-- .../commonizer/CommonizerTargetTest.kt | 70 ------- .../commonizer/core/RootCommonizerTest.kt | 116 ++++------- .../commonizer/core/TypeCommonizerTest.kt | 6 +- .../commonizer/utils/assertions.kt | 3 +- .../descriptors/commonizer/utils/mocks.kt | 29 ++- settings.gradle | 4 +- 59 files changed, 1646 insertions(+), 565 deletions(-) create mode 100644 libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleCliCommonizer.kt rename libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/{KotlinNativeKlibCommonizerToolRunner.kt => KotlinNativeCommonizerToolRunner.kt} (93%) create mode 100644 native/commonizer-api/build.gradle.kts create mode 100644 native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/CliCommonizer.kt create mode 100644 native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/Commonizer.kt create mode 100644 native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTarget.kt create mode 100644 native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/TargetLibrariesLayout.kt create mode 100644 native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/parseCommonizerTarget.kt create mode 100644 native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CliCommonizerTest.kt create mode 100644 native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizeLibcurlTest.kt create mode 100644 native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetIdentityStringTest.kt create mode 100644 native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetPrettyNameTest.kt create mode 100644 native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/utils/konanHome.kt create mode 100644 native/commonizer-api/testData/libcurl/linux_arm64/libcurl.klib create mode 100644 native/commonizer-api/testData/libcurl/linux_x64/libcurl.klib delete mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTarget.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/KonanDistribution.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/NativeLibraryLoader.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/DependencyLibrariesOptionType.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/InputLibrariesOptionType.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/LibrariesSetOptionType.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/OutputCommonizerTargetOptionType.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/ProgressLogger.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyLibrariesFromKonanDistributionResultsConsumer.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyUnconsumedModulesAsIsConsumer.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LoggingResultsConsumer.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/ModuleSerializer.kt delete mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionResultsConsumer.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/FilesRepository.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/KonanDistributionRepository.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/Repository.kt delete mode 100644 native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetTest.kt diff --git a/build.gradle.kts b/build.gradle.kts index 53c91650853..86d145a1f06 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -768,6 +768,7 @@ tasks { register("toolsTest") { dependsOn(":tools:kotlinp:test") dependsOn(":native:kotlin-klib-commonizer:test") + dependsOn(":native:kotlin-klib-commonizer-api:test") } register("examplesTest") { diff --git a/buildSrc/src/main/kotlin/tasks.kt b/buildSrc/src/main/kotlin/tasks.kt index 58b37c62099..51a47280ad4 100644 --- a/buildSrc/src/main/kotlin/tasks.kt +++ b/buildSrc/src/main/kotlin/tasks.kt @@ -53,7 +53,8 @@ fun Task.dependsOnKotlinPluginInstall() { ":kotlin-scripting-compiler-embeddable:install", ":kotlin-scripting-compiler-impl-embeddable:install", ":kotlin-test-js-runner:install", - ":native:kotlin-klib-commonizer-embeddable:install" + ":native:kotlin-klib-commonizer-embeddable:install", + ":native:kotlin-klib-commonizer-api:install" ) } diff --git a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts index d0f46edc9ee..74be09e504c 100644 --- a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts @@ -42,6 +42,7 @@ dependencies { implementation(kotlinStdlib()) implementation(project(":kotlin-util-klib")) + implementation(project(":native:kotlin-klib-commonizer-api")) compileOnly(project(":kotlin-reflect-api")) compileOnly(project(":kotlin-android-extensions")) compileOnly(project(":kotlin-build-common")) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleCliCommonizer.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleCliCommonizer.kt new file mode 100644 index 00000000000..0d6f6c9335d --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleCliCommonizer.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2010-2021 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("FunctionName") + +package org.jetbrains.kotlin.compilerRunner + +import org.gradle.api.Project +import org.jetbrains.kotlin.descriptors.commonizer.CliCommonizer + +/** + * Creates an instance of [CliCommonizer] that is backed by [KotlinNativeCommonizerToolRunner] to adhere to user defined settings + * when executing the commonizer (like jvm arguments, running in separate process, etc) + */ +internal fun GradleCliCommonizer(project: Project): CliCommonizer { + return CliCommonizer(CliCommonizer.Executor { arguments -> + KotlinNativeCommonizerToolRunner(project).run(arguments) + }) +} diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/KotlinNativeKlibCommonizerToolRunner.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/KotlinNativeCommonizerToolRunner.kt similarity index 93% rename from libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/KotlinNativeKlibCommonizerToolRunner.kt rename to libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/KotlinNativeCommonizerToolRunner.kt index c8a0bfa7309..dff26f69c67 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/KotlinNativeKlibCommonizerToolRunner.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/KotlinNativeCommonizerToolRunner.kt @@ -11,7 +11,7 @@ import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion import java.io.File -internal class KotlinNativeKlibCommonizerToolRunner(project: Project) : KotlinToolRunner(project) { +internal class KotlinNativeCommonizerToolRunner(project: Project) : KotlinToolRunner(project) { override val displayName get() = "Kotlin/Native KLIB commonizer" override val mainClass: String get() = "org.jetbrains.kotlin.descriptors.commonizer.cli.CommonizerCLI" diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CommonizerTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CommonizerTask.kt index 2da6a510bdb..984ec24de82 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CommonizerTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CommonizerTask.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.gradle.targets.native.internal import org.gradle.api.DefaultTask import org.gradle.api.Project import org.gradle.api.tasks.* -import org.jetbrains.kotlin.compilerRunner.KotlinNativeKlibCommonizerToolRunner +import org.jetbrains.kotlin.compilerRunner.KotlinNativeCommonizerToolRunner import org.jetbrains.kotlin.compilerRunner.konanHome import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion import org.jetbrains.kotlin.gradle.targets.native.internal.SuccessMarker.Companion.getSuccessMarker @@ -24,7 +24,6 @@ import java.nio.file.* import java.nio.file.attribute.* import java.time.* import java.util.* -import javax.inject.Inject internal const val COMMONIZER_TASK_NAME = "runCommonizer" @@ -190,7 +189,7 @@ internal fun Project.createTempNativeDistributionCommonizerOutputDirectory(targe fun callCommonizerCLI(project: Project, commandLineArguments: List) { if (commandLineArguments.isEmpty()) return - KotlinNativeKlibCommonizerToolRunner(project).run(commandLineArguments) + KotlinNativeCommonizerToolRunner(project).run(commandLineArguments) } private fun renameDirectory(source: File, destination: File) { diff --git a/native/commonizer-api/build.gradle.kts b/native/commonizer-api/build.gradle.kts new file mode 100644 index 00000000000..314a2b16402 --- /dev/null +++ b/native/commonizer-api/build.gradle.kts @@ -0,0 +1,44 @@ +import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader + +plugins { + kotlin("jvm") + id("jps-compatible") +} + +kotlin { + explicitApi() +} + +description = "Kotlin KLIB Library Commonizer API" +publish() + +dependencies { + implementation(kotlinStdlib()) + implementation(project(":native:kotlin-native-utils")) + testImplementation(project(":kotlin-test::kotlin-test-junit")) + testImplementation(commonDep("junit:junit")) + testImplementation(projectTests(":compiler:tests-common")) + testRuntimeOnly(project(":native:kotlin-klib-commonizer")) +} + +sourceSets { + "main" { projectDefault() } + "test" { projectDefault() } +} + +tasks.register("downloadNativeCompiler") { + doFirst { + NativeCompilerDownloader(project).downloadIfNeeded() + } +} + +projectTest(parallel = false) { + dependsOn(":dist") + dependsOn("downloadNativeCompiler") + workingDir = projectDir + environment("KONAN_HOME", NativeCompilerDownloader(project).compilerDirectory.absolutePath) +} + +runtimeJar() +sourcesJar() +javadocJar() diff --git a/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/CliCommonizer.kt b/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/CliCommonizer.kt new file mode 100644 index 00000000000..bee9c28084f --- /dev/null +++ b/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/CliCommonizer.kt @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer + +import java.io.File +import java.net.URLClassLoader +import kotlin.jvm.Throws + +public fun CliCommonizer(classpath: Iterable): CliCommonizer { + return CliCommonizer(URLClassLoader(classpath.map { it.absoluteFile.toURI().toURL() }.toTypedArray())) +} + +public fun CliCommonizer(classLoader: ClassLoader): CliCommonizer { + return CliCommonizer(CommonizerClassLoaderExecutor(classLoader)) +} + +public class CliCommonizer(private val executor: Executor) : Commonizer { + + public fun interface Executor { + public operator fun invoke(arguments: List) + } + + override fun commonizeLibraries( + konanHome: File, + inputLibraries: Set, + dependencyLibraries: Set, + outputCommonizerTarget: SharedCommonizerTarget, + outputDirectory: File + ) { + val arguments = mutableListOf().apply { + add("native-klib-commonize") + add("-distribution-path"); add(konanHome.absolutePath) + add("-input-libraries"); add(inputLibraries.joinToString(";") { it.absolutePath }) + add("-dependency-libraries"); add(dependencyLibraries.joinToString(";") { it.absolutePath }) + add("-output-commonizer-target"); add(outputCommonizerTarget.identityString) + add("-output-path"); add(outputDirectory.absolutePath) + } + executor(arguments) + } +} + +private class CommonizerClassLoaderExecutor(private val commonizerClassLoader: ClassLoader) : CliCommonizer.Executor { + companion object { + private const val commonizerMainClass = "org.jetbrains.kotlin.descriptors.commonizer.cli.CommonizerCLI" + private const val commonizerMainFunction = "main" + } + + @Throws(Throwable::class) + override fun invoke(arguments: List) { + val commonizerMainClass = commonizerClassLoader.loadClass(commonizerMainClass) + val commonizerMainMethod = commonizerMainClass.methods.singleOrNull { it.name == commonizerMainFunction } + ?: throw IllegalArgumentException( + "Missing or conflicting $commonizerMainFunction function in " + + "Class ${commonizerMainClass.name} from ClassLoader $commonizerClassLoader" + ) + commonizerMainMethod.invoke(null, arguments.toTypedArray()) + } +} diff --git a/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/Commonizer.kt b/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/Commonizer.kt new file mode 100644 index 00000000000..6795dad584f --- /dev/null +++ b/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/Commonizer.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer + +import java.io.File +import java.io.Serializable +import kotlin.jvm.Throws + +public interface Commonizer : Serializable { + @Throws(Throwable::class) + public fun commonizeLibraries( + konanHome: File, + inputLibraries: Set, + dependencyLibraries: Set, + outputCommonizerTarget: SharedCommonizerTarget, + outputDirectory: File + ) +} diff --git a/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTarget.kt b/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTarget.kt new file mode 100644 index 00000000000..35328d0f057 --- /dev/null +++ b/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTarget.kt @@ -0,0 +1,100 @@ +/* + * Copyright 2010-2021 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("FunctionName") + +package org.jetbrains.kotlin.descriptors.commonizer + +import org.jetbrains.kotlin.konan.target.KonanTarget +import java.io.Serializable + +// N.B. TargetPlatform/SimplePlatform are non exhaustive enough to address both target platforms such as +// JVM, JS and concrete Kotlin/Native targets, e.g. macos_x64, ios_x64, linux_x64. +public sealed class CommonizerTarget : Serializable { + final override fun toString(): String = identityString +} + +public data class LeafCommonizerTarget public constructor(val name: String) : CommonizerTarget() { + public constructor(konanTarget: KonanTarget) : this(konanTarget.name) + + public val konanTargetOrNull: KonanTarget? = KonanTarget.predefinedTargets[name] + + public val konanTarget: KonanTarget get() = konanTargetOrNull ?: error("Unknown KonanTarget: $name") +} + +public data class SharedCommonizerTarget(val targets: Set) : CommonizerTarget() { + public constructor(vararg targets: CommonizerTarget) : this(targets.toSet()) + public constructor(vararg targets: KonanTarget) : this(targets.toSet()) + public constructor(targets: Iterable) : this(targets.map(::LeafCommonizerTarget).toSet()) + + init { + require(targets.isNotEmpty()) + } +} + +public fun CommonizerTarget(konanTargets: Iterable): CommonizerTarget { + val konanTargetsSet = konanTargets.toSet() + require(konanTargetsSet.isNotEmpty()) { "Empty set of of konanTargets" } + val leafTargets = konanTargetsSet.map(::LeafCommonizerTarget) + return leafTargets.singleOrNull() ?: SharedCommonizerTarget(leafTargets.toSet()) +} + +public fun CommonizerTarget(konanTarget: KonanTarget): LeafCommonizerTarget { + return LeafCommonizerTarget(konanTarget) +} + +public fun CommonizerTarget(konanTarget: KonanTarget, vararg konanTargets: KonanTarget): SharedCommonizerTarget { + val targets = ArrayList(konanTargets.size + 1).apply { + add(konanTarget) + addAll(konanTargets) + } + return SharedCommonizerTarget(targets.map(::LeafCommonizerTarget).toSet()) +} + +public val CommonizerTarget.identityString: String + get() = when (this) { + is LeafCommonizerTarget -> name + is SharedCommonizerTarget -> identityString + } + +private val SharedCommonizerTarget.identityString: String + get() { + val segments = targets.map(CommonizerTarget::identityString).sorted() + return segments.joinToString( + separator = ", ", prefix = "(", postfix = ")" + ) + } + +public val CommonizerTarget.prettyName: String + get() = when (this) { + is LeafCommonizerTarget -> "[$name]" + is SharedCommonizerTarget -> prettyName(null) + } + +public fun SharedCommonizerTarget.prettyName(highlightedChild: CommonizerTarget?): String { + return targets + .sortedWith(compareBy { it.level }.thenBy { it.identityString }).joinToString(", ", "[", "]") { child -> + when (child) { + is LeafCommonizerTarget -> child.name + is SharedCommonizerTarget -> child.prettyName(highlightedChild) + } + if (child == highlightedChild) "(*)" else "" + } +} + +public val CommonizerTarget.konanTargets: Set + get() { + return when (this) { + is LeafCommonizerTarget -> setOf(konanTarget) + is SharedCommonizerTarget -> targets.flatMap { it.konanTargets }.toSet() + } + } + +public val CommonizerTarget.level: Int + get() { + return when (this) { + is LeafCommonizerTarget -> return 0 + is SharedCommonizerTarget -> targets.maxOf { it.level } + 1 + } + } diff --git a/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/TargetLibrariesLayout.kt b/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/TargetLibrariesLayout.kt new file mode 100644 index 00000000000..63a862f9b8c --- /dev/null +++ b/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/TargetLibrariesLayout.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer + +import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_COMMON_LIBS_DIR +import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR +import java.io.File + + +public fun interface CommonizerOutputLayout { + public fun getTargetDirectory(root: File, target: CommonizerTarget): File +} + +public object NativeDistributionCommonizerOutputLayout : CommonizerOutputLayout { + override fun getTargetDirectory(root: File, target: CommonizerTarget): File { + return when (target) { + is LeafCommonizerTarget -> root.resolve(KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR).resolve(target.name) + is SharedCommonizerTarget -> root.resolve(KONAN_DISTRIBUTION_COMMON_LIBS_DIR) + } + } +} + +public object HierarchicalCommonizerOutputLayout : CommonizerOutputLayout { + override fun getTargetDirectory(root: File, target: CommonizerTarget): File { + return root.resolve(target.identityString) + } +} diff --git a/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/parseCommonizerTarget.kt b/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/parseCommonizerTarget.kt new file mode 100644 index 00000000000..5c4e570b929 --- /dev/null +++ b/native/commonizer-api/src/org/jetbrains/kotlin/descriptors/commonizer/parseCommonizerTarget.kt @@ -0,0 +1,196 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer + +import org.jetbrains.kotlin.descriptors.commonizer.IdentityStringSyntaxNode.LeafTargetSyntaxNode +import org.jetbrains.kotlin.descriptors.commonizer.IdentityStringSyntaxNode.SharedTargetSyntaxNode +import org.jetbrains.kotlin.descriptors.commonizer.IdentityStringToken.* + +public fun parseCommonizerTarget(identityString: String): CommonizerTarget { + try { + val tokens = tokenizeIdentityString(identityString) + val syntaxTree = parser(tokens) ?: error("Failed building syntax tree. $identityString") + check(syntaxTree.remaining.isEmpty()) { "Failed building syntax tree. Unexpected remaining tokens ${syntaxTree.remaining}" } + return buildCommonizerTarget(syntaxTree.value) + } catch (e: Throwable) { + throw IllegalArgumentException("Failed parsing CommonizerTarget from \"$identityString\"", e) + } +} + +//region Tokens + +private fun tokenizeIdentityString(identityString: String): List { + var remainingString = identityString + val tokenizer = sharedTargetStartTokenizer + sharedTargetEndTokenizer + separatorTokenizer + wordTokenizer + return mutableListOf().apply { + while (remainingString.isNotEmpty()) { + val generatedToken = tokenizer.nextToken(remainingString) + ?: error("Unexpected token at $remainingString") + + remainingString = generatedToken.remaining + add(generatedToken.token) + } + }.toList() +} + +private sealed class IdentityStringToken { + data class Word(val value: String) : IdentityStringToken() + object Separator : IdentityStringToken() + object SharedTargetStart : IdentityStringToken() + object SharedTargetEnd : IdentityStringToken() + + final override fun toString(): String { + return when (this) { + is Word -> value + is Separator -> ", " + is SharedTargetStart -> "[" + is SharedTargetEnd -> "]" + } + } +} + +private data class GeneratedToken(val token: IdentityStringToken, val remaining: String) + +private interface IdentityStringTokenizer { + fun nextToken(value: String): GeneratedToken? +} + +private operator fun IdentityStringTokenizer.plus(other: IdentityStringTokenizer): IdentityStringTokenizer { + return CompositeIdentityStringTokenizer(this, other) +} + +private data class CompositeIdentityStringTokenizer( + val first: IdentityStringTokenizer, + val second: IdentityStringTokenizer +) : IdentityStringTokenizer { + override fun nextToken(value: String): GeneratedToken? { + return first.nextToken(value) ?: second.nextToken(value) + } +} + +private data class RegexIdentityStringTokenizer( + val regex: Regex, + val token: (String) -> IdentityStringToken +) : IdentityStringTokenizer { + override fun nextToken(value: String): GeneratedToken? { + val firstMatchResult = regex.findAll(value, 0).firstOrNull() ?: return null + val range = firstMatchResult.range + if (range.first != 0) return null + return GeneratedToken(token(firstMatchResult.value), value.drop(firstMatchResult.value.length)) + } +} + +private val sharedTargetStartTokenizer = + RegexIdentityStringTokenizer(Regex.fromLiteral("(")) { SharedTargetStart } + +private val sharedTargetEndTokenizer = + RegexIdentityStringTokenizer(Regex.fromLiteral(")")) { SharedTargetEnd } + +private val separatorTokenizer = + RegexIdentityStringTokenizer(Regex("""\s*,\s*""")) { Separator } + +private val wordTokenizer = + RegexIdentityStringTokenizer(Regex("\\w+"), IdentityStringToken::Word) + +//endregion + +//region Syntax Tree + +private val parser = anyOf(SharedTargetParser, LeafTargetParser) + +private data class ParserOutput(val value: T, val remaining: List) + +private interface Parser { + operator fun invoke(tokens: List): ParserOutput? +} + + +private fun anyOf(vararg parser: Parser): Parser { + return AnyOfParser(parser.toList()) +} + +private data class AnyOfParser(val parsers: List>) : Parser { + override fun invoke(tokens: List): ParserOutput? { + return parsers.mapNotNull { parser -> parser(tokens) }.firstOrNull() + } +} + +private fun Parser.oneOrMore(): Parser> { + return OneOrMoreParser(this) +} + +private data class OneOrMoreParser(val parser: Parser) : Parser> { + override fun invoke(tokens: List): ParserOutput>? { + val outputs = mutableListOf() + var remainingTokens = tokens + while (true) { + val output = parser(remainingTokens) ?: break + if (output.remaining == remainingTokens) break + outputs.add(output.value) + remainingTokens = output.remaining + } + if (outputs.isEmpty()) { + return null + } + return ParserOutput(outputs.toList(), remainingTokens) + } +} + +private fun Parser.ignore(token: IdentityStringToken): Parser { + return IgnoreTokensParser(this, token) +} + +private data class IgnoreTokensParser(val parser: Parser, val ignoredToken: IdentityStringToken) : Parser { + override fun invoke(tokens: List): ParserOutput? { + return parser( + if (tokens.firstOrNull() == ignoredToken) tokens.drop(1) else tokens + ) + } +} + +private object LeafTargetParser : Parser { + override fun invoke(tokens: List): ParserOutput? { + val nextToken = tokens.firstOrNull() as? Word ?: return null + return ParserOutput(LeafTargetSyntaxNode(nextToken), tokens.drop(1)) + } +} + +private object SharedTargetParser : Parser { + override fun invoke(tokens: List): ParserOutput? { + if (tokens.firstOrNull() !is SharedTargetStart) return null + + val innerParser = anyOf(LeafTargetParser, SharedTargetParser).ignore(Separator).oneOrMore() + val innerParserOutput = innerParser(tokens.drop(1)) ?: return null + + val closingToken = innerParserOutput.remaining.firstOrNull() + if (closingToken != SharedTargetEnd) { + error("Missing ']' at ${tokens.joinToString("")}") + } + + return ParserOutput(SharedTargetSyntaxNode(innerParserOutput.value), innerParserOutput.remaining.drop(1)) + } + +} + +private sealed class IdentityStringSyntaxNode { + data class LeafTargetSyntaxNode(val token: Word) : IdentityStringSyntaxNode() + data class SharedTargetSyntaxNode(val children: List) : IdentityStringSyntaxNode() +} + +//endregion Tree + +//region Build CommonizerTarget + +private fun buildCommonizerTarget(node: IdentityStringSyntaxNode): CommonizerTarget { + return when (node) { + is LeafTargetSyntaxNode -> LeafCommonizerTarget(node.token.value) + is SharedTargetSyntaxNode -> SharedCommonizerTarget( + node.children.map { child -> buildCommonizerTarget(child) }.toSet() + ) + } +} + +//endregion diff --git a/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CliCommonizerTest.kt b/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CliCommonizerTest.kt new file mode 100644 index 00000000000..e51313d4a1b --- /dev/null +++ b/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CliCommonizerTest.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer + +import org.jetbrains.kotlin.descriptors.commonizer.utils.konanHome +import org.jetbrains.kotlin.konan.target.KonanTarget +import org.junit.Rule +import org.junit.rules.TemporaryFolder +import kotlin.test.Test + +class CliCommonizerTest { + + @get:Rule + val temporaryOutputDirectory = TemporaryFolder() + + @Test + fun invokeCliWithEmptyArguments() { + val commonizer = CliCommonizer(this::class.java.classLoader) + commonizer.commonizeLibraries( + konanHome = konanHome, + inputLibraries = emptySet(), + dependencyLibraries = emptySet(), + outputCommonizerTarget = CommonizerTarget(KonanTarget.LINUX_X64, KonanTarget.MACOS_X64), + outputDirectory = temporaryOutputDirectory.root + ) + } +} diff --git a/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizeLibcurlTest.kt b/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizeLibcurlTest.kt new file mode 100644 index 00000000000..8a3191e5bf9 --- /dev/null +++ b/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizeLibcurlTest.kt @@ -0,0 +1,80 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer + +import org.jetbrains.kotlin.descriptors.commonizer.utils.konanHome +import org.jetbrains.kotlin.konan.target.KonanTarget.LINUX_ARM64 +import org.jetbrains.kotlin.konan.target.KonanTarget.LINUX_X64 +import org.junit.Rule +import org.junit.rules.TemporaryFolder +import java.io.File +import kotlin.test.Test +import kotlin.test.assertTrue +import kotlin.test.fail + +class CommonizeLibcurlTest { + + @get:Rule + val temporaryOutputDirectory = TemporaryFolder() + + @Test + fun commonizeSuccessfully() { + val libraries = File("testData/libcurl").walkTopDown().filter { it.isFile && it.extension == "klib" }.toSet() + val commonizer = CliCommonizer(this::class.java.classLoader) + + commonizer.commonizeLibraries( + konanHome = konanHome, + inputLibraries = libraries, + dependencyLibraries = emptySet(), + outputCommonizerTarget = CommonizerTarget(LINUX_ARM64, LINUX_X64), + outputDirectory = temporaryOutputDirectory.root + ) + + val x64OutputDirectory = temporaryOutputDirectory.root.resolve(CommonizerTarget(LINUX_X64).identityString) + val arm64OutputDirectory = temporaryOutputDirectory.root.resolve(CommonizerTarget(LINUX_ARM64).identityString) + val commonOutputDirectory = temporaryOutputDirectory.root.resolve(CommonizerTarget(LINUX_X64, LINUX_ARM64).identityString) + + assertTrue( + x64OutputDirectory.exists(), + "Missing output directory for x64 target" + ) + + assertTrue( + arm64OutputDirectory.exists(), + "Missing output directory for arm64 target" + ) + + assertTrue( + commonOutputDirectory.exists(), + "Missing output directory for commonized x64&arm64 target" + ) + + fun assertContainsKnmFiles(file: File) { + assertTrue( + file.walkTopDown().any { it.extension == "knm" }, + "Expected directory ${file.name} to contain at least one knm file" + ) + } + + assertContainsKnmFiles(x64OutputDirectory) + assertContainsKnmFiles(arm64OutputDirectory) + assertContainsKnmFiles(commonOutputDirectory) + + fun assertContainsManifestWithContent(directory: File, content: String) { + val manifest = directory.walkTopDown().firstOrNull { it.name == "manifest" } + ?: fail("${directory.name} does not contain any manifest") + + assertTrue( + content in manifest.readText(), + "Expected manifest in ${directory.name} to contain $content\n${manifest.readText()}" + ) + } + + assertContainsManifestWithContent(x64OutputDirectory, "native_targets=linux_x64") + assertContainsManifestWithContent(arm64OutputDirectory, "native_targets=linux_arm64") + assertContainsManifestWithContent(commonOutputDirectory, "native_targets=linux_x64 linux_arm64") + } +} diff --git a/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetIdentityStringTest.kt b/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetIdentityStringTest.kt new file mode 100644 index 00000000000..7e06c4fd640 --- /dev/null +++ b/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetIdentityStringTest.kt @@ -0,0 +1,137 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer + +import org.jetbrains.kotlin.konan.target.KonanTarget +import org.jetbrains.kotlin.konan.target.KonanTarget.* +import kotlin.test.Test +import kotlin.test.assertEquals + +class CommonizerTargetIdentityStringTest { + + @Test + fun leafTargets() { + KonanTarget.predefinedTargets.values.forEach { konanTarget -> + assertEquals(konanTarget.name, CommonizerTarget(konanTarget).identityString) + assertEquals(CommonizerTarget(konanTarget), parseCommonizerTarget(CommonizerTarget(konanTarget).identityString)) + } + } + + @Test + fun `simple shared targets are invariant under konanTarget order`() { + val macosFirst = CommonizerTarget(MACOS_X64, LINUX_X64) + val linuxFirst = CommonizerTarget(LINUX_X64, MACOS_X64) + + assertEquals(macosFirst, linuxFirst) + assertEquals(macosFirst.identityString, linuxFirst.identityString) + assertEquals(linuxFirst, parseCommonizerTarget(linuxFirst.identityString)) + assertEquals(macosFirst, parseCommonizerTarget(macosFirst.identityString)) + assertEquals(macosFirst, parseCommonizerTarget(linuxFirst.identityString)) + assertEquals(linuxFirst, parseCommonizerTarget(macosFirst.identityString)) + } + + @Test + fun `hierarchical commonizer targets`() { + val hierarchy = SharedCommonizerTarget( + CommonizerTarget(LINUX_X64, MACOS_X64), + CommonizerTarget(IOS_ARM64, IOS_X64) + ) + assertEquals(setOf(LINUX_X64, MACOS_X64, IOS_ARM64, IOS_X64), hierarchy.konanTargets) + assertEquals(hierarchy, parseCommonizerTarget(hierarchy.identityString)) + } + + @Test + fun `multilevel hierarchical commonizer targets`() { + val hierarchy = SharedCommonizerTarget( + SharedCommonizerTarget( + SharedCommonizerTarget( + SharedCommonizerTarget( + CommonizerTarget(LINUX_X64, MACOS_X64), + CommonizerTarget(IOS_X64, IOS_ARM64) + ), + CommonizerTarget(LINUX_ARM32_HFP) + ), + CommonizerTarget(LINUX_MIPSEL32) + ), + CommonizerTarget(WATCHOS_X86, WATCHOS_ARM64) + ) + + assertEquals(hierarchy, parseCommonizerTarget(hierarchy.identityString)) + } + + @Test + fun `parsing CommonizerTarget`() { + val target = parseCommonizerTarget("(x, (x, y, (a, b), (b, c)))") + assertEquals( + SharedCommonizerTarget( + LeafCommonizerTarget("x"), + SharedCommonizerTarget( + LeafCommonizerTarget("x"), + LeafCommonizerTarget("y"), + SharedCommonizerTarget( + LeafCommonizerTarget("a"), + LeafCommonizerTarget("b"), + ), + SharedCommonizerTarget( + LeafCommonizerTarget("b"), + LeafCommonizerTarget("c") + ) + ) + ), + target + ) + } + + @Test(expected = IllegalArgumentException::class) + fun `fail parsing CommonizerTarget 1`() { + parseCommonizerTarget("xxx,") + } + + @Test(expected = IllegalArgumentException::class) + fun `fail parsing CommonizerTarget 2`() { + parseCommonizerTarget("") + } + + @Test(expected = IllegalArgumentException::class) + fun `fail parsing CommonizerTarget 3`() { + parseCommonizerTarget("()") + } + + @Test(expected = IllegalArgumentException::class) + fun `fail parsing CommonizerTarget 4`() { + parseCommonizerTarget("(xxx") + } + + @Test(expected = IllegalArgumentException::class) + fun `fail parsing CommonizerTarget 5`() { + parseCommonizerTarget("xxx)") + } + + @Test(expected = IllegalArgumentException::class) + fun `fail parsing CommonizerTarget 6`() { + parseCommonizerTarget("(xxx") + } + + @Test(expected = IllegalArgumentException::class) + fun `fail parsing CommonizerTarget 7`() { + parseCommonizerTarget("(xxx yyy)") + } + + @Test(expected = IllegalArgumentException::class) + fun `fail parsing CommonizerTarget 8`() { + parseCommonizerTarget(" ") + } + + @Test(expected = IllegalArgumentException::class) + fun `fail parsing CommonizerTarget 9`() { + parseCommonizerTarget("xxx?") + } + + @Test(expected = IllegalArgumentException::class) + fun `fail parsing CommonizerTarget 10`() { + parseCommonizerTarget("(x, (x, y)") + } +} diff --git a/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetPrettyNameTest.kt b/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetPrettyNameTest.kt new file mode 100644 index 00000000000..3891818b2e4 --- /dev/null +++ b/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetPrettyNameTest.kt @@ -0,0 +1,88 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer + +import org.junit.Test +import kotlin.test.assertEquals + +class CommonizerTargetPrettyNameTest { + + @Test + fun leafTargetNames() { + listOf( + Triple("foo", "[foo]", FOO), + Triple("bar", "[bar]", BAR), + Triple("baz_123", "[baz_123]", BAZ), + ).forEach { (name, prettyName, target: LeafCommonizerTarget) -> + assertEquals(name, target.name) + assertEquals(prettyName, target.prettyName) + } + } + + @Test + fun sharedTargetNames() { + listOf( + "[foo]" to SharedTarget(FOO), + "[bar, foo]" to SharedTarget(FOO, BAR), + "[bar, baz_123, foo]" to SharedTarget(FOO, BAR, BAZ), + "[bar, baz_123, foo, [bar, foo]]" to SharedTarget(FOO, BAR, BAZ, SharedTarget(FOO, BAR)) + ).forEach { (prettyName, target: SharedCommonizerTarget) -> + assertEquals(prettyName, target.prettyName) + } + } + + @Test + fun prettyCommonizedName() { + val sharedTarget = SharedTarget(FOO, BAR, BAZ) + listOf( + "[bar, baz_123, foo(*)]" to FOO, + "[bar(*), baz_123, foo]" to BAR, + "[bar, baz_123(*), foo]" to BAZ, + "[bar, baz_123, foo]" to sharedTarget, + ).forEach { (prettyCommonizerName, target: CommonizerTarget) -> + assertEquals(prettyCommonizerName, sharedTarget.prettyName(target)) + } + } + + @Test + fun prettyNestedName() { + val target = parseCommonizerTarget("(a, b, (c, (d, e)))") as SharedCommonizerTarget + + assertEquals( + "[a, b, [c, [d, e]]]", target.prettyName + ) + + assertEquals( + "[a, b, [c, [d, e(*)]]]", target.prettyName(LeafCommonizerTarget("e")) + ) + + assertEquals( + "[a, b, [c, [d, e](*)]]", target.prettyName(parseCommonizerTarget("(d, e)")) + ) + + assertEquals( + "[a, b, [c, [d, e]](*)]", target.prettyName(parseCommonizerTarget("(c, (d, e))")) + ) + + assertEquals( + "[a, b(*), [c, [d, e]]]", target.prettyName(LeafCommonizerTarget("b")) + ) + } + + @Test(expected = IllegalArgumentException::class) + fun sharedTargetNoInnerTargets() { + SharedCommonizerTarget(emptySet()) + } + + private companion object { + val FOO = LeafCommonizerTarget("foo") + val BAR = LeafCommonizerTarget("bar") + val BAZ = LeafCommonizerTarget("baz_123") + + @Suppress("TestFunctionName") + fun SharedTarget(vararg targets: CommonizerTarget) = SharedCommonizerTarget(linkedSetOf(*targets)) + } +} diff --git a/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/utils/konanHome.kt b/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/utils/konanHome.kt new file mode 100644 index 00000000000..941a49a4ccb --- /dev/null +++ b/native/commonizer-api/test/org/jetbrains/kotlin/descriptors/commonizer/utils/konanHome.kt @@ -0,0 +1,14 @@ +/* + * Copyright 2010-2020 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.descriptors.commonizer.utils + +import java.io.File + +internal val konanHome: File + get() { + val konanHomePath = System.getenv("KONAN_HOME")?.toString() ?: error("Missing KONAN_HOME environment variable") + return File(konanHomePath) + } diff --git a/native/commonizer-api/testData/libcurl/linux_arm64/libcurl.klib b/native/commonizer-api/testData/libcurl/linux_arm64/libcurl.klib new file mode 100644 index 0000000000000000000000000000000000000000..a11828a1d123a783c9bf14a7e6fa8d1804b3a838 GIT binary patch literal 40130 zcmb5U1CS_9lP)|uW81cE+qOMtY}>{e+qP}nwr!u`op<;DV>e>Iy}P#~I;*RzGP4p- zcXda~O96vG0{r_y@c*^{-hcxj02rH?8aP`y(WxlI0D%4HQThLt4gNo|IT<*ZnK(KA zzp!Kf3wA4W8)r8?0|#qX=KmK_ME`>*8v`eE7n6T25g7mg9Q?;%0)Tjy8Rk}e0DweA z008R$okSx?Cuc)PT0^7%;x=zBD1K#?x1IrLCSYjSYk+eAV3=-H9Xuv(GY|{AMv;X< zE3GOTbX`FLXxmu}GxSY?0YNk^%8lMirwJFtPqQivy6C8=NmfQjf~La7(aI&s_Z+Sh zAEp~E~)gh)L zLZMtkxutY2OOz-VG!ZsBHB847vN&_4Tn3R>Q;RUJ=dv7zo(F~@TtczKXCZ&o4DB`? zw_xrd#i~2%x3=V|t8AUsEVh=e$cr1t_eAq3!v%z!hj0^4<%Whbuc1ZkV~C{8PKRW- z6wEHuCRde+>c}$Nq2kf|g~>0@%`spkU9CI0hW4r_6c?RaskF8z?jqKyU1{tIn4T|W zvkJ(LrOi(DO|5LrChMkW|IDQ#@i3rqI-hU~#c~+QIt^!@$8anlIgTSZQp>WD&*k7o za}>pLY!$pCKE)4apNE|}55xX_+Sqa)nor-l)(qt;8n7-w{{0Br8FiTuSQ zFrQL)jz6}@jaXNpG+eZixo(8Z8ErOS+^{D(bu-Du4vW;)F)M>2stk z*q2g5lAx8vpQ^-&5W05q>2t@DJ2~dh>S&iOqD1`ymW?A8HV$dw#f?JCr#jV*&)rV; zpD80_&P0c&;D32Av*c^A2*qg5p@ch@4h1-iP(50+A9cKs163U>Sl$AbxMxF2kCt-M zmWiiMcV+e{(}D7EZAs`hBm^1-%te)Q&QNSAVF}i}i}Si00WF;xSPHgGip~6o9k$j< zoyo(bpGtK%qRCUBnV1oU+`y4Zrq;qf5o$x1%?7DXPQ68?r*PbmCt3u!y4Q>s^- zSb!HU;}O8_M{iKhsIFJ5fXeHwhV;h1vABkb&|KL>QYg`!*}h(rKut^t?TddHtXZVE z^BZF|Y6B(pn;N19}CRbgFC0 zDFabC(s*&7{qG{cQm<^5GEqvd+QPU#8i6wcnY@)4oC3le#)&we zX`xj%T+f2~W3c9;64QHhWl0IGweM=%-?2>3viM-Aa1wIqWUt(_>XDYNRcuzK5~Gv9 z8@kw*vq{v%DV&UFe8RKG(!|XVg;Vuz2RwbEV(2Dm9do(Ln4DkT@=F94)4IjsThB*1R-_Zp`>oxuGt!)jfXGB#xG>`tlxk00 z1xp4B^i(JoMY{>VoIO^#{t{t{ouXR9w(US(?cNG@VFL2HSbPiSU#Q;2R{R`pQ#N!oBV(PbY)z|7`$5B;q`WmE3io^S} zj%h^o)vdQnQNBP$>9aT*a>w$<7R%|eoxHydUDK&*v(}wm9n==dG8`82X@C2ofNu;3 z^2MB9U_Rn!lnoC~M1=P5W6JWm=#6~!6-m`ol&8^P-q6F8KWG~;1iJ4kU?^zH^l?op zMrq5B*Q=XCXx1w`??tD!H#%)!+f!oCQM$edZwE8pF0UQ$*=bnsQ!f%dLB+V&6D-hT z+nesMd`Hd$Y`U-SW(Qo#B6P9Iq@vedpGQPRqF0%C1-$4Lf3KbHF~W&c6mbPhAOyor zSA{55x;!kpkadP06S0iy4>A~^Rt`}E_(>a8E~pY|Cz|BJ1n`maDx0Jy61l?F1qJbu z1azFRbIKvZq)KLlP8;*_lAX43DJ(0=j6tmH-3sA&4dhw9#bQIGW3-3b%6=u@XX^1U zXNmVR^!VketusAcLFV|ygqpQclQ!w~R{eD-2_(V4AR)#dpxgb`q`KU?O{Z^;jd&ZV z$G>sKD(U`*ME~7Dih=4YRr(s+V5rBkfl@ya<-2!8De>UzdI}8mX%WrmvkK03auKff zQOpNPzhh~qi;Phb^)^gzd-{;rWI@iy{qx9@;wbj(bqG!2W1{lcn}=ty&mf-OcMo%l ziC+<)#>MEOo<4+nE@yd(&!brG@fZ}v5#1Mo%MPK8GV9i(rML$p63xEe2O(PbPISCo zhA*mZWm5rT>iNukpoC_MNZH*)X{^QcA{*5w=M5artWwLwN4Q5uG6PR9--4oAKs|-@ ze!|=%DUA_QMe-L{fHC#`#OtgL|4?td{hDwawFWhY?P*-pmJbF_Y@GNoj}L|r74qLi zhZsH4Wgj%nKVv=^?=#~0Ceg8fO*;Q(0gtI)rr4JOj^P*oHQ~ehlc0aLtbS|>Cx}Sp3*@`sQx`JucYP z7hh+9+TKcAThD-NFD*`_f6Ueg&>b>ju|S? zp_}W#PxnS*|{ag8~eA_ zkwbSz3whLlhJ(!k5+HUT)(+;_F}Tm&6NMO#_H;++6IEM6JLA!^{&ZnHrj9CvnWDRk zsWrU?8JJR>4FfZZn+L~od!%@13cgXYm9?fbOtpAG+ScNXwdX9aBoeW7ayP-u;BG4j z(V4Q&wF&iDzqp0xMiI{lPW50_n3`j#CwZ3#uxo4ZiFM9>NJarIx`Lfq3xUg<_2yca zo%08xYin-THQ}}$3r10$_Vjn#dr>C)iSObBS8KeiHx&f zb58wHjh)ce6Q33?+hTdk(yupo8}b>Ng%vxYF5dzCof(*>8_`YK?DC8Aer=o5w1kqG z&RDGT5T8dc05S;AMFFM~JESJEin7p_L9&+Rhm_ZFk#`~LZmMitoA*cm7>Z4qTq}uX zt)NMP*P0Z+BlmJ$h?n(`k$muY&**PvZ+x{87!%EO=VYw&Y85UOv9`SGuLizwv~ojH zTQIuCMy~l8Mv`@hrYFnm`5>_1 zlUQ-~zueo~nbSvuA-?Rfai4HH_~xD!X6n8x%J zt?%mQul7v1u&l{qIRx4&ojjDzPN9iN7BheF4}$rxoBv9?J$u=dW^g4|Gux1xt-F@A zjgRo|B$l2~%4yiQL=8~1Atz2AV5|R`IJ#^@FrGY`zAlIxQ^vG)!7ZxDCZo9N@VUMm zCgm~xeH;QQm(xj@#n!RXSPj;i$BJU%1HMa{gBCwKt<+?5520I%q~qaJ3Or=rDR1Np zE^&EGvy(lB(BdGZf*aB^AFw>zb5b0{UZpBEe{8>; z^Ql;(J-Xt2U_D8zZHWG&DvlWVCmoV0r1rK_eIq{jH{RA1kUDO3=Zzh5p2q%QZ92Q*CyG+Le9QQzn%xETf;jG z@!9~+HIcRQyTi2|AFM_pS8HA~w=LFDaJz}rK0Mt?MM3k<7;KV? zMBUW_5zB<8R)Fc(Ug;#}Wm<>F&i=l4@Y6f4`Sy#|dv{mI%N0+n?M-iY*TDOBd#&wF zllKi(haq7Hqp34WdWQvLhpzgXbMLZqVg7}Y*~;H49X8I6>7Hfhf)1)jVYNv#or`KG z9<1E^OBf~h?ey|{ugu(g>@j8c>7Anc54)OirZa*hvtiIjAL%0rAJD(g_&XV+D;4*f z=z@H{dH2}pLVS8k?x>+b9;jlW9zLl!=NyKxPm@!EH%och&TzpV&9?kEBXKup@-t9$ zL|#mb4_}^n*%&#&9=zYAi;ibz#wqdHSbK#hAIkGcoS~1CGGsg$6XG+UzN9=Ck`gmS za0%HoG=(Q?IE5!wYT`5Rq2eZ;_{WVe8sMA%-FrbsdP_oTqfFS8WmNZX#Dr{K(DId(#T-RE^s^A&p!o+PGwN zv2lE}dL~j2pr?9rr=VRqCD!dm_U%4qlMERjd{vKX^~WwZCw;t18B2@QGL{z^v7nzt z3|EEBQwt>?C4<&_SJjOj<&h{)ZPyl69qj`+?p{f6jCtMhGTD|SGn$J99`}Ul!Mwc3 zPH>-|{z&%i3)8C$MD30R40=+Ak&RR`xEBF9)s20ZXOqGXTh31rZ_h~+)y?H+(1X0_ zo|DBL@M7Q3hYAwZH0-pdo1{IS1ryAxDaUoDxj`TE89vkL%TejxG-3gB(p%2rv5IxP zx(aL89}gN4ovSk0Go(Fi(ia?mFg$IX#&3U5Vi4m~F-{$fuiix1oHI44PX&6Pfq9OCGZ^e0RN2prD7g#Mw+AmD zp>0q)mP;<99jC01FP~dNQB_EePdpa8hq!|x|4yHOQjXMZV$GYuzfj{)D9tsR(%SZY z`b49(c0ao73KY{k)}^MgbTqaujAm-?WNa;}tO~?`&RrKe;U^?+WyGy2GyJsh>|g<= zi5{`QJ-7T&bVdFKEg?IeXhqMY+81i%SkSYf0$p%zn|I0mm1yeJIzMOF{5+S@ArtHR zWTzq5u&`RVq8NH$Jg4mmXT8#8qWnC{@hrX0djcavK^L=PHhMxacrub(Qn$yv^kMKDm9{Vekxbf5J7`P~t zA@y#C15ZD8X3neb#HZU-0;pc^qAkZ^u3Y&2L&NFn;%eXW@^>fPBj{e6obJcuAJ+)V z=Nb&!tWIK@nn2kBKF5;HKNQ6aTx>J_o(Dt6tg~)6L5^7GIz;7;?D{Z#HM(DI+e==& z)0Q)kbLrjfcE5aaI-iTXxkRpLmLV>^Cqyh;rkb?1V;$34v;9o+?=DWlYbM6Bi}pV> zFny}KSn39v5_OQYbDYZ5yYzLsH1?k;#}K=oDY{;pq_-9WafYW0N1h+IQ0H!(A-q4A zcW$4y#-Hz&S%s8=+YKU@7ng$1@;?yF+sS)|(m}mQx=D{`PfXk65}*MGng0T;TeUBx z&`^@;Yz275cFdD@@`6=C3BNR3dYjIDj@6BF@3Abd8zV+9(ITyOS+;Aj>NT?Rd_D-j z)CWc$->oci^;{RbBQ3A{S#1Y3v2OB-H5QAZhHub4erGqUou)a`Nyz-*mx+TK%dyfe zei0YLv2tCadi%BMK&~eKDze9Z^M#ZH+imWTW8xxi*XihYs`jUE3igm*Tt`mlCHZG^ zr`=2o?E8%I$4xaydB)PvcgJz*PWATZoAby();ZM8$Dy70bJ;;t6(3hRv28_U(^?OE zI>}8LoJAQ{3{AY;;!2|s8@3jS*;4W7az@NmyzSD|pS2#&?BtJ1+?c||=@VibNi3E^ zCtf=90#z~hfJ{0G&a!86&)Nr*FSXUpy4&n>A1uG1Clqluk{ZXi-((5jEFiIU@vuPloB&ZBmR?<)VW~V&Z z{u?($ip2eN2wxBeqQrZi-ov{MrMiY1;@{=jsj~3jqF3_$v5h+6m%ydoPi`f%vRc;DrI{~M~Q z1i=U73t|zL=mY%2QF_y{^HmWg1`6CO8u9`Z#3%nB`bGH9oewWk8(un}Ulwv?KU1$L zE3x2T>B?@o0sVcW=Io~^?-|~^%{jBesiD@Rs{Q*V+X;8X9wwEoRwW|y8?Hr`Z4F1RVz)~F9SA^HtQhQwh z?{`1UlV9+!Iu_bBe!btZm@8EHw>^eVUPB87`L(e8yE}q=?SLRYpurcQ@UK$xTrsx= zw%w&wq(2@3g}eX;c{hce!GquLl-&CZ4Ahg+{{RN^r9pbFq5DxGy;;%ustNOtW7aS; z>G*eRW_P^+f%xPCPvF44Qb2$BUN@LuJ%91<-Yo2TBh9ku!Bk7}*TR|KegG0ozhH9v z^6yUc{}a_7r~z*N-Hg=ca5Fu`kRP+{$NTMc0sL>E2iyTczNYCj(fD_JQ2!bEfE)N{ zv-&3r_K4MR{Iw&}!%u+V_K2hhKc4;09&`Kh>!r(%dVoFM2qiPx z@`E=68`$VOxXFro0tEUdF1R6Bo1yx4OG`@94UCvEP6L?|vgagSWJIuPY_H zoIlCOe4GXe|7xz8DaOBhVrh>H=zUQ!bO8eX0ZXGx#=pBj$FnC!rx)TI^Mk2p>Ef)h zh7*P>?(8j*U5{TN?^4h=B)B}CQ6@Q?$v0QT`x0sNC|^8jA3pdg+Q3q3(-W=a6reE6#` zjGr&}`_Q1fe*pqMAqx&5<>XqCbKU{_WWSNfJh=I5cW8#5Aii$^$Z_uWbA2_}v|N2KK^S@EB)MsGs4kiDeJbp$)ank|x zUO`yEJzT3Hx7z{^;E@b}fI8h!OLF_M3ytCj>3!WY|2zbqeW`xdQ5(x>FXn!CB+&Y! zY6onu)vx=46MUxyz}q=&o%2VdFDLlVLu3^WZ0`aI{?aV<86*3XbfJ5!VFdJ`^Cy94 z^ecbjvDD|r>!)9$_fmlMMA`PzF)fBGd=)w_8DTMgxs=3FMB@IJC8;O``;DojyuH3Q ze^{0B7R&pK(OwXUw313gEmcWTRgngtxE@?2DL5EN5HV7pioAA%GFTv9Ba?B1(;yD{ znVh63IKNOCwXD65mN->CsK5T>KA>L`aAa~Hd9~cSKM})Cb5KK6H#75tn;<-Et2~{X zlTAesm1}4yn6*$dXt1!Yw9^4+ynZ(4@}-6bx!R9m=mt$klqf-Gv8}dJ_0-g1;)4n( zFK5g$ud1A&q?U4rw4NJ6+LX)zOM}2-oYatkBP+GHP{}D7LK<@=Ir(Hwa)^qTK%;j| zL#5eqpMcBbriysH9T8Crb^jO zh78k7Dx6X&HAr|BCBixhN#_Z|3KCJ<291EEUIJ-~k0D%%<9BDi0|7-^)AOT^s)hz_ zrwfu2dpT)gQGLLgHH!)%1$`a)K88NpBM5{zV=WkEWg#6cLAcH`5(x!`zlh)kX?kIy zFlt%uu&xyq6*BBa?H;ZW+}G-JA=LEdPizF0Ly6)nPy zV|<#7fR@%Y$buwmZFo}f#keID*&*iIW``%JDfUr6sdl!p>^WJdYCOkT4dsllII#)^C;`PtvL1~K zkvKzyy$EAU|CldJ``@IMFz6|b0Ep@VA?fa0;d6{UBUgevGPAsO5>{0K6Li#u zjbqXVhQKWFn1W3XZ+E>w29=wW28^@nyseOS2Cn)@GBiXDjM+8btLX!0N6tu2^$%0q z(u_=K2>Q(SO{1J|K`jV(m<-^YlwY1C5g#I+j9q@~jTj@8sPlQHzc@=FytQiKTsYla zBvRUiKl%@J*Q7`cj@59zJ>FdCn`*TYy=DV@y%+kQ=(F7Ms1pOwg@%jf$u;hFnW3L1 z;@d$$A;U6t%Z3Z)gz*Zr5F?b>G2Z|O)yOf<5F9$*r}j5BI6*dy`b6CR5=Utb@_r3x zgV6Q?ey}2d-uKMD4Q7aB5B}_gL+^es@;`w;IC*CsASPO&tzWE!BBAiNL|bd?lq2Bv zA>0}0(t6F7@WP3AgGK261{_+U(paRKPkET!zsP1p5F!qEkr-ZKO1eQf6X08UQFy;@O0PB#=4?w61dz@jXuf?k{Q=#0^UQ`sqZ9F{=u{ zvG#T)#Z}ck-4XB1hbPIbusbaTNiQ|A2#HNT1KYR0nUyu_^XIS7hVpgB&-M88Hj&~^ z!i+rpI{Kzr(~3ztS&4M5!0e@oi}B;+saLx z=jRoQ4wQ;3NykSuw&LY-EJrICvzArfUt14&lynVAN6Ki`4H-z#6l2ASgF%Idg~mn^ zbNcktGd1PaV-@KsvA#uuAAJ9PxyS!hWMOIR^i#g^uZt}Hb=?Wc|4?LMZewKSY;0ou z{~{CdKgo13akO=IFf#dX%2NKL@)^q>}03Znj0N_7YwOAY2n46k7I{laG4rir_ zm?LKRtrMzxQOW8ZxI$`pdc#5lad344ourAQ>)AF5yZB%y09)-&`H@6479&OY5_4=kUL;|T=P8lg05e#M=K^hv1B9i-bY7WFw8Pzq+z-$rMCE}pXf^e za`i*}d`g?*9&?meot$Bh&XX-Xv2K@s^63Y+f0MQ1ZX8(FUhTZLkbPaum|ZFf#{yIq%sMiScO0Xn9@^)9hYe}s(CfP ziAk}xBTiWuNI!vqUldUGHx1+waa&8(vn)D7k{lswjNc~g#9^3XhTyocJtzQtZW2lW z5$Xt}WEcQ!sk5Lyh%SMH%UK{Y27=7-m$`f}-QlhYz~6;%H}KZv$8HgGcd*AV;<1krU1 zr8ECjQL+D=X#a}e+Sb_F%H+QQ>0rKbjD~!6ikg;IW=UpzhK_=kLXx_cl73!hdXh?l zW}I$zYD`*^mS((8$#B-N)-d!Q;J;rv!N1aMXJBM$U}mCcWo~HX>|pgjSrT%7hzAM? z0I>0M(*1AbG0^}2qG>H{tpAIJ)^l=_gY?Ltx5PMHPiFsG=mcp6F~(Q&$T{ zz*rI#3zeRy7uCVm9f!fykh-;rP_)xjLo5}timT3q2`SRF?zX#8)0A13>8cX6AX3aT z!2wl0Ze_I7k_I=mZ4SIe>HS}l31{>j#)4{+Qld=167~cnlUNCBND<=T{qb_)#YQIw zCy5^kk$Vo#WZ5G=g}lV7yNJHgr?Q`b0(znJ^z7;uSxTm>hV#DVybJ1NVzS0&IO;Ij zpRQV5x7IxMVKP~1Zo%Sg`6Ks$eg7?H|B)?9cmZ1%pa1|XX#Yze)3f~FeVn@Cvmgo| ziZsGr4K7S9yU(6jOi`4mh$+banAy}=*OE+Q)nE#XV+=)h zMSW77W?E*oTY-ug`zfPsa9!}#vJGSx8+_0Y@A+smFPL^CqSef~ zbhmBOt5m3~7Ay9ncLVcq({<03UZu^7da4%*b|QQbq0@{YO?wFDzDurz2Yt zwQxR~T0ILpn$xi068myz0m|!GsTR%pxOtzZkZ@)%pBL+?GWi{LE28BLiIi~15j%Oa zGjAV^n$Fz-vDz!(O4~xZXlD07{f#)fL@W<^QW^aB%Eer3DrcT}Ev?LoMkePX;(SdS zf}&iwU?6@t@!{3z1+o1&Sw?%{t52yJ{WH*+khuY4Bz`46t~kMAa+0Nnl1-C&$~hEG zbe@us9wzDF;vm_qPmmaOHq@@aeQCi;>@LutBW;xOcX>uCgp5Gklf8CkweXyfiVLw~dbIoaLe_Vv{jS?qI^`Cm4V54W4=sw*(A zcUPylSvMK;*_MKSi2aOB|1AcIHd24d`M@f?ROXRKv3Pamv0kW0ok zCAGN{&Yep4K{waeSJ=GXtp!wsU_I#kOyz97UZV9F&}e%Ce=ISw;My%RhALUE7$V0t z44fYkP7pE$<2L$9bSx$eawD^B^2{Vzg*P4ow8`@}{LvU2+uON1-d*98Ey^F#I?hA_ zY=)|ea5oZHnd4-*Ggd;pD}^(_5lI}$RSFfX$@|h^VNN2-nX@s+9f;MA7M}aEa6Y5Q z*JfvT1lepfEhbjt{LHbwRsGiCM^{30b{VIKkLmf^2iG10Xv2||iP$VcCKZ${BrKEB zIGd^T`};_4=3Y@&dJQ%X?q(%0I?=RSLE8(N&y`R|Be8m+AeaA6&!%PO0qIgDlZXLM za)?@cixB|tQSC;ury2hNSuc{)PjXSGqn0#fXf98IAu_SFR4aJ(6YZ}BCteEpTOH3+ z?*CQCuum|SJ%I+e*?1V{jo4d5FV-@lIH&94nD~{RKd@KdoUZ)fK^`kH<-H~7;n~Iv ztzFt6TIY;cY-X6{+Q!=n(|v%z#k-ycQ(zo}k#wHQp}Ue}JD7vlXEt`(`%-^KUS;Kj z?R!0#^Zryfyc0>q(y&Ng6{A;S6=ltXG!yOM++XR(sUTmGn+#PBasDSj6R1g1ej-;k z->0H<2MzL^u~bxGOFfM#)^w35_lq0$URiZ^5MSxc~u>xNX%>>D~ft)VTE1%r9 zax#Mnqm9rc%x*hV~sjXXwR+Q*UpS zCLSeu7zRCp&Y1OVs?vkpY_KNg{N$voj9)5mUGnlKblt(jwGq!(B9GY1vu<>G zJ}U}6DRXCzzqYO@Jz!U6x3)!HJ;9#dY14;1OLtxrdhl|a@$#FoenW#~`N=o|X`X^K z-a&}pL9~X;^`i0uZmfb-ra?<|7`R|1Erq`qWr#5@m`vh<9p_gTriRwn8}g1*M(BuX zsMGDX1!0L76;6z{snrU4o8dMtCDOKq`jHDHLDa zVvIZC5GI~+ZVIPW577K`A^LN{`g8X>S9)d7W|H*J=1rdT$rs1C({%^=Lfej5+Vm&j zPsj78K8v2L7i*_S5kWX3W}IAzx_v1T|?N z$t^c<#(*OHrWk|=}OKYfUI*IMC$5?bdgirtjAdpOe_5PqgJfT!Q4WX2v6rxZm z(Z)(MqJ|$PAY${i)VkuSZu)hR)cX8WSGU-Ea`($yGt&gl z7T5ABTk`z{Uv}C<7Kh`t>vSfD%s|b3h15}mTV;zaF;0r*>`r!`6>E~DX}!bHu`w&I zRMhx#w>n`(aRP;gOGy3MpYF@`-qW3H<>q3l zv~sY}#*3BO>GEO?4kjDws=tW70NXMv2~!CFXbS+&M#5G&l(D6uCz>qAR)qIm!oS7` zsUWUJX;(avD{gZ!(gSQOCnQT&l&ZQ=7mYK1^-6Pt>Zu9&6R@nqHAsdgn5)oYg^7VN zIXIh=w^`$ZlExvehdxg<$@)^Zn+TiW@y07GP*|Yy){;Sa8=@YMABF#BZB|L5@@|DO zUT|>dY=>z|nm)9nOb;VLs%J@1Jm~Gs{m4!1Yh2pV?qR{W=&9sga!XpaY%k}9)m|(~ zPdkN_X-o{)WS(Or)tvUIs%#NdvYe-xO}t=b!d_k_NC`o3M}bG(q?j7C0V>bGTh$j# z*0G?hdKN+8K^d?hMZ!@&3jPzN8Qb^)Of^t}s;ikJy<+5SjV)zd-}{c(Mp;$7Kga8= z13g4pilsalqBO=l*hXD#qjFH6PXm(aURP+CMRfY`%6T~d^_!J)CMT{Fhq*&R*(lt< z(8}bFCfW^AqYbl9JcMZ|{lZ^r&EMEVoiuq0Rt>P$xpOjkyR&Ie0U=&CO!MZ_*Sg{Z%mHjJTfR?y>V z;^t%`;*T)ssq(x3SS15T6!;)qirzBIk zd1omG8OFMl!s#^yP`H;ME!SsE2y#M{!d(hu1k|CaiDSl_k*fEsG(s349F-{zu1q)3W+@tem z&h!WYlg8$u`YQ&OZMvB-lDB=LPmAA$D@oWf{i?-y@KTQz1r8Y2^<&hTAX38#0-2K+ z&7!~7ZRB^e{^X)LCr~t=?ST_qi5ys4)Xm+v1`G2c-JC@~TdN{{-aE4@3>;}GkU0j;0M*oG?i6=&yP3)!hc3(( zX(vd3N8O_6YAmaqnXu?*d}EZ(rkgvx}$XcK!F5vIyG z^QuhJ)aO=;s4>mUsnm9#rBz;Lf}N_>NYP@UWV2SR-DQpI%E){%Zaf`q>Q$+>?{yJP z=DF7oO0k@TQJ5tks?7*pK*^Ghae)y*`gU;Mnoz0noK}D#$auHb6qrnY(M-@P#*e%= z{>$c(Z`3@ge!u3O&5qx#CC5z~mkeEy_q11=r|jP?mO)O(WEJW-EojQR#46 zkdz8DpsS-3Mhn4+pwCIVoonyb0R;QX`(YYr+Q69;SpPkA;Oqr>u)nu)GCEA5(Ex*! zr-+aU@GK8~5G}=cyE?b-PQ`M`(%zveij5OWm(d__rfywfx-3#Mw~uSAFN{6(6Hzw{ z?>A>o!-NR7P`yj&2$oZ5e~i9*^>WZEnMIW?`o1JU>gvG**x_0mK^CSHm-gW!zM&Ps zOaLVtXUIc2A`I}wA2CPsmZ`mS`&Mmz;>EyG{Axx0DlYWS%d)|f8++mYtRQoAu&wE)^^tmWVRqT6vzNcUdd-BWpj#^(nU;rA zsnokythHcLA)bPN_z2DWiu z-u%eGN40?w?*zEHad-htnReU3jme(pujUc3?>$%A>oTZe3E1R~!hn;1+tY)W>5vw7 zK-MtHt{%CzX>jI!_?@i;NZ6H1O5rrB*%huh?bFY<-8*GbqdPGFSsaIeHcClWak_MA z=NGbFzOt|}H`na5X_IfSzi$%;WMzOqx@%JqdbBf2@$*LncGVI8*!q+`Kqa5Zj$}buzMQZf2f;Sgtr)_fUIG4jesC6K^%DBnOH+gn zqK-Kni~Nb*z$k>EfLq`mqxlYCEhW=oHoA4v43tizf`+5gG&KG*Dwx)_b>YTPk7vcmZ&{(W2@`FlR#4P3Ry|OoZz6 z@(%14!Ehlw_wY4P)0v@^qZ5>%9JAF%W(7hbs1Be%=wb%?GwikoT{utQPl+&;#*_^k zOLb3mUd|iZvwbsehSqSzCeeL8j~&pcmg&Ncc;9H%iYNpXI7$!Toqv83?^2MY6UllK zLwf%ato@E6T?sNMP@R#94JJglr3Tn7)jBntl>~d1KoPldO`21!L|S-JQWgh=88W^q zx+q3}cCPASeg`x(kn56k1%&m_H950Yfs52S22kG*+h}tP|odbj3PO=cNiJ*Df({C-dUYWedhw zI1ULQsbNbTUAQh0BL5jU1rn-w1N8cp1DHV4s-P?zoh(S_`5axRU+S^)>^y9+&YS_v zC}H^fM1)$hhru~~@+O(<P$jF9Cm~l2KUn0_Q8g*E z;uTSj1Oo0?!ai7NaYsTAhuDX|BKo#8`7+?S#A8vx>;>{ zkn!7-$!4Rr6KEJtQhnDnAe4CBUHyVvQkgS#97%ZBAYdTwR(o&eCx~x+m?xHLS@koZS72yOv{hfg@tk#)V z;#f5NkAo#03B@=wuNbqkjFF#3sq{glFj29&RX!#|d7V0N2t{qG%%>P5OOd%%9wtTc z9i1>yg?W^GH1)zOTs}j&d6Yu5Lh)UXuu(^GU7&@P8D@({u2Iu#9j*zQyiY=kUXZj*87ArZ~Gr;`D6pF0^15ZauIHV$P=`$agjT9x1OmZB3NjQsD z|IB%Ve5W`Ho_qtarfCNl4{a*$iM7X>xU$&u7~DNGmX3wD;%*5j%K!Ys`D^bn`~<~^EMq6h(yDb* zDyZ{uEHmqRt4tgxDi!DYszp=t#7jjZ4aX|QYP^T-*UCDSG#&|vp< zp9A{UDstxrtEOfP?xylO#3(hRKo|N{G=x;usNy93NW+Q-=4IxTK!V@D7S5v=&ie|| zMD9!HezzlVr`4w;{e1Sr{4Z9uwNIw{cZDyTM|R2BmifegE`is zt+V`SaQpzNE=YhV`yM=a6s`E^r#a^eIARe z4}*{3*9yhS%9@qk86fb&+@eg8i+RC3H<hjFsM+KtphAv%v}+ zBy{!Jzym{W+lU!c9&J_2noFcw7rTz>R;X0S_?AqMN5hUF}?^qT76Z&$8lR!yzLY#dQ<^|vQg z6Q)f&Dm`RXWoWkS)5V+ntYA4(@SlJ6e>n5eKPh{x1C=?Iktb;;=7tBb(8_2g#)X@! z9xzi$LuI5UpM2pmC=6T;o4b_SUhsd`b3avWkA8aee}>*W_N3d}@+e(@huDxt4sN`@ zHMkyc(@SJ!1l?l!w+$uU4w1Ix{aJ)VQcO7{YqCFw@SZp9(Uvx^^ASGIb21`GtX6zG zr#)T?aX*cd!!16d(2*N2<@WwTm?17*@GTz82^NX)2)+_lIZJMUda&Zs&D%dT;s!NDrp8J+I}vy18;=`{+Oqm%ciahmxxj})EaO-h-gk!Ew|&56r{_ah>?^l0xoS7OcdM$fK3l6zp5e z8jKzn&DM{4KfM=ZnjZFx_qZp|NRv-`vrqbZAH6w;xCS2}jU6@W3o?!iG8*{0_bK5^ z9h>8h(VEYp`wM2XPv-hB{<-_ahA%*EIE&qTd5Dxy#@1ihaia+ZQn!cdj87K>dUHeL zH0`{?iOGbUQ4!y=1Rh1a2d)v%`8`S>@CfS!gidJ=@Fb38PhAVtMwUrpg$;IMFv|jd zG||}~u_kZGUebg?I$BQs-9g|FVc=R7+`3V4cw(oNM-t&*vg!rzQ?FkuS;@dAyh-znS|*c6PW( zE^Nkd{q5pjg2fLs)s422NJa>l>z51*Y``o_-!0YTw7%ufirbdeij*9xny@O9HfDPi zGEw7vh~8Uahc z(Hj)3uMcD^&ae}8EpL%LM~}`n!5$&S+YJ59LMb^M(yv5}%H#LaPG4LnN}VG&Vzx-1 zlM6@xYz&*5IW$4`n{nXh0Fv}O-wrQ}nTLyYP<}y4IQQXMngc2&9jjn0S6NW@)fIk{ zKv>d)C%Nezj4FS8SB{zMGi2l}G*hPWn;Sq0n?pBZHcg+S3rF{s8az!A8GCoxKK!+d z16xZ7K=XwH8;2kd+N;KqiwSrH;1vyQfglgqyTZXQ;D_R8Yv%_8m;~UJ0BlOY54x*` zO%DdB0^pSadKO97i2>vsm=l>&T@kPC3j1N)o57aE{@ z1`rBfA9xoG+l~Rq6zKNwMI2`ZT=1%epc5K_&v2EM7ZQHhO+qUf;C;!~% z%UkDptL{2ewQ6S8^wgRUYpw3-zWN$Lc-2r}HK31BP#VErOCaw_;0Q#zU%olEy~tpb z;JZJwgnaRQbL{yTL8gIsO>k>bft`RpGC`9GcQt{$`+%z;*${jeaBWFIj)89_;Z?(Y zUx7ZtL6r%2J%PNZfGdz>5qjToXM=rVfL`E!wIa>}p_wcUqLGO_`$Sf-Wkjgi?Z1Vi zQ0DG?;;q~cRqj)u4uSt78}d(Jz{}(f^M8=Z-~DJHXCnype=w1={UU;%P7Vu5$X6_C-7Sp3%8cY; zEAyvKS3}RNJlp-KAZPm~g`Vz-@PAO56Lv7vFK>7pXuw_4h!B5b;a*w;DfNa^;2tl< zXO?>M2`~MkMOyMfk^9`q_qyeEdj=lVwcN*ylot_c!`xJy#N4cm=`-y+>&_a|?Ks2y z$RUT|r1r<$)JGcJRgU<*ZoM9MJ3EE*X@jWFsvYcU~2WfPSyg+YP{^D~>*H zjXL>JhkfD=gUo9d(fAFroOes;eHYQVO-|sw7WPqx>$nR>(mf|^;tfUMJuBUj$B!(% z%sALw_N()U_pJq~{-GjAXxLHxJJzpT z@uY$e)xXOnM@Kk{0;lts0Zd*mrEX0ydf3RNbPcnMQ4qg%y855ux zy&B~A+kXQRZx+aRMijbxN)vf?b3JwT#yo$Ez5+ia@)G8Mh$9_^2#tO00w(ciQ@MK? z-(}^}yjFWJ{rV;U_2D-BnqquU3|%V`p2SBYd0@Y8y(r7`&lWy zAQe11a>TQQ9943|`-}ZToU1fySV6uR7j5_;OukrWDl0M&?g7w0#Si3PwI%y0?7rM+ zJ^jF!WiM?1>7(HGW{2w>{bwBeKmC>e8SnegxD>pu%n-r?0fsf!eFDX^%)cm{<1l@zRGLP;?8Haj@??x!9eDLwZ}!9rt&qu;>X~ro z$rB;Y;^TwQX!30xq@nkUd{-YS)SH@!{ZBZ#&Ym>ZZNx4U(y(nLYIo6> zQ*MpLQ*M*c?YRB|7bc9Zg5!c`E4jyQG~pZ0{L?IC;hT>9Q!g3RuA7Mb=MTUfXSwhV zIYAdjICd8X+#IL6>tpm$zRRTNqc?f@c8t*6dmXtuFOu*Lx7?#QMfmoN(42=^{3+f- zzDs1x_JnZMHf8WB9woqiRV-$nhW3fF(8l)Ln%4&QpucerQ$ zxmxlwj&AO^srH&3J>xgzuX!05Nc+O_x0AJ*HlrM#?>5-`6efW{H`>MAYl*8AP$a9)_5T=E(BNf7ZV?5z-gyqL{;6AunU`#GCW zlA=@BXry)#UZJerus(Ne-{PWqapw$P4I^5;Q%k?Tu~GvM3qQnS6-|pT4N%aSPrDpl zwkj}S-Rkrj5#?!DXcul*YL{9k*`m2hzK;DT<|5%D?jq??jMNpcLDXuW;2yM!v z`_`~yM&a1g`l7nex3q@O;?CCf^wIL=m9@*sy!K~Zv)R)6YN_~z4R_Nr1<_9t7W)4y zg`r|deY{{h)0Z6?U0xX9?NiT;564}sH&d`e?I?osr(1xbvT9W@{D-=bT%tGv*~UUqNat9rinyMQqgJWE zh*w>83bqM_P(3q#>t+i|Z8NEkA(DS*t?R{Fn}@TS8dwg5q*A6(g|$Jv;*i!HPK3z} zHFpNS`xdkt9JDL4u7otWpVrk;jIc>xV0IVV)|S@x!(;??#~K-3(VLN26!)R#LZ)St zfn!BKDSoV8&xAb8jSy*H97Udgv9~HqIoy7w%+)6FL4v|E|CXRcF?lE}jzk`gUpxD} z87o|DLf=+C+cpA6w(lG@_Pa=`RAc0U^r9O;sXq9qiE%0EW+WM`f8@6pjD{}8v?-9+ z1?qW+H&cu1g37#~)ea7Yd?49~Pr^+YHj}!PU0)9q+KL<`6sC|>tghW;P|7giKdMiL zN;#YBgl_+b@*-Fo%t&7aJNBVfH>E{($T?MPMpnfCX}MhOc=9N2U=vE)>Q~G4w}@{N z^VTq6&snPo?YZ2Ud=t{u-9W{#_#t>kKFD~Dzd}f)q5W)0tNKjhYE{8*u7y$cXmdmY z<%lC)Km@Ooxfpgs4tfxw^9nAgG2uE02?k_ELDS`exsjl}2%7U(Tdfv41*f3^@#zFgUh1H)f?j;+J+Z@MUo;u$Wfw62F6QO42LwLdQU8(t8T8 z{fr)7_{uwMm&gI#{JZGTLuN)5UWB1%t9RRJgd6K&0_c3N5=`s#l!>fMiO4t*dmeu3 z=g}tpZ6I-QPGb6+oF}&Z`5EDIg1CC({+tj4q_14E5E1s`@Wxkzj>1%nQFOi@#V4i{ z>u9>lYUQIFBg9N1Z5zO89I=aAl1>UIgiyAYe##N@8)eQ)<4Mu(;#nGZ{!yc)gEq1M zXj*C@$=TRZcbyUu#xOfZ47yf8Gx+Kg41vkk#i zj`}@Tnm=AV55Z|T0hbVxs1M|fNNET#5E06*I|z{;=CsqgxI%Q6mbppGP~c|#i?ST2 z7inyW6ewMUdyARIn*0HkxD}bh_ zxz|pUSraBoG6+i#^eE3z0&g1&ZFM>wgXs`{kq9UHq&MhXsaZi?_Pu=BJ4u02{e-YZ>NCB0{8l)Ra@{)c+quI&xh*`M`LLr=>?5v^V(3airGjk^Rb zoV}|gG2lk-W%{B>Uiu@Nq^Bc($BTshU-RM3M#9c7$+r8Rij}C-S9|YH69qj7>vuhG zSlOEDckbM0<469yXQM~GJlgS7VgXvi$M{(clgG^22rO>eM-r?qnNxKUT1YQ55nAXj z-U15&Uc!QB7_Z+22#{WCDV=AAnj~Is614u?mgwMEfKhe+U`YGm-veM+7>3~dEKm#r zu~U5GZ{zlQohQj3a9vnE6Ygn-Zhgvel`^$U07}SaQa!J-gEe~UG$eNyrXLK*J$?XI#bkyi!yh4*=A4vPqVZ6h58Ncty zPTi6QbMjAE!gvRoYDn)+*gWC~b$&aGeUR*9hxG_t#=lrNP7&X+vTcyvwWKCj0luo& zGy%4J`!{yZV*3QPR?_@UUvPKu$OM9(aA7{8 zp44IAe4cn=-$I_;VKKzfVjmdAM-a&0)Cua#F7dPh0sc~CmPmIJYf=nm4hUn1lt&`* zV=CiP07__Q#xbV8fAN(%wHjh9zgPeELkoGf#Qz;`$uVT;R*Od)^tgrBjqpR$s6PXXMjBf zj*sNCWA%u4q!s6G;PsZt#zdHVNh+|jsGKL5*59n8|3q@XHVHcuWb)>w|0K6+*XbQ# z!bQBL$3E9zB7Q6%>4{U>K4AKy9NsZ|&1u}MTlNwE0{!25zQ#ChUGE1)zf16c)$@%1 zRnK>&Zup>#ppC@c3gbtr)f~Yz3q}e+A`L^@l`!2&sINsFX&E*3vk z_FRc_x13uy$qRCWx5$-k@iCH3=kPK*SyH5lkrp!)sSlM&qiL2nZ<%eTX1BLWj9$8% zSy&XGb+QCNIH*%-F*!J|kJhBFZ*~UFuBA1Um>`cZoEtU9WYAU^^D{a&YE-nDwg#+6 zjFSwY>Plhkb?O(L%*m21M?{o3`-9L2vg*N z&aiNrjmzmo4e){!^~~RJn_*p4=PAQY`9eUN#TOG8fYb(b6wTu{NSnJf9tuCE}GL|ehE<+X3K=f!i;fH(AO&kr~>6E7`HAP;i zEH;U~#xP6cpcbYkW|{QkKaDta<1OoU7vLGfR8p=~=w*r2W9~?0)M{a1DyJ+gl zl9b8e5FZ(P>aH8P!9o4;z;%03vQkOROig>72=9%3uo!o`9xbxY4PEj9o_|p!1U&*J zZutd>DoweF>M(~iAtD`WUF-=+{hL8n69v>4I$_MB#4OeG^kSm8h#y~6AzqS{C(%q5 zT&4H)jZPKv1$a+ZQ^5WSa{@uL)}&G#`V-0oc8l^nnQ|7#OAi>Bm?&xmv`d9Ih?#L% z_IE6?hKpEK2%>7FnlyrJ`f0+$x#zZ5qU~Pc=Y@7g6z9*}JXNH)tBYL>N07j*j( zoq1+O%IR=)s8Mz#xx+o(&557N7!*8C7Y`_PEsa0j8yAE_+{$=#ov~!4Z?s1Ii@lMl zkgcxapsu;q;Fnysm8fuTQ>@aaO|r@B;<`SPA5ax6pkB)o8FE^0UsjeT6kh1~uMHvVLa!2{Gf#xG6d#e2cOB*4P#@%;p5zgI zl~121*eOq%Y~JNLp?xrPL9wqh46&ZP6t5v5@1aeRl4XqI*c3j&a`E7cCknM)`KlEY zZmO{jb~%x{a?P}Ufz~=H7lO~ZE(6=bT46opOxcnpvY~t&9a*M@sV+7ZvOy)esT7=_UTbTEJi!}Ub$%_3{)nT}o>k~}^d2xYr zxcIMmgc{|t;jDF0Xr#*Zr3C>SA%+hB@fle}FzZSvxutv|B!xCU>$xRZRp5iBJ_^p2 zR5!6_JF0)4W)WqLBxv~51i>@7$fA_8UV{SoEWR2=GDXoiT#3ac)E;iwYaXuut(nieO7prCP zr!WZ-Uwq(ngjudxRuCrOMc7%0S^ryUjsBFT9|_7Ud*9)`dm3<>o0;1zZTQ`gmqZm1 z9{JzhMD7^*^BKT*?71qSj@YLf!0zCu8^Gyc=D$w!UIJnr8Iu!D4$WReJyoycI)(*S zi0peJ4{6vl`3&-eTq5-A$>uUn#U06ZH_+P23x;B|dyBf$=0{W7`l!yCe*T`C!GD*Qvecd-C%T=d2TY^;r1O zhc+B8owO~zaA=yUr}L9fp@kZbv6K6tkJD;%gLne%>(UBBVZ}$qt0J|L(Ze>>{R>V0 zCcTU5&?8Rv)eaS;#XYC`<=`)B@JMzM^wF>_-AUmUQ`AWy@2$}d0zN&_crr*|8)A1$ zH-|07lh;Vw*bekD!V4?z0&aG2i*k5Uc(b^+U--n;j7obT>I=aO)VA=uwYlNmLI&;; z@cfb6XYrBk$SabN6_4NuxRgoCzAZ9o33%~33*qX+Anb!{qu2qgd{W>(OkWS|e*LyX z-R5s{IJMOeCqY0uh!MPXQNG08ba}gVTR1^tdq59x(~DVf*sxhlqXDUh5YrH_{b++OIPDT1XaY5*{PUTgjn(J5rpLkqU`{<_C zez+u)a9pNye8=I)F6W+2&ih=+dpZd!hk-va$1TZccN~T12rB=hzv6>fMfxR?E`s<> zE9O>4lkE&e8hOtHe{V(8l_Abh;6tPrR^KPcAcP+a;wY!>K5^#gPyNJ5mDU&N(4>KGJ_~KIQG#jf3vXoTf1{c6c}-$TZK`xExPTrllp}cJ?r0dYL+Ty>3d>(w|UX z^c5dDkV*4+>ak-++*7f)xt}}E()H948R%)&QYEO>4u}|5!>m!XS5h`;)9v~HnGl#N zB4@g($IQNi8!e89TCm*d>XXJXJ8Kj(DvnSdMM3|Spu`sMh76;1IR01(fxXs4yLx>O zE&P+{quGHM1xI<+-(jU%2DXmoFN|+pI~y1`WG@Fm_V(Mpr-3QfqKQ>agO&CR1M8?H zwSz1R77){7Y76}Y=xWx{MR0gqsvPlh9^_aZ5%s?^L^T@1SG6|wlTN}#L>MEyiNzaZ zPJt^Z4If45EeA&q_2N!Vzj3wAQdtBcy*FFJzgadW3bUeeV_Hlyrv5?Gv?0N806B(4 zUv)fRk!TR2yYde@hr*-L+IsU#^BdLfaks)`g6$j--ay!(LP4>jNk!r$P5>=Ty(Wmz z?_V)dtD6(>DZKo~*P&2Fp;|B_&49W{j!L7G;iQ7Gu8&Kso1D_F>t)#9ms8DwY#@@= z#9juLk2JItQKUtoLGKS70T=S*PnVbffK^Wotx_X&nWl46x3kKlerg+=7ry;B8Y)Shb3GRC7qekA-coPytc!f zQR_nIViD%Alf6}Q=Z#gvhW%A+MECk=e0_$NQYvMVAopVy2b&KTr3@p+bfZ6`K%Lw3 zqY!mvs=V>eBc4KWRxzh(IGFL24A*2*>O<9zse!;7F`SG)crPOKno89e^Uxk@jKOf4bn-c5jaDKr!VjC zeb4EF3Td5ZOv|pKY^`DdlL#)u znG~T(J2jbBAFIsYP8`^j%(rwgT7eEe%XSIrwJ#vAp&Gg>nCT1rxe*;QKd+wXF8eZ- zWJKEL>tRl`t$Do1=_%p7OqMc?f4(1;_kQwUaA8bE`bwPE+2bjJf%6svOcm!?gc%Ii zN)fv7_A0f$jVx#Q=i>&_lX&hW8&eM!^*(+-4Nftix~_IB7R-A=e!Qi9;z&~NVBj=M^D4% z5U_Xe&7SV%6`4Gt?ZQQ^IbvR7&%@_O#XCbV_GqqNi|Xz z4wwv+{2& zFlCK(hP8@sJTO%#%;L)+y+U1&D$L^V2y1LG-66cT=+?EP4Wm`x6y49Ex+c4u`FR~Y$M%7db(&pc2YXaILk4@)xrFv9 z(QioZY|w9r@022VN$;2=o)cc$hjLK|H@XDS9{-r7~7yZRxPuAMup&};f>U$>5Wyo3sK-ED~T+|`)tI@q!c*W}%6 z#5Bu`c)ykt*WB_m>9GiLnfJ+v{o_+(EL6V6gT{L@2#b*TB` zx}^le3WD}X>A1JJg@r=z%SYIs>>qLt;RCF}5;Lxd7ucv<`cEUednG!@qK}@j|5xAde}dzd{OJ2H z?EkC2XZ!E^K20MOcL>|}`PkUX05@Ul(wKG5wdcYb`KD#jab>bmV`1y8JbNuH<^DSC z7=SPHh9oc&LmVVoYT=j<#_XEy`2R*RSx{gdbmo7RWutn3q$KO0`}*?1i;ZWa$ac0`7l zQ0WX398ACcT^p3#h$B3ahT~Y5OtxaddBg))kh~|#UaF|n6Q7I$RT5!y0z06KGbhh<)Lht^e{!hR0kD88c#=GDVYKprf4fmFWZ@}nH09TdEa>3G(_;IkQ# z&}y+AsbNNk5F~G0L?UTm(CxpmdNx?hD*WI{=hTjP2hu$q+W-&I=O8O&hP07>;Zzhh z%;M=Pl2CC>X8m`24FyTN>UQzvKjLQRT%$TA=jHsK9OTAzGQFPl;21e4gH+bRaZj#R zcUVkBP9jE$sP(e3C=j}W1hYkfZvr%vGZO-)R;uw#+UHH=P`kh^RBtvfN0)+Z#Ml6} ztf1JlY#15zAW8WW0tq-Gb_GW$23!_*O~kk){JGyhprKgBR-Vx(62D!$6}fSKC8|6G zn`y~S^j_b_V@)a3l)!#BqMVCudl{0I*QkT3ejJ2+YaWzemC_GU4~z33dRp^x-mvdB0n6?FgkZ=+8I# zSxXRP=rgV4W_@kQ#mWb%lX^Yn}8)%Zb=R1?b| z76QNq$Lo5Bwt@x_63}7!&;__8vS0sL1V$2NE0svZ%STPPBxZ~n2QKE-hw{!!ZHs6) zsezEPw=@;LH_XcZ*-GYT6gMp)HEqxPmHg7?-j60C3`5nFG{)7_Y`0EF5Z{TesT5Es zs47A-LG3ZJ2E`v=NM;tZ3}w*CrWQ?IRjyc0>Y`y|od#;|_7{U@RM41nSwy}nT6x*@ zFo6d0UUYW9T-Q^tK^)-XvNli2hqLqh@HV{FLK3^U1?)Ik0I?;p*O*sQ^)HCpFW!5a zHEFFRlQ46`CZONWZhxa22Y|k&p!cNozI)S8LyV=MN@G_6ErDXkw29+N*sTMBP}_G! zw7q>w0Rk?iQpsWo<IzJ&$S6~zy z|Ao*ysoCG#P^)(UxC2ER5xbN*Ac(&7^Sr6lp%3aeBL*~Fk!hAs|1n@WAAe~$G0^c( zrpkr*R3SOoxgz%=b@~z_NeLB_$VZ70WDqIsdh*?O>d=n4b1a)emcu9+*ri~T;N54) z5B##IY1pajE!&T`_0`LlkJ~EZm1u3cZYR?-db`n#RLrWbj}Kc0*hjiV@B3}Y*|v4p zplYDEmr{8xzjE(l#g!FO*|)a5kb*}TLGHwEGff_lA{(rBs02d#BwoOL4IDRm(GF%iQqc~!J8rh> zL+-)cFRxNiClF}f`CB1W?@B>CWcRa}w61w zFGay7xwn*8^J%X7QIaNkk1_}IYo&WNO?wWqOFfb2T;*?7%36F%&(|wFRsv@O?@fDC zrF#U8d(@@p1|mI0^0U3q zm#Okr`Q zx`1`+)t^K@4$fSpZ2D0wPN!V;;kv-TnOGhPT#ezj{N{E3dRq_m_;qXcEAvf-dxnLMzL1Sb>R_=iahJQlzZ`CZ2Q%y3w}q%@LGC4O9oZz|k-P~1xdGev3Jw{O!t^NLBawOGAP?#LD zoT8^jGYTXEB59->uy%kQK`wDHEGE6-9nhr%6{oziQhPhc9nZH5&HL$x&ocCf$nVW2 zY3UhJtsd~o1gi4Qo!U0bD58?DwQJ1XMa`BXT6v5flIJa%SHZ4Lli?5BVI5hDmd5SH zsV8c=I^-p9N|U6usw>u2YB@Ak5}Ts)&$9%oikpuZsHSFk{@x@!7A&>- zTM6Uo9JDeFHaGg>x8zzzU+<1SU}?nHgPZ<>_fNVweOZPSZ1@sm{Mgno8yn>Twx8R9 ziv>Teb_qK}jit)lL#C(4iIWr4D60CYly?E0!v@>Lg^+_GMC)MDQX}E!cR9Pz>N(u6 zf-y{gt%v?gkSykY@+CH?7MOH-rGI|SRo1K?`o^NhHnw{Eb$bbtCgs?}rv5oYA*Rp` zt1Q8iDfA2AE5o*41DMmB!?uTX#_ds92aDjJy)5AtC33ivQTChH7D{myMxhP7BhhA& zv}BVp*|3Z5-jEqQun@$#3Z2@&tjQG0@@!(ZaY9i!&p@kg-5;L{Rgx^CKqxs-UF>rI1l} z*n3PuV9=cqXQVnL^Hg8Muj^o5Q`s5I);)msMbGomeS zQfu4`EHYCkHxKD`C#;s)dd$x$Ihs)7gg9%Y@_fh-0^2>*$ATS1Lg9Que}u%O@$u;H* z>$X0%5IGW8)Aq`70Cjj_-QD*Bavzytf>kogy2&;2qHoQKB^)v2X{i#5YJfbe$&skz zO64usq;y?b%k8AT>PB?QjfAgFVlR4V;$x4*N{uE=#1n+6mJI182~EeD-H&GvbA&EY z@1zkw$|>(JM9)aM`Wy{Fz7*IVpg&Y`*`C3Rr}SYMgXi$%I2E0zk!7Ujz^Ba`|8z&=mx zYjc2A=la@Z zWFa{h%gyd!nBYF2>o6bW3aV(hEGnzCqTRkw(F;(feJ)#3xCT6`CvdKbG0BywNE_S3 z`}5=DqvP}Vo5TEgj>e9vMwc#}2L?-JmNoIcou;1N2a7r_xc8FVf+E+)o@}9O+Q_6cjsyua`>>DHY*kXbYm?=D7F9Y*We zW3)(CFaw?(QOa-w#M0leSlo{tgxje6vcgCob&4zq6^dOY-og#tuk*@jd?D_gDwgN^ zEjuJt?_YF*4|fF#-REM_j4=u!#$*Oxy*p)BB#_S&f+&YFQf+l46c)Y`ZjtJwP%9WK z(&}#qIn`^s*!WpZVGW!GaV;;L1%%#o1PZW70iz=7)(2%(%6xGyxiyLzit4R!ZKcwo z)|*vz9-Q!2Pt2GxU5IkydLBsgV;gz+H{bVM+rES3q*XL=xG@ zHptst(NH*30cn+9@17@9P>K7)D%!<7;O(on-cP$R?&m4B0AVzv#PTRQ`9^eqUM|?J zj2jHll)$-d(&xJ{hksG055p1`f*BR zJ_$ySrNukvc4E*fBt|+f!`odZ4F9p54mzU5BGWlKA*Cf*am7Fc1SOPZSDB)C=zq9vlT&I{R;^(M#Yn9SU%Px7B8jM z!EW&Fvr1^1hk&(?RsqF>Fi^}BQ>zLa*5CNVAQO34p(yWjD>HQeFV8`O{V6}p$ZqI8 zQWrTKA(9boc!g@@;h-!-c4(?eKM;nLt$4_$$=?2YUDU!w%CrVC#tLnXcGG=|3NIU) z%_!`MsO{hgzv8p5;s7RU+CdLfe0{7ig)jM7wl*nT2_wiMM7H;97y3o4u$c>3cPo_< zjYY#rxAg*Anq1wXFv+YCMi^{+VJ4HMW{`Za4Y<$F9h0eB-+aFL!h|&lNWb}qdx1s8 zh>T`iBTJp3(Ohg2Eo|OoF_s%wh(ww3{cP5 z6m{=fq8mJ1Q07j}UFEI@Q#Oic#W0M&4NmU}gl(Z6;H7o=1T1Ivh2hqWsq9v6Hv^0C z?-@wX8WjbF{}A{KnGCI2$tAj{`hkb9Odi(N8T(fC9ARz)_7sR0UjchACzCo*yFvlv zX#jQ>XuD*=1m8*I-8IWFr%j|w4BHQvQ-<; z&y%PcAHFd#0+WwM45sm$fBE$FDUoijYnV5b!>&5a!|&-oPgP&82$x~g7*XquE`x{| zU9tnVRU3h%Tc)S23Xe|7Yb;-f-QGMr$T!|q+s*bn@g-oo1-V57747u`%>mVBy){Y= z^6M7`-#HYFPYtAk%o88=vmFJX@`e5d0r5)@WJgRDSIy4hhZ80j1K!W#mnw({FEUbe zb;4(v?rhE@kUR}d?!6ft`R5e1^OeSXii6$b5i*m>`V{gK!uzNJ`Y{6fB1fDfFcLXO zuu|F6K7?}|sNChk&QrFh^O_}XrhOgCC}Uxg4dyOVAlmn|k$%zh;-nl^EqPiw+|xA_ z!)1b-ZZSOPxJ{QXaq55k%4(P9ba2{j%5{Tx;Fc0ua9eMOYHjL>^MTmLk)bo1J%v9- zNkH~`arDWL_uiKq{W%MO4Y-}lRsM2~y$ut`1l~&*9}TEYo4fzG@ma~G=ABAyj`X`v ztJd5>4fuG7B-|5r)Ee>Z_Q^Zo+Qs3(f7`RA7`OY=qkA|AT&@`NJtnExJ!U6BymbWlDMD7{*zhR z&Fy2f^B;uUvFCOCZj)2rs+I=^hVvDaG-W(@L|=H2R?D{Y4L1xwA{x<_$Mb%5mxuqt zlSy_31Fa&R+9#o_2HhVGVf3;F1z{(U~Cft4)h55kg2IkpC>yBWO1r zJ3u_=u*Zt#IWJ;e1UdK*g~d**Qi`WZxKFy3s;1L}=j<-cb0azu!*>fyKvX~oY$xJA zt{rJ)dc*WD|G84bXhz4F0?>d{0vwcuQ-?ZDI&H1%ovGXwjmEoX(-*Su`x9JLF$Fy# z#5pEnOg30|1s45aTRVuRJD@svP-!sUOcM|BNXMDtwow}8tb~@&^S}jM6~^q>To6Es zkx(S~MKpQ%R*fELJYQPa8L!7wm!%odD+!R3emE9|%l*@U!x_zJY)U$@{5SL#?@*bU z^X(B^gDIt&yLQJXJSNkHJHiiLr7X?8thkMl+XZtT%c&8RM!Kri8r3;eIlI=UTK}%A zr9zk}##{vYQ=4I-#8D9Fq0(!isSO?gEII%uL}wwlfl$2s8Z0*O3jnYiP26x;bNMiU zJk@g6dR{$Q=c%dS@up!F`JyH}7XrlKplN^&D>CdRr3Vxkg+)s7-8llY%j65kt|`3N z3Bxfda3O4a)r>iJ8Rtk~>piOa_V_pxs#OgxU(YGMsqASh$!LS2T#^VT1W`YH6;TZ_ z#0`A$Se-GoqIEfW$lwSST-SQYh(9=rZ+R^;ewkw{SX3*IwNq&>jceQ=6Xc8e$4kqi zjcHw)i`P8WVu>v=Z}ld;HK}_B1S0~0OLK9Q&r^H_JbX?QdHkTVv@;YzqEzGCYvySJ z#zu+kqK7_Gne`D|K0_DVIVa|(I%ko)JrtbaD%A3(DZJD>26c(#p`ySn#ErzoQeC+o z5sM+5;#${wSrV^eZokNPV&q}Q4~?yMcPP5C^naX#(lDz)Yz3WtoAlIb=fx>~iL^5j z#_2*NlVS?q3(Ub&I(_P9so9Z4D%i~#Z=H>k; z)ke;#>wg?bdoLSlL;e7z*wfqWweAQQb9Qi@x|};5f#+WiX=uf|PBUmGDN&FHr;P=- zNIbZ$RBOXr_#NVJ1q43@;~H$8hX>O#4_EXdhAkQvKyyuY`$Kg>Yh{GkRraVSA#2__ z2k;nn*C--uIjXHbO!H+(oQAHx3lwct!!HjlosIWI;_TuVJGL<`RHx-NcwBpb@sh_zpb`vkKCx2nYM*q3kyB5$Dxb`ZOlxKuW z4i!qQ*yH{sIhX)V@-)7t-Ru6ti6_5NYlKV-E?Yzxi5J(Jf~hO7HOQ} zMhYUHDmk;1vJ^x?RGhBmk(j~SA*3gM&`d$pQ3A0-h%u`avvdabMyKWT>C{9^lol&P zi%u3$XJ=h3?FQ4rOCO>J)a8^NIDu=J*pm1xYYD=l`Tme!g z;npnBLhOaAzX{+8&z=68+kGV17Ec^O-G@wkfHwEsUH+-Gtl(@Iwd@UfJ&Sa2!qg?W z(PNZ@OL88eYQQ8RSVy?kFR&(WE2?md_}{XF*c+`RYuuxOfQ83K>n#!sVh{GJMi`d@PT-x{dfIy zc>NQ+%pFsSHKBZGT})G8{)TExVBTlrhmoS@6Ku~2@PWFgjO-np@)h6t_!^L!IU(*o z-rg9+^nun-Ddvj0mjvJnzEuHmMc+~&dq>5zrCYDeB;&ZliSyP!s>kCuKXSzLxB+EB zier>Wz>}?$Qu}q2cDWP8T3f(4sgOWPYGC z`!KS-Q3A7MZ1M{$a)n;r0pJOGHND_u?zJv{gXVDo_o&^cVN>`F-LJFY0lp^%;0mq% zIot@+hIEe?X5A$ePP{#&&K{j|$p?*k92hcD;fti{lFd&*b0?%5XLv!|$s?5u#6 zs4K*J4dag6Cszfgy;JODxqMr)+&dtzH71Y@@hdKHXTRuqA+4##&G*a9=;7=4=fe2; zS6JbU`kP5Sj|ss$;@Q2=9XCS4E$Z7Nl|OndXG@#Lm1)u^ zOq<7j4he8@<}te;9H=uTO`~TC(9{S+#Wpdj5A5b$NL(6y}Zbpe?5%BBs@0i^)`+<6wK}UnSqpeIdm0(0+{lCTo^C&)T z2{f&$Fglr%61*@9%Ci~Lg*C^xa_Hfwz&dZt0U{6D5gu(@-0ZAKjZeF68q_9hegOiq zK71TvMLeSN?e`%`Py<^w>@pzLx7%*KvdvUWx6e$+{tac8=;#tgc)w|kRFsc>%ru%l z;k#P4j1)DxUMNCecs#`Zw|uhV=0z6yz+9jhjkitjAZa>BW14rGosqE0(Or zr_J#goe8aCiWD-SQHspSV3u2UKiL{RcBJdchQikbTexUKYP*_}XG^mc$A);U`~N`L zg|EJLCL|^8Wq$!?`k{u1#lxh)9yRmsL*(kK=OPQJQQXe5A;zSgMJ$egAy1r=W&{6F zEX^Tf3zJ@5Vw#4vZik`x#WTodCNBEpw};rZ$#7VY2e12qMVeL#Khu+#9{-XfFVsdB z;u5nMPYPcIqYtRUpAM8yhMpr~8{-#j*da56LrCg$jvf_aOb;yl1B5fo_%D#sE?(Hd zf+zu}iE$e$7;KWrMut!MNS@#R&q6u_z9Mu4DIsbGLpul>5FrlbQ5#f>bm2I={5r+l zqIcioVI!lIaH0V%;wuW_m*Q|;Ls4h5Y_R3?rBfKYD=1;G7{lKHZi5m#6W|PtTbfI3 zaS+%*M|ln{|B4U}Y_cBicnPC9Zhi^PcdjZNtV{8pW1qd=j_=X#-5u9kuayFcpC=Z3wTJ-NuK%0q3T zZ1_*K+O=(0X;)u+Urs;M-NQ{f8N3~AC6Zcqs5F80=d?xFX$yEj@e>KSy16!SK8Di-T4ecpBQPqtH=PGf&(d?_HRalwvrCjGYdP zy(!w@rW#%V7xO?!QX~mim@HzRY*SJc$ulm`nZ)a#k+BEA63nsvHN4!!KgF;6{e&qDvQpG^j>32S$R=L#^l&a}`7HN|`CLw#5#N@CDc9Y$#X+18LRF3EkQ7 z>d|QP!XZ&iC$8arac1vqy~rj1o^Q`bM(CK4>9Pf**UpF_&FrHwU|6#IIOtMI=y>3A zpT(s+)U|+92gM#WIvJ>FP@()|ZJ+KnUvV=fuZ|$?DxRK$oTS*lisACsVTvr#-$c&U z)|v`>cnyK7P};%B_M~n*_Z$F`7Fo_@nxn&j%`FMr24b@lX|cELFF#v>0m6UGytdUpjK>XgnWFn%lB0|8}aps zP|RO=z^FcZd)zV`InWvGBabvi3SPnyA5mgE(~_W_A=^B{W#LH5p*SFMDlZuj7_LjH z*TTG8b6K4ZNz(fNHFoCVP~wWl4-bP*JF$5)K#hWnx(rRdjzXIe%2& zyf&Bp6}@$1&33hsP9NO6!~*&t8=n^heREMK zcajlmw4F&T)35$&w3_D}ldW{$S4cqI)EXsi{1w?V@xg5I!mk-k34;p_*zq%-3iR`k z0hmD*`i6Ctbx$a-sKLe53bRf^j7Q5g^YmkG;i<-NUzs>cu0O>-sE&Kmi7qgXW#iX< z7Yo!N%N@q$Juz@|%!5yK6S9#^Y7fm?bgDTzlK3VRq&crruKM1DK2o1FX1b(J8UqoB zQkcrQ6%U$bWY1#btZjT`-XtOvEP8Hc#3arL3AHHMx2>EZb&bMmmzKPrx1Q`4ai%kb zv!AdFxGR*?>+;t9TK=#tlAR+u(8&FGS)gN^s3zAl1zsOJNBeXcu;RNrz6i&(*-Mwy zpKHIMaGZ|xsVup4F-fREGO9D;f%XjV$Wm5NRzhG!ds|81+r{SV5Ow<0HyJuPp=S6; z`3yGVbpUDmg8<8_^}^Wi<27s_=$pXGh%al5+%wChOj1osUkwn>b^Snm6i3Dry*N@$ z^5tv>ZqLGl$LHOdziCB>d?xs6Xy;yj`WKS34m~lLxOlWO$Eg0!gkr&DHwj5E+?*4t z+P^5-)tu4qnKxOA2vHaI#*b-Xz0>cp_x<>Q-Qw7E(3>tRfMxZ+Alu&Y7900AXL<%0 zDY@Ju&r*v41|A>xVr)nOhJ6M4lSaU}Jj(HLRQ!}4%PJE+*tJFK@Dc-KNF;MePUjkL z*7}K;4QQ=;)hz(OfL6ob(Q^ zEygU!NFW5>@{WJ$Ami^OU^86{as%k1b^XKu68`~gaT$MQtl(7&SEc}l<1ALsqaL-! zTq;4toyTW7h+v*xSBdItBO>Kl{rMA-VT7UpCLr8>i7$xH;3h2tw%oCRe(N0 zp>WmW@@BSAich;juPFagZt=2!CqP{mPgLX2TKpQlX|N#^RVgB8eQP=4nvw1ihEM5fork*}^ z?9(Y6gM2uE#JOXd_(K2d_ zzvhpR=|2rxHSE96}?!v)S^vNOl{%pK7Vh%f3 zQFl3ptB)VXN~e$%e2Y;oN6R8EK~R>km^faIn=PK}6^!>HAJ|%m#i`PnJl6TS(b4Nq zk~dO+;LjYK>@1EjgE2^msX*62JQ(FcK%Jrblk3mC)uJUdTzG7I$x8=MU1oZ9L)Y!5c`m8;*m;Sj?5!WtQ>b#WutB{ znBKe``2u1dU(Z8kXu6Tk*UwUBOD#R%mpKFo(I-Of3!dkPFpIQb zhlp}X^oI&*PQUMwN;@Q_>I_y6jWO7iW+2W)V?ikehgS%j^2?!&)#~dW5)MUvjc+K= zoXPli43T1Xa)Jc0SXd*n`g}Q;HY{sV#4KKm6n8t;lB~A4eRVF(d!a&RT3PW2b9*fl z>Pgbs+rJIlYdKIu#sqbP+_vh_s@PJK=Py{5iR*r;Oh!5Iqd-uXz~aQ8qd8R zpkHrGP;Kj8ebkoetwzzPEs5!Xv46stN+>!?jA^|zYKm~#*vxd<(8|6GDUs(4!|CL1 zaLLtip7o|9NVWaiF3fzycY@L_)xDYIJd6&tNURs$#9GAka{qYl`|91xyAmWmqm-yf z=$7%$HiH!B|NeM^d}QQTbE|a?2O1)|A%fjBEbZFjmfeW^XfTvJ>9OW10jFDo$#kfY zRe3yZ!?%ho+ruzC+xES&+r0Pu$R-|NYz?mPVz*JHUE7=@+}kH#pE)yk=-?Jaw&VDE zO{{`@2P##y#$S7D722*AzV%$C977tj#@$HW7E$xvMrj<4s z)`h|#3yeLfRJl8;$?wPVg5{Ux6}AuVVyu*a`-sS}&n!O+i^>@r%_I)s*f56a4t6VA zGQ$yL5^t(_^KW%09$i5doroKaPMNNKeVsrnGQ+{5jWy_kGS1Ob zk38IZqgtZ&<%sKZLp)zT7uZc~Sm60kcO&7C!<0(}QrVpY!^C^I?aUOoNRarHkcJD) z>&Fr}Mt-08a9R*$ib>q)e6z5sP#jspTZ~Q|x(7CQ`Thpntv3(+ZgT4T^9g37i=&+r z%w~GCE~_~Qx6w0 zDli?4EMbfM2x=O(*Hwg;0Z%9=l+9*@bq*Uxo}6Nze1m=Rk~JoU5AI2&Nov%yVH z7ceIA);cNI=IKkVnH0DbW^64lXeP%=FaA+$wE}eZa z3@7;%z&iB+6l{knjk;j<hE#346g9_XMqiGozy*UC#e}lVZzr37b+$o-ij1{n*g?ug7zY~aiCbBu8iI|d8 zqTtJpM`s^k8`5>qGg)TWacw=)o_*HVWz=}##ky%ZF)FC!r&JmH#G2Bnu%R2KhG*h} z%EDE)o8=yIk&1f+qgwR+p}l!x+}v7=pAEE%-$ z9Sz?md!uU}DW-LS_^z~h&TBLd>ii0QAitU!xz&vCs~ru(<63gHvtH4L89oi+eRY4==r6C z6=I*b+7jjj62=8SWToL3D^f~trv#nvJH6F)&JvJ4<$%Dq3BSx+K9}%Cd4-E*zLk>h zDLX{~BUS@|X)owKi~EETJ$OxA<$bp?H_7%^@iLnS%ee<)%8#(G58Gm`YPKI&^v#TG zzBm3V|5&dyNO>J-YrH;kl>|@@?Xc;hm7Q`Vxag- z-`Vl5tVdo}5`;lebMa{vOgk~z;!Z-R$f@V&Tjvfp;--HZqU=N>&lUK({)p2pirT^v zft?G@xQ`)c&qxheanNh8nD%c;gdlIJe(AY!O)tP-jns15VaSxrSNE_) z2vOGG3mc%&RUnSJDYcI?O7ccmaNkw!5*&2E>LxbTzP`x)K75;$Q6socfo9bA>ux*P z&lA)&rlcVzI?LU}d}tLz^UrN|+~55%KspfM&n8GF0P~JGj{4&Yzv|@gf!MLNF#vX6 z5CV1#VtWtgpc$^Z^YlN%5l+5taKzsN$bG~J(ZmG&A!bL1=Z}Or`Fg4-?JrV{CbIRv zM0zD+KqT&>EGfDIJRYq3rT2?LncvwvU?f z+HgOVU6=UnL7}}gh?-J%Wj~Z%R|xGvp*`D8P4TkZ4`tU$?>#8AC(5WP4zBy5>^fhz z2Zgp}otom}u^-B=2KGHDw7sF!6i1)^P;6Mw*y)}9TP4c}kYfS>(Ad9!{STjt9`XPH literal 0 HcmV?d00001 diff --git a/native/commonizer-api/testData/libcurl/linux_x64/libcurl.klib b/native/commonizer-api/testData/libcurl/linux_x64/libcurl.klib new file mode 100644 index 0000000000000000000000000000000000000000..2d09a208ebc6ee9dda2927c7b218b644fb1b1173 GIT binary patch literal 40048 zcmb5V1$5+Ik1rTzPKT2YGcz+YGcz+YGc$8K%*;s#I~8VTW`+)K{@>f(nX~iF?0a>N zbuHVHb$^nsRW6l+G$&O8lZrXflN%z3|(zp=v7tVfgu0$S%v>r4Cz0K zxfnW`o4PpvpNM1s8*v*;J68{V4>p$n6Gepoqar&)7fUzOf3NQc5D*m9_hboywl&Cd zdyxJh92;N zte`8Rb)=>Gh0kPg5kj|^p22F&aDD|w{4A_g)H6Tb?3XCKn##Ian53AfnVBV6x|h}Y zUM~uL-zNC1kGd^>d|tGCdS8C&dFT2*aaveu9iP591VIr%5vki|@%WF0E7SWsPRD$$ zN`OBQdZ%O&d@3M|)U!k-5KU=3{Bn_9GdWM5R#iAEnM{IsOaWT-2=)=Ko#znG>g425 z{b_{IR_@{t%e2gH%HdT^_A8u?O}TY)?$EcAcXy=uEh`3Jdg2kj({grR%V^2tvtevy zIed?90a>IZgn%ecrspr@s{{p+0_pf-ek)ek`eV3m7^&2mo6T)YHPq*H2RWlKYhLaHgtQe{e&6ZSZaiEHIZRL%&P zZZR>WXKL=No%%tC8?Pe1=a3!8axGRfR@}l*5QQ$7Vi1 zB8ulU{>Y-5&Ox0c<*+6en#@!-uuJM!b<-=Ut9YK>GOj&)jtEmum|ga#NY^KBTUWK# zuj;uAlFRLhi>w6Mq56!KD8yHbYm)Vaoza}S^lMFhjbXVzw! z;t1d`9{_pDCSw3@9Bb_qXw9oiki#rocOPnA@r7#9J1rAv%|_PTE0dy%DM5Nu&*qmD z_X4zq{0YXKE1^WzkJ>-;4=jYnoV?c+CykxyT+X50RttHoiObw$`Vc?V>k`-@#&%_# zJOmgwgg!TfzI1HnK1~+%@D*~1n}&Z`noBi#cqz3_meQKL-sWj!8xLqLkwGof z(oM(SI%(h=O%6z>6c50YpJ)Vi|B%#WHV=n9S&?~`hIWS;9VMurD3mZmC%(-mMT8wZ z&l72FQo>uhluzXyq;HOaT1xs_B5RwB(U+0F73+2ip|>TZJN>cVOG0=cxppRHZ&zH2 zP}2nPX*&hmxMkCXSoPGXsBJ@He~@s@G*-3M;3p~rN|?X7Be$BD z#*%fg1u8Ip_@-~2q(!KqKhc(DgH^(0 z&Jv%~R_%chWK_hJD?3g>CGN4;Cw0ukr$eR&)?epq@<0|5Le7GVzsbS3`NOKe`Ir2J zu2*)!fP0KRqv8@|ZJBxP;;D)(sy=&L^Ph?@=*)!KHa%aGaHlCvr3&TKH8**capt~S z9`xRNZw`;!-tEzl3ES7b=NQp6{)oRKZ9-CCiqeNl;P;TeGi{0f6;39*h^!o>s8?r# zYi)Lutk~R<@cE%`h;lbns|*h^$_4_v<4`OV}Aqa4ee3K%P992Ah-U$ zUo*m-76>U~e3WXDW#XyhJ^Z>2WNwVrZ^nXr+!BynWWM@ZSu<`C^J{XoFw@>oEx-h@ zB&a>ZDAnOazRpyq9oqonidrgaUm6{{9PgFwgcu#~4bhOfcx#$uQ5tEfMh{fP*_Ub5+VwNESn~hbrMmc{>$b_A6&#LxyS|9nHJz5(hM~&4+45eK-%5|;{*cI= z_@mIlRSXGbAhJ|Q*TD^YaqdavH6SPsaRfD~rGm@Tmy(d&B6*P*)|RCLyO(^16CyK* z6VN_$m|}&LOK*WXD;g(r&8D=;OksXl>ZBJi%SIBSE}j$ z;T-w3AuTD4LA+fSM0+|45S7VQFA#-+Fw(+Zi#V*zorkqvgX3a>BxSIVU?Y$ z^n>r(blt0oA|U~ni_|Y8gDo2mb1Mx#mL8T8uW}U zd8$WGp1?hzBE+4FXoE=~9}>7k9yZQBngFet7`=0adzTGBECM*Q!e^y5m#W--S9;L*(IZPUNg(M$pGHXL6xT zrLp6bZ6(f}=L0zLQk+5597A$K!_kLUd)q{+M_Wt2xWligeKC)dM2G zGLsxJ&Ly3i;<5)fU~*~Fc4~(`&ou4Imocc-EpoOxgDNgNx=JyZiGVHN*IE#4b)5#Z zdA4@>Ncxshd+i<^&{V;XXI4;3skIuT{L6T&AJj^oh3P*U{@A*sDp3b^%_Z@*v%KVj zje<+YQ%@&qB;_PNNINA@_T$x7j(DbWZ}bjY+TVw1+pMrGP2<=V)b5yHIYjqeagy&kIH{SJIP9lbI7br1m8jce#boM8cG(|MxH*v4^c{II z1mK*x+WL{RFDwAKOZkT2UH93mjOf`_X6#!hHx%@9=8iOjI|_SyjQ5o6$}v9wsJv(6 zP%Wo*rDI6pblQ-yEB3V>q)2i^t~K)Mx<_>lITJ5`{L$Zwd3c8ENM_v#c0ONpMVTUF z=&srIU~p%~%J5k!Ki11OKPpAsRS+Xvhy#B-8{ANU=f>HSuq%I|6nF9{+{$AAf@4=X z8AM$aZ!g??dZOD4^>ULsCK!WPePWkpWlwoPK9wZP2b(fq37zQ%zMAWP9Z$g}bNR@Z!Mc#|bh4ng~eq=W@;y=4hsS&}7ZQ}(;+ zHP+S0+n{quS58+0t`z1P-M$UY@iqdBW=c0N)kPD@m4kGf@|Ed^0zQePokT}rTrD%+ z4izFdl3PmI`vWX`W=gTo-A9m%Y-YQqvcICC*`CgudS1U-&DE+$W)eW%bj>5U?)-KCV!oF=pXUcZv+~$zk zo`vYPm~RC13#e~0jjS6A+W0N-w?e$#zpMAr~7DcwGX;9F{$ zIQ$YY&X!hE$!OcA;F-TPr6p=Y`oj42OqDl|>;%21OZ8NpS_|sCMt%8EtB5dF)wgHI zwAw5EDxn<5I@o(Rag1UEH_&K)vYXMl2aRqu0rHMgy<$JUgZ%#E_p|)2-o@p3%zV3f znJ2r_qUOfhx;te7dy4n7zmFP#d1H5~_LQq%*^f|z`#V~vY?33nbvA3R$~u~~AJ*HC z{%)-5@@7za=W%b0xGl49?83BUwaeL+)6<}i@b$w!c8ETKu&11-h90jL=Jdd*Kfjd^ zq6}q))0hdLAKVgt*MFd8pO5uCw11e1t*>)}dj7I{}P8+$qjD)xAUCH7b$X@r>=)YsIKXE@%HM_awP4*t(` z&d5EW52?56*5@^Hg!xcA_PFcIiU-4A*bVEn15M0pN{)m#>$JpN4CXYGH~)d>4slLd zN5t!=zOWY?TXG&oYjPgq76EU5ue?|9Ir+Ly;cWTB^9hs@D?q&(P;renR|l0oVJFqZ z^1xEYmD<7zxLZ;^a}Gi86OUCb!|v=N;2(R|;gi_8#$d@b?eIV5e)e@P=QqyV?|bVeieE(4X`MVzOV(^%LweC@-$Y;KX75fb`pEa0cQi_&fIs9B%ePQH-Ljzziib_Y0UIiXrTvEai9G22#)d8q(8 zElf45&hgDD?u5ua)BJGwE6y_}8F*N(h7=AgNeGO68b^7(^SO%(N9S_V7Pga}3aBgU zASW3^d$p`$UyP`jO)%%P7WP5MC$L5&Yma2J`Q+`3i_*)6GL-YJBG<5F3sK3|?yBx# zE=*SsLtX!RiasT!j#R!k-VMy56q}Y>mO_JPl{oRQ+o;sBJZBvASYg1Rd6Zc0m)ZNh z0)}Jld0M)@6z*eSMM<@Du&gcjQ)2BO>}gi##E|NW*MuQah&ak=uxlzB>BeWX*l=iL z$!RSM%06>G9lFeh#L_o9$|Z8B_neyp=jj_#KPc(DlG}>GQzq@4%L;~VP7B>_yO6Kn z4ex5n)MbJd#eFeJ<9F7&EV@2}F;&xpjN4|PPOn3L-0pc?rnLzd4PRirf%{yyXTE{$ z8@+8QUgRlW*higDuhGuL|NVNnP1Wn7W!d}t5MTP)Y@W0SrJ65Hv9)I6qMWj#AzLdH zfz|)BYEi9R?$Kj9#4lggP-@DxyjUelwG_HXB~ileRd@A{0Qt>PlFeTZWz7%JS{=a* z!TecojpgkVcLb{&f5R$0@yD;}92p>6g>re1INMU^7*W^I^m$#tjx_Cik#mgb+ibMh zOG+L!G9^1@TReX=o#W`=6nXkEHJRMWqGe;}`zS4*yDspIqL@owBK_j|co*K)^x~7V zTnk>r>dWg2?2p&|6qW}maye;PyyAU@QL{;V^)~$2eiVJ4IE4|b&#dgD8|OZWdc2J_ zFx}Ed*4lO4U>$UxJc(L`QC-C?+^t87RkX}!`lBzcVqL6$aD~mwMt-_yw?{91W;y$b zyf@E#g>P$Z3VkuaZl#FTm6ugCg`Ywi`H;Pg6jVR7?%USYEV=`Z+)Z}iLk3w>FT|gUDAEhENs2J%%iSM zA?M8RmKV7Drou9dm$dSIj>=oyirhObWD!fF*TucAi!Q5TCOXnf$k^U5TaQFuBboMa=#Ukw>$$1D%b}BOxhz%BU%mEaPqAvZ5Cimc<;JSkEH?Y=rXVE4TLqTyvYRBG z6ubq}|8_YSAD~{!;<=7@NZz$9G5PJJIaeLTv|9R%+a5b7jjy5ZGk-bslKhpe$`+{5 z;U<+;Sqh=1TDDHAQ8@>bFF4mvayuIW6Hhp&9m`IkBVt}zB=pP&L@`wA+DpHdFGUEp zob!%3o{5NLkGLu@$y7Z2oLi**8wr@>Zmx|dX{%7{Q9XVYY2-Ty$-}(nqFO~SioU?T zeidqDCZTS$4LY}uBrjoQA`kNHN~|M`AZcbOY@~%uV`%BZ&y}3fC(5-nH>$+w6V)dl zaC}n^b4T~}#xw+Y3_Sl$`;DQ{gQ+3$MGXJic6VLa8g@f$t4`>RZ?!G>g8af?#3uPY zuw!n)|K#Vvyax*8XZ(lS8+)+*^ar+*CwYf@S1rdA`o8E)) z7LGmNa@4f7>H<4oe@izBczEqX~Y5a0W^s5R{y5Npb6 zM5K#zN*;fKhjnb(@(z3EjsJqY@$iww z?EM4|DsjM_(Wz+NHt8~6lv z@Xa6aj!${w*B-pV1$M$?2EY7)kY4-+FQLB!z#b<&Kl58`nnUL~px@sHx7J%=r|xI? zwfQ&ahTEGD4Dy8*_6!rhJ$U2g@m>sfO%d;(xT||`>yH(F{;elD!<p2ERZK3Tp!ziX6)ws`IVG2OL=?>*Uts?+YY+_4Vz#k9b)GlBF)&o{fUD5Ose;8x6qsX z4boTi+B`IWkZ%skC^(pR<3IF`skA4?+@10}lz)F#qSR3rTyq(%eek@gl79QEUS47M z9pv>%747GD)={f?FY@@(3K%Lj*MqiFEOB zjOU>u zs%YBigozuAI~=u$>6ir#Sy?e^hD+4c+(e0^siI|Vk3{$0qZ7E!pGo}LO_BcB;r-=S#eA=;{2IB}my`=28cw#Yn#)*cBD+0iT?=}0Q&j1Y|# zwC@VFSohJ44IG-zH6p=iwPf}PA7``zmt`wTiI6g{<>|prO-+re+szo2qf+b_X=4!Q zMd~3DWqm!x9+m;d0|j&ha|0xRzL=hlFj9A^n3QsAf~e3HRaQxdCc3$MPSJo~Q;(#P zaJ0d~^smt(I>vP20d(DSJJ{5NXcS{yt|`l}cb`Pd-*GycDvA_&$L%C+;I_7_#WK`e zLu6@(80l(<@qk!EXLTBkal!7)$%@u!i|BY$W!zsx%UV9T>;U7xL{&KW(~-ha8EYkuP&oe9 z39$FgNhKC?N;3dlGx{~bygfa4rH~CLh&ZUmVQ+NVxZ7Gwl-d!Xp^Zdlm0_FEPoz)2 zYscbRQ=z2%CY_;ti@UdByR%3}zdnsf@5r$K(GlYUCC~ig5oil`q*62x@&h$65Ao2Cl&o6+RZVKOc{qau$pICXpqo)}Rz z#1Igt#06wbv^iy#u+~RgZ+JI;>Nuf{Q^dfLTW_P8p}cbRfZ-W&nAsg^XfkK}lG%-D zK-w3K-0>Da35dJu*Ksh`X~>&}Ke@(WI7U4VmU-&8ffdGgEjGwK_sT_rq)Xs)T)cT{ zisZa^7R!J2B1qa$yMt{z2iWJc+~QV~^+HC2?Hn?&iJhR*dR${caAkti83qm*jx1BE zouJN=pP-ZP{fImA4Y+xXJmw7Xk^70-?v^HJh`uV1+za%rzaEkQ7Cms>-XM=QM9^m% zwUll7TMF8bi}+DHO&0Xie0O?piq_9)JAV;TpZy97R8z zBTqQw+F#)IF$%*q`r(kL>7|oAW&|m6$2aNrQRcu~#A{}nwHE>X`!ad{gO?Xco^Xrr zcLJmCpN!BtM#c`-Jbd5gpAJ{uc{I(CclJ(zCe`UzXQ-Eu`*%geqy7U+JkJcZ-pPQx zT(SGGpMFRPzu_weHJ{=F?OeL&!kud~l<$SYKy1`U#$j|4iG$c!M0zn8vj!NPo-66l9dFRjam@>kR@Hu!TuRivRW;ybS66b9`kH~BxHpdD z^HdJ({b`~fueEVt(e3^VTMxncbu>l|fGVjNYFKKs>iUD)`s}pPBl4qV4U|UI zJu{Ue@yEHdBrMTT(o|MvwKSEf%Et6bp*D)wYQ8Ee@1^3nwL7#$)CV8pqdWxCae9ZBm zzJM>#|Grt{e{Pbnws-k%z4-S{692wug!q4KlCZQhwsAEvHTgf$i1ME_I+;4#yE+-0 z{x=OJ|IxRx;4BON8w3a_84L*MKlh{98roT!nL4}tm+lN#W$E|>7Np)|^@Es{=553h zT%>xVUuY6g9E2@^!#kM_7ZhCcll=JPO!O`&gr`EjH*b~IX|TjQww=7P@rK9gNthQ9 zc@`OC4ysAMc>gPx++DFjTiq_lb+@yD#*`Wp4gW7MG`u+H!tUzL{W&;OpI_F2?;@sE zI`@8kTd`JKhzO+D3mfGEAt1}kRz^BUfzOr4@N{jiITZeCOS&b?aoX0ds85bm``xAT z-qPq<{~TUTES6tYyUX8ixy@rC47`LI&+_E^zAN~uo;GFb`%ZP+kY6{ZjW-j>KzhF+ zalt~mY;h;DXNuz>L>0biBwjL2aa<;1ch*VM;itW09K7J|f_0GT9&rJT6}0uun~YQW zGHTmy#V)^qsSob*cRKB-?SHrW?{EKnspI#z+WHv6-@;dlfNmBy7>Xnx4PE{nn5392 z3~oWAfpVgJqloMv4=hP$%TjDoY$aHLoF^R{0<|+6fIUMVNS*rwb^|8Rq^G2lnN+r%#TH(U&x)*_RVeYt9Hp$Jr-BM8 zsyZ&1|ssUmc3ok_$_6)4b$tH?kBfj_buuo*Ke2{4@v0<;D(y~@Y` zX60&+YKn-US$~m4sL+d;dpe9Xa$OINY0xRbh;f9Iu_UTx?X%gC{-pOBlmEb15ej>? zf2038+Q)c4Z;X9Dvj6W>9Qi*b(04Xln;5zn{`&;{kNlzU70zP$?ttR>-Z1{1ysf>7 ztBvV@Nu&L_<}q4|nMoQtI@v{8z%)H29i8?9>FcBrSk`W^znMijEf0plmc_ zRBsf12lU@t{+}18|JQN{Lt|@0b5ngAOCw`fC!7DjnS`Ak;6nfd0j+;;^#5)q|6hHK z4F8X6I%_-I|1v|{S$U};h93|&BzWA99TlKL75}m-EJ;IFgj})!rxP zwV}3M2cfkvdi5!=bW_yBtW|PKE3QPz=`wVl_B%0CRJqn!YLawd(k#=VK{b6I6?9Wl zhS&8SPJF+z20o>dPZ_#Qgw&;^#hAg9cLk+V*@)`MkQ0ys@e7c||4a-`kUS9m=-WS) zW9_WcW78(Et{$tDg2W6EpCvF%N?8MY{2GtylivdT=h19 z&tapzflRO$h~5SD|Ci7HBU+U4gEr40fPj`U{x>mZVEvyl&RF-G7efk19p$Kn5+RY> z<47r`{FS1FEyVGV)6(3~mPT5ryUNH51r-P}7b0XKJuSYbevoJh}wc%Cz%XdGdQToTxb1mjQR)ugd89Yy~T?SUJGkM#J;Uo^{7@FL&#)Jgzlq*-YKINYWIrmxc;parw>e>^4ghZhp6+6UQJ_1`d_Ko8Tliu0*Fkc^ zJVk+;ynPnmI8%fov7D~=f&`y+v2le2uDOfs8L^cRWPcNXM7%6-SDq4j$y_XrMlNnF zmr?Nr?#1>ztk02hJ%;U3>mF?h(e!Q+AI@WS+8e@VRNE;k8PT>gZrVn7;T|Lny{92c ztxwRUj+M->>79LzSCZH=@xmVyDo_^7=dO7f9H!32>c z2bX`&NgM&>*`2{Je&yy2PavnlmWE8x1l0sTB?u4FQmr+W?OH6;&tPd|3zdcSvB`!O zhRA39Ld0qEV0Qu?%Zr!ecR+@m>0(sADzh_S7G&$pFp;;zVO@DkeiJ}kQNkU@A=kQd2@H}9M=4#YZ9kl!9`U0q(1$3Mkb{$=-i_qcwlxrF3?b9YIY@sPzF zz5}U3nLZXl6iS@rOrO`bgF+P#XF3aZ_EjjR%i3@*FF1cS5YN3qKz#+ompd3s5Ij$e z&OPVIRvcsWHy|zligTnwq<~TZ8#=T!6z5n?;yh?OWvifld}q^zSv0XLt1pmr?N+`E zxxTu(#O3pCFQz7f?86jbu4M1`5o^SP!`Kx}w8qLs?6k@ru4cVtj0R{Lx;`KuBj*Su ztPhatT8$ePMCaNSnoF^XtltOeP!z5QVlXv#c5-*Uxg)ArRo-WIor(t84cGkoxt_AZ zk|4{Iy&UFSEs_m|Lh4MRTB2x6@jDX%{y3_VB@Y|mM52B;|MWW-?;{qlIy18^#BQf$ zHNKn>V2Sgk7O;l&XE{uFhiPi$h=IRzX!Rk8E)rFRnB6LDLQ&aD(mD-;tCiYd;5X^@ z>h_{U^&FZ;1r+j7=4emC!W~tnJQN&A5`fdt&d3UhD>6AB#HMruJ znj7W1ckp$?_wFNe^Q~pV7n{UkrJiMQ>MiHn59QL4F23qMhvIY!l$Ls#4X*myqo80)-y1qoAN6!8`hdGM<3V5Ox2)KgK6~m6 zzIjRIg|Ixcxh3ZA4f*&+mo@BNzWuD&hhNZ&U(||Y0SA^FAnO96bpqCW3oUUA-5x35 zkIo0Yz5-UA2`AZQ=!TQJ82R=qTbya$bOImpsHnOmBfPQEhz~#&r7Nzf+5lu4W`t|1 z90i?%r%of1S)qYw${h8msHSWKYkD6Aub`%W0Rg~{@t_iresTz%pc^M858GN-PQz8Ugw#y6BHcYB#)zU2eLv~x7CNalH^jbfhn z2@l{B?;FpwY0O`6QDVejbdh4jUuc81f)Zod$?sPmHn^RSZpJ-a1bLfh-{GU-cTSCk#r+1k+hIBif}pc`f@9ZrVw7YZu zyv+MtPUkE4sT?fX!MeLD>BA_G>Na~4ymafC?Yu%8wp1yzMyKH;6SkkyF@U9B4Wg>j zWJ*o9u*TEG-itL0tyV5jNt*QWRVH|pT=9{{HZ!kMNIMek`(7DteW=7@`sBMrn1h`~p!4qDhGvdOb`Md{O57A^R*W z!ESCsnk7Lt5|&Ji)kvCk0CR&{lp7dw`8zIM)FCaMc%Yvyg7No^kk{k*_3?OAq6ox^ z%3I)AH6v#X)DU8uv}Kh%(p=zsMgqqga|zyM;4B_TO^kKzAK7JZDdtMc?s6=0tTkz; zRRb>0B#^k`Q^9g{YFNiuF`nd$b==GA@E&#~ytv^}gTcU%5w_e3vbUrJX$jCvO=@NO zVSn#T$d`5OI-{6A)XAF)Jwx!3?CE@sHBZDIWQ-nR*th4~bAoh%w zxPgz2>N?t}v_MvLm#4g!GWpUxc@^q>3GVljMAI%aIx`lNUHm~*gc{TIiwbGWZ;x^m z%_%-E<&L{t?aB&M+zjnz$~G%yyVX*i9^0SpOf2UBlc`WMpKA3zpYvF9@7)0i%B57S zl3ayw9VWP9D%LElbF3(`*Zs5hF31fgig7aJvW6x7{Bh zEVz;8hu~%xGg%$9*y9Kf=YYPfQ0GOEqDG|3A%%t3J!%utEH}EJZNZjfc1FAxgcSr4 zXj;)G2Najf3`pu{O7Crh6T7^0XrsB5+;$HNygO+9?GO%SSRpq*Ymf-JM;q z+6YI5{Eo96-1|58p*fb{4l*G!2Txrf2kzj4XU?HQ1AR@>FyTv#2N_+wMTJE{XLuPx z=qLf58a#U2RZC@yy9a7$b}nc=#zUYvdJQF6a;RxMe(v%9@Q!eg#J#M1UtIZ3aRwT-OCc-dRyFpRds09dEBp752df=~x!5k;ItLE~Mm9jxK~(HqVfU3N z@Sx|3;?9GR)y{Z=A$h|Oir9P0z=44R!wwt7hE zFmItmfqr~AP(^qM(Xzg(@m*&}u488|56uE-uuJ5jr%;Gcgtlos7Z2|pZbB{&cOtbu7msWO` zmRi5a<)*%*-yZ#xu)9z#B6!s}&@1(Z6<1AM|;$yu+zC1T zc3(IH+cjV>jEo~Z+AY|&o(Z&J!JMUKOptwid_-%&wS>fH1{qHc$hgR`pCNqGcqoJ zXDX|Cw(C{sjB2&CIAse$sSC4Wvj9|A>gq^#&;c2Ckui|lh)i(7_~v0a=P_oBL+f+M zvS-difI$L1i0i#humm^8salpb5aIT_F7SkZF7l1nCZ5AJ!ETmqzfK-fr*M0Fi=oyIy>gwtD%aQr~iD+zYH{$1=RxtSg-2+GcQ_#Qhz0XmH$< zTYR!l(NBcJYhEjZ!8;Wg4!^);4uI+>NGWq)E_k?_f`e;)GaD(cx{bLgK{?O z6+S<0kCi=nTWP4_Z92_`fX_!^Gj*U?$BI( zNS~ZZt5xcB;FDleR8TOqx1}?AvfHxnxFIJ$&(KHB z(VzUX<+r0Z_X2I#1&m}{bYZoPXYdHFlh~;<{6+7S3v1Qfs5N*h)XSPim(|g8#F+}DC;w1Kg5|>e_7fTVpEph(u)vRS;i>D z(#*dg7BN;@#wf-rmfrS>7Q*IU;dOJ%YqWIEW5#wPDSMzTa!H}&tuqvNmf|On z8qJuK#&(lA=U_c)KdMP4%Ei9R3UeuH-KDK+8K7I#U$C*H=~3z|uUR9bhCKt|nAsbfR$5gpnzevHgnF*|?K7;@P`EbP zw6t3Bv{W{r#HbqwyD?;7AZMt>l%^U)8&x&2EU}~q6Iy`JpT*9f{VvWFy(^!!=tSnp zG94&h9I>qWUA!uKM`6H%2NZvlabr>JxF&XEVVB4wg(X`Sga_bciMQ(Lt~{Jr=O750T%Zf9^4ojRJwsU>;}=8!{Ppo#ZL&nOnJP# zYU6MU3_3r%Ap6VBvUrXMQsy`j7B2q)EkzJ+Iyb4R z1`TN@ny_FgG@YfoWlPa0A5_%DE_>LDlXSXeP4JDW+E)u?7;$wbRFRXEzA+DUaM)uD zC417Vqh?8Kkxcu1$2rReo%#oXHS@#ah_iM&n~!kNoeDLT{HBz2B9n{G7(lgmjLD_w z&ZNXrQy6U4MK7+DQy>}5VnEdLj3zf|yx2D{~rAVm7n2J#cK_u!li;DRV$?+GKiHS(^aJu1$1`Z(Iio%u8OsJgk)uKvW5SeLrPnjMqvde!j@Wct z8x!dDp(A#%Wr|7z#0hY_l{!3F({_=D3k)I>CiNdZ3q0|2z7-T~>eRvJ0tP=n!(n!| zGqM>61f*x_SMvqoXizcMIfm>wV|ShI%^L|^Vfm6{tKm@9w4$c~+7YQ}d)*SV+hFQv ze)u|npZ(bZ<5Q}l=EvRaz$xq(aMo74n0s3!OGrK24Ed07N1OX^W$Y$q8`t>{lO=nBrf~A z*|LAp1MnLfs-c_K{VFy;ukDjrrIbB9etQJa&aHZ->y~a%$sUe=JOXTo?<_aQFZPof zr7N|qw2ib)vQ2T^gMX8ny!V8qL@`nqk9sQVQ+`K6ULz!O$#g;@btZr8nWr(fP8Ba{auA1K5)7b?&3lhGef{Ah zLlmN`?K03C0(Bn&rCr6N7lVi|enNF98Tl!vQT#SpKXTwh%o$F>x%GZPp-g_vD{Qc&Q=Pg#)2En&p5R9!54yvO zP){HLvg3+CAsXLg*D=gSqftotE^f1NX(Dsh}r1_ z(;orTP6C`DQUPaMkri=si1AJ;&uGbKe!PpbAmwCZRZNwt^D6#&B9D^Di~2~U*Zo5= zl@D(!akIaTn7B&JRcHfd2hk#CF^yTwvS#TcF@2?nPSQok-rTkhz<2Nv>WP48KhY2p zkQE^M)j12Wfe(RvVnMBt6@dGfIRyj*&;slo0^osDfqard%?Je`cC>LBAc0kZe6m3= zpvob3bP>vh1>k|UcLVN`6kz))5i;TfPJw*VLC=s2fNppZECl-DfO@BaVUY|#cOY>c z7(vWHZiEpuA_6pl-XlQig!^rP{3d{-kr*HY@*Vn7z$Uwf^d0=?&erV;Mw0Qvm}u7Tn}44B7tAO$%BzL7@Ihz$4(^d1GOM!4exXPwj#{}p_?uYqLYh0`$krYTNrzm9zJtDrfFQP)-vHqo2g&hd&^?Qz3wvy6x{Cem#2{+Mx`=$tVzJ4uM0G z5BVoB;%D-O`9H|!?|w8;uoH&*KbXqfeG$V+nWtgQJ{J;ZHeVd5MQ7uo7Qz*>>31MZTnFT2-NaiBbBcHU{uo zOT_3l4e@*Qhf&L_ZJe-G4(RnS*99c>D%M-lrw>zKeL=HYf028|SFQZQK7ENN@rE++o{j#<^T(D!_Vvf&235XW zR`~VP{Wqju52>xXZQTxs1oc0&y48V^{p$STeH$U_e`qKXn)cNHjt%Noyr>aE4eoL& zFc6QT!0A0_0F&2Csaq3Fp0@I7T{FFx+x@T;-FOY}lT4m+gO?=4CWPq5uZH>k4&Q*p zn+1xU5ykGF(nLPJTrb_dF|S`@ufPw9d_?&l639m(!ebx1fJuVcRGwa@cRBeq@73N* zzkaEIeRvI!Q%vuPp=%`~lLW}54@~*-pOvLXe2fy*2o`nhqa*usKX=L?M2&!f67ei4 zPo3QG{^GC@=O%;pgG3eQrVAg0%@^-XWkUhNI{^Bp^nn6dTe6?R@s|g^ryuyT?1lY5 z`>1%m+2OiJ|Cz`6&;H8)%=i6gUK&A9c8KtQPPPBfFlYBaRuca+-2cze9O0Mj5WMOt zA*K!XeFEjP?7t}7<1hp3RN6-U?8HaD@?^|fT?CC;ACANd?U2cp>X~qt$rE9&{=LdTd=LbYpyaf9f2Z|z9F|xSl2YG_$2ex3ZKN(!vaoGr8V|9TQy$I5Qy$aM z?YRB|S7ywvg5!c`Yx&1*bdejb{L?HHk(-YEQ*T+cuA7Mb=MTUfSGmXy1z{IvI8GNP z{2Z5t+hg=mzU!pdqYp*+c8u`cdmV)bAF{{|kNl$#W%%}t@SLZ4{3-rIzH4O6_Jl~( zHdXK`J{7=Y|Q17{2LFsV-}z z1ud=#VQ?k9yGjeY^?x-vo)=~(mwd*35=MNA_$bC7FJ`md#Dl}qea_~Srs&o+8mnJ~ zSE%STtj`@gw76 z#CY2k+eO-y+ojh@w`i}DuVep-yGpuBxJr2zc@}yWy%&1Vf6n`y0iXSS%zcb~taXy} z5cW{=_@nXF`WX0F=p@cb%|psVgCCb2mz|WI5G^?)MJG-tIZ~KXm{Oz)II%wqd@Nsl zO@C~E41WCnzY9RDqn&F9{jnJh$dTb3lWfYD*tuJc$ ze#>b3F79kyPaiE`UfH;w%$=Zl8K)dN}T4yP1L$elICR|2H)~bGcRXv~>0Pps`j7DT8)9i@3UM=6^TJ22wE0 z4$G;QY9RC*gMI;)+PYQI=pWiba*5IiR2wU0A-z+v8q#_;u6m`xB7Sw%DcB}7V)e}U zt-Bp4jqRicrfB}1jh;7KZ65AwYG64KvTB)P74`{pR=spiN7*+n;iN@MU*3-eOS-B>Ev;K*+;7#%~Lc~da23)Jflf2J1A6^&&- zs~sE~tI7~6CSVO1Du#|DYf7E~+jcPX68N=Z>)kUxj zn6ZH>PV7UgUP_DHkV~rgjGUJewUpeTMPOEKJr zJj@_s=M{WVW5RV1GAzi7qL%9gOCw=<5eye(Tdg(*C6|#P$?9ZX-r9!2=6fEbby>0j z_-1e<7(Dx%JB#vfiA#G~gtE95I4tXT$zQ=YCFzy;p<^Jl={<$le#Q?k{N){XOB8@^ zfn5xkA#>vjZ=%q%)w}I9qK)-1K@9#^N#=D1szkP>L=;?zJx@Q4^JvrlHjp@YXK@29 zt`ocd{ETpUAv}Eve=djtvR7_7hzJJ>1e2>lClTt!DEhyi#V2MH>*#ta>gA&wBP7hC zZ5zO8oUw~rQqGDeM9_9teku_P8)Yua<4MsT5?Pve{!yc)gSN5%Xj^KaDALMJf1?^r z=W2KIpUt+e9%!2U>ORd+TRZcfyUu#xN-%}Dx-c@r-i%e9vkSpeiTX8Gnm=AV55Z+L z0iO_(XaMAbL}dgp6cx^{I|z{(=CaqmxI%J~k-bUFP~>6ygSs52A8BHQ94Z35k!6Ra zFJ8Hd%ZHaTSjo!M;Tf~3$nFC-5@sP6>vGtTyARId-m$U|89>|9+-tAJq6Hfz6@;x1 zdX#4*iNB4FzB-+b$$W^gNQ@hO(i?QH+^nb}_g=p25$ERP6`LzDP`^vdoC#Fj4Z#VI zt`@=?FwWqm8TePU89MXp#h>j^Q(xOt3B6u63cJ$6ou>pnoTIBGG2ll2W%{B> zLFOZxw5KC}$D5SnU-RM3M#2uHRNH+|#Y)uatAkIcsiMB4&AYx2oLo)yJ5TPj$)iBt zv+<*T9^LpUi6EWPWBe?p>0{<>1U3)dBPn*5?5Tz*9hA4ZC>=}}U%`*`5>df3toN@1 zL@00dl+H6FEmCiHNjm>+D-3XKz^H~mFqA{^uK_S@Oe1gsR%k}S*eU+;w{Zvk&XeR1 z_%7_836C@*_db=lO4-^a02Nd-nZ9@0)9@oIlNEGrNX8U_-%9+8Ttgb>3jl@ChSd{X zM{J)YRF>=xHB^@9E+JHw^iDBU_97S-Bu8ey#Qq=lR&Ay?Sy)crnyK@E!@o6v4~A*Z z0{q0nXE$zgwe_#N2&~m%8@1`~zk_spm#`iB9Ph*^ zJ&_G`WOr0*CmG@&l+)dTgEjgZw4`?zW*>|wJ$?;zNtrGi)^fVY@e8Q9BAISSKVSK~*8NcqxPu-ISbMjAE!}tc8 zYRK+R*gfM1b$_{te~|9ug!Kqs#=lrPO_AKOv2T#ywWKCj0luo&v;cPe`#1J3;`@Yl z)-wBq$SV>bsQbTBz9a2zN$%*}IIYO@VU+{MbD1<^@@L|4UUNm9f{9gEB-@;xz zVKF4p;vbmBM-V9AGzl8ZuJLpM0shkDR>*gfYtoG7j)-H2R7axmW2)oQ04f+4rZMKe zfAN*NwVL8T6tF-2Fv4Cf@qdO}a*P-G*X<00KL;G7#Qkvx`< z^u(!dA25GW4eyx0<}_~BE&ED*{SO5H{{TH|Ow!i%e-QM$g#TMV&-7pYd{^p*FX{;T zNZhRmL8N-k5p1(iq#zXXFqC}>^PQx|TEvmIaZ^7lk$Pa~FbEOHd^=V=2Aj1+#s7wZ3tHfo?d^0t>y;XAb(!<=+viPi%H2}g< zgHoH>(Pe$KCUt$YGiY`#t)aveWrXqExG^S!uEIos$*EDZqRp%|U_D}-bO23H8gsAH zpy*^yj(j;HqV#)eN@Jjmv#7Y?O~unOxw#aB+L$4xe@U5HP;HqW6McfrkR+ptrq()N zzOE`XcnqLBd34z?+1IRcZ_$@++O5&5SBR+u`@-A5#$04ndLT%Yq5yP;joWNePA_JN zADpOf@rKt7=c+bO6>cUV%86Ohc8!29un%@pi_xddG9Dsv77Qu+cD?_PVssIM0G`w?68-pD&j{$rt4w+>sm$$Ni;*yB%G z6qdjVl>VX0wqi(8&6d;a;|s3iJAzjyFF~7A$(g0?O0&3^#sL))th;WEYG(5=y|E7t^G?sRMb4$6OCiAP52~b)XQ1S*fFNkq z){quNq+_kC10k7zGstS9pvFQcta+5Ul}4U^OcXcCF@?|b55)NjwQBmQOgP; zG|g1gMvzTEEd+Rv-1bWJ-7A8;(9VeB{F%F_xn@nT+ZWM3m46Kf!6{OGT>=Db1)-X3 z=k|-Vkt^N=)zGd0PV5Q#F~xCAeM22T9Yu%4=XqVJX1PMGvNoB5Za?BPudGOUUCs`5 zs*WTN_@}!$iBnm_g2(CN0p+fx@uz!}f^djiSVDl$aE%t`Cz4MD@MvjJ?(f2=H@ zhOcm=FYXfCFF2VsFbVQ?Amm&bR6}&NmEPNc3} zGp}Euw@%835OA%_!nLqf*bKQ)wPcBIXkz}JKaBQw;bCRXxVUoWInp?5UJ&k*ZmCmu z$*4qAYeb;gV@|Jx>NZ~01Vk}3qMr{>DGPhIHaI; z*19M>Qsws2f{23{Lr?Jdj3O$ObtRnKQoaz9LKmO)+!CxN_(5AA1@A_tm-xfp>7S=v zL|r2d8a_2e^a?JrETyW~qy#>TuSS(hQ8EcvW_1m9fFJgrhwpzYbT+A|ozaX`U0dI< z(lN}z{qu~_z_!{sc1#;q2i<`k*9~f<)IOlHZ5-}t^+o&c6?1n}|LXm688mYfGOCyI z=o1=8c-t4#dIn6+Hyp4vFDqEebzlFe54Ed*RL;|00PMpM zI#9=8J|05ycV}lCVj|Ru-pyyDq1O;3`iTzwb?2R^KM$W+xF{uPiIci=nX2CcA6ex> zS-)xjXN0b5si9O=>hx#!Ox|2Hb;Mqu06H%ORS;1k?_Z&urzF-@Pzeuiu6(ZK-)Mo8Vvwx&nwdMQI1Cq6 zGX9po<-i{BW-6swu(Qg!55OMir5L#r{B+O_nn)_d@KQ9pCtLO zPN)za-Z?d-qraHpBl$(pN5i&EC#82xQ755-k7hRr`1C~M$sj{*i2W`79F8<^UL##& zJJ81nADo0MxcR{?>fuS@&EndA;S+Z=8r^}|UkE;+wuN7<%?D`;2zMVQQ6GF8z6&+wm_5PshvSM zDI)SgjL@yC$|c^W>)WmS!U;0_14e+me$0a7j`e0T?`}}IK;9{h)YxO&y8Ek?tkYBn z5clv+FJaO?D-ikDq&copj`Yh5B+-Ypgd!JMne|xp=3iR16xF=uZ>g?zStws+UH9>d z^=t4@yl+dWuSg6pP&d!~g_crsi|?JSk!SH9sGx5^)mP1G?qfv)l5sJeqnlQT;gU?EaoNuC z9mga4oO^b8pL1oO=_KeJMuEf}_axulaa7(T==_iViVqT1nU_TR2$HiOjUQPp_A^u& zls!*^y%jAt#yBIv57AyY1K%LS5CLq6qnx(;#F?Yt^%Emi+FzhgpQu-F#ZP=Y|6iPP zy6`{T_@6YD!VgyYe?_XIXZ^3?tMl5HE&dQXklhA!^jhHIFi}_?Jh;ZMS;WjiXg`JY zt`5f={7zSsE+)(OVsq9h)r8%38w)eR-$h=~M1kcndF6uWf~A5`M1epe%0Wo`$p1O` zl(%0u4!SRUn#RP`;pvDd+dO0IdOSIqmX?Iq*~5h8ZRYI#x+z)9a6)y_SA671F2n1k z&w&+jPtDQhaqcur-&03ysIOH^ouFPjAZk<%yGGewN!6f3zvusZLU5{xg88N%EBg+9 zv^XAm!D^?gPX^cgtWn&!I6`F<6$3IsnLXYe1y=iT{IL=OXRU{B_4*!0mja5s7lkp1!>!>8Nhbjve6xU{M z3;hJ>Y1Pq3aQaxO9`SJ<|B1$D3eHfh#HxA4TXd z2S*O|;!RDzaktG>Y!Ifu z@(((P#;4WZdh<*38`bIYu*PDB>l_f-K-{24MYX0)Mdl(&04+?tCX6uXUolm$n-lac zy!&3I``*CVVcTR1(Tge ze8u9dVlK0AFq0`+?#ZOohpHVjL%}x^cv*k&UL=?`)v7U;qh0%Swi7kP;v(GhQbjs^ z)l?JFBn0PbFW+OVEmaEm5uFwdg_p7ykUz@fcWU>VWRuP#@J5bLUq0XaUeg5?GP=)L zR$WEe+Qr1s`mLH%;7XO+YF%#TpY!WydKE-oFd2t@y{xWTp^= z5mw79_)ynT%J`I=b_tM)Hlh6TmYSX%E2#cSvpY%Q2ZCvIJX%E!0bONjH8QR>E$R8kB|3H{XRALWL`EAgX{Dt~bc`cXZYy~t5nhHfE5VR;YB8@q zR$08AII=5SZ0TXP0v&vo?GiEQTtHnzH*{67FckRnAUS4!UOmxY_GK!|inh(y!=C8a z@cN81P{DhfE@hbfyg#b%{S=V!Va!Da%3L0$wcNWbf6c|XzML}_TGsi%5lubz{Y>YU3<{Lst&Nq$yue- zoZa#Ci5pU2;p1As$-?#BklenD8x9O2eOl2IMP>);|jk@R!bg?+#|c6fZ@x(zkuN@zTbf1E4=TBaYJ_J z9>E0Y*0ZMzqtnXli zlq2}a?pPw86JFYfa$;XxBM@U>f`@YAUy6qY0Nut6fII65X_TEhthkrzq13@=YDN^k z+EwDa`XSb^@7h(OyBrLTFhUKl*ufa;>A07=p};}e;5%_71h#+p&_ZVMjmV9OjZtO~ zg;9CNh2Uo4jWlNIja7OJQQ)R4iL55&*sfzvhH;B4x^)M-IC2Zu6y0kiJ6;1#o`H*O zSznQhEtv$QPu3-Tqpf>pFO9b zMc=l#>UeCzLAI4s7U!$4^u=%XF8*_0?V27U&!(Kii^4V8`w)qUx)HHag71_2SDG@_ zOdY_JWl4(o=Wx`KJR|vg*eBQgCHX(YAJfa71QWixAK;9S!M9&yftwm1!=HVILB4r6 zygLaTSt4GM1MI;PbMA;2xTsr(PhIfPBxGddyHGs;(9oA(0>Z*Wkc1x{<;CSC?>i-vU%H>ZpHI5D`=7SM zxINa-*;!mJ?uP2EmN6{`C(#$Stq;*z*(avIH@x4o@jG1IEgyF5iH)$J(-|c>nSc4a zH7L82M0g<&$FVJ$ZpDK0N(8VX`%IL*R8earKA8ZjB*W$??5v7saN-ybN6!Ulj#iCc z8{-LBtDuuG-``E{XrA#u5k3pZ~L6B1i_OosU7i-WP7@H0iI&dLDndYX(Rn2si^E&#nV-!p%Pdu z2Ja4_7^scnMep4_bOu$hUSMU4~D z>g8flA@qa@XNv;g1ZgK{CIro_)#90T&YLKpcY#@{-)vuwE```hZ~*FAL9u7qu(B9I zQVJ!6lJLYFicZjsc&r{;NO4I7bH9E-L$OM&yrWN~e!KQ7^5X)^)Om=u(^8uly?+~z zwWQ5b0{h)jW+BE>>q!mxOlZfo3KJWRQ-Y_GDcDPgfTeSjU`aVCQWl5An1zW8R>>xx zT;Tiyz(U<>?QjDluqIpo9ErfnhTm@|*aOVdhszY_{ca_6B9zNuKHn5(tw2y<&a{)8 z4RoNAi`-q0pL`~NmHo*yZq4FqU{_r*EqADp%_CmUGbmzE7XUp{ODum_2ml)#uj?J! z3K~F6z<}e&5agE3e*JA37)hM1Tp}5-5H;bNm@#S+xR_TT$~P;$Evo6P4noG!(p31~ zFe~?aD_MZ)N2Y?ztUV7h`K8UHA6--gmbxivjJv1Vex05$z7s=BIiOHTO_X$k#&cv1 zS|GlV+&pF(+OU&dJ({MfT&bMQRnyic4b;N@4<_xXkO|kas6th=%CgyE0xi_N*zA6} zo|k@u1i;mGZJvrBcjwpPZFsAt6i#sq*m1HTQcGg537?eO9}sm&zI)m=8SNy~Fbkt5 zpkFTTf1(=)fWD?+_N4W{d(%%tOr)VpV^;w!f#Sz>iQ~#RtpkD3+jm8Dy?x37g07{~ z$>Is+FqD%sUMojKbv)FM0UF_DHIav|EW5Tka`RIZ7u3~=m8zv?G}JTK`GQTpmFe(O zqwb=LC5jd{Arqg-+u}tyR?Fn?bL-^mm{cd1H*&ABST_Tg+&q zBZVT81MU3na?|<^4MSmARuDL0jU|dT_q0>=!RV-IWgHZ`KP6B%U{qWGh0r_c*rh7w{aNmbIwN68Ts5NVxyirsgb(2lutY}-QC!zfv}rC`(G-Dju|g0iS-xT)(c zyN|c^)ytQU+bWWkXdU`)XR|W~`_YV4tg5b$4?9MACB1TZQ~v9z!Pt%SSvbcUZZPl~Re^lBy`WRz$xlOQz_aCC+s2tuy>e-Yxvq zHTC&*%J3G4(i2TpJAv}&K%gC{Bx3p`e!zSUJP$_E4puvI(GHFWUbfmp?!g?ScPXed z2n^r+tuUHTrI0;}$IqW_<`d+XWSh=^m!8WWvy|jNni{?^FWzFV?=8r`6a|~+-cnu7 zr@0wKNtxz7${x(GmG0Fv?K#RV^+cX?m%ml1X!9#SU$5|53!V+UH|bqG6_;M#5IVnCDH`j++eyjq0`LUM>x=oq}HsoK5n>|S_ zo~aIQm0y@y1v+tb8-`0PXDxS@cqPyXW_h(E=+q6LIhCG3t2}th-@4?xfOYFNoa5EIJZ zcTnClkbcXG@KzswSB;Vc(P_x^5IPdilLu1Mo|=)9j2^-&tH7Z_8Q8 z?>YvMe$3}6+Ciy+FE@in@{xan%i`CiVzp+75kU?oxw(m!jFs$i1-WPNP35QctS3)` zRrwaqZJTA3QOVajH5MLX=1UQ+yv7g7^HwaYVAp2J2#4)(POL>s;|>xu6SdqO3Q{+v zNiy2i73-?CoSG|%P0{)1S%Ou?%}0#XQ!~5@i_QHv9DK_1rrszkf%w4lO*UxhQ_bZ` zCv<=RSf45@n{&3{mr8Gyt-1F0H+|KU9`N9ws5JKbXsbB=+9Wy_Dz*Jn3G3w&v@#4f zH~QkY$2lWB2pU07#l_0Hl2`59H zwaUj+wx`FLiwny*s`{yvZvlhT7RS_;h?6ly`(V*ZGvVe}IfwA-IXq;+7?!{GL;od6 z7E3?H5<7GYY`TK-KfmTG8#Ye^6EPE8JN^B-y#y)Ka-3l^|D2%^Gnj@|)?ld=h6V7I zVLR^utm(~RyF+@D_9*OwMexsF)^N)bdA!Lehs|qC<+uvt&<4JdX!A%q^2rzq&A)pU zWiLSXnmWh#{T-n?Z$7{&P}t8*OBjSgn^+kFcO5(B6tytGb6xIu|V*|(DQQhBc}aoprr++P*L_cd(6UMFr5%* zWV)pD)L+A|>tNnf*%`|eQLAsxI;3w9HG$pct{xlJH|tN;TZZj3VlD2{Ydj0AvQsBF z59xI$Y*yL&EYB%9TF??ixNBqz{3s8C+dVYLLLJ1y;rznCg(Wm5Lz-S1ukmhP3BGXL zItBM-i3IpT1PhVw6m^AOK)ps$ZD<*3f9cvi038rJoF5Yne~w~qWztW-N!lPpLdMax zxkuh1-5ayX(i4dKOicYg0DBG3kct$Gt@)9FIQYwbc1#s17FV*#J>~}IzCN`OITBaX z_R4txeRyHh-S+}=ADLl_T{6nH$vyI7V8ewi5;5dur5cK6h%&3inW*bV?IYBrd|g?~ zwwHggDyhM8-%5v4CO8bL(i4nkM96`gdth)tQkMbrQk2j zz(lqB91TFZ6x<$QI8=4rp23f&@?{)D;Pm3>vtx!M4BRq3`hKq55lLQK2n^phX2zY$E|7qbk}ifoS;sNg*iDviPqBRq8Q6M#u&@^ z>f&8q7(RRIqmvD>?sL@Kx1;^pVi+(4>J%PEd53X9^@-zQ&)gMp_8j7d70Ggek6|F34=|0&q#iNAb}{zx3H zqyKL|e$4;%e0+3z z9)EM3AJ5U;QPb?wgZIQ_t<16^xwqHS*S}mnYW<_(C%emsTpY#OEUD1^3AJ(LavAS& zY8YHalbH}Zgg!H}+&n!FJLpm0U?V~>z_J=nVyWe)C*k2zElYtAcGG5US-4lD%Wi0W zl)k0c#QsabAyAEz^-0UJvV+!B`A-_lT*HWRKR0eZwTpVvJOP1}A=l%)DML@T1F822 zL36ADN=s%UCgcXPR&C3a&0MO-(s6g9Dawm=8ml=j4aM8O3i3 zEB4rC^v&d!EBlOjjIeQU0t+yQB8`5XkX1d7ylkBz-~`!4V~Or!G__&$jy)#JWJPn} z$r0rYcR(z|4Xfq-*g?3hDx@`L`lxecL8x%-D#;dJ=zg7dPU8zn?^Lk@_b<62>3aX7 z3j+8nD40H1%Vx|`2ytd}gzDWX`y#=7-Vh{t)RAiIBjK>{m2k^cXT@5fSkYF0d#I^i zyT!)OYDyd6EQo6bkt`sLrXx^*WeONIakl{|n{wuhOUbQq%urNsgEgfg2@&Tuz)X$2s3G2JbPjVGP`DzpD;BcoK8|7D=8C4` znJP%D%zF1cxuR;^Z#Jg)Y<8{>Xn(hCsAGs>)wVv}#g_vht8-70v&04+(} z+a?443k!r74TexG_$6oUwceFV!d)kVK=5m}y!0@^azJI@rKD-cb*UehWag7lH?A zy3+A2QjuGpbUgO7<7$#UVI08~R{Er=87{(Wvd5J7b(-4B$z97H9AfADXM(z=(eM9BVu-g zBLYg#dP)OWXlVyM%<=WHB9wnA#ryC)~V*m?MZ>KoRACjCC{XZLU~ z3Dn>V*1e$NshANTQ)*g(X3Rg{Z5eyTn7X!zW-lvoDOd=FDZc^1B(>M1Rgede*2Z zDgB4QU&v+Y%u6mYyfh9x|H|fJU!8GmRnHOSHsDNwc=H!<}<0JSR?K%EBQWP!Fz z6-@A-MBZJq4s+Q?y2cP~6MKkLwM+X%g+$R3FzCF>A0!bn>AczxBt@J`S_4+)Cs`2F? z10yv3XvAb5zxkKXP@fX%?zV?4I&8PbsX>1IV&FT6 zLh-4A)KGa6qkeXy05ty4KOi7}>46+bsS;}0IRfw^6ym`9Spw1p@!&r=LlCSd)kL^ zj{{Y@Tse5l_HwP|zrA2+@$xioxJsm+mo_i5EyJ7@tP z50ONBB2L;PUfsTV2i&{3oCI%MI9-hj#~db2q>xz&kTwQ|FH$5Qvt zd}+BxN$@8-i2R#1-1jG0=o`99Ap!^uloJ*f0R-+6q6kZ#5|SqFr*Zr+E4z7ojd%Wo za69(8j^Ax^?pxLN#Kd&Df|j9*=ZWYG57KVgcDdn!6+l8K-tv6jukP~nUwAUju3)57 zqF4VUa?_;$tto<07HHa+4xDDm5NAX~5JCy3f>@}Z*Q)n76>6A=#PNXxlTuAHtW~Kh zu&C~jOTFF}|E4@8TZwX&_eJCJuG#d3?EC%%S2ZjlF9-?Fi5Sxj zwq3zRKe*No;^_|P4qh}`%r~>dLwvGv=D2OtMtN)DE^E8@d?k#bdiqmLpNzF3vX*46O?wLoX2t+MCFmLYV}49PBpHs^{LiB>*}cxrb;mv zf&Mh+*r;)og!*U<+UV+o2LQ_szzOkL$Za4rpMWN-Ey4l->_!VO9L_=^44^>0oVA`; zPu_WICUm@MR7J6<#lejTF*s-zV9SOAw@Kv*4Mu61Qhaxg$l^Nr!ntdP;C;e)Oa@#C z*IqSa!BfUH64-i=rm;Of&WvVVgU8=<%3vmU+DbawU?iU;iUmR3k5ENiLjrMwP&`&= zLZf6;P7yLVLJi-w9x~z&j{3K}7KNb9sTC}$mDk3(G?&&b?zbt*#r)%?Rnf+@9___z zo?5Zwmbi~b6aJd?JtLwqq2Q&31nTE0fg(Num#G3lP+8g;st|Fi$?Y}EG$B)?WOmU* zADQg>2p+$YtKFP4OH-YT=-nPFZg3S^dD9er>K&toWb#l^U>4Fw;$o?ue2=K*5N>g; zTfH2qcQKD&W8J11wUU%6$%50yf?FgX+*hh~ zU@!a*3AO@)pMvoWx6Z?Z=~#v<`jEmFjS676C%gTjyI{04LhLJhG?GxX?py+Rjk;@; zP_&)YS0ASNGbB$#SKkGTwyF`9hnCL9dm?dn35uQCm=~(k@)~@wC#sA!$LVEv)ADnK zzXYrGDe~9VRJr%doTd!o&;2ycT$#E_7C4f>Fk_>CU+i5A>Iq(Zmq{rwK_`a_Csyq7 zKuQfJz>q$Tuj%x9{Al7SY}6W~(1FVp5k=z1wWeU{Nsjy(9!uwzMBO5bGulW&!dIhU zkyeq0D2R&FvpNztTswsFA_$r(h&oCjQ4BF*lV*|0z}e`udOn?+Xo=EhV{FmQ0_yCn zi>2FOUU=z4(uBU8@{Ppd6rDHy>V`X2G6XkwovTd(bj;Ke#$WmjfW-5db#i1q9)llD z{W%Z=@aUa79YhkfgPazWdXSa9)hqKvD1B1(LqO;7cN`RMtyFC(7oICZsV3Z-2U?21 zQ1>?hybyTOfAM&X1l!?DAZqxMOAOHEo_i=fm6jEp4WpI4p{!?-?M;}u1~+<+a&k+} zBUTNVCIst>wE6|s1M?N3TH=3UyI;MVy$C8iwJLXoD)9u~o&Y|Ou5|vae-5vIf|q$< zDYGS%@2rb!3C`b8Zwb!(Zu}@x)O>>N83R7h_Eb=Of>XZYJ0D*IQZpwcJjUA_qnJO? z`>Dj;(Dsr5+`+f10Pg5pN)(@{n6`AAm6>E*4|oZ_`bUj;g62ogcwTp)EEtKBZlRKN zryiVvg{Yrf2y-z+xgOZ0_i$L7Y!ZJP2YxJ*rbCe80(cMbvgWZtBJ5vCyukI-cBvp0 zKWYf9lI%S|F`<0HAM}p3co`QYE)0y!UjcYb%6^@7&(!GwBnVrS=7KB^bY~w%wl_*( zmrP6{u_IR)6dVCwpjXoi&KBP55;y3c7x0fdeVVp~&oKSE3!dP6(g5zzTELzslr7mF zAM&;!9eQ9({4HqYoV5{JcQZqKR^j`O$QIXWrN$PQgh&7IGh3me*zB#X#8Sy+Q^#qQ zLCu!*d_wZJ$o#ij3C3xczy1e4bPs>dzgf$n?e>(fZoRWDz-LcU5BXUE9dTEP%^Kz% zk8iFjYbAp*xQq#xLjUu-Or z0~Zm$Ong_vb5d7~>XP!-k|Ik%9Afw9-kEC6w(?Dv$5Z*E_j0z3SzMVGL&CI0+~<%W zCs!Ve$H9RHbJ8?MmLP472y|={lg7YqZq}GtR6wGdv*&J3(USEH1`7*MF-^{R@rcx# zS6%F6p_pQkAX)Zck3@@_T{V?o=<;o?zMB{Vn8*Wm2YWWvA4~Yx%naUYkQ~$XCNXqO7ZT=FxRwEsmw(3WpE(XRx(quSG@R^Yqp5`=3hVzh9#};2>qw$&SB25b zmXzR!QBs}FkS(k^#g)ShKLytLU=0v^(v9%y*x_YoMQVQ9Z_}bR*$4;{lJ^ndk|^O5 zmv6rhNr4*LvE!5hslDBH|>?T_KDopvS*~I z)AvFX0j!M=N)x~j?3=@;)h8HG8AEMDLdyvoBAPLVdf2M~DwPLd$otLpcajXy2gVcR zPVHc-vI<%xOl^1eqvyqac?zt`e@^N(Py^l?i>DeyPX21I!b?O5RK*d0T;eaRL%5z? zT}UEKn8@n()s4jeUQI7>v5<_|C&J2r34B%%T(K`^7vzRR{U;}wnTbb4fYQ&|K~E$R zl%358Nv2rf1;C;_PZqT=Zf6X+_nazOAZ4FPvLU+?OqcC9$nvjfLcjV=p2qdVYck@b zV~XF2imVb6Zu}K9dWP zbxe_B1`KMEIXUcd%kC$8qvwuHJ^4`hnotWjZAfibQ}S$Sw$j)TuTB4N2>bBW*Up5b zq`mAfz)U~%5Q#*XG}xn7-hGICef3;q0S&7ASvJI&jEkt{F(k^wDOon~kHpd(3XTZb z)g_i$SnGBes$V>#d}iXJKS6tleVZ(&&3N#-A6TSWmB=##so624JVl`niZHjh<#sgBy9Q)CLqITY3@=N5hX77rVl zq(u@9>5yJgiN2JE>l%tWo8^M7o-dulINU&qg2fsC1n?M^*qZ`pVBXSR;z)qN1v)8k zYWr7&aN>~n@We|R&+!OIYQ@`}BOsHiKXGO!DA{k;(IgUO+_oJSxhlqGwy+P76j_Z0 zC6Mjs0l1pku5WBhFA%ostQrLiO+VKQwR5!rWekE9A`)l~QiNA|q_xp)7xKlZ2x%SR- zp~aRi25HfZYYvQso`+g7Cgv)J-jy>`pwMRvMX#L^Lzz27W5Tj#_i@svlG5|S=RQlwbZBS; zrw)ogYIZVG)1pE9$J#yJYrW!SN?jd6*;hP02RTb~d=A}zCA$hAg?0h?Qrb`2!vCoF%5CEeF z9PM$->=Zy}aF4t)lqvWLNBqQz?aWI;_D1aUh?j*UDTfk(#HqYwKw!8Ym3|A$Zp~$N zIuvQ^Rr^_(l{k`!dk2TE1NqvOa@yi~eUW+EyIC>h;@F(}pLVrqRuO3EG_a4s1$AIT z{6V+dwB^4%Y?UscK65e;Ag8*vs6^A+EtqprNij7V#i9U8buIlm7+#!#a2S9Rh!nRJxa}1)J(0? z5;aTO7{$+X&hPm>iBr#!bMi;d$$h^*_kQnx-_N}-erd<|!pmo`7}jJny`wN~F-k`W z;?>9+cygJt2jyP9Tb6Amumjm^MjmD_9?a;f8wxBYqIMN6GPAfr>2Nhchaw>NxkM(1 zT;hLVpUQ&bT{rX?-|*`+K^*Kn-ZS29Aio0aTVtRb5|7F81$W-i$eyJF>+YvxORrRY z)!odojm(sb^Ek~dsBan|s`nM%J2Pakdi~des*v{edgSya7b%Km&>%#+GWfn}rD<;< z2fy}>Or&%3J;T&<4k5{UAKu-v7TzvFKC6m;)fJql7sbe>`7w%21ut<5mGes5 z!8!*z(}T%`(5%>7N# z%^L})^Mu2@LZ7KGa7?Ua_-4fVRJ6Ai`FvPyasnw+BzLB1WCa?aU*uAn3DyEcE$IQq zmD~AI->0h?hbS6>@~|&kRBQ|DxO7}~QhzlWl+}qkCY(9#l~y#aI`MWUC7Vk={rP1_ z+HYzR{+}@(D(cy{Oa23AsSTbPj$b|dCQG;O@r-odY!41j!P}G-s5r1H+})Hm;F2?2 z4D(m!bwf|7A>C4+GWGu$Lhdo|T4~Lf=0P$B-r~(4y9rFY8Pb#iCW>zNN;1?S$b8OE zyHeFBkp+Dv^TJI4Q8|S3(*ZGaS`3>s6hQlCkyC4wRQ_SK{#jjH92wg(ZS}3^OD|0G zajmI#?130O6Lo{VVImZhFD}fUdH|xBYzw9~6q{#d*g)x421VHb^0M(4Wb#~ zF=Vl_)3j6(&CXujd>8~w1NljnG6Pa+kb`*nGzpJ2Vw zl}3q0cUU1yQTdcmC9qB9r{CeRs3N&FWjki}f>Eo)xWyPz*b;K7qV{$qYd;s{1i4g# z-$N>iEH$I(SRQfAYW#E+YO!#sk0-_zPrbJig;FHH^-|;KPDh^?PEuF-nHQ~JqOBmz z075Awpa9;YV@Jpj18Q}YUpc+zoG9Q@#Ur+<0vZ~U<+A2*CjVhcS21UTdF7}1rUq@!x!9gkcwsKGLHMX%h^ zZ0CMtvudc>K1(JqF>lpwf>;rW=GeUQ-AA;89Y;Z@7BrHO1o>F%PwQ9O>QejxPL88` zE)H)Z4_ge4;-^Jw>;#ifbiFT2S}ZnphTdl8#ze>jTIRjZ^{3@)cLMRV3JnCFR-OOU zE0S_jM9~%~9~h~`JZ&QdKE$I}2GAcs6tr%53rIkCb5o77{!d zfhb4=yy{vxt2!iOmCqnX4Hx|=${4S-x_@^m$Ze%UY+hda2W@)|O~9*!%a4BRwAU~P zjOk&NwX<8R0xP46Z@qqdLLR#vV_T#JN%V7)vde1s27wbNAmA9bZSN~}<`~7+p3N7n z>268{m71c+4hYjILSIPQT4+kGO}8=BZf7^$ZbvQi38+YtB?zUFy~8R|%W~O`93#^D zYd=5z1*Z(5N2F&r!FD`2&?vr+cNb|C*~j+dwa2@UZBK-7oVrQjVc6xb z9e-xxS5u2=HFGdXc!v+Ut5e*)$0oiLJ)%99J?p&XA_OJhf{1k};1$_j%tQ7HjN5|{ z?E98|QTrTEJ@L1kznE*^;Xv*O6nF2l@UiV*cz@~A(nnRL$`o}!d7n?oV?RLUECFINkTKYuum^V52!Ed7YWStBCNEcT#k#J( zqiyCcI~J*0pj~hDvtcyK)u7ORd|3=;=JP74L=@L2cB8|^5N|%%|L}UguMxr$S1jL? z(CGPNeZ~08`Uc~WqreG*cN{D%=rhC5{DN|-1_L2#6eB_>)yiT+O>8`LN~p7vBllrX z{Mn6w0-5N^h@|B>(a@p*#jN@PvuIl{dTC+ z(ir=f&v_OzJ4R^EfG1(lmqGHy+{sL~K0$)LY!(JmtT<3il7Ibm+U;|(%oD$5hA#31 z=p*8Hx;j@jr3%A}I0}Q~$DRTW?Y?&cd$g9xzTcAl{(6R1_r_$`46T9IqTOZ|{eJM8 zY|MlE{_;YC4}}`B&R3fZY-{G4K^xq78uU01XbPL-7Fsw=wX0uaAzWbLNdRxU#H>d9 zkO{@#ZDdh<-cj$P?!PQ--l#w}JZGTTnyHy>cfXEq*xLk@&)4s>Fv&gd2QOj_8=)KM zt7F4EhPC_QXG)t!171#veY%qE5X~3f9=jm09WVQ{RxcA^*1N-oPvzFban#tz*W_Fg z*}9cym!Gz`zLImHNXy}ax@<&a^SC=;Tqc)qm}y~0<5XY^GCGxMI0z+N0yr`EjLy#j zQ5=5V_rqeIIrh857g)y9CGo|6}55*J~d2Awzvzu;X8Oqv2E^l!8X(H10 zHd0}Tiy87Tzrl=9oSrk3+6FrLD`O|AgtaMzW${tZcx0BLo!(C=ZB@%_{Dq=9&|xVy z@5z+38*a?rlfQx8;$PYps1Ax}$0NDT7eQakuRQiamGSKks>0?Zv}ay6x0}>kdAqG&jt%!M`YBS%G_xfq8#H!bU*}S^Z)u3aev`y=R$O5( zPed~h^(BmYzVK(fWLchj&g>MV?k!=&bzrN~SQ5->z!Yr1VN9up?x_DZ+ZR#&LOP|J zj`L2d%d$$tu*R>zXOf%gzV^}!RZmcD&@p=bUO7MG;<(0>FVY99Lo{(~ja^Gk-ay_- zn`F-)0)ZWHUO{teZCMA5r+>^Q97(^Hj`=3<@@dK zMhbehBB}UMlJB+ti+kNyjRBc+RxorcZ(Gj#)z~lc8>|e=Ere7T@i`0-w&_il@|MD- zu%8#!i&jOwiF2585N>Y~EH!(!o=qKDeuim#+#G3Az5lYJe_>knlipX!ms-WX^4nzQ zx0s6F7uLUAtJbMV09GV?W|PV(l)E5D$8+vElZ~wQ1d@^0xbB#uI72z|A^Ks2;W0t$+}jWP$T}AFNqAA zFjJ^+=nw1(`NJP7e(Ak`PxN2n8NAd4No|tSfMggYM(fs(H2v;Iz5{&3!A&WsI`QoG9p)#(EDn z7hFl%^mCsH^;drk895!`&lX4;0PTS|j`(8_y=&v;3_Gy3Q34KL5CRSiVn+{WCK;}H z@bABe!)!bpps>I6kH?7NCW-O>L(G9x&I=BKE65!$ke?*5>0bj~ZD9Ajp`^KNfPWf_ zrc8u0{m%dZ*7^W|7)dVEfvN8BeE%u*f4O#^FfUtADOj|CUSS{yawVNs{DnqGVzRC{Ymc+LGEoiMQf=qM(0VphPi8?PwN~dfp5DGt+}d z^S4rwD2KQlQkf!gIn=^`$oX5XNR)O|Riw}L(Vx-|>kUcv3vrdCqD0~(_Ly1MTO3h7lr z#1w}+$Dtg$IOqrp>4|P)im=6TD2L8>A3-5KM@CHHus;sv(5bQ`D5Q<*#1tOq<4_K@ ztsg-l?Fc2NaJe6ca;QJ_2nuOO4KYO>ejLi7{+c5wq_5?ODUjgfP!7GM`#**9pkwwg Rfh;HBEX{#T7Wvn&{{o3A=Tray literal 0 HcmV?d00001 diff --git a/native/commonizer/build.gradle.kts b/native/commonizer/build.gradle.kts index c9e124ef4b5..fcd6ca29fc2 100644 --- a/native/commonizer/build.gradle.kts +++ b/native/commonizer/build.gradle.kts @@ -16,11 +16,13 @@ configurations { dependencies { embedded(project(":kotlinx-metadata-klib")) { isTransitive = false } embedded(project(":kotlinx-metadata")) { isTransitive = false } + embedded(project(":native:kotlin-klib-commonizer-api")) { isTransitive = false } // N.B. The order of "kotlinx-metadata*" dependencies makes sense for runtime classpath // of the "runCommonizer" task. Please, don't mix them up. compileOnly(project(":kotlinx-metadata-klib")) { isTransitive = false } compileOnly(project(":kotlinx-metadata")) { isTransitive = false } + compileOnly(project(":native:kotlin-klib-commonizer-api")) { isTransitive = false } compileOnly(project(":compiler:cli-common")) compileOnly(project(":compiler:ir.serialization.common")) compileOnly(project(":compiler:frontend")) @@ -38,6 +40,7 @@ dependencies { testImplementation(projectTests(":compiler:tests-common")) testImplementation(project(":kotlinx-metadata-klib")) { isTransitive = false } testImplementation(project(":kotlinx-metadata")) { isTransitive = false } + testImplementation(project(":native:kotlin-klib-commonizer-api")) } val runCommonizer by tasks.registering(JavaExec::class) { diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerParameters.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerParameters.kt index e19779bf7a4..f53a823693d 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerParameters.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerParameters.kt @@ -5,16 +5,19 @@ package org.jetbrains.kotlin.descriptors.commonizer +import org.jetbrains.kotlin.descriptors.commonizer.konan.TargetedNativeManifestDataProvider import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsCollector class CommonizerParameters( + val resultsConsumer: ResultsConsumer, + val manifestDataProvider: TargetedNativeManifestDataProvider, val statsCollector: StatsCollector? = null, val progressLogger: ((String) -> Unit)? = null ) { // use linked hash map to preserve order - private val _targetProviders = LinkedHashMap() + private val _targetProviders = LinkedHashMap() val targetProviders: List get() = _targetProviders.values.toList() - val sharedTarget: SharedTarget get() = SharedTarget(_targetProviders.keys) + val sharedTarget: SharedCommonizerTarget get() = SharedCommonizerTarget(_targetProviders.keys) // common module dependencies (ex: Kotlin stdlib) var dependencyModulesProvider: ModulesProvider? = null @@ -30,14 +33,6 @@ class CommonizerParameters( return this } - private var _resultsConsumer: ResultsConsumer? = null - var resultsConsumer: ResultsConsumer - get() = _resultsConsumer ?: error("Results consumer has not been set") - set(value) { - check(_resultsConsumer == null) - _resultsConsumer = value - } - fun getCommonModuleNames(): Set { if (_targetProviders.size < 2) return emptySet() // too few targets diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTarget.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTarget.kt deleted file mode 100644 index b91271767a6..00000000000 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTarget.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2010-2019 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.descriptors.commonizer - -import org.jetbrains.kotlin.konan.target.KonanTarget - -// N.B. TargetPlatform/SimplePlatform are non exhaustive enough to address both target platforms such as -// JVM, JS and concrete Kotlin/Native targets, e.g. macos_x64, ios_x64, linux_x64. -sealed class CommonizerTarget { - abstract val name: String - abstract val prettyName: String - - fun prettyCommonizedName(sharedTarget: SharedTarget): String = when { - this == sharedTarget -> prettyName - this in sharedTarget.targets -> sharedTarget.targets.joinToString(prefix = "[", postfix = "]") { - if (it == this) "${it.name}(*)" else it.name - } - else -> error("Target $prettyName is not in ${sharedTarget.prettyName}") - } -} - -data class LeafTarget(override val name: String, val konanTarget: KonanTarget? = null) : CommonizerTarget() { - override val prettyName get() = "[$name]" -} - -data class SharedTarget(val targets: Set) : CommonizerTarget() { - init { - require(targets.isNotEmpty()) - } - - override val name get() = targets.joinToString(prefix = "[", postfix = "]") { it.name } - override val prettyName get() = name -} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/KonanDistribution.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/KonanDistribution.kt new file mode 100644 index 00000000000..21ccb614359 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/KonanDistribution.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2020 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.descriptors.commonizer + +import org.jetbrains.kotlin.konan.library.* +import java.io.File + +internal data class KonanDistribution(val root: File) + +internal val KonanDistribution.stdlib: File + get() = root.resolve(konanCommonLibraryPath(KONAN_STDLIB_NAME)) + +internal val KonanDistribution.klibDir: File + get() = root.resolve(KONAN_DISTRIBUTION_KLIB_DIR) + +internal val KonanDistribution.platformLibsDir: File + get() = klibDir.resolve(KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/NativeLibraryLoader.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/NativeLibraryLoader.kt new file mode 100644 index 00000000000..78f88095602 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/NativeLibraryLoader.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2020 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.descriptors.commonizer + +import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataVersion +import org.jetbrains.kotlin.backend.common.serialization.metadata.metadataVersion +import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeLibrary +import org.jetbrains.kotlin.library.ToolingSingleFileKlibResolveStrategy +import org.jetbrains.kotlin.library.resolveSingleFileKlib +import org.jetbrains.kotlin.util.Logger +import java.io.File + +internal fun interface NativeLibraryLoader { + operator fun invoke(file: File): NativeLibrary +} + +internal class DefaultNativeLibraryLoader( + private val logger: Logger +) : NativeLibraryLoader { + override fun invoke(file: File): NativeLibrary { + val library = resolveSingleFileKlib( + libraryFile = org.jetbrains.kotlin.konan.file.File(file.path), + logger = logger, + strategy = ToolingSingleFileKlibResolveStrategy + ) + + if (library.versions.metadataVersion == null) + logger.fatal("Library does not have metadata version specified in manifest: $file") + + val metadataVersion = library.metadataVersion + if (metadataVersion?.isCompatible() != true) + logger.fatal( + """ + Library has incompatible metadata version ${metadataVersion ?: "\"unknown\""}: $file + Please make sure that all libraries passed to commonizer compatible metadata version ${KlibMetadataVersion.INSTANCE} + """.trimIndent() + ) + + return NativeLibrary(library) + } +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/ResultsConsumer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/ResultsConsumer.kt index cf9dfd5db2b..e3826298d8d 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/ResultsConsumer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/ResultsConsumer.kt @@ -5,9 +5,14 @@ package org.jetbrains.kotlin.descriptors.commonizer +import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeSensitiveManifestData import org.jetbrains.kotlin.library.SerializedMetadata import java.io.File +internal fun buildResultsConsumer(init: ResultsConsumerBuilder.() -> Unit): ResultsConsumer { + return ResultsConsumerBuilder().apply(init).build() +} + interface ResultsConsumer { enum class Status { NOTHING_TO_DO, DONE } @@ -18,23 +23,70 @@ interface ResultsConsumer { override val libraryName: String get() = originalLocation.name } - class Commonized(override val libraryName: String, val metadata: SerializedMetadata) : ModuleResult() + class Commonized( + override val libraryName: String, val metadata: SerializedMetadata, val manifest: NativeSensitiveManifestData + ) : ModuleResult() } /** * Consume a single [ModuleResult] for the specified [CommonizerTarget]. */ - fun consume(target: CommonizerTarget, moduleResult: ModuleResult) + fun consume(target: CommonizerTarget, moduleResult: ModuleResult) = Unit /** * Mark the specified [CommonizerTarget] as fully consumed. * It's forbidden to make subsequent [consume] calls for fully consumed targets. */ - fun targetConsumed(target: CommonizerTarget) + fun targetConsumed(target: CommonizerTarget) = Unit /** * Notify that all results have been consumed. * It's forbidden to make any subsequent [consume] and [targetConsumed] calls after this call. */ - fun allConsumed(status: Status) + fun allConsumed(status: Status) = Unit +} + +internal class ResultsConsumerBuilder { + private var resultsConsumer: ResultsConsumer? = null + + infix fun add(consumer: ResultsConsumer) { + val resultsConsumer = this.resultsConsumer + if (resultsConsumer == null) { + this.resultsConsumer = consumer + return + } + this.resultsConsumer = resultsConsumer + consumer + } + + fun build(): ResultsConsumer { + return resultsConsumer ?: object : ResultsConsumer {} + } +} + +operator fun ResultsConsumer.plus(other: ResultsConsumer?): ResultsConsumer { + if (other == null) return this + if (this is CompositeResultsConsumer) { + return CompositeResultsConsumer(consumers + other) + } + return CompositeResultsConsumer(listOf(this, other)) +} + +private class CompositeResultsConsumer(val consumers: List) : ResultsConsumer { + override fun consume(target: CommonizerTarget, moduleResult: ResultsConsumer.ModuleResult) { + consumers.forEach { consumer -> + consumer.consume(target, moduleResult) + } + } + + override fun targetConsumed(target: CommonizerTarget) { + consumers.forEach { consumer -> + consumer.targetConsumed(target) + } + } + + override fun allConsumed(status: ResultsConsumer.Status) { + consumers.forEach { consumer -> + consumer.allConsumed(status) + } + } } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt index 5f0b287a857..1a4343fd6d3 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt @@ -10,7 +10,7 @@ import org.jetbrains.kotlin.library.SerializedMetadata import java.io.File class TargetProvider( - val target: LeafTarget, + val target: LeafCommonizerTarget, val modulesProvider: ModulesProvider, val dependencyModulesProvider: ModulesProvider? ) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/DependencyLibrariesOptionType.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/DependencyLibrariesOptionType.kt new file mode 100644 index 00000000000..6b8dfbc284a --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/DependencyLibrariesOptionType.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer.cli + +internal object DependencyLibrariesOptionType : LibrariesSetOptionType( + mandatory = true, + alias = "dependency-libraries", + description = "';' separated list of klib file paths that can be used as dependency" +) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/InputLibrariesOptionType.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/InputLibrariesOptionType.kt new file mode 100644 index 00000000000..1860655a6aa --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/InputLibrariesOptionType.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer.cli + +internal object InputLibrariesOptionType : LibrariesSetOptionType( + mandatory = true, + alias = "input-libraries", + description = "';' separated list of klib file paths that will get commonized" +) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/LibrariesSetOptionType.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/LibrariesSetOptionType.kt new file mode 100644 index 00000000000..015cace78b5 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/LibrariesSetOptionType.kt @@ -0,0 +1,25 @@ +/* + * Copyright 2010-2020 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.descriptors.commonizer.cli + +import java.io.File + +internal abstract class LibrariesSetOptionType( + mandatory: Boolean, + alias: String, + description: String +) : OptionType>( + mandatory = mandatory, + alias = alias, + description = description +) { + override fun parse(rawValue: String, onError: (reason: String) -> Nothing): Option> { + if (rawValue.isBlank()) { + return Option(this, emptyList()) + } + return Option(this, rawValue.split(";").map(::File)) + } +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/OutputCommonizerTargetOptionType.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/OutputCommonizerTargetOptionType.kt new file mode 100644 index 00000000000..55f052137a0 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/OutputCommonizerTargetOptionType.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2010-2020 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.descriptors.commonizer.cli + +import org.jetbrains.kotlin.descriptors.commonizer.SharedCommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.parseCommonizerTarget + +internal object OutputCommonizerTargetOptionType : OptionType( + alias = "output-commonizer-target", + description = "Shared commonizer target representing the commonized output hierarchy", + mandatory = true +) { + override fun parse(rawValue: String, onError: (reason: String) -> Nothing): Option { + return try { + Option(this, parseCommonizerTarget(rawValue) as SharedCommonizerTarget) + } catch (t: Throwable) { + onError("Failed parsing output-commonizer-target ($rawValue): ${t.message}") + } + } +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/ProgressLogger.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/ProgressLogger.kt new file mode 100644 index 00000000000..90c130f6c39 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/ProgressLogger.kt @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer.cli + +import org.jetbrains.kotlin.util.Logger + +fun Logger.toProgressLogger(): Logger { + return ProgressLogger(this) +} + +private class ProgressLogger(private val logger: Logger) : Logger by logger { + override fun log(message: String) { + logger.log("* $message") + } + + override fun warning(message: String) { + logger.log("* $message") + } +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/StatsTypeOptionType.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/StatsTypeOptionType.kt index be731ff2d18..9cd3fb31477 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/StatsTypeOptionType.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/StatsTypeOptionType.kt @@ -5,7 +5,7 @@ package org.jetbrains.kotlin.descriptors.commonizer.cli -import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeDistributionCommonizer.StatsType +import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsType internal object StatsTypeOptionType : OptionType("log-stats", DESCRIPTION, mandatory = false) { override fun parse(rawValue: String, onError: (reason: String) -> Nothing): Option { diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/TaskType.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/TaskType.kt index c2030f04cb3..d9420f7818c 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/TaskType.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/TaskType.kt @@ -40,7 +40,21 @@ internal enum class TaskType( NativeDistributionOptionType ), ::NativeDistributionListTargets - ); + ), + + NATIVE_KLIB_COMMONIZE( + "native-klib-commonize", + "Commonize any platform-specific libraries", + listOf( + NativeDistributionOptionType, + OutputOptionType, + InputLibrariesOptionType, + DependencyLibrariesOptionType, + OutputCommonizerTargetOptionType, + ), + ::NativeKlibCommonize + ) + ; companion object { fun getByAlias(alias: String) = values().firstOrNull { it.alias == alias } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt index e0ff95e4642..4af1aef8a9f 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt @@ -5,8 +5,20 @@ package org.jetbrains.kotlin.descriptors.commonizer.cli +import org.jetbrains.kotlin.descriptors.commonizer.* +import org.jetbrains.kotlin.descriptors.commonizer.konan.* +import org.jetbrains.kotlin.descriptors.commonizer.konan.CopyUnconsumedModulesAsIsConsumer +import org.jetbrains.kotlin.descriptors.commonizer.konan.CopyStdlibResultsConsumer import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeDistributionCommonizer -import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeDistributionCommonizer.StatsType +import org.jetbrains.kotlin.descriptors.commonizer.konan.ModuleSerializer +import org.jetbrains.kotlin.descriptors.commonizer.repository.* +import org.jetbrains.kotlin.descriptors.commonizer.repository.EmptyRepository +import org.jetbrains.kotlin.descriptors.commonizer.repository.FilesRepository +import org.jetbrains.kotlin.descriptors.commonizer.repository.KonanDistributionRepository +import org.jetbrains.kotlin.descriptors.commonizer.repository.Repository +import org.jetbrains.kotlin.descriptors.commonizer.stats.FileStatsOutput +import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsCollector +import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsType import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_KLIB_DIR import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR import org.jetbrains.kotlin.konan.target.KonanTarget @@ -35,11 +47,52 @@ internal class NativeDistributionListTargets(options: Collection>) : T } } +internal class NativeKlibCommonize(options: Collection>) : Task(options) { + override val category: Category = Category.COMMONIZATION + + override fun execute(logPrefix: String) { + val distribution = KonanDistribution(getMandatory()) + val destination = getMandatory() + val targetLibraries = getMandatory, InputLibrariesOptionType>() + val dependencyLibraries = getMandatory, DependencyLibrariesOptionType>() + val outputCommonizerTarget = getMandatory() + val statsType = getOptional { it == "log-stats" } ?: StatsType.NONE + + val konanTargets = outputCommonizerTarget.konanTargets + val logger = CliLoggerAdapter(2) + val libraryLoader = DefaultNativeLibraryLoader(logger) + val statsCollector = StatsCollector(statsType, outputCommonizerTarget.konanTargets.toList()) + val repository = FilesRepository(targetLibraries.toSet(), libraryLoader) + + val resultsConsumer = buildResultsConsumer { + this add ModuleSerializer(destination, HierarchicalCommonizerOutputLayout) + this add CopyUnconsumedModulesAsIsConsumer( + repository, destination, konanTargets, NativeDistributionCommonizerOutputLayout, logger.toProgressLogger() + ) + this add LoggingResultsConsumer(outputCommonizerTarget, logger.toProgressLogger()) + } + + NativeDistributionCommonizer( + konanDistribution = distribution, + repository = repository, + dependencies = KonanDistributionRepository(distribution, outputCommonizerTarget.konanTargets, libraryLoader) + + FilesRepository(dependencyLibraries.toSet(), libraryLoader), + libraryLoader = libraryLoader, + targets = outputCommonizerTarget.konanTargets.toList(), + resultsConsumer = resultsConsumer, + statsCollector = statsCollector, + logger = logger + ).run() + + statsCollector?.writeTo(FileStatsOutput(destination, statsType.name.toLowerCase())) + } +} + internal class NativeDistributionCommonize(options: Collection>) : Task(options) { override val category get() = Category.COMMONIZATION override fun execute(logPrefix: String) { - val distribution = getMandatory() + val distribution = KonanDistribution(getMandatory()) val destination = getMandatory() val targets = getMandatory, NativeTargetsOptionType>() @@ -47,35 +100,43 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas val copyEndorsedLibs = getOptional { it == "copy-endorsed-libs" } ?: false val statsType = getOptional { it == "log-stats" } ?: StatsType.NONE - val targetNames = targets.joinToString { "[${it.name}]" } - val descriptionSuffix = estimateLibrariesCount(distribution, targets)?.let { " ($it items)" } ?: "" - val description = "${logPrefix}Preparing commonized Kotlin/Native libraries for targets $targetNames$descriptionSuffix" + val logger = CliLoggerAdapter(2) + val libraryLoader = DefaultNativeLibraryLoader(logger) + val repository = KonanDistributionRepository(distribution, targets.toSet(), libraryLoader) + val statsCollector = StatsCollector(statsType, targets.toList()) + val resultsConsumer = buildResultsConsumer { + this add ModuleSerializer(destination, NativeDistributionCommonizerOutputLayout) + this add CopyUnconsumedModulesAsIsConsumer( + repository, destination, targets.toSet(), NativeDistributionCommonizerOutputLayout, logger.toProgressLogger() + ) + if (copyStdlib) this add CopyStdlibResultsConsumer(distribution, destination, logger.toProgressLogger()) + if (copyEndorsedLibs) this add CopyEndorsedLibrairesResultsConsumer(distribution, destination, logger.toProgressLogger()) + this add LoggingResultsConsumer(SharedCommonizerTarget(targets), logger.toProgressLogger()) + } + + val targetNames = targets.joinToString { "[${it.name}]" } + val descriptionSuffix = estimateLibrariesCount(repository, targets).let { " ($it items)" } + val description = "${logPrefix}Preparing commonized Kotlin/Native libraries for targets $targetNames$descriptionSuffix" println(description) NativeDistributionCommonizer( - repository = distribution, + repository = repository, + konanDistribution = distribution, + dependencies = EmptyRepository, + libraryLoader = libraryLoader, targets = targets, - destination = destination, - copyStdlib = copyStdlib, - copyEndorsedLibs = copyEndorsedLibs, - statsType = statsType, - logger = CliLoggerAdapter(2) + resultsConsumer = resultsConsumer, + statsCollector = statsCollector, + logger = logger ).run() println("$description: Done") } companion object { - private fun estimateLibrariesCount(distribution: File, targets: List): Int? { - val targetNames = targets.map { it.name } - return distribution.resolve(KONAN_DISTRIBUTION_KLIB_DIR) - .resolve(KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR) - .listFiles() - ?.filter { it.name in targetNames } - ?.mapNotNull { it.listFiles() } - ?.flatMap { it.toList() } - ?.size + private fun estimateLibrariesCount(repository: Repository, targets: List): Int { + return targets.flatMap { repository.getLibraries(LeafCommonizerTarget(it)) }.count() } } } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/RootCommonizer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/RootCommonizer.kt index 6a684c9272a..a7bdcb64079 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/RootCommonizer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/RootCommonizer.kt @@ -5,24 +5,24 @@ package org.jetbrains.kotlin.descriptors.commonizer.core -import org.jetbrains.kotlin.descriptors.commonizer.LeafTarget -import org.jetbrains.kotlin.descriptors.commonizer.SharedTarget +import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.SharedCommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.cir.CirRoot import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirRootFactory class RootCommonizer : AbstractStandardCommonizer() { - private val leafTargets = mutableSetOf() + private val leafTargets = mutableSetOf() override fun commonizationResult() = CirRootFactory.create( - target = SharedTarget(leafTargets) + target = SharedCommonizerTarget(leafTargets) ) override fun initialize(first: CirRoot) { - leafTargets += first.target as LeafTarget + leafTargets += first.target as LeafCommonizerTarget } override fun doCommonizeWith(next: CirRoot): Boolean { - leafTargets += next.target as LeafTarget + leafTargets += next.target as LeafCommonizerTarget return true } } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt index fcb7eca39a3..e85620ef3c0 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt @@ -67,11 +67,11 @@ private fun serializeTarget(mergeResult: CirTreeMergeResult, targetIndex: Int, p val serializedMetadata = with(metadataModule.write(KLIB_FRAGMENT_WRITE_STRATEGY)) { SerializedMetadata(header, fragments, fragmentNames) } - - parameters.resultsConsumer.consume(target, ModuleResult.Commonized(libraryName, serializedMetadata)) + val manifestData = parameters.manifestDataProvider.getManifest(target, libraryName) + parameters.resultsConsumer.consume(target, ModuleResult.Commonized(libraryName, serializedMetadata, manifestData)) } - if (target is LeafTarget) { + if (target is LeafCommonizerTarget) { mergeResult.missingModuleInfos.getValue(target).forEach { parameters.resultsConsumer.consume(target, ModuleResult.Missing(it.originalLocation)) } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyLibrariesFromKonanDistributionResultsConsumer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyLibrariesFromKonanDistributionResultsConsumer.kt new file mode 100644 index 00000000000..23f4002c501 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyLibrariesFromKonanDistributionResultsConsumer.kt @@ -0,0 +1,62 @@ +/* + * Copyright 2010-2021 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("FunctionName") + +package org.jetbrains.kotlin.descriptors.commonizer.konan + +import org.jetbrains.kotlin.descriptors.commonizer.KonanDistribution +import org.jetbrains.kotlin.descriptors.commonizer.ResultsConsumer +import org.jetbrains.kotlin.descriptors.commonizer.klibDir +import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_COMMON_LIBS_DIR +import org.jetbrains.kotlin.konan.library.KONAN_STDLIB_NAME +import org.jetbrains.kotlin.util.Logger +import java.io.File + +internal fun CopyStdlibResultsConsumer( + konanDistribution: KonanDistribution, + destination: File, + logger: Logger +): ResultsConsumer { + return CopyLibrariesFromKonanDistributionResultsConsumer( + konanDistribution, + destination, + invokeWhenCopied = { logger.log("Copied standard library") }, + copyFileIf = { file -> file.endsWith(KONAN_STDLIB_NAME) } + ) +} + +internal fun CopyEndorsedLibrairesResultsConsumer( + konanDistribution: KonanDistribution, + destination: File, + logger: Logger +): ResultsConsumer { + return CopyLibrariesFromKonanDistributionResultsConsumer( + konanDistribution, + destination, + invokeWhenCopied = { logger.log("Copied endorsed libraries") }, + copyFileIf = { file -> !file.endsWith(KONAN_STDLIB_NAME) } + ) +} + +private class CopyLibrariesFromKonanDistributionResultsConsumer( + private val konanDistribution: KonanDistribution, + private val destination: File, + private val invokeWhenCopied: () -> Unit = {}, + private val copyFileIf: (File) -> Boolean = { true } +) : ResultsConsumer { + override fun allConsumed(status: ResultsConsumer.Status) { + konanDistribution.klibDir + .resolve(KONAN_DISTRIBUTION_COMMON_LIBS_DIR) + .listFiles().orEmpty() + .filter { it.isDirectory } + .filterNot(copyFileIf) + .forEach { libraryOrigin -> + val libraryDestination = destination.resolve(KONAN_DISTRIBUTION_COMMON_LIBS_DIR).resolve(libraryOrigin.name) + libraryOrigin.copyRecursively(libraryDestination) + } + invokeWhenCopied() + } +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyUnconsumedModulesAsIsConsumer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyUnconsumedModulesAsIsConsumer.kt new file mode 100644 index 00000000000..ce804095e4d --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyUnconsumedModulesAsIsConsumer.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer.konan + +import org.jetbrains.kotlin.descriptors.commonizer.* +import org.jetbrains.kotlin.descriptors.commonizer.repository.Repository +import org.jetbrains.kotlin.konan.target.KonanTarget +import org.jetbrains.kotlin.util.Logger +import java.io.File + +internal class CopyUnconsumedModulesAsIsConsumer( + private val repository: Repository, + private val destination: File, + private val targets: Set, + private val outputLayout: CommonizerOutputLayout, + private val logger: Logger? = null +) : ResultsConsumer { + + private val consumedTargets = mutableSetOf() + + override fun targetConsumed(target: CommonizerTarget) { + if (target is LeafCommonizerTarget) { + consumedTargets.add(target.konanTarget) + } + } + + override fun allConsumed(status: ResultsConsumer.Status) { + when (status) { + ResultsConsumer.Status.NOTHING_TO_DO -> targets.forEach(::copyTargetAsIs) + ResultsConsumer.Status.DONE -> targets.minus(consumedTargets).forEach(::copyTargetAsIs) + } + } + + private fun copyTargetAsIs(target: KonanTarget) { + val commonizerTarget = CommonizerTarget(target) + val libraries = repository.getLibraries(commonizerTarget) + val librariesDestination = outputLayout.getTargetDirectory(destination, commonizerTarget) + librariesDestination.mkdirs() // always create an empty directory even if there is nothing to copy + libraries.map { it.library.libraryFile.absolutePath }.map(::File).forEach { libraryFile -> + libraryFile.copyRecursively(destination.resolve(libraryFile.name)) + } + + logger?.log("Copied ${libraries.size} libraries for ${commonizerTarget.prettyName}") + } +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LoggingResultsConsumer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LoggingResultsConsumer.kt new file mode 100644 index 00000000000..b8c800740a9 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LoggingResultsConsumer.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer.konan + +import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.ResultsConsumer +import org.jetbrains.kotlin.descriptors.commonizer.SharedCommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.prettyName +import org.jetbrains.kotlin.util.Logger + +internal class LoggingResultsConsumer( + private val outputCommonizerTarget: SharedCommonizerTarget, private val logger: Logger +) : ResultsConsumer { + override fun targetConsumed(target: CommonizerTarget) { + logger.log("Written libraries for ${outputCommonizerTarget.prettyName(target)}") + } +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/ModuleSerializer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/ModuleSerializer.kt new file mode 100644 index 00000000000..19ec275bdc3 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/ModuleSerializer.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer.konan + +import org.jetbrains.kotlin.descriptors.commonizer.* +import org.jetbrains.kotlin.library.SerializedMetadata +import org.jetbrains.kotlin.library.impl.BaseWriterImpl +import org.jetbrains.kotlin.library.impl.BuiltInsPlatform +import org.jetbrains.kotlin.library.impl.KotlinLibraryLayoutForWriter +import org.jetbrains.kotlin.library.impl.KotlinLibraryWriterImpl +import org.jetbrains.kotlin.util.Logger +import java.io.File + +internal class ModuleSerializer( + private val destination: File, + private val outputLayout: CommonizerOutputLayout, +) : ResultsConsumer { + override fun consume(target: CommonizerTarget, moduleResult: ResultsConsumer.ModuleResult) { + val librariesDestination = outputLayout.getTargetDirectory(destination, target) + when (moduleResult) { + is ResultsConsumer.ModuleResult.Commonized -> { + val libraryName = moduleResult.libraryName + val libraryDestination = librariesDestination.resolve(libraryName) + writeLibrary(moduleResult.metadata, moduleResult.manifest, libraryDestination) + } + is ResultsConsumer.ModuleResult.Missing -> { + val libraryName = moduleResult.libraryName + val missingModuleLocation = moduleResult.originalLocation + missingModuleLocation.copyRecursively(librariesDestination.resolve(libraryName)) + } + } + } +} + +private fun writeLibrary( + metadata: SerializedMetadata, + manifestData: NativeSensitiveManifestData, + libraryDestination: File +) { + val layout = org.jetbrains.kotlin.konan.file.File(libraryDestination.path).let { KotlinLibraryLayoutForWriter(it, it) } + val library = KotlinLibraryWriterImpl( + moduleName = manifestData.uniqueName, + versions = manifestData.versions, + builtInsPlatform = BuiltInsPlatform.NATIVE, + nativeTargets = emptyList(), // will be overwritten with NativeSensitiveManifestData.applyTo() below + nopack = true, + shortName = manifestData.shortName, + layout = layout + ) + library.addMetadata(metadata) + manifestData.applyTo(library.base as BaseWriterImpl) + library.commit() +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionCommonizer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionCommonizer.kt index 76340070127..df23088222e 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionCommonizer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionCommonizer.kt @@ -5,160 +5,91 @@ package org.jetbrains.kotlin.descriptors.commonizer.konan -import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataVersion -import org.jetbrains.kotlin.backend.common.serialization.metadata.metadataVersion import org.jetbrains.kotlin.descriptors.commonizer.* -import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeDistributionCommonizer.StatsType.* -import org.jetbrains.kotlin.descriptors.commonizer.stats.* +import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.cli.toProgressLogger +import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeDistributionCommonizer.* +import org.jetbrains.kotlin.descriptors.commonizer.repository.Repository +import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsCollector import org.jetbrains.kotlin.descriptors.commonizer.utils.ResettableClockMark import org.jetbrains.kotlin.konan.library.* import org.jetbrains.kotlin.konan.target.KonanTarget -import org.jetbrains.kotlin.library.KotlinLibrary -import org.jetbrains.kotlin.library.ToolingSingleFileKlibResolveStrategy -import org.jetbrains.kotlin.library.resolveSingleFileKlib import org.jetbrains.kotlin.storage.LockBasedStorageManager import org.jetbrains.kotlin.util.Logger -import java.io.File -import org.jetbrains.kotlin.konan.file.File as KFile -class NativeDistributionCommonizer( - private val repository: File, +internal class NativeDistributionCommonizer internal constructor( + private val konanDistribution: KonanDistribution, + private val repository: Repository, + private val dependencies: Repository, + private val libraryLoader: NativeLibraryLoader, private val targets: List, - private val destination: File, - private val copyStdlib: Boolean, - private val copyEndorsedLibs: Boolean, - private val statsType: StatsType, + private val resultsConsumer: ResultsConsumer, + private val statsCollector: StatsCollector?, private val logger: Logger ) { - enum class StatsType { RAW, AGGREGATED, NONE } private val clockMark = ResettableClockMark() fun run() { checkPreconditions() clockMark.reset() - - // 1. load libraries val allLibraries = loadLibraries() - - // 2. run commonization & write new libraries commonizeAndSaveResults(allLibraries) - logTotal() } - private fun checkPreconditions() { - if (!repository.isDirectory) - logger.fatal("Repository does not exist: $repository") - - when (targets.size) { - 0 -> logger.fatal("No targets specified") - 1 -> logger.fatal("Too few targets specified: $targets") - } - - when { - !destination.exists() -> destination.mkdirs() - !destination.isDirectory -> logger.fatal("Output already exists: $destination") - destination.walkTopDown().any { it != destination } -> logger.fatal("Output is not empty: $destination") - } - } - - private fun logProgress(message: String) = logger.log("* $message in ${clockMark.elapsedSinceLast()}") - - private fun logTotal() = logger.log("TOTAL: ${clockMark.elapsedSinceStart()}") - private fun loadLibraries(): AllNativeLibraries { - val stdlibPath = repository.resolve(konanCommonLibraryPath(KONAN_STDLIB_NAME)) - val stdlib = NativeLibrary(loadLibrary(stdlibPath)) + val stdlib = libraryLoader(konanDistribution.stdlib) - val librariesByTargets = targets.associate { target -> - val leafTarget = LeafTarget(target.name, target) - - val platformLibs = leafTarget.platformLibrariesSource - .takeIf { it.isDirectory } - ?.listFiles() - ?.takeIf { it.isNotEmpty() } - ?.map { NativeLibrary(loadLibrary(it)) } - .orEmpty() - - if (platformLibs.isEmpty()) - logger.warning("No platform libraries found for target ${leafTarget.prettyName}. This target will be excluded from commonization.") - - leafTarget to NativeLibrariesToCommonize(platformLibs) + val librariesByTargets = targets.map(::LeafCommonizerTarget).associateWith { target -> + NativeLibrariesToCommonize(repository.getLibraries(target).toList()) } + librariesByTargets.forEach { (target, librariesToCommonize) -> + if (librariesToCommonize.libraries.isEmpty()) { + logger.warning("No platform libraries found for target $target. This target will be excluded from commonization.") + } + } logProgress("Read lazy (uninitialized) libraries") - return AllNativeLibraries(stdlib, librariesByTargets) } - private fun loadLibrary(location: File): KotlinLibrary { - if (!location.isDirectory) - logger.fatal("Library not found: $location") - - val library = resolveSingleFileKlib( - libraryFile = KFile(location.path), - logger = logger, - strategy = ToolingSingleFileKlibResolveStrategy - ) - - if (library.versions.metadataVersion == null) - logger.fatal("Library does not have metadata version specified in manifest: $location") - - val metadataVersion = library.metadataVersion - if (metadataVersion?.isCompatible() != true) - logger.fatal( - """ - Library has incompatible metadata version ${metadataVersion ?: "\"unknown\""}: $location - Please make sure that all libraries passed to commonizer compatible metadata version ${KlibMetadataVersion.INSTANCE} - """.trimIndent() - ) - - return library - } - private fun commonizeAndSaveResults(allLibraries: AllNativeLibraries) { - val statsCollector = when (statsType) { - RAW -> RawStatsCollector(targets) - AGGREGATED -> AggregatedStatsCollector(targets) - NONE -> null - } + val manifestProvider = TargetedNativeManifestDataProvider(allLibraries) - val parameters = CommonizerParameters(statsCollector, ::logProgress).apply { + val parameters = CommonizerParameters(resultsConsumer, manifestProvider, statsCollector, ::logProgress).apply { val storageManager = LockBasedStorageManager("Commonized modules") - - resultsConsumer = NativeDistributionResultsConsumer( - repository = repository, - originalLibraries = allLibraries, - destination = destination, - copyStdlib = copyStdlib, - copyEndorsedLibs = copyEndorsedLibs, - logProgress = ::logProgress - ) dependencyModulesProvider = NativeDistributionModulesProvider.forStandardLibrary(storageManager, allLibraries.stdlib) allLibraries.librariesByTargets.forEach { (target, librariesToCommonize) -> if (librariesToCommonize.libraries.isEmpty()) return@forEach val modulesProvider = NativeDistributionModulesProvider.platformLibraries(storageManager, librariesToCommonize) + val dependencyModuleProvider = NativeDistributionModulesProvider.platformLibraries( + storageManager, NativeLibrariesToCommonize(dependencies.getLibraries(target).toList()), + ) addTarget( TargetProvider( target = target, modulesProvider = modulesProvider, - dependencyModulesProvider = null // stdlib is already set as common dependency + dependencyModulesProvider = dependencyModuleProvider ) ) } } runCommonization(parameters) - - statsCollector?.writeTo(FileStatsOutput(destination, statsType.name.toLowerCase())) } - private val LeafTarget.platformLibrariesSource: File - get() = repository.resolve(KONAN_DISTRIBUTION_KLIB_DIR) - .resolve(KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR) - .resolve(name) + private fun checkPreconditions() { + when (targets.size) { + 0 -> logger.fatal("No targets specified") + 1 -> logger.fatal("Too few targets specified: $targets") + } + } + + private fun logProgress(message: String) = logger.toProgressLogger().log("$message in ${clockMark.elapsedSinceLast()}") + + private fun logTotal() = logger.log("TOTAL: ${clockMark.elapsedSinceStart()}") } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionModulesProvider.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionModulesProvider.kt index 5dbd7c2546d..d977bb4c702 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionModulesProvider.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionModulesProvider.kt @@ -34,8 +34,6 @@ internal abstract class NativeDistributionModulesProvider(libraries: Collection< protected val moduleInfoMap: Map init { - check(libraries.isNotEmpty()) { "No libraries supplied" } - val libraryMap = mutableMapOf() val moduleInfoMap = mutableMapOf() diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionResultsConsumer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionResultsConsumer.kt deleted file mode 100644 index 4bed4d2c4e9..00000000000 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionResultsConsumer.kt +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2010-2021 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.descriptors.commonizer.konan - -import com.intellij.util.containers.FactoryMap -import org.jetbrains.kotlin.descriptors.commonizer.ResultsConsumer -import org.jetbrains.kotlin.descriptors.commonizer.ResultsConsumer.ModuleResult -import org.jetbrains.kotlin.descriptors.commonizer.ResultsConsumer.Status -import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget -import org.jetbrains.kotlin.descriptors.commonizer.LeafTarget -import org.jetbrains.kotlin.descriptors.commonizer.SharedTarget -import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_COMMON_LIBS_DIR -import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_KLIB_DIR -import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR -import org.jetbrains.kotlin.konan.library.KONAN_STDLIB_NAME -import org.jetbrains.kotlin.library.SerializedMetadata -import org.jetbrains.kotlin.library.impl.BaseWriterImpl -import org.jetbrains.kotlin.library.impl.BuiltInsPlatform -import org.jetbrains.kotlin.library.impl.KotlinLibraryLayoutForWriter -import org.jetbrains.kotlin.library.impl.KotlinLibraryWriterImpl -import java.io.File -import org.jetbrains.kotlin.konan.file.File as KFile - -internal class NativeDistributionResultsConsumer( - private val repository: File, - private val originalLibraries: AllNativeLibraries, - private val destination: File, - private val copyStdlib: Boolean, - private val copyEndorsedLibs: Boolean, - private val logProgress: (String) -> Unit -) : ResultsConsumer { - private val allLeafTargets = originalLibraries.librariesByTargets.keys - - private val allLeafCommonizedTargets = originalLibraries.librariesByTargets.filterValues { it.libraries.isNotEmpty() }.keys - private val sharedTarget = SharedTarget(allLeafCommonizedTargets) - - private val consumedTargets = LinkedHashSet() - - private val cachedManifestProviders = FactoryMap.create { target -> - when (target) { - is LeafTarget -> originalLibraries.librariesByTargets.getValue(target) - is SharedTarget -> CommonNativeManifestDataProvider(originalLibraries.librariesByTargets.values) - } - } - - private val cachedLibrariesDestination = FactoryMap.create { target -> - val librariesDestination = when (target) { - is LeafTarget -> destination.resolve(KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR).resolve(target.name) - is SharedTarget -> destination.resolve(KONAN_DISTRIBUTION_COMMON_LIBS_DIR) - } - - librariesDestination.mkdirs() // always create an empty directory even if there is nothing to copy - librariesDestination - } - - override fun consume(target: CommonizerTarget, moduleResult: ModuleResult) { - check(target in allLeafCommonizedTargets || target == sharedTarget) - consumedTargets += target - - serializeModule(target, moduleResult) - } - - override fun targetConsumed(target: CommonizerTarget) { - check(target in consumedTargets) - - logProgress("Written libraries for ${target.prettyCommonizedName(sharedTarget)}") - } - - override fun allConsumed(status: Status) { - // optimization: stdlib and endorsed libraries effectively remain the same across all Kotlin/Native targets, - // so they can be just copied to the new destination without running serializer - copyCommonStandardLibraries() - - when (status) { - Status.NOTHING_TO_DO -> { - // It may happen that all targets to be commonized (or at least all but one target) miss platform libraries. - // In such case commonizer will do nothing and raise a special status value 'NOTHING_TO_DO'. - // So, let's just copy platform libraries from the target where they are to the new destination. - allLeafTargets.forEach(::copyTargetAsIs) - } - Status.DONE -> { - // 'targetsToCopy' are some leaf targets with empty set of platform libraries - val targetsToCopy = allLeafTargets - consumedTargets.filterIsInstance() - targetsToCopy.forEach(::copyTargetAsIs) - } - } - } - - private fun copyCommonStandardLibraries() { - if (copyStdlib || copyEndorsedLibs) { - repository.resolve(KONAN_DISTRIBUTION_KLIB_DIR) - .resolve(KONAN_DISTRIBUTION_COMMON_LIBS_DIR) - .listFiles() - ?.filter { it.isDirectory } - ?.let { - if (copyStdlib) { - if (copyEndorsedLibs) it else it.filter { dir -> dir.endsWith(KONAN_STDLIB_NAME) } - } else - it.filter { dir -> !dir.endsWith(KONAN_STDLIB_NAME) } - }?.forEach { libraryOrigin -> - val libraryDestination = destination.resolve(KONAN_DISTRIBUTION_COMMON_LIBS_DIR).resolve(libraryOrigin.name) - libraryOrigin.copyRecursively(libraryDestination) - } - - val what = listOfNotNull( - "standard library".takeIf { copyStdlib }, - "endorsed libraries".takeIf { copyEndorsedLibs } - ).joinToString(separator = " and ") - - logProgress("Copied $what") - } - } - - private fun copyTargetAsIs(leafTarget: LeafTarget) { - val librariesCount = originalLibraries.librariesByTargets.getValue(leafTarget).libraries.size - val librariesDestination = cachedLibrariesDestination.getValue(leafTarget) - - val librariesSource = leafTarget.platformLibrariesSource - if (librariesSource.isDirectory) librariesSource.copyRecursively(librariesDestination) - - logProgress("Copied $librariesCount libraries for ${leafTarget.prettyName}") - } - - private fun serializeModule(target: CommonizerTarget, moduleResult: ModuleResult) { - val librariesDestination = cachedLibrariesDestination.getValue(target) - - when (moduleResult) { - is ModuleResult.Commonized -> { - val libraryName = moduleResult.libraryName - - val manifestData = cachedManifestProviders.getValue(target).getManifest(libraryName) - val libraryDestination = librariesDestination.resolve(libraryName) - - writeLibrary(moduleResult.metadata, manifestData, libraryDestination) - } - is ModuleResult.Missing -> { - val libraryName = moduleResult.libraryName - val missingModuleLocation = moduleResult.originalLocation - - missingModuleLocation.copyRecursively(librariesDestination.resolve(libraryName)) - } - } - } - - private fun writeLibrary( - metadata: SerializedMetadata, - manifestData: NativeSensitiveManifestData, - libraryDestination: File - ) { - val layout = KFile(libraryDestination.path).let { KotlinLibraryLayoutForWriter(it, it) } - val library = KotlinLibraryWriterImpl( - moduleName = manifestData.uniqueName, - versions = manifestData.versions, - builtInsPlatform = BuiltInsPlatform.NATIVE, - nativeTargets = emptyList(), // will be overwritten with NativeSensitiveManifestData.applyTo() below - nopack = true, - shortName = manifestData.shortName, - layout = layout - ) - library.addMetadata(metadata) - manifestData.applyTo(library.base as BaseWriterImpl) - library.commit() - } - - private val LeafTarget.platformLibrariesSource: File - get() = repository.resolve(KONAN_DISTRIBUTION_KLIB_DIR) - .resolve(KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR) - .resolve(name) -} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeLibrary.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeLibrary.kt index 557274101b2..d80d7ec9974 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeLibrary.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeLibrary.kt @@ -5,14 +5,33 @@ package org.jetbrains.kotlin.descriptors.commonizer.konan +import com.intellij.util.containers.FactoryMap import gnu.trove.THashMap -import org.jetbrains.kotlin.descriptors.commonizer.LeafTarget +import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.SharedCommonizerTarget import org.jetbrains.kotlin.library.KotlinLibrary +fun interface TargetedNativeManifestDataProvider { + fun getManifest(target: CommonizerTarget, libraryName: String): NativeSensitiveManifestData +} + internal interface NativeManifestDataProvider { fun getManifest(libraryName: String): NativeSensitiveManifestData } +internal fun TargetedNativeManifestDataProvider(libraries: AllNativeLibraries): TargetedNativeManifestDataProvider { + val cachedManifestProviders: Map = FactoryMap.create { target -> + when (target) { + is LeafCommonizerTarget -> libraries.librariesByTargets.getValue(target) + is SharedCommonizerTarget -> CommonNativeManifestDataProvider(libraries.librariesByTargets.values) + } + } + return TargetedNativeManifestDataProvider { target, libraryName -> + cachedManifestProviders.getValue(target).getManifest(libraryName) + } +} + /** * A separate Kotlin/Native library. */ @@ -37,7 +56,7 @@ internal class NativeLibrariesToCommonize(val libraries: List) : internal class AllNativeLibraries( val stdlib: NativeLibrary, - val librariesByTargets: Map + val librariesByTargets: Map ) internal class CommonNativeManifestDataProvider( diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeSensitiveManifestData.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeSensitiveManifestData.kt index 3d3ee40a5ef..a479c9c05b2 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeSensitiveManifestData.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeSensitiveManifestData.kt @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.library.impl.BaseWriterImpl * The set of properties in manifest of Kotlin/Native library that should be * preserved in commonized libraries (both for "common" and platform-specific library parts). */ -internal data class NativeSensitiveManifestData( +data class NativeSensitiveManifestData( val uniqueName: String, val versions: KotlinLibraryVersioning, val dependencies: List, diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt index 27274c344c5..27cbc668f33 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt @@ -6,10 +6,8 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.commonizer.LeafTarget +import org.jetbrains.kotlin.descriptors.commonizer.* import org.jetbrains.kotlin.descriptors.commonizer.ModulesProvider.ModuleInfo -import org.jetbrains.kotlin.descriptors.commonizer.CommonizerParameters -import org.jetbrains.kotlin.descriptors.commonizer.TargetProvider import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPackageName @@ -49,7 +47,7 @@ class CirTreeMerger( ) { class CirTreeMergeResult( val root: CirRootNode, - val missingModuleInfos: Map> + val missingModuleInfos: Map> ) private val size = parameters.targetProviders.size diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt index 2fe350c6502..0f386bee1ea 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree import gnu.trove.THashMap import gnu.trove.THashSet import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.descriptors.commonizer.SharedTarget +import org.jetbrains.kotlin.descriptors.commonizer.SharedCommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPackageName @@ -25,7 +25,7 @@ class CirKnownClassifiers( ) { // a shortcut for fast access val commonDependencies: CirProvidedClassifiers = - dependencies.filterKeys { it is SharedTarget }.values.singleOrNull() ?: CirProvidedClassifiers.EMPTY + dependencies.filterKeys { it is SharedCommonizerTarget }.values.singleOrNull() ?: CirProvidedClassifiers.EMPTY } interface CirCommonizedClassifiers { diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/FilesRepository.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/FilesRepository.kt new file mode 100644 index 00000000000..9719dddfdde --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/FilesRepository.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2010-2020 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.descriptors.commonizer.repository + +import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.NativeLibraryLoader +import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeLibrary +import org.jetbrains.kotlin.konan.target.KonanTarget +import java.io.File + +internal class FilesRepository( + private val libraryFiles: Set, + private val libraryLoader: NativeLibraryLoader +) : Repository { + + private val librariesByTarget: Map> by lazy { + libraryFiles + .map(libraryLoader::invoke) + .groupBy { library -> CommonizerTarget(library.manifestData.nativeTargets.map(::konanTargetOrThrow)) } + .mapValues { (_, list) -> list.toSet() } + } + + override fun getLibraries(target: LeafCommonizerTarget): Set { + return librariesByTarget[target].orEmpty() + } +} + +private fun konanTargetOrThrow(value: String): KonanTarget { + return KonanTarget.predefinedTargets[value] ?: error("Unexpected KonanTarget $value") +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/KonanDistributionRepository.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/KonanDistributionRepository.kt new file mode 100644 index 00000000000..3aa005bd904 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/KonanDistributionRepository.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2020 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.descriptors.commonizer.repository + +import org.jetbrains.kotlin.descriptors.commonizer.KonanDistribution +import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.NativeLibraryLoader +import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeLibrary +import org.jetbrains.kotlin.descriptors.commonizer.platformLibsDir +import org.jetbrains.kotlin.konan.target.KonanTarget + +internal class KonanDistributionRepository( + konanDistribution: KonanDistribution, + targets: Set, + libraryLoader: NativeLibraryLoader, +) : Repository { + + private val librariesByTarget: Map>> = + targets.map(::LeafCommonizerTarget).associateWith { target -> + lazy { + konanDistribution.platformLibsDir + .resolve(target.name) + .takeIf { it.isDirectory } + ?.listFiles() + .orEmpty().toList() + .map { libraryLoader(it) } + .toSet() + } + } + + override fun getLibraries(target: LeafCommonizerTarget): Set { + return librariesByTarget[target]?.value ?: error("Missing target $target") + } +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/Repository.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/Repository.kt new file mode 100644 index 00000000000..5f7074b0a2b --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/Repository.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2020 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.descriptors.commonizer.repository + +import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeLibrary + +internal interface Repository { + fun getLibraries(target: LeafCommonizerTarget): Set +} + +internal operator fun Repository.plus(other: Repository): Repository { + if (this is CompositeRepository) { + return CompositeRepository(this.repositories + other) + } + return CompositeRepository(listOf(this, other)) +} + +private class CompositeRepository(val repositories: Iterable) : Repository { + override fun getLibraries(target: LeafCommonizerTarget): Set { + return repositories.map { it.getLibraries(target) }.flatten().toSet() + } +} + +internal object EmptyRepository : Repository { + override fun getLibraries(target: LeafCommonizerTarget): Set { + return emptySet() + } +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/StatsCollector.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/StatsCollector.kt index 6a67558db9d..8adede045ed 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/StatsCollector.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/StatsCollector.kt @@ -5,6 +5,20 @@ package org.jetbrains.kotlin.descriptors.commonizer.stats +import org.jetbrains.kotlin.konan.target.KonanTarget + +fun StatsCollector(type: StatsType, targets: List): StatsCollector? { + return when (type) { + StatsType.RAW -> RawStatsCollector(targets) + StatsType.AGGREGATED -> AggregatedStatsCollector(targets) + StatsType.NONE -> null + } +} + +enum class StatsType { + RAW, AGGREGATED, NONE; +} + interface StatsCollector { data class StatsKey( val id: String, diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt index 95af8cb91d4..fcad9a3e61f 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.PackageFragmentProvider import org.jetbrains.kotlin.descriptors.commonizer.ResultsConsumer.ModuleResult import org.jetbrains.kotlin.descriptors.commonizer.ResultsConsumer.Status import org.jetbrains.kotlin.descriptors.commonizer.SourceModuleRoot.Companion.SHARED_TARGET_NAME +import org.jetbrains.kotlin.descriptors.commonizer.konan.TargetedNativeManifestDataProvider import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ClassCollector import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.FunctionCollector import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.collectMembers @@ -75,7 +76,7 @@ abstract class AbstractCommonizationFromSourcesTest : KtUsefulTestCase() { runCommonization(analyzedModules.toCommonizerParameters(results)) assertEquals(Status.DONE, results.status) - val sharedTarget: SharedTarget = analyzedModules.sharedTarget + val sharedTarget: SharedCommonizerTarget = analyzedModules.sharedTarget assertEquals(sharedTarget, results.sharedTarget) val sharedModuleAsExpected: SerializedMetadata = analyzedModules.commonizedModules.getValue(sharedTarget) @@ -84,7 +85,7 @@ abstract class AbstractCommonizationFromSourcesTest : KtUsefulTestCase() { assertModulesAreEqual(sharedModuleAsExpected, sharedModuleByCommonizer, sharedTarget) - val leafTargets: Set = analyzedModules.leafTargets + val leafTargets: Set = analyzedModules.leafTargets assertEquals(leafTargets, results.leafTargets) for (leafTarget in leafTargets) { @@ -116,18 +117,18 @@ private data class SourceModuleRoot( } private class SourceModuleRoots( - val originalRoots: Map, + val originalRoots: Map, val commonizedRoots: Map, val dependencyRoots: Map ) { - val leafTargets: Set = originalRoots.keys - val sharedTarget: SharedTarget + val leafTargets: Set = originalRoots.keys + val sharedTarget: SharedCommonizerTarget init { check(leafTargets.size >= 2) check(leafTargets.none { it.name == SHARED_TARGET_NAME }) - val sharedTargets = commonizedRoots.keys.filterIsInstance() + val sharedTargets = commonizedRoots.keys.filterIsInstance() check(sharedTargets.size == 1) sharedTarget = sharedTargets.single() @@ -140,10 +141,10 @@ private class SourceModuleRoots( companion object { fun load(dataDir: File): SourceModuleRoots = try { - val originalRoots = listRoots(dataDir, ORIGINAL_ROOTS_DIR).mapKeys { LeafTarget(it.key) } + val originalRoots = listRoots(dataDir, ORIGINAL_ROOTS_DIR).mapKeys { LeafCommonizerTarget(it.key) } val leafTargets = originalRoots.keys - val sharedTarget = SharedTarget(leafTargets) + val sharedTarget = SharedCommonizerTarget(leafTargets) fun getTarget(targetName: String): CommonizerTarget = if (targetName == SHARED_TARGET_NAME) sharedTarget else leafTargets.first { it.name == targetName } @@ -185,41 +186,41 @@ private class AnalyzedModules( val commonizedModules: Map, val dependencyModules: Map> ) { - val leafTargets: Set - val sharedTarget: SharedTarget + val leafTargets: Set + val sharedTarget: SharedCommonizerTarget init { originalModules.keys.let { targets -> check(targets.isNotEmpty()) - leafTargets = targets.filterIsInstance().toSet() + leafTargets = targets.filterIsInstance().toSet() check(targets.size == leafTargets.size) } - sharedTarget = SharedTarget(leafTargets) + sharedTarget = SharedCommonizerTarget(leafTargets) val allTargets = leafTargets + sharedTarget check(commonizedModules.keys == allTargets) check(allTargets.containsAll(dependencyModules.keys)) } - fun toCommonizerParameters(resultsConsumer: ResultsConsumer) = - CommonizerParameters().also { parameters -> - parameters.resultsConsumer = resultsConsumer - parameters.dependencyModulesProvider = dependencyModules[sharedTarget]?.let(MockModulesProvider::create) + fun toCommonizerParameters( + resultsConsumer: ResultsConsumer, manifestDataProvider: TargetedNativeManifestDataProvider = MockNativeManifestDataProvider() + ) = CommonizerParameters(resultsConsumer, manifestDataProvider).also { parameters -> + parameters.dependencyModulesProvider = dependencyModules[sharedTarget]?.let(MockModulesProvider::create) - leafTargets.forEach { leafTarget -> - val originalModule = originalModules.getValue(leafTarget) + leafTargets.forEach { leafTarget -> + val originalModule = originalModules.getValue(leafTarget) - parameters.addTarget( - TargetProvider( - target = leafTarget, - modulesProvider = MockModulesProvider.create(originalModule), - dependencyModulesProvider = dependencyModules[leafTarget]?.let(MockModulesProvider::create) - ) + parameters.addTarget( + TargetProvider( + target = leafTarget, + modulesProvider = MockModulesProvider.create(originalModule), + dependencyModulesProvider = dependencyModules[leafTarget]?.let(MockModulesProvider::create) ) - } + ) } + } companion object { fun create( @@ -242,7 +243,7 @@ private class AnalyzedModules( } private fun createDependencyModules( - sharedTarget: SharedTarget, + sharedTarget: SharedCommonizerTarget, dependencyRoots: Map, parentDisposable: Disposable ): Pair>, AnalyzedModuleDependencies> { @@ -263,7 +264,7 @@ private class AnalyzedModules( } private fun createModules( - sharedTarget: SharedTarget, + sharedTarget: SharedCommonizerTarget, moduleRoots: Map, dependencies: AnalyzedModuleDependencies, parentDisposable: Disposable, @@ -290,7 +291,7 @@ private class AnalyzedModules( } private fun createModule( - sharedTarget: SharedTarget, + sharedTarget: SharedCommonizerTarget, currentTarget: CommonizerTarget, moduleRoot: SourceModuleRoot, dependencies: AnalyzedModuleDependencies, @@ -338,7 +339,7 @@ private class AnalyzedModules( } private class DependenciesContainerImpl( - sharedTarget: SharedTarget, + sharedTarget: SharedCommonizerTarget, currentTarget: CommonizerTarget, dependencies: AnalyzedModuleDependencies ) : CommonDependenciesContainer { diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerFacadeTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerFacadeTest.kt index 0f4af9f10f1..106cd004c61 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerFacadeTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerFacadeTest.kt @@ -7,8 +7,11 @@ package org.jetbrains.kotlin.descriptors.commonizer import org.jetbrains.kotlin.descriptors.commonizer.ResultsConsumer.ModuleResult import org.jetbrains.kotlin.descriptors.commonizer.ResultsConsumer.Status +import org.jetbrains.kotlin.descriptors.commonizer.konan.CommonNativeManifestDataProvider +import org.jetbrains.kotlin.descriptors.commonizer.konan.TargetedNativeManifestDataProvider import org.jetbrains.kotlin.descriptors.commonizer.utils.MockResultsConsumer import org.jetbrains.kotlin.descriptors.commonizer.utils.MockModulesProvider +import org.jetbrains.kotlin.descriptors.commonizer.utils.MockNativeManifestDataProvider import org.junit.Test import kotlin.contracts.ExperimentalContracts import kotlin.test.assertEquals @@ -62,20 +65,19 @@ class CommonizerFacadeTest { ) companion object { - private fun Map>.toCommonizerParameters(resultsConsumer: ResultsConsumer) = - CommonizerParameters().also { parameters -> - parameters.resultsConsumer = resultsConsumer - - forEach { (targetName, moduleNames) -> - parameters.addTarget( - TargetProvider( - target = LeafTarget(targetName), - modulesProvider = MockModulesProvider.create(moduleNames), - dependencyModulesProvider = null - ) + private fun Map>.toCommonizerParameters( + resultsConsumer: ResultsConsumer, manifestDataProvider: TargetedNativeManifestDataProvider = MockNativeManifestDataProvider() + ) = CommonizerParameters(resultsConsumer, manifestDataProvider).also { parameters -> + forEach { (targetName, moduleNames) -> + parameters.addTarget( + TargetProvider( + target = LeafCommonizerTarget(targetName), + modulesProvider = MockModulesProvider.create(moduleNames), + dependencyModulesProvider = null ) - } + ) } + } private fun doTestNothingToCommonize(originalModules: Map>) { val results = MockResultsConsumer() diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetTest.kt deleted file mode 100644 index f56e791652f..00000000000 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/CommonizerTargetTest.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2010-2021 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.descriptors.commonizer - -import org.jetbrains.kotlin.konan.target.KonanTarget -import org.junit.Test -import kotlin.test.assertEquals - -class CommonizerTargetTest { - - @Test - fun leafTargetNames() { - listOf( - Triple("foo", "[foo]", FOO), - Triple("bar", "[bar]", BAR), - Triple("baz_123", "[baz_123]", BAZ), - ).forEach { (name, prettyName, target: LeafTarget) -> - assertEquals(name, target.name) - assertEquals(prettyName, target.prettyName) - } - } - - @Test - fun sharedTargetNames() { - listOf( - "[foo]" to SharedTarget(FOO), - "[foo, bar]" to SharedTarget(FOO, BAR), - "[foo, bar, baz_123]" to SharedTarget(FOO, BAR, BAZ), - "[foo, bar, baz_123, [foo, bar]]" to SharedTarget(FOO, BAR, BAZ, SharedTarget(FOO, BAR)) - ).forEach { (prettyName, target: SharedTarget) -> - assertEquals(prettyName, target.prettyName) - assertEquals(prettyName, target.name) - } - } - - @Test - fun prettyCommonizedName() { - val sharedTarget = SharedTarget(FOO, BAR, BAZ) - listOf( - "[foo(*), bar, baz_123]" to FOO, - "[foo, bar(*), baz_123]" to BAR, - "[foo, bar, baz_123(*)]" to BAZ, - "[foo, bar, baz_123]" to sharedTarget - ).forEach { (prettyCommonizerName, target: CommonizerTarget) -> - assertEquals(prettyCommonizerName, target.prettyCommonizedName(sharedTarget)) - } - } - - @Test(expected = IllegalStateException::class) - fun prettyCommonizedNameFailure() { - FOO.prettyCommonizedName(SharedTarget(BAR, BAZ)) - } - - @Test(expected = IllegalArgumentException::class) - fun sharedTargetNoInnerTargets() { - SharedTarget(emptySet()) - } - - private companion object { - val FOO = LeafTarget("foo") - val BAR = LeafTarget("bar", KonanTarget.IOS_X64) - val BAZ = LeafTarget("baz_123", KonanTarget.MACOS_X64) - - @Suppress("TestFunctionName") - fun SharedTarget(vararg targets: CommonizerTarget) = SharedTarget(linkedSetOf(*targets)) - } -} diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/RootCommonizerTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/RootCommonizerTest.kt index a78996b49fb..c0ec2144ae1 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/RootCommonizerTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/RootCommonizerTest.kt @@ -6,8 +6,8 @@ package org.jetbrains.kotlin.descriptors.commonizer.core import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget -import org.jetbrains.kotlin.descriptors.commonizer.LeafTarget -import org.jetbrains.kotlin.descriptors.commonizer.SharedTarget +import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.SharedCommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.cir.CirRoot import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirRootFactory import org.jetbrains.kotlin.konan.target.KonanTarget @@ -17,114 +17,86 @@ class RootCommonizerTest : AbstractCommonizerTest() { @Test fun allAreNative() = doTestSuccess( - expected = SharedTarget( + expected = SharedCommonizerTarget( setOf( - LeafTarget("ios_x64", KonanTarget.IOS_X64), - LeafTarget("ios_arm64", KonanTarget.IOS_ARM64), - LeafTarget("ios_arm32", KonanTarget.IOS_ARM32) + LeafCommonizerTarget(KonanTarget.IOS_X64), + LeafCommonizerTarget(KonanTarget.IOS_ARM64), + LeafCommonizerTarget(KonanTarget.IOS_ARM32) ) ).toMock(), - LeafTarget("ios_x64", KonanTarget.IOS_X64).toMock(), - LeafTarget("ios_arm64", KonanTarget.IOS_ARM64).toMock(), - LeafTarget("ios_arm32", KonanTarget.IOS_ARM32).toMock() + LeafCommonizerTarget(KonanTarget.IOS_X64).toMock(), + LeafCommonizerTarget(KonanTarget.IOS_ARM64).toMock(), + LeafCommonizerTarget(KonanTarget.IOS_ARM32).toMock() ) @Test fun jvmAndNative1() = doTestSuccess( - expected = SharedTarget( + expected = SharedCommonizerTarget( setOf( - LeafTarget("jvm1"), - LeafTarget("ios_x64", KonanTarget.IOS_X64), - LeafTarget("jvm2") + LeafCommonizerTarget("jvm1"), + LeafCommonizerTarget(KonanTarget.IOS_X64), + LeafCommonizerTarget("jvm2") ) ).toMock(), - LeafTarget("jvm1").toMock(), - LeafTarget("ios_x64", KonanTarget.IOS_X64).toMock(), - LeafTarget("jvm2").toMock() + LeafCommonizerTarget("jvm1").toMock(), + LeafCommonizerTarget(KonanTarget.IOS_X64).toMock(), + LeafCommonizerTarget("jvm2").toMock() ) @Test fun jvmAndNative2() = doTestSuccess( - expected = SharedTarget( + expected = SharedCommonizerTarget( setOf( - LeafTarget("ios_x64", KonanTarget.IOS_X64), - LeafTarget("jvm"), - LeafTarget("ios_arm64", KonanTarget.IOS_ARM64) + LeafCommonizerTarget(KonanTarget.IOS_X64), + LeafCommonizerTarget("jvm"), + LeafCommonizerTarget(KonanTarget.IOS_ARM64) ) ).toMock(), - LeafTarget("ios_x64", KonanTarget.IOS_X64).toMock(), - LeafTarget("jvm").toMock(), - LeafTarget("ios_arm64", KonanTarget.IOS_ARM64).toMock() + LeafCommonizerTarget(KonanTarget.IOS_X64).toMock(), + LeafCommonizerTarget("jvm").toMock(), + LeafCommonizerTarget(KonanTarget.IOS_ARM64).toMock() ) @Test fun noNative1() = doTestSuccess( - expected = SharedTarget( + expected = SharedCommonizerTarget( setOf( - LeafTarget("default1"), - LeafTarget("default2"), - LeafTarget("default3") + LeafCommonizerTarget("default1"), + LeafCommonizerTarget("default2"), + LeafCommonizerTarget("default3") ) ).toMock(), - LeafTarget("default1").toMock(), - LeafTarget("default2").toMock(), - LeafTarget("default3").toMock() + LeafCommonizerTarget("default1").toMock(), + LeafCommonizerTarget("default2").toMock(), + LeafCommonizerTarget("default3").toMock() ) @Test fun noNative2() = doTestSuccess( - expected = SharedTarget( + expected = SharedCommonizerTarget( setOf( - LeafTarget("jvm1"), - LeafTarget("default"), - LeafTarget("jvm2") + LeafCommonizerTarget("jvm1"), + LeafCommonizerTarget("default"), + LeafCommonizerTarget("jvm2") ) ).toMock(), - LeafTarget("jvm1").toMock(), - LeafTarget("default").toMock(), - LeafTarget("jvm2").toMock() + LeafCommonizerTarget("jvm1").toMock(), + LeafCommonizerTarget("default").toMock(), + LeafCommonizerTarget("jvm2").toMock() ) @Test fun noNative3() = doTestSuccess( - expected = SharedTarget( + expected = SharedCommonizerTarget( setOf( - LeafTarget("jvm1"), - LeafTarget("jvm2"), - LeafTarget("jvm3") + LeafCommonizerTarget("jvm1"), + LeafCommonizerTarget("jvm2"), + LeafCommonizerTarget("jvm3") ) ).toMock(), - LeafTarget("jvm1").toMock(), - LeafTarget("jvm2").toMock(), - LeafTarget("jvm3").toMock() - ) - - @Test(expected = ObjectsNotEqual::class) - fun misconfiguration1() = doTestSuccess( - expected = SharedTarget( - setOf( - LeafTarget("ios_x64", KonanTarget.IOS_X64), - LeafTarget("ios_arm64", KonanTarget.IOS_ARM64), - LeafTarget("ios_arm32", KonanTarget.IOS_ARM32) - ) - ).toMock(), - LeafTarget("ios_x64").toMock(), // KonanTarget is missing here! - LeafTarget("ios_arm64", KonanTarget.IOS_ARM64).toMock(), - LeafTarget("ios_arm32", KonanTarget.IOS_ARM32).toMock() - ) - - @Test(expected = ObjectsNotEqual::class) - fun misconfiguration2() = doTestSuccess( - expected = SharedTarget( - setOf( - LeafTarget("jvm1"), - LeafTarget("jvm2"), - LeafTarget("jvm3") - ) - ).toMock(), - LeafTarget("jvm1", KonanTarget.IOS_X64).toMock(), // mistakenly specified KonanTarget! - LeafTarget("jvm2").toMock(), - LeafTarget("jvm3").toMock() + LeafCommonizerTarget("jvm1").toMock(), + LeafCommonizerTarget("jvm2").toMock(), + LeafCommonizerTarget("jvm3").toMock() ) override fun createCommonizer() = RootCommonizer() diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt index 7da9705f162..61a5a32e0be 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt @@ -7,8 +7,8 @@ package org.jetbrains.kotlin.descriptors.commonizer.core import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor -import org.jetbrains.kotlin.descriptors.commonizer.LeafTarget -import org.jetbrains.kotlin.descriptors.commonizer.SharedTarget +import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.SharedCommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirClassFactory @@ -537,7 +537,7 @@ class TypeCommonizerTest : AbstractCommonizerTest() { fun areEqual(classifiers: CirKnownClassifiers, a: CirType, b: CirType): Boolean = TypeCommonizer(classifiers).run { commonizeWith(a) && commonizeWith(b) } - private val FAKE_SHARED_TARGET = SharedTarget(setOf(LeafTarget("a"), LeafTarget("b"))) + private val FAKE_SHARED_TARGET = SharedCommonizerTarget(setOf(LeafCommonizerTarget("a"), LeafCommonizerTarget("b"))) private fun CirKnownClassifiers.classNode(classId: CirEntityId, computation: () -> CirClassNode) = commonized.classNode(classId) ?: computation() diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/assertions.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/assertions.kt index 3d2eefde44e..72709bef6c6 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/assertions.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/assertions.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.descriptors.commonizer.utils import kotlinx.metadata.klib.KlibModuleMetadata import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.identityString import org.jetbrains.kotlin.descriptors.commonizer.metadata.utils.MetadataDeclarationsComparator import org.jetbrains.kotlin.descriptors.commonizer.metadata.utils.MetadataDeclarationsComparator.Mismatch import org.jetbrains.kotlin.descriptors.commonizer.metadata.utils.MetadataDeclarationsComparator.Result @@ -38,7 +39,7 @@ fun assertModulesAreEqual(reference: SerializedMetadata, generated: SerializedMe val digitCount = mismatches.size.toString().length val failureMessage = buildString { - appendLine("${mismatches.size} mismatches found while comparing reference module ${referenceModule.name} (A) and generated module ${generatedModule.name} (B) for target ${target.prettyName}:") + appendLine("${mismatches.size} mismatches found while comparing reference module ${referenceModule.name} (A) and generated module ${generatedModule.name} (B) for target ${target.identityString}:") mismatches.forEachIndexed { index, mismatch -> appendLine((index + 1).toString().padStart(digitCount, ' ') + ". " + mismatch) } diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt index 03a7f70c316..9169e2b0fe6 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt @@ -16,9 +16,12 @@ import org.jetbrains.kotlin.descriptors.commonizer.ModulesProvider.ModuleInfo import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirClassFactory +import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeSensitiveManifestData +import org.jetbrains.kotlin.descriptors.commonizer.konan.TargetedNativeManifestDataProvider import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.* import org.jetbrains.kotlin.descriptors.impl.AbstractTypeAliasDescriptor import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl +import org.jetbrains.kotlin.library.KotlinLibraryVersioning import org.jetbrains.kotlin.library.SerializedMetadata import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.parentOrNull @@ -204,8 +207,8 @@ internal class MockResultsConsumer : ResultsConsumer { val modulesByTargets: Map> get() = _modulesByTargets.mapValues { it.value.values } - val sharedTarget: SharedTarget by lazy { modulesByTargets.keys.filterIsInstance().single() } - val leafTargets: Set by lazy { modulesByTargets.keys.filterIsInstance().toSet() } + val sharedTarget: SharedCommonizerTarget by lazy { modulesByTargets.keys.filterIsInstance().single() } + val leafTargets: Set by lazy { modulesByTargets.keys.filterIsInstance().toSet() } private val finishedTargets = mutableSetOf() @@ -232,3 +235,25 @@ internal class MockResultsConsumer : ResultsConsumer { this.status = status } } + +fun MockNativeManifestDataProvider( + uniqueName: String = "mock", + versions: KotlinLibraryVersioning = KotlinLibraryVersioning(null, null, null, null, null), + dependencies: List = emptyList(), + isInterop: Boolean = true, + packageFqName: String? = "mock", + exportForwardDeclarations: List = emptyList(), + nativeTargets: Collection = emptyList(), + shortName: String? = "mock" +): TargetedNativeManifestDataProvider = TargetedNativeManifestDataProvider { target, libraryName -> + NativeSensitiveManifestData( + uniqueName = uniqueName, + versions = versions, + dependencies = dependencies, + isInterop = isInterop, + packageFqName = packageFqName, + exportForwardDeclarations = exportForwardDeclarations, + nativeTargets = nativeTargets, + shortName = shortName + ) +} diff --git a/settings.gradle b/settings.gradle index 0d56a3fe779..0cf60573b00 100644 --- a/settings.gradle +++ b/settings.gradle @@ -136,6 +136,7 @@ include ":benchmarks", ":native:kotlin-native-utils", ":native:frontend.native", ":native:kotlin-klib-commonizer", + ":native:kotlin-klib-commonizer-api", ":native:kotlin-klib-commonizer-embeddable", ":jps-plugin", ":kotlin-jps-plugin", @@ -492,6 +493,7 @@ project(':kotlin-util-klib-metadata').projectDir = "$rootDir/compiler/util-klib- project(':native:kotlin-native-utils').projectDir = "$rootDir/native/utils" as File project(':native:frontend.native').projectDir = "$rootDir/native/frontend" as File project(':native:kotlin-klib-commonizer').projectDir = "$rootDir/native/commonizer" as File +project(":native:kotlin-klib-commonizer-api").projectDir = "$rootDir/native/commonizer-api" as File project(':native:kotlin-klib-commonizer-embeddable').projectDir = "$rootDir/native/commonizer-embeddable" as File project(':kotlin-jps-plugin').projectDir = "$rootDir/prepare/jps-plugin" as File project(':idea:idea-android-output-parser').projectDir = "$rootDir/idea/idea-android/idea-android-output-parser" as File @@ -569,7 +571,7 @@ project(':plugins:jvm-abi-gen').projectDir = "$rootDir/plugins/jvm-abi-gen" as F project(':plugins:jvm-abi-gen-embeddable').projectDir = "$rootDir/plugins/jvm-abi-gen/embeddable" as File project(":dukat").projectDir = "$rootDir/libraries/tools/dukat" as File -project(':js:js.tests').projectDir = "$rootDir/js/js.tests" as File +project(':js:js.tests').projectDir = "$rootDir/js/js.tests" as File project(':js:js.engines').projectDir = "$rootDir/js/js.engines" as File project(':kotlinx-serialization-compiler-plugin').projectDir = file("$rootDir/plugins/kotlin-serialization/kotlin-serialization-compiler") From 35008df9697d9d949e6f6176e3b4578c4237cb99 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 17 Feb 2021 09:34:00 +0100 Subject: [PATCH 246/368] [Commonizer] Rename NativeDistributionCommonizer to LibraryCommonizer --- .../kotlin/descriptors/commonizer/cli/nativeTasks.kt | 6 +++--- ...NativeDistributionCommonizer.kt => LibraryCommonizer.kt} | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) rename native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/{NativeDistributionCommonizer.kt => LibraryCommonizer.kt} (96%) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt index 4af1aef8a9f..7a9e869283e 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.descriptors.commonizer.* import org.jetbrains.kotlin.descriptors.commonizer.konan.* import org.jetbrains.kotlin.descriptors.commonizer.konan.CopyUnconsumedModulesAsIsConsumer import org.jetbrains.kotlin.descriptors.commonizer.konan.CopyStdlibResultsConsumer -import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeDistributionCommonizer +import org.jetbrains.kotlin.descriptors.commonizer.konan.LibraryCommonizer import org.jetbrains.kotlin.descriptors.commonizer.konan.ModuleSerializer import org.jetbrains.kotlin.descriptors.commonizer.repository.* import org.jetbrains.kotlin.descriptors.commonizer.repository.EmptyRepository @@ -72,7 +72,7 @@ internal class NativeKlibCommonize(options: Collection>) : Task(option this add LoggingResultsConsumer(outputCommonizerTarget, logger.toProgressLogger()) } - NativeDistributionCommonizer( + LibraryCommonizer( konanDistribution = distribution, repository = repository, dependencies = KonanDistributionRepository(distribution, outputCommonizerTarget.konanTargets, libraryLoader) + @@ -120,7 +120,7 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas val description = "${logPrefix}Preparing commonized Kotlin/Native libraries for targets $targetNames$descriptionSuffix" println(description) - NativeDistributionCommonizer( + LibraryCommonizer( repository = repository, konanDistribution = distribution, dependencies = EmptyRepository, diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionCommonizer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt similarity index 96% rename from native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionCommonizer.kt rename to native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt index df23088222e..b2e3e6a1ff2 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionCommonizer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.descriptors.commonizer.konan import org.jetbrains.kotlin.descriptors.commonizer.* import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.cli.toProgressLogger -import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeDistributionCommonizer.* +import org.jetbrains.kotlin.descriptors.commonizer.konan.LibraryCommonizer.* import org.jetbrains.kotlin.descriptors.commonizer.repository.Repository import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsCollector import org.jetbrains.kotlin.descriptors.commonizer.utils.ResettableClockMark @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.konan.target.KonanTarget import org.jetbrains.kotlin.storage.LockBasedStorageManager import org.jetbrains.kotlin.util.Logger -internal class NativeDistributionCommonizer internal constructor( +internal class LibraryCommonizer internal constructor( private val konanDistribution: KonanDistribution, private val repository: Repository, private val dependencies: Repository, From adb05ab076da2d69b6942e7efb39b636f098aec3 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 15 Feb 2021 18:34:50 +0100 Subject: [PATCH 247/368] JVM IR: write inherited multifile parts flag to kotlin.Metadata This flag is unused at the moment, but might be used one day to support proper incremental compilation for multifile classes. --- .../FirBlackBoxCodegenTestGenerated.java | 6 +++ .../backend/jvm/codegen/ClassCodegen.kt | 21 +++++--- .../box/multifileClasses/metadataFlag.kt | 50 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 +++ .../IrBlackBoxCodegenTestGenerated.java | 6 +++ .../LightAnalysisModeTestGenerated.java | 5 ++ 6 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 compiler/testData/codegen/box/multifileClasses/metadataFlag.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 959af81e15f..2abd3a2743b 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -24010,6 +24010,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/multifileClasses/kt16077.kt"); } + @Test + @TestMetadata("metadataFlag.kt") + public void testMetadataFlag() throws Exception { + runTest("compiler/testData/codegen/box/multifileClasses/metadataFlag.kt"); + } + @Test @TestMetadata("multifileClassPartsInitialization.kt") public void testMultifileClassPartsInitialization() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt index 13bc92b485f..705ad911636 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt @@ -10,8 +10,12 @@ import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.lower.MultifileFacadeFileEntry import org.jetbrains.kotlin.backend.jvm.lower.buildAssertionsDisabledField import org.jetbrains.kotlin.backend.jvm.lower.hasAssertionsDisabledField -import org.jetbrains.kotlin.codegen.* +import org.jetbrains.kotlin.codegen.DescriptorAsmUtil +import org.jetbrains.kotlin.codegen.VersionIndependentOpcodes +import org.jetbrains.kotlin.codegen.addRecordComponent import org.jetbrains.kotlin.codegen.inline.* +import org.jetbrains.kotlin.codegen.writeKotlinMetadata +import org.jetbrains.kotlin.config.JvmAnalysisFlags import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.descriptors.DescriptorVisibilities @@ -194,9 +198,6 @@ class ClassCodegen private constructor( ) private fun generateKotlinMetadataAnnotation() { - // TODO: if `-Xmultifile-parts-inherit` is enabled, write the corresponding flag for parts and facades to [Metadata.extraInt]. - val extraFlags = context.backendExtension.generateMetadataExtraFlags(state.abiStability) - val facadeClassName = context.multifileFacadeForPart[irClass.attributeOwnerId] val metadata = irClass.metadata val entry = irClass.fileParent.fileEntry @@ -208,6 +209,14 @@ class ClassCodegen private constructor( entry is MultifileFacadeFileEntry -> KotlinClassHeader.Kind.MULTIFILE_CLASS else -> KotlinClassHeader.Kind.SYNTHETIC_CLASS } + + val isMultifileClassOrPart = kind == KotlinClassHeader.Kind.MULTIFILE_CLASS || kind == KotlinClassHeader.Kind.MULTIFILE_CLASS_PART + + var extraFlags = context.backendExtension.generateMetadataExtraFlags(state.abiStability) + if (isMultifileClassOrPart && state.languageVersionSettings.getFlag(JvmAnalysisFlags.inheritMultifileParts)) { + extraFlags = extraFlags or JvmAnnotationNames.METADATA_MULTIFILE_PARTS_INHERIT_FLAG + } + writeKotlinMetadata(visitor, state, kind, extraFlags) { if (metadata != null) { metadataSerializer.serialize(metadata)?.let { (proto, stringTable) -> @@ -229,9 +238,7 @@ class ClassCodegen private constructor( } if (irClass in context.classNameOverride) { - val isFileClass = kind == KotlinClassHeader.Kind.MULTIFILE_CLASS || - kind == KotlinClassHeader.Kind.MULTIFILE_CLASS_PART || - kind == KotlinClassHeader.Kind.FILE_FACADE + val isFileClass = isMultifileClassOrPart || kind == KotlinClassHeader.Kind.FILE_FACADE assert(isFileClass) { "JvmPackageName is not supported for classes: ${irClass.render()}" } it.visit(JvmAnnotationNames.METADATA_PACKAGE_NAME_FIELD_NAME, irClass.fqNameWhenAvailable!!.parent().asString()) } diff --git a/compiler/testData/codegen/box/multifileClasses/metadataFlag.kt b/compiler/testData/codegen/box/multifileClasses/metadataFlag.kt new file mode 100644 index 00000000000..7e0ee954544 --- /dev/null +++ b/compiler/testData/codegen/box/multifileClasses/metadataFlag.kt @@ -0,0 +1,50 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME + +// FIR reports unresolved reference on `extraInt`. +// IGNORE_BACKEND_FIR: JVM_IR + +// MODULE: optimized +// !INHERIT_MULTIFILE_PARTS +// FILE: optimized.kt + +@file:JvmMultifileClass +@file:JvmName("Optimized") +package optimized + +fun test() {} + +class RandomClass + +// MODULE: main(optimized) +// FILE: default.kt + +@file:JvmMultifileClass +@file:JvmName("Default") +package default + +fun test() {} + +// FILE: box.kt + +fun isFlagSet(className: String): Boolean { + val extraInt = Class.forName(className).getAnnotation(Metadata::class.java).extraInt + return (extraInt and (1 shl 0)) != 0 +} + +fun box(): String { + if (isFlagSet("default.Default")) + return "Fail: inherited multifile parts flag should NOT be set by default for the facade" + if (isFlagSet("default.Default__DefaultKt")) + return "Fail: inherited multifile parts flag should NOT be set by default for the part" + + if (!isFlagSet("optimized.Optimized")) + return "Fail: inherited multifile parts flag SHOULD be set by default for the facade" + if (!isFlagSet("optimized.Optimized__OptimizedKt")) + return "Fail: inherited multifile parts flag SHOULD be set by default for the part" + + if (isFlagSet("optimized.RandomClass")) + return "Fail: inherited multifile parts flag should NOT be set by default for some random class if -Xmultifile-part-inherit is enabled" + + return "OK" +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 1261d8e2386..a54c619c34d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -24010,6 +24010,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/multifileClasses/kt16077.kt"); } + @Test + @TestMetadata("metadataFlag.kt") + public void testMetadataFlag() throws Exception { + runTest("compiler/testData/codegen/box/multifileClasses/metadataFlag.kt"); + } + @Test @TestMetadata("multifileClassPartsInitialization.kt") public void testMultifileClassPartsInitialization() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 6968dda1cf0..b145c3735d4 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -24010,6 +24010,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/multifileClasses/kt16077.kt"); } + @Test + @TestMetadata("metadataFlag.kt") + public void testMetadataFlag() throws Exception { + runTest("compiler/testData/codegen/box/multifileClasses/metadataFlag.kt"); + } + @Test @TestMetadata("multifileClassPartsInitialization.kt") public void testMultifileClassPartsInitialization() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 79bd3056596..5f14b1c8bea 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -20367,6 +20367,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/multifileClasses/kt16077.kt"); } + @TestMetadata("metadataFlag.kt") + public void testMetadataFlag() throws Exception { + runTest("compiler/testData/codegen/box/multifileClasses/metadataFlag.kt"); + } + @TestMetadata("multifileClassPartsInitialization.kt") public void testMultifileClassPartsInitialization() throws Exception { runTest("compiler/testData/codegen/box/multifileClasses/multifileClassPartsInitialization.kt"); From 9b4949a3c58f51c93f9f146abecaa10548583df9 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 17 Feb 2021 17:38:23 +0300 Subject: [PATCH 248/368] [FIR] Fix taking symbol of expression with smartcast inside DFA --- ...IsNotTouchedTilContractsPhaseTestGenerated.java | 5 +++++ .../boundSmartcasts/thisAssignment.fir.txt | 14 ++++++++++++++ .../smartcasts/boundSmartcasts/thisAssignment.kt | 12 ++++++++++++ .../test/runners/FirDiagnosticTestGenerated.java | 6 ++++++ .../FirDiagnosticsWithLightTreeTestGenerated.java | 6 ++++++ .../org/jetbrains/kotlin/fir/resolve/dfa/util.kt | 4 +++- 6 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.kt diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 084912af263..5bd3d252ab9 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -2944,6 +2944,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract public void testFunctionCallBound() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/functionCallBound.kt"); } + + @TestMetadata("thisAssignment.kt") + public void testThisAssignment() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.kt"); + } } @TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures") diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.fir.txt new file mode 100644 index 00000000000..7b4d98deb9d --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.fir.txt @@ -0,0 +1,14 @@ +FILE: thisAssignment.kt + public abstract interface A : R|kotlin/Any| { + public abstract fun foo(): R|kotlin/Unit| + + } + public final fun R|kotlin/Any|.test(): R|kotlin/Unit| { + when () { + (this@R|/test| is R|A|) -> { + lval a: R|kotlin/Any| = this@R|/test| + R|/a|.R|/A.foo|() + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.kt new file mode 100644 index 00000000000..9ead2245296 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.kt @@ -0,0 +1,12 @@ +interface A { + fun foo() +} + +fun Any.test() { + if (this is A) { + val a = this + a.foo() + } +} + + diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index dc995f11a31..e8ed54adf0d 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -3323,6 +3323,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { public void testFunctionCallBound() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/functionCallBound.kt"); } + + @Test + @TestMetadata("thisAssignment.kt") + public void testThisAssignment() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.kt"); + } } @Nested diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index fbdb96cf4b0..dfb0ad3938f 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -3362,6 +3362,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos public void testFunctionCallBound() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/functionCallBound.kt"); } + + @Test + @TestMetadata("thisAssignment.kt") + public void testThisAssignment() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/thisAssignment.kt"); + } } @Nested diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/util.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/util.kt index 34a41cfc1e7..7c763a21042 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/util.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/util.kt @@ -99,7 +99,7 @@ internal val FirElement.symbol: AbstractFirBasedSymbol<*>? is FirWhenSubjectExpression -> whenRef.value.subject?.symbol is FirSafeCallExpression -> regularQualifiedAccess.symbol else -> null - }?.takeIf { this is FirThisReceiverExpression || (it !is FirFunctionSymbol<*> && it !is FirAccessorSymbol) } + }?.takeIf { this.unwrapSmartcastExpression() is FirThisReceiverExpression || (it !is FirFunctionSymbol<*> && it !is FirAccessorSymbol) } @DfaInternals internal val FirResolvable.symbol: AbstractFirBasedSymbol<*>? @@ -109,3 +109,5 @@ internal val FirResolvable.symbol: AbstractFirBasedSymbol<*>? is FirNamedReferenceWithCandidate -> reference.candidateSymbol else -> null } + +private fun FirElement.unwrapSmartcastExpression(): FirElement = if (this is FirExpressionWithSmartcast) originalExpression else this From a3fa6c6d1369ba4226464b058243b8bed0016d97 Mon Sep 17 00:00:00 2001 From: Alexander Dudinsky Date: Wed, 17 Feb 2021 12:27:30 +0300 Subject: [PATCH 249/368] Publish artifacts needed for the kotlin-gradle-plugin in kotlin-ide repository --- build.gradle.kts | 6 ++ buildSrc/src/main/kotlin/tasks.kt | 83 +++++++++++-------- idea/idea-gradle/build.gradle.kts | 2 +- libraries/commonConfiguration.gradle | 4 +- .../build.gradle.kts | 2 +- 5 files changed, 57 insertions(+), 40 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 86d145a1f06..35cb043c57f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -948,6 +948,12 @@ tasks { } } + register("publishGradlePluginArtifacts") { + idePluginDependency { + dependsOnKotlinGradlePluginPublish() + } + } + register("publishIdeArtifacts") { idePluginDependency { dependsOn( diff --git a/buildSrc/src/main/kotlin/tasks.kt b/buildSrc/src/main/kotlin/tasks.kt index 51a47280ad4..4b2e483bf9a 100644 --- a/buildSrc/src/main/kotlin/tasks.kt +++ b/buildSrc/src/main/kotlin/tasks.kt @@ -20,42 +20,53 @@ import java.lang.Character.isUpperCase import java.nio.file.Files import java.nio.file.Path -fun Task.dependsOnKotlinPluginInstall() { - dependsOn( - ":kotlin-allopen:install", - ":kotlin-noarg:install", - ":kotlin-sam-with-receiver:install", - ":kotlin-android-extensions:install", - ":kotlin-parcelize-compiler:install", - ":kotlin-build-common:install", - ":kotlin-compiler-embeddable:install", - ":native:kotlin-native-utils:install", - ":kotlin-util-klib:install", - ":kotlin-util-io:install", - ":kotlin-compiler-runner:install", - ":kotlin-daemon-embeddable:install", - ":kotlin-daemon-client:install", - ":kotlin-gradle-plugin-api:install", - ":kotlin-gradle-plugin:install", - ":kotlin-gradle-plugin-model:install", - ":kotlin-reflect:install", - ":kotlin-annotation-processing-gradle:install", - ":kotlin-test:install", - ":kotlin-gradle-subplugin-example:install", - ":kotlin-stdlib-common:install", - ":kotlin-stdlib:install", - ":kotlin-stdlib-jdk8:install", - ":kotlin-stdlib-js:install", - ":examples:annotation-processor-example:install", - ":kotlin-script-runtime:install", - ":kotlin-scripting-common:install", - ":kotlin-scripting-jvm:install", - ":kotlin-scripting-compiler-embeddable:install", - ":kotlin-scripting-compiler-impl-embeddable:install", - ":kotlin-test-js-runner:install", - ":native:kotlin-klib-commonizer-embeddable:install", - ":native:kotlin-klib-commonizer-api:install" - ) +val kotlinGradlePluginAndItsRequired = arrayOf( + ":kotlin-allopen", + ":kotlin-noarg", + ":kotlin-sam-with-receiver", + ":kotlin-android-extensions", + ":kotlin-parcelize-compiler", + ":kotlin-build-common", + ":kotlin-compiler-embeddable", + ":native:kotlin-native-utils", + ":kotlin-util-klib", + ":kotlin-util-io", + ":kotlin-compiler-runner", + ":kotlin-daemon-embeddable", + ":kotlin-daemon-client", + ":kotlin-gradle-plugin-api", + ":kotlin-gradle-plugin", + ":kotlin-gradle-plugin-model", + ":kotlin-reflect", + ":kotlin-annotation-processing-gradle", + ":kotlin-test", + ":kotlin-gradle-subplugin-example", + ":kotlin-stdlib-common", + ":kotlin-stdlib", + ":kotlin-stdlib-jdk8", + ":kotlin-stdlib-js", + ":examples:annotation-processor-example", + ":kotlin-script-runtime", + ":kotlin-scripting-common", + ":kotlin-scripting-jvm", + ":kotlin-scripting-compiler-embeddable", + ":kotlin-scripting-compiler-impl-embeddable", + ":kotlin-test-js-runner", + ":native:kotlin-klib-commonizer-embeddable" +) + +fun Task.dependsOnKotlinGradlePluginInstall() { + kotlinGradlePluginAndItsRequired.forEach { + dependsOn("${it}:install") + } +} + +fun Task.dependsOnKotlinGradlePluginPublish() { + kotlinGradlePluginAndItsRequired.forEach { + project.rootProject.tasks.findByPath("${it}:publish")?.let { task -> + dependsOn(task) + } + } } fun Project.projectTest( diff --git a/idea/idea-gradle/build.gradle.kts b/idea/idea-gradle/build.gradle.kts index 2dbf4ee68aa..d85fd0aba37 100644 --- a/idea/idea-gradle/build.gradle.kts +++ b/idea/idea-gradle/build.gradle.kts @@ -99,7 +99,7 @@ testsJar() projectTest(parallel = false) { dependsOn(":dist") - dependsOnKotlinPluginInstall() + dependsOnKotlinGradlePluginInstall() if (!Ide.AS41.orHigher()) { systemProperty("android.studio.sdk.manager.disabled", "true") } diff --git a/libraries/commonConfiguration.gradle b/libraries/commonConfiguration.gradle index a5af870d911..fb226d640b2 100644 --- a/libraries/commonConfiguration.gradle +++ b/libraries/commonConfiguration.gradle @@ -112,8 +112,8 @@ task preparePublication { project.ext['signing.password'] = project.properties['kotlin.key.passphrase'] String sonatypeSnapshotsUrl = (isSonatypePublish && !isRelease) ? "https://oss.sonatype.org/content/repositories/snapshots/" : null - - ext.repoUrl = properties["deployRepoUrl"] ?: sonatypeSnapshotsUrl ?: properties["deploy-url"] ?: "file://${rootProject.buildDir}/repo".toString() + String repoFolder = properties["deployRepoFolder"] ?: "repo" + ext.repoUrl = properties["deployRepoUrl"] ?: sonatypeSnapshotsUrl ?: properties["deploy-url"] ?: "file://${rootProject.buildDir}/${repoFolder}".toString() ext.username = properties["deployRepoUsername"] ?: properties["kotlin.${repoProvider}.user"] ext.password = properties["deployRepoPassword"] ?: properties["kotlin.${repoProvider}.password"] diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts index 60c89d7c839..d1a94fb4fe6 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/build.gradle.kts @@ -157,7 +157,7 @@ tasks.withType { onlyIf { !project.hasProperty("noTest") } dependsOn(":kotlin-gradle-plugin:validateTaskProperties") - dependsOnKotlinPluginInstall() + dependsOnKotlinGradlePluginInstall() executable = "${rootProject.extra["JDK_18"]!!}/bin/java" From 82ac4821433b0776e2931e6cfc5b98c922a77337 Mon Sep 17 00:00:00 2001 From: Hyojae Kim Date: Thu, 18 Feb 2021 18:28:19 +0900 Subject: [PATCH 250/368] Fix typo (#4051) Fix typo --- .../runners/FirOldFrontendDiagnosticsTestGenerated.java | 6 +++--- ...ialization.fir.kt => varIndefiniteInitialization.fir.kt} | 0 ...initeIntialization.kt => varIndefiniteInitialization.kt} | 0 ...iteIntialization.txt => varIndefiniteInitialization.txt} | 0 .../kotlin/test/runners/DiagnosticTestGenerated.java | 6 +++--- .../org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) rename compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/{varIndefiniteIntialization.fir.kt => varIndefiniteInitialization.fir.kt} (100%) rename compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/{varIndefiniteIntialization.kt => varIndefiniteInitialization.kt} (100%) rename compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/{varIndefiniteIntialization.txt => varIndefiniteInitialization.txt} (100%) diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 76568acc0cd..b377e3129e6 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -31809,9 +31809,9 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti } @Test - @TestMetadata("varIndefiniteIntialization.kt") - public void testVarIndefiniteIntialization() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.kt"); + @TestMetadata("varIndefiniteInitialization.kt") + public void testVarIndefiniteInitialization() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteInitialization.kt"); } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteInitialization.fir.kt similarity index 100% rename from compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.fir.kt rename to compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteInitialization.fir.kt diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteInitialization.kt similarity index 100% rename from compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.kt rename to compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteInitialization.kt diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.txt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteInitialization.txt similarity index 100% rename from compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.txt rename to compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteInitialization.txt diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 6e7bb6e4ed0..f9a9f827efc 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -31905,9 +31905,9 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { } @Test - @TestMetadata("varIndefiniteIntialization.kt") - public void testVarIndefiniteIntialization() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteIntialization.kt"); + @TestMetadata("varIndefiniteInitialization.kt") + public void testVarIndefiniteInitialization() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/initialization/atLeastOnce/varIndefiniteInitialization.kt"); } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt index 1d56732bf87..b0880333037 100755 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt @@ -477,7 +477,7 @@ internal abstract class AbstractKotlinPlugin( } } - // Setup conf2ScopeMappings so that the API dependencies are wriiten with the compile scope in the POMs in case of 'java' plugin + // Setup conf2ScopeMappings so that the API dependencies are written with the compile scope in the POMs in case of 'java' plugin project.convention.getPlugin(MavenPluginConvention::class.java) .conf2ScopeMappings.addMapping(0, project.configurations.getByName("api"), Conf2ScopeMappingContainer.COMPILE) } From 49fc1b9e3e613a4b44716ac0f8fbb37bf4864e18 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 17 Feb 2021 23:02:30 +0100 Subject: [PATCH 251/368] Build: enable -Werror for several modules --- build.gradle.kts | 5 +---- compiler/cli/build.gradle.kts | 4 +++- .../uast/kotlin/generate/KotlinUastCodeGenerationPlugin.kt | 2 ++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 35cb043c57f..88ef1820899 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -325,11 +325,8 @@ extra["tasksWithWarnings"] = listOf( ":kotlin-stdlib:compileTestKotlin", ":kotlin-stdlib-jdk7:compileTestKotlin", ":kotlin-stdlib-jdk8:compileTestKotlin", - ":compiler:cli:compileKotlin", - ":kotlin-scripting-compiler:compileKotlin", ":plugins:uast-kotlin:compileKotlin", - ":plugins:uast-kotlin:compileTestKotlin", - ":plugins:uast-kotlin-idea:compileKotlin" + ":plugins:uast-kotlin:compileTestKotlin" ) val tasksWithWarnings: List by extra diff --git a/compiler/cli/build.gradle.kts b/compiler/cli/build.gradle.kts index 536c89fc0f9..4b625d46d34 100644 --- a/compiler/cli/build.gradle.kts +++ b/compiler/cli/build.gradle.kts @@ -56,7 +56,9 @@ tasks.withType> { kotlinOptions { languageVersion = "1.3" apiVersion = "1.3" - freeCompilerArgs = freeCompilerArgs - "-progressive" + "-Xskip-prerelease-check" + freeCompilerArgs = freeCompilerArgs - "-progressive" + listOf( + "-Xskip-prerelease-check", "-Xsuppress-version-warnings" + ) } } diff --git a/plugins/uast-kotlin-idea/src/org/jetbrains/uast/kotlin/generate/KotlinUastCodeGenerationPlugin.kt b/plugins/uast-kotlin-idea/src/org/jetbrains/uast/kotlin/generate/KotlinUastCodeGenerationPlugin.kt index 9a3dbe575cb..b4e78d8f8d9 100644 --- a/plugins/uast-kotlin-idea/src/org/jetbrains/uast/kotlin/generate/KotlinUastCodeGenerationPlugin.kt +++ b/plugins/uast-kotlin-idea/src/org/jetbrains/uast/kotlin/generate/KotlinUastCodeGenerationPlugin.kt @@ -91,6 +91,7 @@ class KotlinUastElementFactory(project: Project) : UastElementFactory { return createQualifiedReference(qualifiedName, context?.sourcePsi) } + @Suppress("UNUSED_PARAMETER") /*override*/ fun createQualifiedReference(qualifiedName: String, context: PsiElement?): UQualifiedReferenceExpression? { return psiFactory.createExpression(qualifiedName).let { when (it) { @@ -153,6 +154,7 @@ class KotlinUastElementFactory(project: Project) : UastElementFactory { return psiFactory.createExpression("null").toUElementOfType()!! } + @Suppress("UNUSED_PARAMETER") /*override*/ fun createIntLiteral(value: Int, context: PsiElement?): ULiteralExpression { return psiFactory.createExpression(value.toString()).toUElementOfType()!! } From 1d6b19891517f8e2daccfde513160127728d47f0 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 17 Feb 2021 23:09:33 +0100 Subject: [PATCH 252/368] Build: suppress version and JVM target warnings To further reduce the output on each build. --- buildSrc/build.gradle.kts | 5 +++-- compiler/daemon/daemon-client-new/build.gradle.kts | 1 + compiler/daemon/daemon-client/build.gradle.kts | 1 + idea/kotlin-gradle-tooling/build.gradle.kts | 6 ++++++ libraries/kotlinx-metadata/build.gradle.kts | 6 ++++++ libraries/kotlinx-metadata/jvm/build.gradle.kts | 6 ++++++ libraries/scripting/common/build.gradle.kts | 5 +++-- libraries/scripting/dependencies-maven/build.gradle.kts | 5 +++-- libraries/scripting/dependencies/build.gradle.kts | 5 +++-- libraries/stdlib/jvm-minimal-for-test/build.gradle.kts | 2 +- libraries/stdlib/jvm/build.gradle | 1 + libraries/tools/kotlin-allopen/build.gradle | 4 +++- libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts | 4 +++- libraries/tools/kotlin-gradle-plugin-model/build.gradle.kts | 4 +++- libraries/tools/kotlin-gradle-plugin/build.gradle.kts | 4 +++- libraries/tools/kotlin-noarg/build.gradle | 4 +++- libraries/tools/kotlin-sam-with-receiver/build.gradle | 4 +++- .../sam-with-receiver-cli/build.gradle.kts | 1 - 18 files changed, 52 insertions(+), 16 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 3ec018187ed..0322a6a739d 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -128,8 +128,9 @@ java { } tasks.withType().configureEach { - kotlinOptions.freeCompilerArgs += - listOf("-Xopt-in=kotlin.RequiresOptIn", "-Xskip-runtime-version-check") + kotlinOptions.freeCompilerArgs += listOf( + "-Xopt-in=kotlin.RequiresOptIn", "-Xskip-runtime-version-check", "-Xsuppress-version-warnings" + ) } tasks["build"].dependsOn(":prepare-deps:build") diff --git a/compiler/daemon/daemon-client-new/build.gradle.kts b/compiler/daemon/daemon-client-new/build.gradle.kts index c94462e9635..bf93f440a3d 100644 --- a/compiler/daemon/daemon-client-new/build.gradle.kts +++ b/compiler/daemon/daemon-client-new/build.gradle.kts @@ -50,6 +50,7 @@ dependencies { tasks.withType> { kotlinOptions { apiVersion = "1.3" + freeCompilerArgs += "-Xsuppress-version-warnings" } } diff --git a/compiler/daemon/daemon-client/build.gradle.kts b/compiler/daemon/daemon-client/build.gradle.kts index 1be90e1a62d..20923bdfec7 100644 --- a/compiler/daemon/daemon-client/build.gradle.kts +++ b/compiler/daemon/daemon-client/build.gradle.kts @@ -42,6 +42,7 @@ tasks.withType> { kotlinOptions { // This module is being run from within Gradle, older versions of which only have kotlin-stdlib 1.3 in the runtime classpath. apiVersion = "1.3" + freeCompilerArgs += "-Xsuppress-version-warnings" } } diff --git a/idea/kotlin-gradle-tooling/build.gradle.kts b/idea/kotlin-gradle-tooling/build.gradle.kts index 60b4dd929f4..06764e4de8f 100644 --- a/idea/kotlin-gradle-tooling/build.gradle.kts +++ b/idea/kotlin-gradle-tooling/build.gradle.kts @@ -19,6 +19,12 @@ sourceSets { "test" {} } +tasks.withType> { + kotlinOptions { + freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning" + } +} + runtimeJar() sourcesJar() diff --git a/libraries/kotlinx-metadata/build.gradle.kts b/libraries/kotlinx-metadata/build.gradle.kts index e545c5e09ca..c24e2411374 100644 --- a/libraries/kotlinx-metadata/build.gradle.kts +++ b/libraries/kotlinx-metadata/build.gradle.kts @@ -18,3 +18,9 @@ dependencies { compileOnly(project(":core:metadata")) compileOnly(protobufLite()) } + +tasks.withType> { + kotlinOptions { + freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning" + } +} diff --git a/libraries/kotlinx-metadata/jvm/build.gradle.kts b/libraries/kotlinx-metadata/jvm/build.gradle.kts index 6a6c85bbacb..72d540a524c 100644 --- a/libraries/kotlinx-metadata/jvm/build.gradle.kts +++ b/libraries/kotlinx-metadata/jvm/build.gradle.kts @@ -48,6 +48,12 @@ dependencies { testRuntimeOnly(project(":kotlin-reflect")) } +tasks.withType> { + kotlinOptions { + freeCompilerArgs += "-Xsuppress-deprecated-jvm-target-warning" + } +} + if (deployVersion != null) { publish() } diff --git a/libraries/scripting/common/build.gradle.kts b/libraries/scripting/common/build.gradle.kts index 9955f16991b..1b0adbdfd28 100644 --- a/libraries/scripting/common/build.gradle.kts +++ b/libraries/scripting/common/build.gradle.kts @@ -1,4 +1,3 @@ - plugins { kotlin("jvm") id("jps-compatible") @@ -19,7 +18,9 @@ sourceSets { } tasks.withType> { - kotlinOptions.freeCompilerArgs += "-Xallow-kotlin-package" + kotlinOptions.freeCompilerArgs += listOf( + "-Xallow-kotlin-package", "-Xsuppress-deprecated-jvm-target-warning" + ) } publish() diff --git a/libraries/scripting/dependencies-maven/build.gradle.kts b/libraries/scripting/dependencies-maven/build.gradle.kts index a371f4b98b7..a4378fc558f 100644 --- a/libraries/scripting/dependencies-maven/build.gradle.kts +++ b/libraries/scripting/dependencies-maven/build.gradle.kts @@ -1,4 +1,3 @@ - plugins { kotlin("jvm") id("jps-compatible") @@ -32,7 +31,9 @@ sourceSets { } tasks.withType> { - kotlinOptions.freeCompilerArgs += "-Xallow-kotlin-package" + kotlinOptions.freeCompilerArgs += listOf( + "-Xallow-kotlin-package", "-Xsuppress-deprecated-jvm-target-warning" + ) } publish() diff --git a/libraries/scripting/dependencies/build.gradle.kts b/libraries/scripting/dependencies/build.gradle.kts index b889f05eb85..a9f6d5b2c1f 100644 --- a/libraries/scripting/dependencies/build.gradle.kts +++ b/libraries/scripting/dependencies/build.gradle.kts @@ -1,4 +1,3 @@ - plugins { kotlin("jvm") id("jps-compatible") @@ -18,7 +17,9 @@ sourceSets { } tasks.withType> { - kotlinOptions.freeCompilerArgs += "-Xallow-kotlin-package" + kotlinOptions.freeCompilerArgs += listOf( + "-Xallow-kotlin-package", "-Xsuppress-deprecated-jvm-target-warning" + ) } publish() diff --git a/libraries/stdlib/jvm-minimal-for-test/build.gradle.kts b/libraries/stdlib/jvm-minimal-for-test/build.gradle.kts index 4bdac657e5a..38cd5f2ac1f 100644 --- a/libraries/stdlib/jvm-minimal-for-test/build.gradle.kts +++ b/libraries/stdlib/jvm-minimal-for-test/build.gradle.kts @@ -65,6 +65,7 @@ tasks.withType { freeCompilerArgs += listOf( "-Xallow-kotlin-package", "-Xmulti-platform", + "-Xsuppress-deprecated-jvm-target-warning", "-Xopt-in=kotlin.RequiresOptIn", "-Xopt-in=kotlin.contracts.ExperimentalContracts" ) @@ -90,4 +91,3 @@ publishing { maven("${rootProject.buildDir}/internal/repo") } } - diff --git a/libraries/stdlib/jvm/build.gradle b/libraries/stdlib/jvm/build.gradle index 9a48d3bf301..67f05c2259d 100644 --- a/libraries/stdlib/jvm/build.gradle +++ b/libraries/stdlib/jvm/build.gradle @@ -136,6 +136,7 @@ compileTestKotlin { "-Xopt-in=kotlin.RequiresOptIn", "-Xopt-in=kotlin.ExperimentalUnsignedTypes", "-Xopt-in=kotlin.ExperimentalStdlibApi", + "-Xsuppress-deprecated-jvm-target-warning", ] // This is needed for JavaTypeTest; typeOf for non-reified type parameters doesn't work otherwise, for implementation reasons. freeCompilerArgs.remove("-Xno-optimized-callable-references") diff --git a/libraries/tools/kotlin-allopen/build.gradle b/libraries/tools/kotlin-allopen/build.gradle index 536acf8add2..cc85eb13c72 100644 --- a/libraries/tools/kotlin-allopen/build.gradle +++ b/libraries/tools/kotlin-allopen/build.gradle @@ -26,7 +26,9 @@ dependencies { tasks.withType(project.compileKotlin.class) { kotlinOptions.languageVersion = "1.3" kotlinOptions.apiVersion = "1.3" - kotlinOptions.freeCompilerArgs += ["-Xskip-prerelease-check", "-Xskip-runtime-version-check"] + kotlinOptions.freeCompilerArgs += [ + "-Xskip-prerelease-check", "-Xskip-runtime-version-check", "-Xsuppress-version-warnings" + ] } jar { diff --git a/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts index fe436db8a7f..c7ffbcbf555 100644 --- a/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-api/build.gradle.kts @@ -26,7 +26,9 @@ tasks { withType { kotlinOptions.languageVersion = "1.3" kotlinOptions.apiVersion = "1.3" - kotlinOptions.freeCompilerArgs += listOf("-Xskip-prerelease-check") + kotlinOptions.freeCompilerArgs += listOf( + "-Xskip-prerelease-check", "-Xsuppress-version-warnings" + ) } named("jar") { diff --git a/libraries/tools/kotlin-gradle-plugin-model/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-model/build.gradle.kts index cd28b8da42a..4ce6cbf8cd5 100644 --- a/libraries/tools/kotlin-gradle-plugin-model/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin-model/build.gradle.kts @@ -22,7 +22,9 @@ tasks { withType { kotlinOptions.languageVersion = "1.3" kotlinOptions.apiVersion = "1.3" - kotlinOptions.freeCompilerArgs += listOf("-Xskip-prerelease-check") + kotlinOptions.freeCompilerArgs += listOf( + "-Xskip-prerelease-check", "-Xsuppress-version-warnings" + ) } named("jar") { diff --git a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts index 74be09e504c..b0b1c7a6fee 100644 --- a/libraries/tools/kotlin-gradle-plugin/build.gradle.kts +++ b/libraries/tools/kotlin-gradle-plugin/build.gradle.kts @@ -124,7 +124,9 @@ tasks { kotlinOptions.jdkHome = rootProject.extra["JDK_18"] as String kotlinOptions.languageVersion = "1.3" kotlinOptions.apiVersion = "1.3" - kotlinOptions.freeCompilerArgs += listOf("-Xskip-prerelease-check") + kotlinOptions.freeCompilerArgs += listOf( + "-Xskip-prerelease-check", "-Xsuppress-version-warnings" + ) } named("processResources") { diff --git a/libraries/tools/kotlin-noarg/build.gradle b/libraries/tools/kotlin-noarg/build.gradle index b30bf561c84..2cd5fb8f2d9 100644 --- a/libraries/tools/kotlin-noarg/build.gradle +++ b/libraries/tools/kotlin-noarg/build.gradle @@ -32,7 +32,9 @@ dependencies { tasks.withType(project.compileKotlin.class) { kotlinOptions.languageVersion = "1.3" kotlinOptions.apiVersion = "1.3" - kotlinOptions.freeCompilerArgs += ["-Xskip-prerelease-check", "-Xskip-runtime-version-check"] + kotlinOptions.freeCompilerArgs += [ + "-Xskip-prerelease-check", "-Xskip-runtime-version-check", "-Xsuppress-version-warnings" + ] } jar { diff --git a/libraries/tools/kotlin-sam-with-receiver/build.gradle b/libraries/tools/kotlin-sam-with-receiver/build.gradle index edfe8f7b30f..7ae03b1566d 100644 --- a/libraries/tools/kotlin-sam-with-receiver/build.gradle +++ b/libraries/tools/kotlin-sam-with-receiver/build.gradle @@ -32,7 +32,9 @@ dependencies { tasks.withType(project.compileKotlin.class) { kotlinOptions.languageVersion = "1.3" kotlinOptions.apiVersion = "1.3" - kotlinOptions.freeCompilerArgs += ["-Xskip-prerelease-check", "-Xskip-runtime-version-check"] + kotlinOptions.freeCompilerArgs += [ + "-Xskip-prerelease-check", "-Xskip-runtime-version-check", "-Xsuppress-version-warnings" + ] } jar { diff --git a/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts b/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts index 8f79c1e3ca0..55bba0cd277 100644 --- a/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts +++ b/plugins/sam-with-receiver/sam-with-receiver-cli/build.gradle.kts @@ -1,4 +1,3 @@ - description = "Kotlin SamWithReceiver Compiler Plugin" plugins { From dbadd5846a440eb98e913b8c64f7fef583129c0a Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 15 Feb 2021 20:18:00 +0100 Subject: [PATCH 253/368] Add test for script flag in kotlin.Metadata It passes at the moment because the test uses old backend, but the required behavior is not yet supported in JVM IR, and it'll need to be fixed. --- .../testData/compiler/metadata_flag.kts | 3 +++ .../scripting/compiler/test/ScriptTest.kt | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 plugins/scripting/scripting-compiler/testData/compiler/metadata_flag.kts diff --git a/plugins/scripting/scripting-compiler/testData/compiler/metadata_flag.kts b/plugins/scripting/scripting-compiler/testData/compiler/metadata_flag.kts new file mode 100644 index 00000000000..2c6cf40c67d --- /dev/null +++ b/plugins/scripting/scripting-compiler/testData/compiler/metadata_flag.kts @@ -0,0 +1,3 @@ +class RandomClass + +println() diff --git a/plugins/scripting/scripting-compiler/tests/org/jetbrains/kotlin/scripting/compiler/test/ScriptTest.kt b/plugins/scripting/scripting-compiler/tests/org/jetbrains/kotlin/scripting/compiler/test/ScriptTest.kt index 73e4f3c8ec4..e0f63bb36fa 100644 --- a/plugins/scripting/scripting-compiler/tests/org/jetbrains/kotlin/scripting/compiler/test/ScriptTest.kt +++ b/plugins/scripting/scripting-compiler/tests/org/jetbrains/kotlin/scripting/compiler/test/ScriptTest.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.codegen.CompilationException import org.jetbrains.kotlin.config.JVMConfigurationKeys +import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.kotlin.script.loadScriptingPlugin import org.jetbrains.kotlin.scripting.configuration.ScriptingConfigurationKeys import org.jetbrains.kotlin.scripting.definitions.KotlinScriptDefinition @@ -86,6 +87,23 @@ class ScriptTest : TestCase() { assertEqualsTrimmed("[(1, a)]", out) } + fun testMetadataFlag() { + // Test that we're writing the flag to [Metadata.extraInt] that distinguishes scripts from other classes. + + fun Class<*>.isFlagSet(): Boolean { + val metadata = annotations.single { it.annotationClass.java.name == Metadata::class.java.name } + val extraInt = metadata.javaClass.methods.single { it.name == JvmAnnotationNames.METADATA_EXTRA_INT_FIELD_NAME } + return (extraInt(metadata) as Int) and JvmAnnotationNames.METADATA_SCRIPT_FLAG != 0 + } + + val scriptClass = compileScript("metadata_flag.kts", StandardScriptDefinition)!! + assertTrue("Script class SHOULD have the metadata flag set", scriptClass.isFlagSet()) + assertFalse( + "Non-script class in a script should NOT have the metadata flag set", + scriptClass.classLoader.loadClass("Metadata_flag\$RandomClass").isFlagSet() + ) + } + private fun compileScript( scriptPath: String, scriptDefinition: KotlinScriptDefinition, From 8c95b783463f20029c74e613d9802b22bb2ff40d Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 15 Feb 2021 18:07:38 +0100 Subject: [PATCH 254/368] Update JVM metadata version to 1.5.0 Improve the test which checks that we use correct metadata version if `-language-version` is passed by checking all supported language versions. The change in libraries/reflect/build.gradle.kts is needed because kotlinx-metadata-jvm of version 0.1.0 is based on pre-1.4 Kotlin, which doesn't support the new module file metadata generated with metadata version 1.4 and later, and module files need to be readable there to be able to transform them for the shadow plugin. Similarly override dependency on kotlinx-metadata-jvm in the binary-compatibility-validator module. --- .../kotlin/codegen/state/GenerationState.kt | 23 +++++++++++-- .../output.txt | 10 +++--- .../CompileKotlinAgainstCustomBinariesTest.kt | 32 ++++++++++++++----- .../jvm/deserialization/JvmMetadataVersion.kt | 2 +- libraries/reflect/build.gradle.kts | 2 +- .../build.gradle | 5 +++ 6 files changed, 57 insertions(+), 17 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt index ed57f52192a..f24b29deb7a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/GenerationState.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods import org.jetbrains.kotlin.codegen.optimization.OptimizationClassBuilderFactory import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings import org.jetbrains.kotlin.config.* +import org.jetbrains.kotlin.config.LanguageVersion.* import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.ScriptDescriptor @@ -49,6 +50,7 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeApproximator import org.jetbrains.org.objectweb.asm.Type import java.io.File +import java.util.* class GenerationState private constructor( val project: Project, @@ -320,8 +322,7 @@ class GenerationState private constructor( val metadataVersion = configuration.get(CommonConfigurationKeys.METADATA_VERSION) - ?: if (languageVersionSettings.languageVersion >= LanguageVersion.LATEST_STABLE) JvmMetadataVersion.INSTANCE - else JvmMetadataVersion(1, 1, 18) + ?: LANGUAGE_TO_METADATA_VERSION.getValue(languageVersionSettings.languageVersion) val abiStability = configuration.get(JVMConfigurationKeys.ABI_STABILITY) @@ -392,6 +393,24 @@ class GenerationState private constructor( private fun shouldOnlyCollectSignatures(origin: JvmDeclarationOrigin) = classBuilderMode == ClassBuilderMode.LIGHT_CLASSES && origin.originKind in doNotGenerateInLightClassMode + + companion object { + private val LANGUAGE_TO_METADATA_VERSION = EnumMap(LanguageVersion::class.java).apply { + val oldMetadataVersion = JvmMetadataVersion(1, 1, 18) + this[KOTLIN_1_0] = oldMetadataVersion + this[KOTLIN_1_1] = oldMetadataVersion + this[KOTLIN_1_2] = oldMetadataVersion + this[KOTLIN_1_3] = oldMetadataVersion + this[KOTLIN_1_4] = JvmMetadataVersion(1, 4, 3) + this[KOTLIN_1_5] = JvmMetadataVersion.INSTANCE + this[KOTLIN_1_6] = JvmMetadataVersion(1, 6, 0) + + check(size == LanguageVersion.values().size) { + "Please add mappings from the missing LanguageVersion instances to the corresponding JvmMetadataVersion " + + "in `GenerationState.LANGUAGE_TO_METADATA_VERSION`" + } + } + } } private val doNotGenerateInLightClassMode = setOf(CLASS_MEMBER_DELEGATION_TO_DEFAULT_IMPL, BRIDGE, COLLECTION_STUB, AUGMENTED_BUILTIN_API) diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/output.txt index 45fe2dc4d3c..516d02f626e 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/output.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/output.txt @@ -1,6 +1,6 @@ error: incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors -$TMP_DIR$/library.jar!/META-INF/main.kotlin_module: error: module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.0, expected version is $ABI_VERSION$. -compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:3:13: error: class 'a.C' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.0, expected version is $ABI_VERSION$. +$TMP_DIR$/library.jar!/META-INF/main.kotlin_module: error: module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is $ABI_VERSION$. +compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:3:13: error: class 'a.C' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is $ABI_VERSION$. The class is loaded from $TMP_DIR$/library.jar!/a/C.class fun test(c: C) { ^ @@ -10,15 +10,15 @@ compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemant compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:5:5: error: unresolved reference: v v ^ -compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:5: error: class 'a.C' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.0, expected version is $ABI_VERSION$. +compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:5: error: class 'a.C' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is $ABI_VERSION$. The class is loaded from $TMP_DIR$/library.jar!/a/C.class c.let { C() } ^ -compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:7: error: class 'a.C' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.0, expected version is $ABI_VERSION$. +compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:7: error: class 'a.C' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is $ABI_VERSION$. The class is loaded from $TMP_DIR$/library.jar!/a/C.class c.let { C() } ^ -compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:13: error: class 'a.C' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.0, expected version is $ABI_VERSION$. +compiler/testData/compileKotlinAgainstCustomBinaries/strictMetadataVersionSemanticsOldVersion/source.kt:6:13: error: class 'a.C' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is $ABI_VERSION$. The class is loaded from $TMP_DIR$/library.jar!/a/C.class c.let { C() } ^ diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt index 8b4940a5851..4eaf74593c2 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt @@ -421,22 +421,38 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration } fun testStrictMetadataVersionSemanticsOldVersion() { + val nextMetadataVersion = JvmMetadataVersion(JvmMetadataVersion.INSTANCE.major, JvmMetadataVersion.INSTANCE.minor + 1, 0) val library = compileLibrary( - "library", additionalOptions = listOf("-Xgenerate-strict-metadata-version", "-Xmetadata-version=1.5.0") + "library", additionalOptions = listOf("-Xgenerate-strict-metadata-version", "-Xmetadata-version=$nextMetadataVersion") ) compileKotlin("source.kt", tmpdir, listOf(library)) } fun testMetadataVersionDerivedFromLanguage() { - compileKotlin("source.kt", tmpdir, additionalOptions = listOf("-language-version", "1.3"), expectedFileName = null) + for (languageVersion in LanguageVersion.values()) { + if (languageVersion.isUnsupported) continue - val expectedVersion = JvmMetadataVersion(1, 1, 18) - val topLevelClass = LocalFileKotlinClass.create(File(tmpdir.absolutePath, "Foo.class"))!! - assertEquals(expectedVersion, topLevelClass.classHeader.metadataVersion) + compileKotlin( + "source.kt", tmpdir, additionalOptions = listOf("-language-version", languageVersion.versionString), + expectedFileName = null + ) - val moduleFile = File(tmpdir.absolutePath, "META-INF/main.kotlin_module").readBytes() - val versionNumber = ModuleMapping.readVersionNumber(DataInputStream(ByteArrayInputStream(moduleFile)))!! - assertEquals(expectedVersion, JvmMetadataVersion(*versionNumber)) + // Starting from Kotlin 1.4, major.minor version of JVM metadata must be equal to the language version. + // From Kotlin 1.0 to 1.4, we used JVM metadata version 1.1.*. + val expectedMajor = 1 + val expectedMinor = if (languageVersion < LanguageVersion.KOTLIN_1_4) 1 else languageVersion.minor + + val topLevelClass = LocalFileKotlinClass.create(File(tmpdir.absolutePath, "Foo.class"))!! + val classVersion = topLevelClass.classHeader.metadataVersion + assertEquals("Actual version: $classVersion", expectedMajor, classVersion.major) + assertEquals("Actual version: $classVersion", expectedMinor, classVersion.minor) + + val moduleFile = File(tmpdir.absolutePath, "META-INF/main.kotlin_module").readBytes() + val versionNumber = ModuleMapping.readVersionNumber(DataInputStream(ByteArrayInputStream(moduleFile)))!! + val moduleVersion = JvmMetadataVersion(*versionNumber) + assertEquals("Actual version: $moduleVersion", expectedMajor, moduleVersion.major) + assertEquals("Actual version: $moduleVersion", expectedMinor, moduleVersion.minor) + } } /*test source mapping generation when source info is absent*/ diff --git a/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/deserialization/JvmMetadataVersion.kt b/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/deserialization/JvmMetadataVersion.kt index 43e17e0ccdf..1b1ea4deda8 100644 --- a/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/deserialization/JvmMetadataVersion.kt +++ b/core/metadata.jvm/src/org/jetbrains/kotlin/metadata/jvm/deserialization/JvmMetadataVersion.kt @@ -26,7 +26,7 @@ class JvmMetadataVersion(versionArray: IntArray, val isStrictSemantics: Boolean) companion object { @JvmField - val INSTANCE = JvmMetadataVersion(1, 4, 2) + val INSTANCE = JvmMetadataVersion(1, 5, 0) @JvmField val INVALID_VERSION = JvmMetadataVersion() diff --git a/libraries/reflect/build.gradle.kts b/libraries/reflect/build.gradle.kts index edb4652eae9..8c75995d8cb 100644 --- a/libraries/reflect/build.gradle.kts +++ b/libraries/reflect/build.gradle.kts @@ -11,7 +11,7 @@ description = "Kotlin Full Reflection Library" buildscript { dependencies { - classpath("org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.1.0") + classpath("org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.2.0") } } diff --git a/libraries/tools/binary-compatibility-validator/build.gradle b/libraries/tools/binary-compatibility-validator/build.gradle index 63f44f4b56b..584c858ba35 100644 --- a/libraries/tools/binary-compatibility-validator/build.gradle +++ b/libraries/tools/binary-compatibility-validator/build.gradle @@ -6,6 +6,11 @@ configurations { } dependencies { + // Override dependency of binary-compatibility-validator:0.2.3 on kotlinx-metadata-jvm:0.1.0, + // until the new version of the binary compatibility validator is released. + // kotlinx-metadata-jvm 0.1.0 can't read metadata of version 1.5 and greater. + runtimeOnly("org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.2.0") + compile("org.jetbrains.kotlinx:binary-compatibility-validator:0.2.3") testCompile project(':kotlin-test:kotlin-test-junit') From 7b7b8fbea74174c7cd9d5a4dd503af73fc918441 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 18 Feb 2021 12:24:21 +0300 Subject: [PATCH 255/368] [Test] Filter dependent modules by source kind in creating FirModuleInfo --- .../box/annotations/javaAnnotationArrayValueNoDefault.kt | 1 - .../testData/codegen/box/annotations/javaAnnotationCall.kt | 1 - .../testData/codegen/box/annotations/javaAnnotationDefault.kt | 1 - .../annotations/javaNegativePropertyAsAnnotationParameter.kt | 1 - .../box/annotations/javaPropertyAsAnnotationParameter.kt | 1 - .../codegen/box/annotations/javaPropertyWithIntInitializer.kt | 1 - .../box/annotations/kClassMapping/arrayClassParameter.kt | 1 - .../kClassMapping/arrayClassParameterOnJavaClass.kt | 1 - .../codegen/box/annotations/kClassMapping/classParameter.kt | 1 - .../box/annotations/kClassMapping/classParameterOnJavaClass.kt | 1 - .../box/annotations/kClassMapping/varargClassParameter.kt | 1 - .../kClassMapping/varargClassParameterOnJavaClass.kt | 1 - .../box/compileKotlinAgainstKotlin/annotationsOnTypeAliases.kt | 1 - .../box/compileKotlinAgainstKotlin/delegationAndAnnotations.kt | 1 - .../compileKotlinAgainstKotlin/fir/IrConstAcceptMultiModule.kt | 1 - .../box/compileKotlinAgainstKotlin/inlineClassesOldMangling.kt | 1 - .../codegen/box/compileKotlinAgainstKotlin/inlinedConstants.kt | 1 - .../codegen/box/compileKotlinAgainstKotlin/jvmNames.kt | 1 - .../codegen/box/compileKotlinAgainstKotlin/recursiveGeneric.kt | 1 - .../reflectTopLevelFunctionOtherFile.kt | 1 - .../suspendFunWithDefaultMangling.kt | 1 - .../suspendFunWithDefaultOldMangling.kt | 1 - .../typeAnnotations/implicitReturn.kt | 1 - .../codegen/box/coroutines/multiModule/inlineCrossModule.kt | 1 - .../coroutines/multiModule/inlineFunctionWithOptionalParam.kt | 1 - .../codegen/box/coroutines/multiModule/inlineMultiModule.kt | 1 - .../box/coroutines/multiModule/inlineMultiModuleOverride.kt | 1 - .../coroutines/multiModule/inlineMultiModuleWithController.kt | 1 - .../multiModule/inlineMultiModuleWithInnerInlining.kt | 1 - .../codegen/box/coroutines/multiModule/inlineTailCall.kt | 1 - .../codegen/box/coroutines/multiModule/inlineWithJava.kt | 1 - compiler/testData/codegen/box/coroutines/multiModule/simple.kt | 1 - .../codegen/box/ir/serializationRegressions/genericProperty.kt | 1 - compiler/testData/codegen/box/multifileClasses/metadataFlag.kt | 3 --- .../testData/codegen/box/multiplatform/optionalExpectation.kt | 1 + .../codegen/box/properties/genericPropertyMultiModule.kt | 1 - compiler/testData/codegen/box/recursiveRawTypes/kt16639.kt | 1 - .../testData/codegen/box/reflection/mapping/jClass2kClass.kt | 1 - .../testData/codegen/box/reflection/mapping/javaConstructor.kt | 1 - compiler/testData/codegen/box/reflection/mapping/javaFields.kt | 1 - compiler/testData/codegen/box/sam/adapters/implementAdapter.kt | 1 - compiler/testData/codegen/box/sam/differentFqNames.kt | 1 - compiler/testData/codegen/box/sam/kt11696.kt | 1 - .../testData/codegen/box/sam/samConstructorGenericSignature.kt | 1 - .../codegen/box/throws/delegationAndThrows_AgainstCompiled.kt | 1 - .../kotlin/test/frontend/fir/FirModuleInfoProvider.kt | 3 ++- 46 files changed, 3 insertions(+), 47 deletions(-) diff --git a/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueNoDefault.kt b/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueNoDefault.kt index 8412a95d6b1..38573369acd 100644 --- a/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueNoDefault.kt +++ b/compiler/testData/codegen/box/annotations/javaAnnotationArrayValueNoDefault.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/javaAnnotationCall.kt b/compiler/testData/codegen/box/annotations/javaAnnotationCall.kt index 620fcc14ad8..d5edf29db14 100644 --- a/compiler/testData/codegen/box/annotations/javaAnnotationCall.kt +++ b/compiler/testData/codegen/box/annotations/javaAnnotationCall.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/javaAnnotationDefault.kt b/compiler/testData/codegen/box/annotations/javaAnnotationDefault.kt index ae1bc8260d8..764350a4992 100644 --- a/compiler/testData/codegen/box/annotations/javaAnnotationDefault.kt +++ b/compiler/testData/codegen/box/annotations/javaAnnotationDefault.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/javaNegativePropertyAsAnnotationParameter.kt b/compiler/testData/codegen/box/annotations/javaNegativePropertyAsAnnotationParameter.kt index bddcd66f575..4ae868f6530 100644 --- a/compiler/testData/codegen/box/annotations/javaNegativePropertyAsAnnotationParameter.kt +++ b/compiler/testData/codegen/box/annotations/javaNegativePropertyAsAnnotationParameter.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/javaPropertyAsAnnotationParameter.kt b/compiler/testData/codegen/box/annotations/javaPropertyAsAnnotationParameter.kt index 3331356ff42..5ddb739e548 100644 --- a/compiler/testData/codegen/box/annotations/javaPropertyAsAnnotationParameter.kt +++ b/compiler/testData/codegen/box/annotations/javaPropertyAsAnnotationParameter.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/javaPropertyWithIntInitializer.kt b/compiler/testData/codegen/box/annotations/javaPropertyWithIntInitializer.kt index 94c94183b80..fb2096625a0 100644 --- a/compiler/testData/codegen/box/annotations/javaPropertyWithIntInitializer.kt +++ b/compiler/testData/codegen/box/annotations/javaPropertyWithIntInitializer.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameter.kt b/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameter.kt index ce69c8df11b..fe64d65d06d 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameter.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameter.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameterOnJavaClass.kt b/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameterOnJavaClass.kt index 480b5b7f321..e0e376ddbb4 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameterOnJavaClass.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/arrayClassParameterOnJavaClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/classParameter.kt b/compiler/testData/codegen/box/annotations/kClassMapping/classParameter.kt index e8d0dca4c84..1b253eb0740 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/classParameter.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/classParameter.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/classParameterOnJavaClass.kt b/compiler/testData/codegen/box/annotations/kClassMapping/classParameterOnJavaClass.kt index 639c7790d9a..cd348ae401e 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/classParameterOnJavaClass.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/classParameterOnJavaClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameter.kt b/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameter.kt index ee81b20d4cf..5636c0c879f 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameter.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameter.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameterOnJavaClass.kt b/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameterOnJavaClass.kt index 7b2deaac2ec..3927f0d157b 100644 --- a/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameterOnJavaClass.kt +++ b/compiler/testData/codegen/box/annotations/kClassMapping/varargClassParameterOnJavaClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationsOnTypeAliases.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationsOnTypeAliases.kt index 6d64ff59d17..ff70b6dd8f5 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationsOnTypeAliases.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationsOnTypeAliases.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_STDLIB diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/delegationAndAnnotations.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/delegationAndAnnotations.kt index fb606a0f1ac..87a454e40a7 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/delegationAndAnnotations.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/delegationAndAnnotations.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/fir/IrConstAcceptMultiModule.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/fir/IrConstAcceptMultiModule.kt index e7e1c121860..cf2f845ac6c 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/fir/IrConstAcceptMultiModule.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/fir/IrConstAcceptMultiModule.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // MODULE: lib // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/inlineClassesOldMangling.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/inlineClassesOldMangling.kt index 3b1e8a45766..910f0ed7fad 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/inlineClassesOldMangling.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/inlineClassesOldMangling.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // !LANGUAGE: +InlineClasses // WITH_STDLIB diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/inlinedConstants.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/inlinedConstants.kt index 29ea554b454..f839f1cf208 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/inlinedConstants.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/inlinedConstants.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_STDLIB diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/jvmNames.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/jvmNames.kt index f6e9815858a..cb482e0d566 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/jvmNames.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/jvmNames.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_STDLIB // WITH_REFLECT diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/recursiveGeneric.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/recursiveGeneric.kt index 948af9ada40..33545618f77 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/recursiveGeneric.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/recursiveGeneric.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_STDLIB // FULL_JDK diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/reflectTopLevelFunctionOtherFile.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/reflectTopLevelFunctionOtherFile.kt index b021228d93a..84946ee5c2f 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/reflectTopLevelFunctionOtherFile.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/reflectTopLevelFunctionOtherFile.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/suspendFunWithDefaultMangling.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/suspendFunWithDefaultMangling.kt index a58fa376dbf..b3fd679c0bb 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/suspendFunWithDefaultMangling.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/suspendFunWithDefaultMangling.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // !LANGUAGE: +InlineClasses // WITH_STDLIB diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/suspendFunWithDefaultOldMangling.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/suspendFunWithDefaultOldMangling.kt index c531356ccb0..0b1d290a87e 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/suspendFunWithDefaultOldMangling.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/suspendFunWithDefaultOldMangling.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // !LANGUAGE: +InlineClasses // WITH_STDLIB // MODULE: lib diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/typeAnnotations/implicitReturn.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/typeAnnotations/implicitReturn.kt index a3810a8b2bc..7ed00621e62 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/typeAnnotations/implicitReturn.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/typeAnnotations/implicitReturn.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // EMIT_JVM_TYPE_ANNOTATIONS // TARGET_BACKEND: JVM // JVM_TARGET: 1.8 diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineCrossModule.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineCrossModule.kt index 606a4962d8b..df7775d29c0 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/inlineCrossModule.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineCrossModule.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: NATIVE // WITH_COROUTINES // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt index b8b2597b182..25c060efb0a 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_COROUTINES // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModule.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModule.kt index aa5cba02e90..285dae7d44e 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModule.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModule.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_COROUTINES // WITH_RUNTIME // MODULE: lib(support) diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleOverride.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleOverride.kt index 0861a7eb94f..8d689cd45e5 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleOverride.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleOverride.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_COROUTINES // WITH_RUNTIME // MODULE: lib(support) diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithController.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithController.kt index 9fb4eb91f2d..736540d70a3 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithController.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithController.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_COROUTINES // WITH_RUNTIME // MODULE: lib(support) diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithInnerInlining.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithInnerInlining.kt index c5b823bf671..99501074f46 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithInnerInlining.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineMultiModuleWithInnerInlining.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: NATIVE // WITH_COROUTINES // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineTailCall.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineTailCall.kt index 2b1b648811b..a66518f6dff 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/inlineTailCall.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineTailCall.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: NATIVE // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineWithJava.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineWithJava.kt index aa7c820ff98..733f95a6f2d 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/inlineWithJava.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineWithJava.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_COROUTINES // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/coroutines/multiModule/simple.kt b/compiler/testData/codegen/box/coroutines/multiModule/simple.kt index f5a4ad9f5c5..0a2c2596937 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/simple.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/simple.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // WITH_COROUTINES // MODULE: controller(support) diff --git a/compiler/testData/codegen/box/ir/serializationRegressions/genericProperty.kt b/compiler/testData/codegen/box/ir/serializationRegressions/genericProperty.kt index f246433635c..93d92e76267 100644 --- a/compiler/testData/codegen/box/ir/serializationRegressions/genericProperty.kt +++ b/compiler/testData/codegen/box/ir/serializationRegressions/genericProperty.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // DONT_TARGET_EXACT_BACKEND: WASM // WASM_MUTE_REASON: PROPERTY_REFERENCES // IGNORE_BACKEND: NATIVE diff --git a/compiler/testData/codegen/box/multifileClasses/metadataFlag.kt b/compiler/testData/codegen/box/multifileClasses/metadataFlag.kt index 7e0ee954544..a870f178729 100644 --- a/compiler/testData/codegen/box/multifileClasses/metadataFlag.kt +++ b/compiler/testData/codegen/box/multifileClasses/metadataFlag.kt @@ -1,9 +1,6 @@ // TARGET_BACKEND: JVM // WITH_RUNTIME -// FIR reports unresolved reference on `extraInt`. -// IGNORE_BACKEND_FIR: JVM_IR - // MODULE: optimized // !INHERIT_MULTIFILE_PARTS // FILE: optimized.kt diff --git a/compiler/testData/codegen/box/multiplatform/optionalExpectation.kt b/compiler/testData/codegen/box/multiplatform/optionalExpectation.kt index 91d1f7864b7..16701c85c52 100644 --- a/compiler/testData/codegen/box/multiplatform/optionalExpectation.kt +++ b/compiler/testData/codegen/box/multiplatform/optionalExpectation.kt @@ -1,3 +1,4 @@ +// IGNORE_BACKEND_FIR: JVM_IR // !LANGUAGE: +MultiPlatformProjects // !USE_EXPERIMENTAL: kotlin.ExperimentalMultiplatform // IGNORE_BACKEND: NATIVE diff --git a/compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt b/compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt index e207a31b16a..f97b4aa6ed3 100644 --- a/compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt +++ b/compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // DONT_TARGET_EXACT_BACKEND: WASM // WASM_MUTE_REASON: PROPERTY_REFERENCES // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/recursiveRawTypes/kt16639.kt b/compiler/testData/codegen/box/recursiveRawTypes/kt16639.kt index 771fa8e60de..6644dea2e68 100644 --- a/compiler/testData/codegen/box/recursiveRawTypes/kt16639.kt +++ b/compiler/testData/codegen/box/recursiveRawTypes/kt16639.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/reflection/mapping/jClass2kClass.kt b/compiler/testData/codegen/box/reflection/mapping/jClass2kClass.kt index 6db31bd6c13..4cd579de10c 100644 --- a/compiler/testData/codegen/box/reflection/mapping/jClass2kClass.kt +++ b/compiler/testData/codegen/box/reflection/mapping/jClass2kClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/reflection/mapping/javaConstructor.kt b/compiler/testData/codegen/box/reflection/mapping/javaConstructor.kt index bb18df44566..16295a70613 100644 --- a/compiler/testData/codegen/box/reflection/mapping/javaConstructor.kt +++ b/compiler/testData/codegen/box/reflection/mapping/javaConstructor.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT // MODULE: lib diff --git a/compiler/testData/codegen/box/reflection/mapping/javaFields.kt b/compiler/testData/codegen/box/reflection/mapping/javaFields.kt index f5eda2640d4..7e78a0582d2 100644 --- a/compiler/testData/codegen/box/reflection/mapping/javaFields.kt +++ b/compiler/testData/codegen/box/reflection/mapping/javaFields.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_REFLECT // FULL_JDK diff --git a/compiler/testData/codegen/box/sam/adapters/implementAdapter.kt b/compiler/testData/codegen/box/sam/adapters/implementAdapter.kt index 9d6e02cf249..de66846c697 100644 --- a/compiler/testData/codegen/box/sam/adapters/implementAdapter.kt +++ b/compiler/testData/codegen/box/sam/adapters/implementAdapter.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/sam/differentFqNames.kt b/compiler/testData/codegen/box/sam/differentFqNames.kt index a75ec7c69a1..867a4c9126c 100644 --- a/compiler/testData/codegen/box/sam/differentFqNames.kt +++ b/compiler/testData/codegen/box/sam/differentFqNames.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/testData/codegen/box/sam/kt11696.kt b/compiler/testData/codegen/box/sam/kt11696.kt index e2ca195926f..0619296d355 100644 --- a/compiler/testData/codegen/box/sam/kt11696.kt +++ b/compiler/testData/codegen/box/sam/kt11696.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // SAM_CONVERSIONS: CLASS // ^ test checks reflection for synthetic classes diff --git a/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt b/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt index 177123f353c..81c2772b4e1 100644 --- a/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt +++ b/compiler/testData/codegen/box/sam/samConstructorGenericSignature.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // SKIP_JDK6 // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/throws/delegationAndThrows_AgainstCompiled.kt b/compiler/testData/codegen/box/throws/delegationAndThrows_AgainstCompiled.kt index 80104409b1d..9a8a353be1e 100644 --- a/compiler/testData/codegen/box/throws/delegationAndThrows_AgainstCompiled.kt +++ b/compiler/testData/codegen/box/throws/delegationAndThrows_AgainstCompiled.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME // MODULE: lib diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/FirModuleInfoProvider.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/FirModuleInfoProvider.kt index b41a7763cf0..9cb6a93521f 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/FirModuleInfoProvider.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/FirModuleInfoProvider.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.test.frontend.fir import org.jetbrains.kotlin.fir.java.FirProjectSessionProvider import org.jetbrains.kotlin.fir.session.FirJvmModuleInfo import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.test.model.DependencyKind import org.jetbrains.kotlin.test.services.TestService import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.dependencyProvider @@ -24,7 +25,7 @@ class FirModuleInfoProvider( fun convertToFirModuleInfo(module: TestModule): FirJvmModuleInfo { return firModuleInfoByModule.getOrPut(module) { val dependencies = mutableListOf(builtinsModuleInfoForModule(module)) - module.dependencies.mapTo(dependencies) { + module.dependencies.filter { it.kind == DependencyKind.Source }.mapTo(dependencies) { convertToFirModuleInfo(testServices.dependencyProvider.getTestModule(it.moduleName)) } FirJvmModuleInfo(Name.identifier(module.name), dependencies) From 8c20c655febcb596b28d93b381274ff1428cc633 Mon Sep 17 00:00:00 2001 From: Sergey Shanshin Date: Thu, 18 Feb 2021 15:03:35 +0300 Subject: [PATCH 256/368] Updated bytecode of serialization for IR `shouldEncodeElementDefault` now checked before evaluating default value --- .../testData/codegen/Basic.ir.txt | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/testData/codegen/Basic.ir.txt b/plugins/kotlin-serialization/kotlin-serialization-compiler/testData/codegen/Basic.ir.txt index 91e1368f7f2..8d781abb2a7 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/testData/codegen/Basic.ir.txt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/testData/codegen/Basic.ir.txt @@ -474,9 +474,17 @@ public final class OptionalUser$$serializer : java/lang/Object, kotlinx/serializ ALOAD (3) INVOKEINTERFACE (kotlinx/serialization/encoding/Encoder, beginStructure, (Lkotlinx/serialization/descriptors/SerialDescriptor;)Lkotlinx/serialization/encoding/CompositeEncoder;) ASTORE (4) + ALOAD (4) + ALOAD (3) + ICONST_0 + INVOKEINTERFACE (kotlinx/serialization/encoding/CompositeEncoder, shouldEncodeElementDefault, (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Z) + IFEQ (L2) + ICONST_1 + GOTO (L3) + LABEL (L2) ALOAD (2) INVOKEVIRTUAL (OptionalUser, getUser, ()LUser;) - LABEL (L2) + LABEL (L4) LINENUMBER (10) NEW DUP @@ -484,18 +492,15 @@ public final class OptionalUser$$serializer : java/lang/Object, kotlinx/serializ LDC () INVOKESPECIAL (User, , (Ljava/lang/String;Ljava/lang/String;)V) INVOKESTATIC (kotlin/jvm/internal/Intrinsics, areEqual, (Ljava/lang/Object;Ljava/lang/Object;)Z) - IFNE (L3) - LABEL (L4) - LINENUMBER (9) + IFNE (L5) ICONST_1 - GOTO (L5) - LABEL (L3) - ALOAD (4) - ALOAD (3) - ICONST_0 - INVOKEINTERFACE (kotlinx/serialization/encoding/CompositeEncoder, shouldEncodeElementDefault, (Lkotlinx/serialization/descriptors/SerialDescriptor;I)Z) + GOTO (L3) LABEL (L5) + ICONST_0 + LABEL (L3) IFEQ (L6) + LABEL (L7) + LINENUMBER (9) ALOAD (4) ALOAD (3) ICONST_0 @@ -509,7 +514,7 @@ public final class OptionalUser$$serializer : java/lang/Object, kotlinx/serializ ALOAD (3) INVOKEINTERFACE (kotlinx/serialization/encoding/CompositeEncoder, endStructure, (Lkotlinx/serialization/descriptors/SerialDescriptor;)V) RETURN - LABEL (L7) + LABEL (L8) } public void serialize(kotlinx.serialization.encoding.Encoder encoder, java.lang.Object value) { @@ -978,4 +983,4 @@ public final class User : java/lang/Object { public final java.lang.String getFirstName() public final java.lang.String getLastName() -} \ No newline at end of file +} From 33313ae4b40a393d47bd5ebbd4314c4bc4d8aa5d Mon Sep 17 00:00:00 2001 From: Alexander Dudinsky Date: Thu, 18 Feb 2021 16:47:22 +0300 Subject: [PATCH 257/368] Fix artifacts needed for the kotlin-gradle-plugin --- buildSrc/src/main/kotlin/tasks.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/tasks.kt b/buildSrc/src/main/kotlin/tasks.kt index 4b2e483bf9a..f7e7d615695 100644 --- a/buildSrc/src/main/kotlin/tasks.kt +++ b/buildSrc/src/main/kotlin/tasks.kt @@ -52,7 +52,8 @@ val kotlinGradlePluginAndItsRequired = arrayOf( ":kotlin-scripting-compiler-embeddable", ":kotlin-scripting-compiler-impl-embeddable", ":kotlin-test-js-runner", - ":native:kotlin-klib-commonizer-embeddable" + ":native:kotlin-klib-commonizer-embeddable", + ":native:kotlin-klib-commonizer-api:install" ) fun Task.dependsOnKotlinGradlePluginInstall() { From 5cbbbc3b832f2bc82f936445a28ca2655b544fc0 Mon Sep 17 00:00:00 2001 From: Alexander Dudinsky Date: Thu, 18 Feb 2021 16:50:52 +0300 Subject: [PATCH 258/368] Fix artifacts needed for the kotlin-gradle-plugin --- buildSrc/src/main/kotlin/tasks.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/tasks.kt b/buildSrc/src/main/kotlin/tasks.kt index f7e7d615695..083970e0f04 100644 --- a/buildSrc/src/main/kotlin/tasks.kt +++ b/buildSrc/src/main/kotlin/tasks.kt @@ -53,7 +53,7 @@ val kotlinGradlePluginAndItsRequired = arrayOf( ":kotlin-scripting-compiler-impl-embeddable", ":kotlin-test-js-runner", ":native:kotlin-klib-commonizer-embeddable", - ":native:kotlin-klib-commonizer-api:install" + ":native:kotlin-klib-commonizer-api" ) fun Task.dependsOnKotlinGradlePluginInstall() { From ad9fd7ecf3c03f5cde070de8e033af18676bc578 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Mon, 15 Feb 2021 18:06:57 +0300 Subject: [PATCH 259/368] KotlinBinaryClassCache: clean-up request caches for all threads ^KT-44550 Fixed --- .../load/kotlin/KotlinBinaryClassCache.kt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt index 005b2f236a1..1ec5289d942 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinBinaryClassCache.kt @@ -23,6 +23,7 @@ import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.util.Computable import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiJavaModule +import java.util.concurrent.CopyOnWriteArrayList class KotlinBinaryClassCache : Disposable { private class RequestCache { @@ -43,17 +44,22 @@ class KotlinBinaryClassCache : Disposable { } private val cache = object : ThreadLocal() { + private val requestCaches = CopyOnWriteArrayList() + override fun initialValue(): RequestCache { - return RequestCache() + return RequestCache().also { requestCaches.add(it) } + } + + override fun remove() { + for (cache in requestCaches) { + cache.result = null + cache.virtualFile = null + } + super.remove() } } override fun dispose() { - cache.get().apply { - result = null - virtualFile = null - } - // This is only relevant for tests. We create a new instance of Application for each test, and so a new instance of this service is // also created for each test. However all tests share the same event dispatch thread, which would collect all instances of this // thread-local if they're not removed properly. Each instance would transitively retain VFS resulting in OutOfMemoryError From bc9a7918090a1052c576dd92c2369b51782ccca0 Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Tue, 15 Dec 2020 20:09:54 +0300 Subject: [PATCH 260/368] Refactor klib serializer/deserializer --- .../BasicIrModuleDeserializer.kt | 182 ++ .../IncrementalCompilationSupport.kt | 4 - .../serialization/IrBodyDeserializer.kt | 787 +++++++++ .../IrDeclarationDeserializer.kt | 695 ++++++++ .../serialization/IrFileDeserializer.kt | 1569 ++--------------- .../serialization/IrModuleDeserializer.kt | 6 - .../serialization/IrSymbolDeserializer.kt | 156 ++ .../common/serialization/KotlinIrLinker.kt | 535 +----- .../js/lower/serialization/ir/JsIrLinker.kt | 2 +- .../backend/jvm/serialization/JvmIrLinker.kt | 2 +- 10 files changed, 2012 insertions(+), 1926 deletions(-) create mode 100644 compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/BasicIrModuleDeserializer.kt create mode 100644 compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrBodyDeserializer.kt create mode 100644 compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt create mode 100644 compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrSymbolDeserializer.kt diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/BasicIrModuleDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/BasicIrModuleDeserializer.kt new file mode 100644 index 00000000000..8f76a552f45 --- /dev/null +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/BasicIrModuleDeserializer.kt @@ -0,0 +1,182 @@ +/* + * Copyright 2010-2020 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.backend.common.serialization + +import org.jetbrains.kotlin.backend.common.serialization.encodings.BinarySymbolData +import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.ir.declarations.IrFile +import org.jetbrains.kotlin.ir.declarations.IrModuleFragment +import org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl +import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.symbols.IrSymbol +import org.jetbrains.kotlin.ir.util.IdSignature +import org.jetbrains.kotlin.library.IrLibrary +import org.jetbrains.kotlin.protobuf.CodedInputStream +import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite + +import org.jetbrains.kotlin.backend.common.serialization.proto.IrFile as ProtoFile + +abstract class BasicIrModuleDeserializer( + val linker: KotlinIrLinker, + moduleDescriptor: ModuleDescriptor, + override val klib: IrLibrary, + override val strategy: DeserializationStrategy, + private val containsErrorCode: Boolean = false +) : + IrModuleDeserializer(moduleDescriptor) { + + private val fileToDeserializerMap = mutableMapOf() + + private val moduleDeserializationState = ModuleDeserializationState(linker, this) + + internal val moduleReversedFileIndex = mutableMapOf() + + override val moduleDependencies by lazy { + moduleDescriptor.allDependencyModules.filter { it != moduleDescriptor }.map { linker.resolveModuleDeserializer(it, null) } + } + + override fun init(delegate: IrModuleDeserializer) { + val fileCount = klib.fileCount() + + val files = ArrayList(fileCount) + + for (i in 0 until fileCount) { + val fileStream = klib.file(i).codedInputStream + val fileProto = ProtoFile.parseFrom(fileStream, ExtensionRegistryLite.newInstance()) + files.add(deserializeIrFile(fileProto, i, delegate, containsErrorCode)) + } + + moduleFragment.files.addAll(files) + + fileToDeserializerMap.values.forEach { it.symbolDeserializer.deserializeExpectActualMapping() } + } + + private fun IrSymbolDeserializer.deserializeExpectActualMapping() { + actuals.forEach { + val expectSymbol = parseSymbolData(it.expectSymbol) + val actualSymbol = parseSymbolData(it.actualSymbol) + + val expect = deserializeIdSignature(expectSymbol.signatureId) + val actual = deserializeIdSignature(actualSymbol.signatureId) + + assert(linker.expectUniqIdToActualUniqId[expect] == null) { + "Expect signature $expect is already actualized by ${linker.expectUniqIdToActualUniqId[expect]}, while we try to record $actual" + } + linker.expectUniqIdToActualUniqId[expect] = actual + // Non-null only for topLevel declarations. + findModuleDeserializerForTopLevelId(actual)?.let { md -> linker.topLevelActualUniqItToDeserializer[actual] = md } + } + } + + override fun referenceSimpleFunctionByLocalSignature(file: IrFile, idSignature: IdSignature) : IrSimpleFunctionSymbol = + fileToDeserializerMap[file]?.symbolDeserializer?.referenceSimpleFunctionByLocalSignature(idSignature) + ?: error("No deserializer for file $file in module ${moduleDescriptor.name}") + + override fun referencePropertyByLocalSignature(file: IrFile, idSignature: IdSignature): IrPropertySymbol = + fileToDeserializerMap[file]?.symbolDeserializer?.referencePropertyByLocalSignature(idSignature) + ?: error("No deserializer for file $file in module ${moduleDescriptor.name}") + + // TODO: fix to topLevel checker + override fun contains(idSig: IdSignature): Boolean = idSig in moduleReversedFileIndex + + override fun deserializeIrSymbol(idSig: IdSignature, symbolKind: BinarySymbolData.SymbolKind): IrSymbol { + assert(idSig.isPublic) + + val topLevelSignature = idSig.topLevelSignature() + val fileLocalDeserializationState = moduleReversedFileIndex[topLevelSignature] + ?: error("No file for $topLevelSignature (@ $idSig) in module $moduleDescriptor") + + fileLocalDeserializationState.addIdSignature(topLevelSignature) + moduleDeserializationState.enqueueFile(fileLocalDeserializationState) + + return fileLocalDeserializationState.fileDeserializer.symbolDeserializer.deserializeIrSymbol(idSig, symbolKind).also { + linker.deserializedSymbols.add(it) + } + } + + override val moduleFragment: IrModuleFragment = IrModuleFragmentImpl(moduleDescriptor, linker.builtIns, emptyList()) + + private fun deserializeIrFile(fileProto: ProtoFile, fileIndex: Int, moduleDeserializer: IrModuleDeserializer, allowErrorNodes: Boolean): IrFile { + + val fileReader = IrLibraryFileFromKlib(moduleDeserializer.klib, fileIndex) + val file = fileReader.createFile(moduleDescriptor, fileProto) + + val fileDeserializationState = FileDeserializationState( + linker, + file, + fileReader, + fileProto, + strategy.needBodies, + allowErrorNodes, + strategy.inlineBodies, + moduleDeserializer, + linker::handleNoModuleDeserializerFound, + ) + + fileToDeserializerMap[file] = fileDeserializationState.fileDeserializer + + val topLevelDeclarations = fileDeserializationState.fileDeserializer.reversedSignatureIndex.keys + topLevelDeclarations.forEach { + moduleReversedFileIndex.putIfAbsent(it, fileDeserializationState) // TODO Why not simple put? + } + + if (strategy.theWholeWorld) { + fileDeserializationState.enqueueAllDeclarations() + } + if (strategy.theWholeWorld || strategy.explicitlyExported) { + moduleDeserializationState.enqueueFile(fileDeserializationState) + } + + return file + } + + // TODO useless + override fun addModuleReachableTopLevel(idSig: IdSignature) { + moduleDeserializationState.addIdSignature(idSig) + } +} + +internal class ModuleDeserializationState(val linker: KotlinIrLinker, val moduleDeserializer: BasicIrModuleDeserializer) { + private val filesWithPendingTopLevels = mutableSetOf() + + fun enqueueFile(fileDeserializationState: FileDeserializationState) { + filesWithPendingTopLevels.add(fileDeserializationState) + linker.modulesWithReachableTopLevels.add(this) + } + + fun addIdSignature(key: IdSignature) { + val fileLocalDeserializationState = moduleDeserializer.moduleReversedFileIndex[key] ?: error("No file found for key $key") + fileLocalDeserializationState.addIdSignature(key) + + enqueueFile(fileLocalDeserializationState) + } + + fun deserializeReachableDeclarations() { + while (filesWithPendingTopLevels.isNotEmpty()) { + val pendingFileDeserializationState = filesWithPendingTopLevels.first() + + pendingFileDeserializationState.fileDeserializer.deserializeFileImplicitDataIfFirstUse() + pendingFileDeserializationState.deserializeAllFileReachableTopLevel() + + filesWithPendingTopLevels.remove(pendingFileDeserializationState) + } + } + + override fun toString(): String = moduleDeserializer.klib.toString() +} + +fun IrModuleDeserializer.findModuleDeserializerForTopLevelId(idSignature: IdSignature): IrModuleDeserializer? { + if (idSignature in this) return this + return moduleDependencies.firstOrNull { idSignature in it } +} + +internal val ByteArray.codedInputStream: CodedInputStream + get() { + val codedInputStream = CodedInputStream.newInstance(this) + codedInputStream.setRecursionLimit(65535) // The default 64 is blatantly not enough for IR. + return codedInputStream + } \ No newline at end of file diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IncrementalCompilationSupport.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IncrementalCompilationSupport.kt index b10c31c6c11..1c03e15ec86 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IncrementalCompilationSupport.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IncrementalCompilationSupport.kt @@ -100,10 +100,6 @@ class CurrentModuleWithICDeserializer( icDeserializer.addModuleReachableTopLevel(idSig) } - override fun deserializeReachableDeclarations() { - icDeserializer.deserializeReachableDeclarations() - } - private fun DeclarationDescriptor.isDirtyDescriptor(): Boolean { if (this is PropertyAccessorDescriptor) return correspondingProperty.isDirtyDescriptor() // Since descriptors for FO methods of `kotlin.Any` (toString, equals, hashCode) are Deserialized even in diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrBodyDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrBodyDeserializer.kt new file mode 100644 index 00000000000..7e7f54c1667 --- /dev/null +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrBodyDeserializer.kt @@ -0,0 +1,787 @@ +/* + * Copyright 2010-2020 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.backend.common.serialization + +import org.jetbrains.kotlin.backend.common.serialization.encodings.* +import org.jetbrains.kotlin.backend.common.serialization.proto.IrConst.ValueCase.* +import org.jetbrains.kotlin.backend.common.serialization.proto.IrOperation.OperationCase.* +import org.jetbrains.kotlin.backend.common.serialization.proto.IrStatement.StatementCase +import org.jetbrains.kotlin.backend.common.serialization.proto.IrVarargElement.VarargElementCase +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.IrStatement +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.descriptors.* +import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.* +import org.jetbrains.kotlin.ir.symbols.* +import org.jetbrains.kotlin.ir.types.* +import org.jetbrains.kotlin.backend.common.serialization.proto.IrBlock as ProtoBlock +import org.jetbrains.kotlin.backend.common.serialization.proto.IrBlockBody as ProtoBlockBody +import org.jetbrains.kotlin.backend.common.serialization.proto.IrBranch as ProtoBranch +import org.jetbrains.kotlin.backend.common.serialization.proto.IrBreak as ProtoBreak +import org.jetbrains.kotlin.backend.common.serialization.proto.IrCall as ProtoCall +import org.jetbrains.kotlin.backend.common.serialization.proto.IrCatch as ProtoCatch +import org.jetbrains.kotlin.backend.common.serialization.proto.IrClassReference as ProtoClassReference +import org.jetbrains.kotlin.backend.common.serialization.proto.IrComposite as ProtoComposite +import org.jetbrains.kotlin.backend.common.serialization.proto.IrConst as ProtoConst +import org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall as ProtoConstructorCall +import org.jetbrains.kotlin.backend.common.serialization.proto.IrContinue as ProtoContinue +import org.jetbrains.kotlin.backend.common.serialization.proto.IrDelegatingConstructorCall as ProtoDelegatingConstructorCall +import org.jetbrains.kotlin.backend.common.serialization.proto.IrDoWhile as ProtoDoWhile +import org.jetbrains.kotlin.backend.common.serialization.proto.IrDynamicMemberExpression as ProtoDynamicMemberExpression +import org.jetbrains.kotlin.backend.common.serialization.proto.IrDynamicOperatorExpression as ProtoDynamicOperatorExpression +import org.jetbrains.kotlin.backend.common.serialization.proto.IrEnumConstructorCall as ProtoEnumConstructorCall +import org.jetbrains.kotlin.backend.common.serialization.proto.IrExpression as ProtoExpression +import org.jetbrains.kotlin.backend.common.serialization.proto.IrFunctionExpression as ProtoFunctionExpression +import org.jetbrains.kotlin.backend.common.serialization.proto.IrErrorExpression as ProtoErrorExpression +import org.jetbrains.kotlin.backend.common.serialization.proto.IrErrorCallExpression as ProtoErrorCallExpression +import org.jetbrains.kotlin.backend.common.serialization.proto.IrFunctionReference as ProtoFunctionReference +import org.jetbrains.kotlin.backend.common.serialization.proto.IrGetClass as ProtoGetClass +import org.jetbrains.kotlin.backend.common.serialization.proto.IrGetEnumValue as ProtoGetEnumValue +import org.jetbrains.kotlin.backend.common.serialization.proto.IrGetField as ProtoGetField +import org.jetbrains.kotlin.backend.common.serialization.proto.IrGetObject as ProtoGetObject +import org.jetbrains.kotlin.backend.common.serialization.proto.IrGetValue as ProtoGetValue +import org.jetbrains.kotlin.backend.common.serialization.proto.IrInstanceInitializerCall as ProtoInstanceInitializerCall +import org.jetbrains.kotlin.backend.common.serialization.proto.IrLocalDelegatedPropertyReference as ProtoLocalDelegatedPropertyReference +import org.jetbrains.kotlin.backend.common.serialization.proto.IrOperation as ProtoOperation +import org.jetbrains.kotlin.backend.common.serialization.proto.IrPropertyReference as ProtoPropertyReference +import org.jetbrains.kotlin.backend.common.serialization.proto.IrReturn as ProtoReturn +import org.jetbrains.kotlin.backend.common.serialization.proto.IrSetField as ProtoSetField +import org.jetbrains.kotlin.backend.common.serialization.proto.IrSetValue as ProtoSetValue +import org.jetbrains.kotlin.backend.common.serialization.proto.IrSpreadElement as ProtoSpreadElement +import org.jetbrains.kotlin.backend.common.serialization.proto.IrStatement as ProtoStatement +import org.jetbrains.kotlin.backend.common.serialization.proto.IrStringConcat as ProtoStringConcat +import org.jetbrains.kotlin.backend.common.serialization.proto.IrSyntheticBody as ProtoSyntheticBody +import org.jetbrains.kotlin.backend.common.serialization.proto.IrSyntheticBodyKind as ProtoSyntheticBodyKind +import org.jetbrains.kotlin.backend.common.serialization.proto.IrThrow as ProtoThrow +import org.jetbrains.kotlin.backend.common.serialization.proto.IrTry as ProtoTry +import org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeOp as ProtoTypeOp +import org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeOperator as ProtoTypeOperator +import org.jetbrains.kotlin.backend.common.serialization.proto.IrVararg as ProtoVararg +import org.jetbrains.kotlin.backend.common.serialization.proto.IrVarargElement as ProtoVarargElement +import org.jetbrains.kotlin.backend.common.serialization.proto.IrWhen as ProtoWhen +import org.jetbrains.kotlin.backend.common.serialization.proto.IrWhile as ProtoWhile +import org.jetbrains.kotlin.backend.common.serialization.proto.Loop as ProtoLoop +import org.jetbrains.kotlin.backend.common.serialization.proto.MemberAccessCommon as ProtoMemberAccessCommon + +class IrBodyDeserializer( + private val builtIns: IrBuiltIns, + private val allowErrorNodes: Boolean, + private val irFactory: IrFactory, + private val fileReader: IrLibraryFile, + private val declarationDeserializer: IrDeclarationDeserializer, +) { + + private val fileLoops = mutableMapOf() + + private fun deserializeLoopHeader(loopIndex: Int, loopBuilder: () -> IrLoop): IrLoop = + fileLoops.getOrPut(loopIndex, loopBuilder) + + private fun deserializeBlockBody( + proto: ProtoBlockBody, + start: Int, end: Int + ): IrBlockBody { + + val statements = mutableListOf() + + val statementProtos = proto.statementList + statementProtos.forEach { + statements.add(deserializeStatement(it) as IrStatement) + } + + return irFactory.createBlockBody(start, end, statements) + } + + private fun deserializeBranch(proto: ProtoBranch, start: Int, end: Int): IrBranch { + + val condition = deserializeExpression(proto.condition) + val result = deserializeExpression(proto.result) + + return IrBranchImpl(start, end, condition, result) + } + + private fun deserializeCatch(proto: ProtoCatch, start: Int, end: Int): IrCatch { + val catchParameter = declarationDeserializer.deserializeIrVariable(proto.catchParameter) + val result = deserializeExpression(proto.result) + + return IrCatchImpl(start, end, catchParameter, result) + } + + private fun deserializeSyntheticBody(proto: ProtoSyntheticBody, start: Int, end: Int): IrSyntheticBody { + val kind = when (proto.kind!!) { + ProtoSyntheticBodyKind.ENUM_VALUES -> IrSyntheticBodyKind.ENUM_VALUES + ProtoSyntheticBodyKind.ENUM_VALUEOF -> IrSyntheticBodyKind.ENUM_VALUEOF + } + return IrSyntheticBodyImpl(start, end, kind) + } + + internal fun deserializeStatement(proto: ProtoStatement): IrElement { + val coordinates = BinaryCoordinates.decode(proto.coordinates) + val start = coordinates.startOffset + val end = coordinates.endOffset + val element = when (proto.statementCase) { + StatementCase.BLOCK_BODY //proto.hasBlockBody() + -> deserializeBlockBody(proto.blockBody, start, end) + StatementCase.BRANCH //proto.hasBranch() + -> deserializeBranch(proto.branch, start, end) + StatementCase.CATCH //proto.hasCatch() + -> deserializeCatch(proto.catch, start, end) + StatementCase.DECLARATION // proto.hasDeclaration() + -> declarationDeserializer.deserializeDeclaration(proto.declaration) + StatementCase.EXPRESSION // proto.hasExpression() + -> deserializeExpression(proto.expression) + StatementCase.SYNTHETIC_BODY // proto.hasSyntheticBody() + -> deserializeSyntheticBody(proto.syntheticBody, start, end) + else + -> TODO("Statement deserialization not implemented: ${proto.statementCase}") + } + + return element + } + + private fun deserializeBlock(proto: ProtoBlock, start: Int, end: Int, type: IrType): IrBlock { + val statements = mutableListOf() + val statementProtos = proto.statementList + val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null + + statementProtos.forEach { + statements.add(deserializeStatement(it) as IrStatement) + } + + return IrBlockImpl(start, end, type, origin, statements) + } + + private fun deserializeMemberAccessCommon(access: IrMemberAccessExpression<*>, proto: ProtoMemberAccessCommon) { + + proto.valueArgumentList.mapIndexed { i, arg -> + if (arg.hasExpression()) { + val expr = deserializeExpression(arg.expression) + access.putValueArgument(i, expr) + } + } + + proto.typeArgumentList.mapIndexed { i, arg -> + access.putTypeArgument(i, declarationDeserializer.deserializeIrType(arg)) + } + + if (proto.hasDispatchReceiver()) { + access.dispatchReceiver = deserializeExpression(proto.dispatchReceiver) + } + if (proto.hasExtensionReceiver()) { + access.extensionReceiver = deserializeExpression(proto.extensionReceiver) + } + } + + private fun deserializeClassReference( + proto: ProtoClassReference, + start: Int, + end: Int, + type: IrType + ): IrClassReference { + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.classSymbol) as IrClassifierSymbol + val classType = declarationDeserializer.deserializeIrType(proto.classType) + /** TODO: [createClassifierSymbolForClassReference] is internal function */ + return IrClassReferenceImpl(start, end, type, symbol, classType) + } + + fun deserializeAnnotation(proto: ProtoConstructorCall): IrConstructorCall { + return deserializeConstructorCall(proto, 0, 0, builtIns.unitType) // TODO: need a proper deserialization here + } + + fun deserializeConstructorCall(proto: ProtoConstructorCall, start: Int, end: Int, type: IrType): IrConstructorCall { + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrConstructorSymbol + return IrConstructorCallImpl( + start, end, type, + symbol, typeArgumentsCount = proto.memberAccess.typeArgumentCount, + constructorTypeArgumentsCount = proto.constructorTypeArgumentsCount, + valueArgumentsCount = proto.memberAccess.valueArgumentCount + ).also { + deserializeMemberAccessCommon(it, proto.memberAccess) + } + } + + private fun deserializeCall(proto: ProtoCall, start: Int, end: Int, type: IrType): IrCall { + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrSimpleFunctionSymbol + + val superSymbol = if (proto.hasSuper()) { + declarationDeserializer.deserializeIrSymbolAndRemap(proto.`super`) as IrClassSymbol + } else null + + val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null + + val call: IrCall = + // TODO: implement the last three args here. + IrCallImpl( + start, end, type, + symbol, proto.memberAccess.typeArgumentCount, + proto.memberAccess.valueArgumentList.size, + origin, + superSymbol + ) + deserializeMemberAccessCommon(call, proto.memberAccess) + return call + } + + private fun deserializeComposite(proto: ProtoComposite, start: Int, end: Int, type: IrType): IrComposite { + val statements = mutableListOf() + val statementProtos = proto.statementList + val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null + + statementProtos.forEach { + statements.add(deserializeStatement(it) as IrStatement) + } + return IrCompositeImpl(start, end, type, origin, statements) + } + + private fun deserializeDelegatingConstructorCall( + proto: ProtoDelegatingConstructorCall, + start: Int, + end: Int + ): IrDelegatingConstructorCall { + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrConstructorSymbol + val call = IrDelegatingConstructorCallImpl( + start, + end, + builtIns.unitType, + symbol, + proto.memberAccess.typeArgumentCount, + proto.memberAccess.valueArgumentCount + ) + + deserializeMemberAccessCommon(call, proto.memberAccess) + return call + } + + + private fun deserializeEnumConstructorCall( + proto: ProtoEnumConstructorCall, + start: Int, + end: Int, + ): IrEnumConstructorCall { + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrConstructorSymbol + val call = IrEnumConstructorCallImpl( + start, + end, + builtIns.unitType, + symbol, + proto.memberAccess.typeArgumentCount, + proto.memberAccess.valueArgumentCount + ) + deserializeMemberAccessCommon(call, proto.memberAccess) + return call + } + + private fun deserializeFunctionExpression( + functionExpression: ProtoFunctionExpression, + start: Int, + end: Int, + type: IrType + ) = + IrFunctionExpressionImpl( + start, end, type, + declarationDeserializer.deserializeIrFunction(functionExpression.function), + deserializeIrStatementOrigin(functionExpression.originName) + ) + + private fun deserializeErrorExpression( + proto: ProtoErrorExpression, + start: Int, end: Int, type: IrType + ): IrErrorExpression { + require(allowErrorNodes) { + "IrErrorExpression($start, $end, \"${fileReader.deserializeString(proto.description)}\") found but error code is not allowed" + } + return IrErrorExpressionImpl(start, end, type, fileReader.deserializeString(proto.description)) + } + + private fun deserializeErrorCallExpression( + proto: ProtoErrorCallExpression, + start: Int, end: Int, type: IrType + ): IrErrorCallExpression { + require(allowErrorNodes) { + "IrErrorCallExpressionImpl($start, $end, \"${fileReader.deserializeString(proto.description)}\") found but error code is not allowed" + } + return IrErrorCallExpressionImpl(start, end, type, fileReader.deserializeString(proto.description)).apply { + if (proto.hasReceiver()) { + explicitReceiver = deserializeExpression(proto.receiver) + } + proto.valueArgumentList.forEach { + addArgument(deserializeExpression(it)) + } + } + + } + + private fun deserializeFunctionReference( + proto: ProtoFunctionReference, + start: Int, end: Int, type: IrType + ): IrFunctionReference { + + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrFunctionSymbol + val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null + val reflectionTarget = + if (proto.hasReflectionTargetSymbol()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.reflectionTargetSymbol) as IrFunctionSymbol else null + val callable = IrFunctionReferenceImpl( + start, + end, + type, + symbol, + proto.memberAccess.typeArgumentCount, + proto.memberAccess.valueArgumentCount, + reflectionTarget, + origin + ) + deserializeMemberAccessCommon(callable, proto.memberAccess) + + return callable + } + + private fun deserializeGetClass(proto: ProtoGetClass, start: Int, end: Int, type: IrType): IrGetClass { + val argument = deserializeExpression(proto.argument) + return IrGetClassImpl(start, end, type, argument) + } + + private fun deserializeGetField(proto: ProtoGetField, start: Int, end: Int, type: IrType): IrGetField { + val access = proto.fieldAccess + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(access.symbol) as IrFieldSymbol + val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null + + val superQualifier = if (access.hasSuper()) { + declarationDeserializer.deserializeIrSymbolAndRemap(access.symbol) as IrClassSymbol + } else null + val receiver = if (access.hasReceiver()) { + deserializeExpression(access.receiver) + } else null + + return IrGetFieldImpl(start, end, symbol, type, receiver, origin, superQualifier) + } + + private fun deserializeGetValue(proto: ProtoGetValue, start: Int, end: Int, type: IrType): IrGetValue { + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrValueSymbol + val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null + // TODO: origin! + return IrGetValueImpl(start, end, type, symbol, origin) + } + + private fun deserializeGetEnumValue( + proto: ProtoGetEnumValue, + start: Int, + end: Int, + type: IrType + ): IrGetEnumValue { + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrEnumEntrySymbol + return IrGetEnumValueImpl(start, end, type, symbol) + } + + private fun deserializeGetObject( + proto: ProtoGetObject, + start: Int, + end: Int, + type: IrType + ): IrGetObjectValue { + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrClassSymbol + return IrGetObjectValueImpl(start, end, type, symbol) + } + + private fun deserializeInstanceInitializerCall( + proto: ProtoInstanceInitializerCall, + start: Int, + end: Int + ): IrInstanceInitializerCall { + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrClassSymbol + return IrInstanceInitializerCallImpl(start, end, symbol, builtIns.unitType) + } + + private fun deserializeIrLocalDelegatedPropertyReference( + proto: ProtoLocalDelegatedPropertyReference, + start: Int, + end: Int, + type: IrType + ): IrLocalDelegatedPropertyReference { + + val delegate = declarationDeserializer.deserializeIrSymbolAndRemap(proto.delegate) as IrVariableSymbol + val getter = declarationDeserializer.deserializeIrSymbolAndRemap(proto.getter) as IrSimpleFunctionSymbol + val setter = if (proto.hasSetter()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.setter) as IrSimpleFunctionSymbol else null + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrLocalDelegatedPropertySymbol + val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null + + return IrLocalDelegatedPropertyReferenceImpl( + start, end, type, + symbol, + delegate, + getter, + setter, + origin + ) + } + + private fun deserializePropertyReference(proto: ProtoPropertyReference, start: Int, end: Int, type: IrType): IrPropertyReference { + + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrPropertySymbol + + val field = if (proto.hasField()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.field) as IrFieldSymbol else null + val getter = if (proto.hasGetter()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.getter) as IrSimpleFunctionSymbol else null + val setter = if (proto.hasSetter()) declarationDeserializer.deserializeIrSymbolAndRemap(proto.setter) as IrSimpleFunctionSymbol else null + val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null + + val callable = IrPropertyReferenceImpl( + start, end, type, + symbol, + proto.memberAccess.typeArgumentCount, + field, + getter, + setter, + origin + ) + deserializeMemberAccessCommon(callable, proto.memberAccess) + return callable + } + + private fun deserializeReturn(proto: ProtoReturn, start: Int, end: Int): IrReturn { + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.returnTarget) as IrReturnTargetSymbol + val value = deserializeExpression(proto.value) + return IrReturnImpl(start, end, builtIns.nothingType, symbol, value) + } + + private fun deserializeSetField(proto: ProtoSetField, start: Int, end: Int): IrSetField { + val access = proto.fieldAccess + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(access.symbol) as IrFieldSymbol + val superQualifier = if (access.hasSuper()) { + declarationDeserializer.deserializeIrSymbolAndRemap(access.symbol) as IrClassSymbol + } else null + val receiver = if (access.hasReceiver()) { + deserializeExpression(access.receiver) + } else null + val value = deserializeExpression(proto.value) + val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null + + return IrSetFieldImpl(start, end, symbol, receiver, value, builtIns.unitType, origin, superQualifier) + } + + private fun deserializeSetValue(proto: ProtoSetValue, start: Int, end: Int): IrSetValue { + val symbol = declarationDeserializer.deserializeIrSymbolAndRemap(proto.symbol) as IrVariableSymbol + val value = deserializeExpression(proto.value) + val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null + return IrSetValueImpl(start, end, builtIns.unitType, symbol, value, origin) + } + + private fun deserializeSpreadElement(proto: ProtoSpreadElement): IrSpreadElement { + val expression = deserializeExpression(proto.expression) + val coordinates = BinaryCoordinates.decode(proto.coordinates) + return IrSpreadElementImpl(coordinates.startOffset, coordinates.endOffset, expression) + } + + private fun deserializeStringConcat(proto: ProtoStringConcat, start: Int, end: Int, type: IrType): IrStringConcatenation { + val argumentProtos = proto.argumentList + val arguments = mutableListOf() + + argumentProtos.forEach { + arguments.add(deserializeExpression(it)) + } + return IrStringConcatenationImpl(start, end, type, arguments) + } + + private fun deserializeThrow(proto: ProtoThrow, start: Int, end: Int): IrThrowImpl { + return IrThrowImpl(start, end, builtIns.nothingType, deserializeExpression(proto.value)) + } + + private fun deserializeTry(proto: ProtoTry, start: Int, end: Int, type: IrType): IrTryImpl { + val result = deserializeExpression(proto.result) + val catches = mutableListOf() + proto.catchList.forEach { + catches.add(deserializeStatement(it) as IrCatch) + } + val finallyExpression = + if (proto.hasFinally()) deserializeExpression(proto.getFinally()) else null + return IrTryImpl(start, end, type, result, catches, finallyExpression) + } + + private fun deserializeTypeOperator(operator: ProtoTypeOperator) = when (operator) { + ProtoTypeOperator.CAST -> + IrTypeOperator.CAST + ProtoTypeOperator.IMPLICIT_CAST -> + IrTypeOperator.IMPLICIT_CAST + ProtoTypeOperator.IMPLICIT_NOTNULL -> + IrTypeOperator.IMPLICIT_NOTNULL + ProtoTypeOperator.IMPLICIT_COERCION_TO_UNIT -> + IrTypeOperator.IMPLICIT_COERCION_TO_UNIT + ProtoTypeOperator.IMPLICIT_INTEGER_COERCION -> + IrTypeOperator.IMPLICIT_INTEGER_COERCION + ProtoTypeOperator.SAFE_CAST -> + IrTypeOperator.SAFE_CAST + ProtoTypeOperator.INSTANCEOF -> + IrTypeOperator.INSTANCEOF + ProtoTypeOperator.NOT_INSTANCEOF -> + IrTypeOperator.NOT_INSTANCEOF + ProtoTypeOperator.SAM_CONVERSION -> + IrTypeOperator.SAM_CONVERSION + ProtoTypeOperator.IMPLICIT_DYNAMIC_CAST -> + IrTypeOperator.IMPLICIT_DYNAMIC_CAST + } + + private fun deserializeTypeOp(proto: ProtoTypeOp, start: Int, end: Int, type: IrType): IrTypeOperatorCall { + val operator = deserializeTypeOperator(proto.operator) + val operand = declarationDeserializer.deserializeIrType(proto.operand)//.brokenIr + val argument = deserializeExpression(proto.argument) + return IrTypeOperatorCallImpl(start, end, type, operator, operand, argument) + } + + private fun deserializeVararg(proto: ProtoVararg, start: Int, end: Int, type: IrType): IrVararg { + val elementType = declarationDeserializer.deserializeIrType(proto.elementType) + + val elements = mutableListOf() + proto.elementList.forEach { + elements.add(deserializeVarargElement(it)) + } + return IrVarargImpl(start, end, type, elementType, elements) + } + + private fun deserializeVarargElement(element: ProtoVarargElement): IrVarargElement { + return when (element.varargElementCase) { + VarargElementCase.EXPRESSION + -> deserializeExpression(element.expression) + VarargElementCase.SPREAD_ELEMENT + -> deserializeSpreadElement(element.spreadElement) + else + -> TODO("Unexpected vararg element") + } + } + + private fun deserializeWhen(proto: ProtoWhen, start: Int, end: Int, type: IrType): IrWhen { + val branches = mutableListOf() + val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null + + proto.branchList.forEach { + branches.add(deserializeStatement(it) as IrBranch) + } + + // TODO: provide some origin! + return IrWhenImpl(start, end, type, origin, branches) + } + + private fun deserializeLoop(proto: ProtoLoop, loop: IrLoop): IrLoop { + val label = if (proto.hasLabel()) fileReader.deserializeString(proto.label) else null + val body = if (proto.hasBody()) deserializeExpression(proto.body) else null + val condition = deserializeExpression(proto.condition) + + loop.label = label + loop.condition = condition + loop.body = body + + return loop + } + + // we create the loop before deserializing the body, so that + // IrBreak statements have something to put into 'loop' field. + private fun deserializeDoWhile(proto: ProtoDoWhile, start: Int, end: Int, type: IrType) = + deserializeLoop( + proto.loop, + deserializeLoopHeader(proto.loop.loopId) { + val origin = if (proto.loop.hasOriginName()) deserializeIrStatementOrigin(proto.loop.originName) else null + IrDoWhileLoopImpl(start, end, type, origin) + } + ) + + private fun deserializeWhile(proto: ProtoWhile, start: Int, end: Int, type: IrType) = + deserializeLoop( + proto.loop, + deserializeLoopHeader(proto.loop.loopId) { + val origin = if (proto.loop.hasOriginName()) deserializeIrStatementOrigin(proto.loop.originName) else null + IrWhileLoopImpl(start, end, type, origin) + } + ) + + private fun deserializeDynamicMemberExpression( + proto: ProtoDynamicMemberExpression, + start: Int, + end: Int, + type: IrType + ) = + IrDynamicMemberExpressionImpl( + start, + end, + type, + fileReader.deserializeString(proto.memberName), + deserializeExpression(proto.receiver) + ) + + private fun deserializeDynamicOperatorExpression( + proto: ProtoDynamicOperatorExpression, + start: Int, + end: Int, + type: IrType + ) = + IrDynamicOperatorExpressionImpl(start, end, type, deserializeDynamicOperator(proto.operator)).apply { + receiver = deserializeExpression(proto.receiver) + proto.argumentList.mapTo(arguments) { deserializeExpression(it) } + } + + private fun deserializeDynamicOperator(operator: ProtoDynamicOperatorExpression.IrDynamicOperator) = + when (operator) { + ProtoDynamicOperatorExpression.IrDynamicOperator.UNARY_PLUS -> IrDynamicOperator.UNARY_PLUS + ProtoDynamicOperatorExpression.IrDynamicOperator.UNARY_MINUS -> IrDynamicOperator.UNARY_MINUS + + ProtoDynamicOperatorExpression.IrDynamicOperator.EXCL -> IrDynamicOperator.EXCL + + ProtoDynamicOperatorExpression.IrDynamicOperator.PREFIX_INCREMENT -> IrDynamicOperator.PREFIX_INCREMENT + ProtoDynamicOperatorExpression.IrDynamicOperator.PREFIX_DECREMENT -> IrDynamicOperator.PREFIX_DECREMENT + + ProtoDynamicOperatorExpression.IrDynamicOperator.POSTFIX_INCREMENT -> IrDynamicOperator.POSTFIX_INCREMENT + ProtoDynamicOperatorExpression.IrDynamicOperator.POSTFIX_DECREMENT -> IrDynamicOperator.POSTFIX_DECREMENT + + ProtoDynamicOperatorExpression.IrDynamicOperator.BINARY_PLUS -> IrDynamicOperator.BINARY_PLUS + ProtoDynamicOperatorExpression.IrDynamicOperator.BINARY_MINUS -> IrDynamicOperator.BINARY_MINUS + ProtoDynamicOperatorExpression.IrDynamicOperator.MUL -> IrDynamicOperator.MUL + ProtoDynamicOperatorExpression.IrDynamicOperator.DIV -> IrDynamicOperator.DIV + ProtoDynamicOperatorExpression.IrDynamicOperator.MOD -> IrDynamicOperator.MOD + + ProtoDynamicOperatorExpression.IrDynamicOperator.GT -> IrDynamicOperator.GT + ProtoDynamicOperatorExpression.IrDynamicOperator.LT -> IrDynamicOperator.LT + ProtoDynamicOperatorExpression.IrDynamicOperator.GE -> IrDynamicOperator.GE + ProtoDynamicOperatorExpression.IrDynamicOperator.LE -> IrDynamicOperator.LE + + ProtoDynamicOperatorExpression.IrDynamicOperator.EQEQ -> IrDynamicOperator.EQEQ + ProtoDynamicOperatorExpression.IrDynamicOperator.EXCLEQ -> IrDynamicOperator.EXCLEQ + + ProtoDynamicOperatorExpression.IrDynamicOperator.EQEQEQ -> IrDynamicOperator.EQEQEQ + ProtoDynamicOperatorExpression.IrDynamicOperator.EXCLEQEQ -> IrDynamicOperator.EXCLEQEQ + + ProtoDynamicOperatorExpression.IrDynamicOperator.ANDAND -> IrDynamicOperator.ANDAND + ProtoDynamicOperatorExpression.IrDynamicOperator.OROR -> IrDynamicOperator.OROR + + ProtoDynamicOperatorExpression.IrDynamicOperator.EQ -> IrDynamicOperator.EQ + ProtoDynamicOperatorExpression.IrDynamicOperator.PLUSEQ -> IrDynamicOperator.PLUSEQ + ProtoDynamicOperatorExpression.IrDynamicOperator.MINUSEQ -> IrDynamicOperator.MINUSEQ + ProtoDynamicOperatorExpression.IrDynamicOperator.MULEQ -> IrDynamicOperator.MULEQ + ProtoDynamicOperatorExpression.IrDynamicOperator.DIVEQ -> IrDynamicOperator.DIVEQ + ProtoDynamicOperatorExpression.IrDynamicOperator.MODEQ -> IrDynamicOperator.MODEQ + + ProtoDynamicOperatorExpression.IrDynamicOperator.ARRAY_ACCESS -> IrDynamicOperator.ARRAY_ACCESS + + ProtoDynamicOperatorExpression.IrDynamicOperator.INVOKE -> IrDynamicOperator.INVOKE + } + + private fun deserializeBreak(proto: ProtoBreak, start: Int, end: Int, type: IrType): IrBreak { + val label = if (proto.hasLabel()) fileReader.deserializeString(proto.label) else null + val loopId = proto.loopId + val loop = deserializeLoopHeader(loopId) { error("break clause before loop header") } + val irBreak = IrBreakImpl(start, end, type, loop) + irBreak.label = label + + return irBreak + } + + private fun deserializeContinue(proto: ProtoContinue, start: Int, end: Int, type: IrType): IrContinue { + val label = if (proto.hasLabel()) fileReader.deserializeString(proto.label) else null + val loopId = proto.loopId + val loop = deserializeLoopHeader(loopId) { error("continue clause before loop header") } + val irContinue = IrContinueImpl(start, end, type, loop) + irContinue.label = label + + return irContinue + } + + private fun deserializeConst(proto: ProtoConst, start: Int, end: Int, type: IrType): IrExpression = + when (proto.valueCase!!) { + NULL + -> IrConstImpl.constNull(start, end, type) + BOOLEAN + -> IrConstImpl.boolean(start, end, type, proto.boolean) + BYTE + -> IrConstImpl.byte(start, end, type, proto.byte.toByte()) + CHAR + -> IrConstImpl.char(start, end, type, proto.char.toChar()) + SHORT + -> IrConstImpl.short(start, end, type, proto.short.toShort()) + INT + -> IrConstImpl.int(start, end, type, proto.int) + LONG + -> IrConstImpl.long(start, end, type, proto.long) + STRING + -> IrConstImpl.string(start, end, type, fileReader.deserializeString(proto.string)) + FLOAT_BITS + -> IrConstImpl.float(start, end, type, Float.fromBits(proto.floatBits)) + DOUBLE_BITS + -> IrConstImpl.double(start, end, type, Double.fromBits(proto.doubleBits)) + VALUE_NOT_SET + -> error("Const deserialization error: ${proto.valueCase} ") + } + + private fun deserializeOperation(proto: ProtoOperation, start: Int, end: Int, type: IrType): IrExpression = + when (proto.operationCase!!) { + BLOCK -> deserializeBlock(proto.block, start, end, type) + BREAK -> deserializeBreak(proto.`break`, start, end, type) + CLASS_REFERENCE -> deserializeClassReference(proto.classReference, start, end, type) + CALL -> deserializeCall(proto.call, start, end, type) + COMPOSITE -> deserializeComposite(proto.composite, start, end, type) + CONST -> deserializeConst(proto.const, start, end, type) + CONTINUE -> deserializeContinue(proto.`continue`, start, end, type) + DELEGATING_CONSTRUCTOR_CALL -> deserializeDelegatingConstructorCall(proto.delegatingConstructorCall, start, end) + DO_WHILE -> deserializeDoWhile(proto.doWhile, start, end, type) + ENUM_CONSTRUCTOR_CALL -> deserializeEnumConstructorCall(proto.enumConstructorCall, start, end) + FUNCTION_REFERENCE -> deserializeFunctionReference(proto.functionReference, start, end, type) + GET_ENUM_VALUE -> deserializeGetEnumValue(proto.getEnumValue, start, end, type) + GET_CLASS -> deserializeGetClass(proto.getClass, start, end, type) + GET_FIELD -> deserializeGetField(proto.getField, start, end, type) + GET_OBJECT -> deserializeGetObject(proto.getObject, start, end, type) + GET_VALUE -> deserializeGetValue(proto.getValue, start, end, type) + LOCAL_DELEGATED_PROPERTY_REFERENCE -> deserializeIrLocalDelegatedPropertyReference( + proto.localDelegatedPropertyReference, + start, + end, + type + ) + INSTANCE_INITIALIZER_CALL -> deserializeInstanceInitializerCall(proto.instanceInitializerCall, start, end) + PROPERTY_REFERENCE -> deserializePropertyReference(proto.propertyReference, start, end, type) + RETURN -> deserializeReturn(proto.`return`, start, end) + SET_FIELD -> deserializeSetField(proto.setField, start, end) + SET_VALUE -> deserializeSetValue(proto.setValue, start, end) + STRING_CONCAT -> deserializeStringConcat(proto.stringConcat, start, end, type) + THROW -> deserializeThrow(proto.`throw`, start, end) + TRY -> deserializeTry(proto.`try`, start, end, type) + TYPE_OP -> deserializeTypeOp(proto.typeOp, start, end, type) + VARARG -> deserializeVararg(proto.vararg, start, end, type) + WHEN -> deserializeWhen(proto.`when`, start, end, type) + WHILE -> deserializeWhile(proto.`while`, start, end, type) + DYNAMIC_MEMBER -> deserializeDynamicMemberExpression(proto.dynamicMember, start, end, type) + DYNAMIC_OPERATOR -> deserializeDynamicOperatorExpression(proto.dynamicOperator, start, end, type) + CONSTRUCTOR_CALL -> deserializeConstructorCall(proto.constructorCall, start, end, type) + FUNCTION_EXPRESSION -> deserializeFunctionExpression(proto.functionExpression, start, end, type) + ERROR_EXPRESSION -> deserializeErrorExpression(proto.errorExpression, start, end, type) + ERROR_CALL_EXPRESSION -> deserializeErrorCallExpression(proto.errorCallExpression, start, end, type) + OPERATION_NOT_SET -> error("Expression deserialization not implemented: ${proto.operationCase}") + } + + fun deserializeExpression(proto: ProtoExpression): IrExpression { + val coordinates = BinaryCoordinates.decode(proto.coordinates) + val start = coordinates.startOffset + val end = coordinates.endOffset + val type = declarationDeserializer.deserializeIrType(proto.type) + val operation = proto.operation + val expression = deserializeOperation(operation, start, end, type) + + return expression + } + + fun deserializeIrStatementOrigin(protoName: Int): IrStatementOrigin { + return fileReader.deserializeString(protoName).let { + val componentPrefix = "COMPONENT_" + when { + it.startsWith(componentPrefix) -> { + IrStatementOrigin.COMPONENT_N.withIndex(it.removePrefix(componentPrefix).toInt()) + } + else -> statementOriginIndex[it] ?: error("Unexpected statement origin: $it") + } + } + } + + companion object { + + private val allKnownStatementOrigins = IrStatementOrigin::class.nestedClasses.toList() + + private val statementOriginIndex = + allKnownStatementOrigins.mapNotNull { it.objectInstance as? IrStatementOriginImpl }.associateBy { it.debugName } + } +} \ No newline at end of file diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt new file mode 100644 index 00000000000..8e166151faa --- /dev/null +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrDeclarationDeserializer.kt @@ -0,0 +1,695 @@ +/* + * Copyright 2010-2020 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.backend.common.serialization + +import org.jetbrains.kotlin.backend.common.lower.InnerClassesSupport +import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideBuilder +import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideClassFilter +import org.jetbrains.kotlin.backend.common.serialization.encodings.* +import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclaration.DeclaratorCase.* +import org.jetbrains.kotlin.backend.common.serialization.proto.IrType.KindCase.* +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl +import org.jetbrains.kotlin.ir.descriptors.* +import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl +import org.jetbrains.kotlin.ir.symbols.* +import org.jetbrains.kotlin.ir.symbols.impl.IrPublicSymbolBase +import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl +import org.jetbrains.kotlin.ir.types.* +import org.jetbrains.kotlin.ir.types.impl.* +import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.protobuf.CodedInputStream +import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite +import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.backend.common.serialization.proto.IrAnonymousInit as ProtoAnonymousInit +import org.jetbrains.kotlin.backend.common.serialization.proto.IrClass as ProtoClass +import org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructor as ProtoConstructor +import org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall as ProtoConstructorCall +import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclaration as ProtoDeclaration +import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclarationBase as ProtoDeclarationBase +import org.jetbrains.kotlin.backend.common.serialization.proto.IrDynamicType as ProtoDynamicType +import org.jetbrains.kotlin.backend.common.serialization.proto.IrEnumEntry as ProtoEnumEntry +import org.jetbrains.kotlin.backend.common.serialization.proto.IrErrorType as ProtoErrorType +import org.jetbrains.kotlin.backend.common.serialization.proto.IrField as ProtoField +import org.jetbrains.kotlin.backend.common.serialization.proto.IrFunction as ProtoFunction +import org.jetbrains.kotlin.backend.common.serialization.proto.IrFunctionBase as ProtoFunctionBase +import org.jetbrains.kotlin.backend.common.serialization.proto.IrErrorDeclaration as ProtoErrorDeclaration +import org.jetbrains.kotlin.backend.common.serialization.proto.IrExpression as ProtoExpression +import org.jetbrains.kotlin.backend.common.serialization.proto.IrStatement as ProtoStatement +import org.jetbrains.kotlin.backend.common.serialization.proto.IrLocalDelegatedProperty as ProtoLocalDelegatedProperty +import org.jetbrains.kotlin.backend.common.serialization.proto.IrProperty as ProtoProperty +import org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType as ProtoSimpleType +import org.jetbrains.kotlin.backend.common.serialization.proto.IrType as ProtoType +import org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation as ProtoTypeAbbreviation +import org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAlias as ProtoTypeAlias +import org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeParameter as ProtoTypeParameter +import org.jetbrains.kotlin.backend.common.serialization.proto.IrValueParameter as ProtoValueParameter +import org.jetbrains.kotlin.backend.common.serialization.proto.IrVariable as ProtoVariable + + +class IrDeclarationDeserializer( + builtIns: IrBuiltIns, + private val symbolTable: SymbolTable, + private val irFactory: IrFactory, + private val fileReader: IrLibraryFile, + file: IrFile, + private val allowErrorNodes: Boolean, + private val deserializeInlineFunctions: Boolean, + private var deserializeBodies: Boolean, + private val symbolDeserializer: IrSymbolDeserializer, + private val platformFakeOverrideClassFilter: FakeOverrideClassFilter, + private val fakeOverrideBuilder: FakeOverrideBuilder, +) { + + private val bodyDeserializer = IrBodyDeserializer(builtIns, allowErrorNodes, irFactory, fileReader, this) + + private fun deserializeName(index: Int): Name { + val name = fileReader.deserializeString(index) + return Name.guessByFirstCharacter(name) + } + + private val irTypeCache = mutableMapOf() + + private fun readType(index: Int): CodedInputStream = + fileReader.type(index).codedInputStream + + private fun loadTypeProto(index: Int): ProtoType { + return ProtoType.parseFrom(readType(index), ExtensionRegistryLite.newInstance()) + } + + internal fun deserializeIrType(index: Int): IrType { + return irTypeCache.getOrPut(index) { + val typeData = loadTypeProto(index) + deserializeIrTypeData(typeData) + } + } + + private fun deserializeIrTypeArgument(proto: Long): IrTypeArgument { + val encoding = BinaryTypeProjection.decode(proto) + + if (encoding.isStarProjection) return IrStarProjectionImpl + + return makeTypeProjection(deserializeIrType(encoding.typeIndex), encoding.variance) + } + + internal fun deserializeAnnotations(annotations: List): List { + return annotations.map { + bodyDeserializer.deserializeAnnotation(it) + } + } + + private fun deserializeSimpleType(proto: ProtoSimpleType): IrSimpleType { + val symbol = deserializeIrSymbolAndRemap(proto.classifier) as? IrClassifierSymbol + ?: error("could not convert sym to ClassifierSymbol") + + val arguments = proto.argumentList.map { deserializeIrTypeArgument(it) } + val annotations = deserializeAnnotations(proto.annotationList) + + val result: IrSimpleType = IrSimpleTypeImpl( + null, + symbol, + proto.hasQuestionMark, + arguments, + annotations, + if (proto.hasAbbreviation()) deserializeTypeAbbreviation(proto.abbreviation) else null + ) + return result + + } + + private fun deserializeTypeAbbreviation(proto: ProtoTypeAbbreviation): IrTypeAbbreviation = + IrTypeAbbreviationImpl( + deserializeIrSymbolAndRemap(proto.typeAlias).let { + it as? IrTypeAliasSymbol + ?: error("IrTypeAliasSymbol expected: $it") + }, + proto.hasQuestionMark, + proto.argumentList.map { deserializeIrTypeArgument(it) }, + deserializeAnnotations(proto.annotationList) + ) + + private fun deserializeDynamicType(proto: ProtoDynamicType): IrDynamicType { + val annotations = deserializeAnnotations(proto.annotationList) + return IrDynamicTypeImpl(null, annotations, Variance.INVARIANT) + } + + private fun deserializeErrorType(proto: ProtoErrorType): IrErrorType { + require(allowErrorNodes) { "IrErrorType found but error code is not allowed" } + val annotations = deserializeAnnotations(proto.annotationList) + return IrErrorTypeImpl(null, annotations, Variance.INVARIANT) + } + + private fun deserializeIrTypeData(proto: ProtoType): IrType { + return when (proto.kindCase) { + SIMPLE -> deserializeSimpleType(proto.simple) + DYNAMIC -> deserializeDynamicType(proto.dynamic) + ERROR -> deserializeErrorType(proto.error) + else -> error("Unexpected IrType kind: ${proto.kindCase}") + } + } + + private var currentParent: IrDeclarationParent = file + + private inline fun T.usingParent(block: T.() -> Unit): T = + this.apply { + val oldParent = currentParent + currentParent = this + try { + block(this) + } finally { + currentParent = oldParent + } + } + + // Delegating symbol maps to it's delegate only inside the declaration the symbol belongs to. + private val delegatedSymbolMap = mutableMapOf() + + internal fun deserializeIrSymbolAndRemap(code: Long): IrSymbol { + // TODO: could be simplified + return symbolDeserializer.deserializeIrSymbol(code).let { + delegatedSymbolMap[it] ?: it + } + } + + private fun recordDelegatedSymbol(symbol: IrSymbol) { + if (symbol is IrDelegatingSymbol<*, *, *>) { + delegatedSymbolMap[symbol] = symbol.delegate + } + } + + private fun eraseDelegatedSymbol(symbol: IrSymbol) { + if (symbol is IrDelegatingSymbol<*, *, *>) { + delegatedSymbolMap.remove(symbol) + } + } + + private inline fun withDeserializedIrDeclarationBase( + proto: ProtoDeclarationBase, + block: (IrSymbol, IdSignature, Int, Int, IrDeclarationOrigin, Long) -> T + ): T where T : IrDeclaration, T : IrSymbolOwner { + val (s, uid) = symbolDeserializer.deserializeIrSymbolToDeclare(proto.symbol) + val coordinates = BinaryCoordinates.decode(proto.coordinates) + try { + recordDelegatedSymbol(s) + val result = block( + s, + uid, + coordinates.startOffset, coordinates.endOffset, + deserializeIrDeclarationOrigin(proto.originName), proto.flags + ) + result.annotations += deserializeAnnotations(proto.annotationList) + result.parent = currentParent + return result + } finally { + eraseDelegatedSymbol(s) + } + } + + private fun deserializeIrTypeParameter(proto: ProtoTypeParameter, index: Int, isGlobal: Boolean): IrTypeParameter { + val name = deserializeName(proto.name) + val coordinates = BinaryCoordinates.decode(proto.base.coordinates) + val flags = TypeParameterFlags.decode(proto.base.flags) + + val factory = { symbol: IrTypeParameterSymbol -> + irFactory.createTypeParameter( + coordinates.startOffset, + coordinates.endOffset, + deserializeIrDeclarationOrigin(proto.base.originName), + symbol, + name, + index, + flags.isReified, + flags.variance + ) + } + + val sig: IdSignature + val result = symbolTable.run { + if (isGlobal) { + val p = symbolDeserializer.deserializeIrSymbolToDeclare(proto.base.symbol) + val symbol = p.first as IrTypeParameterSymbol + sig = p.second + declareGlobalTypeParameter(sig, { symbol }, factory) + } else { + val symbolData = BinarySymbolData + .decode(proto.base.symbol) + sig = symbolDeserializer.deserializeIdSignature(symbolData.signatureId) + declareScopedTypeParameter(sig, { IrTypeParameterSymbolImpl() }, factory) + } + } + + // make sure this symbol is known to linker + symbolDeserializer.referenceLocalIrSymbol(result.symbol, sig) + result.annotations += deserializeAnnotations(proto.base.annotationList) + result.parent = currentParent + return result + } + + private fun deserializeIrValueParameter(proto: ProtoValueParameter, index: Int): IrValueParameter = + withDeserializedIrDeclarationBase(proto.base) { symbol, _, startOffset, endOffset, origin, fcode -> + val flags = ValueParameterFlags.decode(fcode) + val nameAndType = BinaryNameAndType.decode(proto.nameType) + irFactory.createValueParameter( + startOffset, endOffset, origin, + symbol as IrValueParameterSymbol, + deserializeName(nameAndType.nameIndex), + index, + deserializeIrType(nameAndType.typeIndex), + if (proto.hasVarargElementType()) deserializeIrType(proto.varargElementType) else null, + flags.isCrossInline, + flags.isNoInline, + flags.isHidden, + flags.isAssignable + ).apply { + if (proto.hasDefaultValue()) + defaultValue = deserializeExpressionBody(proto.defaultValue) + } + } + + private fun deserializeIrClass(proto: ProtoClass): IrClass = + withDeserializedIrDeclarationBase(proto.base) { symbol, signature, startOffset, endOffset, origin, fcode -> + val flags = ClassFlags.decode(fcode) + + symbolTable.declareClass(signature, { symbol as IrClassSymbol }) { + irFactory.createClass( + startOffset, endOffset, origin, + it, + deserializeName(proto.name), + flags.kind, + flags.visibility, + flags.modality, + flags.isCompanion, + flags.isInner, + flags.isData, + flags.isExternal, + flags.isInline, + flags.isExpect, + flags.isFun, + ) + }.usingParent { + typeParameters = deserializeTypeParameters(proto.typeParameterList, true) + + superTypes = proto.superTypeList.map { deserializeIrType(it) } + + proto.declarationList + .filterNot { isSkippableFakeOverride(it, this) } + .mapTo(declarations) { deserializeDeclaration(it) } + + thisReceiver = deserializeIrValueParameter(proto.thisReceiver, -1) + + fakeOverrideBuilder.enqueueClass(this, signature) + } + } + + private fun deserializeIrTypeAlias(proto: ProtoTypeAlias): IrTypeAlias = + withDeserializedIrDeclarationBase(proto.base) { symbol, uniqId, startOffset, endOffset, origin, fcode -> + require(symbol is IrTypeAliasSymbol) + symbolTable.declareTypeAlias(uniqId, { symbol }) { + val flags = TypeAliasFlags.decode(fcode) + val nameType = BinaryNameAndType.decode(proto.nameType) + irFactory.createTypeAlias( + startOffset, endOffset, + it, + deserializeName(nameType.nameIndex), + flags.visibility, + deserializeIrType(nameType.typeIndex), + flags.isActual, + origin + ) + }.usingParent { + typeParameters = deserializeTypeParameters(proto.typeParameterList, true) + } + } + + private fun deserializeErrorDeclaration(proto: ProtoErrorDeclaration): IrErrorDeclaration { + require(allowErrorNodes) { "IrErrorDeclaration found but error code is not allowed" } + val coordinates = BinaryCoordinates.decode(proto.coordinates) + return irFactory.createErrorDeclaration(coordinates.startOffset, coordinates.endOffset).also { + it.parent = currentParent + } + } + + private fun deserializeTypeParameters(protos: List, isGlobal: Boolean): List { + // NOTE: fun , T : Any> Array.filterNotNullTo(destination: C): C + val result = ArrayList(protos.size) + for (index in protos.indices) { + val proto = protos[index] + result.add(deserializeIrTypeParameter(proto, index, isGlobal)) + } + + for (i in protos.indices) { + result[i].superTypes = protos[i].superTypeList.map { deserializeIrType(it) } + } + + return result + } + + private fun deserializeValueParameters(protos: List): List { + val result = ArrayList(protos.size) + + for (i in protos.indices) { + result.add(deserializeIrValueParameter(protos[i], i)) + } + + return result + } + + + /** + * In `declarations-only` mode in case of private property/function with inferred anonymous private type like this + * class C { + * private val p = object { + * fun foo() = 42 + * } + * + * private fun f() = object { + * fun bar() = "42" + * } + * + * private val pp = p.foo() + * private fun ff() = f().bar() + * } + * object's classifier is leaked outside p/f scopes and accessible on C's level so + * if their initializer/body weren't read we have unbound `foo/bar` symbol and unbound `object` symbols. + * To fix this make sure that such declaration forced to be deserialized completely. + * + * For more information see `anonymousClassLeak.kt` test and issue KT-40216 + */ + private fun IrType.checkObjectLeak(): Boolean { + return if (this is IrSimpleType) { + classifier.let { !it.isPublicApi && it !is IrTypeParameterSymbol } || arguments.any { it.typeOrNull?.checkObjectLeak() == true } + } else false + } + + private fun T.withBodyGuard(block: T.() -> Unit) { + val oldBodiesPolicy = deserializeBodies + + fun checkInlineBody(): Boolean = deserializeInlineFunctions && this is IrSimpleFunction && isInline + + try { + deserializeBodies = oldBodiesPolicy || checkInlineBody() || returnType.checkObjectLeak() + block() + } finally { + deserializeBodies = oldBodiesPolicy + } + } + + + private fun IrField.withInitializerGuard(f: IrField.() -> Unit) { + val oldBodiesPolicy = deserializeBodies + + try { + deserializeBodies = oldBodiesPolicy || type.checkObjectLeak() + f() + } finally { + deserializeBodies = oldBodiesPolicy + } + } + + private fun readBody(index: Int): CodedInputStream = + fileReader.body(index).codedInputStream + + private fun loadStatementBodyProto(index: Int): ProtoStatement { + return ProtoStatement.parseFrom(readBody(index), ExtensionRegistryLite.newInstance()) + } + + private fun loadExpressionBodyProto(index: Int): ProtoExpression { + return ProtoExpression.parseFrom(readBody(index), ExtensionRegistryLite.newInstance()) + } + + private fun deserializeExpressionBody(index: Int): IrExpressionBody { + return irFactory.createExpressionBody( + if (deserializeBodies) { + val bodyData = loadExpressionBodyProto(index) + bodyDeserializer.deserializeExpression(bodyData) + } else { + val errorType = IrErrorTypeImpl(null, emptyList(), Variance.INVARIANT) + IrErrorExpressionImpl(-1, -1, errorType, "Expression body is not deserialized yet") + } + ) + } + + private fun deserializeStatementBody(index: Int): IrElement { + return if (deserializeBodies) { + val bodyData = loadStatementBodyProto(index) + bodyDeserializer.deserializeStatement(bodyData) + } else { + val errorType = IrErrorTypeImpl(null, emptyList(), Variance.INVARIANT) + irFactory.createBlockBody( + -1, -1, listOf(IrErrorExpressionImpl(-1, -1, errorType, "Statement body is not deserialized yet")) + ) + } + } + + private inline fun withDeserializedIrFunctionBase( + proto: ProtoFunctionBase, + block: (IrFunctionSymbol, IdSignature, Int, Int, IrDeclarationOrigin, Long) -> T + ): T = withDeserializedIrDeclarationBase(proto.base) { symbol, idSig, startOffset, endOffset, origin, fcode -> + symbolTable.withScope(symbol) { + block(symbol as IrFunctionSymbol, idSig, startOffset, endOffset, origin, fcode).usingParent { + typeParameters = deserializeTypeParameters(proto.typeParameterList, false) + val nameType = BinaryNameAndType.decode(proto.nameType) + returnType = deserializeIrType(nameType.typeIndex) + + withBodyGuard { + valueParameters = deserializeValueParameters(proto.valueParameterList) + if (proto.hasDispatchReceiver()) + dispatchReceiverParameter = deserializeIrValueParameter(proto.dispatchReceiver, -1) + if (proto.hasExtensionReceiver()) + extensionReceiverParameter = deserializeIrValueParameter(proto.extensionReceiver, -1) + if (proto.hasBody()) { + body = deserializeStatementBody(proto.body) as IrBody + } + } + } + } + } + + internal fun deserializeIrFunction(proto: ProtoFunction): IrSimpleFunction { + return withDeserializedIrFunctionBase(proto.base) { symbol, idSig, startOffset, endOffset, origin, fcode -> + val flags = FunctionFlags.decode(fcode) + symbolTable.declareSimpleFunction(idSig, { symbol as IrSimpleFunctionSymbol }) { + val nameType = BinaryNameAndType.decode(proto.base.nameType) + irFactory.createFunction( + startOffset, endOffset, origin, + it, + deserializeName(nameType.nameIndex), + flags.visibility, + flags.modality, + IrUninitializedType, + flags.isInline, + flags.isExternal, + flags.isTailrec, + flags.isSuspend, + flags.isOperator, + flags.isInfix, + flags.isExpect, + flags.isFakeOverride + ) + }.apply { + overriddenSymbols = proto.overriddenList.map { deserializeIrSymbolAndRemap(it) as IrSimpleFunctionSymbol } + } + } + } + + internal fun deserializeIrVariable(proto: ProtoVariable): IrVariable = + withDeserializedIrDeclarationBase(proto.base) { symbol, _, startOffset, endOffset, origin, fcode -> + val flags = LocalVariableFlags.decode(fcode) + val nameType = BinaryNameAndType.decode(proto.nameType) + IrVariableImpl( + startOffset, endOffset, origin, + symbol as IrVariableSymbol, + deserializeName(nameType.nameIndex), + deserializeIrType(nameType.typeIndex), + flags.isVar, + flags.isConst, + flags.isLateinit + ).apply { + if (proto.hasInitializer()) + initializer = bodyDeserializer.deserializeExpression(proto.initializer) + } + } + + private fun deserializeIrEnumEntry(proto: ProtoEnumEntry): IrEnumEntry = + withDeserializedIrDeclarationBase(proto.base) { symbol, uniqId, startOffset, endOffset, origin, _ -> + symbolTable.declareEnumEntry(uniqId, { symbol as IrEnumEntrySymbol }) { + irFactory.createEnumEntry(startOffset, endOffset, origin, it, deserializeName(proto.name)) + }.apply { + if (proto.hasCorrespondingClass()) + correspondingClass = deserializeIrClass(proto.correspondingClass) + if (proto.hasInitializer()) + initializerExpression = deserializeExpressionBody(proto.initializer) + } + } + + private fun deserializeIrAnonymousInit(proto: ProtoAnonymousInit): IrAnonymousInitializer = + withDeserializedIrDeclarationBase(proto.base) { symbol, _, startOffset, endOffset, origin, _ -> + irFactory.createAnonymousInitializer(startOffset, endOffset, origin, symbol as IrAnonymousInitializerSymbol).apply { + body = deserializeStatementBody(proto.body) as IrBlockBody + } + } + + private fun deserializeIrConstructor(proto: ProtoConstructor): IrConstructor = + withDeserializedIrFunctionBase(proto.base) { symbol, idSig, startOffset, endOffset, origin, fcode -> + require(symbol is IrConstructorSymbol) + val flags = FunctionFlags.decode(fcode) + val nameType = BinaryNameAndType.decode(proto.base.nameType) + symbolTable.declareConstructor(idSig, { symbol }) { + irFactory.createConstructor( + startOffset, endOffset, origin, + it, + deserializeName(nameType.nameIndex), + flags.visibility, + IrUninitializedType, + flags.isInline, + flags.isExternal, + flags.isPrimary, + flags.isExpect + ) + } + } + + + private fun deserializeIrField(proto: ProtoField): IrField = + withDeserializedIrDeclarationBase(proto.base) { symbol, uniqId, startOffset, endOffset, origin, fcode -> + require(symbol is IrFieldSymbol) + val nameType = BinaryNameAndType.decode(proto.nameType) + val type = deserializeIrType(nameType.typeIndex) + val flags = FieldFlags.decode(fcode) + symbolTable.declareField(uniqId, { symbol }) { + irFactory.createField( + startOffset, endOffset, origin, + it, + deserializeName(nameType.nameIndex), + type, + flags.visibility, + flags.isFinal, + flags.isExternal, + flags.isStatic, + ) + }.usingParent { + if (proto.hasInitializer()) { + withInitializerGuard { + initializer = deserializeExpressionBody(proto.initializer) + } + } + } + } + + private fun deserializeIrLocalDelegatedProperty(proto: ProtoLocalDelegatedProperty): IrLocalDelegatedProperty = + withDeserializedIrDeclarationBase(proto.base) { symbol, _, startOffset, endOffset, origin, fcode -> + val flags = LocalVariableFlags.decode(fcode) + val nameAndType = BinaryNameAndType.decode(proto.nameType) + irFactory.createLocalDelegatedProperty( + startOffset, endOffset, origin, + symbol as IrLocalDelegatedPropertySymbol, + deserializeName(nameAndType.nameIndex), + deserializeIrType(nameAndType.typeIndex), + flags.isVar + ).apply { + delegate = deserializeIrVariable(proto.delegate) + getter = deserializeIrFunction(proto.getter) + if (proto.hasSetter()) + setter = deserializeIrFunction(proto.setter) + } + } + + private fun deserializeIrProperty(proto: ProtoProperty): IrProperty = + withDeserializedIrDeclarationBase(proto.base) { symbol, uniqId, startOffset, endOffset, origin, fcode -> + require(symbol is IrPropertySymbol) + val flags = PropertyFlags.decode(fcode) + symbolTable.declareProperty(uniqId, { symbol }) { + irFactory.createProperty( + startOffset, endOffset, origin, + it, + deserializeName(proto.name), + flags.visibility, + flags.modality, + flags.isVar, + flags.isConst, + flags.isLateinit, + flags.isDelegated, + flags.isExternal, + flags.isExpect, + flags.isFakeOverride + ) + }.apply { + if (proto.hasGetter()) { + getter = deserializeIrFunction(proto.getter).also { + it.correspondingPropertySymbol = symbol + } + } + if (proto.hasSetter()) { + setter = deserializeIrFunction(proto.setter).also { + it.correspondingPropertySymbol = symbol + } + } + if (proto.hasBackingField()) { + backingField = deserializeIrField(proto.backingField).also { + it.correspondingPropertySymbol = symbol + } + } + } + } + + companion object { + private val allKnownDeclarationOrigins = + IrDeclarationOrigin::class.nestedClasses.toList() + InnerClassesSupport.FIELD_FOR_OUTER_THIS::class + private val declarationOriginIndex = + allKnownDeclarationOrigins.map { it.objectInstance as IrDeclarationOriginImpl }.associateBy { it.name } + } + + private fun deserializeIrDeclarationOrigin(protoName: Int): IrDeclarationOriginImpl { + val originName = fileReader.deserializeString(protoName) + return declarationOriginIndex[originName] ?: object : IrDeclarationOriginImpl(originName) {} + } + + fun deserializeDeclaration(proto: ProtoDeclaration): IrDeclaration { + val declaration: IrDeclaration = when (proto.declaratorCase!!) { + IR_ANONYMOUS_INIT -> deserializeIrAnonymousInit(proto.irAnonymousInit) + IR_CONSTRUCTOR -> deserializeIrConstructor(proto.irConstructor) + IR_FIELD -> deserializeIrField(proto.irField) + IR_CLASS -> deserializeIrClass(proto.irClass) + IR_FUNCTION -> deserializeIrFunction(proto.irFunction) + IR_PROPERTY -> deserializeIrProperty(proto.irProperty) + IR_TYPE_PARAMETER -> error("Unreachable execution Type Parameter") // deserializeIrTypeParameter(proto.irTypeParameter) + IR_VARIABLE -> deserializeIrVariable(proto.irVariable) + IR_VALUE_PARAMETER -> error("Unreachable execution Value Parameter") // deserializeIrValueParameter(proto.irValueParameter) + IR_ENUM_ENTRY -> deserializeIrEnumEntry(proto.irEnumEntry) + IR_LOCAL_DELEGATED_PROPERTY -> deserializeIrLocalDelegatedProperty(proto.irLocalDelegatedProperty) + IR_TYPE_ALIAS -> deserializeIrTypeAlias(proto.irTypeAlias) + IR_ERROR_DECLARATION -> deserializeErrorDeclaration(proto.irErrorDeclaration) + DECLARATOR_NOT_SET -> error("Declaration deserialization not implemented: ${proto.declaratorCase}") + } + + return declaration + } + + // Depending on deserialization strategy we either deserialize public api fake overrides + // or reconstruct them after IR linker completes. + private fun isSkippableFakeOverride(proto: ProtoDeclaration, parent: IrClass): Boolean { + if (!platformFakeOverrideClassFilter.needToConstructFakeOverrides(parent)) return false + + val symbol = when (proto.declaratorCase!!) { + IR_FUNCTION -> symbolDeserializer.deserializeIrSymbol(proto.irFunction.base.base.symbol) + IR_PROPERTY -> symbolDeserializer.deserializeIrSymbol(proto.irProperty.base.symbol) + // Don't consider IR_FIELDS here. + else -> return false + } + if (symbol !is IrPublicSymbolBase<*>) return false + if (!symbol.signature.isPublic) return false + + return when (proto.declaratorCase!!) { + IR_FUNCTION -> FunctionFlags.decode(proto.irFunction.base.base.flags).isFakeOverride + IR_PROPERTY -> PropertyFlags.decode(proto.irProperty.base.flags).isFakeOverride + // Don't consider IR_FIELDS here. + else -> false + } + } +} \ No newline at end of file diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt index b949cff18ac..dd2d4861c5b 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt @@ -5,1450 +5,157 @@ package org.jetbrains.kotlin.backend.common.serialization -import org.jetbrains.kotlin.backend.common.lower.InnerClassesSupport -import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideBuilder -import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideClassFilter -import org.jetbrains.kotlin.backend.common.peek -import org.jetbrains.kotlin.backend.common.pop -import org.jetbrains.kotlin.backend.common.push -import org.jetbrains.kotlin.backend.common.serialization.encodings.* -import org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature.IdsigCase.* -import org.jetbrains.kotlin.backend.common.serialization.proto.IrConst.ValueCase.* -import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclaration.DeclaratorCase.* -import org.jetbrains.kotlin.backend.common.serialization.proto.IrOperation.OperationCase.* -import org.jetbrains.kotlin.backend.common.serialization.proto.IrStatement.StatementCase -import org.jetbrains.kotlin.backend.common.serialization.proto.IrType.KindCase.* -import org.jetbrains.kotlin.backend.common.serialization.proto.IrVarargElement.VarargElementCase -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.IrStatement +import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl -import org.jetbrains.kotlin.ir.descriptors.* -import org.jetbrains.kotlin.ir.expressions.* -import org.jetbrains.kotlin.ir.expressions.impl.* -import org.jetbrains.kotlin.ir.symbols.* -import org.jetbrains.kotlin.ir.symbols.impl.IrPublicSymbolBase -import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl -import org.jetbrains.kotlin.ir.types.* -import org.jetbrains.kotlin.ir.types.impl.* +import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl +import org.jetbrains.kotlin.ir.symbols.impl.IrFileSymbolImpl import org.jetbrains.kotlin.ir.util.* -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.types.Variance -import org.jetbrains.kotlin.backend.common.serialization.proto.AccessorIdSignature as ProtoAccessorIdSignature -import org.jetbrains.kotlin.backend.common.serialization.proto.FileLocalIdSignature as ProtoFileLocalIdSignature -import org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature as ProtoIdSignature -import org.jetbrains.kotlin.backend.common.serialization.proto.IrAnonymousInit as ProtoAnonymousInit -import org.jetbrains.kotlin.backend.common.serialization.proto.IrBlock as ProtoBlock -import org.jetbrains.kotlin.backend.common.serialization.proto.IrBlockBody as ProtoBlockBody -import org.jetbrains.kotlin.backend.common.serialization.proto.IrBranch as ProtoBranch -import org.jetbrains.kotlin.backend.common.serialization.proto.IrBreak as ProtoBreak -import org.jetbrains.kotlin.backend.common.serialization.proto.IrCall as ProtoCall -import org.jetbrains.kotlin.backend.common.serialization.proto.IrCatch as ProtoCatch -import org.jetbrains.kotlin.backend.common.serialization.proto.IrClass as ProtoClass -import org.jetbrains.kotlin.backend.common.serialization.proto.IrClassReference as ProtoClassReference -import org.jetbrains.kotlin.backend.common.serialization.proto.IrComposite as ProtoComposite -import org.jetbrains.kotlin.backend.common.serialization.proto.IrConst as ProtoConst -import org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructor as ProtoConstructor +import org.jetbrains.kotlin.library.IrLibrary +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.protobuf.CodedInputStream +import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite import org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall as ProtoConstructorCall -import org.jetbrains.kotlin.backend.common.serialization.proto.IrContinue as ProtoContinue import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclaration as ProtoDeclaration -import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclarationBase as ProtoDeclarationBase -import org.jetbrains.kotlin.backend.common.serialization.proto.IrDelegatingConstructorCall as ProtoDelegatingConstructorCall -import org.jetbrains.kotlin.backend.common.serialization.proto.IrDoWhile as ProtoDoWhile -import org.jetbrains.kotlin.backend.common.serialization.proto.IrDynamicMemberExpression as ProtoDynamicMemberExpression -import org.jetbrains.kotlin.backend.common.serialization.proto.IrDynamicOperatorExpression as ProtoDynamicOperatorExpression -import org.jetbrains.kotlin.backend.common.serialization.proto.IrDynamicType as ProtoDynamicType -import org.jetbrains.kotlin.backend.common.serialization.proto.IrEnumConstructorCall as ProtoEnumConstructorCall -import org.jetbrains.kotlin.backend.common.serialization.proto.IrEnumEntry as ProtoEnumEntry -import org.jetbrains.kotlin.backend.common.serialization.proto.IrErrorCallExpression as ProtoErrorCallExpression -import org.jetbrains.kotlin.backend.common.serialization.proto.IrErrorDeclaration as ProtoErrorDeclaration -import org.jetbrains.kotlin.backend.common.serialization.proto.IrErrorExpression as ProtoErrorExpression -import org.jetbrains.kotlin.backend.common.serialization.proto.IrErrorType as ProtoErrorType -import org.jetbrains.kotlin.backend.common.serialization.proto.IrExpression as ProtoExpression -import org.jetbrains.kotlin.backend.common.serialization.proto.IrField as ProtoField -import org.jetbrains.kotlin.backend.common.serialization.proto.IrFunction as ProtoFunction -import org.jetbrains.kotlin.backend.common.serialization.proto.IrFunctionBase as ProtoFunctionBase -import org.jetbrains.kotlin.backend.common.serialization.proto.IrFunctionExpression as ProtoFunctionExpression -import org.jetbrains.kotlin.backend.common.serialization.proto.IrFunctionReference as ProtoFunctionReference -import org.jetbrains.kotlin.backend.common.serialization.proto.IrGetClass as ProtoGetClass -import org.jetbrains.kotlin.backend.common.serialization.proto.IrGetEnumValue as ProtoGetEnumValue -import org.jetbrains.kotlin.backend.common.serialization.proto.IrGetField as ProtoGetField -import org.jetbrains.kotlin.backend.common.serialization.proto.IrGetObject as ProtoGetObject -import org.jetbrains.kotlin.backend.common.serialization.proto.IrGetValue as ProtoGetValue -import org.jetbrains.kotlin.backend.common.serialization.proto.IrInstanceInitializerCall as ProtoInstanceInitializerCall -import org.jetbrains.kotlin.backend.common.serialization.proto.IrLocalDelegatedProperty as ProtoLocalDelegatedProperty -import org.jetbrains.kotlin.backend.common.serialization.proto.IrLocalDelegatedPropertyReference as ProtoLocalDelegatedPropertyReference -import org.jetbrains.kotlin.backend.common.serialization.proto.IrOperation as ProtoOperation -import org.jetbrains.kotlin.backend.common.serialization.proto.IrProperty as ProtoProperty -import org.jetbrains.kotlin.backend.common.serialization.proto.IrPropertyReference as ProtoPropertyReference -import org.jetbrains.kotlin.backend.common.serialization.proto.IrReturn as ProtoReturn -import org.jetbrains.kotlin.backend.common.serialization.proto.IrSetField as ProtoSetField -import org.jetbrains.kotlin.backend.common.serialization.proto.IrSetValue as ProtoSetValue -import org.jetbrains.kotlin.backend.common.serialization.proto.IrSimpleType as ProtoSimpleType -import org.jetbrains.kotlin.backend.common.serialization.proto.IrSpreadElement as ProtoSpreadElement -import org.jetbrains.kotlin.backend.common.serialization.proto.IrStatement as ProtoStatement -import org.jetbrains.kotlin.backend.common.serialization.proto.IrStringConcat as ProtoStringConcat -import org.jetbrains.kotlin.backend.common.serialization.proto.IrSyntheticBody as ProtoSyntheticBody -import org.jetbrains.kotlin.backend.common.serialization.proto.IrSyntheticBodyKind as ProtoSyntheticBodyKind -import org.jetbrains.kotlin.backend.common.serialization.proto.IrThrow as ProtoThrow -import org.jetbrains.kotlin.backend.common.serialization.proto.IrTry as ProtoTry -import org.jetbrains.kotlin.backend.common.serialization.proto.IrType as ProtoType -import org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAbbreviation as ProtoTypeAbbreviation -import org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeAlias as ProtoTypeAlias -import org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeOp as ProtoTypeOp -import org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeOperator as ProtoTypeOperator -import org.jetbrains.kotlin.backend.common.serialization.proto.IrTypeParameter as ProtoTypeParameter -import org.jetbrains.kotlin.backend.common.serialization.proto.IrValueParameter as ProtoValueParameter -import org.jetbrains.kotlin.backend.common.serialization.proto.IrVararg as ProtoVararg -import org.jetbrains.kotlin.backend.common.serialization.proto.IrVarargElement as ProtoVarargElement -import org.jetbrains.kotlin.backend.common.serialization.proto.IrVariable as ProtoVariable -import org.jetbrains.kotlin.backend.common.serialization.proto.IrWhen as ProtoWhen -import org.jetbrains.kotlin.backend.common.serialization.proto.IrWhile as ProtoWhile -import org.jetbrains.kotlin.backend.common.serialization.proto.Loop as ProtoLoop -import org.jetbrains.kotlin.backend.common.serialization.proto.MemberAccessCommon as ProtoMemberAccessCommon -import org.jetbrains.kotlin.backend.common.serialization.proto.PublicIdSignature as ProtoPublicIdSignature +import org.jetbrains.kotlin.backend.common.serialization.proto.IrFile as ProtoFile -abstract class IrFileDeserializer( - val messageLogger: IrMessageLogger, - val builtIns: IrBuiltIns, - val symbolTable: SymbolTable, - protected var deserializeBodies: Boolean, - private val fakeOverrideBuilder: FakeOverrideBuilder, - private val allowErrorNodes: Boolean +class IrFileDeserializer( + val file: IrFile, + private val fileReader: IrLibraryFile, + fileProto: ProtoFile, + val symbolDeserializer: IrSymbolDeserializer, + val declarationDeserializer: IrDeclarationDeserializer, ) { - protected val irFactory: IrFactory get() = symbolTable.irFactory + val reversedSignatureIndex = fileProto.declarationIdList.associateBy { symbolDeserializer.deserializeIdSignature(it) } - abstract fun deserializeIrSymbolToDeclare(code: Long): Pair - abstract fun deserializeIrSymbol(code: Long): IrSymbol - abstract fun deserializeIrType(index: Int): IrType - abstract fun deserializeIdSignature(index: Int): IdSignature - abstract fun deserializeString(index: Int): String - abstract fun deserializeExpressionBody(index: Int): IrExpression - abstract fun deserializeStatementBody(index: Int): IrElement - abstract fun deserializeLoopHeader(loopIndex: Int, loopBuilder: () -> IrLoop): IrLoop + private var annotations: List? = fileProto.annotationList - abstract fun referenceIrSymbol(symbol: IrSymbol, signature: IdSignature) - - private val parentsStack = mutableListOf() - private val delegatedSymbolMap = mutableMapOf() - - abstract val deserializeInlineFunctions: Boolean - abstract val platformFakeOverrideClassFilter: FakeOverrideClassFilter - - fun deserializeFqName(fqn: List): String = - fqn.joinToString(".", transform = ::deserializeString) - - private fun deserializeIrSymbolAndRemap(code: Long): IrSymbol { - // TODO: could be simplified - return deserializeIrSymbol(code).let { - delegatedSymbolMap[it] ?: it + internal fun deserializeDeclaration(idSig: IdSignature): IrDeclaration { + return declarationDeserializer.deserializeDeclaration(loadTopLevelDeclarationProto(idSig)).also { + file.declarations += it } } - private fun deserializeName(index: Int): Name { - val name = deserializeString(index) - return Name.guessByFirstCharacter(name) + private fun readDeclaration(index: Int): CodedInputStream = + fileReader.irDeclaration(index).codedInputStream + + private fun loadTopLevelDeclarationProto(idSig: IdSignature): ProtoDeclaration { + val idSigIndex = reversedSignatureIndex[idSig] ?: error("Not found Idx for $idSig") + return ProtoDeclaration.parseFrom(readDeclaration(idSigIndex), ExtensionRegistryLite.newInstance()) } - private fun deserializeIrTypeArgument(proto: Long): IrTypeArgument { - val encoding = BinaryTypeProjection.decode(proto) - - if (encoding.isStarProjection) return IrStarProjectionImpl - - return makeTypeProjection(deserializeIrType(encoding.typeIndex), encoding.variance) - } - - fun deserializeAnnotations(annotations: List): List { - return annotations.map { - deserializeConstructorCall(it, 0, 0, builtIns.unitType) // TODO: need a proper deserialization here + fun deserializeFileImplicitDataIfFirstUse() { + annotations?.let { + file.annotations += declarationDeserializer.deserializeAnnotations(it) + annotations = null } } - - private fun deserializeSimpleType(proto: ProtoSimpleType): IrSimpleType { - val symbol = deserializeIrSymbolAndRemap(proto.classifier) as? IrClassifierSymbol - ?: error("could not convert sym to ClassifierSymbol") - - val arguments = proto.argumentList.map { deserializeIrTypeArgument(it) } - val annotations = deserializeAnnotations(proto.annotationList) - - val result: IrSimpleType = IrSimpleTypeImpl( - null, - symbol, - proto.hasQuestionMark, - arguments, - annotations, - if (proto.hasAbbreviation()) deserializeTypeAbbreviation(proto.abbreviation) else null - ) - return result - - } - - private fun deserializeTypeAbbreviation(proto: ProtoTypeAbbreviation): IrTypeAbbreviation = - IrTypeAbbreviationImpl( - deserializeIrSymbolAndRemap(proto.typeAlias).let { - it as? IrTypeAliasSymbol - ?: error("IrTypeAliasSymbol expected: $it") - }, - proto.hasQuestionMark, - proto.argumentList.map { deserializeIrTypeArgument(it) }, - deserializeAnnotations(proto.annotationList) - ) - - private fun deserializeDynamicType(proto: ProtoDynamicType): IrDynamicType { - val annotations = deserializeAnnotations(proto.annotationList) - return IrDynamicTypeImpl(null, annotations, Variance.INVARIANT) - } - - private fun deserializeErrorType(proto: ProtoErrorType): IrErrorType { - require(allowErrorNodes) { "IrErrorType found but error code is not allowed" } - val annotations = deserializeAnnotations(proto.annotationList) - return IrErrorTypeImpl(null, annotations, Variance.INVARIANT) - } - - fun deserializeIrTypeData(proto: ProtoType): IrType { - return when (proto.kindCase) { - SIMPLE -> deserializeSimpleType(proto.simple) - DYNAMIC -> deserializeDynamicType(proto.dynamic) - ERROR -> deserializeErrorType(proto.error) - else -> error("Unexpected IrType kind: ${proto.kindCase}") - } - } - - /* -------------------------------------------------------------- */ - - // TODO: Think about isolating id signature related logic behind corresponding interface - - private fun deserializePublicIdSignature(proto: ProtoPublicIdSignature): IdSignature.PublicSignature { - val pkg = deserializeFqName(proto.packageFqNameList) - val cls = deserializeFqName(proto.declarationFqNameList) - val memberId = if (proto.hasMemberUniqId()) proto.memberUniqId else null - - return IdSignature.PublicSignature(pkg, cls, memberId, proto.flags) - } - - private fun deserializeAccessorIdSignature(proto: ProtoAccessorIdSignature): IdSignature.AccessorSignature { - val propertySignature = deserializeIdSignature(proto.propertySignature) - require(propertySignature is IdSignature.PublicSignature) { "For public accessor corresponding property supposed to be public as well" } - val name = deserializeString(proto.name) - val hash = proto.accessorHashId - val mask = proto.flags - - val accessorSignature = - IdSignature.PublicSignature(propertySignature.packageFqName, "${propertySignature.declarationFqName}.$name", hash, mask) - - return IdSignature.AccessorSignature(propertySignature, accessorSignature) - } - - private fun deserializeFileLocalIdSignature(proto: ProtoFileLocalIdSignature): IdSignature.FileLocalSignature { - return IdSignature.FileLocalSignature(deserializeIdSignature(proto.container), proto.localId) - } - - private fun deserializeScopeLocalIdSignature(proto: Int): IdSignature.ScopeLocalDeclaration { - return IdSignature.ScopeLocalDeclaration(proto) - } - - fun deserializeSignatureData(proto: ProtoIdSignature): IdSignature { - return when (proto.idsigCase) { - PUBLIC_SIG -> deserializePublicIdSignature(proto.publicSig) - ACCESSOR_SIG -> deserializeAccessorIdSignature(proto.accessorSig) - PRIVATE_SIG -> deserializeFileLocalIdSignature(proto.privateSig) - SCOPED_LOCAL_SIG -> deserializeScopeLocalIdSignature(proto.scopedLocalSig) - else -> error("Unexpected IdSignature kind: ${proto.idsigCase}") - } - } - - /* -------------------------------------------------------------- */ - - private fun deserializeBlockBody( - proto: ProtoBlockBody, - start: Int, end: Int - ): IrBlockBody { - - val statements = mutableListOf() - - val statementProtos = proto.statementList - statementProtos.forEach { - statements.add(deserializeStatement(it) as IrStatement) - } - - return irFactory.createBlockBody(start, end, statements) - } - - private fun deserializeBranch(proto: ProtoBranch, start: Int, end: Int): IrBranch { - - val condition = deserializeExpression(proto.condition) - val result = deserializeExpression(proto.result) - - return IrBranchImpl(start, end, condition, result) - } - - private fun deserializeCatch(proto: ProtoCatch, start: Int, end: Int): IrCatch { - val catchParameter = deserializeIrVariable(proto.catchParameter) - val result = deserializeExpression(proto.result) - - return IrCatchImpl(start, end, catchParameter, result) - } - - private fun deserializeSyntheticBody(proto: ProtoSyntheticBody, start: Int, end: Int): IrSyntheticBody { - val kind = when (proto.kind!!) { - ProtoSyntheticBodyKind.ENUM_VALUES -> IrSyntheticBodyKind.ENUM_VALUES - ProtoSyntheticBodyKind.ENUM_VALUEOF -> IrSyntheticBodyKind.ENUM_VALUEOF - } - return IrSyntheticBodyImpl(start, end, kind) - } - - fun deserializeStatement(proto: ProtoStatement): IrElement { - val coordinates = BinaryCoordinates.decode(proto.coordinates) - val start = coordinates.startOffset - val end = coordinates.endOffset - val element = when (proto.statementCase) { - StatementCase.BLOCK_BODY //proto.hasBlockBody() - -> deserializeBlockBody(proto.blockBody, start, end) - StatementCase.BRANCH //proto.hasBranch() - -> deserializeBranch(proto.branch, start, end) - StatementCase.CATCH //proto.hasCatch() - -> deserializeCatch(proto.catch, start, end) - StatementCase.DECLARATION // proto.hasDeclaration() - -> deserializeDeclaration(proto.declaration) - StatementCase.EXPRESSION // proto.hasExpression() - -> deserializeExpression(proto.expression) - StatementCase.SYNTHETIC_BODY // proto.hasSyntheticBody() - -> deserializeSyntheticBody(proto.syntheticBody, start, end) - else - -> TODO("Statement deserialization not implemented: ${proto.statementCase}") - } - - return element - } - - private fun deserializeBlock(proto: ProtoBlock, start: Int, end: Int, type: IrType): IrBlock { - val statements = mutableListOf() - val statementProtos = proto.statementList - val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null - - statementProtos.forEach { - statements.add(deserializeStatement(it) as IrStatement) - } - - return IrBlockImpl(start, end, type, origin, statements) - } - - private fun deserializeMemberAccessCommon(access: IrMemberAccessExpression<*>, proto: ProtoMemberAccessCommon) { - - proto.valueArgumentList.mapIndexed { i, arg -> - if (arg.hasExpression()) { - val expr = deserializeExpression(arg.expression) - access.putValueArgument(i, expr) - } - } - - proto.typeArgumentList.mapIndexed { i, arg -> - access.putTypeArgument(i, deserializeIrType(arg)) - } - - if (proto.hasDispatchReceiver()) { - access.dispatchReceiver = deserializeExpression(proto.dispatchReceiver) - } - if (proto.hasExtensionReceiver()) { - access.extensionReceiver = deserializeExpression(proto.extensionReceiver) - } - } - - private fun deserializeClassReference( - proto: ProtoClassReference, - start: Int, - end: Int, - type: IrType - ): IrClassReference { - val symbol = deserializeIrSymbolAndRemap(proto.classSymbol) as IrClassifierSymbol - val classType = deserializeIrType(proto.classType) - /** TODO: [createClassifierSymbolForClassReference] is internal function */ - return IrClassReferenceImpl(start, end, type, symbol, classType) - } - - private fun deserializeConstructorCall(proto: ProtoConstructorCall, start: Int, end: Int, type: IrType): IrConstructorCall { - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrConstructorSymbol - return IrConstructorCallImpl( - start, end, type, - symbol, typeArgumentsCount = proto.memberAccess.typeArgumentCount, - constructorTypeArgumentsCount = proto.constructorTypeArgumentsCount, - valueArgumentsCount = proto.memberAccess.valueArgumentCount - ).also { - deserializeMemberAccessCommon(it, proto.memberAccess) - } - } - - private fun deserializeCall(proto: ProtoCall, start: Int, end: Int, type: IrType): IrCall { - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrSimpleFunctionSymbol - - val superSymbol = if (proto.hasSuper()) { - deserializeIrSymbolAndRemap(proto.`super`) as IrClassSymbol - } else null - - val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null - - val call: IrCall = - // TODO: implement the last three args here. - IrCallImpl( - start, end, type, - symbol, proto.memberAccess.typeArgumentCount, - proto.memberAccess.valueArgumentList.size, - origin, - superSymbol - ) - deserializeMemberAccessCommon(call, proto.memberAccess) - return call - } - - private fun deserializeComposite(proto: ProtoComposite, start: Int, end: Int, type: IrType): IrComposite { - val statements = mutableListOf() - val statementProtos = proto.statementList - val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null - - statementProtos.forEach { - statements.add(deserializeStatement(it) as IrStatement) - } - return IrCompositeImpl(start, end, type, origin, statements) - } - - private fun deserializeDelegatingConstructorCall( - proto: ProtoDelegatingConstructorCall, - start: Int, - end: Int - ): IrDelegatingConstructorCall { - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrConstructorSymbol - val call = IrDelegatingConstructorCallImpl( - start, - end, - builtIns.unitType, - symbol, - proto.memberAccess.typeArgumentCount, - proto.memberAccess.valueArgumentCount - ) - - deserializeMemberAccessCommon(call, proto.memberAccess) - return call - } - - - private fun deserializeEnumConstructorCall( - proto: ProtoEnumConstructorCall, - start: Int, - end: Int, - ): IrEnumConstructorCall { - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrConstructorSymbol - val call = IrEnumConstructorCallImpl( - start, - end, - builtIns.unitType, - symbol, - proto.memberAccess.typeArgumentCount, - proto.memberAccess.valueArgumentCount - ) - deserializeMemberAccessCommon(call, proto.memberAccess) - return call - } - - private fun deserializeFunctionExpression( - functionExpression: ProtoFunctionExpression, - start: Int, - end: Int, - type: IrType - ) = - IrFunctionExpressionImpl( - start, end, type, - deserializeIrFunction(functionExpression.function), - deserializeIrStatementOrigin(functionExpression.originName) - ) - - private fun deserializeErrorExpression( - proto: ProtoErrorExpression, - start: Int, end: Int, type: IrType - ): IrErrorExpression { - require(allowErrorNodes) { - "IrErrorExpression($start, $end, \"${deserializeString(proto.description)}\") found but error code is not allowed" - } - return IrErrorExpressionImpl(start, end, type, deserializeString(proto.description)) - } - - private fun deserializeErrorCallExpression( - proto: ProtoErrorCallExpression, - start: Int, end: Int, type: IrType - ): IrErrorCallExpression { - require(allowErrorNodes) { - "IrErrorCallExpressionImpl($start, $end, \"${deserializeString(proto.description)}\") found but error code is not allowed" - } - return IrErrorCallExpressionImpl(start, end, type, deserializeString(proto.description)).apply { - if (proto.hasReceiver()) { - explicitReceiver = deserializeExpression(proto.receiver) - } - proto.valueArgumentList.forEach { - addArgument(deserializeExpression(it)) - } - } - - } - - private fun deserializeFunctionReference( - proto: ProtoFunctionReference, - start: Int, end: Int, type: IrType - ): IrFunctionReference { - - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrFunctionSymbol - val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null - val reflectionTarget = - if (proto.hasReflectionTargetSymbol()) deserializeIrSymbolAndRemap(proto.reflectionTargetSymbol) as IrFunctionSymbol else null - val callable = IrFunctionReferenceImpl( - start, - end, - type, - symbol, - proto.memberAccess.typeArgumentCount, - proto.memberAccess.valueArgumentCount, - reflectionTarget, - origin - ) - deserializeMemberAccessCommon(callable, proto.memberAccess) - - return callable - } - - private fun deserializeGetClass(proto: ProtoGetClass, start: Int, end: Int, type: IrType): IrGetClass { - val argument = deserializeExpression(proto.argument) - return IrGetClassImpl(start, end, type, argument) - } - - private fun deserializeGetField(proto: ProtoGetField, start: Int, end: Int, type: IrType): IrGetField { - val access = proto.fieldAccess - val symbol = deserializeIrSymbolAndRemap(access.symbol) as IrFieldSymbol - val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null - - val superQualifier = if (access.hasSuper()) { - deserializeIrSymbolAndRemap(access.symbol) as IrClassSymbol - } else null - val receiver = if (access.hasReceiver()) { - deserializeExpression(access.receiver) - } else null - - return IrGetFieldImpl(start, end, symbol, type, receiver, origin, superQualifier) - } - - private fun deserializeGetValue(proto: ProtoGetValue, start: Int, end: Int, type: IrType): IrGetValue { - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrValueSymbol - val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null - // TODO: origin! - return IrGetValueImpl(start, end, type, symbol, origin) - } - - private fun deserializeGetEnumValue( - proto: ProtoGetEnumValue, - start: Int, - end: Int, - type: IrType - ): IrGetEnumValue { - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrEnumEntrySymbol - return IrGetEnumValueImpl(start, end, type, symbol) - } - - private fun deserializeGetObject( - proto: ProtoGetObject, - start: Int, - end: Int, - type: IrType - ): IrGetObjectValue { - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrClassSymbol - return IrGetObjectValueImpl(start, end, type, symbol) - } - - private fun deserializeInstanceInitializerCall( - proto: ProtoInstanceInitializerCall, - start: Int, - end: Int - ): IrInstanceInitializerCall { - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrClassSymbol - return IrInstanceInitializerCallImpl(start, end, symbol, builtIns.unitType) - } - - private fun deserializeIrLocalDelegatedPropertyReference( - proto: ProtoLocalDelegatedPropertyReference, - start: Int, - end: Int, - type: IrType - ): IrLocalDelegatedPropertyReference { - - val delegate = deserializeIrSymbolAndRemap(proto.delegate) as IrVariableSymbol - val getter = deserializeIrSymbolAndRemap(proto.getter) as IrSimpleFunctionSymbol - val setter = if (proto.hasSetter()) deserializeIrSymbolAndRemap(proto.setter) as IrSimpleFunctionSymbol else null - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrLocalDelegatedPropertySymbol - val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null - - return IrLocalDelegatedPropertyReferenceImpl( - start, end, type, - symbol, - delegate, - getter, - setter, - origin - ) - } - - private fun deserializePropertyReference(proto: ProtoPropertyReference, start: Int, end: Int, type: IrType): IrPropertyReference { - - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrPropertySymbol - - val field = if (proto.hasField()) deserializeIrSymbolAndRemap(proto.field) as IrFieldSymbol else null - val getter = if (proto.hasGetter()) deserializeIrSymbolAndRemap(proto.getter) as IrSimpleFunctionSymbol else null - val setter = if (proto.hasSetter()) deserializeIrSymbolAndRemap(proto.setter) as IrSimpleFunctionSymbol else null - val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null - - val callable = IrPropertyReferenceImpl( - start, end, type, - symbol, - proto.memberAccess.typeArgumentCount, - field, - getter, - setter, - origin - ) - deserializeMemberAccessCommon(callable, proto.memberAccess) - return callable - } - - private fun deserializeReturn(proto: ProtoReturn, start: Int, end: Int): IrReturn { - val symbol = deserializeIrSymbolAndRemap(proto.returnTarget) as IrReturnTargetSymbol - val value = deserializeExpression(proto.value) - return IrReturnImpl(start, end, builtIns.nothingType, symbol, value) - } - - private fun deserializeSetField(proto: ProtoSetField, start: Int, end: Int): IrSetField { - val access = proto.fieldAccess - val symbol = deserializeIrSymbolAndRemap(access.symbol) as IrFieldSymbol - val superQualifier = if (access.hasSuper()) { - deserializeIrSymbolAndRemap(access.symbol) as IrClassSymbol - } else null - val receiver = if (access.hasReceiver()) { - deserializeExpression(access.receiver) - } else null - val value = deserializeExpression(proto.value) - val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null - - return IrSetFieldImpl(start, end, symbol, receiver, value, builtIns.unitType, origin, superQualifier) - } - - private fun deserializeSetValue(proto: ProtoSetValue, start: Int, end: Int): IrSetValue { - val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrVariableSymbol - val value = deserializeExpression(proto.value) - val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null - return IrSetValueImpl(start, end, builtIns.unitType, symbol, value, origin) - } - - private fun deserializeSpreadElement(proto: ProtoSpreadElement): IrSpreadElement { - val expression = deserializeExpression(proto.expression) - val coordinates = BinaryCoordinates.decode(proto.coordinates) - return IrSpreadElementImpl(coordinates.startOffset, coordinates.endOffset, expression) - } - - private fun deserializeStringConcat(proto: ProtoStringConcat, start: Int, end: Int, type: IrType): IrStringConcatenation { - val argumentProtos = proto.argumentList - val arguments = mutableListOf() - - argumentProtos.forEach { - arguments.add(deserializeExpression(it)) - } - return IrStringConcatenationImpl(start, end, type, arguments) - } - - private fun deserializeThrow(proto: ProtoThrow, start: Int, end: Int): IrThrowImpl { - return IrThrowImpl(start, end, builtIns.nothingType, deserializeExpression(proto.value)) - } - - private fun deserializeTry(proto: ProtoTry, start: Int, end: Int, type: IrType): IrTryImpl { - val result = deserializeExpression(proto.result) - val catches = mutableListOf() - proto.catchList.forEach { - catches.add(deserializeStatement(it) as IrCatch) - } - val finallyExpression = - if (proto.hasFinally()) deserializeExpression(proto.getFinally()) else null - return IrTryImpl(start, end, type, result, catches, finallyExpression) - } - - private fun deserializeTypeOperator(operator: ProtoTypeOperator) = when (operator) { - ProtoTypeOperator.CAST -> - IrTypeOperator.CAST - ProtoTypeOperator.IMPLICIT_CAST -> - IrTypeOperator.IMPLICIT_CAST - ProtoTypeOperator.IMPLICIT_NOTNULL -> - IrTypeOperator.IMPLICIT_NOTNULL - ProtoTypeOperator.IMPLICIT_COERCION_TO_UNIT -> - IrTypeOperator.IMPLICIT_COERCION_TO_UNIT - ProtoTypeOperator.IMPLICIT_INTEGER_COERCION -> - IrTypeOperator.IMPLICIT_INTEGER_COERCION - ProtoTypeOperator.SAFE_CAST -> - IrTypeOperator.SAFE_CAST - ProtoTypeOperator.INSTANCEOF -> - IrTypeOperator.INSTANCEOF - ProtoTypeOperator.NOT_INSTANCEOF -> - IrTypeOperator.NOT_INSTANCEOF - ProtoTypeOperator.SAM_CONVERSION -> - IrTypeOperator.SAM_CONVERSION - ProtoTypeOperator.IMPLICIT_DYNAMIC_CAST -> - IrTypeOperator.IMPLICIT_DYNAMIC_CAST - } - - private fun deserializeTypeOp(proto: ProtoTypeOp, start: Int, end: Int, type: IrType): IrTypeOperatorCall { - val operator = deserializeTypeOperator(proto.operator) - val operand = deserializeIrType(proto.operand)//.brokenIr - val argument = deserializeExpression(proto.argument) - return IrTypeOperatorCallImpl(start, end, type, operator, operand, argument) - } - - private fun deserializeVararg(proto: ProtoVararg, start: Int, end: Int, type: IrType): IrVararg { - val elementType = deserializeIrType(proto.elementType) - - val elements = mutableListOf() - proto.elementList.forEach { - elements.add(deserializeVarargElement(it)) - } - return IrVarargImpl(start, end, type, elementType, elements) - } - - private fun deserializeVarargElement(element: ProtoVarargElement): IrVarargElement { - return when (element.varargElementCase) { - VarargElementCase.EXPRESSION - -> deserializeExpression(element.expression) - VarargElementCase.SPREAD_ELEMENT - -> deserializeSpreadElement(element.spreadElement) - else - -> TODO("Unexpected vararg element") - } - } - - private fun deserializeWhen(proto: ProtoWhen, start: Int, end: Int, type: IrType): IrWhen { - val branches = mutableListOf() - val origin = if (proto.hasOriginName()) deserializeIrStatementOrigin(proto.originName) else null - - proto.branchList.forEach { - branches.add(deserializeStatement(it) as IrBranch) - } - - // TODO: provide some origin! - return IrWhenImpl(start, end, type, origin, branches) - } - - private fun deserializeLoop(proto: ProtoLoop, loop: IrLoop): IrLoop { - val label = if (proto.hasLabel()) deserializeString(proto.label) else null - val body = if (proto.hasBody()) deserializeExpression(proto.body) else null - val condition = deserializeExpression(proto.condition) - - loop.label = label - loop.condition = condition - loop.body = body - - return loop - } - - // we create the loop before deserializing the body, so that - // IrBreak statements have something to put into 'loop' field. - private fun deserializeDoWhile(proto: ProtoDoWhile, start: Int, end: Int, type: IrType) = - deserializeLoop( - proto.loop, - deserializeLoopHeader(proto.loop.loopId) { - val origin = if (proto.loop.hasOriginName()) deserializeIrStatementOrigin(proto.loop.originName) else null - IrDoWhileLoopImpl(start, end, type, origin) - } - ) - - private fun deserializeWhile(proto: ProtoWhile, start: Int, end: Int, type: IrType) = - deserializeLoop( - proto.loop, - deserializeLoopHeader(proto.loop.loopId) { - val origin = if (proto.loop.hasOriginName()) deserializeIrStatementOrigin(proto.loop.originName) else null - IrWhileLoopImpl(start, end, type, origin) - } - ) - - private fun deserializeDynamicMemberExpression( - proto: ProtoDynamicMemberExpression, - start: Int, - end: Int, - type: IrType - ) = - IrDynamicMemberExpressionImpl( - start, - end, - type, - deserializeString(proto.memberName), - deserializeExpression(proto.receiver) - ) - - private fun deserializeDynamicOperatorExpression( - proto: ProtoDynamicOperatorExpression, - start: Int, - end: Int, - type: IrType - ) = - IrDynamicOperatorExpressionImpl(start, end, type, deserializeDynamicOperator(proto.operator)).apply { - receiver = deserializeExpression(proto.receiver) - proto.argumentList.mapTo(arguments) { deserializeExpression(it) } - } - - private fun deserializeDynamicOperator(operator: ProtoDynamicOperatorExpression.IrDynamicOperator) = - when (operator) { - ProtoDynamicOperatorExpression.IrDynamicOperator.UNARY_PLUS -> IrDynamicOperator.UNARY_PLUS - ProtoDynamicOperatorExpression.IrDynamicOperator.UNARY_MINUS -> IrDynamicOperator.UNARY_MINUS - - ProtoDynamicOperatorExpression.IrDynamicOperator.EXCL -> IrDynamicOperator.EXCL - - ProtoDynamicOperatorExpression.IrDynamicOperator.PREFIX_INCREMENT -> IrDynamicOperator.PREFIX_INCREMENT - ProtoDynamicOperatorExpression.IrDynamicOperator.PREFIX_DECREMENT -> IrDynamicOperator.PREFIX_DECREMENT - - ProtoDynamicOperatorExpression.IrDynamicOperator.POSTFIX_INCREMENT -> IrDynamicOperator.POSTFIX_INCREMENT - ProtoDynamicOperatorExpression.IrDynamicOperator.POSTFIX_DECREMENT -> IrDynamicOperator.POSTFIX_DECREMENT - - ProtoDynamicOperatorExpression.IrDynamicOperator.BINARY_PLUS -> IrDynamicOperator.BINARY_PLUS - ProtoDynamicOperatorExpression.IrDynamicOperator.BINARY_MINUS -> IrDynamicOperator.BINARY_MINUS - ProtoDynamicOperatorExpression.IrDynamicOperator.MUL -> IrDynamicOperator.MUL - ProtoDynamicOperatorExpression.IrDynamicOperator.DIV -> IrDynamicOperator.DIV - ProtoDynamicOperatorExpression.IrDynamicOperator.MOD -> IrDynamicOperator.MOD - - ProtoDynamicOperatorExpression.IrDynamicOperator.GT -> IrDynamicOperator.GT - ProtoDynamicOperatorExpression.IrDynamicOperator.LT -> IrDynamicOperator.LT - ProtoDynamicOperatorExpression.IrDynamicOperator.GE -> IrDynamicOperator.GE - ProtoDynamicOperatorExpression.IrDynamicOperator.LE -> IrDynamicOperator.LE - - ProtoDynamicOperatorExpression.IrDynamicOperator.EQEQ -> IrDynamicOperator.EQEQ - ProtoDynamicOperatorExpression.IrDynamicOperator.EXCLEQ -> IrDynamicOperator.EXCLEQ - - ProtoDynamicOperatorExpression.IrDynamicOperator.EQEQEQ -> IrDynamicOperator.EQEQEQ - ProtoDynamicOperatorExpression.IrDynamicOperator.EXCLEQEQ -> IrDynamicOperator.EXCLEQEQ - - ProtoDynamicOperatorExpression.IrDynamicOperator.ANDAND -> IrDynamicOperator.ANDAND - ProtoDynamicOperatorExpression.IrDynamicOperator.OROR -> IrDynamicOperator.OROR - - ProtoDynamicOperatorExpression.IrDynamicOperator.EQ -> IrDynamicOperator.EQ - ProtoDynamicOperatorExpression.IrDynamicOperator.PLUSEQ -> IrDynamicOperator.PLUSEQ - ProtoDynamicOperatorExpression.IrDynamicOperator.MINUSEQ -> IrDynamicOperator.MINUSEQ - ProtoDynamicOperatorExpression.IrDynamicOperator.MULEQ -> IrDynamicOperator.MULEQ - ProtoDynamicOperatorExpression.IrDynamicOperator.DIVEQ -> IrDynamicOperator.DIVEQ - ProtoDynamicOperatorExpression.IrDynamicOperator.MODEQ -> IrDynamicOperator.MODEQ - - ProtoDynamicOperatorExpression.IrDynamicOperator.ARRAY_ACCESS -> IrDynamicOperator.ARRAY_ACCESS - - ProtoDynamicOperatorExpression.IrDynamicOperator.INVOKE -> IrDynamicOperator.INVOKE - } - - private fun deserializeBreak(proto: ProtoBreak, start: Int, end: Int, type: IrType): IrBreak { - val label = if (proto.hasLabel()) deserializeString(proto.label) else null - val loopId = proto.loopId - val loop = deserializeLoopHeader(loopId) { error("break clause before loop header") } - val irBreak = IrBreakImpl(start, end, type, loop) - irBreak.label = label - - return irBreak - } - - private fun deserializeContinue(proto: ProtoContinue, start: Int, end: Int, type: IrType): IrContinue { - val label = if (proto.hasLabel()) deserializeString(proto.label) else null - val loopId = proto.loopId - val loop = deserializeLoopHeader(loopId) { error("continue clause before loop header") } - val irContinue = IrContinueImpl(start, end, type, loop) - irContinue.label = label - - return irContinue - } - - private fun deserializeConst(proto: ProtoConst, start: Int, end: Int, type: IrType): IrExpression = - when (proto.valueCase!!) { - NULL - -> IrConstImpl.constNull(start, end, type) - BOOLEAN - -> IrConstImpl.boolean(start, end, type, proto.boolean) - BYTE - -> IrConstImpl.byte(start, end, type, proto.byte.toByte()) - CHAR - -> IrConstImpl.char(start, end, type, proto.char.toChar()) - SHORT - -> IrConstImpl.short(start, end, type, proto.short.toShort()) - INT - -> IrConstImpl.int(start, end, type, proto.int) - LONG - -> IrConstImpl.long(start, end, type, proto.long) - STRING - -> IrConstImpl.string(start, end, type, deserializeString(proto.string)) - FLOAT_BITS - -> IrConstImpl.float(start, end, type, Float.fromBits(proto.floatBits)) - DOUBLE_BITS - -> IrConstImpl.double(start, end, type, Double.fromBits(proto.doubleBits)) - VALUE_NOT_SET - -> error("Const deserialization error: ${proto.valueCase} ") - } - - private fun deserializeOperation(proto: ProtoOperation, start: Int, end: Int, type: IrType): IrExpression = - when (proto.operationCase!!) { - BLOCK -> deserializeBlock(proto.block, start, end, type) - BREAK -> deserializeBreak(proto.`break`, start, end, type) - CLASS_REFERENCE -> deserializeClassReference(proto.classReference, start, end, type) - CALL -> deserializeCall(proto.call, start, end, type) - COMPOSITE -> deserializeComposite(proto.composite, start, end, type) - CONST -> deserializeConst(proto.const, start, end, type) - CONTINUE -> deserializeContinue(proto.`continue`, start, end, type) - DELEGATING_CONSTRUCTOR_CALL -> deserializeDelegatingConstructorCall(proto.delegatingConstructorCall, start, end) - DO_WHILE -> deserializeDoWhile(proto.doWhile, start, end, type) - ENUM_CONSTRUCTOR_CALL -> deserializeEnumConstructorCall(proto.enumConstructorCall, start, end) - FUNCTION_REFERENCE -> deserializeFunctionReference(proto.functionReference, start, end, type) - GET_ENUM_VALUE -> deserializeGetEnumValue(proto.getEnumValue, start, end, type) - GET_CLASS -> deserializeGetClass(proto.getClass, start, end, type) - GET_FIELD -> deserializeGetField(proto.getField, start, end, type) - GET_OBJECT -> deserializeGetObject(proto.getObject, start, end, type) - GET_VALUE -> deserializeGetValue(proto.getValue, start, end, type) - LOCAL_DELEGATED_PROPERTY_REFERENCE -> deserializeIrLocalDelegatedPropertyReference(proto.localDelegatedPropertyReference, start, end, type) - INSTANCE_INITIALIZER_CALL -> deserializeInstanceInitializerCall(proto.instanceInitializerCall, start, end) - PROPERTY_REFERENCE -> deserializePropertyReference(proto.propertyReference, start, end, type) - RETURN -> deserializeReturn(proto.`return`, start, end) - SET_FIELD -> deserializeSetField(proto.setField, start, end) - SET_VALUE -> deserializeSetValue(proto.setValue, start, end) - STRING_CONCAT -> deserializeStringConcat(proto.stringConcat, start, end, type) - THROW -> deserializeThrow(proto.`throw`, start, end) - TRY -> deserializeTry(proto.`try`, start, end, type) - TYPE_OP -> deserializeTypeOp(proto.typeOp, start, end, type) - VARARG -> deserializeVararg(proto.vararg, start, end, type) - WHEN -> deserializeWhen(proto.`when`, start, end, type) - WHILE -> deserializeWhile(proto.`while`, start, end, type) - DYNAMIC_MEMBER -> deserializeDynamicMemberExpression(proto.dynamicMember, start, end, type) - DYNAMIC_OPERATOR -> deserializeDynamicOperatorExpression(proto.dynamicOperator, start, end, type) - CONSTRUCTOR_CALL -> deserializeConstructorCall(proto.constructorCall, start, end, type) - FUNCTION_EXPRESSION -> deserializeFunctionExpression(proto.functionExpression, start, end, type) - ERROR_EXPRESSION -> deserializeErrorExpression(proto.errorExpression, start, end, type) - ERROR_CALL_EXPRESSION -> deserializeErrorCallExpression(proto.errorCallExpression, start, end, type) - OPERATION_NOT_SET -> error("Expression deserialization not implemented: ${proto.operationCase}") - } - - fun deserializeExpression(proto: ProtoExpression): IrExpression { - val coordinates = BinaryCoordinates.decode(proto.coordinates) - val start = coordinates.startOffset - val end = coordinates.endOffset - val type = deserializeIrType(proto.type) - val operation = proto.operation - val expression = deserializeOperation(operation, start, end, type) - - return expression - } - - private inline fun usingParent(parent: T, block: (T) -> R): R { - parentsStack.push(parent) - try { - return block(parent) - } finally { - parentsStack.pop() - } - } - - private fun recordDelegatedSymbol(symbol: IrSymbol) { - if (symbol is IrDelegatingSymbol<*, *, *>) { - delegatedSymbolMap[symbol] = symbol.delegate - } - } - - private fun eraseDelegatedSymbol(symbol: IrSymbol) { - if (symbol is IrDelegatingSymbol<*, *, *>) { - delegatedSymbolMap.remove(symbol) - } - } - - private inline fun T.usingParent(block: T.() -> Unit): T = - this.apply { usingParent(this) { block(it) } } - - private inline fun withDeserializedIrDeclarationBase( - proto: ProtoDeclarationBase, - block: (IrSymbol, IdSignature, Int, Int, IrDeclarationOrigin, Long) -> T - ): T where T : IrDeclaration, T : IrSymbolOwner { - val (s, uid) = deserializeIrSymbolToDeclare(proto.symbol) - val coordinates = BinaryCoordinates.decode(proto.coordinates) - try { - recordDelegatedSymbol(s) - val result = block( - s, - uid, - coordinates.startOffset, coordinates.endOffset, - deserializeIrDeclarationOrigin(proto.originName), proto.flags - ) - result.annotations += deserializeAnnotations(proto.annotationList) - result.parent = parentsStack.peek()!! - return result - } finally { - eraseDelegatedSymbol(s) - } - } - - private fun deserializeIrTypeParameter(proto: ProtoTypeParameter, index: Int, isGlobal: Boolean): IrTypeParameter { - val name = deserializeName(proto.name) - val coordinates = BinaryCoordinates.decode(proto.base.coordinates) - val flags = TypeParameterFlags.decode(proto.base.flags) - - val factory = { symbol: IrTypeParameterSymbol -> - irFactory.createTypeParameter( - coordinates.startOffset, - coordinates.endOffset, - deserializeIrDeclarationOrigin(proto.base.originName), - symbol, - name, - index, - flags.isReified, - flags.variance - ) - } - - val sig: IdSignature - val result = symbolTable.run { - if (isGlobal) { - val p = deserializeIrSymbolToDeclare(proto.base.symbol) - val symbol = p.first as IrTypeParameterSymbol - sig = p.second - declareGlobalTypeParameter(sig, { symbol }, factory) - } else { - val symbolData = BinarySymbolData - .decode(proto.base.symbol) - sig = deserializeIdSignature(symbolData.signatureId) - declareScopedTypeParameter(sig, { IrTypeParameterSymbolImpl() }, factory) - } - } - - // make sure this symbol is known to linker - referenceIrSymbol(result.symbol, sig) - result.annotations += deserializeAnnotations(proto.base.annotationList) - result.parent = parentsStack.peek()!! - return result - } - - private fun deserializeIrValueParameter(proto: ProtoValueParameter, index: Int): IrValueParameter = - withDeserializedIrDeclarationBase(proto.base) { symbol, _, startOffset, endOffset, origin, fcode -> - val flags = ValueParameterFlags.decode(fcode) - val nameAndType = BinaryNameAndType.decode(proto.nameType) - irFactory.createValueParameter( - startOffset, endOffset, origin, - symbol as IrValueParameterSymbol, - deserializeName(nameAndType.nameIndex), - index, - deserializeIrType(nameAndType.typeIndex), - if (proto.hasVarargElementType()) deserializeIrType(proto.varargElementType) else null, - flags.isCrossInline, - flags.isNoInline, - flags.isHidden, - flags.isAssignable - ).apply { - if (proto.hasDefaultValue()) - defaultValue = irFactory.createExpressionBody(deserializeExpressionBody(proto.defaultValue)) - } - } - - private fun deserializeIrClass(proto: ProtoClass): IrClass = - withDeserializedIrDeclarationBase(proto.base) { symbol, signature, startOffset, endOffset, origin, fcode -> - val flags = ClassFlags.decode(fcode) - - symbolTable.declareClass(signature, { symbol as IrClassSymbol }) { - irFactory.createClass( - startOffset, endOffset, origin, - it, - deserializeName(proto.name), - flags.kind, - flags.visibility, - flags.modality, - flags.isCompanion, - flags.isInner, - flags.isData, - flags.isExternal, - flags.isInline, - flags.isExpect, - flags.isFun, - ) - }.usingParent { - typeParameters = deserializeTypeParameters(proto.typeParameterList, true) - - superTypes = proto.superTypeList.map { deserializeIrType(it) } - - proto.declarationList - .filterNot { isSkippableFakeOverride(it, this) } - .mapTo(declarations) { deserializeDeclaration(it) } - - thisReceiver = deserializeIrValueParameter(proto.thisReceiver, -1) - - fakeOverrideBuilder.enqueueClass(this, signature) - } - } - - private fun deserializeIrTypeAlias(proto: ProtoTypeAlias): IrTypeAlias = - withDeserializedIrDeclarationBase(proto.base) { symbol, uniqId, startOffset, endOffset, origin, fcode -> - require(symbol is IrTypeAliasSymbol) - symbolTable.declareTypeAlias(uniqId, { symbol }) { - val flags = TypeAliasFlags.decode(fcode) - val nameType = BinaryNameAndType.decode(proto.nameType) - irFactory.createTypeAlias( - startOffset, endOffset, - it, - deserializeName(nameType.nameIndex), - flags.visibility, - deserializeIrType(nameType.typeIndex), - flags.isActual, - origin - ) - }.usingParent { - typeParameters = deserializeTypeParameters(proto.typeParameterList, true) - } - } - - private fun deserializeErrorDeclaration(proto: ProtoErrorDeclaration): IrErrorDeclaration { - require(allowErrorNodes) { "IrErrorDeclaration found but error code is not allowed" } - val coordinates = BinaryCoordinates.decode(proto.coordinates) - return irFactory.createErrorDeclaration(coordinates.startOffset, coordinates.endOffset).also { - it.parent = parentsStack.peek()!! - } - } - - private fun deserializeTypeParameters(protos: List, isGlobal: Boolean): List { - // NOTE: fun , T : Any> Array.filterNotNullTo(destination: C): C - val result = ArrayList(protos.size) - for (index in protos.indices) { - val proto = protos[index] - result.add(deserializeIrTypeParameter(proto, index, isGlobal)) - } - - for (i in protos.indices) { - result[i].superTypes = protos[i].superTypeList.map { deserializeIrType(it) } - } - - return result - } - - private fun deserializeValueParameters(protos: List): List { - val result = ArrayList(protos.size) - - for (i in protos.indices) { - result.add(deserializeIrValueParameter(protos[i], i)) - } - - return result - } - - - /** - * In `declarations-only` mode in case of private property/function with inferred anonymous private type like this - * class C { - * private val p = object { - * fun foo() = 42 - * } - * - * private fun f() = object { - * fun bar() = "42" - * } - * - * private val pp = p.foo() - * private fun ff() = f().bar() - * } - * object's classifier is leaked outside p/f scopes and accessible on C's level so - * if their initializer/body weren't read we have unbound `foo/bar` symbol and unbound `object` symbols. - * To fix this make sure that such declaration forced to be deserialized completely. - * - * For more information see `anonymousClassLeak.kt` test and issue KT-40216 - */ - private fun IrType.checkObjectLeak(): Boolean { - return if (this is IrSimpleType) { - classifier.let { !it.isPublicApi && it !is IrTypeParameterSymbol } || arguments.any { it.typeOrNull?.checkObjectLeak() == true } - } else false - } - - private fun T.withBodyGuard(block: T.() -> Unit) { - val oldBodiesPolicy = deserializeBodies - - fun checkInlineBody(): Boolean = deserializeInlineFunctions && this is IrSimpleFunction && isInline - - try { - deserializeBodies = oldBodiesPolicy || checkInlineBody() || returnType.checkObjectLeak() - block() - } finally { - deserializeBodies = oldBodiesPolicy - } - } - - - private fun IrField.withInitializerGuard(f: IrField.() -> Unit) { - val oldBodiesPolicy = deserializeBodies - - try { - deserializeBodies = oldBodiesPolicy || type.checkObjectLeak() - f() - } finally { - deserializeBodies = oldBodiesPolicy - } - } - - private inline fun withDeserializedIrFunctionBase( - proto: ProtoFunctionBase, - block: (IrFunctionSymbol, IdSignature, Int, Int, IrDeclarationOrigin, Long) -> T - ): T = withDeserializedIrDeclarationBase(proto.base) { symbol, idSig, startOffset, endOffset, origin, fcode -> - symbolTable.withScope(symbol) { - block(symbol as IrFunctionSymbol, idSig, startOffset, endOffset, origin, fcode).usingParent { - typeParameters = deserializeTypeParameters(proto.typeParameterList, false) - val nameType = BinaryNameAndType.decode(proto.nameType) - returnType = deserializeIrType(nameType.typeIndex) - - withBodyGuard { - valueParameters = deserializeValueParameters(proto.valueParameterList) - if (proto.hasDispatchReceiver()) - dispatchReceiverParameter = deserializeIrValueParameter(proto.dispatchReceiver, -1) - if (proto.hasExtensionReceiver()) - extensionReceiverParameter = deserializeIrValueParameter(proto.extensionReceiver, -1) - if (proto.hasBody()) { - body = deserializeStatementBody(proto.body) as IrBody - } - } - } - } - } - - private fun deserializeIrFunction(proto: ProtoFunction): IrSimpleFunction { - return withDeserializedIrFunctionBase(proto.base) { symbol, idSig, startOffset, endOffset, origin, fcode -> - val flags = FunctionFlags.decode(fcode) - symbolTable.declareSimpleFunction(idSig, { symbol as IrSimpleFunctionSymbol }) { - val nameType = BinaryNameAndType.decode(proto.base.nameType) - irFactory.createFunction( - startOffset, endOffset, origin, - it, - deserializeName(nameType.nameIndex), - flags.visibility, - flags.modality, - IrUninitializedType, - flags.isInline, - flags.isExternal, - flags.isTailrec, - flags.isSuspend, - flags.isOperator, - flags.isInfix, - flags.isExpect, - flags.isFakeOverride - ) - }.apply { - overriddenSymbols = proto.overriddenList.map { deserializeIrSymbolAndRemap(it) as IrSimpleFunctionSymbol } - } - } - } - - private fun deserializeIrVariable(proto: ProtoVariable): IrVariable = - withDeserializedIrDeclarationBase(proto.base) { symbol, _, startOffset, endOffset, origin, fcode -> - val flags = LocalVariableFlags.decode(fcode) - val nameType = BinaryNameAndType.decode(proto.nameType) - IrVariableImpl( - startOffset, endOffset, origin, - symbol as IrVariableSymbol, - deserializeName(nameType.nameIndex), - deserializeIrType(nameType.typeIndex), - flags.isVar, - flags.isConst, - flags.isLateinit - ).apply { - if (proto.hasInitializer()) - initializer = deserializeExpression(proto.initializer) - } - } - - private fun deserializeIrEnumEntry(proto: ProtoEnumEntry): IrEnumEntry = - withDeserializedIrDeclarationBase(proto.base) { symbol, uniqId, startOffset, endOffset, origin, _ -> - symbolTable.declareEnumEntry(uniqId, { symbol as IrEnumEntrySymbol }) { - irFactory.createEnumEntry(startOffset, endOffset, origin, it, deserializeName(proto.name)) - }.apply { - if (proto.hasCorrespondingClass()) - correspondingClass = deserializeIrClass(proto.correspondingClass) - if (proto.hasInitializer()) - initializerExpression = irFactory.createExpressionBody(deserializeExpressionBody(proto.initializer)) - } - } - - private fun deserializeIrAnonymousInit(proto: ProtoAnonymousInit): IrAnonymousInitializer = - withDeserializedIrDeclarationBase(proto.base) { symbol, _, startOffset, endOffset, origin, _ -> - irFactory.createAnonymousInitializer(startOffset, endOffset, origin, symbol as IrAnonymousInitializerSymbol).apply { -// body = deserializeBlockBody(proto.body.blockBody, startOffset, endOffset) - body = deserializeStatementBody(proto.body) as IrBlockBody - } - } - - private fun deserializeIrConstructor(proto: ProtoConstructor): IrConstructor = - withDeserializedIrFunctionBase(proto.base) { symbol, idSig, startOffset, endOffset, origin, fcode -> - require(symbol is IrConstructorSymbol) - val flags = FunctionFlags.decode(fcode) - val nameType = BinaryNameAndType.decode(proto.base.nameType) - symbolTable.declareConstructor(idSig, { symbol }) { - irFactory.createConstructor( - startOffset, endOffset, origin, - it, - deserializeName(nameType.nameIndex), - flags.visibility, - IrUninitializedType, - flags.isInline, - flags.isExternal, - flags.isPrimary, - flags.isExpect - ) - } - } - - - - private fun deserializeIrField(proto: ProtoField): IrField = - withDeserializedIrDeclarationBase(proto.base) { symbol, uniqId, startOffset, endOffset, origin, fcode -> - require(symbol is IrFieldSymbol) - val nameType = BinaryNameAndType.decode(proto.nameType) - val type = deserializeIrType(nameType.typeIndex) - val flags = FieldFlags.decode(fcode) - symbolTable.declareField(uniqId, { symbol }) { - irFactory.createField( - startOffset, endOffset, origin, - it, - deserializeName(nameType.nameIndex), - type, - flags.visibility, - flags.isFinal, - flags.isExternal, - flags.isStatic, - ) - }.usingParent { - if (proto.hasInitializer()) { - withInitializerGuard { - initializer = irFactory.createExpressionBody(deserializeExpressionBody(proto.initializer)) - } - } - } - } - - private fun deserializeIrLocalDelegatedProperty(proto: ProtoLocalDelegatedProperty): IrLocalDelegatedProperty = - withDeserializedIrDeclarationBase(proto.base) { symbol, _, startOffset, endOffset, origin, fcode -> - val flags = LocalVariableFlags.decode(fcode) - val nameAndType = BinaryNameAndType.decode(proto.nameType) - irFactory.createLocalDelegatedProperty( - startOffset, endOffset, origin, - symbol as IrLocalDelegatedPropertySymbol, - deserializeName(nameAndType.nameIndex), - deserializeIrType(nameAndType.typeIndex), - flags.isVar - ).apply { - delegate = deserializeIrVariable(proto.delegate) - getter = deserializeIrFunction(proto.getter) - if (proto.hasSetter()) - setter = deserializeIrFunction(proto.setter) - } - } - - private fun deserializeIrProperty(proto: ProtoProperty): IrProperty = - withDeserializedIrDeclarationBase(proto.base) { symbol, uniqId, startOffset, endOffset, origin, fcode -> - require(symbol is IrPropertySymbol) - val flags = PropertyFlags.decode(fcode) - symbolTable.declareProperty(uniqId, { symbol }) { - irFactory.createProperty( - startOffset, endOffset, origin, - it, - deserializeName(proto.name), - flags.visibility, - flags.modality, - flags.isVar, - flags.isConst, - flags.isLateinit, - flags.isDelegated, - flags.isExternal, - flags.isExpect, - flags.isFakeOverride - ) - }.apply { - if (proto.hasGetter()) { - getter = deserializeIrFunction(proto.getter).also { - it.correspondingPropertySymbol = symbol - } - } - if (proto.hasSetter()) { - setter = deserializeIrFunction(proto.setter).also { - it.correspondingPropertySymbol = symbol - } - } - if (proto.hasBackingField()) { - backingField = deserializeIrField(proto.backingField).also { - it.correspondingPropertySymbol = symbol - } - } - } - } - - companion object { - private val allKnownDeclarationOrigins = - IrDeclarationOrigin::class.nestedClasses.toList() + InnerClassesSupport.FIELD_FOR_OUTER_THIS::class - private val declarationOriginIndex = - allKnownDeclarationOrigins.map { it.objectInstance as IrDeclarationOriginImpl }.associateBy { it.name } - - private val allKnownStatementOrigins = - IrStatementOrigin::class.nestedClasses.toList() - private val statementOriginIndex = - allKnownStatementOrigins.mapNotNull { it.objectInstance as? IrStatementOriginImpl }.associateBy { it.debugName } - } - - private fun deserializeIrDeclarationOrigin(protoName: Int): IrDeclarationOriginImpl { - val originName = deserializeString(protoName) - return declarationOriginIndex[originName] ?: object : IrDeclarationOriginImpl(originName) {} - } - - fun deserializeIrStatementOrigin(protoName: Int): IrStatementOrigin { - return deserializeString(protoName).let { - val componentPrefix = "COMPONENT_" - when { - it.startsWith(componentPrefix) -> { - IrStatementOrigin.COMPONENT_N.withIndex(it.removePrefix(componentPrefix).toInt()) - } - else -> statementOriginIndex[it] ?: error("Unexpected statement origin: $it") - } - } - } - - private fun deserializeDeclaration(proto: ProtoDeclaration): IrDeclaration { - val declaration: IrDeclaration = when (proto.declaratorCase!!) { - IR_ANONYMOUS_INIT -> deserializeIrAnonymousInit(proto.irAnonymousInit) - IR_CONSTRUCTOR -> deserializeIrConstructor(proto.irConstructor) - IR_FIELD -> deserializeIrField(proto.irField) - IR_CLASS -> deserializeIrClass(proto.irClass) - IR_FUNCTION -> deserializeIrFunction(proto.irFunction) - IR_PROPERTY -> deserializeIrProperty(proto.irProperty) - IR_TYPE_PARAMETER -> error("Unreachable execution Type Parameter") // deserializeIrTypeParameter(proto.irTypeParameter) - IR_VARIABLE -> deserializeIrVariable(proto.irVariable) - IR_VALUE_PARAMETER -> error("Unreachable execution Value Parameter") // deserializeIrValueParameter(proto.irValueParameter) - IR_ENUM_ENTRY -> deserializeIrEnumEntry(proto.irEnumEntry) - IR_LOCAL_DELEGATED_PROPERTY -> deserializeIrLocalDelegatedProperty(proto.irLocalDelegatedProperty) - IR_TYPE_ALIAS -> deserializeIrTypeAlias(proto.irTypeAlias) - IR_ERROR_DECLARATION -> deserializeErrorDeclaration(proto.irErrorDeclaration) - DECLARATOR_NOT_SET -> error("Declaration deserialization not implemented: ${proto.declaratorCase}") - } - - return declaration - } - - // Depending on deserialization strategy we either deserialize public api fake overrides - // or reconstruct them after IR linker completes. - private fun isSkippableFakeOverride(proto: ProtoDeclaration, parent: IrClass): Boolean { - if (!platformFakeOverrideClassFilter.needToConstructFakeOverrides(parent)) return false - - val symbol = when (proto.declaratorCase!!) { - IR_FUNCTION -> deserializeIrSymbol(proto.irFunction.base.base.symbol) - IR_PROPERTY -> deserializeIrSymbol(proto.irProperty.base.symbol) - // Don't consider IR_FIELDS here. - else -> return false - } - if (symbol !is IrPublicSymbolBase<*>) return false - if (!symbol.signature.isPublic) return false - - return when (proto.declaratorCase!!) { - IR_FUNCTION -> FunctionFlags.decode(proto.irFunction.base.base.flags).isFakeOverride - IR_PROPERTY -> PropertyFlags.decode(proto.irProperty.base.flags).isFakeOverride - // Don't consider IR_FIELDS here. - else -> false - } - } - - fun deserializeDeclaration(proto: ProtoDeclaration, parent: IrDeclarationParent): IrDeclaration = - usingParent(parent) { - deserializeDeclaration(proto) - } } + +class FileDeserializationState( + val linker: KotlinIrLinker, + file: IrFile, + fileReader: IrLibraryFile, + fileProto: ProtoFile, + deserializeBodies: Boolean, + allowErrorNodes: Boolean, + deserializeInlineFunctions: Boolean, + moduleDeserializer: IrModuleDeserializer, + handleNoModuleDeserializerFound: (IdSignature, ModuleDescriptor, Collection) -> IrModuleDeserializer, +) { + + val symbolDeserializer = + IrSymbolDeserializer(linker.symbolTable, fileReader, fileProto.actualsList, ::addIdSignature, linker::handleExpectActualMapping) { idSig, symbolKind -> + assert(idSig.isPublic) + + val topLevelSig = idSig.topLevelSignature() + val actualModuleDeserializer = + moduleDeserializer.findModuleDeserializerForTopLevelId(topLevelSig) ?: handleNoModuleDeserializerFound( + idSig, + moduleDeserializer.moduleDescriptor, + moduleDeserializer.moduleDependencies + ) + + actualModuleDeserializer.deserializeIrSymbol(idSig, symbolKind) + } + + private val declarationDeserializer = IrDeclarationDeserializer( + linker.builtIns, + linker.symbolTable, + linker.symbolTable.irFactory, + fileReader, + file, + allowErrorNodes, + deserializeInlineFunctions, + deserializeBodies, + symbolDeserializer, + linker.fakeOverrideBuilder.platformSpecificClassFilter, + linker.fakeOverrideBuilder, + ) + + val fileDeserializer = IrFileDeserializer(file, fileReader, fileProto, symbolDeserializer, declarationDeserializer) + + private val reachableTopLevels = LinkedHashSet() + + init { + // Explicitly exported declarations (e.g. top-level initializers) must be deserialized before all other declarations. + // Thus we schedule their deserialization in deserializer's constructor. + fileProto.explicitlyExportedToCompilerList.forEach { + val symbolData = symbolDeserializer.parseSymbolData(it) + val sig = symbolDeserializer.deserializeIdSignature(symbolData.signatureId) + assert(!sig.isPackageSignature()) + addIdSignature(sig.topLevelSignature()) + } + } + + fun addIdSignature(key: IdSignature) { + reachableTopLevels.add(key) + } + + fun enqueueAllDeclarations() { + reachableTopLevels.addAll(fileDeserializer.reversedSignatureIndex.keys) + } + + fun deserializeAllFileReachableTopLevel() { + while (reachableTopLevels.isNotEmpty()) { + val reachableKey = reachableTopLevels.first() + + val existedSymbol = symbolDeserializer.deserializedSymbols[reachableKey] + if (existedSymbol == null || !existedSymbol.isBound) { + fileDeserializer.deserializeDeclaration(reachableKey) + } + + reachableTopLevels.remove(reachableKey) + } + } +} + +abstract class IrLibraryFile { + abstract fun irDeclaration(index: Int): ByteArray + abstract fun type(index: Int): ByteArray + abstract fun signature(index: Int): ByteArray + abstract fun string(index: Int): ByteArray + abstract fun body(index: Int): ByteArray +} + +class IrLibraryFileFromKlib(private val klib: IrLibrary, private val fileIndex: Int): IrLibraryFile() { + override fun irDeclaration(index: Int): ByteArray = klib.irDeclaration(index, fileIndex) + override fun type(index: Int): ByteArray = klib.type(index, fileIndex) + override fun signature(index: Int): ByteArray = klib.signature(index, fileIndex) + override fun string(index: Int): ByteArray = klib.string(index, fileIndex) + override fun body(index: Int): ByteArray = klib.body(index, fileIndex) +} + +internal fun IrLibraryFile.deserializeString(index: Int): String = String(string(index)) + +internal fun IrLibraryFile.deserializeFqName(fqn: List): String = + fqn.joinToString(".", transform = ::deserializeString) + +internal fun IrLibraryFile.createFile(moduleDescriptor: ModuleDescriptor, fileProto: ProtoFile): IrFile { + val fileName = fileProto.fileEntry.name + val fileEntry = NaiveSourceBasedFileEntryImpl(fileName, fileProto.fileEntry.lineStartOffsetsList.toIntArray()) + val fqName = FqName(deserializeFqName(fileProto.fqNameList)) + val packageFragmentDescriptor = EmptyPackageFragmentDescriptor(moduleDescriptor, fqName) + val symbol = IrFileSymbolImpl(packageFragmentDescriptor) + return IrFileImpl(fileEntry, symbol, fqName) +} \ No newline at end of file diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt index 434cae774d3..779667dbd2c 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt @@ -55,8 +55,6 @@ abstract class IrModuleDeserializer(val moduleDescriptor: ModuleDescriptor) { open fun addModuleReachableTopLevel(idSig: IdSignature) { error("Unsupported Operation (sig: $idSig") } - open fun deserializeReachableDeclarations() { error("Unsupported Operation") } - abstract val moduleFragment: IrModuleFragment abstract val moduleDependencies: Collection @@ -103,10 +101,6 @@ class IrModuleDeserializerWithBuiltIns( override fun referencePropertyByLocalSignature(file: IrFile, idSignature: IdSignature): IrPropertySymbol = delegate.referencePropertyByLocalSignature(file, idSignature) - override fun deserializeReachableDeclarations() { - delegate.deserializeReachableDeclarations() - } - private fun computeFunctionDescriptor(className: String): FunctionClassDescriptor { val isK = className[0] == 'K' val isSuspend = (if (isK) className[1] else className[0]) == 'S' diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrSymbolDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrSymbolDeserializer.kt new file mode 100644 index 00000000000..02589b2b87d --- /dev/null +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrSymbolDeserializer.kt @@ -0,0 +1,156 @@ +/* + * Copyright 2010-2020 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.backend.common.serialization + +import org.jetbrains.kotlin.backend.common.serialization.encodings.* +import org.jetbrains.kotlin.backend.common.serialization.proto.Actual +import org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature.IdsigCase.* +import org.jetbrains.kotlin.ir.symbols.* +import org.jetbrains.kotlin.ir.symbols.impl.IrAnonymousInitializerSymbolImpl +import org.jetbrains.kotlin.ir.symbols.impl.IrLocalDelegatedPropertySymbolImpl +import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl +import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl +import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.protobuf.CodedInputStream +import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite +import org.jetbrains.kotlin.backend.common.serialization.proto.AccessorIdSignature as ProtoAccessorIdSignature +import org.jetbrains.kotlin.backend.common.serialization.proto.FileLocalIdSignature as ProtoFileLocalIdSignature +import org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature as ProtoIdSignature +import org.jetbrains.kotlin.backend.common.serialization.proto.PublicIdSignature as ProtoPublicIdSignature + +class IrSymbolDeserializer( + val symbolTable: ReferenceSymbolTable, + val fileReader: IrLibraryFile, + val actuals: List, + val enqueueLocalTopLevelDeclaration: (IdSignature) -> Unit, + val handleExpectActualMapping: (IdSignature, IrSymbol) -> IrSymbol, + val deserializePublicSymbol: (IdSignature, BinarySymbolData.SymbolKind) -> IrSymbol, +) { + + val deserializedSymbols = mutableMapOf() + + fun deserializeIrSymbol(idSig: IdSignature, symbolKind: BinarySymbolData.SymbolKind): IrSymbol { + return deserializedSymbols.getOrPut(idSig) { + val symbol = referenceDeserializedSymbol(symbolKind, idSig) + + handleExpectActualMapping(idSig, symbol) + } + } + + private fun referenceDeserializedSymbol(symbolKind: BinarySymbolData.SymbolKind, idSig: IdSignature): IrSymbol = symbolTable.run { + when (symbolKind) { + BinarySymbolData.SymbolKind.ANONYMOUS_INIT_SYMBOL -> IrAnonymousInitializerSymbolImpl() + BinarySymbolData.SymbolKind.CLASS_SYMBOL -> referenceClassFromLinker(idSig) + BinarySymbolData.SymbolKind.CONSTRUCTOR_SYMBOL -> referenceConstructorFromLinker(idSig) + BinarySymbolData.SymbolKind.TYPE_PARAMETER_SYMBOL -> referenceTypeParameterFromLinker(idSig) + BinarySymbolData.SymbolKind.ENUM_ENTRY_SYMBOL -> referenceEnumEntryFromLinker(idSig) + BinarySymbolData.SymbolKind.STANDALONE_FIELD_SYMBOL -> referenceFieldFromLinker(idSig) + BinarySymbolData.SymbolKind.FIELD_SYMBOL -> referenceFieldFromLinker(idSig) + BinarySymbolData.SymbolKind.FUNCTION_SYMBOL -> referenceSimpleFunctionFromLinker(idSig) + BinarySymbolData.SymbolKind.TYPEALIAS_SYMBOL -> referenceTypeAliasFromLinker(idSig) + BinarySymbolData.SymbolKind.PROPERTY_SYMBOL -> referencePropertyFromLinker(idSig) + BinarySymbolData.SymbolKind.VARIABLE_SYMBOL -> IrVariableSymbolImpl() + BinarySymbolData.SymbolKind.VALUE_PARAMETER_SYMBOL -> IrValueParameterSymbolImpl() + BinarySymbolData.SymbolKind.RECEIVER_PARAMETER_SYMBOL -> IrValueParameterSymbolImpl() + BinarySymbolData.SymbolKind.LOCAL_DELEGATED_PROPERTY_SYMBOL -> + IrLocalDelegatedPropertySymbolImpl() + else -> error("Unexpected classifier symbol kind: $symbolKind for signature $idSig") + } + } + + fun referenceLocalIrSymbol(symbol: IrSymbol, signature: IdSignature) { + assert(signature.isLocal) + deserializedSymbols.putIfAbsent(signature, symbol) + } + + fun referenceSimpleFunctionByLocalSignature(idSignature: IdSignature) : IrSimpleFunctionSymbol = + deserializeIrSymbolData(idSignature, BinarySymbolData.SymbolKind.FUNCTION_SYMBOL) as IrSimpleFunctionSymbol + + fun referencePropertyByLocalSignature(idSignature: IdSignature): IrPropertySymbol = + deserializeIrSymbolData(idSignature, BinarySymbolData.SymbolKind.PROPERTY_SYMBOL) as IrPropertySymbol + + private fun deserializeIrSymbolData(idSignature: IdSignature, symbolKind: BinarySymbolData.SymbolKind): IrSymbol { + if (idSignature.isLocal) { + if (idSignature.hasTopLevel) { + enqueueLocalTopLevelDeclaration(idSignature.topLevelSignature()) + } + return deserializedSymbols.getOrPut(idSignature) { + referenceDeserializedSymbol(symbolKind, idSignature) + } + } + + return deserializePublicSymbol(idSignature, symbolKind) + } + + fun deserializeIrSymbolToDeclare(code: Long): Pair { + val symbolData = parseSymbolData(code) + val signature = deserializeIdSignature(symbolData.signatureId) + return Pair(deserializeIrSymbolData(signature, symbolData.kind), signature) + } + + fun parseSymbolData(code: Long): BinarySymbolData = BinarySymbolData.decode(code) + + fun deserializeIrSymbol(code: Long): IrSymbol { + val symbolData = parseSymbolData(code) + val signature = deserializeIdSignature(symbolData.signatureId) + return deserializeIrSymbolData(signature, symbolData.kind) + } + + private fun readSignature(index: Int): CodedInputStream = + fileReader.signature(index).codedInputStream + + private fun loadSignatureProto(index: Int): ProtoIdSignature { + return ProtoIdSignature.parseFrom(readSignature(index), ExtensionRegistryLite.newInstance()) + } + + fun deserializeIdSignature(index: Int): IdSignature { + val sigData = loadSignatureProto(index) + return deserializeSignatureData(sigData) + } + + /* -------------------------------------------------------------- */ + + // TODO: Think about isolating id signature related logic behind corresponding interface + + private fun deserializePublicIdSignature(proto: ProtoPublicIdSignature): IdSignature.PublicSignature { + val pkg = fileReader.deserializeFqName(proto.packageFqNameList) + val cls = fileReader.deserializeFqName(proto.declarationFqNameList) + val memberId = if (proto.hasMemberUniqId()) proto.memberUniqId else null + + return IdSignature.PublicSignature(pkg, cls, memberId, proto.flags) + } + + private fun deserializeAccessorIdSignature(proto: ProtoAccessorIdSignature): IdSignature.AccessorSignature { + val propertySignature = deserializeIdSignature(proto.propertySignature) + require(propertySignature is IdSignature.PublicSignature) { "For public accessor corresponding property supposed to be public as well" } + val name = fileReader.deserializeString(proto.name) + val hash = proto.accessorHashId + val mask = proto.flags + + val accessorSignature = + IdSignature.PublicSignature(propertySignature.packageFqName, "${propertySignature.declarationFqName}.$name", hash, mask) + + return IdSignature.AccessorSignature(propertySignature, accessorSignature) + } + + private fun deserializeFileLocalIdSignature(proto: ProtoFileLocalIdSignature): IdSignature.FileLocalSignature { + return IdSignature.FileLocalSignature(deserializeIdSignature(proto.container), proto.localId) + } + + private fun deserializeScopeLocalIdSignature(proto: Int): IdSignature.ScopeLocalDeclaration { + return IdSignature.ScopeLocalDeclaration(proto) + } + + fun deserializeSignatureData(proto: ProtoIdSignature): IdSignature { + return when (proto.idsigCase) { + PUBLIC_SIG -> deserializePublicIdSignature(proto.publicSig) + ACCESSOR_SIG -> deserializeAccessorIdSignature(proto.accessorSig) + PRIVATE_SIG -> deserializeFileLocalIdSignature(proto.privateSig) + SCOPED_LOCAL_SIG -> deserializeScopeLocalIdSignature(proto.scopedLocalSig) + else -> error("Unexpected IdSignature kind: ${proto.idsigCase}") + } + } +} \ No newline at end of file diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIrLinker.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIrLinker.kt index 6796aefbe2d..143594d75cf 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIrLinker.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIrLinker.kt @@ -11,25 +11,15 @@ import org.jetbrains.kotlin.backend.common.serialization.encodings.BinarySymbolD import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor -import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.builders.TranslationPluginContext import org.jetbrains.kotlin.ir.declarations.IrDeclaration import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment -import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl -import org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl -import org.jetbrains.kotlin.ir.descriptors.IrAbstractFunctionFactory -import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns -import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrLoop -import org.jetbrains.kotlin.ir.expressions.impl.IrErrorExpressionImpl +import org.jetbrains.kotlin.ir.descriptors.* +import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.linkage.IrDeserializer import org.jetbrains.kotlin.ir.linkage.KotlinIrLinkerInternalException import org.jetbrains.kotlin.ir.symbols.* -import org.jetbrains.kotlin.ir.symbols.impl.* -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.library.IrLibrary import org.jetbrains.kotlin.library.KotlinLibrary @@ -38,32 +28,23 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.protobuf.CodedInputStream import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite.newInstance import org.jetbrains.kotlin.resolve.descriptorUtil.module -import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult -import org.jetbrains.kotlin.backend.common.serialization.proto.Actual as ProtoActual -import org.jetbrains.kotlin.backend.common.serialization.proto.IdSignature as ProtoIdSignature -import org.jetbrains.kotlin.backend.common.serialization.proto.IrConstructorCall as ProtoConstructorCall -import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclaration as ProtoDeclaration -import org.jetbrains.kotlin.backend.common.serialization.proto.IrExpression as ProtoExpression -import org.jetbrains.kotlin.backend.common.serialization.proto.IrFile as ProtoFile -import org.jetbrains.kotlin.backend.common.serialization.proto.IrStatement as ProtoStatement -import org.jetbrains.kotlin.backend.common.serialization.proto.IrType as ProtoType abstract class KotlinIrLinker( private val currentModule: ModuleDescriptor?, val messageLogger: IrMessageLogger, val builtIns: IrBuiltIns, val symbolTable: SymbolTable, - private val exportedDependencies: List + private val exportedDependencies: List, ) : IrDeserializer, FileLocalAwareLinker { // Kotlin-MPP related data. Consider some refactoring - private val expectUniqIdToActualUniqId = mutableMapOf() - private val topLevelActualUniqItToDeserializer = mutableMapOf() - private val expectSymbols = mutableMapOf() - private val actualSymbols = mutableMapOf() + internal val expectUniqIdToActualUniqId = mutableMapOf() + internal val topLevelActualUniqItToDeserializer = mutableMapOf() + internal val expectSymbols = mutableMapOf() + internal val actualSymbols = mutableMapOf() - private val modulesWithReachableTopLevels = mutableSetOf() + internal val modulesWithReachableTopLevels = mutableSetOf() // TODO: replace with Map protected val deserializersForModules = mutableMapOf() @@ -72,411 +53,12 @@ abstract class KotlinIrLinker( abstract val translationPluginContext: TranslationPluginContext? - private val haveSeen = mutableSetOf() + internal val triedToDeserializeDeclarationForSymbol = mutableSetOf() + internal val deserializedSymbols = mutableSetOf() private lateinit var linkerExtensions: Collection - abstract inner class BasicIrModuleDeserializer(moduleDescriptor: ModuleDescriptor, override val klib: IrLibrary, override val strategy: DeserializationStrategy, private val containsErrorCode: Boolean = false) : - IrModuleDeserializer(moduleDescriptor) { - - private val fileToDeserializerMap = mutableMapOf() - - private inner class ModuleDeserializationState { - private val filesWithPendingTopLevels = mutableSetOf() - - fun enqueueFile(fileDeserializer: IrDeserializerForFile) { - filesWithPendingTopLevels.add(fileDeserializer) - enqueueModule() - } - - fun addIdSignature(key: IdSignature) { - val fileDeserializer = moduleReversedFileIndex[key] ?: error("No file found for key $key") - fileDeserializer.fileLocalDeserializationState.addIdSignature(key) - - enqueueFile(fileDeserializer) - } - - fun processPendingDeclarations() { - while (filesWithPendingTopLevels.isNotEmpty()) { - val pendingDeserializer = filesWithPendingTopLevels.first() - - pendingDeserializer.deserializeFileImplicitDataIfFirstUse() - pendingDeserializer.deserializeAllFileReachableTopLevel() - - filesWithPendingTopLevels.remove(pendingDeserializer) - } - } - - override fun toString(): String = klib.toString() - } - - private val moduleDeserializationState = ModuleDeserializationState() - private val moduleReversedFileIndex = mutableMapOf() - override val moduleDependencies by lazy { - moduleDescriptor.allDependencyModules.filter { it != moduleDescriptor }.map { resolveModuleDeserializer(it, null) } - } - - override fun init(delegate: IrModuleDeserializer) { - val fileCount = klib.fileCount() - - val files = ArrayList(fileCount) - - for (i in 0 until fileCount) { - val fileStream = klib.file(i).codedInputStream - files.add(deserializeIrFile(ProtoFile.parseFrom(fileStream, newInstance()), i, delegate, containsErrorCode)) - } - - moduleFragment.files.addAll(files) - - fileToDeserializerMap.values.forEach { it.deserializeExpectActualMapping() } - } - - override fun referenceSimpleFunctionByLocalSignature(file: IrFile, idSignature: IdSignature): IrSimpleFunctionSymbol = - fileToDeserializerMap[file]?.referenceSimpleFunctionByLocalSignature(idSignature) - ?: error("No deserializer for file $file in module ${moduleDescriptor.name}") - - override fun referencePropertyByLocalSignature(file: IrFile, idSignature: IdSignature): IrPropertySymbol = - fileToDeserializerMap[file]?.referencePropertyByLocalSignature(idSignature) - ?: error("No deserializer for file $file in module ${moduleDescriptor.name}") - - // TODO: fix to topLevel checker - override fun contains(idSig: IdSignature): Boolean = idSig in moduleReversedFileIndex - - override fun deserializeIrSymbol(idSig: IdSignature, symbolKind: BinarySymbolData.SymbolKind): IrSymbol { - assert(idSig.isPublic) - - val topLevelSignature = idSig.topLevelSignature() - val fileDeserializer = moduleReversedFileIndex[topLevelSignature] - ?: error("No file for $topLevelSignature (@ $idSig) in module $moduleDescriptor") - - val fileDeserializationState = fileDeserializer.fileLocalDeserializationState - - fileDeserializationState.addIdSignature(topLevelSignature) - moduleDeserializationState.enqueueFile(fileDeserializer) - - return fileDeserializationState.deserializedSymbols.getOrPut(idSig) { -// val descriptor = resolveSpecialSignature(idSig) - val symbol = referenceDeserializedSymbol(symbolKind, idSig) - - handleExpectActualMapping(idSig, symbol) - } - } - - override val moduleFragment: IrModuleFragment = IrModuleFragmentImpl(moduleDescriptor, builtIns, emptyList()) - - private fun deserializeIrFile(fileProto: ProtoFile, fileIndex: Int, moduleDeserializer: IrModuleDeserializer, allowErrorNodes: Boolean): IrFile { - - val fileName = fileProto.fileEntry.name - - val fileEntry = NaiveSourceBasedFileEntryImpl(fileName, fileProto.fileEntry.lineStartOffsetsList.toIntArray()) - - val fileDeserializer = - IrDeserializerForFile( - fileProto.annotationList, - fileProto.actualsList, - fileIndex, - !strategy.needBodies, - strategy.inlineBodies, - moduleDeserializer, allowErrorNodes - ).apply { - - // Explicitly exported declarations (e.g. top-level initializers) must be deserialized before all other declarations. - // Thus we schedule their deserialization in deserializer's constructor. - fileProto.explicitlyExportedToCompilerList.forEach { - val symbolData = parseSymbolData(it) - val sig = deserializeIdSignature(symbolData.signatureId) - assert(!sig.isPackageSignature()) - fileLocalDeserializationState.addIdSignature(sig.topLevelSignature()) - } - } - - val fqName = FqName(fileDeserializer.deserializeFqName(fileProto.fqNameList)) - - val packageFragmentDescriptor = EmptyPackageFragmentDescriptor(moduleDescriptor, fqName) - - val symbol = IrFileSymbolImpl(packageFragmentDescriptor) - val file = IrFileImpl(fileEntry, symbol, fqName) - - fileDeserializer.file = file - fileToDeserializerMap[file] = fileDeserializer - - val fileSignatureIndex = fileProto.declarationIdList.map { fileDeserializer.deserializeIdSignature(it) to it } - - fileSignatureIndex.forEach { - moduleReversedFileIndex.getOrPut(it.first) { fileDeserializer } - } - - fileDeserializer.reversedSignatureIndex = fileSignatureIndex.toMap() - - if (strategy.theWholeWorld) { - for (id in fileSignatureIndex) { - moduleDeserializationState.addIdSignature(id.first) - } - moduleDeserializationState.enqueueFile(fileDeserializer) - } else if (strategy.explicitlyExported) { - moduleDeserializationState.enqueueFile(fileDeserializer) - } - - return file - } - - override fun deserializeReachableDeclarations() { - moduleDeserializationState.processPendingDeclarations() - } - - private fun enqueueModule() { - modulesWithReachableTopLevels.add(this) - } - - override fun addModuleReachableTopLevel(idSig: IdSignature) { - moduleDeserializationState.addIdSignature(idSig) - } - } - - inner class IrDeserializerForFile( - private var annotations: List?, - private val actuals: List, - private val fileIndex: Int, - onlyHeaders: Boolean, - inlineBodies: Boolean, - private val moduleDeserializer: IrModuleDeserializer, - allowErrorNodes: Boolean - ) : - IrFileDeserializer( - messageLogger, - builtIns, - symbolTable, - !onlyHeaders, - fakeOverrideBuilder, - allowErrorNodes - ) - { - - private var fileLoops = mutableMapOf() - - lateinit var file: IrFile - - private val irTypeCache = mutableMapOf() - - override val deserializeInlineFunctions: Boolean = inlineBodies - - override val platformFakeOverrideClassFilter = fakeOverrideBuilder.platformSpecificClassFilter - - var reversedSignatureIndex = emptyMap() - - inner class FileDeserializationState { - private val reachableTopLevels = LinkedHashSet() - val deserializedSymbols = mutableMapOf() - - fun addIdSignature(key: IdSignature) { - reachableTopLevels.add(key) - } - - fun processPendingDeclarations() { - while (reachableTopLevels.isNotEmpty()) { - val reachableKey = reachableTopLevels.first() - - val existedSymbol = deserializedSymbols[reachableKey] - if (existedSymbol == null || !existedSymbol.isBound) { - val declaration = deserializeDeclaration(reachableKey) - file.declarations.add(declaration) - } - - reachableTopLevels.remove(reachableKey) - } - } - } - - val fileLocalDeserializationState = FileDeserializationState() - - fun deserializeDeclaration(idSig: IdSignature): IrDeclaration { - return deserializeDeclaration(loadTopLevelDeclarationProto(idSig), file) - } - - fun deserializeExpectActualMapping() { - actuals.forEach { - val expectSymbol = parseSymbolData(it.expectSymbol) - val actualSymbol = parseSymbolData(it.actualSymbol) - - val expect = deserializeIdSignature(expectSymbol.signatureId) - val actual = deserializeIdSignature(actualSymbol.signatureId) - - assert(expectUniqIdToActualUniqId[expect] == null) { - "Expect signature $expect is already actualized by ${expectUniqIdToActualUniqId[expect]}, while we try to record $actual" - } - expectUniqIdToActualUniqId[expect] = actual - // Non-null only for topLevel declarations. - getModuleForTopLevelId(actual)?.let { md -> topLevelActualUniqItToDeserializer[actual] = md } - } - } - - private fun resolveSignatureIndex(idSig: IdSignature): Int { - return reversedSignatureIndex[idSig] ?: error("Not found Idx for $idSig") - } - - private fun readDeclaration(index: Int): CodedInputStream = - moduleDeserializer.klib.irDeclaration(index, fileIndex).codedInputStream - - private fun loadTopLevelDeclarationProto(idSig: IdSignature): ProtoDeclaration { - val idSigIndex = resolveSignatureIndex(idSig) - return ProtoDeclaration.parseFrom(readDeclaration(idSigIndex), newInstance()) - } - - private fun readType(index: Int): CodedInputStream = - moduleDeserializer.klib.type(index, fileIndex).codedInputStream - - private fun loadTypeProto(index: Int): ProtoType { - return ProtoType.parseFrom(readType(index), newInstance()) - } - - private fun readSignature(index: Int): CodedInputStream = - moduleDeserializer.klib.signature(index, fileIndex).codedInputStream - - private fun loadSignatureProto(index: Int): ProtoIdSignature { - return ProtoIdSignature.parseFrom(readSignature(index), newInstance()) - } - - private fun readBody(index: Int): CodedInputStream = - moduleDeserializer.klib.body(index, fileIndex).codedInputStream - - private fun loadStatementBodyProto(index: Int): ProtoStatement { - return ProtoStatement.parseFrom(readBody(index), newInstance()) - } - - private fun loadExpressionBodyProto(index: Int): ProtoExpression { - return ProtoExpression.parseFrom(readBody(index), newInstance()) - } - - private fun loadStringProto(index: Int): String { - return String(moduleDeserializer.klib.string(index, fileIndex)) - } - - private fun getModuleForTopLevelId(idSignature: IdSignature): IrModuleDeserializer? { - if (idSignature in moduleDeserializer) return moduleDeserializer - return moduleDeserializer.moduleDependencies.firstOrNull { idSignature in it } - } - - private fun findModuleDeserializer(idSig: IdSignature): IrModuleDeserializer { - assert(idSig.isPublic) - - val topLevelSig = idSig.topLevelSignature() - if (topLevelSig in moduleDeserializer) return moduleDeserializer - return moduleDeserializer.moduleDependencies.firstOrNull { topLevelSig in it } ?: handleNoModuleDeserializerFound( - idSig, - moduleDeserializer.moduleDescriptor, - moduleDeserializer.moduleDependencies - ) - } - - private fun referenceIrSymbolData(symbol: IrSymbol, signature: IdSignature) { - assert(signature.isLocal) - fileLocalDeserializationState.deserializedSymbols.putIfAbsent(signature, symbol) - } - - private fun deserializeIrLocalSymbolData(idSig: IdSignature, symbolKind: BinarySymbolData.SymbolKind): IrSymbol { - assert(idSig.isLocal) - - if (idSig.hasTopLevel) { - fileLocalDeserializationState.addIdSignature(idSig.topLevelSignature()) - } - - return fileLocalDeserializationState.deserializedSymbols.getOrPut(idSig) { - referenceDeserializedSymbol(symbolKind, idSig) - } - } - - fun referenceSimpleFunctionByLocalSignature(idSignature: IdSignature) : IrSimpleFunctionSymbol = - deserializeIrSymbolData(idSignature, BinarySymbolData.SymbolKind.FUNCTION_SYMBOL) as IrSimpleFunctionSymbol - - fun referencePropertyByLocalSignature(idSignature: IdSignature): IrPropertySymbol = - deserializeIrSymbolData(idSignature, BinarySymbolData.SymbolKind.PROPERTY_SYMBOL) as IrPropertySymbol - - private fun deserializeIrSymbolData(idSignature: IdSignature, symbolKind: BinarySymbolData.SymbolKind): IrSymbol { - if (idSignature.isLocal) return deserializeIrLocalSymbolData(idSignature, symbolKind) - - return findModuleDeserializer(idSignature).deserializeIrSymbol(idSignature, symbolKind).also { - haveSeen.add(it) - } - } - - override fun deserializeIrSymbolToDeclare(code: Long): Pair { - val symbolData = parseSymbolData(code) - val signature = deserializeIdSignature(symbolData.signatureId) - return Pair(deserializeIrSymbolData(signature, symbolData.kind), signature) - } - - fun parseSymbolData(code: Long): BinarySymbolData = BinarySymbolData.decode(code) - - override fun deserializeIrSymbol(code: Long): IrSymbol { - val symbolData = parseSymbolData(code) - val signature = deserializeIdSignature(symbolData.signatureId) - return deserializeIrSymbolData(signature, symbolData.kind) - } - - override fun deserializeIrType(index: Int): IrType { - return irTypeCache.getOrPut(index) { - val typeData = loadTypeProto(index) - deserializeIrTypeData(typeData) - } - } - - override fun deserializeIdSignature(index: Int): IdSignature { - val sigData = loadSignatureProto(index) - return deserializeSignatureData(sigData) - } - - override fun deserializeString(index: Int): String = - loadStringProto(index) - - override fun deserializeLoopHeader(loopIndex: Int, loopBuilder: () -> IrLoop) = - fileLoops.getOrPut(loopIndex, loopBuilder) - - override fun deserializeExpressionBody(index: Int): IrExpression { - return if (deserializeBodies) { - val bodyData = loadExpressionBodyProto(index) - deserializeExpression(bodyData) - } else { - val errorType = IrErrorTypeImpl(null, emptyList(), Variance.INVARIANT) - IrErrorExpressionImpl(-1, -1, errorType, "Expression body is not deserialized yet") - } - } - - override fun deserializeStatementBody(index: Int): IrElement { - return if (deserializeBodies) { - val bodyData = loadStatementBodyProto(index) - deserializeStatement(bodyData) - } else { - val errorType = IrErrorTypeImpl(null, emptyList(), Variance.INVARIANT) - irFactory.createBlockBody( - -1, -1, listOf(IrErrorExpressionImpl(-1, -1, errorType, "Statement body is not deserialized yet")) - ) - } - } - - override fun referenceIrSymbol(symbol: IrSymbol, signature: IdSignature) { - referenceIrSymbolData(symbol, signature) - } - - fun deserializeFileImplicitDataIfFirstUse() { - annotations?.let { - file.annotations += deserializeAnnotations(it) - annotations = null - } - } - - fun deserializeAllFileReachableTopLevel() { - fileLocalDeserializationState.processPendingDeclarations() - } - } - - private val ByteArray.codedInputStream: CodedInputStream - get() { - val codedInputStream = CodedInputStream.newInstance(this) - codedInputStream.setRecursionLimit(65535) // The default 64 is blatantly not enough for IR. - return codedInputStream - } - - protected open fun handleNoModuleDeserializerFound(idSignature: IdSignature, currentModule: ModuleDescriptor, dependencies: Collection): IrModuleDeserializer { + public open fun handleNoModuleDeserializerFound(idSignature: IdSignature, currentModule: ModuleDescriptor, dependencies: Collection): IrModuleDeserializer { val message = buildString { append("Module $currentModule has reference $idSignature, unfortunately neither itself nor its dependencies ") dependencies.joinTo(this, "\n\t", "[\n\t", "\n]") @@ -489,7 +71,7 @@ abstract class KotlinIrLinker( throw KotlinIrLinkerInternalException } - protected open fun resolveModuleDeserializer(module: ModuleDescriptor, signature: IdSignature?): IrModuleDeserializer { + public open fun resolveModuleDeserializer(module: ModuleDescriptor, signature: IdSignature?): IrModuleDeserializer { return deserializersForModules[module] ?: run { val message = buildString { append("Could not load module ") @@ -515,58 +97,22 @@ abstract class KotlinIrLinker( protected abstract fun isBuiltInModule(moduleDescriptor: ModuleDescriptor): Boolean - // TODO: the following code worth some refactoring in the nearest future - - private fun handleExpectActualMapping(idSig: IdSignature, rawSymbol: IrSymbol): IrSymbol { - val referencingSymbol = if (idSig in expectUniqIdToActualUniqId.keys) { - assert(idSig.run { IdSignature.Flags.IS_EXPECT.test() }) - wrapInDelegatedSymbol(rawSymbol).also { expectSymbols[idSig] = it } - } else rawSymbol - - if (idSig in expectUniqIdToActualUniqId.values) { - actualSymbols[idSig] = rawSymbol - } - - return referencingSymbol - } - - private fun referenceDeserializedSymbol(symbolKind: BinarySymbolData.SymbolKind, idSig: IdSignature): IrSymbol = symbolTable.run { - when (symbolKind) { - BinarySymbolData.SymbolKind.ANONYMOUS_INIT_SYMBOL -> IrAnonymousInitializerSymbolImpl() - BinarySymbolData.SymbolKind.CLASS_SYMBOL -> referenceClassFromLinker(idSig) - BinarySymbolData.SymbolKind.CONSTRUCTOR_SYMBOL -> referenceConstructorFromLinker(idSig) - BinarySymbolData.SymbolKind.TYPE_PARAMETER_SYMBOL -> referenceTypeParameterFromLinker(idSig) - BinarySymbolData.SymbolKind.ENUM_ENTRY_SYMBOL -> referenceEnumEntryFromLinker(idSig) - BinarySymbolData.SymbolKind.STANDALONE_FIELD_SYMBOL -> referenceFieldFromLinker(idSig) - BinarySymbolData.SymbolKind.FIELD_SYMBOL -> referenceFieldFromLinker(idSig) - BinarySymbolData.SymbolKind.FUNCTION_SYMBOL -> referenceSimpleFunctionFromLinker(idSig) - BinarySymbolData.SymbolKind.TYPEALIAS_SYMBOL -> referenceTypeAliasFromLinker(idSig) - BinarySymbolData.SymbolKind.PROPERTY_SYMBOL -> referencePropertyFromLinker(idSig) - BinarySymbolData.SymbolKind.VARIABLE_SYMBOL -> IrVariableSymbolImpl() - BinarySymbolData.SymbolKind.VALUE_PARAMETER_SYMBOL -> IrValueParameterSymbolImpl() - BinarySymbolData.SymbolKind.RECEIVER_PARAMETER_SYMBOL -> IrValueParameterSymbolImpl() - BinarySymbolData.SymbolKind.LOCAL_DELEGATED_PROPERTY_SYMBOL -> - IrLocalDelegatedPropertySymbolImpl() - else -> error("Unexpected classifier symbol kind: $symbolKind for signature $idSig") - } - } - private fun deserializeAllReachableTopLevels() { while (modulesWithReachableTopLevels.isNotEmpty()) { - val moduleDeserializer = modulesWithReachableTopLevels.first() - modulesWithReachableTopLevels.remove(moduleDeserializer) + val moduleDeserializationState = modulesWithReachableTopLevels.first() + modulesWithReachableTopLevels.remove(moduleDeserializationState) - moduleDeserializer.deserializeReachableDeclarations() + moduleDeserializationState.deserializeReachableDeclarations() } } private fun findDeserializedDeclarationForSymbol(symbol: IrSymbol): DeclarationDescriptor? { assert(symbol.isPublicApi || symbol.descriptor.module === currentModule || platformSpecificSymbol(symbol)) - if (haveSeen.contains(symbol)) { + if (symbol in triedToDeserializeDeclarationForSymbol || symbol in deserializedSymbols) { return null } - haveSeen.add(symbol) + triedToDeserializeDeclarationForSymbol.add(symbol) val descriptor = symbol.descriptor @@ -586,6 +132,7 @@ abstract class KotlinIrLinker( if (!symbol.hasDescriptor) return null val descriptor = symbol.descriptor + if (descriptor is CallableMemberDescriptor) { if (descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { // skip fake overrides @@ -661,12 +208,43 @@ abstract class KotlinIrLinker( override fun postProcess() { finalizeExpectActualLinker() fakeOverrideBuilder.provideFakeOverrides() - haveSeen.clear() + triedToDeserializeDeclarationForSymbol.clear() + deserializedSymbols.clear() // TODO: fix IrPluginContext to make it not produce additional external reference // symbolTable.noUnboundLeft("unbound after fake overrides:") } + fun handleExpectActualMapping(idSig: IdSignature, rawSymbol: IrSymbol): IrSymbol { + + // Actual signature + if (idSig in expectUniqIdToActualUniqId.values) { + actualSymbols[idSig] = rawSymbol + } + + // Expect signature + expectUniqIdToActualUniqId[idSig]?.let { actualSig -> + assert(idSig.run { IdSignature.Flags.IS_EXPECT.test() }) + + val referencingSymbol = wrapInDelegatedSymbol(rawSymbol) + + expectSymbols[idSig] = referencingSymbol + + // Trigger actual symbol deserialization + topLevelActualUniqItToDeserializer[actualSig]?.let { moduleDeserializer -> // Not null if top-level + val actualSymbol = actualSymbols[actualSig] + // Check if + if (actualSymbol == null || !actualSymbol.isBound) { + moduleDeserializer.addModuleReachableTopLevel(actualSig) + } + } + + return referencingSymbol + } + + return rawSymbol + } + private fun topLevelKindToSymbolKind(kind: IrDeserializer.TopLevelSymbolKind): BinarySymbolData.SymbolKind { return when (kind) { IrDeserializer.TopLevelSymbolKind.CLASS_SYMBOL -> BinarySymbolData.SymbolKind.CLASS_SYMBOL @@ -690,16 +268,7 @@ abstract class KotlinIrLinker( // because the expect can not see the actual higher in the module dependency dag. // So we force deserialization of actuals for all deserialized expect symbols here. private fun finalizeExpectActualLinker() { - expectUniqIdToActualUniqId.filter { topLevelActualUniqItToDeserializer[it.value] != null }.forEach { - val expectSymbol = expectSymbols[it.key] - val actualSymbol = actualSymbols[it.value] - if (expectSymbol != null && (actualSymbol == null || !actualSymbol.isBound)) { - topLevelActualUniqItToDeserializer[it.value]!!.addModuleReachableTopLevel(it.value) - deserializeAllReachableTopLevels() - } - } - - // Now after all actuals have been deserialized, retarget delegating symbols from expects to actuals. + // All actuals have been deserialized, retarget delegating symbols from expects to actuals. expectUniqIdToActualUniqId.forEach { val expectSymbol = expectSymbols[it.key] val actualSymbol = actualSymbols[it.value] @@ -773,4 +342,4 @@ enum class DeserializationStrategy( EXPLICITLY_EXPORTED(true, true, false, true), ONLY_DECLARATION_HEADERS(false, false, false, false), WITH_INLINE_BODIES(false, false, false, true) -} +} \ No newline at end of file diff --git a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/lower/serialization/ir/JsIrLinker.kt b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/lower/serialization/ir/JsIrLinker.kt index 33423e36a90..ef43bab8011 100644 --- a/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/lower/serialization/ir/JsIrLinker.kt +++ b/compiler/ir/serialization.js/src/org/jetbrains/kotlin/ir/backend/js/lower/serialization/ir/JsIrLinker.kt @@ -41,7 +41,7 @@ class JsIrLinker( JsModuleDeserializer(moduleDescriptor, klib ?: error("Expecting kotlin library"), strategy, klib.libContainsErrorCode) private inner class JsModuleDeserializer(moduleDescriptor: ModuleDescriptor, klib: IrLibrary, strategy: DeserializationStrategy, allowErrorCode: Boolean) : - KotlinIrLinker.BasicIrModuleDeserializer(moduleDescriptor, klib, strategy, allowErrorCode) + BasicIrModuleDeserializer(this, moduleDescriptor, klib, strategy, allowErrorCode) override fun createCurrentModuleDeserializer(moduleFragment: IrModuleFragment, dependencies: Collection): IrModuleDeserializer { val currentModuleDeserializer = super.createCurrentModuleDeserializer(moduleFragment, dependencies) diff --git a/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/ir/backend/jvm/serialization/JvmIrLinker.kt b/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/ir/backend/jvm/serialization/JvmIrLinker.kt index 77746c688d6..a91b54145e3 100644 --- a/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/ir/backend/jvm/serialization/JvmIrLinker.kt +++ b/compiler/ir/serialization.jvm/src/org/jetbrains/kotlin/ir/backend/jvm/serialization/JvmIrLinker.kt @@ -61,7 +61,7 @@ class JvmIrLinker( } private inner class JvmModuleDeserializer(moduleDescriptor: ModuleDescriptor, klib: IrLibrary, strategy: DeserializationStrategy) : - KotlinIrLinker.BasicIrModuleDeserializer(moduleDescriptor, klib, strategy) + BasicIrModuleDeserializer(this, moduleDescriptor, klib, strategy) private fun DeclarationDescriptor.isJavaDescriptor(): Boolean { if (this is PackageFragmentDescriptor) { From 79e3ce022f0af71dea86875a740a5d3a929fdf17 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Wed, 17 Feb 2021 18:13:18 +0300 Subject: [PATCH 261/368] [Commonizer] Fix: Keep fwd declarations under real names in CirForwardDeclarations cache --- .../kotlin/descriptors/commonizer/TargetProvider.kt | 1 - .../commonizer/konan/NativeDistributionModulesProvider.kt | 6 +----- .../descriptors/commonizer/mergedtree/CirTreeMerger.kt | 5 +++-- .../commonizer/mergedtree/classifierContainers.kt | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt index 1a4343fd6d3..7ae25ddf463 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/TargetProvider.kt @@ -23,7 +23,6 @@ interface ModulesProvider { ) class CInteropModuleAttributes( - val mainPackageFqName: String, val exportForwardDeclarations: Collection ) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionModulesProvider.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionModulesProvider.kt index d977bb4c702..e7dfdc1833e 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionModulesProvider.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/NativeDistributionModulesProvider.kt @@ -45,11 +45,7 @@ internal abstract class NativeDistributionModulesProvider(libraries: Collection< val dependencies = manifestData.dependencies.toSet() val cInteropAttributes = if (manifestData.isInterop) { - val packageFqName = manifestData.packageFqName - ?: manifestData.shortName?.let { "platform.$it" } - ?: manifestData.uniqueName.substringAfter("platform.").let { "platform.$it" } - - CInteropModuleAttributes(packageFqName, manifestData.exportForwardDeclarations) + CInteropModuleAttributes(manifestData.exportForwardDeclarations) } else null libraryMap.put(name, library)?.let { error("Duplicated libraries: $name") } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt index 27cbc668f33..3d93cb64564 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirTreeMerger.kt @@ -253,12 +253,13 @@ class CirTreeMerger( private fun processCInteropModuleAttributes(moduleInfo: ModuleInfo) { val cInteropAttributes = moduleInfo.cInteropAttributes ?: return val exportForwardDeclarations = cInteropAttributes.exportForwardDeclarations.takeIf { it.isNotEmpty() } ?: return - val mainPackageFqName = CirPackageName.create(cInteropAttributes.mainPackageFqName) exportForwardDeclarations.forEach { classFqName -> // Class has synthetic package FQ name (cnames/objcnames). Need to transfer it to the main package. + val packageName = CirPackageName.create(classFqName.substringBeforeLast('.', missingDelimiterValue = "")) val className = CirName.create(classFqName.substringAfterLast('.')) - classifiers.forwardDeclarations.addExportedForwardDeclaration(CirEntityId.create(mainPackageFqName, className)) + + classifiers.forwardDeclarations.addExportedForwardDeclaration(CirEntityId.create(packageName, className)) } } } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt index 0f386bee1ea..0f2624405ea 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt @@ -72,7 +72,7 @@ interface CirForwardDeclarations { override fun isExportedForwardDeclaration(classId: CirEntityId) = classId in exportedForwardDeclarations override fun addExportedForwardDeclaration(classId: CirEntityId) { - check(!classId.packageName.isUnderKotlinNativeSyntheticPackages) + check(classId.packageName.isUnderKotlinNativeSyntheticPackages) exportedForwardDeclarations += classId } } From 43ad0ed9071131d318858e931dbfec6319098ef7 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Tue, 16 Feb 2021 14:58:44 +0300 Subject: [PATCH 262/368] [Commonizer] Optimized implementation of CirProvidedClassifiers Read classifiers directly from metadata, don't use descriptors. --- .../kotlin/descriptors/commonizer/facade.kt | 7 +- .../mergedtree/CirCompositeClassifiers.kt | 14 ++++ .../CirFictitiousFunctionClassifiers.kt | 32 +++++++++ .../mergedtree/CirLoadedClassifiers.kt | 67 +++++++++++++++++++ .../mergedtree/classifierContainers.kt | 48 ++----------- .../commonizer/mergedtree/collectors.kt | 8 +-- 6 files changed, 122 insertions(+), 54 deletions(-) create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirCompositeClassifiers.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirFictitiousFunctionClassifiers.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirLoadedClassifiers.kt diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt index e85620ef3c0..41f164369ce 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt @@ -43,9 +43,10 @@ private fun mergeAndCommonize(storageManager: StorageManager, parameters: Common forwardDeclarations = CirForwardDeclarations.default(), dependencies = mapOf( // for now, supply only common dependency libraries (ex: Kotlin stdlib) - parameters.sharedTarget to CirProvidedClassifiers.fromModules(storageManager) { - parameters.dependencyModulesProvider?.loadModules(emptyList())?.values.orEmpty() - } + parameters.sharedTarget to CirCompositeClassifiers( + CirFictitiousFunctionClassifiers, + CirLoadedClassifiers.from(parameters.dependencyModulesProvider) + ) ) ) val mergeResult = CirTreeMerger(storageManager, classifiers, parameters).merge() diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirCompositeClassifiers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirCompositeClassifiers.kt new file mode 100644 index 00000000000..b92faa5a278 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirCompositeClassifiers.kt @@ -0,0 +1,14 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer.mergedtree + +import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId + +class CirCompositeClassifiers(private val delegates: List) : CirProvidedClassifiers { + constructor(vararg delegates: CirProvidedClassifiers) : this(delegates.toList()) + + override fun hasClassifier(classifierId: CirEntityId): Boolean = delegates.any { it.hasClassifier(classifierId) } +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirFictitiousFunctionClassifiers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirFictitiousFunctionClassifiers.kt new file mode 100644 index 00000000000..eb4a8699c86 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirFictitiousFunctionClassifiers.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer.mergedtree + +import gnu.trove.THashSet +import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId +import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName +import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPackageName + +object CirFictitiousFunctionClassifiers : CirProvidedClassifiers { + private const val MIN_ARITY = 0 + private const val MAX_ARITY = 255 + + private val FUNCTION_PREFIXES = arrayOf("Function", "SuspendFunction") + private val PACKAGE_NAME = CirPackageName.create("kotlin") + + private val classifiers: Set = THashSet().apply { + (MIN_ARITY..MAX_ARITY).forEach { arity -> + FUNCTION_PREFIXES.forEach { prefix -> + this += buildFictitiousFunctionClass(prefix, arity) + } + } + } + + override fun hasClassifier(classifierId: CirEntityId): Boolean = classifierId in classifiers + + private fun buildFictitiousFunctionClass(prefix: String, arity: Int): CirEntityId = + CirEntityId.create(PACKAGE_NAME, CirName.create("$prefix$arity")) +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirLoadedClassifiers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirLoadedClassifiers.kt new file mode 100644 index 00000000000..60a0275655c --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirLoadedClassifiers.kt @@ -0,0 +1,67 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer.mergedtree + +import gnu.trove.THashSet +import org.jetbrains.kotlin.descriptors.commonizer.ModulesProvider +import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId +import org.jetbrains.kotlin.descriptors.commonizer.cir.CirName +import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPackageName +import org.jetbrains.kotlin.library.metadata.parsePackageFragment +import org.jetbrains.kotlin.metadata.ProtoBuf +import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl + +class CirLoadedClassifiers(modulesProvider: ModulesProvider) : CirProvidedClassifiers { + private val classifiers: Set = loadClassifiers(modulesProvider) + + override fun hasClassifier(classifierId: CirEntityId): Boolean = classifierId in classifiers + + companion object { + fun from(modulesProvider: ModulesProvider?): CirProvidedClassifiers = + if (modulesProvider != null) CirLoadedClassifiers(modulesProvider) else CirProvidedClassifiers.EMPTY + } +} + +private fun loadClassifiers(modulesProvider: ModulesProvider): Set { + val result = THashSet() + + modulesProvider.loadModuleInfos().forEach { moduleInfo -> + val metadata = modulesProvider.loadModuleMetadata(moduleInfo.name) + + for (i in metadata.fragmentNames.indices) { + val packageFqName = metadata.fragmentNames[i] + val packageFragments = metadata.fragments[i] + + for (j in packageFragments.indices) { + val packageFragment: ProtoBuf.PackageFragment = parsePackageFragment(packageFragments[j]) + + val classes: List = packageFragment.class_List + val typeAliases: List = packageFragment.`package`?.typeAliasList.orEmpty() + + if (classes.isEmpty() && typeAliases.isEmpty()) + break // this and next package fragments do not contain classifiers and can be skipped + + val packageName = CirPackageName.create(packageFqName) + val nameResolver = NameResolverImpl(packageFragment.strings, packageFragment.qualifiedNames) + + for (clazz in classes) { + if (!nameResolver.isLocalClassName(clazz.fqName)) { + val classId = CirEntityId.create(nameResolver.getQualifiedClassName(clazz.fqName)) + check(classId.packageName == packageName) + result += classId + } + } + + for (typeAlias in typeAliases) { + val typeAliasId = CirEntityId.create(packageName, CirName.create(nameResolver.getString(typeAlias.name))) + result += typeAliasId + } + } + } + } + + return result +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt index 0f2624405ea..eb5835ac479 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt @@ -7,16 +7,10 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree import gnu.trove.THashMap import gnu.trove.THashSet -import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.descriptors.commonizer.SharedCommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.SharedCommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId -import org.jetbrains.kotlin.descriptors.commonizer.cir.CirPackageName import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderKotlinNativeSyntheticPackages -import org.jetbrains.kotlin.descriptors.commonizer.utils.resolveClassOrTypeAlias -import org.jetbrains.kotlin.resolve.scopes.MemberScope -import org.jetbrains.kotlin.storage.StorageManager -import org.jetbrains.kotlin.storage.getValue class CirKnownClassifiers( val commonized: CirCommonizedClassifiers, @@ -28,6 +22,7 @@ class CirKnownClassifiers( dependencies.filterKeys { it is SharedCommonizerTarget }.values.singleOrNull() ?: CirProvidedClassifiers.EMPTY } +/** A set of all CIR nodes built for commonized classes and type aliases. */ interface CirCommonizedClassifiers { /* Accessors */ fun classNode(classId: CirEntityId): CirClassNode? @@ -58,6 +53,7 @@ interface CirCommonizedClassifiers { } } +/** A set of all exported forward declaration classes/objects/structs. */ interface CirForwardDeclarations { /* Accessors */ fun isExportedForwardDeclaration(classId: CirEntityId): Boolean @@ -79,6 +75,7 @@ interface CirForwardDeclarations { } } +/** A set of classes and type aliases provided by libraries (either the libraries to commonize, or their dependency libraries)/ */ interface CirProvidedClassifiers { fun hasClassifier(classifierId: CirEntityId): Boolean @@ -89,42 +86,5 @@ interface CirProvidedClassifiers { internal val EMPTY = object : CirProvidedClassifiers { override fun hasClassifier(classifierId: CirEntityId) = false } - - // N.B. This is suboptimal implementation. It will be replaced by another implementation that will - // retrieve classifier information directly from the metadata. - fun fromModules(storageManager: StorageManager, modules: () -> Collection) = object : CirProvidedClassifiers { - private val nonEmptyMemberScopes: Map by storageManager.createLazyValue { - THashMap().apply { - for (module in modules()) { - module.collectNonEmptyPackageMemberScopes(probeRootPackageForEmptiness = true) { packageName, memberScope -> - this[packageName] = memberScope - } - } - } - } - - private val presentClassifiers = THashSet() - private val missingClassifiers = THashSet() - - override fun hasClassifier(classifierId: CirEntityId): Boolean { - if (classifierId.relativeNameSegments.isEmpty()) - return false - - val memberScope = nonEmptyMemberScopes[classifierId.packageName] ?: return false - - return when (classifierId) { - in presentClassifiers -> true - in missingClassifiers -> false - else -> { - val found = memberScope.resolveClassOrTypeAlias(classifierId.relativeNameSegments) != null - when (found) { - true -> presentClassifiers += classifierId - false -> missingClassifiers += classifierId - } - found - } - } - } - } } } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/collectors.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/collectors.kt index ba08a232890..ca4d487a75b 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/collectors.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/collectors.kt @@ -64,23 +64,17 @@ internal inline fun FunctionCollector( } // collects member scopes for every non-empty package provided by this module -internal fun ModuleDescriptor.collectNonEmptyPackageMemberScopes( - probeRootPackageForEmptiness: Boolean = false, // false is the default as probing might be expensive and is not always necessary - collector: (CirPackageName, MemberScope) -> Unit -) { +internal fun ModuleDescriptor.collectNonEmptyPackageMemberScopes(collector: (CirPackageName, MemberScope) -> Unit) { // we don's need to process fragments from other modules which are the dependencies of this module, so // let's use the appropriate package fragment provider val packageFragmentProvider = this.packageFragmentProvider fun recurse(packageFqName: FqName) { - val probeForEmptiness = probeRootPackageForEmptiness && packageFqName.isRoot - val ownPackageMemberScopes = packageFragmentProvider.packageFragments(packageFqName) .asSequence() .filter { it !is ExportedForwardDeclarationsPackageFragmentDescriptor && it !is ClassifierAliasingPackageFragmentDescriptor } .map { it.getMemberScope() } .filter { it != MemberScope.Empty } - .filter { !probeForEmptiness || it.getContributedDescriptors().isNotEmpty() } .toList() if (ownPackageMemberScopes.isNotEmpty()) { From 2581b67cdaa26a2ede32166aa1ac142193382272 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Wed, 17 Feb 2021 19:21:15 +0300 Subject: [PATCH 263/368] [Commonizer] Rename: CirCommonizedClassifiers -> CirCommonizedClassifierNodes --- .../descriptors/commonizer/core/CommonizationVisitor.kt | 2 +- .../kotlin/descriptors/commonizer/core/TypeCommonizer.kt | 4 ++-- .../org/jetbrains/kotlin/descriptors/commonizer/facade.kt | 2 +- .../commonizer/mergedtree/classifierContainers.kt | 6 +++--- .../descriptors/commonizer/mergedtree/nodeBuilders.kt | 4 ++-- .../descriptors/commonizer/core/TypeCommonizerTest.kt | 6 +++--- .../jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt index 14bd17fbd62..c3c7db23ea3 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/CommonizationVisitor.kt @@ -129,7 +129,7 @@ internal class CommonizationVisitor( if (classifiers.commonDependencies.hasClassifier(expandedClassId)) return null // this case is not supported yet - val expandedClassNode = classifiers.commonized.classNode(expandedClassId) ?: return null + val expandedClassNode = classifiers.commonizedNodes.classNode(expandedClassId) ?: return null val expandedClass = expandedClassNode.targetDeclarations[index] ?: error("Can't find expanded class with class ID $expandedClassId and index $index for type alias $classifierName") diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizer.kt index 49ad68f72e3..efea745b149 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizer.kt @@ -204,7 +204,7 @@ private fun commonizeClass(classId: CirEntityId, classifiers: CirKnownClassifier return true } - return when (val node = classifiers.commonized.classNode(classId)) { + return when (val node = classifiers.commonizedNodes.classNode(classId)) { null -> { // No node means that the class was not subject for commonization. // - Either it is missing in certain targets at all => not commonized. @@ -224,7 +224,7 @@ private fun commonizeTypeAlias(typeAliasId: CirEntityId, classifiers: CirKnownCl return SUCCESS_FROM_DEPENDENCY_LIBRARY } - return when (val node = classifiers.commonized.typeAliasNode(typeAliasId)) { + return when (val node = classifiers.commonizedNodes.typeAliasNode(typeAliasId)) { null -> { // No node means that the type alias was not subject for commonization. It is missing in some target(s) => not commonized. FAILURE_MISSING_IN_SOME_TARGET diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt index 41f164369ce..e2d03a1a80c 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt @@ -39,7 +39,7 @@ fun runCommonization(parameters: CommonizerParameters) { private fun mergeAndCommonize(storageManager: StorageManager, parameters: CommonizerParameters): CirTreeMergeResult { // build merged tree: val classifiers = CirKnownClassifiers( - commonized = CirCommonizedClassifiers.default(), + commonizedNodes = CirCommonizedClassifierNodes.default(), forwardDeclarations = CirForwardDeclarations.default(), dependencies = mapOf( // for now, supply only common dependency libraries (ex: Kotlin stdlib) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt index eb5835ac479..1a8a5af8628 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderKotlinNativeSyntheticPackages class CirKnownClassifiers( - val commonized: CirCommonizedClassifiers, + val commonizedNodes: CirCommonizedClassifierNodes, val forwardDeclarations: CirForwardDeclarations, val dependencies: Map ) { @@ -23,7 +23,7 @@ class CirKnownClassifiers( } /** A set of all CIR nodes built for commonized classes and type aliases. */ -interface CirCommonizedClassifiers { +interface CirCommonizedClassifierNodes { /* Accessors */ fun classNode(classId: CirEntityId): CirClassNode? fun typeAliasNode(typeAliasId: CirEntityId): CirTypeAliasNode? @@ -33,7 +33,7 @@ interface CirCommonizedClassifiers { fun addTypeAliasNode(typeAliasId: CirEntityId, node: CirTypeAliasNode) companion object { - fun default() = object : CirCommonizedClassifiers { + fun default() = object : CirCommonizedClassifierNodes { private val classNodes = THashMap() private val typeAliases = THashMap() diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/nodeBuilders.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/nodeBuilders.kt index 82644db2801..11ec623313c 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/nodeBuilders.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/nodeBuilders.kt @@ -84,7 +84,7 @@ internal fun buildClassNode( recursionMarker = CirClassRecursionMarker, nodeProducer = { targetDeclarations, commonDeclaration -> CirClassNode(targetDeclarations, commonDeclaration).also { - classifiers.commonized.addClassNode(classId, it) + classifiers.commonizedNodes.addClassNode(classId, it) } } ) @@ -114,7 +114,7 @@ internal fun buildTypeAliasNode( recursionMarker = CirClassifierRecursionMarker, nodeProducer = { targetDeclarations, commonDeclaration -> CirTypeAliasNode(targetDeclarations, commonDeclaration).also { - classifiers.commonized.addTypeAliasNode(typeAliasId, it) + classifiers.commonizedNodes.addTypeAliasNode(typeAliasId, it) } } ) diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt index 61a5a32e0be..f0973a2677b 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt @@ -33,7 +33,7 @@ class TypeCommonizerTest : AbstractCommonizerTest() { fun initialize() { // reset cache classifiers = CirKnownClassifiers( - commonized = CirCommonizedClassifiers.default(), + commonizedNodes = CirCommonizedClassifierNodes.default(), forwardDeclarations = CirForwardDeclarations.default(), dependencies = mapOf( FAKE_SHARED_TARGET to object : CirProvidedClassifiers { @@ -540,9 +540,9 @@ class TypeCommonizerTest : AbstractCommonizerTest() { private val FAKE_SHARED_TARGET = SharedCommonizerTarget(setOf(LeafCommonizerTarget("a"), LeafCommonizerTarget("b"))) private fun CirKnownClassifiers.classNode(classId: CirEntityId, computation: () -> CirClassNode) = - commonized.classNode(classId) ?: computation() + commonizedNodes.classNode(classId) ?: computation() private fun CirKnownClassifiers.typeAliasNode(typeAliasId: CirEntityId, computation: () -> CirTypeAliasNode) = - commonized.typeAliasNode(typeAliasId) ?: computation() + commonizedNodes.typeAliasNode(typeAliasId) ?: computation() } } diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt index 9169e2b0fe6..ad81b942d2c 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt @@ -123,7 +123,7 @@ private fun createPackageFragmentForClassifier(classifierFqName: FqName): Packag } internal val MOCK_CLASSIFIERS = CirKnownClassifiers( - commonized = object : CirCommonizedClassifiers { + commonizedNodes = object : CirCommonizedClassifierNodes { private val MOCK_CLASS_NODE = CirClassNode( CommonizedGroup(0), LockBasedStorageManager.NO_LOCKS.createNullableLazyValue { From 84ce9c612c9d942ee4aeb93dcea51a3d7e1aa25d Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Wed, 17 Feb 2021 19:27:59 +0300 Subject: [PATCH 264/368] [Commonizer] Keep only "common" dependencies in CirKnownClassifiers --- .../kotlin/descriptors/commonizer/facade.kt | 9 +++------ .../commonizer/mergedtree/classifierContainers.kt | 10 ++-------- .../commonizer/core/TypeCommonizerTest.kt | 12 +++--------- .../kotlin/descriptors/commonizer/utils/mocks.kt | 2 +- 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt index e2d03a1a80c..5e5ea0902ef 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt @@ -41,12 +41,9 @@ private fun mergeAndCommonize(storageManager: StorageManager, parameters: Common val classifiers = CirKnownClassifiers( commonizedNodes = CirCommonizedClassifierNodes.default(), forwardDeclarations = CirForwardDeclarations.default(), - dependencies = mapOf( - // for now, supply only common dependency libraries (ex: Kotlin stdlib) - parameters.sharedTarget to CirCompositeClassifiers( - CirFictitiousFunctionClassifiers, - CirLoadedClassifiers.from(parameters.dependencyModulesProvider) - ) + commonDependencies = CirCompositeClassifiers( + CirFictitiousFunctionClassifiers, + CirLoadedClassifiers.from(parameters.dependencyModulesProvider) ) ) val mergeResult = CirTreeMerger(storageManager, classifiers, parameters).merge() diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt index 1a8a5af8628..c1c49332180 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt @@ -7,20 +7,14 @@ package org.jetbrains.kotlin.descriptors.commonizer.mergedtree import gnu.trove.THashMap import gnu.trove.THashSet -import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget -import org.jetbrains.kotlin.descriptors.commonizer.SharedCommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.utils.isUnderKotlinNativeSyntheticPackages class CirKnownClassifiers( val commonizedNodes: CirCommonizedClassifierNodes, val forwardDeclarations: CirForwardDeclarations, - val dependencies: Map -) { - // a shortcut for fast access - val commonDependencies: CirProvidedClassifiers = - dependencies.filterKeys { it is SharedCommonizerTarget }.values.singleOrNull() ?: CirProvidedClassifiers.EMPTY -} + val commonDependencies: CirProvidedClassifiers +) /** A set of all CIR nodes built for commonized classes and type aliases. */ interface CirCommonizedClassifierNodes { diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt index f0973a2677b..a38dd76335c 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/TypeCommonizerTest.kt @@ -7,8 +7,6 @@ package org.jetbrains.kotlin.descriptors.commonizer.core import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor -import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget -import org.jetbrains.kotlin.descriptors.commonizer.SharedCommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId import org.jetbrains.kotlin.descriptors.commonizer.cir.CirType import org.jetbrains.kotlin.descriptors.commonizer.cir.factory.CirClassFactory @@ -35,11 +33,9 @@ class TypeCommonizerTest : AbstractCommonizerTest() { classifiers = CirKnownClassifiers( commonizedNodes = CirCommonizedClassifierNodes.default(), forwardDeclarations = CirForwardDeclarations.default(), - dependencies = mapOf( - FAKE_SHARED_TARGET to object : CirProvidedClassifiers { - override fun hasClassifier(classifierId: CirEntityId): Boolean = classifierId.packageName.isUnderStandardKotlinPackages - } - ) + commonDependencies = object : CirProvidedClassifiers { + override fun hasClassifier(classifierId: CirEntityId): Boolean = classifierId.packageName.isUnderStandardKotlinPackages + } ) } @@ -537,8 +533,6 @@ class TypeCommonizerTest : AbstractCommonizerTest() { fun areEqual(classifiers: CirKnownClassifiers, a: CirType, b: CirType): Boolean = TypeCommonizer(classifiers).run { commonizeWith(a) && commonizeWith(b) } - private val FAKE_SHARED_TARGET = SharedCommonizerTarget(setOf(LeafCommonizerTarget("a"), LeafCommonizerTarget("b"))) - private fun CirKnownClassifiers.classNode(classId: CirEntityId, computation: () -> CirClassNode) = commonizedNodes.classNode(classId) ?: computation() diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt index ad81b942d2c..6051408180d 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/utils/mocks.kt @@ -153,7 +153,7 @@ internal val MOCK_CLASSIFIERS = CirKnownClassifiers( override fun isExportedForwardDeclaration(classId: CirEntityId) = false override fun addExportedForwardDeclaration(classId: CirEntityId) = error("This method should not be called") }, - dependencies = emptyMap() + commonDependencies = CirProvidedClassifiers.EMPTY ) internal class MockModulesProvider private constructor( From f473b88e4789c0659b1037b9cb242685f8d76e23 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Wed, 17 Feb 2021 19:42:16 +0300 Subject: [PATCH 265/368] [Commonizer] Nicer API for CirProvidedClassifiers --- .../kotlin/descriptors/commonizer/facade.kt | 4 +- .../mergedtree/CirCompositeClassifiers.kt | 14 ------ .../mergedtree/CirProvidedClassifiers.kt | 47 +++++++++++++++++++ ....kt => CirProvidedClassifiersByModules.kt} | 7 +-- .../mergedtree/classifierContainers.kt | 16 +------ 5 files changed, 51 insertions(+), 37 deletions(-) delete mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirCompositeClassifiers.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirProvidedClassifiers.kt rename native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/{CirLoadedClassifiers.kt => CirProvidedClassifiersByModules.kt} (89%) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt index 5e5ea0902ef..cfe4c416e41 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/facade.kt @@ -41,9 +41,9 @@ private fun mergeAndCommonize(storageManager: StorageManager, parameters: Common val classifiers = CirKnownClassifiers( commonizedNodes = CirCommonizedClassifierNodes.default(), forwardDeclarations = CirForwardDeclarations.default(), - commonDependencies = CirCompositeClassifiers( + commonDependencies = CirProvidedClassifiers.of( CirFictitiousFunctionClassifiers, - CirLoadedClassifiers.from(parameters.dependencyModulesProvider) + CirProvidedClassifiers.by(parameters.dependencyModulesProvider) ) ) val mergeResult = CirTreeMerger(storageManager, classifiers, parameters).merge() diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirCompositeClassifiers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirCompositeClassifiers.kt deleted file mode 100644 index b92faa5a278..00000000000 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirCompositeClassifiers.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2010-2021 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.descriptors.commonizer.mergedtree - -import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId - -class CirCompositeClassifiers(private val delegates: List) : CirProvidedClassifiers { - constructor(vararg delegates: CirProvidedClassifiers) : this(delegates.toList()) - - override fun hasClassifier(classifierId: CirEntityId): Boolean = delegates.any { it.hasClassifier(classifierId) } -} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirProvidedClassifiers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirProvidedClassifiers.kt new file mode 100644 index 00000000000..46c9de53303 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirProvidedClassifiers.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer.mergedtree + +import org.jetbrains.kotlin.descriptors.commonizer.ModulesProvider +import org.jetbrains.kotlin.descriptors.commonizer.cir.CirEntityId + +/** A set of classes and type aliases provided by libraries (either the libraries to commonize, or their dependency libraries)/ */ +interface CirProvidedClassifiers { + fun hasClassifier(classifierId: CirEntityId): Boolean + + // TODO: implement later + //fun classifier(classifierId: ClassId): Any? + + object EMPTY : CirProvidedClassifiers { + override fun hasClassifier(classifierId: CirEntityId) = false + } + + private class CompositeClassifiers(val delegates: List) : CirProvidedClassifiers { + override fun hasClassifier(classifierId: CirEntityId) = delegates.any { it.hasClassifier(classifierId) } + } + + companion object { + fun of(vararg delegates: CirProvidedClassifiers): CirProvidedClassifiers { + val unwrappedDelegates: List = delegates.fold(ArrayList()) { acc, delegate -> + when (delegate) { + EMPTY -> Unit + is CompositeClassifiers -> acc.addAll(delegate.delegates) + else -> acc.add(delegate) + } + acc + } + + return when (unwrappedDelegates.size) { + 0 -> EMPTY + 1 -> unwrappedDelegates.first() + else -> CompositeClassifiers(unwrappedDelegates) + } + } + + fun by(modulesProvider: ModulesProvider?): CirProvidedClassifiers = + if (modulesProvider != null) CirProvidedClassifiersByModules(modulesProvider) else EMPTY + } +} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirLoadedClassifiers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirProvidedClassifiersByModules.kt similarity index 89% rename from native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirLoadedClassifiers.kt rename to native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirProvidedClassifiersByModules.kt index 60a0275655c..b28a1cb23b3 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirLoadedClassifiers.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/CirProvidedClassifiersByModules.kt @@ -14,15 +14,10 @@ import org.jetbrains.kotlin.library.metadata.parsePackageFragment import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl -class CirLoadedClassifiers(modulesProvider: ModulesProvider) : CirProvidedClassifiers { +internal class CirProvidedClassifiersByModules(modulesProvider: ModulesProvider) : CirProvidedClassifiers { private val classifiers: Set = loadClassifiers(modulesProvider) override fun hasClassifier(classifierId: CirEntityId): Boolean = classifierId in classifiers - - companion object { - fun from(modulesProvider: ModulesProvider?): CirProvidedClassifiers = - if (modulesProvider != null) CirLoadedClassifiers(modulesProvider) else CirProvidedClassifiers.EMPTY - } } private fun loadClassifiers(modulesProvider: ModulesProvider): Set { diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt index c1c49332180..38c805d06d4 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/mergedtree/classifierContainers.kt @@ -67,18 +67,4 @@ interface CirForwardDeclarations { } } } -} - -/** A set of classes and type aliases provided by libraries (either the libraries to commonize, or their dependency libraries)/ */ -interface CirProvidedClassifiers { - fun hasClassifier(classifierId: CirEntityId): Boolean - - // TODO: implement later - //fun classifier(classifierId: ClassId): Any? - - companion object { - internal val EMPTY = object : CirProvidedClassifiers { - override fun hasClassifier(classifierId: CirEntityId) = false - } - } -} +} \ No newline at end of file From 1895c230efb8da1f6d53e29c49979682e9b98291 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Thu, 18 Feb 2021 13:37:59 +0300 Subject: [PATCH 266/368] [Commonizer] K/N dist: Process targets in alphabetical order --- .../descriptors/commonizer/cli/NativeTargetsOptionType.kt | 2 +- .../kotlin/descriptors/commonizer/cli/nativeTasks.kt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/NativeTargetsOptionType.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/NativeTargetsOptionType.kt index 84ae55292b6..96c3ef3052b 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/NativeTargetsOptionType.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/NativeTargetsOptionType.kt @@ -15,7 +15,7 @@ internal object NativeTargetsOptionType : OptionType>("targets val targets = targetNames.mapTo(HashSet()) { targetName -> predefinedTargets[targetName] ?: onError("Unknown hardware target: $targetName") - }.toList() + }.sortedBy { it.name } return Option(this, targets) } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt index 7a9e869283e..53da24d0b7b 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt @@ -61,7 +61,7 @@ internal class NativeKlibCommonize(options: Collection>) : Task(option val konanTargets = outputCommonizerTarget.konanTargets val logger = CliLoggerAdapter(2) val libraryLoader = DefaultNativeLibraryLoader(logger) - val statsCollector = StatsCollector(statsType, outputCommonizerTarget.konanTargets.toList()) + val statsCollector = StatsCollector(statsType, konanTargets.toList()) val repository = FilesRepository(targetLibraries.toSet(), libraryLoader) val resultsConsumer = buildResultsConsumer { @@ -75,10 +75,10 @@ internal class NativeKlibCommonize(options: Collection>) : Task(option LibraryCommonizer( konanDistribution = distribution, repository = repository, - dependencies = KonanDistributionRepository(distribution, outputCommonizerTarget.konanTargets, libraryLoader) + + dependencies = KonanDistributionRepository(distribution, konanTargets, libraryLoader) + FilesRepository(dependencyLibraries.toSet(), libraryLoader), libraryLoader = libraryLoader, - targets = outputCommonizerTarget.konanTargets.toList(), + targets = konanTargets.toList(), resultsConsumer = resultsConsumer, statsCollector = statsCollector, logger = logger @@ -103,7 +103,7 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas val logger = CliLoggerAdapter(2) val libraryLoader = DefaultNativeLibraryLoader(logger) val repository = KonanDistributionRepository(distribution, targets.toSet(), libraryLoader) - val statsCollector = StatsCollector(statsType, targets.toList()) + val statsCollector = StatsCollector(statsType, targets) val resultsConsumer = buildResultsConsumer { this add ModuleSerializer(destination, NativeDistributionCommonizerOutputLayout) From 3ad7b6074787da10b4ddb00bc314c190f3e709bc Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Thu, 18 Feb 2021 14:06:51 +0300 Subject: [PATCH 267/368] [Commonizer] Prefer using CommonizerTarget instead of KonanTarget --- .../descriptors/commonizer/cli/nativeTasks.kt | 31 ++++++++++--------- .../CopyUnconsumedModulesAsIsConsumer.kt | 16 +++++----- .../commonizer/konan/LibraryCommonizer.kt | 5 ++- .../repository/KonanDistributionRepository.kt | 5 ++- .../stats/AggregatedStatsCollector.kt | 4 +-- .../commonizer/stats/RawStatsCollector.kt | 7 +++-- .../commonizer/stats/StatsCollector.kt | 4 +-- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt index 53da24d0b7b..5f2c5c0cd1f 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt @@ -59,15 +59,17 @@ internal class NativeKlibCommonize(options: Collection>) : Task(option val statsType = getOptional { it == "log-stats" } ?: StatsType.NONE val konanTargets = outputCommonizerTarget.konanTargets + val commonizerTargets = konanTargets.map(::CommonizerTarget) + val logger = CliLoggerAdapter(2) val libraryLoader = DefaultNativeLibraryLoader(logger) - val statsCollector = StatsCollector(statsType, konanTargets.toList()) + val statsCollector = StatsCollector(statsType, commonizerTargets) val repository = FilesRepository(targetLibraries.toSet(), libraryLoader) val resultsConsumer = buildResultsConsumer { this add ModuleSerializer(destination, HierarchicalCommonizerOutputLayout) this add CopyUnconsumedModulesAsIsConsumer( - repository, destination, konanTargets, NativeDistributionCommonizerOutputLayout, logger.toProgressLogger() + repository, destination, commonizerTargets.toSet(), NativeDistributionCommonizerOutputLayout, logger.toProgressLogger() ) this add LoggingResultsConsumer(outputCommonizerTarget, logger.toProgressLogger()) } @@ -75,10 +77,10 @@ internal class NativeKlibCommonize(options: Collection>) : Task(option LibraryCommonizer( konanDistribution = distribution, repository = repository, - dependencies = KonanDistributionRepository(distribution, konanTargets, libraryLoader) + + dependencies = KonanDistributionRepository(distribution, commonizerTargets.toSet(), libraryLoader) + FilesRepository(dependencyLibraries.toSet(), libraryLoader), libraryLoader = libraryLoader, - targets = konanTargets.toList(), + targets = commonizerTargets, resultsConsumer = resultsConsumer, statsCollector = statsCollector, logger = logger @@ -94,7 +96,8 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas override fun execute(logPrefix: String) { val distribution = KonanDistribution(getMandatory()) val destination = getMandatory() - val targets = getMandatory, NativeTargetsOptionType>() + val konanTargets = getMandatory, NativeTargetsOptionType>() + val commonizerTargets = konanTargets.map(::CommonizerTarget) val copyStdlib = getOptional { it == "copy-stdlib" } ?: false val copyEndorsedLibs = getOptional { it == "copy-endorsed-libs" } ?: false @@ -102,21 +105,21 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas val logger = CliLoggerAdapter(2) val libraryLoader = DefaultNativeLibraryLoader(logger) - val repository = KonanDistributionRepository(distribution, targets.toSet(), libraryLoader) - val statsCollector = StatsCollector(statsType, targets) + val repository = KonanDistributionRepository(distribution, commonizerTargets.toSet(), libraryLoader) + val statsCollector = StatsCollector(statsType, commonizerTargets) val resultsConsumer = buildResultsConsumer { this add ModuleSerializer(destination, NativeDistributionCommonizerOutputLayout) this add CopyUnconsumedModulesAsIsConsumer( - repository, destination, targets.toSet(), NativeDistributionCommonizerOutputLayout, logger.toProgressLogger() + repository, destination, commonizerTargets.toSet(), NativeDistributionCommonizerOutputLayout, logger.toProgressLogger() ) if (copyStdlib) this add CopyStdlibResultsConsumer(distribution, destination, logger.toProgressLogger()) if (copyEndorsedLibs) this add CopyEndorsedLibrairesResultsConsumer(distribution, destination, logger.toProgressLogger()) - this add LoggingResultsConsumer(SharedCommonizerTarget(targets), logger.toProgressLogger()) + this add LoggingResultsConsumer(SharedCommonizerTarget(commonizerTargets.toSet()), logger.toProgressLogger()) } - val targetNames = targets.joinToString { "[${it.name}]" } - val descriptionSuffix = estimateLibrariesCount(repository, targets).let { " ($it items)" } + val targetNames = commonizerTargets.joinToString { it.prettyName } + val descriptionSuffix = estimateLibrariesCount(repository, commonizerTargets).let { " ($it items)" } val description = "${logPrefix}Preparing commonized Kotlin/Native libraries for targets $targetNames$descriptionSuffix" println(description) @@ -125,7 +128,7 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas konanDistribution = distribution, dependencies = EmptyRepository, libraryLoader = libraryLoader, - targets = targets, + targets = commonizerTargets, resultsConsumer = resultsConsumer, statsCollector = statsCollector, logger = logger @@ -135,8 +138,8 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas } companion object { - private fun estimateLibrariesCount(repository: Repository, targets: List): Int { - return targets.flatMap { repository.getLibraries(LeafCommonizerTarget(it)) }.count() + private fun estimateLibrariesCount(repository: Repository, targets: List): Int { + return targets.flatMap { repository.getLibraries(it) }.count() } } } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyUnconsumedModulesAsIsConsumer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyUnconsumedModulesAsIsConsumer.kt index ce804095e4d..559eccad9c9 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyUnconsumedModulesAsIsConsumer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/CopyUnconsumedModulesAsIsConsumer.kt @@ -7,23 +7,22 @@ package org.jetbrains.kotlin.descriptors.commonizer.konan import org.jetbrains.kotlin.descriptors.commonizer.* import org.jetbrains.kotlin.descriptors.commonizer.repository.Repository -import org.jetbrains.kotlin.konan.target.KonanTarget import org.jetbrains.kotlin.util.Logger import java.io.File internal class CopyUnconsumedModulesAsIsConsumer( private val repository: Repository, private val destination: File, - private val targets: Set, + private val targets: Set, private val outputLayout: CommonizerOutputLayout, private val logger: Logger? = null ) : ResultsConsumer { - private val consumedTargets = mutableSetOf() + private val consumedTargets = mutableSetOf() override fun targetConsumed(target: CommonizerTarget) { if (target is LeafCommonizerTarget) { - consumedTargets.add(target.konanTarget) + consumedTargets += target } } @@ -34,15 +33,14 @@ internal class CopyUnconsumedModulesAsIsConsumer( } } - private fun copyTargetAsIs(target: KonanTarget) { - val commonizerTarget = CommonizerTarget(target) - val libraries = repository.getLibraries(commonizerTarget) - val librariesDestination = outputLayout.getTargetDirectory(destination, commonizerTarget) + private fun copyTargetAsIs(target: LeafCommonizerTarget) { + val libraries = repository.getLibraries(target) + val librariesDestination = outputLayout.getTargetDirectory(destination, target) librariesDestination.mkdirs() // always create an empty directory even if there is nothing to copy libraries.map { it.library.libraryFile.absolutePath }.map(::File).forEach { libraryFile -> libraryFile.copyRecursively(destination.resolve(libraryFile.name)) } - logger?.log("Copied ${libraries.size} libraries for ${commonizerTarget.prettyName}") + logger?.log("Copied ${libraries.size} libraries for ${target.prettyName}") } } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt index b2e3e6a1ff2..47bb2b5b901 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt @@ -13,7 +13,6 @@ import org.jetbrains.kotlin.descriptors.commonizer.repository.Repository import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsCollector import org.jetbrains.kotlin.descriptors.commonizer.utils.ResettableClockMark import org.jetbrains.kotlin.konan.library.* -import org.jetbrains.kotlin.konan.target.KonanTarget import org.jetbrains.kotlin.storage.LockBasedStorageManager import org.jetbrains.kotlin.util.Logger @@ -22,7 +21,7 @@ internal class LibraryCommonizer internal constructor( private val repository: Repository, private val dependencies: Repository, private val libraryLoader: NativeLibraryLoader, - private val targets: List, + private val targets: List, private val resultsConsumer: ResultsConsumer, private val statsCollector: StatsCollector?, private val logger: Logger @@ -41,7 +40,7 @@ internal class LibraryCommonizer internal constructor( private fun loadLibraries(): AllNativeLibraries { val stdlib = libraryLoader(konanDistribution.stdlib) - val librariesByTargets = targets.map(::LeafCommonizerTarget).associateWith { target -> + val librariesByTargets = targets.associateWith { target -> NativeLibrariesToCommonize(repository.getLibraries(target).toList()) } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/KonanDistributionRepository.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/KonanDistributionRepository.kt index 3aa005bd904..34c848ebc48 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/KonanDistributionRepository.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/repository/KonanDistributionRepository.kt @@ -10,16 +10,15 @@ import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.NativeLibraryLoader import org.jetbrains.kotlin.descriptors.commonizer.konan.NativeLibrary import org.jetbrains.kotlin.descriptors.commonizer.platformLibsDir -import org.jetbrains.kotlin.konan.target.KonanTarget internal class KonanDistributionRepository( konanDistribution: KonanDistribution, - targets: Set, + targets: Set, libraryLoader: NativeLibraryLoader, ) : Repository { private val librariesByTarget: Map>> = - targets.map(::LeafCommonizerTarget).associateWith { target -> + targets.associateWith { target -> lazy { konanDistribution.platformLibsDir .resolve(target.name) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/AggregatedStatsCollector.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/AggregatedStatsCollector.kt index 5c3f1e4b6dc..b95cab00bd4 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/AggregatedStatsCollector.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/AggregatedStatsCollector.kt @@ -5,11 +5,11 @@ package org.jetbrains.kotlin.descriptors.commonizer.stats +import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget import org.jetbrains.kotlin.descriptors.commonizer.stats.RawStatsCollector.CommonDeclarationStatus.* -import org.jetbrains.kotlin.konan.target.KonanTarget class AggregatedStatsCollector( - targets: List + targets: List ) : StatsCollector { private val wrappedCollector = RawStatsCollector(targets) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/RawStatsCollector.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/RawStatsCollector.kt index 2142e3aa1ab..bf32c86918a 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/RawStatsCollector.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/RawStatsCollector.kt @@ -7,10 +7,11 @@ package org.jetbrains.kotlin.descriptors.commonizer.stats import com.intellij.util.containers.FactoryMap import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget +import org.jetbrains.kotlin.descriptors.commonizer.identityString import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsCollector.StatsKey import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsOutput.StatsHeader import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsOutput.StatsRow -import org.jetbrains.kotlin.konan.target.KonanTarget import java.util.* import kotlin.collections.ArrayList @@ -56,9 +57,9 @@ platform/SystemConfiguration/SCDynamicStoreRefVar||||TYPE_ALIAS|-|O|O platform/SystemConfiguration/SCVLANInterfaceRef||||TYPE_ALIAS|-|O|O */ -class RawStatsCollector(private val targets: List) : StatsCollector { +class RawStatsCollector(private val targets: List) : StatsCollector { private inline val dimension get() = targets.size + 1 - private inline val targetNames get() = targets.map { it.name } + private inline val targetNames get() = targets.map { it.identityString } private inline val indexOfCommon get() = targets.size private inline val platformDeclarationsCount get() = targets.size diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/StatsCollector.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/StatsCollector.kt index 8adede045ed..f7a1da3d822 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/StatsCollector.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/stats/StatsCollector.kt @@ -5,9 +5,9 @@ package org.jetbrains.kotlin.descriptors.commonizer.stats -import org.jetbrains.kotlin.konan.target.KonanTarget +import org.jetbrains.kotlin.descriptors.commonizer.CommonizerTarget -fun StatsCollector(type: StatsType, targets: List): StatsCollector? { +fun StatsCollector(type: StatsType, targets: List): StatsCollector? { return when (type) { StatsType.RAW -> RawStatsCollector(targets) StatsType.AGGREGATED -> AggregatedStatsCollector(targets) From 496aad3c4acfd4794ff69ee089a41c43fe1ae18c Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Thu, 18 Feb 2021 14:07:31 +0300 Subject: [PATCH 268/368] [Commonizer] Log commonization only for really present targets --- .../jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt index 5f2c5c0cd1f..ddfa904a4cb 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt @@ -106,6 +106,7 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas val logger = CliLoggerAdapter(2) val libraryLoader = DefaultNativeLibraryLoader(logger) val repository = KonanDistributionRepository(distribution, commonizerTargets.toSet(), libraryLoader) + val existingTargets = commonizerTargets.filter { repository.getLibraries(it).isNotEmpty() }.toSet() val statsCollector = StatsCollector(statsType, commonizerTargets) val resultsConsumer = buildResultsConsumer { @@ -115,7 +116,7 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas ) if (copyStdlib) this add CopyStdlibResultsConsumer(distribution, destination, logger.toProgressLogger()) if (copyEndorsedLibs) this add CopyEndorsedLibrairesResultsConsumer(distribution, destination, logger.toProgressLogger()) - this add LoggingResultsConsumer(SharedCommonizerTarget(commonizerTargets.toSet()), logger.toProgressLogger()) + this add LoggingResultsConsumer(SharedCommonizerTarget(existingTargets), logger.toProgressLogger()) } val targetNames = commonizerTargets.joinToString { it.prettyName } From fb51105a5d25af7a4781c650e6d9153c24f7802b Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Thu, 18 Feb 2021 15:01:41 +0300 Subject: [PATCH 269/368] [Commonizer] Log time in commonizer result consumers --- .../commonizer/cli/ProgressLogger.kt | 22 -------------- .../descriptors/commonizer/cli/nativeTasks.kt | 25 ++++++++-------- .../commonizer/konan/LibraryCommonizer.kt | 26 ++++++----------- .../commonizer/utils/ProgressLogger.kt | 29 +++++++++++++++++++ 4 files changed, 51 insertions(+), 51 deletions(-) delete mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/ProgressLogger.kt create mode 100644 native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/ProgressLogger.kt diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/ProgressLogger.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/ProgressLogger.kt deleted file mode 100644 index 90c130f6c39..00000000000 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/ProgressLogger.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2010-2021 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.descriptors.commonizer.cli - -import org.jetbrains.kotlin.util.Logger - -fun Logger.toProgressLogger(): Logger { - return ProgressLogger(this) -} - -private class ProgressLogger(private val logger: Logger) : Logger by logger { - override fun log(message: String) { - logger.log("* $message") - } - - override fun warning(message: String) { - logger.log("* $message") - } -} diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt index ddfa904a4cb..6b61c074243 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.descriptors.commonizer.repository.Repository import org.jetbrains.kotlin.descriptors.commonizer.stats.FileStatsOutput import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsCollector import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsType +import org.jetbrains.kotlin.descriptors.commonizer.utils.ProgressLogger import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_KLIB_DIR import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR import org.jetbrains.kotlin.konan.target.KonanTarget @@ -61,17 +62,17 @@ internal class NativeKlibCommonize(options: Collection>) : Task(option val konanTargets = outputCommonizerTarget.konanTargets val commonizerTargets = konanTargets.map(::CommonizerTarget) - val logger = CliLoggerAdapter(2) - val libraryLoader = DefaultNativeLibraryLoader(logger) + val progressLogger = ProgressLogger(CliLoggerAdapter(2)) + val libraryLoader = DefaultNativeLibraryLoader(progressLogger) val statsCollector = StatsCollector(statsType, commonizerTargets) val repository = FilesRepository(targetLibraries.toSet(), libraryLoader) val resultsConsumer = buildResultsConsumer { this add ModuleSerializer(destination, HierarchicalCommonizerOutputLayout) this add CopyUnconsumedModulesAsIsConsumer( - repository, destination, commonizerTargets.toSet(), NativeDistributionCommonizerOutputLayout, logger.toProgressLogger() + repository, destination, commonizerTargets.toSet(), NativeDistributionCommonizerOutputLayout, progressLogger ) - this add LoggingResultsConsumer(outputCommonizerTarget, logger.toProgressLogger()) + this add LoggingResultsConsumer(outputCommonizerTarget, progressLogger) } LibraryCommonizer( @@ -83,7 +84,7 @@ internal class NativeKlibCommonize(options: Collection>) : Task(option targets = commonizerTargets, resultsConsumer = resultsConsumer, statsCollector = statsCollector, - logger = logger + progressLogger = progressLogger ).run() statsCollector?.writeTo(FileStatsOutput(destination, statsType.name.toLowerCase())) @@ -103,8 +104,8 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas val copyEndorsedLibs = getOptional { it == "copy-endorsed-libs" } ?: false val statsType = getOptional { it == "log-stats" } ?: StatsType.NONE - val logger = CliLoggerAdapter(2) - val libraryLoader = DefaultNativeLibraryLoader(logger) + val progressLogger = ProgressLogger(CliLoggerAdapter(2)) + val libraryLoader = DefaultNativeLibraryLoader(progressLogger) val repository = KonanDistributionRepository(distribution, commonizerTargets.toSet(), libraryLoader) val existingTargets = commonizerTargets.filter { repository.getLibraries(it).isNotEmpty() }.toSet() val statsCollector = StatsCollector(statsType, commonizerTargets) @@ -112,11 +113,11 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas val resultsConsumer = buildResultsConsumer { this add ModuleSerializer(destination, NativeDistributionCommonizerOutputLayout) this add CopyUnconsumedModulesAsIsConsumer( - repository, destination, commonizerTargets.toSet(), NativeDistributionCommonizerOutputLayout, logger.toProgressLogger() + repository, destination, commonizerTargets.toSet(), NativeDistributionCommonizerOutputLayout, progressLogger ) - if (copyStdlib) this add CopyStdlibResultsConsumer(distribution, destination, logger.toProgressLogger()) - if (copyEndorsedLibs) this add CopyEndorsedLibrairesResultsConsumer(distribution, destination, logger.toProgressLogger()) - this add LoggingResultsConsumer(SharedCommonizerTarget(existingTargets), logger.toProgressLogger()) + if (copyStdlib) this add CopyStdlibResultsConsumer(distribution, destination, progressLogger) + if (copyEndorsedLibs) this add CopyEndorsedLibrairesResultsConsumer(distribution, destination, progressLogger) + this add LoggingResultsConsumer(SharedCommonizerTarget(existingTargets), progressLogger) } val targetNames = commonizerTargets.joinToString { it.prettyName } @@ -132,7 +133,7 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas targets = commonizerTargets, resultsConsumer = resultsConsumer, statsCollector = statsCollector, - logger = logger + progressLogger = progressLogger ).run() println("$description: Done") diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt index 47bb2b5b901..1e253013467 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt @@ -7,14 +7,12 @@ package org.jetbrains.kotlin.descriptors.commonizer.konan import org.jetbrains.kotlin.descriptors.commonizer.* import org.jetbrains.kotlin.descriptors.commonizer.LeafCommonizerTarget -import org.jetbrains.kotlin.descriptors.commonizer.cli.toProgressLogger import org.jetbrains.kotlin.descriptors.commonizer.konan.LibraryCommonizer.* import org.jetbrains.kotlin.descriptors.commonizer.repository.Repository import org.jetbrains.kotlin.descriptors.commonizer.stats.StatsCollector -import org.jetbrains.kotlin.descriptors.commonizer.utils.ResettableClockMark +import org.jetbrains.kotlin.descriptors.commonizer.utils.ProgressLogger import org.jetbrains.kotlin.konan.library.* import org.jetbrains.kotlin.storage.LockBasedStorageManager -import org.jetbrains.kotlin.util.Logger internal class LibraryCommonizer internal constructor( private val konanDistribution: KonanDistribution, @@ -24,17 +22,15 @@ internal class LibraryCommonizer internal constructor( private val targets: List, private val resultsConsumer: ResultsConsumer, private val statsCollector: StatsCollector?, - private val logger: Logger + private val progressLogger: ProgressLogger ) { - private val clockMark = ResettableClockMark() - fun run() { checkPreconditions() - clockMark.reset() + progressLogger.reset() val allLibraries = loadLibraries() commonizeAndSaveResults(allLibraries) - logTotal() + progressLogger.logTotal() } private fun loadLibraries(): AllNativeLibraries { @@ -46,17 +42,17 @@ internal class LibraryCommonizer internal constructor( librariesByTargets.forEach { (target, librariesToCommonize) -> if (librariesToCommonize.libraries.isEmpty()) { - logger.warning("No platform libraries found for target $target. This target will be excluded from commonization.") + progressLogger.warning("No platform libraries found for target $target. This target will be excluded from commonization.") } } - logProgress("Read lazy (uninitialized) libraries") + progressLogger.log("Read lazy (uninitialized) libraries") return AllNativeLibraries(stdlib, librariesByTargets) } private fun commonizeAndSaveResults(allLibraries: AllNativeLibraries) { val manifestProvider = TargetedNativeManifestDataProvider(allLibraries) - val parameters = CommonizerParameters(resultsConsumer, manifestProvider, statsCollector, ::logProgress).apply { + val parameters = CommonizerParameters(resultsConsumer, manifestProvider, statsCollector, progressLogger::log).apply { val storageManager = LockBasedStorageManager("Commonized modules") dependencyModulesProvider = NativeDistributionModulesProvider.forStandardLibrary(storageManager, allLibraries.stdlib) @@ -83,12 +79,8 @@ internal class LibraryCommonizer internal constructor( private fun checkPreconditions() { when (targets.size) { - 0 -> logger.fatal("No targets specified") - 1 -> logger.fatal("Too few targets specified: $targets") + 0 -> progressLogger.fatal("No targets specified") + 1 -> progressLogger.fatal("Too few targets specified: $targets") } } - - private fun logProgress(message: String) = logger.toProgressLogger().log("$message in ${clockMark.elapsedSinceLast()}") - - private fun logTotal() = logger.log("TOTAL: ${clockMark.elapsedSinceStart()}") } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/ProgressLogger.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/ProgressLogger.kt new file mode 100644 index 00000000000..191473e38f5 --- /dev/null +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/ProgressLogger.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2021 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.descriptors.commonizer.utils + +import org.jetbrains.kotlin.util.Logger + +class ProgressLogger(private val wrapped: Logger) : Logger by wrapped { + private val clockMark = ResettableClockMark() + private var finished = true + + fun reset() { + clockMark.reset() + finished = false + } + + override fun log(message: String) { + check(!finished) + wrapped.log("* $message in ${clockMark.elapsedSinceLast()}") + } + + fun logTotal() { + check(!finished) + wrapped.log("TOTAL: ${clockMark.elapsedSinceStart()}") + finished = true + } +} From 0b26a281dee8ecd519867e6ee3e22fa7e56ee685 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Thu, 18 Feb 2021 15:14:55 +0300 Subject: [PATCH 270/368] [Commonizer] Print pretty target name in console output --- .../kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt index 1e253013467..236fc1c1736 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt @@ -42,7 +42,7 @@ internal class LibraryCommonizer internal constructor( librariesByTargets.forEach { (target, librariesToCommonize) -> if (librariesToCommonize.libraries.isEmpty()) { - progressLogger.warning("No platform libraries found for target $target. This target will be excluded from commonization.") + progressLogger.warning("No platform libraries found for target ${target.prettyName}. This target will be excluded from commonization.") } } progressLogger.log("Read lazy (uninitialized) libraries") From 05447ce0c8bb408e42b68103b738441507c488a7 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Thu, 18 Feb 2021 15:36:45 +0300 Subject: [PATCH 271/368] [Commonizer] Print true time for resolving of libraries to be commonized --- .../kotlin/descriptors/commonizer/cli/nativeTasks.kt | 4 ++-- .../descriptors/commonizer/konan/LibraryCommonizer.kt | 3 +-- .../descriptors/commonizer/utils/ProgressLogger.kt | 10 +++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt index 6b61c074243..b0f2e8ffdf0 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/cli/nativeTasks.kt @@ -62,7 +62,7 @@ internal class NativeKlibCommonize(options: Collection>) : Task(option val konanTargets = outputCommonizerTarget.konanTargets val commonizerTargets = konanTargets.map(::CommonizerTarget) - val progressLogger = ProgressLogger(CliLoggerAdapter(2)) + val progressLogger = ProgressLogger(CliLoggerAdapter(2), startImmediately = true) val libraryLoader = DefaultNativeLibraryLoader(progressLogger) val statsCollector = StatsCollector(statsType, commonizerTargets) val repository = FilesRepository(targetLibraries.toSet(), libraryLoader) @@ -104,7 +104,7 @@ internal class NativeDistributionCommonize(options: Collection>) : Tas val copyEndorsedLibs = getOptional { it == "copy-endorsed-libs" } ?: false val statsType = getOptional { it == "log-stats" } ?: StatsType.NONE - val progressLogger = ProgressLogger(CliLoggerAdapter(2)) + val progressLogger = ProgressLogger(CliLoggerAdapter(2), startImmediately = true) val libraryLoader = DefaultNativeLibraryLoader(progressLogger) val repository = KonanDistributionRepository(distribution, commonizerTargets.toSet(), libraryLoader) val existingTargets = commonizerTargets.filter { repository.getLibraries(it).isNotEmpty() }.toSet() diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt index 236fc1c1736..96624554b06 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/konan/LibraryCommonizer.kt @@ -27,7 +27,6 @@ internal class LibraryCommonizer internal constructor( fun run() { checkPreconditions() - progressLogger.reset() val allLibraries = loadLibraries() commonizeAndSaveResults(allLibraries) progressLogger.logTotal() @@ -45,7 +44,7 @@ internal class LibraryCommonizer internal constructor( progressLogger.warning("No platform libraries found for target ${target.prettyName}. This target will be excluded from commonization.") } } - progressLogger.log("Read lazy (uninitialized) libraries") + progressLogger.log("Resolved libraries to be commonized") return AllNativeLibraries(stdlib, librariesByTargets) } diff --git a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/ProgressLogger.kt b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/ProgressLogger.kt index 191473e38f5..a9b74408755 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/ProgressLogger.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/descriptors/commonizer/utils/ProgressLogger.kt @@ -7,10 +7,18 @@ package org.jetbrains.kotlin.descriptors.commonizer.utils import org.jetbrains.kotlin.util.Logger -class ProgressLogger(private val wrapped: Logger) : Logger by wrapped { +class ProgressLogger( + private val wrapped: Logger, + startImmediately: Boolean = false +) : Logger by wrapped { private val clockMark = ResettableClockMark() private var finished = true + init { + if (startImmediately) + reset() + } + fun reset() { clockMark.reset() finished = false From 744a0fcd250cfb171f754e33489596bab3f83284 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Thu, 18 Feb 2021 17:18:10 +0300 Subject: [PATCH 272/368] PSI2IR KT-45022 object in LHS of compound assignment --- .../FirBlackBoxCodegenTestGenerated.java | 6 ++++ .../runners/ir/Fir2IrTextTestGenerated.java | 6 ++++ .../psi2ir/generators/AssignmentGenerator.kt | 3 ++ .../box/operatorConventions/kt45022.kt | 8 +++++ .../ir/irText/expressions/kt45022.fir.txt | 35 +++++++++++++++++++ .../testData/ir/irText/expressions/kt45022.kt | 12 +++++++ .../ir/irText/expressions/kt45022.txt | 35 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++++ .../test/runners/ir/IrTextTestGenerated.java | 6 ++++ .../LightAnalysisModeTestGenerated.java | 5 +++ .../IrJsCodegenBoxES6TestGenerated.java | 5 +++ .../IrJsCodegenBoxTestGenerated.java | 5 +++ .../semantics/JsCodegenBoxTestGenerated.java | 5 +++ .../IrCodegenBoxWasmTestGenerated.java | 5 +++ 15 files changed, 148 insertions(+) create mode 100644 compiler/testData/codegen/box/operatorConventions/kt45022.kt create mode 100644 compiler/testData/ir/irText/expressions/kt45022.fir.txt create mode 100644 compiler/testData/ir/irText/expressions/kt45022.kt create mode 100644 compiler/testData/ir/irText/expressions/kt45022.txt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 2abd3a2743b..af7a523537f 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -25344,6 +25344,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @Test + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @Test @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index ce07fa4515b..8e4989b1fd0 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -1346,6 +1346,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/kt37779.kt"); } + @Test + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/ir/irText/expressions/kt45022.kt"); + } + @Test @TestMetadata("lambdaInCAO.kt") public void testLambdaInCAO() throws Exception { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt index fa7f1e62144..e6369b53bf4 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/AssignmentGenerator.kt @@ -41,6 +41,7 @@ import org.jetbrains.kotlin.resolve.PropertyImportedFromObject import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic +import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject import org.jetbrains.kotlin.types.KotlinType class AssignmentGenerator(statementGenerator: StatementGenerator) : StatementGeneratorExtension(statementGenerator) { @@ -206,6 +207,8 @@ class AssignmentGenerator(statementGenerator: StatementGenerator) : StatementGen createVariableValue(ktExpr, descriptor, origin) is PropertyDescriptor -> generateAssignmentReceiverForProperty(descriptor, origin, ktExpr, resolvedCall, isAssignmentStatement) + is FakeCallableDescriptorForObject -> + OnceExpressionValue(ktExpr.genExpr()) is ValueDescriptor -> createVariableValue(ktExpr, descriptor, origin) else -> diff --git a/compiler/testData/codegen/box/operatorConventions/kt45022.kt b/compiler/testData/codegen/box/operatorConventions/kt45022.kt new file mode 100644 index 00000000000..10c2ea64f7d --- /dev/null +++ b/compiler/testData/codegen/box/operatorConventions/kt45022.kt @@ -0,0 +1,8 @@ +fun box(): String { + X += 1 + return "OK" +} + +object X { + operator fun plusAssign(any: Any) = Unit +} diff --git a/compiler/testData/ir/irText/expressions/kt45022.fir.txt b/compiler/testData/ir/irText/expressions/kt45022.fir.txt new file mode 100644 index 00000000000..da052287a6f --- /dev/null +++ b/compiler/testData/ir/irText/expressions/kt45022.fir.txt @@ -0,0 +1,35 @@ +FILE fqName: fileName:/kt45022.kt + TYPEALIAS name:AX visibility:public expandedType:.X + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' type=kotlin.Unit origin=null + $this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X + any: CONST Int type=kotlin.Int value=1 + CALL 'public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' type=kotlin.Unit origin=null + $this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X + any: CONST Int type=kotlin.Int value=1 + CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.X + CONSTRUCTOR visibility:private <> () returnType:.X [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:plusAssign visibility:public modality:FINAL <> ($this:.X, any:kotlin.Any) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER name: type:.X + VALUE_PARAMETER name:any index:0 type:kotlin.Any + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' + GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/kt45022.kt b/compiler/testData/ir/irText/expressions/kt45022.kt new file mode 100644 index 00000000000..b8fd8d7083b --- /dev/null +++ b/compiler/testData/ir/irText/expressions/kt45022.kt @@ -0,0 +1,12 @@ +// SKIP_KT_DUMP + +typealias AX = X + +fun test() { + X += 1 + AX += 1 +} + +object X { + operator fun plusAssign(any: Any) = Unit +} diff --git a/compiler/testData/ir/irText/expressions/kt45022.txt b/compiler/testData/ir/irText/expressions/kt45022.txt new file mode 100644 index 00000000000..7809e75f226 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/kt45022.txt @@ -0,0 +1,35 @@ +FILE fqName: fileName:/kt45022.kt + TYPEALIAS name:AX visibility:public expandedType:.X + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' type=kotlin.Unit origin=PLUSEQ + $this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X + any: CONST Int type=kotlin.Int value=1 + CALL 'public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' type=kotlin.Unit origin=PLUSEQ + $this: GET_OBJECT 'CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X + any: CONST Int type=kotlin.Int value=1 + CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.X + CONSTRUCTOR visibility:private <> () returnType:.X [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:X modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:plusAssign visibility:public modality:FINAL <> ($this:.X, any:kotlin.Any) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER name: type:.X + VALUE_PARAMETER name:any index:0 type:kotlin.Any + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun plusAssign (any: kotlin.Any): kotlin.Unit [operator] declared in .X' + GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index a54c619c34d..a636d7b31ba 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -25344,6 +25344,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @Test + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @Test @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index b145c3735d4..11d91fb81ae 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -25344,6 +25344,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @Test + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @Test @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index ceff6e39e78..a1a4dc7681f 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -1346,6 +1346,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/expressions/kt37779.kt"); } + @Test + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/ir/irText/expressions/kt45022.kt"); + } + @Test @TestMetadata("lambdaInCAO.kt") public void testLambdaInCAO() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 5f14b1c8bea..09a84c914c0 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -21544,6 +21544,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); } + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 683bca7103b..491dcd822bb 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -17204,6 +17204,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 860b8daad47..fda916303a0 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -16689,6 +16689,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index ffa34fb50c2..67e5a2ac3f2 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -16754,6 +16754,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/operatorConventions/kt44647.kt"); } + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index bb1aae8e6a8..6a54105c50d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -10520,6 +10520,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/operatorConventions/kt4152.kt"); } + @TestMetadata("kt45022.kt") + public void testKt45022() throws Exception { + runTest("compiler/testData/codegen/box/operatorConventions/kt45022.kt"); + } + @TestMetadata("kt4987.kt") public void testKt4987() throws Exception { runTest("compiler/testData/codegen/box/operatorConventions/kt4987.kt"); From 741c1a864f2dadfa0c8a19f31f2d6048b7d6cb89 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Tue, 16 Feb 2021 09:24:49 +0100 Subject: [PATCH 273/368] JVM_IR: IC: Unbox inline class argument of callable reference if it is unbound and the underlying type is reference type. If the underlying type is primitive, it is boxed and unboxed correctly, otherwise, it is simply casted and not unboxed. Additionally, generate functions for inliner with inline classes in signature, so unboxing works. The unboxing is removed after inlining. #KT-44722 Fixed --- .../FirBlackBoxCodegenTestGenerated.java | 52 +++++++++++++++++++ .../backend/jvm/codegen/ExpressionCodegen.kt | 15 ++++++ .../jvm/codegen/MethodSignatureMapper.kt | 31 ++++++++--- .../jvm/lower/inlineclasses/InlineClassAbi.kt | 8 +++ ...CallableReferencePassedToInlineFunction.kt | 4 +- .../callableReferences/let/any.kt | 22 ++++++++ .../callableReferences/let/anyN.kt | 22 ++++++++ .../callableReferences/let/int.kt | 24 +++++++++ .../callableReferences/let/intN.kt | 24 +++++++++ .../callableReferences/let/result.kt | 23 ++++++++ .../callableReferences/let/string.kt | 22 ++++++++ .../callableReferences/let/stringN.kt | 22 ++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 52 +++++++++++++++++++ .../IrBlackBoxCodegenTestGenerated.java | 52 +++++++++++++++++++ .../LightAnalysisModeTestGenerated.java | 48 +++++++++++++++++ .../IrJsCodegenBoxES6TestGenerated.java | 48 +++++++++++++++++ .../IrJsCodegenBoxTestGenerated.java | 48 +++++++++++++++++ .../semantics/JsCodegenBoxTestGenerated.java | 48 +++++++++++++++++ .../IrCodegenBoxWasmTestGenerated.java | 48 +++++++++++++++++ 19 files changed, 604 insertions(+), 9 deletions(-) create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index af7a523537f..af28c640ed0 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -18214,6 +18214,58 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + public class Let { + @Test + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @Test + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @Test + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @Test + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @Test + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @Test + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @Test + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @Nested diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 11790f03c22..0aa7333d22b 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -15,6 +15,8 @@ import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound import org.jetbrains.kotlin.backend.jvm.ir.isFromJava import org.jetbrains.kotlin.backend.jvm.lower.MultifileFacadeFileEntry import org.jetbrains.kotlin.backend.jvm.lower.constantValue +import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.isInlineCallableReference +import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.isMappedToPrimitive import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.unboxInlineClass import org.jetbrains.kotlin.backend.jvm.lower.isMultifileBridge import org.jetbrains.kotlin.backend.jvm.lower.suspendFunctionOriginal @@ -625,14 +627,27 @@ class ExpressionCodegen( val type = frameMap.typeOf(expression.symbol) mv.load(findLocalIndex(expression.symbol), type) unboxResultIfNeeded(expression) + unboxInlineClassArgumentOfInlineCallableReference(expression) return MaterialValue(this, type, expression.type) } + // JVM_IR generates inline callable differently from the old backend: + // it generates them as normal functions and not objects. + // Thus, we need to unbox inline class argument with reference underlying type. + private fun unboxInlineClassArgumentOfInlineCallableReference(arg: IrGetValue) { + if (!arg.type.isInlined()) return + if (arg.type.isMappedToPrimitive) return + if (!irFunction.isInlineCallableReference) return + if (irFunction.extensionReceiverParameter?.symbol == arg.symbol) return + StackValue.unboxInlineClass(OBJECT_TYPE, arg.type.erasedUpperBound.defaultType.toIrBasedKotlinType(), mv) + } + // We do not mangle functions if Result is the only parameter of the function, // thus, if the function overrides generic parameter, its argument is boxed and there is no // bridge to unbox it. Instead, we unbox it in the non-mangled function manually. private fun unboxResultIfNeeded(arg: IrGetValue) { if (arg.type.erasedUpperBound.fqNameWhenAvailable != StandardNames.RESULT_FQ_NAME) return + // Do not unbox arguments of lambda, but unbox arguments of callable references if (irFunction.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA) return if (!onlyResultInlineClassParameters()) return if (irFunction !is IrSimpleFunction) return diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt index bc16a88365f..c885a659577 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt @@ -12,6 +12,8 @@ import org.jetbrains.kotlin.backend.common.lower.parentsWithSelf import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.ir.* +import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.isInlineCallableReference +import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.isMappedToPrimitive import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.unboxInlineClass import org.jetbrains.kotlin.backend.jvm.lower.suspendFunctionOriginal import org.jetbrains.kotlin.builtins.StandardNames @@ -60,7 +62,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { fun mapFieldSignature(field: IrField): String? { val sw = BothSignatureWriter(BothSignatureWriter.Mode.TYPE) if (field.correspondingPropertySymbol?.owner?.isVar == true) { - writeParameterType(sw, field.type, field) + writeParameterType(sw, field.type, field, false) } else { mapReturnType(field, field.type, sw) } @@ -219,6 +221,13 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { function.origin == JvmLoweredDeclarationOrigin.SYNTHETIC_INLINE_CLASS_MEMBER && function.name.asString() == "box-impl" + private fun forceBoxedInlineClassParametersForInliner(function: IrDeclaration, type: IrType, isBoundReceiver: Boolean): Boolean { + if (isBoundReceiver) return false + if (function !is IrSimpleFunction) return false + if (!function.isInlineCallableReference) return false + return type.isInlined() && !type.isMappedToPrimitive + } + fun mapSignatureSkipGeneric(function: IrFunction): JvmMethodSignature = mapSignature(function, true) @@ -243,7 +252,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { val receiverParameter = function.extensionReceiverParameter if (receiverParameter != null) { - writeParameter(sw, JvmMethodParameterKind.RECEIVER, receiverParameter.type, function) + writeParameter(sw, JvmMethodParameterKind.RECEIVER, receiverParameter.type, function, true) } for (parameter in function.valueParameters) { @@ -256,7 +265,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { if (shouldBoxSingleValueParameterForSpecialCaseOfRemove(function)) parameter.type.makeNullable() else parameter.type - writeParameter(sw, kind, type, function) + writeParameter(sw, kind, type, function, parameter.symbol == function.extensionReceiverParameter?.symbol) } sw.writeReturnType() @@ -318,15 +327,23 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { return irFunction.allOverridden(false).any { it.parent.kotlinFqName == StandardNames.FqNames.mutableCollection } } - private fun writeParameter(sw: JvmSignatureWriter, kind: JvmMethodParameterKind, type: IrType, function: IrFunction) { + private fun writeParameter( + sw: JvmSignatureWriter, + kind: JvmMethodParameterKind, + type: IrType, + function: IrFunction, + isReceiver: Boolean + ) { sw.writeParameterType(kind) - writeParameterType(sw, type, function) + writeParameterType(sw, type, function, isReceiver) sw.writeParameterTypeEnd() } - private fun writeParameterType(sw: JvmSignatureWriter, type: IrType, declaration: IrDeclaration) { + private fun writeParameterType(sw: JvmSignatureWriter, type: IrType, declaration: IrDeclaration, isReceiver: Boolean) { if (sw.skipGenericSignature()) { - if (type.isInlined() && declaration.isFromJava()) { + if (type.isInlined() && + (declaration.isFromJava() || forceBoxedInlineClassParametersForInliner(declaration, type, isReceiver)) + ) { typeMapper.mapType(type, TypeMappingMode.GENERIC_ARGUMENT, sw) } else { typeMapper.mapType(type, TypeMappingMode.DEFAULT, sw) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt index 8ffab3c343f..37e39052d9e 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt @@ -166,3 +166,11 @@ val IrFunction.isInlineClassFieldGetter: Boolean val IrFunction.isPrimaryInlineClassConstructor: Boolean get() = this is IrConstructor && isPrimary && constructedClass.isInline + +val IrFunction.isInlineCallableReference: Boolean + get() = origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA && name.asString().contains("\$stub_for_inlining") + +val IrType.isMappedToPrimitive: Boolean + get() = isInlined() && + !(isNullable() && makeNotNull().unboxInlineClass().isNullable()) && + makeNotNull().unboxInlineClass().isPrimitiveType() \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt b/compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt index 2843b975a31..bdb86ee439d 100644 --- a/compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt +++ b/compiler/testData/codegen/box/inlineClasses/boundCallableReferencePassedToInlineFunction.kt @@ -54,11 +54,11 @@ fun box(): String { val a = IcAny(5) val o = IcOverIc(IcLong(6)) - if (testUnboxed(i, l, a, o) != "345IcLong(l=6)") return "Fail 1" + if (testUnboxed(i, l, a, o) != "345IcLong(l=6)") return "Fail 1 ${testUnboxed(i, l, a, o)}" if (testBoxed(i, l, a, o) != "345IcLong(l=6)") return "Fail 2" if (testLocalVars() != "012IcLong(l=3)") return "Fail 3" if (testGlobalProperties() != "123IcLong(l=4)") return "Fail 4" - if (testCapturedVars() != "234IcLong(l=5)") return "Fail 5" + if (testCapturedVars() != "234IcLong(l=5)") return "Fail 5 ${testCapturedVars()}" return "OK" } diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt new file mode 100644 index 00000000000..1e68b5d1782 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt @@ -0,0 +1,22 @@ +inline class Value(val value: Any) + +object Foo { + fun foo(value: Value) { + res = value.value as String + } + + fun bar(value: Value?) { + res = value?.value as String + } +} + +var res = "FAIL" + +fun box(): String { + Value("OK").let(Foo::foo) + if (res != "OK") return "FAIL 1: $res" + res = "FAIL" + + Value("OK").let(Foo::bar) + return res +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt new file mode 100644 index 00000000000..baba06fb8bb --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt @@ -0,0 +1,22 @@ +inline class Value(val value: Any?) + +object Foo { + fun foo(value: Value) { + res = value.value as String + } + + fun bar(value: Value?) { + res = value?.value as String + } +} + +var res = "FAIL" + +fun box(): String { + Value("OK").let(Foo::foo) + if (res != "OK") return "FAIL 1: $res" + res = "FAIL" + + Value("OK").let(Foo::bar) + return res +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt new file mode 100644 index 00000000000..b1e80d89ed0 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt @@ -0,0 +1,24 @@ +inline class Value(val value: Int) + +object Foo { + fun foo(value: Value) { + res = value.value + } + + fun bar(value: Value?) { + res = value?.value!! + } +} + +var res = 0 + +fun box(): String { + Value(42).let(Foo::foo) + if (res != 42) return "FAIL 1 $res" + res = 0 + + Value(42).let(Foo::bar) + if (res != 42) return "FAIL 2 $res" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt new file mode 100644 index 00000000000..cbb86d633f6 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt @@ -0,0 +1,24 @@ +inline class Value(val value: Int?) + +object Foo { + fun foo(value: Value) { + res = value.value!! + } + + fun bar(value: Value?) { + res = value?.value!! + } +} + +var res = 0 + +fun box(): String { + Value(42).let(Foo::foo) + if (res != 42) return "FAIL 1 $res" + res = 0 + + Value(42).let(Foo::bar) + if (res != 42) return "FAIL 2 $res" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt new file mode 100644 index 00000000000..70021248e67 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt @@ -0,0 +1,23 @@ +// WITH_RUNTIME +// KJS_WITH_FULL_RUNTIME + +object Foo { + fun foo(result: Result) { + res = result.getOrNull()!! + } + + fun bar(result: Result?) { + res = result?.getOrNull()!! + } +} + +var res = "FAIL" + +fun box(): String { + Result.success("OK").let(Foo::foo) + if (res != "OK") return "FAIL 1 $res" + res = "FAIL" + + Result.success("OK").let(Foo::bar) + return res +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt new file mode 100644 index 00000000000..f28dba61fd6 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt @@ -0,0 +1,22 @@ +inline class Value(val value: String) + +object Foo { + fun foo(value: Value) { + res = value.value + } + + fun bar(value: Value?) { + res = value?.value!! + } +} + +var res = "FAIL" + +fun box(): String { + Value("OK").let(Foo::foo) + if (res != "OK") return "FAIL 1: $res" + res = "FAIL" + + Value("OK").let(Foo::bar) + return res +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt new file mode 100644 index 00000000000..5a66c2a727a --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt @@ -0,0 +1,22 @@ +inline class Value(val value: String?) + +object Foo { + fun foo(value: Value) { + res = value.value!! + } + + fun bar(value: Value?) { + res = value?.value!! + } +} + +var res = "FAIL" + +fun box(): String { + Value("OK").let(Foo::foo) + if (res != "OK") return "FAIL 1: $res" + res = "FAIL" + + Value("OK").let(Foo::bar) + return res +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index a636d7b31ba..c05ea81c681 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -18214,6 +18214,58 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + public class Let { + @Test + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @Test + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @Test + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @Test + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @Test + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @Test + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @Test + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @Nested diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 11d91fb81ae..74aeafa291a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -18214,6 +18214,58 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @Nested + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + public class Let { + @Test + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @Test + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @Test + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @Test + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @Test + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @Test + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @Test + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @Nested diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 09a84c914c0..640a8f49110 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -15168,6 +15168,54 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Let extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 491dcd822bb..9c44c09e21d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -13343,6 +13343,54 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Let extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index fda916303a0..bae8d522aad 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -12828,6 +12828,54 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Let extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 67e5a2ac3f2..e2ae4ca6ee8 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -12893,6 +12893,54 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Let extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 6a54105c50d..15b59cf2c7b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -7089,6 +7089,54 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest public void testKt37986() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt"); } + + @TestMetadata("compiler/testData/codegen/box/inlineClasses/callableReferences/let") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Let extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInLet() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/callableReferences/let"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @TestMetadata("any.kt") + public void testAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/any.kt"); + } + + @TestMetadata("anyN.kt") + public void testAnyN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/anyN.kt"); + } + + @TestMetadata("int.kt") + public void testInt() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/int.kt"); + } + + @TestMetadata("intN.kt") + public void testIntN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/intN.kt"); + } + + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt"); + } + + @TestMetadata("string.kt") + public void testString() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/string.kt"); + } + + @TestMetadata("stringN.kt") + public void testStringN() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/callableReferences/let/stringN.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/inlineClasses/contextsAndAccessors") From cacd84390e522a96fbc3fca9236db6a3b6454a78 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Wed, 17 Feb 2021 14:26:59 +0100 Subject: [PATCH 274/368] Use erased upper bound instead of checking for inline type --- .../kotlin/backend/jvm/codegen/ExpressionCodegen.kt | 3 ++- .../kotlin/backend/jvm/codegen/MethodSignatureMapper.kt | 2 +- .../backend/jvm/lower/InlineCallableReferenceToLambda.kt | 4 +++- .../kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt | 5 +++-- .../box/inlineClasses/callableReferences/let/result.kt | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 0aa7333d22b..7897b0aa9c0 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -635,10 +635,11 @@ class ExpressionCodegen( // it generates them as normal functions and not objects. // Thus, we need to unbox inline class argument with reference underlying type. private fun unboxInlineClassArgumentOfInlineCallableReference(arg: IrGetValue) { - if (!arg.type.isInlined()) return + if (!arg.type.erasedUpperBound.isInline) return if (arg.type.isMappedToPrimitive) return if (!irFunction.isInlineCallableReference) return if (irFunction.extensionReceiverParameter?.symbol == arg.symbol) return + if (arg.type.isNullable() && arg.type.makeNotNull().unboxInlineClass().isNullable()) return StackValue.unboxInlineClass(OBJECT_TYPE, arg.type.erasedUpperBound.defaultType.toIrBasedKotlinType(), mv) } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt index c885a659577..5bec4388da2 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt @@ -225,7 +225,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { if (isBoundReceiver) return false if (function !is IrSimpleFunction) return false if (!function.isInlineCallableReference) return false - return type.isInlined() && !type.isMappedToPrimitive + return type.erasedUpperBound.isInline && !type.isMappedToPrimitive } fun mapSignatureSkipGeneric(function: IrFunction): JvmMethodSignature = diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt index 117a35e05ef..3299eee777a 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt @@ -59,6 +59,8 @@ internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendConte } } +const val STUB_FOR_INLINING = "stub_for_inlining" + private class InlineCallableReferenceToLambdaTransformer( val context: JvmBackendContext, val inlinableReferences: Set> @@ -140,7 +142,7 @@ private class InlineCallableReferenceToLambdaTransformer( val function = context.irFactory.buildFun { setSourceRange(expression) origin = IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA - name = Name.identifier("stub_for_inlining") + name = Name.identifier(STUB_FOR_INLINING) visibility = DescriptorVisibilities.LOCAL returnType = referencedFunction.returnType isSuspend = referencedFunction.isSuspend diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt index 37e39052d9e..985779d8149 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/InlineClassAbi.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.backend.jvm.lower.inlineclasses import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound +import org.jetbrains.kotlin.backend.jvm.lower.STUB_FOR_INLINING import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.codegen.state.InfoForMangling import org.jetbrains.kotlin.codegen.state.collectFunctionSignatureForManglingSuffix @@ -168,9 +169,9 @@ val IrFunction.isPrimaryInlineClassConstructor: Boolean get() = this is IrConstructor && isPrimary && constructedClass.isInline val IrFunction.isInlineCallableReference: Boolean - get() = origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA && name.asString().contains("\$stub_for_inlining") + get() = origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA && name.asString().contains("\$$STUB_FOR_INLINING") val IrType.isMappedToPrimitive: Boolean - get() = isInlined() && + get() = erasedUpperBound.isInline && !(isNullable() && makeNotNull().unboxInlineClass().isNullable()) && makeNotNull().unboxInlineClass().isPrimitiveType() \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt index 70021248e67..9fc9f2473f9 100644 --- a/compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt +++ b/compiler/testData/codegen/box/inlineClasses/callableReferences/let/result.kt @@ -1,5 +1,6 @@ // WITH_RUNTIME // KJS_WITH_FULL_RUNTIME +// IGNORE_BACKEND: WASM object Foo { fun foo(result: Result) { From 51da54ce669ae5ad0024ffc4ec329888dd8ff23b Mon Sep 17 00:00:00 2001 From: Tianyu Geng Date: Wed, 17 Feb 2021 15:29:57 -0800 Subject: [PATCH 275/368] FIR IDE: Simplify registerPsiQuickFixes This change makes it possible to register multiple fixes for a diagnostic. Also, the previous registerPsiQuickFix that relies compiler to infer the KtFirDiagnostic type parameter is dangerous since it can silently register fixes on interface `KtDiagnosticWithPsi` if caller doesn't specify it explicitly. --- .../idea/fir/api/fixes/KtQuickFixesList.kt | 13 ++++--- .../idea/quickfix/MainKtQuickFixRegistrar.kt | 24 ++++++------ .../kotlin/idea/quickfix/RemoveModifierFix.kt | 5 ++- .../kotlin/idea/quickfix/QuickFixRegistrar.kt | 37 +++++++++---------- .../nj2k/postProcessing/J2kPostProcessor.kt | 4 +- 5 files changed, 43 insertions(+), 40 deletions(-) diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/fixes/KtQuickFixesList.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/fixes/KtQuickFixesList.kt index 511342d768b..75a2a5aef84 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/fixes/KtQuickFixesList.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/api/fixes/KtQuickFixesList.kt @@ -56,10 +56,13 @@ class KtQuickFixesListBuilder private constructor() { private val quickFixes = mutableMapOf>, MutableList>() @OptIn(PrivateForInline::class) - inline fun > registerPsiQuickFix( - quickFixFactory: QuickFixesPsiBasedFactory + fun > registerPsiQuickFixes( + diagnosticClass: KClass, + vararg quickFixFactories: QuickFixesPsiBasedFactory ) { - registerPsiQuickFix(DIAGNOSTIC::class, quickFixFactory) + for (quickFixFactory in quickFixFactories) { + registerPsiQuickFix(diagnosticClass, quickFixFactory) + } } @OptIn(PrivateForInline::class) @@ -72,7 +75,7 @@ class KtQuickFixesListBuilder private constructor() { @PrivateForInline fun > registerPsiQuickFix( diagnosticClass: KClass, - quickFixFactory: QuickFixesPsiBasedFactory + quickFixFactory: QuickFixesPsiBasedFactory ) { quickFixes.getOrPut(diagnosticClass) { mutableListOf() }.add(HLQuickFixFactory.HLQuickFixesPsiBasedFactory(quickFixFactory)) } @@ -118,4 +121,4 @@ private fun List>>.merge(): Map> { } @RequiresOptIn -annotation class ForKtQuickFixesListBuilder() \ No newline at end of file +annotation class ForKtQuickFixesListBuilder() diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt index d0f59fb5b8f..0df8f195949 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt @@ -5,24 +5,22 @@ package org.jetbrains.kotlin.idea.quickfix -import com.intellij.psi.PsiElement import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixRegistrar import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesList import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesListBuilder import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic import org.jetbrains.kotlin.idea.quickfix.fixes.ChangeTypeQuickFix import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.psi.KtModifierListOwner -import org.jetbrains.kotlin.psi.KtParameter class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { private val modifiers = KtQuickFixesListBuilder.registerPsiQuickFix { - registerPsiQuickFix(RemoveModifierFix.createRemoveModifierFactory(isRedundant = true)) - registerPsiQuickFix(RemoveModifierFix.createRemoveModifierFactory(isRedundant = false)) - registerPsiQuickFix(RemoveModifierFix.createRemoveModifierFactory(isRedundant = false)) - registerPsiQuickFix(RemoveModifierFix.createRemoveModifierFactory(isRedundant = true)) - registerPsiQuickFix(RemoveModifierFix.createRemoveModifierFactory(isRedundant = true)) - registerPsiQuickFix( + registerPsiQuickFixes(KtFirDiagnostic.RedundantModifier::class, RemoveModifierFix.removeRedundantModifier) + registerPsiQuickFixes(KtFirDiagnostic.IncompatibleModifiers::class, RemoveModifierFix.removeNonRedundantModifier) + registerPsiQuickFixes(KtFirDiagnostic.RepeatedModifier::class, RemoveModifierFix.removeNonRedundantModifier) + registerPsiQuickFixes(KtFirDiagnostic.DeprecatedModifierPair::class, RemoveModifierFix.removeRedundantModifier) + registerPsiQuickFixes(KtFirDiagnostic.TypeParametersInEnum::class, RemoveModifierFix.removeRedundantModifier) + registerPsiQuickFixes( + KtFirDiagnostic.RedundantOpenInInterface::class, RemoveModifierFix.createRemoveModifierFromListOwnerFactoryByModifierListOwner( modifier = KtTokens.OPEN_KEYWORD, isRedundant = true @@ -37,9 +35,9 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { } private val mutability = KtQuickFixesListBuilder.registerPsiQuickFix { - registerPsiQuickFix(ChangeVariableMutabilityFix.VAR_OVERRIDDEN_BY_VAL_FACTORY) - registerPsiQuickFix(ChangeVariableMutabilityFix.VAR_ANNOTATION_PARAMETER_FACTORY) - registerPsiQuickFix(ChangeVariableMutabilityFix.LATEINIT_VAL_FACTORY) + registerPsiQuickFixes(KtFirDiagnostic.VarOverriddenByVal::class, ChangeVariableMutabilityFix.VAR_OVERRIDDEN_BY_VAL_FACTORY) + registerPsiQuickFixes(KtFirDiagnostic.VarAnnotationParameter::class, ChangeVariableMutabilityFix.VAR_ANNOTATION_PARAMETER_FACTORY) + registerPsiQuickFixes(KtFirDiagnostic.InapplicableLateinitModifier::class, ChangeVariableMutabilityFix.LATEINIT_VAL_FACTORY) } override val list: KtQuickFixesList = KtQuickFixesList.createCombined( @@ -47,4 +45,4 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { overrides, mutability, ) -} \ No newline at end of file +} diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt index 334b64845d7..c401253ba2d 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt @@ -51,6 +51,9 @@ class RemoveModifierFix( } companion object { + val removeRedundantModifier = createRemoveModifierFactory(isRedundant = true) + val removeNonRedundantModifier = createRemoveModifierFactory(isRedundant = false) + @Deprecated( "For binary compatibility", replaceWith = ReplaceWith("createRemoveModifierFromListOwnerPsiBasedFactory(modifier, isRedundant)") @@ -79,7 +82,7 @@ class RemoveModifierFix( listOf(RemoveModifierFix(it, modifier, isRedundant)) } - fun createRemoveModifierFactory(isRedundant: Boolean = false): QuickFixesPsiBasedFactory { + private fun createRemoveModifierFactory(isRedundant: Boolean = false): QuickFixesPsiBasedFactory { return quickFixesPsiBasedFactory { psiElement: PsiElement -> val elementType = psiElement.node.elementType as? KtModifierKeywordToken ?: return@quickFixesPsiBasedFactory emptyList() val modifierListOwner = psiElement.getStrictParentOfType() diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index b8410695ca2..07c4e400838 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -116,14 +116,14 @@ class QuickFixRegistrar : QuickFixContributor { USELESS_ELVIS.registerFactory(RemoveUselessElvisFix) USELESS_ELVIS_RIGHT_IS_NULL.registerFactory(RemoveUselessElvisFix) - val removeRedundantModifierFactory = RemoveModifierFix.createRemoveModifierFactory(true) + val removeRedundantModifierFactory = RemoveModifierFix.removeRedundantModifier REDUNDANT_MODIFIER.registerFactory(removeRedundantModifierFactory) REDUNDANT_OPEN_IN_INTERFACE.registerFactory(RemoveModifierFix.createRemoveModifierFromListOwnerPsiBasedFactory(OPEN_KEYWORD, true)) REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE.registerFactory(RemoveModifierFix.createRemoveSuspendFactory()) UNNECESSARY_LATEINIT.registerFactory(RemoveModifierFix.createRemoveModifierFromListOwnerPsiBasedFactory(LATEINIT_KEYWORD)) REDUNDANT_PROJECTION.registerFactory(RemoveModifierFix.createRemoveProjectionFactory(true)) - INCOMPATIBLE_MODIFIERS.registerFactory(RemoveModifierFix.createRemoveModifierFactory(false)) + INCOMPATIBLE_MODIFIERS.registerFactory(RemoveModifierFix.removeNonRedundantModifier) VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED.registerFactory(RemoveModifierFix.createRemoveVarianceFactory()) val removeOpenModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerPsiBasedFactory(OPEN_KEYWORD) @@ -133,27 +133,26 @@ class QuickFixRegistrar : QuickFixContributor { ) NON_FINAL_MEMBER_IN_OBJECT.registerFactory(removeOpenModifierFactory) - val removeModifierFactory = RemoveModifierFix.createRemoveModifierFactory() - GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY.registerFactory(removeModifierFactory) - SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY.registerFactory(removeModifierFactory) - PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY.registerFactory(removeModifierFactory) + GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY.registerFactory(RemoveModifierFix.removeNonRedundantModifier) + SETTER_VISIBILITY_INCONSISTENT_WITH_PROPERTY_VISIBILITY.registerFactory(RemoveModifierFix.removeNonRedundantModifier) + PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY.registerFactory(RemoveModifierFix.removeNonRedundantModifier) PRIVATE_SETTER_FOR_OPEN_PROPERTY.registerFactory( AddModifierFixMpp.createFactory(FINAL_KEYWORD, KtProperty::class.java), - removeModifierFactory + RemoveModifierFix.removeNonRedundantModifier ) REDUNDANT_MODIFIER_IN_GETTER.registerFactory(removeRedundantModifierFactory) - WRONG_MODIFIER_TARGET.registerFactory(removeModifierFactory, ConstValFactory) + WRONG_MODIFIER_TARGET.registerFactory(RemoveModifierFix.removeNonRedundantModifier, ConstValFactory) DEPRECATED_MODIFIER.registerFactory(ReplaceModifierFix) - REDUNDANT_MODIFIER_FOR_TARGET.registerFactory(removeModifierFactory) - WRONG_MODIFIER_CONTAINING_DECLARATION.registerFactory(removeModifierFactory) - REPEATED_MODIFIER.registerFactory(removeModifierFactory) - NON_PRIVATE_CONSTRUCTOR_IN_ENUM.registerFactory(removeModifierFactory) - NON_PRIVATE_CONSTRUCTOR_IN_SEALED.registerFactory(removeModifierFactory) - NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED.registerFactory(removeModifierFactory) - TYPE_CANT_BE_USED_FOR_CONST_VAL.registerFactory(removeModifierFactory) - DEPRECATED_BINARY_MOD.registerFactory(removeModifierFactory) + REDUNDANT_MODIFIER_FOR_TARGET.registerFactory(RemoveModifierFix.removeNonRedundantModifier) + WRONG_MODIFIER_CONTAINING_DECLARATION.registerFactory(RemoveModifierFix.removeNonRedundantModifier) + REPEATED_MODIFIER.registerFactory(RemoveModifierFix.removeNonRedundantModifier) + NON_PRIVATE_CONSTRUCTOR_IN_ENUM.registerFactory(RemoveModifierFix.removeNonRedundantModifier) + NON_PRIVATE_CONSTRUCTOR_IN_SEALED.registerFactory(RemoveModifierFix.removeNonRedundantModifier) + NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED.registerFactory(RemoveModifierFix.removeNonRedundantModifier) + TYPE_CANT_BE_USED_FOR_CONST_VAL.registerFactory(RemoveModifierFix.removeNonRedundantModifier) + DEPRECATED_BINARY_MOD.registerFactory(RemoveModifierFix.removeNonRedundantModifier) DEPRECATED_BINARY_MOD.registerFactory(RenameModToRemFix.Factory) - FORBIDDEN_BINARY_MOD.registerFactory(removeModifierFactory) + FORBIDDEN_BINARY_MOD.registerFactory(RemoveModifierFix.removeNonRedundantModifier) FORBIDDEN_BINARY_MOD.registerFactory(RenameModToRemFix.Factory) NO_EXPLICIT_VISIBILITY_IN_API_MODE.registerFactory(ChangeVisibilityFix.SetExplicitVisibilityFactory) @@ -604,7 +603,7 @@ class QuickFixRegistrar : QuickFixContributor { CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT.registerFactory( MoveMemberToCompanionObjectIntention, - RemoveModifierFix.createRemoveModifierFactory() + RemoveModifierFix.removeNonRedundantModifier ) NO_COMPANION_OBJECT.registerFactory(AddIsToWhenConditionFix) @@ -614,7 +613,7 @@ class QuickFixRegistrar : QuickFixContributor { RESOLUTION_TO_CLASSIFIER.registerFactory(ConvertToAnonymousObjectFix) - NOTHING_TO_INLINE.registerFactory(RemoveModifierFix.createRemoveModifierFactory(isRedundant = false)) + NOTHING_TO_INLINE.registerFactory(RemoveModifierFix.removeNonRedundantModifier) DECLARATION_CANT_BE_INLINED.registerFactory(DeclarationCantBeInlinedFactory) diff --git a/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/J2kPostProcessor.kt b/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/J2kPostProcessor.kt index 721e0d8e395..a8c0edf099b 100644 --- a/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/J2kPostProcessor.kt +++ b/nj2k/nj2k-services/src/org/jetbrains/kotlin/nj2k/postProcessing/J2kPostProcessor.kt @@ -141,7 +141,7 @@ private val errorsFixingDiagnosticBasedPostProcessingGroup = Errors.INVISIBLE_MEMBER ), diagnosticBasedProcessing( - RemoveModifierFix.createRemoveModifierFactory(), + RemoveModifierFix.removeNonRedundantModifier, Errors.WRONG_MODIFIER_TARGET ), diagnosticBasedProcessing( @@ -302,4 +302,4 @@ private val processings: List = listOf( FormatCodeProcessing() ) ) -) \ No newline at end of file +) From afe71f5d59bc032fabc6288983e4062745731688 Mon Sep 17 00:00:00 2001 From: tgeng Date: Thu, 18 Feb 2021 14:26:10 -0800 Subject: [PATCH 276/368] FIR: Add runConfig to generate FIR boilerplate (#4130) * FIR: Add runConfig to generate FIR boilerplate * FIR: Add runConfig to generate FIR boilerplate --- ...ker_Components_and_FIR_IDE_Diagnostics.xml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .idea/runConfigurations/Generate_FIR_Checker_Components_and_FIR_IDE_Diagnostics.xml diff --git a/.idea/runConfigurations/Generate_FIR_Checker_Components_and_FIR_IDE_Diagnostics.xml b/.idea/runConfigurations/Generate_FIR_Checker_Components_and_FIR_IDE_Diagnostics.xml new file mode 100644 index 00000000000..a5d3f936568 --- /dev/null +++ b/.idea/runConfigurations/Generate_FIR_Checker_Components_and_FIR_IDE_Diagnostics.xml @@ -0,0 +1,24 @@ + + + + + + + true + true + false + + + \ No newline at end of file From 8783ebc35248452933247cbb7a62e601ae852d2e Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Fri, 19 Feb 2021 05:46:04 +0000 Subject: [PATCH 277/368] Report highlight errors to WolfTheProblemSolver Relates to #KT-37702 #KTIJ-1246 Fixed Original commit: bd222a5255c2fd6f4abfce3115f81733ef9a39f3 --- .../kotlin/generators/tests/GenerateTests.kt | 4 + .../AbstractKotlinHighlightingPass.kt | 39 ++++++ .../idea/highlighter/HighlightingVisitor.kt | 1 - idea/testData/checker/wolf/diagnostic.kt | 3 + .../checker/wolf/diagnosticAfterSyntax.kt | 5 + idea/testData/checker/wolf/none.kt | 3 + idea/testData/checker/wolf/syntax.kt | 3 + .../AbstractKotlinHighlightWolfPassTest.kt | 117 ++++++++++++++++++ .../KotlinHighlightWolfPassTestGenerated.java | 51 ++++++++ .../AbstractOutOfBlockModificationTest.kt | 18 +-- 10 files changed, 234 insertions(+), 10 deletions(-) create mode 100644 idea/testData/checker/wolf/diagnostic.kt create mode 100644 idea/testData/checker/wolf/diagnosticAfterSyntax.kt create mode 100644 idea/testData/checker/wolf/none.kt create mode 100644 idea/testData/checker/wolf/syntax.kt create mode 100644 idea/tests/org/jetbrains/kotlin/checkers/AbstractKotlinHighlightWolfPassTest.kt create mode 100644 idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightWolfPassTestGenerated.java diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index f501b89dc74..9f52ebe9f2b 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -324,6 +324,10 @@ fun main(args: Array) { model("checker/diagnosticsMessage") } + testClass { + model("checker/wolf") + } + testClass { model("kotlinAndJavaChecker/javaAgainstKotlin") model("kotlinAndJavaChecker/javaWithKotlin") diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/AbstractKotlinHighlightingPass.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/AbstractKotlinHighlightingPass.kt index 3e9ae6bd035..f8924edc46c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/AbstractKotlinHighlightingPass.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/AbstractKotlinHighlightingPass.kt @@ -6,15 +6,23 @@ package org.jetbrains.kotlin.idea.highlighter import com.intellij.codeInsight.daemon.impl.Divider +import com.intellij.codeInsight.daemon.impl.HighlightInfo import com.intellij.codeInsight.intention.IntentionAction +import com.intellij.codeInsight.problems.ProblemImpl import com.intellij.lang.annotation.Annotation import com.intellij.lang.annotation.AnnotationHolder import com.intellij.lang.annotation.Annotator +import com.intellij.lang.annotation.HighlightSeverity import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.editor.Document +import com.intellij.openapi.project.Project import com.intellij.openapi.util.Key import com.intellij.openapi.util.TextRange +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.problems.Problem +import com.intellij.problems.WolfTheProblemSolver import com.intellij.psi.PsiElement +import com.intellij.psi.PsiManager import com.intellij.util.CommonProcessors import com.intellij.util.containers.MultiMap import org.jetbrains.kotlin.descriptors.DeclarationDescriptor @@ -44,6 +52,12 @@ abstract class AbstractKotlinHighlightingPass(file: KtFile, document: Document) } } + override fun doApplyInformationToEditor() { + super.doApplyInformationToEditor() + + reportErrorsToWolf() + } + override fun buildBindingContext(holder: AnnotationHolder): BindingContext { val dividedElements: List = ArrayList() Divider.divideInsideAndOutsideAllRoots( @@ -153,6 +167,31 @@ abstract class AbstractKotlinHighlightingPass(file: KtFile, document: Document) protected open fun shouldSuppressUnusedParameter(parameter: KtParameter): Boolean = false + private fun reportErrorsToWolf() { + if (!file.viewProvider.isPhysical) return // e.g. errors in evaluate expression + val project: Project = file.project + if (!PsiManager.getInstance(project).isInProject(file)) return // do not report problems in libraries + val file: VirtualFile = file.virtualFile ?: return + + val wolf = WolfTheProblemSolver.getInstance(project) + + val hasSyntaxErrors = wolf.hasSyntaxErrors(file) + val problemFile = wolf.isProblemFile(file) + + // do nothing if file has already problems + if (hasSyntaxErrors || problemFile) return + + val problems = convertToProblems(infos, file) + wolf.reportProblems(file, problems) + } + + private fun convertToProblems( + infos: Collection, + file: VirtualFile, + hasErrorElement: Boolean = true + ): List = + infos.filter { it.severity == HighlightSeverity.ERROR }.map { ProblemImpl(file, it, hasErrorElement) } + companion object { fun createQuickFixes(diagnostic: Diagnostic): Collection = createQuickFixes(listOfNotNull(diagnostic))[diagnostic] diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/highlighter/HighlightingVisitor.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/highlighter/HighlightingVisitor.kt index df4edf914ab..597a009daf7 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/highlighter/HighlightingVisitor.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/highlighter/HighlightingVisitor.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.idea.highlighter -import com.intellij.lang.annotation.Annotation import com.intellij.lang.annotation.AnnotationHolder import com.intellij.lang.annotation.HighlightSeverity import com.intellij.openapi.editor.colors.TextAttributesKey diff --git a/idea/testData/checker/wolf/diagnostic.kt b/idea/testData/checker/wolf/diagnostic.kt new file mode 100644 index 00000000000..bf03ca376fb --- /dev/null +++ b/idea/testData/checker/wolf/diagnostic.kt @@ -0,0 +1,3 @@ +// HAS-WOLF-ERRORS: true +// TYPE: .map +fun diagnostic(): String = "" \ No newline at end of file diff --git a/idea/testData/checker/wolf/diagnosticAfterSyntax.kt b/idea/testData/checker/wolf/diagnosticAfterSyntax.kt new file mode 100644 index 00000000000..ca02a2eab64 --- /dev/null +++ b/idea/testData/checker/wolf/diagnosticAfterSyntax.kt @@ -0,0 +1,5 @@ +// WOLF-ERRORS: true +// HAS-WOLF-ERRORS: true +// TYPE: asd +// ERROR: Overload resolution ambiguity:
public final operator fun plus(other: Byte): Int defined in kotlin.Int
public final operator fun plus(other: Double): Double defined in kotlin.Int
public final operator fun plus(other: Float): Float defined in kotlin.Int
public final operator fun plus(other: Int): Int defined in kotlin.Int
public final operator fun plus(other: Long): Long defined in kotlin.Int
public final operator fun plus(other: Short): Int defined in kotlin.Int +fun diagnosticAfterSyntax(): Int = 42 + \ No newline at end of file diff --git a/idea/testData/checker/wolf/none.kt b/idea/testData/checker/wolf/none.kt new file mode 100644 index 00000000000..02c4a2ad3fb --- /dev/null +++ b/idea/testData/checker/wolf/none.kt @@ -0,0 +1,3 @@ +// HAS-WOLF-ERRORS: false +// TYPE: +1 +fun none(): Int = 42 \ No newline at end of file diff --git a/idea/testData/checker/wolf/syntax.kt b/idea/testData/checker/wolf/syntax.kt new file mode 100644 index 00000000000..ff4b45dee4f --- /dev/null +++ b/idea/testData/checker/wolf/syntax.kt @@ -0,0 +1,3 @@ +// HAS-WOLF-ERRORS: true +// TYPE: + +fun syntax(): Int = 42 \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/checkers/AbstractKotlinHighlightWolfPassTest.kt b/idea/tests/org/jetbrains/kotlin/checkers/AbstractKotlinHighlightWolfPassTest.kt new file mode 100644 index 00000000000..d635c678b83 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/checkers/AbstractKotlinHighlightWolfPassTest.kt @@ -0,0 +1,117 @@ +package org.jetbrains.kotlin.checkers + +import com.intellij.codeInsight.problems.MockWolfTheProblemSolver +import com.intellij.codeInsight.problems.WolfTheProblemSolverImpl +import com.intellij.openapi.Disposable +import com.intellij.openapi.project.Project +import com.intellij.openapi.util.Disposer +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.problems.ProblemListener +import com.intellij.problems.WolfTheProblemSolver +import com.intellij.psi.PsiDocumentManager +import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture +import com.intellij.util.ThrowableRunnable +import junit.framework.TestCase +import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithAllCompilerChecks +import org.jetbrains.kotlin.idea.codeInsight.AbstractOutOfBlockModificationTest +import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils.checkForUnexpectedErrors +import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.test.runAll +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics +import org.jetbrains.kotlin.test.InTextDirectivesUtils + +abstract class AbstractKotlinHighlightWolfPassTest : KotlinLightCodeInsightFixtureTestCase() { + + private val disposable = Disposer.newDisposable("wolfTheProblemSolverParentDisposable") + private var wolfTheProblemSolver: MockWolfTheProblemSolver? = null + + override fun setUp() { + super.setUp() + wolfTheProblemSolver = prepareWolf(project, disposable) + } + + override fun tearDown() { + runAll( + // TODO: [VD] HAS TO BE UNCOMMENTED with 211 + //ThrowableRunnable { wolfTheProblemSolver?.resetDelegate() }, + ThrowableRunnable { Disposer.dispose(disposable) }, + ThrowableRunnable { super.tearDown() }, + ) + } + + private fun prepareWolf(project: Project, parentDisposable: Disposable): MockWolfTheProblemSolver { + val wolfTheProblemSolver = WolfTheProblemSolver.getInstance(project) as MockWolfTheProblemSolver + + // TODO: [VD] HAS TO BE UNCOMMENTED with 211 +// val theRealSolver = WolfTheProblemSolverImpl.createInstance(project) +// wolfTheProblemSolver.setDelegate(theRealSolver) +// Disposer.register(parentDisposable, (theRealSolver as Disposable)) + + return wolfTheProblemSolver + } + + open fun doTest(filePath: String) { + myFixture.configureByFile(fileName()) + val ktFile = file as KtFile + + myFixture.doHighlighting() + // have to analyze file before any change to support incremental analysis + val diagnosticsProvider: (KtFile) -> Diagnostics = { it.analyzeWithAllCompilerChecks().bindingContext.diagnostics } + checkForUnexpectedErrors(ktFile, diagnosticsProvider) + val wolf = WolfTheProblemSolver.getInstance(project) + val virtualFile = ktFile.virtualFile + val initialWolfErrors = wolfErrors(myFixture) + // TODO: [VD] HAS TO BE UNCOMMENTED with 211 + //TestCase.assertEquals(initialWolfErrors, wolf.isProblemFile(virtualFile) || wolf.hasSyntaxErrors(virtualFile)) + + var problemsAppeared = 0 + var problemsChanged = 0 + var problemsDisappeared = 0 + + project.messageBus.connect(disposable).subscribe(ProblemListener.TOPIC, object : ProblemListener { + override fun problemsAppeared(file: VirtualFile) { + problemsAppeared++ + } + + override fun problemsChanged(file: VirtualFile) { + problemsChanged++ + } + + override fun problemsDisappeared(file: VirtualFile) { + problemsDisappeared++ + } + }) + myFixture.type(AbstractOutOfBlockModificationTest.stringToType(myFixture)) + PsiDocumentManager.getInstance(project).commitDocument(myFixture.getDocument(ktFile)) + myFixture.doHighlighting() + + // TODO: [VD] HAS TO BE UNCOMMENTED with 211 +// val hasWolfErrors = hasWolfErrors(myFixture) +// assertEquals(hasWolfErrors, wolf.isProblemFile(virtualFile) || wolf.hasSyntaxErrors(virtualFile)) +// if (hasWolfErrors) { +// TestCase.assertTrue(problemsAppeared > 0) +// } else { +// assertEquals(0, problemsAppeared) +// } +// assertEquals(if (initialWolfErrors) 1 else 0, problemsDisappeared) + } + + companion object { + private const val HAS_WOLF_ERRORS_DIRECTIVE = "HAS-WOLF-ERRORS:" + + fun hasWolfErrors(fixture: JavaCodeInsightTestFixture): Boolean = findBooleanDirective(fixture, HAS_WOLF_ERRORS_DIRECTIVE) + + private const val WOLF_ERRORS_DIRECTIVE = "WOLF-ERRORS:" + + fun wolfErrors(fixture: JavaCodeInsightTestFixture): Boolean = findBooleanDirective(fixture, WOLF_ERRORS_DIRECTIVE) + + private fun findBooleanDirective( + fixture: JavaCodeInsightTestFixture, + wolfErrorsDirective: String + ): Boolean { + val text = fixture.getDocument(fixture.file).text + return InTextDirectivesUtils.findStringWithPrefixes(text, wolfErrorsDirective) == "true" + } + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightWolfPassTestGenerated.java b/idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightWolfPassTestGenerated.java new file mode 100644 index 00000000000..c7e4450c9a8 --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/checkers/KotlinHighlightWolfPassTestGenerated.java @@ -0,0 +1,51 @@ +/* + * Copyright 2010-2021 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.checkers; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/checker/wolf") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class KotlinHighlightWolfPassTestGenerated extends AbstractKotlinHighlightWolfPassTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInWolf() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/checker/wolf"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("diagnostic.kt") + public void testDiagnostic() throws Exception { + runTest("idea/testData/checker/wolf/diagnostic.kt"); + } + + @TestMetadata("diagnosticAfterSyntax.kt") + public void testDiagnosticAfterSyntax() throws Exception { + runTest("idea/testData/checker/wolf/diagnosticAfterSyntax.kt"); + } + + @TestMetadata("none.kt") + public void testNone() throws Exception { + runTest("idea/testData/checker/wolf/none.kt"); + } + + @TestMetadata("syntax.kt") + public void testSyntax() throws Exception { + runTest("idea/testData/checker/wolf/syntax.kt"); + } +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt index 931eed2f9c0..3f2afa66e72 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractOutOfBlockModificationTest.kt @@ -13,6 +13,7 @@ import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiManager import com.intellij.psi.impl.PsiModificationTrackerImpl import com.intellij.psi.util.PsiTreeUtil +import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture import org.jetbrains.kotlin.idea.FrontendInternals import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithAllCompilerChecks import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade @@ -52,7 +53,7 @@ abstract class AbstractOutOfBlockModificationTest : KotlinLightCodeInsightFixtur // have to analyze file before any change to support incremental analysis ktFile.analyzeWithAllCompilerChecks() - myFixture.type(stringToType) + myFixture.type(stringToType(myFixture)) PsiDocumentManager.getInstance(myFixture.project).commitDocument(myFixture.getDocument(myFixture.file)) val oobAfterCount = ktFile.outOfBlockModificationCount val modificationCountAfterType = tracker.modificationCount @@ -116,14 +117,6 @@ abstract class AbstractOutOfBlockModificationTest : KotlinLightCodeInsightFixtur } } - private val stringToType: String - get() { - val text = myFixture.getDocument(myFixture.file).text - val typeDirectives = - InTextDirectivesUtils.findStringWithPrefixes(text, TYPE_DIRECTIVE) - return if (typeDirectives != null) StringUtil.unescapeStringCharacters(typeDirectives) else "a" - } - private val expectedOutOfBlockResult: Boolean get() { val text = myFixture.getDocument(myFixture.file).text @@ -144,5 +137,12 @@ abstract class AbstractOutOfBlockModificationTest : KotlinLightCodeInsightFixtur const val OUT_OF_CODE_BLOCK_DIRECTIVE = "OUT_OF_CODE_BLOCK:" const val SKIP_ANALYZE_CHECK_DIRECTIVE = "SKIP_ANALYZE_CHECK" const val TYPE_DIRECTIVE = "TYPE:" + + fun stringToType(fixture: JavaCodeInsightTestFixture): String { + val text = fixture.getDocument(fixture.file).text + val typeDirectives = + InTextDirectivesUtils.findStringWithPrefixes(text, TYPE_DIRECTIVE) + return if (typeDirectives != null) StringUtil.unescapeStringCharacters(typeDirectives) else "a" + } } } \ No newline at end of file From 52ea7fdb72be044085ed595dd0fc00bce8c34da7 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Mon, 8 Feb 2021 22:32:30 -0800 Subject: [PATCH 278/368] FIR: ensure type ref after supertype resolve transformer is resolved --- .../transformers/FirSupertypesResolution.kt | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt index a583654d320..033e05f3a0d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.expressions.FirStatement import org.jetbrains.kotlin.fir.extensions.extensionService import org.jetbrains.kotlin.fir.extensions.predicateBasedProvider import org.jetbrains.kotlin.fir.extensions.supertypeGenerators +import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.LocalClassesNavigationInfo import org.jetbrains.kotlin.fir.scopes.FirCompositeScope @@ -112,7 +113,7 @@ private class FirApplySupertypesTransformer( return super.transformAnonymousObject(anonymousObject, data) } - private fun getResolvedSupertypeRefs(classLikeDeclaration: FirClassLikeDeclaration<*>): List { + private fun getResolvedSupertypeRefs(classLikeDeclaration: FirClassLikeDeclaration<*>): List { val status = supertypeComputationSession.getSupertypesComputationStatus(classLikeDeclaration) require(status is SupertypeComputationStatus.Computed) { "Unexpected status at FirApplySupertypesTransformer: $status for ${classLikeDeclaration.symbol.classId}" @@ -248,7 +249,7 @@ private class FirSupertypeResolverVisitor( private fun resolveSpecificClassLikeSupertypes( classLikeDeclaration: FirClassLikeDeclaration<*>, - resolveSuperTypeRefs: (FirTransformer, FirScope) -> List + resolveSuperTypeRefs: (FirTransformer, FirScope) -> List ): List { when (val status = supertypeComputationSession.getSupertypesComputationStatus(classLikeDeclaration)) { is SupertypeComputationStatus.Computed -> return status.supertypeRefs @@ -282,23 +283,26 @@ private class FirSupertypeResolverVisitor( supertypeRefs: List ): List { return resolveSpecificClassLikeSupertypes(classLikeDeclaration) { transformer, scope -> - ArrayList(supertypeRefs).mapTo(mutableListOf()) { + supertypeRefs.mapTo(mutableListOf()) { val superTypeRef = transformer.transformTypeRef(it, scope).single - - if (superTypeRef.coneTypeSafe() != null) - createErrorTypeRef( - superTypeRef, - "Type parameter cannot be a super-type: ${superTypeRef.coneTypeUnsafe().render()}" - ) - else - superTypeRef + when { + superTypeRef.coneTypeSafe() != null -> + createErrorTypeRef( + superTypeRef, + "Type parameter cannot be a super-type: ${superTypeRef.coneTypeUnsafe().render()}" + ) + superTypeRef !is FirResolvedTypeRef -> + createErrorTypeRef(superTypeRef, "Unresolved super-type: ${superTypeRef.render()}") + else -> + superTypeRef + } }.also { addSupertypesFromExtensions(classLikeDeclaration, it) } } } - private fun addSupertypesFromExtensions(klass: FirClassLikeDeclaration<*>, supertypeRefs: MutableList) { + private fun addSupertypesFromExtensions(klass: FirClassLikeDeclaration<*>, supertypeRefs: MutableList) { if (supertypeGenerationExtensions.isEmpty()) return val provider = session.predicateBasedProvider for (extension in supertypeGenerationExtensions) { @@ -384,7 +388,7 @@ private class SupertypeComputationSession { supertypeStatusMap[classLikeDeclaration] = SupertypeComputationStatus.Computing } - fun storeSupertypes(classLikeDeclaration: FirClassLikeDeclaration<*>, resolvedTypesRefs: List) { + fun storeSupertypes(classLikeDeclaration: FirClassLikeDeclaration<*>, resolvedTypesRefs: List) { require(supertypeStatusMap[classLikeDeclaration] is SupertypeComputationStatus.Computing) { "Unexpected in storeSupertypes supertype status for $classLikeDeclaration: ${supertypeStatusMap[classLikeDeclaration]}" } @@ -411,7 +415,7 @@ private class SupertypeComputationSession { } val typeRefs = supertypeComputationStatus.supertypeRefs - val resultingTypeRefs = mutableListOf() + val resultingTypeRefs = mutableListOf() var wereChanges = false for (typeRef in typeRefs) { @@ -453,7 +457,7 @@ sealed class SupertypeComputationStatus { object NotComputed : SupertypeComputationStatus() object Computing : SupertypeComputationStatus() - class Computed(val supertypeRefs: List) : SupertypeComputationStatus() + class Computed(val supertypeRefs: List) : SupertypeComputationStatus() } private typealias ScopePersistentList = PersistentList From fbb19e3b50dbadd17a088ca459e3d6ab6a1d4dc7 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Mon, 8 Feb 2021 23:23:47 -0800 Subject: [PATCH 279/368] FIR: ensure type ref transformed by type resolve transformer is resolved --- .../FirSpecificTypeResolverTransformer.kt | 11 +++++++---- .../resolve/transformers/FirTypeResolveTransformer.kt | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt index dde33c42004..7443b9003aa 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt @@ -38,12 +38,15 @@ class FirSpecificTypeResolverTransformer( } } - override fun transformTypeRef(typeRef: FirTypeRef, data: FirScope): CompositeTransformResult { + override fun transformTypeRef(typeRef: FirTypeRef, data: FirScope): CompositeTransformResult { typeRef.transformChildren(this, data) return transformType(typeRef, typeResolver.resolveType(typeRef, data, areBareTypesAllowed)) } - override fun transformFunctionTypeRef(functionTypeRef: FirFunctionTypeRef, data: FirScope): CompositeTransformResult { + override fun transformFunctionTypeRef( + functionTypeRef: FirFunctionTypeRef, + data: FirScope + ): CompositeTransformResult { functionTypeRef.transformChildren(this, data) val resolvedType = typeResolver.resolveType(functionTypeRef, data, areBareTypesAllowed).takeIfAcceptable() return if (resolvedType != null && resolvedType !is ConeClassErrorType) { @@ -62,11 +65,11 @@ class FirSpecificTypeResolverTransformer( }.compose() } - private fun transformType(typeRef: FirTypeRef, resolvedType: ConeKotlinType): CompositeTransformResult { + private fun transformType(typeRef: FirTypeRef, resolvedType: ConeKotlinType): CompositeTransformResult { return if (resolvedType !is ConeClassErrorType) { buildResolvedTypeRef { source = typeRef.source - type = resolvedType.takeIfAcceptable() ?: return typeRef.compose() + type = resolvedType annotations += typeRef.annotations delegatedTypeRef = typeRef } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt index 64bbe27c43f..78ce3337228 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt @@ -168,7 +168,7 @@ class FirTypeResolveTransformer( return implicitTypeRef.compose() } - override fun transformTypeRef(typeRef: FirTypeRef, data: Nothing?): CompositeTransformResult { + override fun transformTypeRef(typeRef: FirTypeRef, data: Nothing?): CompositeTransformResult { return typeRef.transform(typeResolverTransformer, towerScope) } From 9aaa952b39b0e7882e7eb78b3ed981ed7a84ddac Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Tue, 9 Feb 2021 00:27:04 -0800 Subject: [PATCH 280/368] FIR: regard implicit type for value parameter after body resolve as an error type --- .../checkers/expression/FirCatchParameterChecker.kt | 8 ++------ .../body/resolve/FirBodyResolveTransformer.kt | 2 +- .../body/resolve/FirDeclarationsResolveTransformer.kt | 3 +++ .../basic/common/annotations/ParameterAnnotationArgs.kt | 1 + 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCatchParameterChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCatchParameterChecker.kt index 79970e5eda7..1b1c1d5b400 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCatchParameterChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirCatchParameterChecker.kt @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn import org.jetbrains.kotlin.fir.expressions.FirTryExpression import org.jetbrains.kotlin.fir.types.ConeTypeParameterType -import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef +import org.jetbrains.kotlin.fir.types.coneType object FirCatchParameterChecker : FirTryExpressionChecker() { override fun check(expression: FirTryExpression, context: CheckerContext, reporter: DiagnosticReporter) { @@ -24,11 +24,7 @@ object FirCatchParameterChecker : FirTryExpressionChecker() { reporter.reportOn(catchParameter.source, FirErrors.CATCH_PARAMETER_WITH_DEFAULT_VALUE, context) } - val typeRef = catchParameter.returnTypeRef - // TODO: remaining implicit types should be resolved as an error type, along with proper error kind, most likely syntax error. - if (typeRef !is FirResolvedTypeRef) return - - val coneType = typeRef.type + val coneType = catchParameter.returnTypeRef.coneType if (coneType is ConeTypeParameterType) { val isReified = coneType.lookupTag.typeParameterSymbol.fir.isReified diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt index 976f182f23c..6f1d89db757 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt @@ -74,7 +74,7 @@ open class FirBodyResolveTransformer( return (element.transformChildren(this, data) as E).compose() } - override fun transformTypeRef(typeRef: FirTypeRef, data: ResolutionMode): CompositeTransformResult { + override fun transformTypeRef(typeRef: FirTypeRef, data: ResolutionMode): CompositeTransformResult { if (typeRef is FirResolvedTypeRef) { return typeRef.compose() } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 68734347c7d..6c735933fd5 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -704,6 +704,9 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor context.storeVariable(valueParameter) if (valueParameter.returnTypeRef is FirImplicitTypeRef) { transformer.replaceDeclarationResolvePhaseIfNeeded(valueParameter, transformerPhase) + valueParameter.replaceReturnTypeRef( + valueParameter.returnTypeRef.errorTypeFromPrototype(ConeSimpleDiagnostic("Unresolved value parameter type")) + ) return valueParameter.compose() } diff --git a/idea/idea-completion/testData/basic/common/annotations/ParameterAnnotationArgs.kt b/idea/idea-completion/testData/basic/common/annotations/ParameterAnnotationArgs.kt index 862764e58f4..33701dda0e3 100644 --- a/idea/idea-completion/testData/basic/common/annotations/ParameterAnnotationArgs.kt +++ b/idea/idea-completion/testData/basic/common/annotations/ParameterAnnotationArgs.kt @@ -12,3 +12,4 @@ fun foo(@inlineOptions() { } // EXIST: InlineOption // EXIST: String // EXIST: v +// FIR_COMPARISON From 27c942a0fff6b6bddfc4b7c955ad5e93ae93e29e Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Tue, 9 Feb 2021 01:50:54 -0800 Subject: [PATCH 281/368] FIR: enforce the return type of function literals without body Its return type should be Unit, so do not use the expected type from, e.g., parameter type. --- .../fir/resolve/inference/InferenceUtils.kt | 15 +++++++++++---- .../diagnostics/tests/AutoCreatedIt.fir.kt | 2 +- .../diagnostics/tests/generics/kt34729.fir.kt | 4 ++-- .../kt9820_javaFunctionTypeInheritor.fir.kt | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt index 340bee9b6ad..349530b494f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt @@ -6,10 +6,10 @@ package org.jetbrains.kotlin.fir.resolve.inference import org.jetbrains.kotlin.builtins.functions.FunctionClassKind -import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.originalForSubstitutionOverride +import org.jetbrains.kotlin.fir.expressions.FirReturnExpression import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.Candidate import org.jetbrains.kotlin.fir.scopes.FakeOverrideTypeCalculator @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol -import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.name.ClassId @@ -248,7 +247,15 @@ fun extractLambdaInfoFromFunctionalType( if (!expectedType.isBuiltinFunctionalType(session)) return null val receiverType = argument.receiverType ?: expectedType.receiverType(session) - val returnType = argument.returnType ?: expectedType.returnType(session) ?: return null + val lastStatement = argument.body?.statements?.singleOrNull() + val returnType = + // Simply { }, i.e., function literals without body. Raw FIR added an implicit return with an implicit unit type ref. + if (lastStatement?.source?.kind is FirFakeSourceElementKind.ImplicitReturn && + (lastStatement as? FirReturnExpression)?.result?.source?.kind is FirFakeSourceElementKind.ImplicitUnit + ) { + session.builtinTypes.unitType.type + } else + argument.returnType ?: expectedType.returnType(session) ?: return null val parameters = extractLambdaParameters(expectedType, argument, expectedType.isExtensionFunctionType(session), session) return ResolvedLambdaAtom( diff --git a/compiler/testData/diagnostics/tests/AutoCreatedIt.fir.kt b/compiler/testData/diagnostics/tests/AutoCreatedIt.fir.kt index 02d28cc190b..161b60abe88 100644 --- a/compiler/testData/diagnostics/tests/AutoCreatedIt.fir.kt +++ b/compiler/testData/diagnostics/tests/AutoCreatedIt.fir.kt @@ -10,7 +10,7 @@ fun text() { bar1 {1} bar1 {it + 1} - bar2 {} + bar2 {} bar2 {1} bar2 {it} bar2 {it -> it} diff --git a/compiler/testData/diagnostics/tests/generics/kt34729.fir.kt b/compiler/testData/diagnostics/tests/generics/kt34729.fir.kt index 017f96bd1b4..de5f7d6f060 100644 --- a/compiler/testData/diagnostics/tests/generics/kt34729.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/kt34729.fir.kt @@ -14,6 +14,6 @@ fun bar(a: (Int) -> T) { } fun test() { - foo { } - bar { } + foo { } + bar { } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/regression/kt9820_javaFunctionTypeInheritor.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/regression/kt9820_javaFunctionTypeInheritor.fir.kt index ca950c13b30..1762e31b6d7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/regression/kt9820_javaFunctionTypeInheritor.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/regression/kt9820_javaFunctionTypeInheritor.fir.kt @@ -14,5 +14,5 @@ fun useJ(j: J) { } fun jj() { - useJ({}) + useJ({}) } From a841a0bbca0a09209be490cd1247cb15d5049d39 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Tue, 9 Feb 2021 22:11:13 -0800 Subject: [PATCH 282/368] FIR: transform other parts of function call even though callee is an error --- .../resolve/diagnostics/superIsNotAnExpression.fir.txt | 4 ++-- .../resolve/diagnostics/superIsNotAnExpression.kt | 2 +- .../body/resolve/FirExpressionsResolveTransformer.kt | 9 ++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.fir.txt index bf84fa6d262..304448a68f5 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.fir.txt @@ -13,8 +13,8 @@ FILE: superIsNotAnExpression.kt public final fun act(): R|kotlin/Unit| { #() #() - #( = @fun .(): { - println#(ERROR_EXPR(Incorrect character: 'weird')) + #( = @fun (): R|ERROR CLASS: Unresolved name: println| { + ^ #(ERROR_EXPR(Incorrect character: 'weird')) } ) } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt index ad4f40fa5f2..22f7caf5bcd 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt @@ -7,7 +7,7 @@ class B: A() { invoke() super { - println('weird') + println('weird') } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 61f458b8844..ed23f1d3193 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -262,7 +262,14 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform if (functionCall.calleeReference is FirResolvedNamedReference && functionCall.resultType is FirImplicitTypeRef) { storeTypeFromCallee(functionCall) } - if (functionCall.calleeReference !is FirSimpleNamedReference) return functionCall.compose() + if (functionCall.calleeReference !is FirSimpleNamedReference) { + // The callee reference can be resolved as an error very early, e.g., `super` as a callee during raw FIR creation. + // We still need to visit/transform other parts, e.g., call arguments, to check if any other errors are there. + if (functionCall.calleeReference !is FirResolvedNamedReference) { + functionCall.transformChildren(transformer, data) + } + return functionCall.compose() + } if (functionCall.calleeReference is FirNamedReferenceWithCandidate) return functionCall.compose() dataFlowAnalyzer.enterCall() functionCall.transformAnnotations(transformer, data) From 5f9357eb41cd0bfc4de8eed1fcb152748e118a05 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Tue, 9 Feb 2021 23:37:29 -0800 Subject: [PATCH 283/368] FIR: transform implicit type ref in anonymous function arguments & body ^KT-45010 Fixed --- ...irOldFrontendDiagnosticsTestGenerated.java | 6 ++++ ...rCallCompletionResultsWriterTransformer.kt | 33 ++++++++++++++++++- .../lambdaArgumentOfInapplicableCall.fir.kt | 6 ++++ .../lambdaArgumentOfInapplicableCall.kt | 6 ++++ .../lambdaArgumentOfInapplicableCall.txt | 3 ++ .../test/runners/DiagnosticTestGenerated.java | 6 ++++ 6 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index b377e3129e6..57943e90f00 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -34693,6 +34693,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt"); } + @Test + @TestMetadata("lambdaArgumentOfInapplicableCall.kt") + public void testLambdaArgumentOfInapplicableCall() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.kt"); + } + @Test @TestMetadata("samAgainstFunctionalType.kt") public void testSamAgainstFunctionalType() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index fe7d1d2ad96..11b470461b0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic +import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference import org.jetbrains.kotlin.fir.references.builder.buildResolvedCallableReference @@ -436,7 +437,10 @@ class FirCallCompletionResultsWriterTransformer( // Control flow info is necessary prerequisite because we collect return expressions in that function // // Example: second lambda in the call like list.filter({}, {}) - if (!dataFlowAnalyzer.isThereControlFlowInfoForAnonymousFunction(anonymousFunction)) return anonymousFunction.compose() + if (!dataFlowAnalyzer.isThereControlFlowInfoForAnonymousFunction(anonymousFunction)) { + // But, don't leave implicit type refs behind + return transformImplicitTypeRefInAnonymousFunction(anonymousFunction) + } val expectedType = data?.getExpectedType(anonymousFunction)?.let { expectedArgumentType -> // From the argument mapping, the expected type of this anonymous function would be: @@ -509,6 +513,33 @@ class FirCallCompletionResultsWriterTransformer( return result } + private fun transformImplicitTypeRefInAnonymousFunction( + anonymousFunction: FirAnonymousFunction + ): CompositeTransformResult { + val implicitTypeTransformer = object : FirDefaultTransformer() { + override fun transformElement(element: E, data: Nothing?): CompositeTransformResult { + @Suppress("UNCHECKED_CAST") + return (element.transformChildren(this, data) as E).compose() + } + + override fun transformImplicitTypeRef( + implicitTypeRef: FirImplicitTypeRef, + data: Nothing? + ): CompositeTransformResult = + buildErrorTypeRef { + source = implicitTypeRef.source + // NB: this error message assumes that it is used only if CFG for the anonymous function is not available + diagnostic = ConeSimpleDiagnostic("Cannot infer type w/o CFG", DiagnosticKind.InferenceError) + }.compose() + + } + // NB: if we transform simply all children, there would be too many type error reports. + anonymousFunction.transformReturnTypeRef(implicitTypeTransformer, null) + anonymousFunction.transformValueParameters(implicitTypeTransformer, null) + anonymousFunction.transformBody(implicitTypeTransformer, null) + return anonymousFunction.compose() + } + override fun transformReturnExpression( returnExpression: FirReturnExpression, data: ExpectedArgumentType? diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.fir.kt new file mode 100644 index 00000000000..77ad857b90f --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.fir.kt @@ -0,0 +1,6 @@ +// KT-45010 +fun foo(map: MutableMap) { + map.getOrPut("Not an Int") { + "Hello" + " world" + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.kt new file mode 100644 index 00000000000..c0230d29839 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.kt @@ -0,0 +1,6 @@ +// KT-45010 +fun foo(map: MutableMap) { + map.getOrPut("Not an Int") { + "Hello" + " world" + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.txt new file mode 100644 index 00000000000..0b1efc91e1b --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.txt @@ -0,0 +1,3 @@ +package + +public fun foo(/*0*/ map: kotlin.collections.MutableMap): kotlin.Unit diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index f9a9f827efc..65516cfb384 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -34789,6 +34789,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt"); } + @Test + @TestMetadata("lambdaArgumentOfInapplicableCall.kt") + public void testLambdaArgumentOfInapplicableCall() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/lambdaArgumentOfInapplicableCall.kt"); + } + @Test @TestMetadata("samAgainstFunctionalType.kt") public void testSamAgainstFunctionalType() throws Exception { From e67eb0c123779449563341914b42f877082c67cd Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Tue, 9 Feb 2021 23:59:36 -0800 Subject: [PATCH 284/368] FIR checker: typed declaration's return type should be resolved except for those in function contracts --- .../declaration/FirConflictingProjectionChecker.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictingProjectionChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictingProjectionChecker.kt index b82cb04fc20..92c716e42ed 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictingProjectionChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConflictingProjectionChecker.kt @@ -23,6 +23,10 @@ object FirConflictingProjectionChecker : FirBasicDeclarationChecker() { } if (declaration is FirTypedDeclaration) { + // The body of function contract is not fully resolved. + if (declaration.resolvePhase == FirResolvePhase.CONTRACTS) { + return + } checkTypeRef(declaration.returnTypeRef, context, reporter) } @@ -44,10 +48,7 @@ object FirConflictingProjectionChecker : FirBasicDeclarationChecker() { } private fun checkTypeRef(typeRef: FirTypeRef, context: CheckerContext, reporter: DiagnosticReporter) { - // TODO: remaining implicit types should be resolved as an error type, along with proper error kind, - // e.g., type mismatch, can't infer parameter type, syntax error, etc. - val declaration = typeRef.safeAs() - ?.coneTypeSafe() + val declaration = typeRef.coneTypeSafe() ?.lookupTag ?.toSymbol(context.session) ?.fir.safeAs() From 3e9ff3ecda8ec5a55c131a64a96b4b05c37b44f8 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 16 Feb 2021 15:28:15 +0300 Subject: [PATCH 285/368] FIR: report SUPERTYPE_NOT_A_CLASS_OR_INTERFACE on type parameters --- .../testData/resolve/typeParameterVsNested.fir.txt | 4 ++-- .../testData/resolve/typeParameterVsNested.kt | 4 ++-- .../generator/diagnostics/FirDiagnosticsList.kt | 3 +++ .../kotlin/fir/analysis/diagnostics/FirErrors.kt | 1 + .../analysis/diagnostics/FirDefaultErrorMessages.kt | 3 +++ .../diagnostics/coneDiagnosticToFirDiagnostic.kt | 1 + .../kotlin/fir/resolve/diagnostics/FirDiagnostics.kt | 8 +++++--- .../resolve/transformers/FirSupertypesResolution.kt | 12 +++++++----- .../regressions/TypeParameterAsASupertype.fir.kt | 1 - .../tests/regressions/TypeParameterAsASupertype.kt | 1 + 10 files changed, 25 insertions(+), 13 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/regressions/TypeParameterAsASupertype.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt index 3f336035ba4..848d07d7874 100644 --- a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt @@ -24,7 +24,7 @@ FILE: typeParameterVsNested.kt public abstract val z: public get(): - public final class Some : { + public final class Some : { public constructor(): R|test/My.Some| { super|>() } @@ -32,7 +32,7 @@ FILE: typeParameterVsNested.kt } } - public abstract class Your : { + public abstract class Your : { public constructor(): R|test/Your| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt index ded00ddec29..9126477c414 100644 --- a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt +++ b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt @@ -13,7 +13,7 @@ abstract class My { abstract val z: test.My.T - class Some : T() + class Some : T() } -abstract class Your : T +abstract class Your : T diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index e3f4e665edf..19d4e6c1d21 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -82,6 +82,9 @@ object DIAGNOSTICS_LIST : DiagnosticList() { val CLASS_IN_SUPERTYPE_FOR_ENUM by error() val SEALED_SUPERTYPE by error() val SEALED_SUPERTYPE_IN_LOCAL_CLASS by error() + val SUPERTYPE_NOT_A_CLASS_OR_INTERFACE by error { + parameter("reason") + } } val CONSTRUCTOR_PROBLEMS by object : DiagnosticGroup("Constructor problems") { diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index e34c9481330..63d73dd4a21 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -90,6 +90,7 @@ object FirErrors { val CLASS_IN_SUPERTYPE_FOR_ENUM by error0() val SEALED_SUPERTYPE by error0() val SEALED_SUPERTYPE_IN_LOCAL_CLASS by error0() + val SUPERTYPE_NOT_A_CLASS_OR_INTERFACE by error1() // Constructor problems val CONSTRUCTOR_IN_OBJECT by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index 02a7a799985..9ab8f8b7901 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -146,6 +146,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SEALED_SUPERTYPE_ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPERTYPE_INITIALIZED_IN_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPERTYPE_NOT_A_CLASS_OR_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPER_IS_NOT_AN_EXPRESSION import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPER_NOT_AVAILABLE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SYNTAX @@ -242,6 +243,8 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { map.put(CLASS_IN_SUPERTYPE_FOR_ENUM, "Enum class cannot inherit from classes") map.put(SEALED_SUPERTYPE, "This type is sealed, so it can be inherited by only its own nested classes or objects") map.put(SEALED_SUPERTYPE_IN_LOCAL_CLASS, "Local class cannot extend a sealed class") + map.put(SUPERTYPE_NOT_A_CLASS_OR_INTERFACE, "Supertype is not a class or interface", TO_STRING) + // Constructor problems map.put(CONSTRUCTOR_IN_OBJECT, "Constructors are not allowed for objects") diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt index 440c5992509..b5b953cde2e 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt @@ -47,6 +47,7 @@ fun ConeDiagnostic.toFirDiagnostic(source: FirSourceElement): FirDiagnostic null is ConeIntermediateDiagnostic -> null is ConeContractDescriptionError -> FirErrors.ERROR_IN_CONTRACT_DESCRIPTION.on(source, this.reason) + is ConeTypeParameterSupertype -> FirErrors.SUPERTYPE_NOT_A_CLASS_OR_INTERFACE.on(source, this.reason) else -> throw IllegalArgumentException("Unsupported diagnostic type: ${this.javaClass}") } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt index 34cb331bcf6..d51ffb8f043 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt @@ -9,15 +9,13 @@ import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.calls.Candidate -import org.jetbrains.kotlin.fir.resolve.calls.ResolutionDiagnostic import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol -import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintSystemError import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability class ConeUnresolvedReferenceError(val name: Name? = null) : ConeDiagnostic() { @@ -80,6 +78,10 @@ class ConeUnsupportedCallableReferenceTarget(val fir: FirCallableDeclaration<*>) override val reason: String get() = "Unsupported declaration for callable reference: ${fir.render()}" } +class ConeTypeParameterSupertype(val symbol: FirTypeParameterSymbol) : ConeDiagnostic() { + override val reason: String get() = "Type parameter ${symbol.fir.name} cannot be a supertype" +} + private fun describeSymbol(symbol: AbstractFirBasedSymbol<*>): String { return when (symbol) { is FirClassLikeSymbol<*> -> symbol.classId.asString() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt index 033e05f3a0d..4f4ba4a93f1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.extensions.predicateBasedProvider import org.jetbrains.kotlin.fir.extensions.supertypeGenerators import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.* +import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeTypeParameterSupertype import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.LocalClassesNavigationInfo import org.jetbrains.kotlin.fir.scopes.FirCompositeScope import org.jetbrains.kotlin.fir.scopes.FirScope @@ -285,12 +286,13 @@ private class FirSupertypeResolverVisitor( return resolveSpecificClassLikeSupertypes(classLikeDeclaration) { transformer, scope -> supertypeRefs.mapTo(mutableListOf()) { val superTypeRef = transformer.transformTypeRef(it, scope).single + val typeParameterType = superTypeRef.coneTypeSafe() when { - superTypeRef.coneTypeSafe() != null -> - createErrorTypeRef( - superTypeRef, - "Type parameter cannot be a super-type: ${superTypeRef.coneTypeUnsafe().render()}" - ) + typeParameterType != null -> + buildErrorTypeRef { + source = superTypeRef.source + diagnostic = ConeTypeParameterSupertype(typeParameterType.lookupTag.typeParameterSymbol) + } superTypeRef !is FirResolvedTypeRef -> createErrorTypeRef(superTypeRef, "Unresolved super-type: ${superTypeRef.render()}") else -> diff --git a/compiler/testData/diagnostics/tests/regressions/TypeParameterAsASupertype.fir.kt b/compiler/testData/diagnostics/tests/regressions/TypeParameterAsASupertype.fir.kt deleted file mode 100644 index 6c0c8795e61..00000000000 --- a/compiler/testData/diagnostics/tests/regressions/TypeParameterAsASupertype.fir.kt +++ /dev/null @@ -1 +0,0 @@ -class A : T {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/TypeParameterAsASupertype.kt b/compiler/testData/diagnostics/tests/regressions/TypeParameterAsASupertype.kt index a5f611397ce..0bf4cef74d1 100644 --- a/compiler/testData/diagnostics/tests/regressions/TypeParameterAsASupertype.kt +++ b/compiler/testData/diagnostics/tests/regressions/TypeParameterAsASupertype.kt @@ -1 +1,2 @@ +// FIR_IDENTICAL class A : T {} \ No newline at end of file From 6b453d9b23369059447e5a360eff3f4f7253d5e7 Mon Sep 17 00:00:00 2001 From: Tianyu Geng Date: Tue, 16 Feb 2021 14:04:34 -0800 Subject: [PATCH 286/368] FIR: implement checker for open members Specifically, 1. NON_FINAL_MEMBER_IN_FINAL_CLASS 2. NON_FINAL_MEMBER_IN_OBJECT --- .../RedundantModalityModifierChecker.kt | 2 +- .../diagnostics/FirDiagnosticsList.kt | 2 + .../fir/analysis/diagnostics/FirErrors.kt | 2 + .../declaration/FirDeclarationCheckerUtils.kt | 6 +++ .../declaration/FirOpenMemberChecker.kt | 49 +++++++++++++++++ .../diagnostics/FirDefaultErrorMessages.kt | 4 ++ .../fir/checkers/CommonDeclarationCheckers.kt | 1 + .../inlineClassDeclarationCheck.fir.kt | 2 +- .../tests/modifiers/IllegalModifiers.fir.kt | 54 +++++++++---------- .../tests/modifiers/IllegalModifiers.kt | 52 +++++++++--------- .../tests/objects/OpenInObject.fir.kt | 9 ---- .../diagnostics/tests/objects/OpenInObject.kt | 1 + .../overrideMemberFromFinalClass.fir.kt | 4 +- .../valueClassDeclarationCheck.fir.kt | 2 +- .../annotations/jvmField/interface13.fir.kt | 2 +- .../jvmStatic/finalAndAbstract.fir.kt | 6 +-- .../annotations/jvmStatic/property.fir.kt | 4 +- .../jvmStatic/property_LL13.fir.kt | 4 +- .../diagnostics/KtFirDataClassConverters.kt | 12 +++++ .../api/fir/diagnostics/KtFirDiagnostics.kt | 8 +++ .../fir/diagnostics/KtFirDiagnosticsImpl.kt | 14 +++++ 21 files changed, 165 insertions(+), 75 deletions(-) create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOpenMemberChecker.kt delete mode 100644 compiler/testData/diagnostics/tests/objects/OpenInObject.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantModalityModifierChecker.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantModalityModifierChecker.kt index 29ef5c58d94..bf353fc648e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantModalityModifierChecker.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantModalityModifierChecker.kt @@ -47,7 +47,7 @@ class FinalDerived : Base() { // Redundant final override final fun bar() {} // Non-final member in final class - override open val gav = 13 + override open val gav = 13 } // Open open class OpenDerived : Base() { diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 19d4e6c1d21..8cb30a29927 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -243,6 +243,8 @@ object DIAGNOSTICS_LIST : DiagnosticList() { parameter("overridingDeclaration") parameter("overriddenDeclaration") } + val NON_FINAL_MEMBER_IN_FINAL_CLASS by warning(PositioningStrategy.OPEN_MODIFIER) + val NON_FINAL_MEMBER_IN_OBJECT by warning(PositioningStrategy.OPEN_MODIFIER) } val REDECLARATIONS by object : DiagnosticGroup("Redeclarations") { diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 63d73dd4a21..0133cf8126a 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -176,6 +176,8 @@ object FirErrors { val PROPERTY_TYPE_MISMATCH_ON_OVERRIDE by error2(SourceElementPositioningStrategies.DECLARATION_RETURN_TYPE) val VAR_TYPE_MISMATCH_ON_OVERRIDE by error2(SourceElementPositioningStrategies.DECLARATION_RETURN_TYPE) val VAR_OVERRIDDEN_BY_VAL by error2(SourceElementPositioningStrategies.VAL_OR_VAR_NODE) + val NON_FINAL_MEMBER_IN_FINAL_CLASS by warning0(SourceElementPositioningStrategies.OPEN_MODIFIER) + val NON_FINAL_MEMBER_IN_OBJECT by warning0(SourceElementPositioningStrategies.OPEN_MODIFIER) // Redeclarations val MANY_COMPANION_OBJECTS by error0() diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerUtils.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerUtils.kt index 6b4ac794100..e7f8c001381 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerUtils.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerUtils.kt @@ -5,9 +5,12 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.modality import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn @@ -123,3 +126,6 @@ internal fun checkPropertyInitializer( private val FirProperty.hasAccessorImplementation: Boolean get() = (getter !is FirDefaultPropertyAccessor && getter?.hasBody == true) || (setter !is FirDefaultPropertyAccessor && setter?.hasBody == true) + + +internal val FirClass<*>.canHaveOpenMembers: Boolean get() = modality() != Modality.FINAL || classKind == ClassKind.ENUM_CLASS diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOpenMemberChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOpenMemberChecker.kt new file mode 100644 index 00000000000..715c3871fd0 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirOpenMemberChecker.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2010-2021 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.fir.analysis.checkers.declaration + +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.fir.FirFakeSourceElementKind +import org.jetbrains.kotlin.fir.FirRealSourceElementKind +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirModifierList.Companion.getModifierList +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn +import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration +import org.jetbrains.kotlin.fir.declarations.FirClass +import org.jetbrains.kotlin.fir.declarations.FirConstructor +import org.jetbrains.kotlin.fir.declarations.isOpen +import org.jetbrains.kotlin.lexer.KtTokens + +object FirOpenMemberChecker : FirClassChecker() { + override fun check(declaration: FirClass<*>, context: CheckerContext, reporter: DiagnosticReporter) { + if (declaration.canHaveOpenMembers) return + for (memberDeclaration in declaration.declarations) { + if (memberDeclaration !is FirCallableMemberDeclaration<*> || + // Marking a constructor `open` is an error covered by diagnostic code WRONG_MODIFIER_TARGET + memberDeclaration is FirConstructor + ) continue + val source = memberDeclaration.source ?: continue + if (memberDeclaration.isOpen || (source.hasOpenModifierInSource && source.shouldReportOpenFromSource)) { + if (declaration.classKind == ClassKind.OBJECT) { + reporter.reportOn(source, FirErrors.NON_FINAL_MEMBER_IN_OBJECT, context) + } else { + reporter.reportOn(source, FirErrors.NON_FINAL_MEMBER_IN_FINAL_CLASS, context) + } + } + } + } + + private val FirSourceElement.hasOpenModifierInSource: Boolean get() = getModifierList()?.modifiers?.any { it.token == KtTokens.OPEN_KEYWORD } == true + private val FirSourceElement.shouldReportOpenFromSource: Boolean + get() = when (kind) { + FirRealSourceElementKind, + FirFakeSourceElementKind.PropertyFromParameter -> true + else -> false + } +} diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index 9ab8f8b7901..fd78a00d225 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -99,6 +99,8 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MANY_COMPANION_OB import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_VAL_ON_ANNOTATION_PARAMETER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NONE_APPLICABLE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_ABSTRACT_FUNCTION_WITH_NO_BODY +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_FINAL_MEMBER_IN_FINAL_CLASS +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_FINAL_MEMBER_IN_OBJECT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_MEMBER_FUNCTION_NO_BODY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_PRIVATE_CONSTRUCTOR_IN_ENUM import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED @@ -394,6 +396,8 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { FQ_NAMES_IN_TYPES, FQ_NAMES_IN_TYPES ) + map.put(NON_FINAL_MEMBER_IN_FINAL_CLASS, "'open' has no effect in a final class") + map.put(NON_FINAL_MEMBER_IN_OBJECT, "'open' has no effect in an object") map.put( GENERIC_THROWABLE_SUBCLASS, "Subclass of 'Throwable' may not have type parameters" diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt index a158c5d35d9..3c39382aa5d 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt @@ -39,6 +39,7 @@ object CommonDeclarationCheckers : DeclarationCheckers() { override val classCheckers: Set = setOf( FirOverrideChecker, FirThrowableSubclassChecker, + FirOpenMemberChecker, ) override val regularClassCheckers: Set = setOf( diff --git a/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.fir.kt b/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.fir.kt index 5911eaa8f3e..ea47b0e4e21 100644 --- a/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.fir.kt +++ b/compiler/testData/diagnostics/tests/inlineClasses/inlineClassDeclarationCheck.fir.kt @@ -10,7 +10,7 @@ inline class A4(var x: Int) inline class A5(val x: Int, val y: Int) inline class A6(x: Int, val y: Int) inline class A7(vararg val x: Int) -inline class A8(open val x: Int) +inline class A8(open val x: Int) inline class A9(final val x: Int) class B1 { diff --git a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.fir.kt b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.fir.kt index 32ff714f8dd..bf5893bc6a8 100644 --- a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.fir.kt +++ b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.fir.kt @@ -7,14 +7,14 @@ abstract class A() { final open fun h() {} open var r: String - get - abstract protected set + get + abstract protected set } final interface T {} class FinalClass() { - open fun foo() {} + open fun foo() {} val i: Int = 1 open get(): Int = field var j: Int = 1 @@ -32,13 +32,13 @@ class LegalModifier(val a: Int, @annotated private var b: String, @annotated var //Check illegal modifier in constructor parameters class IllegalModifiers1( - in - out - reified - enum - private - const - a: Int) + in + out + reified + enum + private + const + a: Int) //Check multiple illegal modifiers in constructor class IllegalModifiers2(private abstract a: Int) @@ -53,26 +53,26 @@ class IllegalModifiers4(val a: Int, @annotated("a text") protected vararg v: Int //Check illegal modifiers for functions and catch block abstract class IllegalModifiers5() { - //Check illegal modifier in function parameter - abstract fun foo(public a: Int, vararg v: String) + //Check illegal modifier in function parameter + abstract fun foo(public a: Int, vararg v: String) - //Check multiple illegal modifiers in function parameter - abstract fun bar(public abstract a: Int, vararg v: String) - - //Check annotations with illegal modifiers - abstract fun baz(@annotated("a text") public abstract a: Int) - - private fun qux() { - - //Check illegal modifier in catch block - try {} catch (in out reified enum public e: Exception) {} - - //Check multiple illegal modifiers in catch block - try {} catch (in out reified enum abstract public e: Exception) {} + //Check multiple illegal modifiers in function parameter + abstract fun bar(public abstract a: Int, vararg v: String) //Check annotations with illegal modifiers - try {} catch (@annotated("a text") abstract public e: Exception) {} - } + abstract fun baz(@annotated("a text") public abstract a: Int) + + private fun qux() { + + //Check illegal modifier in catch block + try {} catch (in out reified enum public e: Exception) {} + + //Check multiple illegal modifiers in catch block + try {} catch (in out reified enum abstract public e: Exception) {} + + //Check annotations with illegal modifiers + try {} catch (@annotated("a text") abstract public e: Exception) {} + } } //Check illegal modifiers on anonymous initializers diff --git a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt index eac597e4a5d..4b5c2de73fd 100644 --- a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt +++ b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt @@ -7,8 +7,8 @@ abstract class A() { final open fun h() {} open var r: String - get - abstract protected set + get + abstract protected set } final interface T {} @@ -32,13 +32,13 @@ class LegalModifier(val a: Int, @annotated private var b: String, @annotated var //Check illegal modifier in constructor parameters class IllegalModifiers1( - in - out - reified - enum - private - const - a: Int) + in + out + reified + enum + private + const + a: Int) //Check multiple illegal modifiers in constructor class IllegalModifiers2(private abstract a: Int) @@ -53,26 +53,26 @@ class IllegalModifiers4(val a: Int, @annotated("a text") public a: Int, vararg v: String) + //Check illegal modifier in function parameter + abstract fun foo(public a: Int, vararg v: String) - //Check multiple illegal modifiers in function parameter - abstract fun bar(public abstract a: Int, vararg v: String) - - //Check annotations with illegal modifiers - abstract fun baz(@annotated("a text") public abstract a: Int) - - private fun qux() { - - //Check illegal modifier in catch block - try {} catch (in out reified enum public e: Exception) {} - - //Check multiple illegal modifiers in catch block - try {} catch (in out reified enum abstract public e: Exception) {} + //Check multiple illegal modifiers in function parameter + abstract fun bar(public abstract a: Int, vararg v: String) //Check annotations with illegal modifiers - try {} catch (@annotated("a text") abstract public e: Exception) {} - } + abstract fun baz(@annotated("a text") public abstract a: Int) + + private fun qux() { + + //Check illegal modifier in catch block + try {} catch (in out reified enum public e: Exception) {} + + //Check multiple illegal modifiers in catch block + try {} catch (in out reified enum abstract public e: Exception) {} + + //Check annotations with illegal modifiers + try {} catch (@annotated("a text") abstract public e: Exception) {} + } } //Check illegal modifiers on anonymous initializers diff --git a/compiler/testData/diagnostics/tests/objects/OpenInObject.fir.kt b/compiler/testData/diagnostics/tests/objects/OpenInObject.fir.kt deleted file mode 100644 index ca357cdd3c7..00000000000 --- a/compiler/testData/diagnostics/tests/objects/OpenInObject.fir.kt +++ /dev/null @@ -1,9 +0,0 @@ -object Obj { - fun foo() {} - - open fun bar() {} - - var x: Int = 0 - - open var y: Int = 1 -} diff --git a/compiler/testData/diagnostics/tests/objects/OpenInObject.kt b/compiler/testData/diagnostics/tests/objects/OpenInObject.kt index 0d032133499..356b5d97f9b 100644 --- a/compiler/testData/diagnostics/tests/objects/OpenInObject.kt +++ b/compiler/testData/diagnostics/tests/objects/OpenInObject.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL object Obj { fun foo() {} diff --git a/compiler/testData/diagnostics/tests/override/overrideMemberFromFinalClass.fir.kt b/compiler/testData/diagnostics/tests/override/overrideMemberFromFinalClass.fir.kt index 6585b36718a..1de65fcccc4 100644 --- a/compiler/testData/diagnostics/tests/override/overrideMemberFromFinalClass.fir.kt +++ b/compiler/testData/diagnostics/tests/override/overrideMemberFromFinalClass.fir.kt @@ -1,5 +1,5 @@ class Foo { - open fun openFoo() {} + open fun openFoo() {} fun finalFoo() {} } @@ -25,4 +25,4 @@ abstract class A2 { class B2 : A2() class C2 : B2() { override fun foo() {} -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.fir.kt b/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.fir.kt index a555bccb1bf..a7683e9acda 100644 --- a/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.fir.kt +++ b/compiler/testData/diagnostics/tests/valueClasses/valueClassDeclarationCheck.fir.kt @@ -24,7 +24,7 @@ value class A6(x: Int, val y: Int) @JvmInline value class A7(vararg val x: Int) @JvmInline -value class A8(open val x: Int) +value class A8(open val x: Int) @JvmInline value class A9(final val x: Int) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/interface13.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/interface13.fir.kt index 79b17440a69..c79dc2e47fc 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/interface13.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/interface13.fir.kt @@ -54,6 +54,6 @@ interface E { interface F { companion object { @JvmField - open val a = 3 + open val a = 3 } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/finalAndAbstract.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/finalAndAbstract.fir.kt index a37ff0e192d..2f4126ab0a3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/finalAndAbstract.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/finalAndAbstract.fir.kt @@ -16,7 +16,7 @@ object B: A() { @JvmStatic final override fun c() {} - @JvmStatic open fun d() {} + @JvmStatic open fun d() {} } class C { @@ -28,6 +28,6 @@ class C { @JvmStatic final override fun c() {} - @JvmStatic open fun d() {} + @JvmStatic open fun d() {} } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/property.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/property.fir.kt index 5913ec6959e..30203bc6838 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/property.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/property.fir.kt @@ -30,7 +30,7 @@ class A { @JvmStatic override val base1: Int = 0 - @JvmStatic open fun f() {} + @JvmStatic open fun f() {} override val base2: Int = 0 @JvmStatic get @@ -42,4 +42,4 @@ class A { } @JvmStatic val z2 = 1; -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/property_LL13.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/property_LL13.fir.kt index 3d44a883fa3..d4e2e84617d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/property_LL13.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/property_LL13.fir.kt @@ -30,7 +30,7 @@ class A { @JvmStatic override val base1: Int = 0 - @JvmStatic open fun f() {} + @JvmStatic open fun f() {} override val base2: Int = 0 @JvmStatic get @@ -42,4 +42,4 @@ class A { } @JvmStatic val z2 = 1; -} \ No newline at end of file +} diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt index 12e35474fc9..ed2d4f80ff2 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -723,6 +723,18 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirErrors.NON_FINAL_MEMBER_IN_FINAL_CLASS) { firDiagnostic -> + NonFinalMemberInFinalClassImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NON_FINAL_MEMBER_IN_OBJECT) { firDiagnostic -> + NonFinalMemberInObjectImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } add(FirErrors.MANY_COMPANION_OBJECTS) { firDiagnostic -> ManyCompanionObjectsImpl( firDiagnostic as FirPsiDiagnostic<*>, diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt index 5c3d07e9d6b..59e6aea5ba1 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -515,6 +515,14 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { abstract val overriddenDeclaration: KtSymbol } + abstract class NonFinalMemberInFinalClass : KtFirDiagnostic() { + override val diagnosticClass get() = NonFinalMemberInFinalClass::class + } + + abstract class NonFinalMemberInObject : KtFirDiagnostic() { + override val diagnosticClass get() = NonFinalMemberInObject::class + } + abstract class ManyCompanionObjects : KtFirDiagnostic() { override val diagnosticClass get() = ManyCompanionObjects::class } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index d930ad9ee43..18d7cad5c93 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -822,6 +822,20 @@ internal class VarOverriddenByValImpl( override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) } +internal class NonFinalMemberInFinalClassImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NonFinalMemberInFinalClass(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) +} + +internal class NonFinalMemberInObjectImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NonFinalMemberInObject(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) +} + internal class ManyCompanionObjectsImpl( firDiagnostic: FirPsiDiagnostic<*>, override val token: ValidityToken, From 74bdb2398efbedf8b6cee326513a3f1468db4d61 Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Fri, 19 Feb 2021 07:20:06 +0000 Subject: [PATCH 287/368] FIR: Get rid of PSI dependency in the `:fir:resolve` module --- compiler/fir/resolve/build.gradle.kts | 3 +-- .../kotlin/fir/FirQualifiedNameResolver.kt | 11 +---------- .../tree/src/org/jetbrains/kotlin/fir/Utils.kt | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/compiler/fir/resolve/build.gradle.kts b/compiler/fir/resolve/build.gradle.kts index 7c4bf38f27a..16a0cb9f451 100644 --- a/compiler/fir/resolve/build.gradle.kts +++ b/compiler/fir/resolve/build.gradle.kts @@ -14,10 +14,9 @@ dependencies { api(project(":compiler:fir:tree")) api(kotlinxCollectionsImmutable()) implementation(project(":core:util.runtime")) - implementation(project(":compiler:psi")) compileOnly(project(":kotlin-reflect-api")) - compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) } + compileOnly(intellijCoreDep()) { includeJars("guava", rootProject = rootProject) } } sourceSets { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt index 9c9c0f7e46b..a59121afa78 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirQualifiedNameResolver.kt @@ -19,7 +19,6 @@ import org.jetbrains.kotlin.fir.resolve.typeForQualifier import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf const val ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE = "_root_ide_package_" @@ -92,7 +91,7 @@ class FirQualifiedNameResolver(private val components: BodyResolveComponents) { } return buildResolvedQualifier { - this.source = getWholeQualifierSource(source, qualifierPartsToDrop) + this.source = source?.getWholeQualifierSourceIfPossible(qualifierPartsToDrop) packageFqName = resolved.packageFqName relativeClassFqName = resolved.relativeClassFqName symbol = resolved.classSymbol @@ -104,12 +103,4 @@ class FirQualifiedNameResolver(private val components: BodyResolveComponents) { return null } - - private fun getWholeQualifierSource(qualifierStartSource: FirSourceElement?, stepsToWholeQualifier: Int): FirSourceElement? { - if (qualifierStartSource !is FirRealPsiSourceElement<*>) return qualifierStartSource - - val qualifierStart = qualifierStartSource.psi - val wholeQualifier = qualifierStart.parentsWithSelf.drop(stepsToWholeQualifier).first() - return wholeQualifier.toFirPsiSourceElement() - } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt index 13d2c3e7ba3..f3effe58dc1 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt @@ -56,3 +56,20 @@ fun R.copyWithNewSourceKind(newKind: FirFakeSourceElementKind): } as R } +/** + * Let's take `a.b.c.call()` expression as an example. + * + * This function allows to transform `SourceElement(psi = 'a')` to `SourceElement(psi = 'a.b.c')` + * ([stepsToWholeQualifier] should be = 2 for that). + * + * @receiver original source element + * @param stepsToWholeQualifier distance between the original psi and the whole qualifier psi + */ +fun FirSourceElement.getWholeQualifierSourceIfPossible(stepsToWholeQualifier: Int): FirSourceElement { + if (this !is FirRealPsiSourceElement<*>) return this + + val qualifiersChain = generateSequence(psi) { it.parent } + val wholeQualifier = qualifiersChain.drop(stepsToWholeQualifier).first() + + return wholeQualifier.toFirPsiSourceElement() as FirRealPsiSourceElement +} From 357a7907a34b3ea9a23e10bfdb7ea230d266d8b9 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 15 Feb 2021 19:15:43 +0300 Subject: [PATCH 288/368] FIR: fix type approximation by visibility --- .../cfg/innerClassInAnonymousObject.fir.txt | 4 +- ...tionArgumentKClassLiteralTypeError.fir.txt | 2 +- .../diagnostics/conflictingOverloads.fir.txt | 4 +- .../localEntitytNotAllowed.fir.txt | 4 +- .../expresssions/privateObjectLiteral.fir.txt | 8 +- .../expresssions/privateObjectLiteral.kt | 2 +- ...RedundantVisibilityModifierChecker.fir.txt | 4 +- .../resolveWithStdlib/problems.fir.txt | 4 +- .../FirDeclarationsResolveTransformer.kt | 106 +++++++++--------- .../jetbrains/kotlin/fir/types/TypeUtils.kt | 7 +- .../codegen/box/ir/anonymousClassLeak.kt | 1 - ...approximateReturnedAnonymousObjects.fir.kt | 6 +- .../inline/returnedAnonymousObjects.fir.kt | 6 +- .../objectLiteralExpressions.fir.kt.txt | 2 +- .../classes/objectLiteralExpressions.fir.txt | 8 +- .../expressions/objectReference.fir.kt.txt | 2 +- .../expressions/objectReference.fir.txt | 8 +- .../diagnostics/notLinked/dfa/pos/4.fir.kt | 4 +- 18 files changed, 90 insertions(+), 92 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/innerClassInAnonymousObject.fir.txt b/compiler/fir/analysis-tests/testData/resolve/cfg/innerClassInAnonymousObject.fir.txt index 34e9c667163..f1c88d5bd1b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/innerClassInAnonymousObject.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/innerClassInAnonymousObject.fir.txt @@ -1,5 +1,5 @@ FILE: innerClassInAnonymousObject.kt - public final val x: R|| = object : R|kotlin/Any| { + public final val x: R|kotlin/Any| = object : R|kotlin/Any| { private constructor(): R|| { super() } @@ -16,4 +16,4 @@ FILE: innerClassInAnonymousObject.kt } - public get(): R|| + public get(): R|kotlin/Any| diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/annotationArgumentKClassLiteralTypeError.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/annotationArgumentKClassLiteralTypeError.fir.txt index fa58d460db5..5d037b7f706 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/annotationArgumentKClassLiteralTypeError.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/annotationArgumentKClassLiteralTypeError.fir.txt @@ -8,7 +8,7 @@ FILE: annotationArgumentKClassLiteralTypeError.kt public get(): R|kotlin/Array>| } - public final val R|T|.test: R|| + public final val R|T|.test: R|kotlin/Any| public get(): R|| { ^ @R|Ann|(((R|T|), (Q|kotlin/Array|))) object : R|kotlin/Any| { private constructor(): R|| { diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.fir.txt index b732440a451..67b922bdde5 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.fir.txt @@ -90,14 +90,14 @@ FILE: conflictingOverloads.kt } - public final val Companion: R|| = object : R|kotlin/Any| { + public final val Companion: R|kotlin/Any| = object : R|kotlin/Any| { private constructor(): R|| { super() } } - public get(): R|| + public get(): R|kotlin/Any| } public final fun R|B|.foo(): R|kotlin/Unit| { diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.fir.txt index ff83835dd72..f6a6c1b4556 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.fir.txt @@ -21,7 +21,7 @@ FILE: localEntitytNotAllowed.kt public abstract interface X : R|kotlin/Any| { } - public final val a: R|| = object : R|kotlin/Any| { + public final val a: R|kotlin/Any| = object : R|kotlin/Any| { private constructor(): R|| { super() } @@ -48,7 +48,7 @@ FILE: localEntitytNotAllowed.kt } - public get(): R|| + public get(): R|kotlin/Any| public final fun b(): R|kotlin/Unit| { local final object E : R|kotlin/Any| { diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.fir.txt b/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.fir.txt index f7622cce04e..cefdbc55d45 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.fir.txt @@ -20,7 +20,7 @@ FILE: privateObjectLiteral.kt public final val y: R|kotlin/Int| = this@R|/C|.R|/C.x|.R|/.foo|() public get(): R|kotlin/Int| - internal final val z: R|| = object : R|kotlin/Any| { + internal final val z: R|kotlin/Any| = object : R|kotlin/Any| { private constructor(): R|| { super() } @@ -31,9 +31,9 @@ FILE: privateObjectLiteral.kt } - internal get(): R|| + internal get(): R|kotlin/Any| - public final val w: R|kotlin/Int| = this@R|/C|.R|/C.z|.R|/.foo|() - public get(): R|kotlin/Int| + public final val w: R|ERROR CLASS: Unresolved name: foo| = this@R|/C|.R|/C.z|.#() + public get(): R|ERROR CLASS: Unresolved name: foo| } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.kt index 67188d0d0fe..45f71375792 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.kt @@ -9,5 +9,5 @@ class C { fun foo() = 13 } - val w = z.foo() // ERROR! + val w = z.foo() // ERROR! } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.fir.txt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.fir.txt index d2c4e79b455..2fd1132eb4c 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.fir.txt @@ -22,7 +22,7 @@ FILE: RedundantVisibilityModifierChecker.kt super() } - internal final val z: R|| = object : R|kotlin/Any| { + internal final val z: R|kotlin/Any| = object : R|kotlin/Any| { private constructor(): R|| { super() } @@ -33,7 +33,7 @@ FILE: RedundantVisibilityModifierChecker.kt } - internal get(): R|| + internal get(): R|kotlin/Any| } public final class Foo2 : R|kotlin/Any| { diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems.fir.txt index d6832dbdd69..71f780c9ba1 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems.fir.txt @@ -1,7 +1,7 @@ FILE: problems.kt public final val sb: R|java/lang/StringBuilder| = R|java/lang/StringBuilder.StringBuilder|() public get(): R|java/lang/StringBuilder| - public final val o: R|| = object : R|kotlin/Any| { + public final val o: R|kotlin/Any| = object : R|kotlin/Any| { private constructor(): R|| { super() } @@ -15,7 +15,7 @@ FILE: problems.kt } - public get(): R|| + public get(): R|kotlin/Any| public final fun test(): R|kotlin/Unit| { local final class Local : R|kotlin/Any| { public constructor(): R|Local| { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 6c735933fd5..bc5c67c3e9f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -6,6 +6,8 @@ package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter @@ -45,6 +47,17 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor private var containingClass: FirRegularClass? = null private val statusResolver: FirStatusResolver = FirStatusResolver(session, scopeSession) + private fun FirDeclaration.visibilityForApproximation(): Visibility { + if (this !is FirMemberDeclaration) return Visibilities.Local + val container = context.containers.getOrNull(context.containers.size - 2) + val containerVisibility = + if (container == null) Visibilities.Public + else (container as? FirRegularClass)?.visibility ?: Visibilities.Local + if (containerVisibility == Visibilities.Local || visibility == Visibilities.Local) return Visibilities.Local + if (containerVisibility == Visibilities.Private) return Visibilities.Private + return visibility + } + private inline fun withFirArrayOfCallTransformer(block: () -> T): T { transformer.expressionsTransformer.enableArrayOfCallTransformation = true return try { @@ -560,7 +573,9 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor transformer, withExpectedType( returnExpression.resultType.approximatedIfNeededOrSelf( - inferenceComponents.approximator, simpleFunction?.visibility, simpleFunction?.isInline == true + inferenceComponents.approximator, + simpleFunction?.visibilityForApproximation(), + simpleFunction?.isInline == true ) ) ) @@ -990,67 +1005,50 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor private fun storeVariableReturnType(variable: FirVariable<*>) { val initializer = variable.initializer if (variable.returnTypeRef is FirImplicitTypeRef) { - when { + val resultType = when { initializer != null -> { val unwrappedInitializer = (initializer as? FirExpressionWithSmartcast)?.originalExpression ?: initializer - val expectedType = when (val resultType = unwrappedInitializer.resultType) { - is FirImplicitTypeRef -> buildErrorTypeRef { - diagnostic = ConeSimpleDiagnostic("No result type for initializer", DiagnosticKind.InferenceError) - } - else -> { - buildResolvedTypeRef { - type = resultType.coneType - annotations.addAll(resultType.annotations) - resultType.source?.fakeElement(FirFakeSourceElementKind.PropertyFromParameter)?.let { - source = it - } + unwrappedInitializer.resultType + } + variable.getter != null && variable.getter !is FirDefaultPropertyAccessor -> variable.getter?.returnTypeRef + else -> null + } + if (resultType != null) { + val expectedType = when (resultType) { + is FirImplicitTypeRef -> buildErrorTypeRef { + diagnostic = ConeSimpleDiagnostic("No result type for initializer", DiagnosticKind.InferenceError) + } + else -> { + buildResolvedTypeRef { + type = resultType.coneType + annotations.addAll(resultType.annotations) + resultType.source?.fakeElement(FirFakeSourceElementKind.PropertyFromParameter)?.let { + source = it } } } - variable.transformReturnTypeRef( - transformer, - withExpectedType( - expectedType.approximatedIfNeededOrSelf(inferenceComponents.approximator, (variable as? FirProperty)?.visibility) + } + variable.transformReturnTypeRef( + transformer, + withExpectedType( + expectedType.approximatedIfNeededOrSelf( + inferenceComponents.approximator, + variable.visibilityForApproximation() ) ) - } - variable.getter != null && variable.getter !is FirDefaultPropertyAccessor -> { - val expectedType = when (val resultType = variable.getter?.returnTypeRef) { - is FirImplicitTypeRef -> buildErrorTypeRef { - diagnostic = ConeSimpleDiagnostic("No result type for getter", DiagnosticKind.InferenceError) - } - else -> { - resultType?.let { - buildResolvedTypeRef { - type = resultType.coneType - annotations.addAll(resultType.annotations) - resultType.source?.fakeElement(FirFakeSourceElementKind.PropertyFromParameter)?.let { - source = it - } - } - } - } - } - variable.transformReturnTypeRef( - transformer, - withExpectedType( - expectedType?.approximatedIfNeededOrSelf(inferenceComponents.approximator, (variable as? FirProperty)?.visibility) - ) + ) + } else { + variable.transformReturnTypeRef( + transformer, + withExpectedType( + buildErrorTypeRef { + diagnostic = ConeSimpleDiagnostic( + "Cannot infer variable type without initializer / getter / delegate", + DiagnosticKind.InferenceError, + ) + }, ) - } - else -> { - variable.transformReturnTypeRef( - transformer, - withExpectedType( - buildErrorTypeRef { - diagnostic = ConeSimpleDiagnostic( - "Cannot infer variable type without initializer / getter / delegate", - DiagnosticKind.InferenceError, - ) - }, - ) - ) - } + ) } if (variable.getter?.returnTypeRef is FirImplicitTypeRef) { variable.getter?.transformReturnTypeRef(transformer, withExpectedType(variable.returnTypeRef)) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt index 3a18b53a1f4..95450c2de1b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir.types import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.fir.* -import org.jetbrains.kotlin.fir.declarations.classId +import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap @@ -309,7 +309,8 @@ private fun FirTypeRef.hideLocalTypeIfNeeded( ?.type as? ConeClassLikeType) ?.lookupTag as? ConeClassLookupTagWithFixedSymbol) ?.symbol?.fir - if (firClass?.classId?.isLocal != true) { + if (firClass !is FirAnonymousObject) { + // NB: local classes are acceptable here, but reported by EXPOSED_* checkers as errors return this } if (firClass.superTypeRefs.size > 1) { @@ -318,7 +319,7 @@ private fun FirTypeRef.hideLocalTypeIfNeeded( } } val superType = firClass.superTypeRefs.single() - if (superType is FirResolvedTypeRef && !superType.isAny) { + if (superType is FirResolvedTypeRef) { return superType } } diff --git a/compiler/testData/codegen/box/ir/anonymousClassLeak.kt b/compiler/testData/codegen/box/ir/anonymousClassLeak.kt index 085288c8634..f5edc88422f 100644 --- a/compiler/testData/codegen/box/ir/anonymousClassLeak.kt +++ b/compiler/testData/codegen/box/ir/anonymousClassLeak.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // DONT_TARGET_EXACT_BACKEND: WASM // WASM_MUTE_REASON: PROPERTY_REFERENCES // WITH_RUNTIME diff --git a/compiler/testData/diagnostics/tests/inline/approximateReturnedAnonymousObjects.fir.kt b/compiler/testData/diagnostics/tests/inline/approximateReturnedAnonymousObjects.fir.kt index e5a992792f2..298cb10d9be 100644 --- a/compiler/testData/diagnostics/tests/inline/approximateReturnedAnonymousObjects.fir.kt +++ b/compiler/testData/diagnostics/tests/inline/approximateReturnedAnonymousObjects.fir.kt @@ -20,11 +20,11 @@ private fun foo4(f: () -> Int) = object { } fun test1(b: Boolean) { - var x = ")!>foo1 { 1 } + var x = foo1 { 1 } if (b) { - x = ")!>foo1 { 2 } + x = foo1 { 2 } } - x.bar() + x.bar() } fun test2(b: Boolean) { diff --git a/compiler/testData/diagnostics/tests/inline/returnedAnonymousObjects.fir.kt b/compiler/testData/diagnostics/tests/inline/returnedAnonymousObjects.fir.kt index 7e3dfc4bb9a..45af611f7d9 100644 --- a/compiler/testData/diagnostics/tests/inline/returnedAnonymousObjects.fir.kt +++ b/compiler/testData/diagnostics/tests/inline/returnedAnonymousObjects.fir.kt @@ -20,11 +20,11 @@ private fun foo4(f: () -> Int) = object { } fun test1(b: Boolean) { - var x = ")!>foo1 { 1 } + var x = foo1 { 1 } if (b) { - x = ")!>foo1 { 2 } + x = foo1 { 2 } } - x.bar() + x.bar() } fun test2(b: Boolean) { diff --git a/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.kt.txt b/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.kt.txt index b9886d37fce..693175fa5f8 100644 --- a/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.kt.txt @@ -3,7 +3,7 @@ interface IFoo { } -val test1: +val test1: Any field = { // BLOCK local class { private constructor() /* primary */ { diff --git a/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt b/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt index efbf62e8ce8..d37fe51b879 100644 --- a/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt +++ b/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt @@ -17,7 +17,7 @@ FILE fqName: fileName:/objectLiteralExpressions.kt public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any PROPERTY name:test1 visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:test1 type:.test1. visibility:private [final,static] + FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Any visibility:private [final,static] EXPRESSION_BODY BLOCK type=.test1. origin=OBJECT_LITERAL CLASS CLASS name: modality:FINAL visibility:local superTypes:[kotlin.Any] @@ -40,11 +40,11 @@ FILE fqName: fileName:/objectLiteralExpressions.kt public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test1.' type=.test1. origin=OBJECT_LITERAL - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:.test1. + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Any correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): .test1. declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test1 type:.test1. visibility:private [final,static]' type=.test1. origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Any visibility:private [final,static]' type=kotlin.Any origin=null PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:.IFoo visibility:private [final,static] EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/expressions/objectReference.fir.kt.txt b/compiler/testData/ir/irText/expressions/objectReference.fir.kt.txt index a079149616d..518effa0539 100644 --- a/compiler/testData/ir/irText/expressions/objectReference.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/objectReference.fir.kt.txt @@ -53,7 +53,7 @@ object Z { get - val anObject: + val anObject: Any field = { // BLOCK local class { private constructor() /* primary */ { diff --git a/compiler/testData/ir/irText/expressions/objectReference.fir.txt b/compiler/testData/ir/irText/expressions/objectReference.fir.txt index 9133a67547d..5cd4d0318f4 100644 --- a/compiler/testData/ir/irText/expressions/objectReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectReference.fir.txt @@ -108,7 +108,7 @@ FILE fqName: fileName:/objectReference.kt GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:aLambda type:kotlin.Function0 visibility:private [final]' type=kotlin.Function0 origin=null receiver: GET_VAR ': .Z declared in .Z.' type=.Z origin=null PROPERTY name:anObject visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:anObject type:.Z.anObject. visibility:private [final] + FIELD PROPERTY_BACKING_FIELD name:anObject type:kotlin.Any visibility:private [final] EXPRESSION_BODY BLOCK type=.Z.anObject. origin=OBJECT_LITERAL CLASS CLASS name: modality:FINAL visibility:local superTypes:[kotlin.Any] @@ -156,12 +156,12 @@ FILE fqName: fileName:/objectReference.kt public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Z.anObject.' type=.Z.anObject. origin=OBJECT_LITERAL - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Z) returnType:.Z.anObject. + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Z) returnType:kotlin.Any correspondingProperty: PROPERTY name:anObject visibility:public modality:FINAL [val] $this: VALUE_PARAMETER name: type:.Z BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): .Z.anObject. declared in .Z' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:anObject type:.Z.anObject. visibility:private [final]' type=.Z.anObject. origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .Z' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:anObject type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null receiver: GET_VAR ': .Z declared in .Z.' type=.Z origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt index 8f587d178ee..4465240a87b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt @@ -63,8 +63,8 @@ fun case_6(x: EmptyClass) { // TESTCASE NUMBER: 7 fun case_7() { - if (anonymousTypeProperty == null || & ")!>anonymousTypeProperty == null) { - ")!>anonymousTypeProperty + if (anonymousTypeProperty == null || anonymousTypeProperty == null) { + anonymousTypeProperty } } From c629ba5a3cb13e823276aab0aca4d918b65ca856 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Thu, 18 Feb 2021 13:57:40 +0300 Subject: [PATCH 289/368] JVM_IR indy-SAM: function reference to Java interface --- .../FirBlackBoxCodegenTestGenerated.java | 128 +++++++++++-- .../codegen/FirBytecodeTextTestGenerated.java | 6 + .../jvm/lower/FunctionReferenceLowering.kt | 1 + .../backend/jvm/lower/TypeOperatorLowering.kt | 62 +++--- .../lower/indy/LambdaMetafactoryArguments.kt | 181 +++++++++++++----- .../kotlin/ir/types/irTypePredicates.kt | 8 + .../sam/enhancedNullabilityMix.kt | 29 +++ .../capturedSamArgument.kt | 0 .../capturingLambda.kt | 0 .../extensionLambda1.kt | 0 .../extensionLambda2.kt | 0 .../genericSam1.kt | 0 .../genericSam2.kt | 0 .../simple.kt | 0 .../adaptedFunRefWithCoercionToUnit.kt | 20 ++ .../adaptedFunRefWithDefaultParameters.kt | 19 ++ .../adaptedFunRefWithVararg.kt | 19 ++ .../functionRefToJavaInterface/boundExtFun.kt | 13 ++ .../boundInnerConstructorRef.kt | 16 ++ .../boundLocalExtFun.kt | 15 ++ .../boundMemberRef.kt | 14 ++ .../constructorRef.kt | 12 ++ .../enhancedNullability.kt | 20 ++ .../innerConstructorRef.kt | 16 ++ .../localFunction1.kt | 13 ++ .../localFunction2.kt | 14 ++ .../functionRefToJavaInterface/memberRef.kt | 14 ++ .../nonTrivialReceiver.kt | 23 +++ .../sam/functionRefToJavaInterface/simple.kt | 12 ++ .../functionRefToJavaInterface.kt | 18 ++ .../codegen/BlackBoxCodegenTestGenerated.java | 128 +++++++++++-- .../codegen/BytecodeTextTestGenerated.java | 6 + .../IrBlackBoxCodegenTestGenerated.java | 128 +++++++++++-- .../codegen/IrBytecodeTextTestGenerated.java | 6 + .../LightAnalysisModeTestGenerated.java | 115 +++++++++-- .../IrJsCodegenBoxES6TestGenerated.java | 21 +- .../IrJsCodegenBoxTestGenerated.java | 21 +- .../semantics/JsCodegenBoxTestGenerated.java | 21 +- .../IrCodegenBoxWasmTestGenerated.java | 21 +- 39 files changed, 1005 insertions(+), 135 deletions(-) create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/enhancedNullabilityMix.kt rename compiler/testData/codegen/box/invokedynamic/sam/{functionExpressionArgument => functionExprToJavaInterface}/capturedSamArgument.kt (100%) rename compiler/testData/codegen/box/invokedynamic/sam/{functionExpressionArgument => functionExprToJavaInterface}/capturingLambda.kt (100%) rename compiler/testData/codegen/box/invokedynamic/sam/{functionExpressionArgument => functionExprToJavaInterface}/extensionLambda1.kt (100%) rename compiler/testData/codegen/box/invokedynamic/sam/{functionExpressionArgument => functionExprToJavaInterface}/extensionLambda2.kt (100%) rename compiler/testData/codegen/box/invokedynamic/sam/{functionExpressionArgument => functionExprToJavaInterface}/genericSam1.kt (100%) rename compiler/testData/codegen/box/invokedynamic/sam/{functionExpressionArgument => functionExprToJavaInterface}/genericSam2.kt (100%) rename compiler/testData/codegen/box/invokedynamic/sam/{functionExpressionArgument => functionExprToJavaInterface}/simple.kt (100%) create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithCoercionToUnit.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithDefaultParameters.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithVararg.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundExtFun.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundInnerConstructorRef.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundLocalExtFun.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundMemberRef.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/constructorRef.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/enhancedNullability.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction1.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction2.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/memberRef.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt create mode 100644 compiler/testData/codegen/bytecodeText/invokedynamic/functionRefToJavaInterface.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index af28c640ed0..1d3841fa3bb 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -19997,6 +19997,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt"); } + @Test + @TestMetadata("enhancedNullabilityMix.kt") + public void testEnhancedNullabilityMix() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/enhancedNullabilityMix.kt"); + } + @Test @TestMetadata("genericFunInterface.kt") public void testGenericFunInterface() throws Exception { @@ -20088,54 +20094,154 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } @Nested - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface") @TestDataPath("$PROJECT_ROOT") - public class FunctionExpressionArgument { + public class FunctionExprToJavaInterface { @Test - public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + public void testAllFilesPresentInFunctionExprToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } @Test @TestMetadata("capturedSamArgument.kt") public void testCapturedSamArgument() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturedSamArgument.kt"); } @Test @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturingLambda.kt"); } @Test @TestMetadata("extensionLambda1.kt") public void testExtensionLambda1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda1.kt"); } @Test @TestMetadata("extensionLambda2.kt") public void testExtensionLambda2() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda2.kt"); } @Test @TestMetadata("genericSam1.kt") public void testGenericSam1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam1.kt"); } @Test @TestMetadata("genericSam2.kt") public void testGenericSam2() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam2.kt"); } @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/simple.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface") + @TestDataPath("$PROJECT_ROOT") + public class FunctionRefToJavaInterface { + @Test + @TestMetadata("adaptedFunRefWithCoercionToUnit.kt") + public void testAdaptedFunRefWithCoercionToUnit() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithCoercionToUnit.kt"); + } + + @Test + @TestMetadata("adaptedFunRefWithDefaultParameters.kt") + public void testAdaptedFunRefWithDefaultParameters() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithDefaultParameters.kt"); + } + + @Test + @TestMetadata("adaptedFunRefWithVararg.kt") + public void testAdaptedFunRefWithVararg() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithVararg.kt"); + } + + @Test + public void testAllFilesPresentInFunctionRefToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("boundExtFun.kt") + public void testBoundExtFun() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundExtFun.kt"); + } + + @Test + @TestMetadata("boundInnerConstructorRef.kt") + public void testBoundInnerConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundInnerConstructorRef.kt"); + } + + @Test + @TestMetadata("boundLocalExtFun.kt") + public void testBoundLocalExtFun() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundLocalExtFun.kt"); + } + + @Test + @TestMetadata("boundMemberRef.kt") + public void testBoundMemberRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundMemberRef.kt"); + } + + @Test + @TestMetadata("constructorRef.kt") + public void testConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/constructorRef.kt"); + } + + @Test + @TestMetadata("enhancedNullability.kt") + public void testEnhancedNullability() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/enhancedNullability.kt"); + } + + @Test + @TestMetadata("innerConstructorRef.kt") + public void testInnerConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt"); + } + + @Test + @TestMetadata("localFunction1.kt") + public void testLocalFunction1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction1.kt"); + } + + @Test + @TestMetadata("localFunction2.kt") + public void testLocalFunction2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction2.kt"); + } + + @Test + @TestMetadata("memberRef.kt") + public void testMemberRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/memberRef.kt"); + } + + @Test + @TestMetadata("nonTrivialReceiver.kt") + public void testNonTrivialReceiver() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt"); + } + + @Test + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt"); } } diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java index 85754daa4a0..e7d11e266c3 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java @@ -3944,6 +3944,12 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/invokedynamic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("functionRefToJavaInterface.kt") + public void testFunctionRefToJavaInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/invokedynamic/functionRefToJavaInterface.kt"); + } + @Test @TestMetadata("lambdas.kt") public void testLambdas() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt index 1cebd00bcd4..e885719c80a 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FunctionReferenceLowering.kt @@ -157,6 +157,7 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext) } else { return super.visitTypeOperator(expression) } + reference.transformChildrenVoid() if (shouldGenerateIndySamConversions) { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt index 0622b0ec63c..60cdcacfcb4 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/TypeOperatorLowering.kt @@ -174,7 +174,10 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil override fun visitCall(expression: IrCall): IrExpression { return when (expression.symbol) { - jvmIndyLambdaMetafactoryIntrinsic -> rewriteIndyLambdaMetafactoryCall(expression) + jvmIndyLambdaMetafactoryIntrinsic -> { + expression.transformChildrenVoid() + rewriteIndyLambdaMetafactoryCall(expression) + } else -> super.visitCall(expression) } } @@ -267,10 +270,10 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil private fun wrapClosureInDynamicCall( erasedSamType: IrSimpleType, samMethod: IrSimpleFunction, - irFunRef: IrFunctionReference + targetRef: IrFunctionReference ): IrCall { fun fail(message: String): Nothing = - throw AssertionError("$message, irFunRef:\n${irFunRef.dump()}") + throw AssertionError("$message, irFunRef:\n${targetRef.dump()}") val dynamicCallArguments = ArrayList() @@ -281,32 +284,45 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil }.apply { parent = context.ir.symbols.kotlinJvmInternalInvokeDynamicPackage + val targetFun = targetRef.symbol.owner + val refDispatchReceiver = targetRef.dispatchReceiver + val refExtensionReceiver = targetRef.extensionReceiver + var syntheticParameterIndex = 0 - val targetFun = irFunRef.symbol.owner - - val targetDispatchReceiverParameter = targetFun.dispatchReceiverParameter - if (targetDispatchReceiverParameter != null) { - addValueParameter("p${syntheticParameterIndex++}", targetDispatchReceiverParameter.type) - val dispatchReceiver = irFunRef.dispatchReceiver - ?: fail("Captured dispatch receiver is not provided") - dynamicCallArguments.add(dispatchReceiver) - } - - val targetExtensionReceiverParameter = targetFun.extensionReceiverParameter - if (targetExtensionReceiverParameter != null && irFunRef.extensionReceiver != null) { - addValueParameter("p${syntheticParameterIndex++}", targetExtensionReceiverParameter.type) - val extensionReceiver = irFunRef.extensionReceiver!! - dynamicCallArguments.add(extensionReceiver) + var argumentStart = 0 + when (targetFun) { + is IrSimpleFunction -> { + if (refDispatchReceiver != null) { + addValueParameter("p${syntheticParameterIndex++}", targetFun.dispatchReceiverParameter!!.type) + dynamicCallArguments.add(refDispatchReceiver) + } + if (refExtensionReceiver != null) { + addValueParameter("p${syntheticParameterIndex++}", targetFun.extensionReceiverParameter!!.type) + dynamicCallArguments.add(refExtensionReceiver) + } + } + is IrConstructor -> { + // At this point, outer class instances in inner class constructors are represented as regular value parameters. + // However, in a function reference to such constructors, bound receiver value is stored as a dispatch receiver. + if (refDispatchReceiver != null) { + addValueParameter("p${syntheticParameterIndex++}", targetFun.valueParameters[0].type) + dynamicCallArguments.add(refDispatchReceiver) + argumentStart++ + } + } + else -> { + throw AssertionError("Unexpected function: ${targetFun.render()}") + } } val samMethodValueParametersCount = samMethod.valueParameters.size + - if (samMethod.extensionReceiverParameter != null && irFunRef.extensionReceiver == null) 1 else 0 + if (samMethod.extensionReceiverParameter != null && refExtensionReceiver == null) 1 else 0 val targetFunValueParametersCount = targetFun.valueParameters.size - for (i in 0 until targetFunValueParametersCount - samMethodValueParametersCount) { + for (i in argumentStart until targetFunValueParametersCount - samMethodValueParametersCount) { val targetFunValueParameter = targetFun.valueParameters[i] addValueParameter("p${syntheticParameterIndex++}", targetFunValueParameter.type) - val capturedValueArgument = irFunRef.getValueArgument(i) - ?: fail("Captured value argument #$i (${targetFunValueParameter.name}) not provided") + val capturedValueArgument = targetRef.getValueArgument(i) + ?: fail("Captured value argument #$i (${targetFunValueParameter.render()}) not provided") dynamicCallArguments.add(capturedValueArgument) } } @@ -320,7 +336,7 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil "dynamicCallArguments:\n" + dynamicCallArguments .withIndex() - .joinToString(separator = "\n ", prefix = "[\n ", postfix = "\n]") { (index, irArg) -> + .joinToString(separator = "\n ", prefix = "[\n ", postfix = "\n]") { (index, irArg) -> "#$index: ${irArg.dump()}" } ) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt index bcf1aa2ffa5..f23c451fc17 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound import org.jetbrains.kotlin.backend.jvm.ir.getSingleAbstractMethod import org.jetbrains.kotlin.backend.jvm.ir.isCompiledToJvmDefault +import org.jetbrains.kotlin.backend.jvm.ir.isFromJava import org.jetbrains.kotlin.backend.jvm.lower.findInterfaceImplementation import org.jetbrains.kotlin.builtins.functions.BuiltInFunctionArity import org.jetbrains.kotlin.descriptors.Modality @@ -24,12 +25,10 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionReferenceImpl import org.jetbrains.kotlin.ir.overrides.buildFakeOverrideMember import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl import org.jetbrains.kotlin.ir.types.* -import org.jetbrains.kotlin.ir.util.dump -import org.jetbrains.kotlin.ir.util.functions -import org.jetbrains.kotlin.ir.util.getInlineClassUnderlyingType -import org.jetbrains.kotlin.ir.util.render +import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.utils.addIfNotNull internal class LambdaMetafactoryArguments( val samMethod: IrSimpleFunction, @@ -50,13 +49,14 @@ internal class LambdaMetafactoryArgumentsBuilder( samType: IrType, plainLambda: Boolean ): LambdaMetafactoryArguments? { - // Can't use JDK LambdaMetafactory for function references by default (because of 'equals'). - // TODO special mode that would generate indy everywhere? - if (reference.origin != IrStatementOrigin.LAMBDA) - return null - val samClass = samType.getClass() ?: throw AssertionError("SAM type is not a class: ${samType.render()}") + + // Can't use JDK LambdaMetafactory for function references by default (because of 'equals'). + // TODO special mode that would generate indy everywhere? + if (reference.origin != IrStatementOrigin.LAMBDA && !samClass.isFromJava()) + return null + val samMethod = samClass.getSingleAbstractMethod() ?: throw AssertionError("SAM class has no single abstract method: ${samClass.render()}") @@ -68,32 +68,31 @@ internal class LambdaMetafactoryArgumentsBuilder( if (samClass.requiresDelegationToDefaultImpls()) return null - val target = reference.symbol.owner as? IrSimpleFunction - ?: throw AssertionError("Simple function expected: ${reference.symbol.owner.render()}") + val implFun = reference.symbol.owner // Can't use JDK LambdaMetafactory for annotated lambdas. // JDK LambdaMetafactory doesn't copy annotations from implementation method to an instance method in a // corresponding synthetic class, which doesn't look like a binary compatible change. // TODO relaxed mode? - if (target.annotations.isNotEmpty()) + if (implFun.annotations.isNotEmpty()) return null // Don't use JDK LambdaMetafactory for big arity lambdas. if (plainLambda) { - var parametersCount = target.valueParameters.size - if (target.extensionReceiverParameter != null) ++parametersCount + var parametersCount = implFun.valueParameters.size + if (implFun.extensionReceiverParameter != null) ++parametersCount if (parametersCount >= BuiltInFunctionArity.BIG_ARITY) return null } // Can't use indy-based SAM conversion inside inline fun (Ok in inline lambda). - if (target.parents.any { it.isInlineFunction() || it.isCrossinlineLambda() }) + if (implFun.parents.any { it.isInlineFunction() || it.isCrossinlineLambda() }) return null // Do the hard work of matching Kotlin functional interface hierarchy against LambdaMetafactory constraints. // Briefly: sometimes we have to force boxing on the primitive and inline class values, sometimes we have to keep them unboxed. // If this results in conflicting requirements, we can't use INVOKEDYNAMIC with LambdaMetafactory for creating a closure. - return getLambdaMetafactoryArgsOrNullInner(reference, samMethod, samType, target) + return getLambdaMetafactoryArgsOrNullInner(reference, samMethod, samType, implFun) } private fun IrClass.requiresDelegationToDefaultImpls(): Boolean { @@ -118,7 +117,7 @@ internal class LambdaMetafactoryArgumentsBuilder( reference: IrFunctionReference, samMethod: IrSimpleFunction, samType: IrType, - implLambda: IrSimpleFunction + implFun: IrFunction ): LambdaMetafactoryArguments? { val nonFakeOverriddenFuns = samMethod.allOverridden().filterNot { it.isFakeOverride } val relevantOverriddenFuns = if (samMethod.isFakeOverride) nonFakeOverriddenFuns else nonFakeOverriddenFuns + samMethod @@ -191,16 +190,23 @@ internal class LambdaMetafactoryArgumentsBuilder( // We should have bailed out before if we encountered any kind of type adaptation conflict. // Still, check that we are fine - just in case. - if (signatureAdaptationConstraints.returnType == TypeAdaptationConstraint.CONFLICT || - signatureAdaptationConstraints.valueParameters.values.any { it == TypeAdaptationConstraint.CONFLICT } - ) + if (signatureAdaptationConstraints.hasConflicts()) return null adaptFakeInstanceMethodSignature(fakeInstanceMethod, signatureAdaptationConstraints) + if (implFun.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA) { + adaptLambdaSignature(implFun as IrSimpleFunction, fakeInstanceMethod, signatureAdaptationConstraints) + } else if ( + !checkMethodSignatureCompliance(implFun, fakeInstanceMethod, signatureAdaptationConstraints, reference) + ) { + return null + } - adaptLambdaSignature(implLambda, fakeInstanceMethod, signatureAdaptationConstraints) - - val newReference = remapExtensionLambda(implLambda, reference) + val newReference = + if (implFun.origin == IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA) + remapExtensionLambda(implFun as IrSimpleFunction, reference) + else + reference if (samMethod.isFakeOverride && nonFakeOverriddenFuns.size == 1) { return LambdaMetafactoryArguments(nonFakeOverriddenFuns.single(), fakeInstanceMethod, newReference, listOf()) @@ -208,32 +214,73 @@ internal class LambdaMetafactoryArgumentsBuilder( return LambdaMetafactoryArguments(samMethod, fakeInstanceMethod, newReference, nonFakeOverriddenFuns) } - private fun adaptLambdaSignature( - lambda: IrSimpleFunction, + private fun checkMethodSignatureCompliance( + implFun: IrFunction, fakeInstanceMethod: IrSimpleFunction, - constraints: SignatureAdaptationConstraints - ) { - val lambdaParameters = collectValueParameters(lambda) + constraints: SignatureAdaptationConstraints, + reference: IrFunctionReference + ): Boolean { + val implParameters = collectValueParameters( + implFun, + withDispatchReceiver = reference.dispatchReceiver == null, + withExtensionReceiver = reference.extensionReceiver == null + ) val methodParameters = collectValueParameters(fakeInstanceMethod) - if (lambdaParameters.size != methodParameters.size) + if (implParameters.size != methodParameters.size) throw AssertionError( "Mismatching lambda and instance method parameters:\n" + - "lambda: ${lambda.render()}\n" + - " (${lambdaParameters.size} parameters)\n" + + "implFun: ${implFun.render()}\n" + + " (${implParameters.size} parameters)\n" + "instance method: ${fakeInstanceMethod.render()}\n" + " (${methodParameters.size} parameters)" ) - for ((lambdaParameter, methodParameter) in lambdaParameters.zip(methodParameters)) { - // TODO box inline class parameters only? - val parameterConstraint = constraints.valueParameters[methodParameter] - if (parameterConstraint == TypeAdaptationConstraint.FORCE_BOXING) { - lambdaParameter.type = lambdaParameter.type.makeNullable() - } + for ((implParameter, methodParameter) in implParameters.zip(methodParameters)) { + val constraint = constraints.valueParameters[methodParameter] + if (!checkTypeCompliesWithConstraint(implParameter.type, constraint)) + return false } - if (constraints.returnType == TypeAdaptationConstraint.FORCE_BOXING) { - lambda.returnType = lambda.returnType.makeNullable() + if (!checkTypeCompliesWithConstraint(implFun.returnType, constraints.returnType)) + return false + return true + } + + private fun checkTypeCompliesWithConstraint(irType: IrType, constraint: TypeAdaptationConstraint?): Boolean = + when (constraint) { + null -> true + TypeAdaptationConstraint.FORCE_BOXING -> irType.isNullable() + TypeAdaptationConstraint.KEEP_UNBOXED -> !irType.isNullable() + TypeAdaptationConstraint.BOX_PRIMITIVE -> irType.isJvmPrimitiveOrNullable() + TypeAdaptationConstraint.CONFLICT -> false } + private fun adaptLambdaSignature( + implFun: IrSimpleFunction, + fakeInstanceMethod: IrSimpleFunction, + constraints: SignatureAdaptationConstraints + ) { + if (implFun.origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA) { + throw AssertionError("Can't adapt non-lambda function signature: ${implFun.render()}") + } + + val implParameters = collectValueParameters(implFun) + val methodParameters = collectValueParameters(fakeInstanceMethod) + if (implParameters.size != methodParameters.size) + throw AssertionError( + "Mismatching lambda and instance method parameters:\n" + + "implFun: ${implFun.render()}\n" + + " (${implParameters.size} parameters)\n" + + "instance method: ${fakeInstanceMethod.render()}\n" + + " (${methodParameters.size} parameters)" + ) + for ((implParameter, methodParameter) in implParameters.zip(methodParameters)) { + val parameterConstraint = constraints.valueParameters[methodParameter] + if (parameterConstraint.requiresImplLambdaBoxing()) { + implParameter.type = implParameter.type.makeNullable() + } + } + if (constraints.returnType.requiresImplLambdaBoxing()) { + implFun.returnType = implFun.returnType.makeNullable() + } } private fun remapExtensionLambda(lambda: IrSimpleFunction, reference: IrFunctionReference): IrFunctionReference { @@ -285,25 +332,36 @@ internal class LambdaMetafactoryArgumentsBuilder( "Unexpected value parameter: ${valueParameter.render()}; fakeInstanceMethod:\n" + fakeInstanceMethod.dump() ) - if (constraint == TypeAdaptationConstraint.FORCE_BOXING) { + if (constraint.requiresInstanceMethodBoxing()) { valueParameter.type = valueParameter.type.makeNullable() } } - if (constraints.returnType == TypeAdaptationConstraint.FORCE_BOXING) { + if (constraints.returnType.requiresInstanceMethodBoxing()) { fakeInstanceMethod.returnType = fakeInstanceMethod.returnType.makeNullable() } } private enum class TypeAdaptationConstraint { FORCE_BOXING, + BOX_PRIMITIVE, KEEP_UNBOXED, CONFLICT } + private fun TypeAdaptationConstraint?.requiresInstanceMethodBoxing() = + this == TypeAdaptationConstraint.FORCE_BOXING || this == TypeAdaptationConstraint.BOX_PRIMITIVE + + private fun TypeAdaptationConstraint?.requiresImplLambdaBoxing() = + this == TypeAdaptationConstraint.FORCE_BOXING + private class SignatureAdaptationConstraints( val valueParameters: Map, val returnType: TypeAdaptationConstraint? - ) + ) { + fun hasConflicts() = + returnType == TypeAdaptationConstraint.CONFLICT || + TypeAdaptationConstraint.CONFLICT in valueParameters.values + } private fun computeSignatureAdaptationConstraints( adapteeFun: IrSimpleFunction, @@ -353,10 +411,13 @@ internal class LambdaMetafactoryArgumentsBuilder( // All Kotlin types mapped to JVM primitive are final, // and their supertypes are trivially mapped reference types. if (adapteeType.isJvmPrimitiveType()) { - return if (expectedType.isJvmPrimitiveType()) + return if ( + expectedType.isJvmPrimitiveType() && + !expectedType.hasAnnotation(context.ir.symbols.enhancedNullabilityAnnotationFqName) + ) TypeAdaptationConstraint.KEEP_UNBOXED else - TypeAdaptationConstraint.FORCE_BOXING + TypeAdaptationConstraint.BOX_PRIMITIVE } // ** Inline classes ** @@ -459,13 +520,29 @@ internal class LambdaMetafactoryArgumentsBuilder( private fun IrType.isJvmPrimitiveType() = isBoolean() || isChar() || isByte() || isShort() || isInt() || isLong() || isFloat() || isDouble() -} -fun collectValueParameters(irFun: IrFunction): List { - if (irFun.extensionReceiverParameter == null) - return irFun.valueParameters - return ArrayList().apply { - add(irFun.extensionReceiverParameter!!) - addAll(irFun.valueParameters) + private fun IrType.isJvmPrimitiveOrNullable() = + isBooleanOrNullable() || isCharOrNullable() || + isByteOrNullable() || isShortOrNullable() || isIntOrNullable() || isLongOrNullable() || + isFloatOrNullable() || isDoubleOrNullable() + + fun collectValueParameters( + irFun: IrFunction, + withDispatchReceiver: Boolean = false, + withExtensionReceiver: Boolean = true + ): List { + if ((!withDispatchReceiver || irFun.dispatchReceiverParameter == null) && + (!withExtensionReceiver || irFun.extensionReceiverParameter == null) + ) + return irFun.valueParameters + return ArrayList().apply { + if (withDispatchReceiver) { + addIfNotNull(irFun.dispatchReceiverParameter) + } + if (withExtensionReceiver) { + addIfNotNull(irFun.extensionReceiverParameter) + } + addAll(irFun.valueParameters) + } } -} \ No newline at end of file +} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt index ad70cbe9834..f023b5dfdfa 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/irTypePredicates.kt @@ -109,17 +109,25 @@ fun IrType.isMarkedNullable() = (this as? IrSimpleType)?.hasQuestionMark ?: fals fun IrType.isUnit() = isNotNullClassType(IdSignatureValues.unit) fun IrType.isBoolean(): Boolean = isNotNullClassType(IdSignatureValues._boolean) +fun IrType.isBooleanOrNullable(): Boolean = isClassType(IdSignatureValues._boolean) fun IrType.isChar(): Boolean = isNotNullClassType(IdSignatureValues._char) +fun IrType.isCharOrNullable(): Boolean = isClassType(IdSignatureValues._char) fun IrType.isByte(): Boolean = isNotNullClassType(IdSignatureValues._byte) +fun IrType.isByteOrNullable(): Boolean = isClassType(IdSignatureValues._byte) fun IrType.isShort(): Boolean = isNotNullClassType(IdSignatureValues._short) +fun IrType.isShortOrNullable(): Boolean = isClassType(IdSignatureValues._short) fun IrType.isInt(): Boolean = isNotNullClassType(IdSignatureValues._int) +fun IrType.isIntOrNullable(): Boolean = isClassType(IdSignatureValues._int) fun IrType.isLong(): Boolean = isNotNullClassType(IdSignatureValues._long) +fun IrType.isLongOrNullable(): Boolean = isClassType(IdSignatureValues._long) fun IrType.isUByte(): Boolean = isNotNullClassType(IdSignatureValues.uByte) fun IrType.isUShort(): Boolean = isNotNullClassType(IdSignatureValues.uShort) fun IrType.isUInt(): Boolean = isNotNullClassType(IdSignatureValues.uInt) fun IrType.isULong(): Boolean = isNotNullClassType(IdSignatureValues.uLong) fun IrType.isFloat(): Boolean = isNotNullClassType(IdSignatureValues._float) +fun IrType.isFloatOrNullable(): Boolean = isClassType(IdSignatureValues._float) fun IrType.isDouble(): Boolean = isNotNullClassType(IdSignatureValues._double) +fun IrType.isDoubleOrNullable(): Boolean = isClassType(IdSignatureValues._double) fun IrType.isNumber(): Boolean = isNotNullClassType(IdSignatureValues.number) fun IrType.isComparable(): Boolean = isNotNullClassType(IdSignatureValues.comparable) diff --git a/compiler/testData/codegen/box/invokedynamic/sam/enhancedNullabilityMix.kt b/compiler/testData/codegen/box/invokedynamic/sam/enhancedNullabilityMix.kt new file mode 100644 index 00000000000..af1503754b8 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/enhancedNullabilityMix.kt @@ -0,0 +1,29 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: enhancedNullability.kt +fun interface IGetInt { + fun get(x: Int): Int +} + +// fun interface IGetIntMix0 : IGetInt, Sam +// ^ Error: [FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS] Fun interfaces must have exactly one abstract method + +fun interface IGetIntMix1 : IGetInt, Sam { + override fun get(x: Int): Int +} + +fun box(): String { + val t1 = IGetIntMix1 { it: Int -> it * 2 }.get(21) + if (t1 != 42) + return "Failed: t1=$t1" + + return "OK" +} + +// FILE: Sam.java +import org.jetbrains.annotations.*; + +public interface Sam { + @NotNull Integer get(@NotNull Integer arg); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturedSamArgument.kt similarity index 100% rename from compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt rename to compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturedSamArgument.kt diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturingLambda.kt similarity index 100% rename from compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt rename to compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturingLambda.kt diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda1.kt similarity index 100% rename from compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt rename to compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda1.kt diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda2.kt similarity index 100% rename from compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt rename to compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda2.kt diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam1.kt similarity index 100% rename from compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt rename to compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam1.kt diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam2.kt similarity index 100% rename from compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt rename to compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam2.kt diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/simple.kt similarity index 100% rename from compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt rename to compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/simple.kt diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithCoercionToUnit.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithCoercionToUnit.kt new file mode 100644 index 00000000000..051139d22f3 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithCoercionToUnit.kt @@ -0,0 +1,20 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: adaptedFunRefWithCoercionToUnit.kt +var ok = "Failed" + +fun test(s: String): Int { + ok = s + return 42 +} + +fun box(): String { + Sam(::test).foo("OK") + return ok +} + +// FILE: Sam.java +public interface Sam { + void foo(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithDefaultParameters.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithDefaultParameters.kt new file mode 100644 index 00000000000..1dece0518bd --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithDefaultParameters.kt @@ -0,0 +1,19 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: adaptedFunRefWithDefaultParameters.kt +var ok = "Failed" + +fun test(s1: String, s2: String = "K") { + ok = s1 + s2 +} + +fun box(): String { + Sam(::test).foo("O") + return ok +} + +// FILE: Sam.java +public interface Sam { + void foo(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithVararg.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithVararg.kt new file mode 100644 index 00000000000..6aedd90a58b --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithVararg.kt @@ -0,0 +1,19 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: adaptedFunRefWithVararg.kt +var ok = "Failed" + +fun test(vararg ss: String) { + ok = ss[0] +} + +fun box(): String { + Sam(::test).foo("OK") + return ok +} + +// FILE: Sam.java +public interface Sam { + void foo(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundExtFun.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundExtFun.kt new file mode 100644 index 00000000000..37b2778d920 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundExtFun.kt @@ -0,0 +1,13 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: boundExtFun.kt +fun String.k(s: String) = this + s + "K" + +fun box() = Sam("O"::k).get("") +// NB simply '::k' is a compilation error + +// FILE: Sam.java +public interface Sam { + String get(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundInnerConstructorRef.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundInnerConstructorRef.kt new file mode 100644 index 00000000000..a93ede92537 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundInnerConstructorRef.kt @@ -0,0 +1,16 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: boundInnerConstructorRef.kt +class Outer(val s1: String) { + inner class Inner(val s2: String) { + fun t() = s1 + s2 + } +} + +fun box() = Sam(Outer("O")::Inner).get("K").t() + +// FILE: Sam.java +public interface Sam { + Outer.Inner get(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundLocalExtFun.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundLocalExtFun.kt new file mode 100644 index 00000000000..d81e9f15824 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundLocalExtFun.kt @@ -0,0 +1,15 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: boundLocalExtFun.kt +fun box(): String { + fun String.k(s: String) = this + s + "K" + + return Sam("O"::k).get("") + // NB simply '::k' is a compilation error +} + +// FILE: Sam.java +public interface Sam { + String get(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundMemberRef.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundMemberRef.kt new file mode 100644 index 00000000000..09a7ccf3d88 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundMemberRef.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: boundMemberRef.kt +class C(val t: String) { + fun test() = t +} + +fun box() = Sam(C("OK")::test).get() + +// FILE: Sam.java +public interface Sam { + String get(); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/constructorRef.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/constructorRef.kt new file mode 100644 index 00000000000..ddb91892162 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/constructorRef.kt @@ -0,0 +1,12 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: constructorRef.kt +class C(val t: String) + +fun box() = Sam(::C).get("OK").t + +// FILE: Sam.java +public interface Sam { + C get(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/enhancedNullability.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/enhancedNullability.kt new file mode 100644 index 00000000000..ee4031fb43a --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/enhancedNullability.kt @@ -0,0 +1,20 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND_FIR: JVM_IR +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: enhancedNullability.kt +fun mul2(x: Int) = x * 2 + +fun box(): String { + val t = Sam(::mul2).get(21) + if (t != 42) + return "Failed: t=$t" + return "OK" +} + +// FILE: Sam.java +import org.jetbrains.annotations.*; + +public interface Sam { + @NotNull Integer get(@NotNull Integer arg); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt new file mode 100644 index 00000000000..0a9ca2cd817 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt @@ -0,0 +1,16 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: innerConstructorRef.kt +class Outer(val s1: String) { + inner class Inner(val s2: String) { + fun t() = s1 + s2 + } +} + +fun box() = Sam(Outer::Inner).get(Outer("O"), "K").t() + +// FILE: Sam.java +public interface Sam { + Outer.Inner get(Outer outer, String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction1.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction1.kt new file mode 100644 index 00000000000..3fa6e721122 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction1.kt @@ -0,0 +1,13 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: localFunction1.kt +fun box(): String { + fun ok() = "OK" + return Sam(::ok).get() +} + +// FILE: Sam.java +public interface Sam { + String get(); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction2.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction2.kt new file mode 100644 index 00000000000..8555c03b2f9 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction2.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: localFunction2.kt +fun box(): String { + val t = "O" + fun ok() = t + "K" + return Sam(::ok).get() +} + +// FILE: Sam.java +public interface Sam { + String get(); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/memberRef.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/memberRef.kt new file mode 100644 index 00000000000..fb96f2b3755 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/memberRef.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: memberRef.kt +class C(val t: String) { + fun test() = t +} + +fun box() = Sam(C::test).get(C("OK")) + +// FILE: Sam.java +public interface Sam { + String get(C c); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt new file mode 100644 index 00000000000..92bbfbfb287 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt @@ -0,0 +1,23 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// WITH_RUNTIME +// FILE: JavaRunner.java +public class JavaRunner { + public static void runTwice(Runnable runnable) { + runnable.run(); + runnable.run(); + } +} + +// FILE: nonTrivialReceiver.kt +class A() { + fun f() {} +} + +fun box(): String { + var x = 0 + JavaRunner.runTwice({ x++; A() }()::f) + if (x != 1) return "Fail" + return "OK" +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt new file mode 100644 index 00000000000..161c04b8c87 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt @@ -0,0 +1,12 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: simple.kt +fun ok() = "OK" + +fun box() = Sam(::ok).get() + +// FILE: Sam.java +public interface Sam { + String get(); +} diff --git a/compiler/testData/codegen/bytecodeText/invokedynamic/functionRefToJavaInterface.kt b/compiler/testData/codegen/bytecodeText/invokedynamic/functionRefToJavaInterface.kt new file mode 100644 index 00000000000..be636c2ae6f --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/invokedynamic/functionRefToJavaInterface.kt @@ -0,0 +1,18 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// WITH_RUNTIME +// FULL_JDK + +fun hello() { println("Hello, world!") } + +val test = Runnable(::hello) + +// JVM_TEMPLATES: +// 1 public final class FunctionRefToJavaInterfaceKt +// 1 final synthetic class FunctionRefToJavaInterfaceKt\$sam\$java_lang_Runnable\$0 +// 1 final synthetic class FunctionRefToJavaInterfaceKt\$test\$1 + +// JVM_IR_TEMPLATES: +// 1 INVOKEDYNAMIC +// 1 class FunctionRefToJavaInterfaceKt diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index c05ea81c681..04cd5241f1a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -19997,6 +19997,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt"); } + @Test + @TestMetadata("enhancedNullabilityMix.kt") + public void testEnhancedNullabilityMix() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/enhancedNullabilityMix.kt"); + } + @Test @TestMetadata("genericFunInterface.kt") public void testGenericFunInterface() throws Exception { @@ -20088,54 +20094,154 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } @Nested - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface") @TestDataPath("$PROJECT_ROOT") - public class FunctionExpressionArgument { + public class FunctionExprToJavaInterface { @Test - public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + public void testAllFilesPresentInFunctionExprToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } @Test @TestMetadata("capturedSamArgument.kt") public void testCapturedSamArgument() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturedSamArgument.kt"); } @Test @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturingLambda.kt"); } @Test @TestMetadata("extensionLambda1.kt") public void testExtensionLambda1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda1.kt"); } @Test @TestMetadata("extensionLambda2.kt") public void testExtensionLambda2() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda2.kt"); } @Test @TestMetadata("genericSam1.kt") public void testGenericSam1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam1.kt"); } @Test @TestMetadata("genericSam2.kt") public void testGenericSam2() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam2.kt"); } @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/simple.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface") + @TestDataPath("$PROJECT_ROOT") + public class FunctionRefToJavaInterface { + @Test + @TestMetadata("adaptedFunRefWithCoercionToUnit.kt") + public void testAdaptedFunRefWithCoercionToUnit() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithCoercionToUnit.kt"); + } + + @Test + @TestMetadata("adaptedFunRefWithDefaultParameters.kt") + public void testAdaptedFunRefWithDefaultParameters() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithDefaultParameters.kt"); + } + + @Test + @TestMetadata("adaptedFunRefWithVararg.kt") + public void testAdaptedFunRefWithVararg() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithVararg.kt"); + } + + @Test + public void testAllFilesPresentInFunctionRefToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("boundExtFun.kt") + public void testBoundExtFun() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundExtFun.kt"); + } + + @Test + @TestMetadata("boundInnerConstructorRef.kt") + public void testBoundInnerConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundInnerConstructorRef.kt"); + } + + @Test + @TestMetadata("boundLocalExtFun.kt") + public void testBoundLocalExtFun() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundLocalExtFun.kt"); + } + + @Test + @TestMetadata("boundMemberRef.kt") + public void testBoundMemberRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundMemberRef.kt"); + } + + @Test + @TestMetadata("constructorRef.kt") + public void testConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/constructorRef.kt"); + } + + @Test + @TestMetadata("enhancedNullability.kt") + public void testEnhancedNullability() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/enhancedNullability.kt"); + } + + @Test + @TestMetadata("innerConstructorRef.kt") + public void testInnerConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt"); + } + + @Test + @TestMetadata("localFunction1.kt") + public void testLocalFunction1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction1.kt"); + } + + @Test + @TestMetadata("localFunction2.kt") + public void testLocalFunction2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction2.kt"); + } + + @Test + @TestMetadata("memberRef.kt") + public void testMemberRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/memberRef.kt"); + } + + @Test + @TestMetadata("nonTrivialReceiver.kt") + public void testNonTrivialReceiver() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt"); + } + + @Test + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt"); } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java index 8129e3d2031..2953fa9dad3 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java @@ -3812,6 +3812,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/invokedynamic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("functionRefToJavaInterface.kt") + public void testFunctionRefToJavaInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/invokedynamic/functionRefToJavaInterface.kt"); + } + @Test @TestMetadata("lambdas.kt") public void testLambdas() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 74aeafa291a..3ee926efb95 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -19997,6 +19997,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt"); } + @Test + @TestMetadata("enhancedNullabilityMix.kt") + public void testEnhancedNullabilityMix() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/enhancedNullabilityMix.kt"); + } + @Test @TestMetadata("genericFunInterface.kt") public void testGenericFunInterface() throws Exception { @@ -20088,54 +20094,154 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } @Nested - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface") @TestDataPath("$PROJECT_ROOT") - public class FunctionExpressionArgument { + public class FunctionExprToJavaInterface { @Test - public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + public void testAllFilesPresentInFunctionExprToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } @Test @TestMetadata("capturedSamArgument.kt") public void testCapturedSamArgument() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturedSamArgument.kt"); } @Test @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturingLambda.kt"); } @Test @TestMetadata("extensionLambda1.kt") public void testExtensionLambda1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda1.kt"); } @Test @TestMetadata("extensionLambda2.kt") public void testExtensionLambda2() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda2.kt"); } @Test @TestMetadata("genericSam1.kt") public void testGenericSam1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam1.kt"); } @Test @TestMetadata("genericSam2.kt") public void testGenericSam2() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam2.kt"); } @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/simple.kt"); + } + } + + @Nested + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface") + @TestDataPath("$PROJECT_ROOT") + public class FunctionRefToJavaInterface { + @Test + @TestMetadata("adaptedFunRefWithCoercionToUnit.kt") + public void testAdaptedFunRefWithCoercionToUnit() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithCoercionToUnit.kt"); + } + + @Test + @TestMetadata("adaptedFunRefWithDefaultParameters.kt") + public void testAdaptedFunRefWithDefaultParameters() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithDefaultParameters.kt"); + } + + @Test + @TestMetadata("adaptedFunRefWithVararg.kt") + public void testAdaptedFunRefWithVararg() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithVararg.kt"); + } + + @Test + public void testAllFilesPresentInFunctionRefToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("boundExtFun.kt") + public void testBoundExtFun() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundExtFun.kt"); + } + + @Test + @TestMetadata("boundInnerConstructorRef.kt") + public void testBoundInnerConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundInnerConstructorRef.kt"); + } + + @Test + @TestMetadata("boundLocalExtFun.kt") + public void testBoundLocalExtFun() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundLocalExtFun.kt"); + } + + @Test + @TestMetadata("boundMemberRef.kt") + public void testBoundMemberRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundMemberRef.kt"); + } + + @Test + @TestMetadata("constructorRef.kt") + public void testConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/constructorRef.kt"); + } + + @Test + @TestMetadata("enhancedNullability.kt") + public void testEnhancedNullability() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/enhancedNullability.kt"); + } + + @Test + @TestMetadata("innerConstructorRef.kt") + public void testInnerConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt"); + } + + @Test + @TestMetadata("localFunction1.kt") + public void testLocalFunction1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction1.kt"); + } + + @Test + @TestMetadata("localFunction2.kt") + public void testLocalFunction2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction2.kt"); + } + + @Test + @TestMetadata("memberRef.kt") + public void testMemberRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/memberRef.kt"); + } + + @Test + @TestMetadata("nonTrivialReceiver.kt") + public void testNonTrivialReceiver() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt"); + } + + @Test + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt"); } } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java index e2bc8b6d9f3..67908bf703c 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java @@ -3944,6 +3944,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/invokedynamic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("functionRefToJavaInterface.kt") + public void testFunctionRefToJavaInterface() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/invokedynamic/functionRefToJavaInterface.kt"); + } + @Test @TestMetadata("lambdas.kt") public void testLambdas() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 640a8f49110..e155f40e682 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -16771,6 +16771,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/covariantOverrideWithPrimitive.kt"); } + @TestMetadata("enhancedNullabilityMix.kt") + public void testEnhancedNullabilityMix() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/enhancedNullabilityMix.kt"); + } + @TestMetadata("genericFunInterface.kt") public void testGenericFunInterface() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterface.kt"); @@ -16841,51 +16846,139 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/unboundFunctionReferenceEquality.kt"); } - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class FunctionExpressionArgument extends AbstractLightAnalysisModeTest { + public static class FunctionExprToJavaInterface extends AbstractLightAnalysisModeTest { private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } - public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + public void testAllFilesPresentInFunctionExprToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } @TestMetadata("capturedSamArgument.kt") public void testCapturedSamArgument() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturedSamArgument.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturedSamArgument.kt"); } @TestMetadata("capturingLambda.kt") public void testCapturingLambda() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/capturingLambda.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/capturingLambda.kt"); } @TestMetadata("extensionLambda1.kt") public void testExtensionLambda1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda1.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda1.kt"); } @TestMetadata("extensionLambda2.kt") public void testExtensionLambda2() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/extensionLambda2.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/extensionLambda2.kt"); } @TestMetadata("genericSam1.kt") public void testGenericSam1() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam1.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam1.kt"); } @TestMetadata("genericSam2.kt") public void testGenericSam2() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/genericSam2.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/genericSam2.kt"); } @TestMetadata("simple.kt") public void testSimple() throws Exception { - runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument/simple.kt"); + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface/simple.kt"); + } + } + + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionRefToJavaInterface extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + @TestMetadata("adaptedFunRefWithCoercionToUnit.kt") + public void testAdaptedFunRefWithCoercionToUnit() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithCoercionToUnit.kt"); + } + + @TestMetadata("adaptedFunRefWithDefaultParameters.kt") + public void testAdaptedFunRefWithDefaultParameters() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithDefaultParameters.kt"); + } + + @TestMetadata("adaptedFunRefWithVararg.kt") + public void testAdaptedFunRefWithVararg() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/adaptedFunRefWithVararg.kt"); + } + + public void testAllFilesPresentInFunctionRefToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("boundExtFun.kt") + public void testBoundExtFun() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundExtFun.kt"); + } + + @TestMetadata("boundInnerConstructorRef.kt") + public void testBoundInnerConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundInnerConstructorRef.kt"); + } + + @TestMetadata("boundLocalExtFun.kt") + public void testBoundLocalExtFun() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundLocalExtFun.kt"); + } + + @TestMetadata("boundMemberRef.kt") + public void testBoundMemberRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/boundMemberRef.kt"); + } + + @TestMetadata("constructorRef.kt") + public void testConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/constructorRef.kt"); + } + + @TestMetadata("enhancedNullability.kt") + public void testEnhancedNullability() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/enhancedNullability.kt"); + } + + @TestMetadata("innerConstructorRef.kt") + public void testInnerConstructorRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt"); + } + + @TestMetadata("localFunction1.kt") + public void testLocalFunction1() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction1.kt"); + } + + @TestMetadata("localFunction2.kt") + public void testLocalFunction2() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction2.kt"); + } + + @TestMetadata("memberRef.kt") + public void testMemberRef() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/memberRef.kt"); + } + + @TestMetadata("nonTrivialReceiver.kt") + public void testNonTrivialReceiver() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt"); + } + + @TestMetadata("simple.kt") + public void testSimple() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt"); } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 9c44c09e21d..4169114a9ee 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -14626,16 +14626,29 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class FunctionExpressionArgument extends AbstractIrJsCodegenBoxES6Test { + public static class FunctionExprToJavaInterface extends AbstractIrJsCodegenBoxES6Test { private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); } - public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + public void testAllFilesPresentInFunctionExprToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionRefToJavaInterface extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInFunctionRefToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index bae8d522aad..015b67503e4 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -14111,16 +14111,29 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class FunctionExpressionArgument extends AbstractIrJsCodegenBoxTest { + public static class FunctionExprToJavaInterface extends AbstractIrJsCodegenBoxTest { private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); } - public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + public void testAllFilesPresentInFunctionExprToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionRefToJavaInterface extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInFunctionRefToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index e2ae4ca6ee8..3ad154677cb 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -14176,16 +14176,29 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class FunctionExpressionArgument extends AbstractJsCodegenBoxTest { + public static class FunctionExprToJavaInterface extends AbstractJsCodegenBoxTest { private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); } - public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + public void testAllFilesPresentInFunctionExprToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionRefToJavaInterface extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInFunctionRefToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 15b59cf2c7b..503d850450b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -8212,16 +8212,29 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } - @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument") + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) - public static class FunctionExpressionArgument extends AbstractIrCodegenBoxWasmTest { + public static class FunctionExprToJavaInterface extends AbstractIrCodegenBoxWasmTest { private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); } - public void testAllFilesPresentInFunctionExpressionArgument() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExpressionArgument"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + public void testAllFilesPresentInFunctionExprToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionExprToJavaInterface"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + + @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunctionRefToJavaInterface extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInFunctionRefToJavaInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } } From 73616107b47f5298be764c33cf548d1ff8a5b865 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 19 Feb 2021 12:19:42 +0300 Subject: [PATCH 290/368] Unmute passing FIR BB test --- .../metadataForMembersInLocalClassInInitializer.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/metadataForMembersInLocalClassInInitializer.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/metadataForMembersInLocalClassInInitializer.kt index 3ed9664d4c8..8eb398f8eef 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/metadataForMembersInLocalClassInInitializer.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/metadataForMembersInLocalClassInInitializer.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_STDLIB // WITH_REFLECT From 3626008ed266251ccc040f039f9348cbc5dac5fe Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 18 Feb 2021 17:27:02 +0300 Subject: [PATCH 291/368] [Inference] Add ability to approximate local types in AbstractTypeApproximator --- .../kotlin/fir/types/ConeTypeContext.kt | 9 +++++--- .../kotlin/ir/types/IrTypeSystemContext.kt | 7 ++++++- .../kotlin/types/AbstractTypeApproximator.kt | 21 ++++++++++++++++--- .../types/TypeApproximatorConfiguration.kt | 1 + .../kotlin/types/model/TypeSystemContext.kt | 1 + .../types/checker/ClassicTypeSystemContext.kt | 10 +++++---- 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt index 647d20f8c14..4740a124e62 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeTypeContext.kt @@ -21,9 +21,7 @@ import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe import org.jetbrains.kotlin.fir.resolve.transformers.ensureResolved -import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag -import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqNameUnsafe @@ -44,6 +42,11 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty return this is ConeIntegerLiteralType } + override fun TypeConstructorMarker.isLocalType(): Boolean { + if (this !is ConeClassLikeLookupTag) return false + return classId.isLocal + } + override fun SimpleTypeMarker.possibleIntegerTypes(): Collection { return (this as? ConeIntegerLiteralType)?.possibleTypes ?: emptyList() } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt index 02df059bcd5..900ae060e46 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt @@ -269,6 +269,11 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon override fun TypeConstructorMarker.isIntegerLiteralTypeConstructor() = false + override fun TypeConstructorMarker.isLocalType(): Boolean { + if (this !is IrClassSymbol) return false + return this.owner.classId?.isLocal == true + } + override fun createFlexibleType(lowerBound: SimpleTypeMarker, upperBound: SimpleTypeMarker): KotlinTypeMarker { require(lowerBound.isNothing()) require(upperBound is IrType && upperBound.isNullableAny()) @@ -516,4 +521,4 @@ fun extractTypeParameters(parent: IrDeclarationParent): List { } -class IrTypeSystemContextImpl(override val irBuiltIns: IrBuiltIns) : IrTypeSystemContext \ No newline at end of file +class IrTypeSystemContextImpl(override val irBuiltIns: IrBuiltIns) : IrTypeSystemContext diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt index d4c8f0e3d50..f72fdde9826 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt @@ -162,6 +162,20 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon } } + private fun approximateLocalTypes(type: SimpleTypeMarker, conf: TypeApproximatorConfiguration, toSuper: Boolean): SimpleTypeMarker? { + if (!toSuper) return null + if (!conf.localTypes) return null + val constructor = type.typeConstructor() + val needApproximate = conf.localTypes && constructor.isLocalType() + if (!needApproximate) return null + val superConstructor = constructor.supertypes().first().typeConstructor() + val typeCheckerContext = newBaseTypeCheckerContext( + errorTypesEqualToAnything = false, + stubTypesEqualToAnything = false + ) + return AbstractTypeChecker.findCorrespondingSupertypes(typeCheckerContext, type, superConstructor).first() + } + private fun isIntersectionTypeEffectivelyNothing(constructor: IntersectionTypeConstructorMarker): Boolean { // We consider intersection as Nothing only if one of it's component is a primitive number type // It's intentional we're not trying to prove population of some type as it was in OI @@ -326,7 +340,7 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon null } - return null // simple classifier type + return approximateLocalTypes(type, conf, toSuper) // simple classifier type } private fun approximateDefinitelyNotNullType( @@ -518,10 +532,11 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon } } - if (newArguments.all { it == null }) return null + if (newArguments.all { it == null }) return approximateLocalTypes(type, conf, toSuper) val newArgumentsList = List(type.argumentsCount()) { index -> newArguments[index] ?: type.getArgument(index) } - return type.replaceArguments(newArgumentsList) + val approximatedType = type.replaceArguments(newArgumentsList) + return approximateLocalTypes(approximatedType, conf, toSuper) ?: approximatedType } private fun KotlinTypeMarker.defaultResult(toSuper: Boolean) = if (toSuper) nullableAnyType() else { diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt index 652f778f88c..ba749411d4d 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/types/TypeApproximatorConfiguration.kt @@ -22,6 +22,7 @@ open class TypeApproximatorConfiguration { open val definitelyNotNullType: Boolean get() = true open val intersection: IntersectionStrategy = IntersectionStrategy.TO_COMMON_SUPERTYPE open val intersectionTypesInContravariantPositions = false + open val localTypes = false open val typeVariable: (TypeVariableTypeConstructorMarker) -> Boolean = { false } open fun capturedType(ctx: TypeSystemInferenceExtensionContext, type: CapturedTypeMarker): Boolean = diff --git a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt index 28051c7825d..9a7ef71838d 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt @@ -304,6 +304,7 @@ interface TypeSystemContext : TypeSystemOptimizationContext { fun TypeConstructorMarker.isIntersection(): Boolean fun TypeConstructorMarker.isClassTypeConstructor(): Boolean fun TypeConstructorMarker.isIntegerLiteralTypeConstructor(): Boolean + fun TypeConstructorMarker.isLocalType(): Boolean fun TypeParameterMarker.getVariance(): TypeVariance fun TypeParameterMarker.upperBoundCount(): Int diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt index f929d3e2598..3744076f1f4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt @@ -17,10 +17,7 @@ import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.inference.CapturedType import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe -import org.jetbrains.kotlin.resolve.descriptorUtil.hasExactAnnotation -import org.jetbrains.kotlin.resolve.descriptorUtil.hasNoInferAnnotation -import org.jetbrains.kotlin.resolve.descriptorUtil.isExactAnnotation +import org.jetbrains.kotlin.resolve.descriptorUtil.* import org.jetbrains.kotlin.resolve.isInlineClass import org.jetbrains.kotlin.resolve.substitutedUnderlyingType import org.jetbrains.kotlin.types.* @@ -42,6 +39,11 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy return this is IntegerLiteralTypeConstructor } + override fun TypeConstructorMarker.isLocalType(): Boolean { + require(this is TypeConstructor, this::errorMessage) + return declarationDescriptor?.classId?.isLocal == true + } + override fun SimpleTypeMarker.possibleIntegerTypes(): Collection { val typeConstructor = typeConstructor() require(typeConstructor is IntegerLiteralTypeConstructor, this::errorMessage) From 804df1aec2c08a9ddc4c55f84510c4c3be9d3435 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 18 Feb 2021 20:26:31 +0100 Subject: [PATCH 292/368] FIR IDE: introduce base class for multifile tests --- .../idea/test/framework/AbstractKtIdeaTest.kt | 88 +++++++++++++++++++ .../kotlin/idea/test/framework/KtTest.kt | 12 +++ .../idea/test/framework/TestFileStructure.kt | 57 ++++++++++++ .../test/framework/TestStructureRenderer.kt | 54 ++++++++++++ 4 files changed, 211 insertions(+) create mode 100644 idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/AbstractKtIdeaTest.kt create mode 100644 idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/KtTest.kt create mode 100644 idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/TestFileStructure.kt create mode 100644 idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/TestStructureRenderer.kt diff --git a/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/AbstractKtIdeaTest.kt b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/AbstractKtIdeaTest.kt new file mode 100644 index 00000000000..6b2d0c2325e --- /dev/null +++ b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/AbstractKtIdeaTest.kt @@ -0,0 +1,88 @@ +/* + * Copyright 2010-2021 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.idea.test.framework + +import com.intellij.openapi.util.io.FileUtil +import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase +import java.io.File + +abstract class AbstractKtIdeaTest : KotlinLightCodeInsightFixtureTestCase() { + protected open val allowedDirectives: List> = emptyList() + + protected fun doTest(path: String) { + val testDataFile = File(path) + val text = FileUtil.loadFile(testDataFile) + val testFileStructure = createTestFileStructure(text, testDataFile) + doTestByFileStructure(testFileStructure) + } + + private fun createTestFileStructure(text: String, testDataFile: File): TestFileStructure { + val files = FileSplitter.splitIntoFiles(text, testDataFile.name) + val mainFile = createTestFile(files.first(), isMainFile = true) + val testFiles = files.drop(1).map { file -> + createTestFile(file, isMainFile = false) + } + val directives = parseDirectives(text) + return TestFileStructure( + filePath = testDataFile.toPath(), + caretPosition = getCaretPosition(text), + directives = directives, + mainFile = mainFile as TestFile.KtTestFile, + otherFiles = testFiles + ) + } + + private fun getCaretPosition(text: String) = text.indexOfOrNull(KtTest.CARET_SYMBOL) + + private fun parseDirectives(text: String): TestFileDirectives { + val directives = text.lineSequence().mapNotNull(::extractDirectiveIfAny) + return TestFileDirectives(directives.toMap()) + } + + private fun extractDirectiveIfAny(line: String): Pair? { + val directive = allowedDirectives.firstOrNull { directive -> line.startsWith(directive.name) } ?: return null + val value = line.substringAfter(directive.name).trim() + val parsedValue = directive.parse(value) + ?: error("Invalid ${directive.name} value `$value`") + return directive.name to parsedValue + } + + private fun createTestFile(file: FileSplitter.FileNameWithText, isMainFile: Boolean): TestFile { + val psiFile = if (isMainFile) { + myFixture.configureByText(file.name, file.text) + } else { + myFixture.addFileToProject(file.name, file.text) + } + return TestFile.createByPsiFile(psiFile) + } + + abstract fun doTestByFileStructure(fileStructure: TestFileStructure) +} + +private object FileSplitter { + data class FileNameWithText(val name: String, val text: String) + + fun splitIntoFiles(text: String, defaultName: String): List { + val result = mutableListOf() + val stopAt = text.indexOfOrNull(KtTest.RESULT_DIRECTIVE) ?: text.length + var index = text.indexOfOrNull(KtTest.FILE_DIRECTIVE) ?: return listOf(FileNameWithText(defaultName, text)) + while (index < stopAt) { + val eolIndex = text.indexOfOrNull("\n", index) ?: text.length + val fileName = text.substring(index + KtTest.FILE_DIRECTIVE.length, eolIndex).trim() + val nextFileIndex = text.indexOfOrNull(KtTest.FILE_DIRECTIVE, index + 1) ?: stopAt + val fileText = text.substring(eolIndex, nextFileIndex).trim() + index = nextFileIndex + result += FileNameWithText(fileName, fileText) + } + return result + } +} + +private fun String.indexOfOrNull(substring: String) = + indexOf(substring).takeIf { it >= 0 } + +private fun String.indexOfOrNull(substring: String, startingIndex: Int) = + indexOf(substring, startingIndex).takeIf { it >= 0 } \ No newline at end of file diff --git a/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/KtTest.kt b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/KtTest.kt new file mode 100644 index 00000000000..353f4866d45 --- /dev/null +++ b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/KtTest.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2010-2021 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.idea.test.framework + +object KtTest { + const val CARET_SYMBOL = "" + const val FILE_DIRECTIVE = "// FILE:" + const val RESULT_DIRECTIVE = "// RESULT" +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/TestFileStructure.kt b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/TestFileStructure.kt new file mode 100644 index 00000000000..336f9cc5287 --- /dev/null +++ b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/TestFileStructure.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2010-2021 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.idea.test.framework + +import com.intellij.psi.PsiFile +import com.intellij.psi.PsiJavaFile +import org.jetbrains.kotlin.psi.KtFile +import java.nio.file.Path + +class TestFileStructure( + val filePath: Path, + val caretPosition: Int?, + val directives: TestFileDirectives, + val mainFile: TestFile.KtTestFile, + val otherFiles: List, +) { + val mainKtFile: KtFile + get() = mainFile.psiFile + + val allFiles: List = listOf(mainFile) + otherFiles +} + +data class TestStructureExpectedDataBlock(val name: String, val values: List) + +class TestFileDirectives( + private val directives: Map +) { + fun > getDirectiveValueIfPresent(directive: DIRECTIVE): VALUE? { + val value = directives[directive.name] ?: return null + @Suppress("UNCHECKED_CAST") + return value as VALUE + } +} + +abstract class TestFileDirective { + abstract val name: String + abstract fun parse(value: String): VALUE? +} + +sealed class TestFile { + abstract val psiFile: PsiFile + + data class KtTestFile(override val psiFile: KtFile) : TestFile() + data class JavaTestFile(override val psiFile: PsiJavaFile) : TestFile() + + companion object { + fun createByPsiFile(psiFile: PsiFile) = when (psiFile) { + is KtFile -> KtTestFile(psiFile) + is PsiJavaFile -> JavaTestFile(psiFile) + else -> error("Unknown file type ${psiFile::class}") + } + } +} + diff --git a/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/TestStructureRenderer.kt b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/TestStructureRenderer.kt new file mode 100644 index 00000000000..97b7f6680ec --- /dev/null +++ b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/test/framework/TestStructureRenderer.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2021 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.idea.test.framework + +object TestStructureRenderer { + fun render(testStructure: TestFileStructure, expectedData: List): String = buildString { + renderFiles(testStructure) + renderExpectedData(expectedData) + renderCaretSymbol(testStructure) + } + + private fun StringBuilder.renderCaretSymbol(testStructure: TestFileStructure) { + testStructure.caretPosition?.let { position -> + insert(position, KtTest.CARET_SYMBOL) + } + } + + private fun StringBuilder.renderFiles(testStructure: TestFileStructure) { + if (testStructure.otherFiles.isEmpty()) { + appendLine(testStructure.mainFile.psiFile.text) + } else { + testStructure.allFiles.forEach { file -> + renderFile(file) + } + } + } + + private fun StringBuilder.renderExpectedData(expectedData: List) { + if (expectedData.isNotEmpty()) { + appendLine(KtTest.RESULT_DIRECTIVE) + appendLine() + expectedData.forEach { block -> + renderExpectedDataBlock(block) + appendLine() + } + } + } + + private fun StringBuilder.renderExpectedDataBlock(block: TestStructureExpectedDataBlock) { + appendLine("// ${block.name}") + block.values.forEach { value -> + appendLine("// $value") + } + } + + private fun StringBuilder.renderFile(file: TestFile) { + appendLine("${KtTest.FILE_DIRECTIVE} ${file.psiFile.name}") + appendLine(file.psiFile.text) + appendLine() + } +} \ No newline at end of file From b08eb6cf4c7b74343659f8c04d269ee1bbf36a9e Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 18 Feb 2021 20:27:39 +0100 Subject: [PATCH 293/368] FIR IDE: specify behaviour of HL API getOverriddenSymbols - Split it into two functions getAllOverriddenSymbols and getDirectlyOverriddenSymbols - Implement tests for getOverriddenSymbols - temporary mute inheritance.kt light classes test --- .../asJava/ultraLightClasses/inheritance.kt | 2 - .../kotlin/generators/tests/GenerateTests.kt | 5 + .../KotlinFindUsagesSupportFirImpl.kt | 2 +- .../ChangeReturnTypeOnOverrideQuickFix.kt | 6 +- .../idea/frontend/api/KtAnalysisSession.kt | 29 ++++- .../KtSymbolDeclarationOverridesProvider.kt | 10 +- .../asJava/classes/FirLightClassForSymbol.kt | 2 +- ...KtFirSymbolDeclarationOverridesProvider.kt | 103 +++++++++++++----- .../overridenDeclarations/inOtherFile.kt | 19 ++++ .../intersectionOverride.kt | 34 ++++++ .../intersectionOverride2.kt | 34 ++++++ .../overridenDeclarations/javaAccessors.kt | 27 +++++ .../multipleInterfaces.kt | 39 +++++++ .../sequenceOfOverrides.kt | 30 +++++ ...stractOverriddenDeclarationProviderTest.kt | 75 +++++++++++++ ...iddenDeclarationProviderTestGenerated.java | 61 +++++++++++ 16 files changed, 435 insertions(+), 43 deletions(-) create mode 100644 idea/idea-frontend-fir/testData/components/overridenDeclarations/inOtherFile.kt create mode 100644 idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride.kt create mode 100644 idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride2.kt create mode 100644 idea/idea-frontend-fir/testData/components/overridenDeclarations/javaAccessors.kt create mode 100644 idea/idea-frontend-fir/testData/components/overridenDeclarations/multipleInterfaces.kt create mode 100644 idea/idea-frontend-fir/testData/components/overridenDeclarations/sequenceOfOverrides.kt create mode 100644 idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/components/AbstractOverriddenDeclarationProviderTest.kt create mode 100644 idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/components/OverriddenDeclarationProviderTestGenerated.java diff --git a/compiler/testData/asJava/ultraLightClasses/inheritance.kt b/compiler/testData/asJava/ultraLightClasses/inheritance.kt index 3b71ba7d286..dba936c8021 100644 --- a/compiler/testData/asJava/ultraLightClasses/inheritance.kt +++ b/compiler/testData/asJava/ultraLightClasses/inheritance.kt @@ -29,5 +29,3 @@ private class Private { override val overridesNothing: Boolean get() = false } - -// FIR_COMPARISON \ No newline at end of file diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 9f52ebe9f2b..b47784a444a 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -89,6 +89,7 @@ import org.jetbrains.kotlin.idea.fir.low.level.api.sessions.AbstractSessionsInva import org.jetbrains.kotlin.idea.fir.low.level.api.trackers.AbstractProjectWideOutOfBlockKotlinModificationTrackerTest import org.jetbrains.kotlin.idea.folding.AbstractKotlinFoldingTest import org.jetbrains.kotlin.idea.frontend.api.components.AbstractExpectedExpressionTypeTest +import org.jetbrains.kotlin.idea.frontend.api.components.AbstractOverriddenDeclarationProviderTest import org.jetbrains.kotlin.idea.frontend.api.components.AbstractReturnExpressionTargetTest import org.jetbrains.kotlin.idea.frontend.api.fir.AbstractResolveCallTest import org.jetbrains.kotlin.idea.frontend.api.scopes.AbstractFileScopeTest @@ -1040,6 +1041,10 @@ fun main(args: Array) { testClass { model("components/expectedExpressionType") } + + testClass { + model("components/overridenDeclarations") + } } testGroup("idea/idea-frontend-fir/idea-fir-low-level-api/tests", "idea/testData") { diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesSupportFirImpl.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesSupportFirImpl.kt index b10233b1ff1..10027386a2f 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesSupportFirImpl.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesSupportFirImpl.kt @@ -70,7 +70,7 @@ class KotlinFindUsagesSupportFirImpl : KotlinFindUsagesSupport { val analyzeResult = analyseInModalWindow(declaration, KotlinBundle.message("find.usages.progress.text.declaration.superMethods")) { (declaration.getSymbol() as? KtCallableSymbol)?.let { callableSymbol -> ((callableSymbol as? KtSymbolWithKind)?.getContainingSymbol() as? KtClassOrObjectSymbol)?.let { containingClass -> - val overriddenSymbols = callableSymbol.getOverriddenSymbols(containingClass) + val overriddenSymbols = callableSymbol.getAllOverriddenSymbols() val renderToPsi = overriddenSymbols.mapNotNull { it.psi?.let { psi -> diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ChangeReturnTypeOnOverrideQuickFix.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ChangeReturnTypeOnOverrideQuickFix.kt index 96ed57e012b..b7e081c2621 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ChangeReturnTypeOnOverrideQuickFix.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/fixes/ChangeReturnTypeOnOverrideQuickFix.kt @@ -118,10 +118,10 @@ object ChangeTypeQuickFix { callable: KtCallableSymbol, type: KtType ): KtCallableSymbol? { - val overriddenSymbols = callable.getOverriddenSymbols() + val overriddenSymbols = callable.getDirectlyOverriddenSymbols() return overriddenSymbols .singleOrNull { overridden -> - overridden.origin != KtSymbolOrigin.INTERSECTION_OVERRIDE && !type.isSubTypeOf(overridden.annotatedType.type) + !type.isSubTypeOf(overridden.annotatedType.type) } } @@ -131,7 +131,7 @@ object ChangeTypeQuickFix { private fun KtAnalysisSession.findLowerBoundOfOverriddenCallablesReturnTypes(symbol: KtCallableSymbol): KtType? { var lowestType: KtType? = null - for (overridden in symbol.getOverriddenSymbols()) { + for (overridden in symbol.getDirectlyOverriddenSymbols()) { val overriddenType = overridden.annotatedType.type when { lowestType == null || overriddenType isSubTypeOf lowestType -> { diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt index 147134cb497..73c559ada86 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt @@ -24,7 +24,6 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* -import kotlin.reflect.KClass /** * The entry point into all frontend-related work. Has the following contracts: @@ -59,12 +58,30 @@ abstract class KtAnalysisSession(final override val token: ValidityToken) : Vali abstract fun createContextDependentCopy(originalKtFile: KtFile, fakeKtElement: KtElement): KtAnalysisSession - //TODO get rid of it - fun KtCallableSymbol.getOverriddenSymbols(containingDeclaration: KtClassOrObjectSymbol): List = - symbolDeclarationOverridesProvider.getOverriddenSymbols(this, containingDeclaration) - fun KtCallableSymbol.getOverriddenSymbols(): List = - symbolDeclarationOverridesProvider.getOverriddenSymbols(this) + /** + * Return a list of **all** symbols which are overridden by symbol + * + * E.g, if we have `A.foo` overrides `B.foo` overrides `C.foo`, all two super declarations `B.foo`, `C.foo` will be returned + * + * Unwraps substituted overridden symbols (see [org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbolOrigin.INTERSECTION_OVERRIDE]) + * + * @see getDirectlyOverriddenSymbols + */ + fun KtCallableSymbol.getAllOverriddenSymbols(): List = + symbolDeclarationOverridesProvider.getAllOverriddenSymbols(this) + + /** + * Return a list of symbols which are **directly** overridden by symbol + ** + * E.g, if we have `A.foo` overrides `B.foo` overrides `C.foo`, only declarations directly overriden `B.foo` will be returned + * + * Unwraps substituted overridden symbols (see [org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbolOrigin.INTERSECTION_OVERRIDE]) + * + * @see getAllOverriddenSymbols + */ + fun KtCallableSymbol.getDirectlyOverriddenSymbols(): List = + symbolDeclarationOverridesProvider.getDirectlyOverriddenSymbols(this) fun KtCallableSymbol.getIntersectionOverriddenSymbols(): Collection = symbolDeclarationOverridesProvider.getIntersectionOverriddenSymbols(this) diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolDeclarationOverridesProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolDeclarationOverridesProvider.kt index 6dc5415998e..e93c087fbac 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolDeclarationOverridesProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolDeclarationOverridesProvider.kt @@ -11,20 +11,20 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol abstract class KtSymbolDeclarationOverridesProvider : KtAnalysisSessionComponent() { /** - * Returns symbols that overridden by requested + * Returns symbols that are overridden by requested */ - abstract fun getOverriddenSymbols( + abstract fun getAllOverriddenSymbols( callableSymbol: T, - containingDeclaration: KtClassOrObjectSymbol ): List /** - * Returns symbols that overridden by requested + * Returns symbols that are overridden by requested */ - abstract fun getOverriddenSymbols( + abstract fun getDirectlyOverriddenSymbols( callableSymbol: T, ): List + /** * If [symbol] origin is [org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbolOrigin.INTERSECTION_OVERRIDE] * Then returns the symbols which [symbol] overrides, otherwise empty collection diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/classes/FirLightClassForSymbol.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/classes/FirLightClassForSymbol.kt index 61ac005aa08..78e0e2df9f5 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/classes/FirLightClassForSymbol.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/asJava/classes/FirLightClassForSymbol.kt @@ -34,7 +34,7 @@ internal class FirLightClassForSymbol( var visibility = (symbol as? KtSymbolWithVisibility)?.visibility analyzeWithSymbolAsContext(symbol) { - for (overriddenSymbol in symbol.getOverriddenSymbols(classOrObjectSymbol)) { + for (overriddenSymbol in symbol.getAllOverriddenSymbols()) { val newVisibility = (overriddenSymbol as? KtSymbolWithVisibility)?.visibility if (newVisibility != null) { visibility = newVisibility diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSymbolDeclarationOverridesProvider.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSymbolDeclarationOverridesProvider.kt index 7e2062f83dd..89b16deae63 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSymbolDeclarationOverridesProvider.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSymbolDeclarationOverridesProvider.kt @@ -13,7 +13,6 @@ import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirIntersectionOverrideFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirIntersectionOverridePropertySymbol -import org.jetbrains.kotlin.fir.unwrapFakeOverrides import org.jetbrains.kotlin.idea.frontend.api.ValidityToken import org.jetbrains.kotlin.idea.frontend.api.components.KtSymbolDeclarationOverridesProvider import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession @@ -27,53 +26,107 @@ internal class KtFirSymbolDeclarationOverridesProvider( override val token: ValidityToken, ) : KtSymbolDeclarationOverridesProvider(), KtFirAnalysisSessionComponent { + override fun getAllOverriddenSymbols( + callableSymbol: T, + ): List { + val overriddenElement = mutableSetOf>() + processOverrides(callableSymbol) { firTypeScope, firCallableDeclaration -> + firTypeScope.processAllOverriddenDeclarations(firCallableDeclaration) { overriddenDeclaration -> + overriddenDeclaration.symbol.collectIntersectionOverridesSymbolsTo(overriddenElement) + } + } + return overriddenElement.map { analysisSession.firSymbolBuilder.buildCallableSymbol(it.fir) } + } + + override fun getDirectlyOverriddenSymbols(callableSymbol: T): List { + val overriddenElement = mutableSetOf>() + processOverrides(callableSymbol) { firTypeScope, firCallableDeclaration -> + firTypeScope.processDirectOverriddenDeclarations(firCallableDeclaration) { overriddenDeclaration -> + overriddenDeclaration.symbol.collectIntersectionOverridesSymbolsTo(overriddenElement) + } + } + return overriddenElement.map { analysisSession.firSymbolBuilder.buildCallableSymbol(it.fir) } + } + private fun FirTypeScope.processCallableByName(declaration: FirDeclaration) = when (declaration) { is FirSimpleFunction -> processFunctionsByName(declaration.name) { } is FirProperty -> processPropertiesByName(declaration.name) { } else -> error { "Invalid FIR symbol to process: ${declaration::class}" } } - private fun FirTypeScope.processOverriddenDeclarations( + private fun FirTypeScope.processAllOverriddenDeclarations( declaration: FirDeclaration, - processor: (FirCallableDeclaration<*>) -> ProcessorAction + processor: (FirCallableDeclaration<*>) -> Unit ) = when (declaration) { - is FirSimpleFunction -> processOverriddenFunctions(declaration.symbol) { processor.invoke(it.fir) } - is FirProperty -> processOverriddenProperties(declaration.symbol) { processor.invoke(it.fir) } + is FirSimpleFunction -> processOverriddenFunctions(declaration.symbol) { symbol -> + processor.invoke(symbol.fir) + ProcessorAction.NEXT + } + is FirProperty -> processOverriddenProperties(declaration.symbol) { symbol -> + processor.invoke(symbol.fir) + ProcessorAction.NEXT + } else -> error { "Invalid FIR symbol to process: ${declaration::class}" } } - override fun getOverriddenSymbols( - callableSymbol: T, - containingDeclaration: KtClassOrObjectSymbol - ): List { + private fun FirTypeScope.processDirectOverriddenDeclarations( + declaration: FirDeclaration, + processor: (FirCallableDeclaration<*>) -> Unit + ) = when (declaration) { + is FirSimpleFunction -> processDirectOverriddenFunctionsWithBaseScope(declaration.symbol) { symbol, _ -> + processor.invoke(symbol.fir) + ProcessorAction.NEXT + } + is FirProperty -> processDirectOverriddenPropertiesWithBaseScope(declaration.symbol) { symbol, _ -> + processor.invoke(symbol.fir) + ProcessorAction.NEXT + } + else -> error { "Invalid FIR symbol to process: ${declaration::class}" } + } - check(callableSymbol is KtFirSymbol<*>) + private inline fun processOverrides( + callableSymbol: T, + crossinline process: (FirTypeScope, FirDeclaration) -> Unit + ) { + require(callableSymbol is KtFirSymbol<*>) + val containingDeclaration = with(analysisSession) { + (callableSymbol as? KtSymbolWithKind)?.getContainingSymbol() as? KtClassOrObjectSymbol + } ?: return check(containingDeclaration is KtFirClassOrObjectSymbol) - return containingDeclaration.firRef.withFir(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) { firContainer -> - callableSymbol.firRef.withFirUnsafe { firCallableElement -> + processOverrides(containingDeclaration, callableSymbol, process) + } + + private inline fun processOverrides( + containingDeclaration: KtFirClassOrObjectSymbol, + callableSymbol: KtFirSymbol<*>, + crossinline process: (FirTypeScope, FirDeclaration) -> Unit + ) { + containingDeclaration.firRef.withFir(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) { firContainer -> + callableSymbol.firRef.withFirUnsafe { firCallableDeclaration -> val firTypeScope = firContainer.unsubstitutedScope( firContainer.session, ScopeSession(), withForcedTypeCalculator = false ) - - val overriddenElement = mutableSetOf() - firTypeScope.processCallableByName(firCallableElement) - firTypeScope.processOverriddenDeclarations(firCallableElement) { overriddenDeclaration -> - val ktSymbol = analysisSession.firSymbolBuilder.buildCallableSymbol(overriddenDeclaration) - overriddenElement.add(ktSymbol) - ProcessorAction.NEXT - } - - overriddenElement.toList() + firTypeScope.processCallableByName(firCallableDeclaration) + process(firTypeScope, firCallableDeclaration) } } } - override fun getOverriddenSymbols(callableSymbol: T): List = with(analysisSession) { - val containingDeclaration = (callableSymbol as? KtSymbolWithKind)?.getContainingSymbol() as? KtClassOrObjectSymbol ?: return emptyList() - getOverriddenSymbols(callableSymbol, containingDeclaration) + private fun FirCallableSymbol<*>.collectIntersectionOverridesSymbolsTo(to: MutableCollection>) { + when (this) { + is FirIntersectionOverrideFunctionSymbol -> { + intersections.forEach { it.collectIntersectionOverridesSymbolsTo(to) } + } + is FirIntersectionOverridePropertySymbol -> { + intersections.forEach { it.collectIntersectionOverridesSymbolsTo(to) } + } + else -> { + to += this + } + } } override fun getIntersectionOverriddenSymbols(symbol: KtCallableSymbol): Collection { diff --git a/idea/idea-frontend-fir/testData/components/overridenDeclarations/inOtherFile.kt b/idea/idea-frontend-fir/testData/components/overridenDeclarations/inOtherFile.kt new file mode 100644 index 00000000000..479bfd1624d --- /dev/null +++ b/idea/idea-frontend-fir/testData/components/overridenDeclarations/inOtherFile.kt @@ -0,0 +1,19 @@ +// FILE: main.kt +class A : B(){ + override fun foo(x: Int): Int +} + +// FILE: B.kt +abstract class B { + open fun foo(x: Int): Int + abstract fun foo(x: String): Int +} + +// RESULT + +// ALL: +// B.foo(x: Int): Int + +// DIRECT: +// B.foo(x: Int): Int + diff --git a/idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride.kt b/idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride.kt new file mode 100644 index 00000000000..99b7dac969a --- /dev/null +++ b/idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride.kt @@ -0,0 +1,34 @@ +// FILE: main.kt +class A : B { + override fun foo(x: Int) { + } + + override fun foo(x: String) { + } +} + +// FILE: B.kt +interface B: C, D + +// FILE: C.kt +interface C { + fun foo(x: Int) + fun foo(x: String) +} + +// FILE: D.kt +interface D { + fun foo(x: Int) + fun foo(x: String) +} + +// RESULT + +// ALL: +// C.foo(x: String): Unit +// D.foo(x: String): Unit + +// DIRECT: +// C.foo(x: String): Unit +// D.foo(x: String): Unit + diff --git a/idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride2.kt b/idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride2.kt new file mode 100644 index 00000000000..22fd5063883 --- /dev/null +++ b/idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride2.kt @@ -0,0 +1,34 @@ +// FILE: main.kt +class A : B, C { + override fun foo(x: Int) { + } + + override fun foo(x: String) { + } +} + +// FILE: B.kt +interface B: C, D + +// FILE: C.kt +interface C { + fun foo(x: Int) + fun foo(x: String) +} + +// FILE: D.kt +interface D { + fun foo(x: Int) + fun foo(x: String) +} + +// RESULT + +// ALL: +// C.foo(x: String): Unit +// D.foo(x: String): Unit + +// DIRECT: +// C.foo(x: String): Unit +// D.foo(x: String): Unit + diff --git a/idea/idea-frontend-fir/testData/components/overridenDeclarations/javaAccessors.kt b/idea/idea-frontend-fir/testData/components/overridenDeclarations/javaAccessors.kt new file mode 100644 index 00000000000..6c0557445e8 --- /dev/null +++ b/idea/idea-frontend-fir/testData/components/overridenDeclarations/javaAccessors.kt @@ -0,0 +1,27 @@ +// FILE: main.kt +class A : B() { + override val x: Int get() = super.x +} + +// FILE: B.java +public class B extends C { + @Override + public int getX() { + return 0; + } +} + +// FILE: C.kt +abstract class C { + abstract val x: Int +} + +// RESULT + +// ALL: +// B.x: Int +// C.x: Int + +// DIRECT: +// B.x: Int + diff --git a/idea/idea-frontend-fir/testData/components/overridenDeclarations/multipleInterfaces.kt b/idea/idea-frontend-fir/testData/components/overridenDeclarations/multipleInterfaces.kt new file mode 100644 index 00000000000..c8a275368af --- /dev/null +++ b/idea/idea-frontend-fir/testData/components/overridenDeclarations/multipleInterfaces.kt @@ -0,0 +1,39 @@ +// FILE: main.kt +class A : B, C, D { + override fun foo(x: Int) { + } + + override fun foo(x: String) { + } +} + +// FILE: B.kt +interface B { + fun foo(x: Int) + fun foo(x: String) +} + +// FILE: C.kt +interface C { + fun foo(x: Int) + fun foo(x: String) +} + +// FILE: D.kt +interface D { + fun foo(x: Int) + fun foo(x: String) +} + +// RESULT + +// ALL: +// B.foo(x: String): Unit +// C.foo(x: String): Unit +// D.foo(x: String): Unit + +// DIRECT: +// B.foo(x: String): Unit +// C.foo(x: String): Unit +// D.foo(x: String): Unit + diff --git a/idea/idea-frontend-fir/testData/components/overridenDeclarations/sequenceOfOverrides.kt b/idea/idea-frontend-fir/testData/components/overridenDeclarations/sequenceOfOverrides.kt new file mode 100644 index 00000000000..17f583a8244 --- /dev/null +++ b/idea/idea-frontend-fir/testData/components/overridenDeclarations/sequenceOfOverrides.kt @@ -0,0 +1,30 @@ +// FILE: main.kt +class A : B() { + override fun foo(x: Int) {} +} + +// FILE: B.kt +open class B : C() { + override fun foo(x: Int) {} +} + +// FILE: C.kt +open class C : D() { + override fun foo(x: Int) {} +} + +// FILE: D.kt +open class D { + open fun foo(x: Int) {} +} + +// RESULT + +// ALL: +// B.foo(x: Int): Unit +// C.foo(x: Int): Unit +// D.foo(x: Int): Unit + +// DIRECT: +// B.foo(x: Int): Unit + diff --git a/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/components/AbstractOverriddenDeclarationProviderTest.kt b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/components/AbstractOverriddenDeclarationProviderTest.kt new file mode 100644 index 00000000000..9a03b40707f --- /dev/null +++ b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/components/AbstractOverriddenDeclarationProviderTest.kt @@ -0,0 +1,75 @@ +/* + * Copyright 2010-2021 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.idea.frontend.api.components + +import com.intellij.psi.util.parentOfType +import com.intellij.psi.util.parentsOfType +import org.jetbrains.kotlin.idea.executeOnPooledThreadInReadAction +import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession +import org.jetbrains.kotlin.idea.frontend.api.analyze +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtCallableSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtFunctionSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSyntheticJavaPropertySymbol +import org.jetbrains.kotlin.idea.test.framework.AbstractKtIdeaTest +import org.jetbrains.kotlin.idea.test.framework.TestFileStructure +import org.jetbrains.kotlin.idea.test.framework.TestStructureExpectedDataBlock +import org.jetbrains.kotlin.idea.test.framework.TestStructureRenderer +import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.test.KotlinTestUtils + +abstract class AbstractOverriddenDeclarationProviderTest : AbstractKtIdeaTest() { + override fun doTestByFileStructure(fileStructure: TestFileStructure) { + val signatures = executeOnPooledThreadInReadAction { + analyze(fileStructure.mainKtFile) { + val symbol = getDeclarationAtCaret().getSymbol() as KtCallableSymbol + val allOverriddenSymbols = symbol.getAllOverriddenSymbols().map { renderSignature(it) } + val directlyOverriddenSymbols = symbol.getDirectlyOverriddenSymbols().map { renderSignature(it) } + listOf( + TestStructureExpectedDataBlock("ALL:", allOverriddenSymbols), + TestStructureExpectedDataBlock("DIRECT:", directlyOverriddenSymbols), + ) + } + } + val actual = TestStructureRenderer.render(fileStructure, signatures) + KotlinTestUtils.assertEqualsToFile(fileStructure.filePath.toFile(), actual) + } + + private fun KtAnalysisSession.renderSignature(symbol: KtCallableSymbol): String = buildString { + append(getPath(symbol)) + if (symbol is KtFunctionSymbol) { + append("(") + symbol.valueParameters.forEachIndexed { index, parameter -> + append(parameter.name.identifier) + append(": ") + append(parameter.annotatedType.type.render(KtTypeRendererOptions.SHORT_NAMES)) + if (index != symbol.valueParameters.lastIndex) { + append(", ") + } + } + append(")") + } + append(": ") + append(symbol.annotatedType.type.render(KtTypeRendererOptions.SHORT_NAMES)) + } + + private fun getPath(symbol: KtCallableSymbol): String = when (symbol) { + is KtSyntheticJavaPropertySymbol -> symbol.callableIdIfNonLocal?.asString()!! + else -> { + val ktDeclaration = symbol.psi as KtDeclaration + ktDeclaration + .parentsOfType(withSelf = true) + .map { it.name ?: "" } + .toList() + .asReversed() + .joinToString(separator = ".") + } + } + + private fun getDeclarationAtCaret(): KtDeclaration = + file.findElementAt(myFixture.caretOffset) + ?.parentOfType() + ?: error("No KtDeclaration found at caret with position ${myFixture.caretOffset}") +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/components/OverriddenDeclarationProviderTestGenerated.java b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/components/OverriddenDeclarationProviderTestGenerated.java new file mode 100644 index 00000000000..9179c117b7f --- /dev/null +++ b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/components/OverriddenDeclarationProviderTestGenerated.java @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2021 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.idea.frontend.api.components; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/idea-frontend-fir/testData/components/overridenDeclarations") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class OverriddenDeclarationProviderTestGenerated extends AbstractOverriddenDeclarationProviderTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInOverridenDeclarations() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-frontend-fir/testData/components/overridenDeclarations"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("inOtherFile.kt") + public void testInOtherFile() throws Exception { + runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/inOtherFile.kt"); + } + + @TestMetadata("intersectionOverride.kt") + public void testIntersectionOverride() throws Exception { + runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride.kt"); + } + + @TestMetadata("intersectionOverride2.kt") + public void testIntersectionOverride2() throws Exception { + runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/intersectionOverride2.kt"); + } + + @TestMetadata("javaAccessors.kt") + public void testJavaAccessors() throws Exception { + runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/javaAccessors.kt"); + } + + @TestMetadata("multipleInterfaces.kt") + public void testMultipleInterfaces() throws Exception { + runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/multipleInterfaces.kt"); + } + + @TestMetadata("sequenceOfOverrides.kt") + public void testSequenceOfOverrides() throws Exception { + runTest("idea/idea-frontend-fir/testData/components/overridenDeclarations/sequenceOfOverrides.kt"); + } +} From 88c43e7f7bbfeb9c38967d3769a0626355850e90 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 18 Feb 2021 18:10:15 +0300 Subject: [PATCH 294/368] [FE] Assume that effective visibility of sealed class constructor is internal #KT-45033 Fixed #KT-45043 --- ...irOldFrontendDiagnosticsTestGenerated.java | 12 +++++++++ .../resolve/ExposedVisibilityChecker.kt | 6 ++++- .../sealed/internalTypeInConstructor.fir.kt | 9 +++++++ .../tests/sealed/internalTypeInConstructor.kt | 9 +++++++ .../sealed/internalTypeInConstructor.txt | 16 ++++++++++++ .../sealed/privateTypeInConstructor.fir.kt | 16 ++++++++++++ .../tests/sealed/privateTypeInConstructor.kt | 16 ++++++++++++ .../tests/sealed/privateTypeInConstructor.txt | 26 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 12 +++++++++ 9 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.fir.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.txt create mode 100644 compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.fir.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.kt create mode 100644 compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 57943e90f00..be4efe9b6a6 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -24313,6 +24313,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt"); } + @Test + @TestMetadata("internalTypeInConstructor.kt") + public void testInternalTypeInConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.kt"); + } + @Test @TestMetadata("kt44316.kt") public void testKt44316() throws Exception { @@ -24433,6 +24439,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/sealed/OperationWhen.kt"); } + @Test + @TestMetadata("privateTypeInConstructor.kt") + public void testPrivateTypeInConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.kt"); + } + @Test @TestMetadata("protectedConstructors_disabled.kt") public void testProtectedConstructors_disabled() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ExposedVisibilityChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ExposedVisibilityChecker.kt index 99dfa56d74d..efd92ebe785 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ExposedVisibilityChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ExposedVisibilityChecker.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.diagnostics.DiagnosticFactory3 import org.jetbrains.kotlin.diagnostics.Errors.* import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.visibilityModifier import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.isError @@ -80,7 +81,10 @@ class ExposedVisibilityChecker(private val trace: BindingTrace? = null) { // for checking situation with modified basic visibility visibility: DescriptorVisibility = functionDescriptor.visibility ): Boolean { - val functionVisibility = functionDescriptor.effectiveVisibility(visibility) + var functionVisibility = functionDescriptor.effectiveVisibility(visibility) + if (functionDescriptor is ConstructorDescriptor && functionDescriptor.constructedClass.isSealed() && function.visibilityModifier() == null) { + functionVisibility = EffectiveVisibility.Private + } var result = true if (function !is KtConstructor<*>) { val restricting = functionDescriptor.returnType?.leastPermissiveDescriptor(functionVisibility) diff --git a/compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.fir.kt b/compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.fir.kt new file mode 100644 index 00000000000..f7ad3c9a727 --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.fir.kt @@ -0,0 +1,9 @@ +// ISSUE: KT-45033 +// DIAGNOSTICS: -UNUSED_PARAMETER + +internal class Bar + +sealed class Foo( + internal val x: Bar, + y: Bar +) diff --git a/compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.kt b/compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.kt new file mode 100644 index 00000000000..b5872a1cbc6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.kt @@ -0,0 +1,9 @@ +// ISSUE: KT-45033 +// DIAGNOSTICS: -UNUSED_PARAMETER + +internal class Bar + +sealed class Foo( + internal val x: Bar, + y: Bar +) diff --git a/compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.txt b/compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.txt new file mode 100644 index 00000000000..bc5d64e76bc --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.txt @@ -0,0 +1,16 @@ +package + +internal final class Bar { + public constructor Bar() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public sealed class Foo { + protected constructor Foo(/*0*/ x: Bar, /*1*/ y: Bar) + internal final val x: Bar + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.fir.kt b/compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.fir.kt new file mode 100644 index 00000000000..79e080e9b09 --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.fir.kt @@ -0,0 +1,16 @@ +// ISSUE: KT-45043 +// DIAGNOSTICS: -UNUSED_PARAMETER + +private class Bar + +sealed class SealedFoo( + val x: Bar, + private val y: Bar, + z: Bar +) + +abstract class AbstractFoo( + val x: Bar, + private val y: Bar, + z: Bar +) diff --git a/compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.kt b/compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.kt new file mode 100644 index 00000000000..05d13d85b64 --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.kt @@ -0,0 +1,16 @@ +// ISSUE: KT-45043 +// DIAGNOSTICS: -UNUSED_PARAMETER + +private class Bar + +sealed class SealedFoo( + val x: Bar, + private val y: Bar, + z: Bar +) + +abstract class AbstractFoo( + val x: Bar, + private val y: Bar, + z: Bar +) diff --git a/compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.txt b/compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.txt new file mode 100644 index 00000000000..3f33b21eb9d --- /dev/null +++ b/compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.txt @@ -0,0 +1,26 @@ +package + +public abstract class AbstractFoo { + public constructor AbstractFoo(/*0*/ x: Bar, /*1*/ y: Bar, /*2*/ z: Bar) + public final val x: Bar + private final val y: Bar + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +private final class Bar { + public constructor Bar() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public sealed class SealedFoo { + protected constructor SealedFoo(/*0*/ x: Bar, /*1*/ y: Bar, /*2*/ z: Bar) + public final val x: Bar + private final val y: Bar + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 65516cfb384..99d2bb2e949 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -24403,6 +24403,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt"); } + @Test + @TestMetadata("internalTypeInConstructor.kt") + public void testInternalTypeInConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/internalTypeInConstructor.kt"); + } + @Test @TestMetadata("kt44316.kt") public void testKt44316() throws Exception { @@ -24523,6 +24529,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/sealed/OperationWhen.kt"); } + @Test + @TestMetadata("privateTypeInConstructor.kt") + public void testPrivateTypeInConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/sealed/privateTypeInConstructor.kt"); + } + @Test @TestMetadata("protectedConstructors_disabled.kt") public void testProtectedConstructors_disabled() throws Exception { From 56854a8b1a55dd8a38c03b89845f7d6d7f531d88 Mon Sep 17 00:00:00 2001 From: Tianyu Geng Date: Wed, 10 Feb 2021 17:26:43 -0800 Subject: [PATCH 295/368] FIR IDE: register quickfix for the following 1. NON_ABSTRACT_FUNCTION_WITH_NO_BODY 2. ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS 3. ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS --- .../kotlin/generators/tests/GenerateTests.kt | 1 + .../idea/quickfix/MainKtQuickFixRegistrar.kt | 16 +- .../HighLevelQuickFixTestGenerated.java | 178 ++++++++++++++++++ .../idea/quickfix/AddFunctionBodyFix.kt | 9 +- .../kotlin/idea/quickfix/AddModifierFix.kt | 9 +- .../kotlin/idea/quickfix/RemoveModifierFix.kt | 11 +- .../abstractFunctionInNonAbstractClass.kt | 3 +- ...bstractFunctionInNonAbstractClass.kt.after | 3 +- .../abstractPropertyInCompanionObject.kt | 3 +- .../abstractPropertyInNonAbstractClass1.kt | 1 + ...stractPropertyInNonAbstractClass1.kt.after | 1 + .../abstractPropertyInNonAbstractClass2.kt | 1 + ...stractPropertyInNonAbstractClass2.kt.after | 1 + .../abstractPropertyInNonAbstractClass3.kt | 1 + ...stractPropertyInNonAbstractClass3.kt.after | 1 + .../abstract/abstractPropertyWithGetter1.kt | 3 +- .../abstractPropertyWithGetter1.kt.after | 3 +- .../abstractPropertyWithInitializer1.kt | 1 + .../abstractPropertyWithInitializer1.kt.after | 1 + .../abstract/abstractPropertyWithSetter.kt | 1 + .../abstractPropertyWithSetter.kt.after | 1 + .../abstract/makeEnumEntryAbstract.kt | 3 +- .../abstract/makeInlineClassAbstract.kt | 3 +- .../abstract/makeObjectMemberAbstract.kt | 3 +- .../quickfix/abstract/makeTopLevelAbstract.kt | 3 +- idea/testData/quickfix/abstract/manyImpl.kt | 3 +- ...tBeInitializedOrBeAbstractInSealedClass.kt | 1 + ...tializedOrBeAbstractInSealedClass.kt.after | 1 + .../abstract/nonAbstractFunctionWithNoBody.kt | 1 + .../nonAbstractFunctionWithNoBody.kt.after | 1 + .../testData/quickfix/abstract/replaceOpen.kt | 1 + .../quickfix/abstract/replaceOpen.kt.after | 1 + .../KaptToolIntegrationTestGenerated.java | 9 +- 33 files changed, 251 insertions(+), 28 deletions(-) diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index b47784a444a..77f93a55784 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -1114,6 +1114,7 @@ fun main(args: Array) { testClass { val pattern = "^([\\w\\-_]+)\\.kt$" + model("quickfix/abstract", pattern = pattern, filenameStartsLowerCase = true) model("quickfix/lateinit", pattern = pattern, filenameStartsLowerCase = true) model("quickfix/modifiers", pattern = pattern, filenameStartsLowerCase = true, recursive = false) model("quickfix/override/typeMismatchOnOverride", pattern = pattern, filenameStartsLowerCase = true, recursive = false) diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt index 0df8f195949..25a8798c425 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/quickfix/MainKtQuickFixRegistrar.kt @@ -10,7 +10,6 @@ import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesList import org.jetbrains.kotlin.idea.fir.api.fixes.KtQuickFixesListBuilder import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KtFirDiagnostic import org.jetbrains.kotlin.idea.quickfix.fixes.ChangeTypeQuickFix -import org.jetbrains.kotlin.lexer.KtTokens class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { private val modifiers = KtQuickFixesListBuilder.registerPsiQuickFix { @@ -19,12 +18,17 @@ class MainKtQuickFixRegistrar : KtQuickFixRegistrar() { registerPsiQuickFixes(KtFirDiagnostic.RepeatedModifier::class, RemoveModifierFix.removeNonRedundantModifier) registerPsiQuickFixes(KtFirDiagnostic.DeprecatedModifierPair::class, RemoveModifierFix.removeRedundantModifier) registerPsiQuickFixes(KtFirDiagnostic.TypeParametersInEnum::class, RemoveModifierFix.removeRedundantModifier) + registerPsiQuickFixes(KtFirDiagnostic.RedundantOpenInInterface::class, RemoveModifierFix.removeRedundantOpenModifier) + registerPsiQuickFixes(KtFirDiagnostic.NonAbstractFunctionWithNoBody::class, AddFunctionBodyFix, AddModifierFix.addAbstractModifier) registerPsiQuickFixes( - KtFirDiagnostic.RedundantOpenInInterface::class, - RemoveModifierFix.createRemoveModifierFromListOwnerFactoryByModifierListOwner( - modifier = KtTokens.OPEN_KEYWORD, - isRedundant = true - ) + KtFirDiagnostic.AbstractPropertyInNonAbstractClass::class, + AddModifierFix.addAbstractToContainingClass, + RemoveModifierFix.removeAbstractModifier + ) + registerPsiQuickFixes( + KtFirDiagnostic.AbstractFunctionInNonAbstractClass::class, + AddModifierFix.addAbstractToContainingClass, + RemoveModifierFix.removeAbstractModifier ) } diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java index 012869b9b17..61e5133f78c 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/quickfix/HighLevelQuickFixTestGenerated.java @@ -19,6 +19,184 @@ import java.util.regex.Pattern; @SuppressWarnings("all") @RunWith(JUnit3RunnerWithInners.class) public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTest { + @TestMetadata("idea/testData/quickfix/abstract") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Abstract extends AbstractHighLevelQuickFixTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + @TestMetadata("abstractFunctionInNonAbstractClass.kt") + public void testAbstractFunctionInNonAbstractClass() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractFunctionInNonAbstractClass.kt"); + } + + @TestMetadata("abstractFunctionWithBody.kt") + public void testAbstractFunctionWithBody() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractFunctionWithBody.kt"); + } + + @TestMetadata("abstractFunctionWithBody2.kt") + public void testAbstractFunctionWithBody2() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractFunctionWithBody2.kt"); + } + + @TestMetadata("abstractFunctionWithBody3.kt") + public void testAbstractFunctionWithBody3() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractFunctionWithBody3.kt"); + } + + @TestMetadata("abstractFunctionWithBodyWithComments.kt") + public void testAbstractFunctionWithBodyWithComments() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractFunctionWithBodyWithComments.kt"); + } + + @TestMetadata("abstractFunctionWithBodyWithComments2.kt") + public void testAbstractFunctionWithBodyWithComments2() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractFunctionWithBodyWithComments2.kt"); + } + + @TestMetadata("abstractPropertyInCompanionObject.kt") + public void testAbstractPropertyInCompanionObject() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyInCompanionObject.kt"); + } + + @TestMetadata("abstractPropertyInNonAbstractClass1.kt") + public void testAbstractPropertyInNonAbstractClass1() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass1.kt"); + } + + @TestMetadata("abstractPropertyInNonAbstractClass2.kt") + public void testAbstractPropertyInNonAbstractClass2() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass2.kt"); + } + + @TestMetadata("abstractPropertyInNonAbstractClass3.kt") + public void testAbstractPropertyInNonAbstractClass3() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass3.kt"); + } + + @TestMetadata("abstractPropertyInPrimaryConstructorParameters.kt") + public void testAbstractPropertyInPrimaryConstructorParameters() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyInPrimaryConstructorParameters.kt"); + } + + @TestMetadata("abstractPropertyNotInClass.kt") + public void testAbstractPropertyNotInClass() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyNotInClass.kt"); + } + + @TestMetadata("abstractPropertyWIthInitializer2.kt") + public void testAbstractPropertyWIthInitializer2() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyWIthInitializer2.kt"); + } + + @TestMetadata("abstractPropertyWIthInitializer3.kt") + public void testAbstractPropertyWIthInitializer3() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyWIthInitializer3.kt"); + } + + @TestMetadata("abstractPropertyWithGetter1.kt") + public void testAbstractPropertyWithGetter1() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyWithGetter1.kt"); + } + + @TestMetadata("abstractPropertyWithGetter2.kt") + public void testAbstractPropertyWithGetter2() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyWithGetter2.kt"); + } + + @TestMetadata("abstractPropertyWithInitializer1.kt") + public void testAbstractPropertyWithInitializer1() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyWithInitializer1.kt"); + } + + @TestMetadata("abstractPropertyWithSetter.kt") + public void testAbstractPropertyWithSetter() throws Exception { + runTest("idea/testData/quickfix/abstract/abstractPropertyWithSetter.kt"); + } + + public void testAllFilesPresentInAbstract() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/quickfix/abstract"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), null, true); + } + + @TestMetadata("makeEnumEntryAbstract.kt") + public void testMakeEnumEntryAbstract() throws Exception { + runTest("idea/testData/quickfix/abstract/makeEnumEntryAbstract.kt"); + } + + @TestMetadata("makeInlineClassAbstract.kt") + public void testMakeInlineClassAbstract() throws Exception { + runTest("idea/testData/quickfix/abstract/makeInlineClassAbstract.kt"); + } + + @TestMetadata("makeObjectMemberAbstract.kt") + public void testMakeObjectMemberAbstract() throws Exception { + runTest("idea/testData/quickfix/abstract/makeObjectMemberAbstract.kt"); + } + + @TestMetadata("makeTopLevelAbstract.kt") + public void testMakeTopLevelAbstract() throws Exception { + runTest("idea/testData/quickfix/abstract/makeTopLevelAbstract.kt"); + } + + @TestMetadata("manyImpl.kt") + public void testManyImpl() throws Exception { + runTest("idea/testData/quickfix/abstract/manyImpl.kt"); + } + + @TestMetadata("mustBeInitializedOrBeAbstract.kt") + public void testMustBeInitializedOrBeAbstract() throws Exception { + runTest("idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstract.kt"); + } + + @TestMetadata("mustBeInitializedOrBeAbstractInFinalClass.kt") + public void testMustBeInitializedOrBeAbstractInFinalClass() throws Exception { + runTest("idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstractInFinalClass.kt"); + } + + @TestMetadata("mustBeInitializedOrBeAbstractInOpenClass.kt") + public void testMustBeInitializedOrBeAbstractInOpenClass() throws Exception { + runTest("idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstractInOpenClass.kt"); + } + + @TestMetadata("mustBeInitializedOrBeAbstractInSealedClass.kt") + public void testMustBeInitializedOrBeAbstractInSealedClass() throws Exception { + runTest("idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstractInSealedClass.kt"); + } + + @TestMetadata("nonAbstractFunctionWithNoBody.kt") + public void testNonAbstractFunctionWithNoBody() throws Exception { + runTest("idea/testData/quickfix/abstract/nonAbstractFunctionWithNoBody.kt"); + } + + @TestMetadata("nonMemberAbstractFunction.kt") + public void testNonMemberAbstractFunction() throws Exception { + runTest("idea/testData/quickfix/abstract/nonMemberAbstractFunction.kt"); + } + + @TestMetadata("nonMemberFunctionNoBody.kt") + public void testNonMemberFunctionNoBody() throws Exception { + runTest("idea/testData/quickfix/abstract/nonMemberFunctionNoBody.kt"); + } + + @TestMetadata("notImplementedMember.kt") + public void testNotImplementedMember() throws Exception { + runTest("idea/testData/quickfix/abstract/notImplementedMember.kt"); + } + + @TestMetadata("notImplementedMemberFromAbstractClass.kt") + public void testNotImplementedMemberFromAbstractClass() throws Exception { + runTest("idea/testData/quickfix/abstract/notImplementedMemberFromAbstractClass.kt"); + } + + @TestMetadata("replaceOpen.kt") + public void testReplaceOpen() throws Exception { + runTest("idea/testData/quickfix/abstract/replaceOpen.kt"); + } + } + @TestMetadata("idea/testData/quickfix/lateinit") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt index 683f81c2078..6406de529a4 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionBodyFix.kt @@ -5,14 +5,13 @@ package org.jetbrains.kotlin.idea.quickfix +import com.intellij.codeInsight.intention.IntentionAction import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project -import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFunction import org.jetbrains.kotlin.psi.KtPsiFactory -import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType class AddFunctionBodyFix(element: KtFunction) : KotlinPsiOnlyQuickFixAction(element) { override fun getFamilyName() = KotlinBundle.message("fix.add.function.body") @@ -30,9 +29,7 @@ class AddFunctionBodyFix(element: KtFunction) : KotlinPsiOnlyQuickFixAction()?.let(::AddFunctionBodyFix) - } + companion object : QuickFixesPsiBasedFactory(KtFunction::class, PsiElementSuitabilityCheckers.ALWAYS_SUITABLE) { + override fun doCreateQuickFix(psiElement: KtFunction): List = listOfNotNull(AddFunctionBodyFix(psiElement)) } } diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt index 5b38e72357e..02b13b0bd6d 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/AddModifierFix.kt @@ -106,9 +106,14 @@ open class AddModifierFix( } companion object : Factory { - private val modalityModifiers = setOf(KtTokens.ABSTRACT_KEYWORD, KtTokens.OPEN_KEYWORD, KtTokens.FINAL_KEYWORD) + val addAbstractModifier: QuickFixesPsiBasedFactory = AddModifierFix.createFactory(KtTokens.ABSTRACT_KEYWORD) + val addAbstractToContainingClass: QuickFixesPsiBasedFactory = + AddModifierFix.createFactory(KtTokens.ABSTRACT_KEYWORD, KtClassOrObject::class.java) + private val modalityModifiers: Set = + setOf(KtTokens.ABSTRACT_KEYWORD, KtTokens.OPEN_KEYWORD, KtTokens.FINAL_KEYWORD) + override fun createModifierFix(element: KtModifierListOwner, modifier: KtModifierKeywordToken): AddModifierFix = AddModifierFix(element, modifier) } -} \ No newline at end of file +} diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt index c401253ba2d..0b30f6f8c32 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/quickfix/RemoveModifierFix.kt @@ -51,8 +51,15 @@ class RemoveModifierFix( } companion object { - val removeRedundantModifier = createRemoveModifierFactory(isRedundant = true) - val removeNonRedundantModifier = createRemoveModifierFactory(isRedundant = false) + val removeRedundantModifier: QuickFixesPsiBasedFactory = createRemoveModifierFactory(isRedundant = true) + val removeNonRedundantModifier: QuickFixesPsiBasedFactory = createRemoveModifierFactory(isRedundant = false) + val removeAbstractModifier: QuickFixesPsiBasedFactory = + createRemoveModifierFromListOwnerPsiBasedFactory(KtTokens.ABSTRACT_KEYWORD) + val removeRedundantOpenModifier: QuickFixesPsiBasedFactory = + createRemoveModifierFromListOwnerFactoryByModifierListOwner( + modifier = KtTokens.OPEN_KEYWORD, + isRedundant = true + ) @Deprecated( "For binary compatibility", diff --git a/idea/testData/quickfix/abstract/abstractFunctionInNonAbstractClass.kt b/idea/testData/quickfix/abstract/abstractFunctionInNonAbstractClass.kt index 5c81dea5e1d..a09e7e6bd4d 100644 --- a/idea/testData/quickfix/abstract/abstractFunctionInNonAbstractClass.kt +++ b/idea/testData/quickfix/abstract/abstractFunctionInNonAbstractClass.kt @@ -1,4 +1,5 @@ // "Make 'foo' not abstract" "true" class A() { abstract fun foo() {} -} \ No newline at end of file +} +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractFunctionInNonAbstractClass.kt.after b/idea/testData/quickfix/abstract/abstractFunctionInNonAbstractClass.kt.after index 86809c0a58f..e5e38c11d67 100644 --- a/idea/testData/quickfix/abstract/abstractFunctionInNonAbstractClass.kt.after +++ b/idea/testData/quickfix/abstract/abstractFunctionInNonAbstractClass.kt.after @@ -1,4 +1,5 @@ // "Make 'foo' not abstract" "true" class A() { fun foo() {} -} \ No newline at end of file +} +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyInCompanionObject.kt b/idea/testData/quickfix/abstract/abstractPropertyInCompanionObject.kt index b557e6164bf..c3779a41342 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyInCompanionObject.kt +++ b/idea/testData/quickfix/abstract/abstractPropertyInCompanionObject.kt @@ -7,4 +7,5 @@ class Owner { companion object { abstract val x: Int } -} \ No newline at end of file +} +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass1.kt b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass1.kt index 0b4e86bfe1e..f36bbe2aba0 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass1.kt +++ b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass1.kt @@ -2,3 +2,4 @@ class A() { abstract var i : Int } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass1.kt.after b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass1.kt.after index d847caf85e2..4c0e5551c18 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass1.kt.after +++ b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass1.kt.after @@ -2,3 +2,4 @@ abstract class A() { abstract var i : Int } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass2.kt b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass2.kt index cdb5a47b594..0eee94636cc 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass2.kt +++ b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass2.kt @@ -2,3 +2,4 @@ class A() { abstract var i : Int = 0 } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass2.kt.after b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass2.kt.after index 773ad489ec7..5bf704d54aa 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass2.kt.after +++ b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass2.kt.after @@ -2,3 +2,4 @@ class A() { var i : Int = 0 } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass3.kt b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass3.kt index ca64a4e54b0..cc8b8c0ad6f 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass3.kt +++ b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass3.kt @@ -2,3 +2,4 @@ public class A() { abstract var i : Int } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass3.kt.after b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass3.kt.after index 6ae6136242b..c6e9f139b96 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass3.kt.after +++ b/idea/testData/quickfix/abstract/abstractPropertyInNonAbstractClass3.kt.after @@ -2,3 +2,4 @@ public abstract class A() { abstract var i : Int } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyWithGetter1.kt b/idea/testData/quickfix/abstract/abstractPropertyWithGetter1.kt index 482300fc24b..97b88445cd5 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyWithGetter1.kt +++ b/idea/testData/quickfix/abstract/abstractPropertyWithGetter1.kt @@ -2,4 +2,5 @@ class B { abstract val i: Int = 0 get() = field -} \ No newline at end of file +} +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyWithGetter1.kt.after b/idea/testData/quickfix/abstract/abstractPropertyWithGetter1.kt.after index c8df4e86d4a..13b69dca120 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyWithGetter1.kt.after +++ b/idea/testData/quickfix/abstract/abstractPropertyWithGetter1.kt.after @@ -2,4 +2,5 @@ class B { val i: Int = 0 get() = field -} \ No newline at end of file +} +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyWithInitializer1.kt b/idea/testData/quickfix/abstract/abstractPropertyWithInitializer1.kt index c56a70cde06..59fc73a9e4f 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyWithInitializer1.kt +++ b/idea/testData/quickfix/abstract/abstractPropertyWithInitializer1.kt @@ -2,3 +2,4 @@ class A { abstract var i = 0 } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyWithInitializer1.kt.after b/idea/testData/quickfix/abstract/abstractPropertyWithInitializer1.kt.after index 01d5197a882..ae725ce1da9 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyWithInitializer1.kt.after +++ b/idea/testData/quickfix/abstract/abstractPropertyWithInitializer1.kt.after @@ -2,3 +2,4 @@ class A { var i = 0 } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyWithSetter.kt b/idea/testData/quickfix/abstract/abstractPropertyWithSetter.kt index cdfb4051f39..afc115a3608 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyWithSetter.kt +++ b/idea/testData/quickfix/abstract/abstractPropertyWithSetter.kt @@ -3,3 +3,4 @@ class B { abstract var j: Int = 0 set(v: Int) {} } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/abstractPropertyWithSetter.kt.after b/idea/testData/quickfix/abstract/abstractPropertyWithSetter.kt.after index cd83c943c58..b67e494c23e 100644 --- a/idea/testData/quickfix/abstract/abstractPropertyWithSetter.kt.after +++ b/idea/testData/quickfix/abstract/abstractPropertyWithSetter.kt.after @@ -3,3 +3,4 @@ class B { var j: Int = 0 set(v: Int) {} } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/makeEnumEntryAbstract.kt b/idea/testData/quickfix/abstract/makeEnumEntryAbstract.kt index 6e5b2be9af3..72c38a36528 100644 --- a/idea/testData/quickfix/abstract/makeEnumEntryAbstract.kt +++ b/idea/testData/quickfix/abstract/makeEnumEntryAbstract.kt @@ -6,4 +6,5 @@ enum class E { A; abstract fun foo() -} \ No newline at end of file +} +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/makeInlineClassAbstract.kt b/idea/testData/quickfix/abstract/makeInlineClassAbstract.kt index a41aebfe9d2..6e697e2f6e2 100644 --- a/idea/testData/quickfix/abstract/makeInlineClassAbstract.kt +++ b/idea/testData/quickfix/abstract/makeInlineClassAbstract.kt @@ -9,4 +9,5 @@ interface I { fun foo(): String } -inline class A : I \ No newline at end of file +inline class A : I +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/makeObjectMemberAbstract.kt b/idea/testData/quickfix/abstract/makeObjectMemberAbstract.kt index 2637215996e..476d90bb2ff 100644 --- a/idea/testData/quickfix/abstract/makeObjectMemberAbstract.kt +++ b/idea/testData/quickfix/abstract/makeObjectMemberAbstract.kt @@ -7,4 +7,5 @@ object O { fun foo() -} \ No newline at end of file +} +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/makeTopLevelAbstract.kt b/idea/testData/quickfix/abstract/makeTopLevelAbstract.kt index 27f891ce35e..e43eb13e15e 100644 --- a/idea/testData/quickfix/abstract/makeTopLevelAbstract.kt +++ b/idea/testData/quickfix/abstract/makeTopLevelAbstract.kt @@ -5,4 +5,5 @@ // ACTION: Make private // ERROR: Function 'foo' must have a body -fun foo() \ No newline at end of file +fun foo() +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/manyImpl.kt b/idea/testData/quickfix/abstract/manyImpl.kt index ebc1d4c637b..8899a524ece 100644 --- a/idea/testData/quickfix/abstract/manyImpl.kt +++ b/idea/testData/quickfix/abstract/manyImpl.kt @@ -18,4 +18,5 @@ object Impl : D, E { override fun foo() {} } -class X : D by Impl, E by Impl {} \ No newline at end of file +class X : D by Impl, E by Impl {} +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstractInSealedClass.kt b/idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstractInSealedClass.kt index acde93f0824..97205fd65f1 100644 --- a/idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstractInSealedClass.kt +++ b/idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstractInSealedClass.kt @@ -2,3 +2,4 @@ sealed class A() { fun i() : Int } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstractInSealedClass.kt.after b/idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstractInSealedClass.kt.after index f80634358e0..225d9fb13e5 100644 --- a/idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstractInSealedClass.kt.after +++ b/idea/testData/quickfix/abstract/mustBeInitializedOrBeAbstractInSealedClass.kt.after @@ -2,3 +2,4 @@ sealed class A() { abstract fun i() : Int } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/nonAbstractFunctionWithNoBody.kt b/idea/testData/quickfix/abstract/nonAbstractFunctionWithNoBody.kt index 0e070005a49..a9518f7c369 100644 --- a/idea/testData/quickfix/abstract/nonAbstractFunctionWithNoBody.kt +++ b/idea/testData/quickfix/abstract/nonAbstractFunctionWithNoBody.kt @@ -2,3 +2,4 @@ class A() { fun foo() } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/nonAbstractFunctionWithNoBody.kt.after b/idea/testData/quickfix/abstract/nonAbstractFunctionWithNoBody.kt.after index 59958ef927e..dd1e04bb937 100644 --- a/idea/testData/quickfix/abstract/nonAbstractFunctionWithNoBody.kt.after +++ b/idea/testData/quickfix/abstract/nonAbstractFunctionWithNoBody.kt.after @@ -2,3 +2,4 @@ class A() { fun foo() {} } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/replaceOpen.kt b/idea/testData/quickfix/abstract/replaceOpen.kt index 13f21216b92..388ace5b0b8 100644 --- a/idea/testData/quickfix/abstract/replaceOpen.kt +++ b/idea/testData/quickfix/abstract/replaceOpen.kt @@ -2,3 +2,4 @@ abstract class B() { open fun foo() } +/* FIR_COMPARISON */ diff --git a/idea/testData/quickfix/abstract/replaceOpen.kt.after b/idea/testData/quickfix/abstract/replaceOpen.kt.after index 6f9b5323658..2f73a3f1d97 100644 --- a/idea/testData/quickfix/abstract/replaceOpen.kt.after +++ b/idea/testData/quickfix/abstract/replaceOpen.kt.after @@ -2,3 +2,4 @@ abstract class B() { abstract fun foo() } +/* FIR_COMPARISON */ diff --git a/plugins/kapt3/kapt3-cli/test/org/jetbrains/kotlin/kapt/cli/test/KaptToolIntegrationTestGenerated.java b/plugins/kapt3/kapt3-cli/test/org/jetbrains/kotlin/kapt/cli/test/KaptToolIntegrationTestGenerated.java index b14aae95ffd..af01cdbe798 100644 --- a/plugins/kapt3/kapt3-cli/test/org/jetbrains/kotlin/kapt/cli/test/KaptToolIntegrationTestGenerated.java +++ b/plugins/kapt3/kapt3-cli/test/org/jetbrains/kotlin/kapt/cli/test/KaptToolIntegrationTestGenerated.java @@ -29,9 +29,9 @@ public class KaptToolIntegrationTestGenerated extends AbstractKaptToolIntegratio KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-cli/testData/integration"), Pattern.compile("^([^\\.]+)$"), null, false); } - @TestMetadata("defaultPackage") + @TestMetadata("argfile") public void testArgfile() throws Exception { - runTest("plugins/kapt3/kapt3-cli/testData/integration/defaultPackage/"); + runTest("plugins/kapt3/kapt3-cli/testData/integration/argfile/"); } @TestMetadata("correctErrorTypesOff") @@ -44,6 +44,11 @@ public class KaptToolIntegrationTestGenerated extends AbstractKaptToolIntegratio runTest("plugins/kapt3/kapt3-cli/testData/integration/correctErrorTypesOn/"); } + @TestMetadata("defaultPackage") + public void testDefaultPackage() throws Exception { + runTest("plugins/kapt3/kapt3-cli/testData/integration/defaultPackage/"); + } + @TestMetadata("kotlinFileGeneration") public void testKotlinFileGeneration() throws Exception { runTest("plugins/kapt3/kapt3-cli/testData/integration/kotlinFileGeneration/"); From 56f9e3360ff91f249bb2467545f10a88df2b7a70 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 18 Feb 2021 13:19:27 +0100 Subject: [PATCH 296/368] JVM IR: do not generate invokeinterface hashCode if smart cast is present #KT-45008 Fixed --- .../codegen/FirBytecodeTextTestGenerated.java | 6 ++++++ .../InheritedDefaultMethodsOnClassesLowering.kt | 2 +- .../hashCode/interfaceHashCodeWithSmartCast.kt | 16 ++++++++++++++++ .../codegen/BytecodeTextTestGenerated.java | 6 ++++++ .../codegen/IrBytecodeTextTestGenerated.java | 6 ++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/codegen/bytecodeText/hashCode/interfaceHashCodeWithSmartCast.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java index e7d11e266c3..42193513368 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBytecodeTextTestGenerated.java @@ -3141,6 +3141,12 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest { public void testInterfaceHashCode() throws Exception { runTest("compiler/testData/codegen/bytecodeText/hashCode/interfaceHashCode.kt"); } + + @Test + @TestMetadata("interfaceHashCodeWithSmartCast.kt") + public void testInterfaceHashCodeWithSmartCast() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/hashCode/interfaceHashCodeWithSmartCast.kt"); + } } @Nested diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InheritedDefaultMethodsOnClassesLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InheritedDefaultMethodsOnClassesLowering.kt index 4c286cafaee..0c934061a5d 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InheritedDefaultMethodsOnClassesLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InheritedDefaultMethodsOnClassesLowering.kt @@ -233,7 +233,7 @@ private class InterfaceObjectCallsLowering(val context: JvmBackendContext) : IrE if (expression.superQualifierSymbol != null && !expression.isSuperToAny()) return super.visitCall(expression) val callee = expression.symbol.owner - if (!callee.hasInterfaceParent()) + if (!callee.hasInterfaceParent() && expression.dispatchReceiver?.run { type.erasedUpperBound.isJvmInterface } != true) return super.visitCall(expression) val resolved = callee.resolveFakeOverride() if (resolved?.isMethodOfAny() != true) diff --git a/compiler/testData/codegen/bytecodeText/hashCode/interfaceHashCodeWithSmartCast.kt b/compiler/testData/codegen/bytecodeText/hashCode/interfaceHashCodeWithSmartCast.kt new file mode 100644 index 00000000000..1e3ef0a82a2 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/hashCode/interfaceHashCodeWithSmartCast.kt @@ -0,0 +1,16 @@ +interface I + +class A : I { + fun f1(other: Any?): Int = + if (other is I) other.hashCode() else 0 + + inline fun f2(other: Any): Int = + if (other is T) other.hashCode() else 0 + + fun f3() { + f2(A()) + } +} + +// 3 INVOKEVIRTUAL java/lang/Object.hashCode \(\)I +// 0 INVOKEINTERFACE diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java index 2953fa9dad3..f2262ddcc0a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeTextTestGenerated.java @@ -3009,6 +3009,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { public void testInterfaceHashCode() throws Exception { runTest("compiler/testData/codegen/bytecodeText/hashCode/interfaceHashCode.kt"); } + + @Test + @TestMetadata("interfaceHashCodeWithSmartCast.kt") + public void testInterfaceHashCodeWithSmartCast() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/hashCode/interfaceHashCodeWithSmartCast.kt"); + } } @Nested diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java index 67908bf703c..2333d6d7779 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeTextTestGenerated.java @@ -3141,6 +3141,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { public void testInterfaceHashCode() throws Exception { runTest("compiler/testData/codegen/bytecodeText/hashCode/interfaceHashCode.kt"); } + + @Test + @TestMetadata("interfaceHashCodeWithSmartCast.kt") + public void testInterfaceHashCodeWithSmartCast() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/hashCode/interfaceHashCodeWithSmartCast.kt"); + } } @Nested From d40777c28f1134161d274bf39f2f91f0f9b8c52b Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 19 Feb 2021 14:01:44 +0300 Subject: [PATCH 297/368] [FIR] Fix calculating arguments of bare type with intersection type as base --- ...TouchedTilContractsPhaseTestGenerated.java | 5 ++ .../resolve/types/castToBareType.fir.txt | 21 ++++++++ .../testData/resolve/types/castToBareType.kt | 17 +++++++ .../runners/FirDiagnosticTestGenerated.java | 6 +++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 +++ .../FirExpressionsResolveTransformer.kt | 48 ++++++++++++------- 6 files changed, 87 insertions(+), 16 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolve/types/castToBareType.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/types/castToBareType.kt diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 5bd3d252ab9..641a17bb81e 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -3256,6 +3256,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract public void testCapturedParametersOfInnerClasses() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt"); } + + @TestMetadata("castToBareType.kt") + public void testCastToBareType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/types/castToBareType.kt"); + } } @TestMetadata("compiler/fir/analysis-tests/testData/resolve/visibility") diff --git a/compiler/fir/analysis-tests/testData/resolve/types/castToBareType.fir.txt b/compiler/fir/analysis-tests/testData/resolve/types/castToBareType.fir.txt new file mode 100644 index 00000000000..4497e5bd014 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/types/castToBareType.fir.txt @@ -0,0 +1,21 @@ +FILE: castToBareType.kt + public abstract interface FirDeclaration : R|kotlin/Any| { + } + public abstract interface FirSymbolOwner|> : R|kotlin/Any| { + public abstract val symbol: R|AbstractFirBasedSymbol| + public get(): R|AbstractFirBasedSymbol| + + } + public abstract interface FirFunction|> : R|FirSymbolOwner|, R|FirDeclaration| { + } + public abstract interface AbstractFirBasedSymbol|, R|FirDeclaration|> : R|kotlin/Any| { + public abstract val fir: R|E| + public get(): R|E| + + } + public final fun foo(firAdaptee: R|FirFunction<*>|): R|kotlin/Unit| { + } + public final fun test(symbol: R|AbstractFirBasedSymbol<*>|): R|kotlin/Unit| { + lval firAdaptee: R|FirFunction & FirDeclaration)> & FirDeclaration)> & FirDeclaration)> & FirDeclaration)>| = (R|/symbol|.R|SubstitutionOverride| as R|FirFunction & FirDeclaration)> & FirDeclaration)> & FirDeclaration)> & FirDeclaration)>|) + R|/foo|(R|/firAdaptee|) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/types/castToBareType.kt b/compiler/fir/analysis-tests/testData/resolve/types/castToBareType.kt new file mode 100644 index 00000000000..eed7c886290 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/types/castToBareType.kt @@ -0,0 +1,17 @@ +interface FirDeclaration + +interface FirSymbolOwner> { + val symbol: AbstractFirBasedSymbol +} +interface FirFunction> : FirSymbolOwner, FirDeclaration + +interface AbstractFirBasedSymbol where E : FirSymbolOwner, E : FirDeclaration { + val fir: E +} + +fun foo(firAdaptee: FirFunction<*>) {} + +fun test(symbol: AbstractFirBasedSymbol<*>) { + val firAdaptee = symbol.fir as FirFunction + foo(firAdaptee) +} diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index e8ed54adf0d..c850c871cd3 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -3630,6 +3630,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { public void testCapturedParametersOfInnerClasses() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt"); } + + @Test + @TestMetadata("castToBareType.kt") + public void testCastToBareType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/types/castToBareType.kt"); + } } @Nested diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index dfb0ad3938f..d4bb412ad93 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -3681,6 +3681,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos public void testCapturedParametersOfInnerClasses() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt"); } + + @Test + @TestMetadata("castToBareType.kt") + public void testCastToBareType() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/types/castToBareType.kt"); + } } @Nested diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index ed23f1d3193..cc802d6b172 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -499,25 +499,41 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform val firClass = type.lookupTag.toSymbol(session)?.fir ?: return this if (firClass !is FirTypeParameterRefsOwner || firClass.typeParameters.isEmpty()) return this - val baseType = argument.typeRef.coneTypeSafe()?.lowerBoundIfFlexible()?.fullyExpandedType(session) ?: return this - if (baseType !is ConeClassLikeType) return this - val baseFirClass = baseType.lookupTag.toSymbol(session)?.fir ?: return this - - val newArguments = if (AbstractTypeChecker.isSubtypeOfClass( - session.typeContext.newBaseTypeCheckerContext(errorTypesEqualToAnything = false, stubTypesEqualToAnything = true), baseType.lookupTag, type.lookupTag)) { - // If actual type of declaration is more specific than bare type then we should just find - // corresponding supertype with proper arguments - with(session.typeContext) { - val superType = baseType.fastCorrespondingSupertypes(type.lookupTag)?.firstOrNull() as? ConeKotlinType? - superType?.typeArguments - } - } else { - type.inheritTypeArguments(baseFirClass, baseType.typeArguments) - } ?: return buildErrorTypeRef { + val originalType = argument.typeRef.coneTypeSafe() ?: return this + val newType = computeRepresentativeTypeForBareType(type, originalType) ?: return buildErrorTypeRef { source = this@withTypeArgumentsForBareType.source diagnostic = ConeWrongNumberOfTypeArgumentsError(firClass.typeParameters.size, firClass.symbol) } - return if (newArguments.isEmpty()) this else withReplacedConeType(type.withArguments(newArguments)) + return if (newType.typeArguments.isEmpty()) this else withReplacedConeType(newType) + } + + private fun computeRepresentativeTypeForBareType(type: ConeClassLikeType, originalType: ConeKotlinType): ConeKotlinType? { + @Suppress("NAME_SHADOWING") + val originalType = originalType.lowerBoundIfFlexible().fullyExpandedType(session) + if (originalType is ConeIntersectionType) { + val candidatesFromIntersectedTypes = originalType.intersectedTypes.mapNotNull { computeRepresentativeTypeForBareType(type, it) } + candidatesFromIntersectedTypes.firstOrNull { it.typeArguments.isNotEmpty() }?.let { return it } + return candidatesFromIntersectedTypes.firstOrNull() + } + if (originalType !is ConeClassLikeType) return type + val baseFirClass = originalType.lookupTag.toSymbol(session)?.fir ?: return type + val isSubtype = AbstractTypeChecker.isSubtypeOfClass( + session.typeContext.newBaseTypeCheckerContext(errorTypesEqualToAnything = false, stubTypesEqualToAnything = true), + originalType.lookupTag, + type.lookupTag + ) + val newArguments = if (isSubtype) { + // If actual type of declaration is more specific than bare type then we should just find + // corresponding supertype with proper arguments + with(session.typeContext) { + val superType = originalType.fastCorrespondingSupertypes(type.lookupTag)?.firstOrNull() as? ConeKotlinType? + superType?.typeArguments + } + } else { + type.inheritTypeArguments(baseFirClass, originalType.typeArguments) + } ?: return null + if (newArguments.isEmpty()) return type + return type.withArguments(newArguments) } override fun transformTypeOperatorCall( From b8d1bbdd0d7c894165e07dcca2520c14872fcb5a Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Fri, 19 Feb 2021 15:04:45 +0000 Subject: [PATCH 298/368] Do not swallow PCE #KT-39776 Fixed --- .../jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt index 1e484346619..0e5b950f0de 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt @@ -17,8 +17,8 @@ package org.jetbrains.kotlin.load.kotlin import com.intellij.ide.highlighter.JavaClassFileType +import com.intellij.openapi.diagnostic.ControlFlowException import com.intellij.openapi.diagnostic.Logger -import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.vfs.VirtualFile import org.jetbrains.kotlin.load.kotlin.KotlinClassFinder.Result.KotlinClass import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader @@ -73,9 +73,10 @@ class VirtualFileKotlinClass private constructor( } } catch (e: FileNotFoundException) { // Valid situation. User can delete jar file. - } catch (e: ProcessCanceledException) { - // Valid situation. } catch (e: Throwable) { + if (e is ControlFlowException) { + throw e + } LOG.warn(renderFileReadingErrorMessage(file), e) } null From 742f1e00693e5084afa6019bdda8e75333f10345 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 17 Feb 2021 14:14:30 +0300 Subject: [PATCH 299/368] FIR: add replaceSource to all FIR tree nodes --- .../jetbrains/kotlin/fir/java/declarations/FirJavaClass.kt | 3 +++ .../kotlin/fir/java/declarations/FirJavaConstructor.kt | 3 +++ .../jetbrains/kotlin/fir/java/declarations/FirJavaField.kt | 3 +++ .../jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt | 3 +++ .../kotlin/fir/java/declarations/FirJavaValueParameter.kt | 3 +++ .../org/jetbrains/kotlin/fir/types/jvm/FirJavaTypeRef.kt | 3 +++ .../kotlin/fir/resolve/calls/CallableReferenceResolution.kt | 3 +++ .../fir/resolve/dfa/FirControlFlowGraphReferenceImpl.kt | 3 +++ .../src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt | 3 +++ .../gen/org/jetbrains/kotlin/fir/FirAnnotationContainer.kt | 2 ++ .../fir/tree/gen/org/jetbrains/kotlin/fir/FirElement.kt | 2 ++ compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirLabel.kt | 2 ++ .../fir/tree/gen/org/jetbrains/kotlin/fir/FirSymbolOwner.kt | 2 ++ .../tree/gen/org/jetbrains/kotlin/fir/FirTargetElement.kt | 2 ++ .../kotlin/fir/contracts/FirContractDescription.kt | 2 ++ .../jetbrains/kotlin/fir/contracts/FirEffectDeclaration.kt | 2 ++ .../kotlin/fir/contracts/FirLegacyRawContractDescription.kt | 2 ++ .../kotlin/fir/contracts/FirRawContractDescription.kt | 2 ++ .../kotlin/fir/contracts/FirResolvedContractDescription.kt | 2 ++ .../kotlin/fir/contracts/impl/FirEffectDeclarationImpl.kt | 6 +++++- .../contracts/impl/FirLegacyRawContractDescriptionImpl.kt | 6 +++++- .../fir/contracts/impl/FirRawContractDescriptionImpl.kt | 6 +++++- .../contracts/impl/FirResolvedContractDescriptionImpl.kt | 6 +++++- .../kotlin/fir/declarations/FirAnnotatedDeclaration.kt | 2 ++ .../kotlin/fir/declarations/FirAnonymousFunction.kt | 2 ++ .../kotlin/fir/declarations/FirAnonymousInitializer.kt | 2 ++ .../jetbrains/kotlin/fir/declarations/FirAnonymousObject.kt | 2 ++ .../kotlin/fir/declarations/FirCallableDeclaration.kt | 2 ++ .../kotlin/fir/declarations/FirCallableMemberDeclaration.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/declarations/FirClass.kt | 2 ++ .../kotlin/fir/declarations/FirClassLikeDeclaration.kt | 2 ++ .../org/jetbrains/kotlin/fir/declarations/FirConstructor.kt | 2 ++ .../kotlin/fir/declarations/FirContractDescriptionOwner.kt | 2 ++ .../kotlin/fir/declarations/FirControlFlowGraphOwner.kt | 2 ++ .../org/jetbrains/kotlin/fir/declarations/FirDeclaration.kt | 2 ++ .../kotlin/fir/declarations/FirDeclarationStatus.kt | 2 ++ .../org/jetbrains/kotlin/fir/declarations/FirEnumEntry.kt | 2 ++ .../jetbrains/kotlin/fir/declarations/FirErrorFunction.kt | 2 ++ .../jetbrains/kotlin/fir/declarations/FirErrorProperty.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/declarations/FirField.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/declarations/FirFile.kt | 2 ++ .../org/jetbrains/kotlin/fir/declarations/FirFunction.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/declarations/FirImport.kt | 2 ++ .../kotlin/fir/declarations/FirMemberDeclaration.kt | 2 ++ .../org/jetbrains/kotlin/fir/declarations/FirProperty.kt | 2 ++ .../kotlin/fir/declarations/FirPropertyAccessor.kt | 2 ++ .../jetbrains/kotlin/fir/declarations/FirRegularClass.kt | 2 ++ .../kotlin/fir/declarations/FirResolvedDeclarationStatus.kt | 2 ++ .../jetbrains/kotlin/fir/declarations/FirResolvedImport.kt | 2 ++ .../jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt | 2 ++ .../org/jetbrains/kotlin/fir/declarations/FirTypeAlias.kt | 2 ++ .../jetbrains/kotlin/fir/declarations/FirTypeParameter.kt | 2 ++ .../kotlin/fir/declarations/FirTypeParameterRef.kt | 2 ++ .../kotlin/fir/declarations/FirTypeParameterRefsOwner.kt | 2 ++ .../kotlin/fir/declarations/FirTypeParametersOwner.kt | 2 ++ .../kotlin/fir/declarations/FirTypedDeclaration.kt | 2 ++ .../jetbrains/kotlin/fir/declarations/FirValueParameter.kt | 2 ++ .../org/jetbrains/kotlin/fir/declarations/FirVariable.kt | 2 ++ .../fir/declarations/impl/FirAnonymousFunctionImpl.kt | 6 +++++- .../fir/declarations/impl/FirAnonymousInitializerImpl.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirAnonymousObjectImpl.kt | 6 +++++- .../impl/FirConstructedClassTypeParameterRef.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirConstructorImpl.kt | 6 +++++- .../fir/declarations/impl/FirDefaultSetterValueParameter.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirEnumEntryImpl.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt | 6 +++++- .../jetbrains/kotlin/fir/declarations/impl/FirFieldImpl.kt | 6 +++++- .../jetbrains/kotlin/fir/declarations/impl/FirFileImpl.kt | 6 +++++- .../jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt | 6 +++++- .../fir/declarations/impl/FirOuterClassTypeParameterRef.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirPrimaryConstructor.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirPropertyImpl.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirRegularClassImpl.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirResolvedImportImpl.kt | 2 ++ .../kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirTypeAliasImpl.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirTypeParameterImpl.kt | 6 +++++- .../kotlin/fir/declarations/impl/FirValueParameterImpl.kt | 6 +++++- .../jetbrains/kotlin/fir/diagnostics/FirDiagnosticHolder.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirAnnotationCall.kt | 2 ++ .../org/jetbrains/kotlin/fir/expressions/FirArgumentList.kt | 2 ++ .../org/jetbrains/kotlin/fir/expressions/FirArrayOfCall.kt | 2 ++ .../fir/expressions/FirAssignmentOperatorStatement.kt | 2 ++ .../kotlin/fir/expressions/FirAugmentedArraySetCall.kt | 2 ++ .../kotlin/fir/expressions/FirBinaryLogicExpression.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/expressions/FirBlock.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirBreakExpression.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/expressions/FirCall.kt | 2 ++ .../kotlin/fir/expressions/FirCallableReferenceAccess.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/expressions/FirCatch.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirCheckNotNullCall.kt | 2 ++ .../kotlin/fir/expressions/FirCheckedSafeCallSubject.kt | 2 ++ .../kotlin/fir/expressions/FirClassReferenceExpression.kt | 2 ++ .../kotlin/fir/expressions/FirComparisonExpression.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirComponentCall.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirConstExpression.kt | 2 ++ .../kotlin/fir/expressions/FirContinueExpression.kt | 2 ++ .../kotlin/fir/expressions/FirDelegatedConstructorCall.kt | 2 ++ .../org/jetbrains/kotlin/fir/expressions/FirDoWhileLoop.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirElvisExpression.kt | 2 ++ .../kotlin/fir/expressions/FirEqualityOperatorCall.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirErrorExpression.kt | 2 ++ .../org/jetbrains/kotlin/fir/expressions/FirErrorLoop.kt | 2 ++ .../kotlin/fir/expressions/FirErrorResolvedQualifier.kt | 2 ++ .../org/jetbrains/kotlin/fir/expressions/FirExpression.kt | 2 ++ .../kotlin/fir/expressions/FirExpressionWithSmartcast.kt | 2 ++ .../org/jetbrains/kotlin/fir/expressions/FirFunctionCall.kt | 2 ++ .../org/jetbrains/kotlin/fir/expressions/FirGetClassCall.kt | 2 ++ .../kotlin/fir/expressions/FirImplicitInvokeCall.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/expressions/FirJump.kt | 2 ++ .../kotlin/fir/expressions/FirLambdaArgumentExpression.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/expressions/FirLoop.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/expressions/FirLoopJump.kt | 2 ++ .../kotlin/fir/expressions/FirNamedArgumentExpression.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirQualifiedAccess.kt | 2 ++ .../kotlin/fir/expressions/FirQualifiedAccessExpression.kt | 2 ++ .../org/jetbrains/kotlin/fir/expressions/FirResolvable.kt | 2 ++ .../kotlin/fir/expressions/FirResolvedQualifier.kt | 2 ++ .../fir/expressions/FirResolvedReifiedParameterReference.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirReturnExpression.kt | 2 ++ .../kotlin/fir/expressions/FirSafeCallExpression.kt | 2 ++ .../kotlin/fir/expressions/FirSpreadArgumentExpression.kt | 2 ++ .../org/jetbrains/kotlin/fir/expressions/FirStatement.kt | 2 ++ .../kotlin/fir/expressions/FirStringConcatenationCall.kt | 2 ++ .../kotlin/fir/expressions/FirThisReceiverExpression.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirThrowExpression.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirTryExpression.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirTypeOperatorCall.kt | 2 ++ .../kotlin/fir/expressions/FirVarargArgumentsExpression.kt | 2 ++ .../kotlin/fir/expressions/FirVariableAssignment.kt | 2 ++ .../org/jetbrains/kotlin/fir/expressions/FirWhenBranch.kt | 2 ++ .../jetbrains/kotlin/fir/expressions/FirWhenExpression.kt | 2 ++ .../kotlin/fir/expressions/FirWhenSubjectExpression.kt | 2 ++ .../org/jetbrains/kotlin/fir/expressions/FirWhileLoop.kt | 2 ++ .../kotlin/fir/expressions/FirWrappedArgumentExpression.kt | 2 ++ .../kotlin/fir/expressions/FirWrappedDelegateExpression.kt | 2 ++ .../kotlin/fir/expressions/FirWrappedExpression.kt | 2 ++ .../kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirArgumentListImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirArrayOfCallImpl.kt | 6 +++++- .../expressions/impl/FirAssignmentOperatorStatementImpl.kt | 6 +++++- .../fir/expressions/impl/FirAugmentedArraySetCallImpl.kt | 6 +++++- .../fir/expressions/impl/FirBinaryLogicExpressionImpl.kt | 6 +++++- .../jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirBreakExpressionImpl.kt | 6 +++++- .../fir/expressions/impl/FirCallableReferenceAccessImpl.kt | 6 +++++- .../jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt | 6 +++++- .../fir/expressions/impl/FirCheckedSafeCallSubjectImpl.kt | 6 +++++- .../fir/expressions/impl/FirClassReferenceExpressionImpl.kt | 6 +++++- .../fir/expressions/impl/FirComparisonExpressionImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirComponentCallImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirConstExpressionImpl.kt | 6 +++++- .../fir/expressions/impl/FirContinueExpressionImpl.kt | 6 +++++- .../fir/expressions/impl/FirDelegatedConstructorCallImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirElseIfTrueCondition.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirElvisExpressionImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirEmptyExpressionBlock.kt | 2 ++ .../fir/expressions/impl/FirEqualityOperatorCallImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirErrorLoopImpl.kt | 6 +++++- .../fir/expressions/impl/FirErrorResolvedQualifierImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirExpressionStub.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirFunctionCallImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirGetClassCallImpl.kt | 6 +++++- .../fir/expressions/impl/FirImplicitInvokeCallImpl.kt | 6 +++++- .../fir/expressions/impl/FirLambdaArgumentExpressionImpl.kt | 6 +++++- .../jetbrains/kotlin/fir/expressions/impl/FirLazyBlock.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirLazyExpression.kt | 6 +++++- .../fir/expressions/impl/FirNamedArgumentExpressionImpl.kt | 6 +++++- .../expressions/impl/FirQualifiedAccessExpressionImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt | 6 +++++- .../impl/FirResolvedReifiedParameterReferenceImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirReturnExpressionImpl.kt | 6 +++++- .../fir/expressions/impl/FirSafeCallExpressionImpl.kt | 6 +++++- .../fir/expressions/impl/FirSpreadArgumentExpressionImpl.kt | 6 +++++- .../fir/expressions/impl/FirStringConcatenationCallImpl.kt | 6 +++++- .../fir/expressions/impl/FirThisReceiverExpressionImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirThrowExpressionImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirTryExpressionImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirTypeOperatorCallImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirUnitExpression.kt | 6 +++++- .../expressions/impl/FirVarargArgumentsExpressionImpl.kt | 6 +++++- .../fir/expressions/impl/FirVariableAssignmentImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirWhenBranchImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt | 6 +++++- .../fir/expressions/impl/FirWhenSubjectExpressionImpl.kt | 6 +++++- .../kotlin/fir/expressions/impl/FirWhileLoopImpl.kt | 6 +++++- .../expressions/impl/FirWrappedDelegateExpressionImpl.kt | 6 +++++- .../tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt | 6 +++++- .../kotlin/fir/references/FirBackingFieldReference.kt | 2 ++ .../kotlin/fir/references/FirControlFlowGraphReference.kt | 2 ++ .../kotlin/fir/references/FirDelegateFieldReference.kt | 2 ++ .../kotlin/fir/references/FirErrorNamedReference.kt | 2 ++ .../jetbrains/kotlin/fir/references/FirNamedReference.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/references/FirReference.kt | 2 ++ .../kotlin/fir/references/FirResolvedCallableReference.kt | 2 ++ .../kotlin/fir/references/FirResolvedNamedReference.kt | 2 ++ .../jetbrains/kotlin/fir/references/FirSuperReference.kt | 2 ++ .../org/jetbrains/kotlin/fir/references/FirThisReference.kt | 2 ++ .../fir/references/impl/FirBackingFieldReferenceImpl.kt | 6 +++++- .../fir/references/impl/FirDelegateFieldReferenceImpl.kt | 6 +++++- .../fir/references/impl/FirErrorNamedReferenceImpl.kt | 6 +++++- .../kotlin/fir/references/impl/FirExplicitSuperReference.kt | 6 +++++- .../kotlin/fir/references/impl/FirExplicitThisReference.kt | 6 +++++- .../kotlin/fir/references/impl/FirImplicitThisReference.kt | 2 ++ .../impl/FirPropertyFromParameterResolvedNamedReference.kt | 6 +++++- .../fir/references/impl/FirResolvedCallableReferenceImpl.kt | 6 +++++- .../fir/references/impl/FirResolvedNamedReferenceImpl.kt | 6 +++++- .../kotlin/fir/references/impl/FirSimpleNamedReference.kt | 6 +++++- .../kotlin/fir/references/impl/FirStubReference.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/types/FirDynamicTypeRef.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/types/FirErrorTypeRef.kt | 2 ++ .../org/jetbrains/kotlin/fir/types/FirFunctionTypeRef.kt | 2 ++ .../org/jetbrains/kotlin/fir/types/FirImplicitTypeRef.kt | 2 ++ .../org/jetbrains/kotlin/fir/types/FirResolvedTypeRef.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/types/FirStarProjection.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/types/FirTypeProjection.kt | 2 ++ .../kotlin/fir/types/FirTypeProjectionWithVariance.kt | 2 ++ .../tree/gen/org/jetbrains/kotlin/fir/types/FirTypeRef.kt | 2 ++ .../jetbrains/kotlin/fir/types/FirTypeRefWithNullability.kt | 2 ++ .../gen/org/jetbrains/kotlin/fir/types/FirUserTypeRef.kt | 2 ++ .../kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt | 6 +++++- .../jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt | 6 +++++- .../kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt | 6 +++++- .../kotlin/fir/types/impl/FirImplicitTypeRefImpl.kt | 6 +++++- .../kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt | 6 +++++- .../kotlin/fir/types/impl/FirStarProjectionImpl.kt | 6 +++++- .../kotlin/fir/types/impl/FirTypePlaceholderProjection.kt | 2 ++ .../fir/types/impl/FirTypeProjectionWithVarianceImpl.kt | 6 +++++- .../fir/contracts/impl/FirEmptyContractDescription.kt | 3 +++ .../fir/declarations/impl/FirDeclarationStatusImpl.kt | 3 +++ .../fir/declarations/synthetic/FirSyntheticProperty.kt | 3 +++ .../declarations/synthetic/FirSyntheticPropertyAccessor.kt | 3 +++ .../org/jetbrains/kotlin/fir/expressions/FirArgumentUtil.kt | 5 +++++ .../kotlin/fir/expressions/impl/FirArraySetArgumentList.kt | 4 ++++ .../fir/expressions/impl/FirExpressionWithSmartcastImpl.kt | 3 +++ .../kotlin/fir/expressions/impl/FirNoReceiverExpression.kt | 3 +++ .../kotlin/fir/expressions/impl/FirResolvedArgumentList.kt | 4 ++++ .../kotlin/fir/expressions/impl/FirSingleExpressionBlock.kt | 3 +++ .../kotlin/fir/expressions/impl/FirStubStatement.kt | 3 +++ .../references/impl/FirReferenceForUnresolvedAnnotations.kt | 3 +++ .../impl/FirReferencePlaceholderForResolvedAnnotations.kt | 3 +++ .../kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt | 3 +++ .../jetbrains/kotlin/fir/types/impl/FirUserTypeRefImpl.kt | 3 +++ .../jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt | 2 +- 249 files changed, 807 insertions(+), 95 deletions(-) diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaClass.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaClass.kt index 0168bd9cc48..0ff5821f349 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaClass.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaClass.kt @@ -116,6 +116,9 @@ class FirJavaClass @FirImplementationDetail internal constructor( typeParameters.transformInplace(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } @FirBuilderDsl diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt index 3175cadd03e..09702e4b03b 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaConstructor.kt @@ -138,6 +138,9 @@ class FirJavaConstructor @FirImplementationDetail constructor( override fun replaceBody(newBody: FirBlock?) { error("Body cannot be replaced for FirJavaConstructor") } + + override fun replaceSource(newSource: FirSourceElement?) { + } } @FirBuilderDsl diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt index 723e21bf066..38093ba7b04 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaField.kt @@ -141,6 +141,9 @@ class FirJavaField @FirImplementationDetail constructor( override fun transformDelegate(transformer: FirTransformer, data: D): FirField { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } @FirBuilderDsl diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt index 8c9b6390f51..7ffd4bc1c43 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt @@ -169,6 +169,9 @@ class FirJavaMethod @FirImplementationDetail constructor( override fun replaceContractDescription(newContractDescription: FirContractDescription) { } + + override fun replaceSource(newSource: FirSourceElement?) { + } } val ALL_JAVA_OPERATION_NAMES = diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt index abc2d4d2de3..bfef6f8fc9e 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt @@ -138,6 +138,9 @@ class FirJavaValueParameter @FirImplementationDetail constructor( override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) { } + + override fun replaceSource(newSource: FirSourceElement?) { + } } @FirBuilderDsl diff --git a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/types/jvm/FirJavaTypeRef.kt b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/types/jvm/FirJavaTypeRef.kt index edf658289f1..57c8a66b152 100644 --- a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/types/jvm/FirJavaTypeRef.kt +++ b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/types/jvm/FirJavaTypeRef.kt @@ -47,6 +47,9 @@ class FirJavaTypeRef( override fun transformAnnotations(transformer: FirTransformer, data: D): FirUserTypeRef { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } @FirBuilderDsl diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt index b2aa2187ffe..d4e99ef8e13 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt @@ -377,6 +377,9 @@ class FirFakeArgumentForCallableReference( override fun transformChildren(transformer: FirTransformer, data: D): FirElement { error("should not be called") } + + override fun replaceSource(newSource: FirSourceElement?) { + } } fun ConeKotlinType.isKCallableType(): Boolean { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirControlFlowGraphReferenceImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirControlFlowGraphReferenceImpl.kt index 993091577b6..fa946c1423f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirControlFlowGraphReferenceImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirControlFlowGraphReferenceImpl.kt @@ -23,6 +23,9 @@ class FirControlFlowGraphReferenceImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirControlFlowGraphReference { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } class DataFlowInfo(val variableStorage: VariableStorage, val flowOnNodes: Map, Flow>) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt index d344fd43af6..97b791957b3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt @@ -732,4 +732,7 @@ object FirStub : FirElement { override fun transformChildren(transformer: FirTransformer, data: D): FirElement { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirAnnotationContainer.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirAnnotationContainer.kt index a15707d3ef0..2846720abe1 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirAnnotationContainer.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirAnnotationContainer.kt @@ -19,5 +19,7 @@ interface FirAnnotationContainer : FirElement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitAnnotationContainer(this, data) + override fun replaceSource(newSource: FirSourceElement?) + fun transformAnnotations(transformer: FirTransformer, data: D): FirAnnotationContainer } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirElement.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirElement.kt index e1bf6d31110..9895ba8655d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirElement.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirElement.kt @@ -18,6 +18,8 @@ interface FirElement { fun accept(visitor: FirVisitor, data: D): R = visitor.visitElement(this, data) + fun replaceSource(newSource: FirSourceElement?) + fun accept(visitor: FirVisitorVoid) = accept(visitor, null) fun acceptChildren(visitor: FirVisitor, data: D) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirLabel.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirLabel.kt index bc4b0949dcb..e1618483369 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirLabel.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirLabel.kt @@ -17,4 +17,6 @@ abstract class FirLabel : FirPureAbstractElement(), FirElement { abstract val name: String override fun accept(visitor: FirVisitor, data: D): R = visitor.visitLabel(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirSymbolOwner.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirSymbolOwner.kt index ee9f92ef11c..23d9128c512 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirSymbolOwner.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirSymbolOwner.kt @@ -19,4 +19,6 @@ interface FirSymbolOwner : FirElement where E : FirSymbolOwner, E : FirDec val symbol: AbstractFirBasedSymbol override fun accept(visitor: FirVisitor, data: D): R = visitor.visitSymbolOwner(this, data) + + override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirTargetElement.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirTargetElement.kt index 102eadd8a98..5b2801c6ccc 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirTargetElement.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/FirTargetElement.kt @@ -16,4 +16,6 @@ interface FirTargetElement : FirElement { override val source: FirSourceElement? override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTargetElement(this, data) + + override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirContractDescription.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirContractDescription.kt index 0f5da0f55fe..739bd4d5ab4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirContractDescription.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirContractDescription.kt @@ -19,4 +19,6 @@ abstract class FirContractDescription : FirPureAbstractElement(), FirElement { abstract override val source: FirSourceElement? override fun accept(visitor: FirVisitor, data: D): R = visitor.visitContractDescription(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirEffectDeclaration.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirEffectDeclaration.kt index b38b2292bf5..49d458059be 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirEffectDeclaration.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirEffectDeclaration.kt @@ -21,4 +21,6 @@ abstract class FirEffectDeclaration : FirPureAbstractElement(), FirElement { abstract val effect: ConeEffectDeclaration override fun accept(visitor: FirVisitor, data: D): R = visitor.visitEffectDeclaration(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirLegacyRawContractDescription.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirLegacyRawContractDescription.kt index cbb2cf506b7..a766d9c6d2e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirLegacyRawContractDescription.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirLegacyRawContractDescription.kt @@ -19,4 +19,6 @@ abstract class FirLegacyRawContractDescription : FirContractDescription() { abstract val contractCall: FirFunctionCall override fun accept(visitor: FirVisitor, data: D): R = visitor.visitLegacyRawContractDescription(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirRawContractDescription.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirRawContractDescription.kt index f58872de6f5..7535bfbe560 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirRawContractDescription.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirRawContractDescription.kt @@ -19,4 +19,6 @@ abstract class FirRawContractDescription : FirContractDescription() { abstract val rawEffects: List override fun accept(visitor: FirVisitor, data: D): R = visitor.visitRawContractDescription(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirResolvedContractDescription.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirResolvedContractDescription.kt index 4166c3069fd..d36852d70ee 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirResolvedContractDescription.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/FirResolvedContractDescription.kt @@ -20,4 +20,6 @@ abstract class FirResolvedContractDescription : FirContractDescription() { abstract val unresolvedEffects: List override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedContractDescription(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirEffectDeclarationImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirEffectDeclarationImpl.kt index edfeecc2c00..89473991d1a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirEffectDeclarationImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirEffectDeclarationImpl.kt @@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirEffectDeclarationImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val effect: ConeEffectDeclaration, ) : FirEffectDeclaration() { override fun acceptChildren(visitor: FirVisitor, data: D) {} @@ -24,4 +24,8 @@ internal class FirEffectDeclarationImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirEffectDeclarationImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirLegacyRawContractDescriptionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirLegacyRawContractDescriptionImpl.kt index 5e154977fa4..0a3090da1a7 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirLegacyRawContractDescriptionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirLegacyRawContractDescriptionImpl.kt @@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirLegacyRawContractDescriptionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var contractCall: FirFunctionCall, ) : FirLegacyRawContractDescription() { override fun acceptChildren(visitor: FirVisitor, data: D) { @@ -27,4 +27,8 @@ internal class FirLegacyRawContractDescriptionImpl( contractCall = contractCall.transformSingle(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirRawContractDescriptionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirRawContractDescriptionImpl.kt index a99cc84bb39..6c3728ebf2b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirRawContractDescriptionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirRawContractDescriptionImpl.kt @@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirRawContractDescriptionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val rawEffects: MutableList, ) : FirRawContractDescription() { override fun acceptChildren(visitor: FirVisitor, data: D) { @@ -27,4 +27,8 @@ internal class FirRawContractDescriptionImpl( rawEffects.transformInplace(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirResolvedContractDescriptionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirResolvedContractDescriptionImpl.kt index 992f5fe73a8..5600b306577 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirResolvedContractDescriptionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/contracts/impl/FirResolvedContractDescriptionImpl.kt @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirResolvedContractDescriptionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val effects: MutableList, override val unresolvedEffects: MutableList, ) : FirResolvedContractDescription() { @@ -31,4 +31,8 @@ internal class FirResolvedContractDescriptionImpl( unresolvedEffects.transformInplace(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnnotatedDeclaration.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnnotatedDeclaration.kt index db1777d5fb3..22480e9bd52 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnnotatedDeclaration.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnnotatedDeclaration.kt @@ -26,6 +26,8 @@ interface FirAnnotatedDeclaration : FirDeclaration, FirAnnotationContainer { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitAnnotatedDeclaration(this, data) + override fun replaceSource(newSource: FirSourceElement?) + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) override fun transformAnnotations(transformer: FirTransformer, data: D): FirAnnotatedDeclaration diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt index c9074ffa35c..8e53d9e6ad9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt @@ -43,6 +43,8 @@ abstract class FirAnonymousFunction : FirFunction, FirExpr override fun accept(visitor: FirVisitor, data: D): R = visitor.visitAnonymousFunction(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousInitializer.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousInitializer.kt index 133e42eda67..0fc183a574c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousInitializer.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousInitializer.kt @@ -31,6 +31,8 @@ abstract class FirAnonymousInitializer : FirPureAbstractElement(), FirDeclaratio override fun accept(visitor: FirVisitor, data: D): R = visitor.visitAnonymousInitializer(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousObject.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousObject.kt index 4733b0d2c85..5e366f0a76f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousObject.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirAnonymousObject.kt @@ -39,6 +39,8 @@ abstract class FirAnonymousObject : FirClass, FirControlFlow override fun accept(visitor: FirVisitor, data: D): R = visitor.visitAnonymousObject(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceSuperTypeRefs(newSuperTypeRefs: List) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableDeclaration.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableDeclaration.kt index 19ecdd4e190..5935a99bb94 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableDeclaration.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableDeclaration.kt @@ -31,6 +31,8 @@ interface FirCallableDeclaration> : FirTypedDeclar override fun accept(visitor: FirVisitor, data: D): R = visitor.visitCallableDeclaration(this, data) + override fun replaceSource(newSource: FirSourceElement?) + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableMemberDeclaration.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableMemberDeclaration.kt index 003d3d2bf05..bf1a41a9c85 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableMemberDeclaration.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirCallableMemberDeclaration.kt @@ -36,6 +36,8 @@ interface FirCallableMemberDeclaration> : Fi override fun accept(visitor: FirVisitor, data: D): R = visitor.visitCallableMemberDeclaration(this, data) + override fun replaceSource(newSource: FirSourceElement?) + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirClass.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirClass.kt index 6e7e2bbf1cd..7a85963be9e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirClass.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirClass.kt @@ -36,6 +36,8 @@ interface FirClass> : FirClassLikeDeclaration, FirStatement, override fun accept(visitor: FirVisitor, data: D): R = visitor.visitClass(this, data) + override fun replaceSource(newSource: FirSourceElement?) + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) fun replaceSuperTypeRefs(newSuperTypeRefs: List) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirClassLikeDeclaration.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirClassLikeDeclaration.kt index 1bd384e9d16..18548443b43 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirClassLikeDeclaration.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirClassLikeDeclaration.kt @@ -29,6 +29,8 @@ interface FirClassLikeDeclaration> : FirAnnotated override fun accept(visitor: FirVisitor, data: D): R = visitor.visitClassLikeDeclaration(this, data) + override fun replaceSource(newSource: FirSourceElement?) + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) override fun transformAnnotations(transformer: FirTransformer, data: D): FirClassLikeDeclaration diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt index cf644f6a1f7..e8b9444ee57 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirConstructor.kt @@ -45,6 +45,8 @@ abstract class FirConstructor : FirPureAbstractElement(), FirFunction accept(visitor: FirVisitor, data: D): R = visitor.visitConstructor(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirContractDescriptionOwner.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirContractDescriptionOwner.kt index b2279b6c488..30c7f080a7b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirContractDescriptionOwner.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirContractDescriptionOwner.kt @@ -21,6 +21,8 @@ interface FirContractDescriptionOwner : FirElement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitContractDescriptionOwner(this, data) + override fun replaceSource(newSource: FirSourceElement?) + fun replaceContractDescription(newContractDescription: FirContractDescription) fun transformContractDescription(transformer: FirTransformer, data: D): FirContractDescriptionOwner diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirControlFlowGraphOwner.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirControlFlowGraphOwner.kt index f68a4cbb559..bc6b963e54b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirControlFlowGraphOwner.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirControlFlowGraphOwner.kt @@ -21,5 +21,7 @@ interface FirControlFlowGraphOwner : FirElement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitControlFlowGraphOwner(this, data) + override fun replaceSource(newSource: FirSourceElement?) + fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirDeclaration.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirDeclaration.kt index abf9792e9ec..0c6f8b4e505 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirDeclaration.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirDeclaration.kt @@ -24,5 +24,7 @@ interface FirDeclaration : FirElement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitDeclaration(this, data) + override fun replaceSource(newSource: FirSourceElement?) + fun replaceResolvePhase(newResolvePhase: FirResolvePhase) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirDeclarationStatus.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirDeclarationStatus.kt index ea4334ea13d..191f80d18f5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirDeclarationStatus.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirDeclarationStatus.kt @@ -40,4 +40,6 @@ interface FirDeclarationStatus : FirElement { val isFun: Boolean override fun accept(visitor: FirVisitor, data: D): R = visitor.visitDeclarationStatus(this, data) + + override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirEnumEntry.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirEnumEntry.kt index ed597d10738..557a1ad8864 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirEnumEntry.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirEnumEntry.kt @@ -47,6 +47,8 @@ abstract class FirEnumEntry : FirVariable(), FirCallableMemberDecl override fun accept(visitor: FirVisitor, data: D): R = visitor.visitEnumEntry(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt index fb06b6cd522..8060e87e6e0 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorFunction.kt @@ -40,6 +40,8 @@ abstract class FirErrorFunction : FirPureAbstractElement(), FirFunction accept(visitor: FirVisitor, data: D): R = visitor.visitErrorFunction(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorProperty.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorProperty.kt index 081dcc7eaf9..1f3ce9c7c9a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorProperty.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirErrorProperty.kt @@ -45,6 +45,8 @@ abstract class FirErrorProperty : FirVariable(), FirDiagnostic override fun accept(visitor: FirVisitor, data: D): R = visitor.visitErrorProperty(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirField.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirField.kt index 37df599d1c4..6f2bb710277 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirField.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirField.kt @@ -47,6 +47,8 @@ abstract class FirField : FirVariable(), FirTypeParametersOwner, FirCa override fun accept(visitor: FirVisitor, data: D): R = visitor.visitField(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFile.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFile.kt index 94c362e8894..5c41d71ec13 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFile.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFile.kt @@ -31,6 +31,8 @@ abstract class FirFile : FirPureAbstractElement(), FirAnnotatedDeclaration { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitFile(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirFile diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt index 1cb4b406e74..95ac997e11a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirFunction.kt @@ -38,6 +38,8 @@ interface FirFunction> : FirCallableDeclaration, FirTarget override fun accept(visitor: FirVisitor, data: D): R = visitor.visitFunction(this, data) + override fun replaceSource(newSource: FirSourceElement?) + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirImport.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirImport.kt index 9a55018b1f0..e8e2e7435c2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirImport.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirImport.kt @@ -24,4 +24,6 @@ abstract class FirImport : FirPureAbstractElement(), FirElement { abstract val aliasName: Name? override fun accept(visitor: FirVisitor, data: D): R = visitor.visitImport(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirMemberDeclaration.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirMemberDeclaration.kt index 5d947eb29a9..e2881a477e8 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirMemberDeclaration.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirMemberDeclaration.kt @@ -27,6 +27,8 @@ interface FirMemberDeclaration : FirAnnotatedDeclaration, FirTypeParameterRefsOw override fun accept(visitor: FirVisitor, data: D): R = visitor.visitMemberDeclaration(this, data) + override fun replaceSource(newSource: FirSourceElement?) + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) override fun transformAnnotations(transformer: FirTransformer, data: D): FirMemberDeclaration diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirProperty.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirProperty.kt index fee9a8d9a39..b0e661c4602 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirProperty.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirProperty.kt @@ -52,6 +52,8 @@ abstract class FirProperty : FirVariable(), FirTypeParametersOwner, override fun accept(visitor: FirVisitor, data: D): R = visitor.visitProperty(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt index e9d9dede216..bb9695633d9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirPropertyAccessor.kt @@ -46,6 +46,8 @@ abstract class FirPropertyAccessor : FirPureAbstractElement(), FirFunction accept(visitor: FirVisitor, data: D): R = visitor.visitPropertyAccessor(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt index a8d5b906dae..fbc14ecc16c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirRegularClass.kt @@ -43,6 +43,8 @@ abstract class FirRegularClass : FirPureAbstractElement(), FirMemberDeclaration, override fun accept(visitor: FirVisitor, data: D): R = visitor.visitRegularClass(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirResolvedDeclarationStatus.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirResolvedDeclarationStatus.kt index 5098de97502..848a5564594 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirResolvedDeclarationStatus.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirResolvedDeclarationStatus.kt @@ -39,4 +39,6 @@ interface FirResolvedDeclarationStatus : FirDeclarationStatus { override val isFun: Boolean override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedDeclarationStatus(this, data) + + override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirResolvedImport.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirResolvedImport.kt index d8d5c9576a7..bf179ccfb75 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirResolvedImport.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirResolvedImport.kt @@ -28,4 +28,6 @@ abstract class FirResolvedImport : FirImport() { abstract val importedName: Name? override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedImport(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt index e27ce2b594c..24ea1e4afc4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirSimpleFunction.kt @@ -46,6 +46,8 @@ abstract class FirSimpleFunction : FirPureAbstractElement(), FirFunction accept(visitor: FirVisitor, data: D): R = visitor.visitSimpleFunction(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeAlias.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeAlias.kt index c26af0d1080..40949e03d1c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeAlias.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeAlias.kt @@ -34,6 +34,8 @@ abstract class FirTypeAlias : FirPureAbstractElement(), FirClassLikeDeclaration< override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypeAlias(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract fun replaceExpandedTypeRef(newExpandedTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameter.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameter.kt index cc5075c7449..8da4f052b17 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameter.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameter.kt @@ -36,6 +36,8 @@ abstract class FirTypeParameter : FirPureAbstractElement(), FirTypeParameterRef, override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypeParameter(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract fun replaceBounds(newBounds: List) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameterRef.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameterRef.kt index cd18d625d0d..c4b258a7436 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameterRef.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameterRef.kt @@ -20,4 +20,6 @@ interface FirTypeParameterRef : FirElement { val symbol: FirTypeParameterSymbol override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypeParameterRef(this, data) + + override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameterRefsOwner.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameterRefsOwner.kt index 9afb114295a..b65131c1e64 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameterRefsOwner.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParameterRefsOwner.kt @@ -20,5 +20,7 @@ interface FirTypeParameterRefsOwner : FirElement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypeParameterRefsOwner(this, data) + override fun replaceSource(newSource: FirSourceElement?) + fun transformTypeParameters(transformer: FirTransformer, data: D): FirTypeParameterRefsOwner } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParametersOwner.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParametersOwner.kt index 07cec0da9d2..3812e5dad0a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParametersOwner.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypeParametersOwner.kt @@ -19,5 +19,7 @@ interface FirTypeParametersOwner : FirTypeParameterRefsOwner { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypeParametersOwner(this, data) + override fun replaceSource(newSource: FirSourceElement?) + override fun transformTypeParameters(transformer: FirTransformer, data: D): FirTypeParametersOwner } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypedDeclaration.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypedDeclaration.kt index 72d486c9a5b..5f75588e8b3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypedDeclaration.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirTypedDeclaration.kt @@ -27,6 +27,8 @@ interface FirTypedDeclaration : FirAnnotatedDeclaration { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypedDeclaration(this, data) + override fun replaceSource(newSource: FirSourceElement?) + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt index 36d1b5a8055..27f71463b2f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirValueParameter.kt @@ -47,6 +47,8 @@ abstract class FirValueParameter : FirVariable(), FirControlF override fun accept(visitor: FirVisitor, data: D): R = visitor.visitValueParameter(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirVariable.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirVariable.kt index 485dcf8ca73..9de2bb0d6d6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirVariable.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/FirVariable.kt @@ -43,6 +43,8 @@ abstract class FirVariable> : FirPureAbstractElement(), FirCa override fun accept(visitor: FirVisitor, data: D): R = visitor.visitVariable(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) abstract override fun replaceReturnTypeRef(newReturnTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt index 892910a0edc..93bf9157954 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirAnonymousFunctionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override val origin: FirDeclarationOrigin, override val attributes: FirDeclarationAttributes, @@ -106,6 +106,10 @@ internal class FirAnonymousFunctionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousInitializerImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousInitializerImpl.kt index 22c7dd7221b..91d53d390c0 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousInitializerImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousInitializerImpl.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirAnonymousInitializerImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -47,6 +47,10 @@ internal class FirAnonymousInitializerImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousObjectImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousObjectImpl.kt index 4b454328ca4..2744d1282d4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousObjectImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousObjectImpl.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirAnonymousObjectImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -86,6 +86,10 @@ internal class FirAnonymousObjectImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructedClassTypeParameterRef.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructedClassTypeParameterRef.kt index fb1b8082bd7..c67c590a9b5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructedClassTypeParameterRef.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructedClassTypeParameterRef.kt @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirConstructedClassTypeParameterRef( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val symbol: FirTypeParameterSymbol, ) : FirPureAbstractElement(), FirTypeParameterRef { override fun acceptChildren(visitor: FirVisitor, data: D) {} @@ -25,4 +25,8 @@ internal class FirConstructedClassTypeParameterRef( override fun transformChildren(transformer: FirTransformer, data: D): FirConstructedClassTypeParameterRef { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt index 245006bf64b..7505dff43af 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirConstructorImpl.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirConstructorImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -119,6 +119,10 @@ internal class FirConstructorImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt index fc29e7767ac..dc56875ac97 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirDefaultSetterValueParameter.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirDefaultSetterValueParameter( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -121,6 +121,10 @@ internal class FirDefaultSetterValueParameter( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirEnumEntryImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirEnumEntryImpl.kt index befb864ad21..be8bebb8537 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirEnumEntryImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirEnumEntryImpl.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirEnumEntryImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -121,6 +121,10 @@ internal class FirEnumEntryImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt index 4c29b705a0a..51f14581892 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirErrorFunctionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -93,6 +93,10 @@ internal class FirErrorFunctionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt index 532a3a6a3ba..37a741ca0fb 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirErrorPropertyImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -108,6 +108,10 @@ internal class FirErrorPropertyImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFieldImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFieldImpl.kt index 532753588ff..84733a7ab98 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFieldImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFieldImpl.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirFieldImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -121,6 +121,10 @@ internal class FirFieldImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFileImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFileImpl.kt index 763006fa1b7..f11a458d907 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFileImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirFileImpl.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirFileImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -62,6 +62,10 @@ internal class FirFileImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt index 4949b61b8dc..fd71d6982e9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirImportImpl.kt @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirImportImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val importedFqName: FqName?, override val isAllUnder: Boolean, override val aliasName: Name?, @@ -27,4 +27,8 @@ internal class FirImportImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirImportImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirOuterClassTypeParameterRef.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirOuterClassTypeParameterRef.kt index 7829b8c4ea8..47b0d831d9a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirOuterClassTypeParameterRef.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirOuterClassTypeParameterRef.kt @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirOuterClassTypeParameterRef( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val symbol: FirTypeParameterSymbol, ) : FirPureAbstractElement(), FirTypeParameterRef { override fun acceptChildren(visitor: FirVisitor, data: D) {} @@ -25,4 +25,8 @@ internal class FirOuterClassTypeParameterRef( override fun transformChildren(transformer: FirTransformer, data: D): FirOuterClassTypeParameterRef { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt index bf47f268595..af9c8c9b335 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPrimaryConstructor.kt @@ -30,7 +30,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirPrimaryConstructor( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -119,6 +119,10 @@ internal class FirPrimaryConstructor( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt index 1f2a17c8cb8..cd500b5ffd4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyAccessorImpl.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ open class FirPropertyAccessorImpl @FirImplementationDetail constructor( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -119,6 +119,10 @@ open class FirPropertyAccessorImpl @FirImplementationDetail constructor( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyImpl.kt index 8be811bafb3..5680a67a5aa 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirPropertyImpl.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirPropertyImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -141,6 +141,10 @@ internal class FirPropertyImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirRegularClassImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirRegularClassImpl.kt index bff65e9a40e..6daaa00a9c3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirRegularClassImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirRegularClassImpl.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirRegularClassImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -102,6 +102,10 @@ internal class FirRegularClassImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirResolvedImportImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirResolvedImportImpl.kt index 2429bce03e2..22099ac8dbf 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirResolvedImportImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirResolvedImportImpl.kt @@ -36,4 +36,6 @@ internal class FirResolvedImportImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirResolvedImportImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) {} } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt index 80a2e7d4dc7..d66c1de34dc 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirSimpleFunctionImpl.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirSimpleFunctionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -120,6 +120,10 @@ internal class FirSimpleFunctionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt index c2450c724bf..797ff354627 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeAliasImpl.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirTypeAliasImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -71,6 +71,10 @@ internal class FirTypeAliasImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt index 7261aaca6d4..c27a1b6bcba 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirTypeParameterImpl.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirTypeParameterImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -56,6 +56,10 @@ internal class FirTypeParameterImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt index 1fe2d7f60c3..39870608815 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirValueParameterImpl.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirValueParameterImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val session: FirSession, override var resolvePhase: FirResolvePhase, override val origin: FirDeclarationOrigin, @@ -106,6 +106,10 @@ internal class FirValueParameterImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) { resolvePhase = newResolvePhase } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/diagnostics/FirDiagnosticHolder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/diagnostics/FirDiagnosticHolder.kt index 75c442dc311..d581580119d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/diagnostics/FirDiagnosticHolder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/diagnostics/FirDiagnosticHolder.kt @@ -19,4 +19,6 @@ interface FirDiagnosticHolder : FirElement { val diagnostic: ConeDiagnostic override fun accept(visitor: FirVisitor, data: D): R = visitor.visitDiagnosticHolder(this, data) + + override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotationCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotationCall.kt index 36b490eae7f..7a9bc59a525 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotationCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotationCall.kt @@ -28,6 +28,8 @@ abstract class FirAnnotationCall : FirExpression(), FirCall, FirResolvable { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitAnnotationCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceArgumentList(newArgumentList: FirArgumentList) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArgumentList.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArgumentList.kt index 69b40d82675..f360f75d348 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArgumentList.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArgumentList.kt @@ -21,5 +21,7 @@ abstract class FirArgumentList : FirPureAbstractElement(), FirElement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitArgumentList(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract fun transformArguments(transformer: FirTransformer, data: D): FirArgumentList } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArrayOfCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArrayOfCall.kt index b6e5f9851f4..ff2c4c7ce15 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArrayOfCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirArrayOfCall.kt @@ -22,6 +22,8 @@ abstract class FirArrayOfCall : FirExpression(), FirCall { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitArrayOfCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceArgumentList(newArgumentList: FirArgumentList) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAssignmentOperatorStatement.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAssignmentOperatorStatement.kt index 4493f05a6cd..489174a446c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAssignmentOperatorStatement.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAssignmentOperatorStatement.kt @@ -23,6 +23,8 @@ abstract class FirAssignmentOperatorStatement : FirPureAbstractElement(), FirSta override fun accept(visitor: FirVisitor, data: D): R = visitor.visitAssignmentOperatorStatement(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirAssignmentOperatorStatement abstract fun transformLeftArgument(transformer: FirTransformer, data: D): FirAssignmentOperatorStatement diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAugmentedArraySetCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAugmentedArraySetCall.kt index 0d615b2b9fc..342db1dd47d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAugmentedArraySetCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAugmentedArraySetCall.kt @@ -25,6 +25,8 @@ abstract class FirAugmentedArraySetCall : FirPureAbstractElement(), FirStatement override fun accept(visitor: FirVisitor, data: D): R = visitor.visitAugmentedArraySetCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract fun replaceCalleeReference(newCalleeReference: FirReference) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirAugmentedArraySetCall diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBinaryLogicExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBinaryLogicExpression.kt index db4f8c71231..05a8d38dbac 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBinaryLogicExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBinaryLogicExpression.kt @@ -24,6 +24,8 @@ abstract class FirBinaryLogicExpression : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitBinaryLogicExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirBinaryLogicExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBlock.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBlock.kt index 2db890bf3f2..6e54c85ec66 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBlock.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBlock.kt @@ -22,6 +22,8 @@ abstract class FirBlock : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitBlock(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirBlock diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBreakExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBreakExpression.kt index 61530fc1cae..188524667c9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBreakExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirBreakExpression.kt @@ -23,6 +23,8 @@ abstract class FirBreakExpression : FirLoopJump() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitBreakExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirBreakExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCall.kt index f3082ecf919..3df726aaa76 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCall.kt @@ -20,6 +20,8 @@ interface FirCall : FirStatement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitCall(this, data) + override fun replaceSource(newSource: FirSourceElement?) + fun replaceArgumentList(newArgumentList: FirArgumentList) override fun transformAnnotations(transformer: FirTransformer, data: D): FirCall diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCallableReferenceAccess.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCallableReferenceAccess.kt index 52868361b9d..defae749895 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCallableReferenceAccess.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCallableReferenceAccess.kt @@ -30,6 +30,8 @@ abstract class FirCallableReferenceAccess : FirQualifiedAccessExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitCallableReferenceAccess(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceTypeArguments(newTypeArguments: List) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCatch.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCatch.kt index db84b03e64f..35530b58d15 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCatch.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCatch.kt @@ -23,6 +23,8 @@ abstract class FirCatch : FirPureAbstractElement(), FirElement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitCatch(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract fun transformParameter(transformer: FirTransformer, data: D): FirCatch abstract fun transformBlock(transformer: FirTransformer, data: D): FirCatch diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCheckNotNullCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCheckNotNullCall.kt index a45eb11b5b1..7e02ffab260 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCheckNotNullCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCheckNotNullCall.kt @@ -24,6 +24,8 @@ abstract class FirCheckNotNullCall : FirExpression(), FirCall, FirResolvable { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitCheckNotNullCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceArgumentList(newArgumentList: FirArgumentList) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCheckedSafeCallSubject.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCheckedSafeCallSubject.kt index 01194ec40e9..b8d16078c51 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCheckedSafeCallSubject.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirCheckedSafeCallSubject.kt @@ -23,6 +23,8 @@ abstract class FirCheckedSafeCallSubject : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitCheckedSafeCallSubject(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirCheckedSafeCallSubject diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirClassReferenceExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirClassReferenceExpression.kt index fdd71d32bf2..047587d6230 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirClassReferenceExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirClassReferenceExpression.kt @@ -22,6 +22,8 @@ abstract class FirClassReferenceExpression : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitClassReferenceExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirClassReferenceExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirComparisonExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirComparisonExpression.kt index 8afe9bc9606..f79e701536a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirComparisonExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirComparisonExpression.kt @@ -23,6 +23,8 @@ abstract class FirComparisonExpression : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitComparisonExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirComparisonExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirComponentCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirComponentCall.kt index ee71186fb9c..11a60d02cad 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirComponentCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirComponentCall.kt @@ -31,6 +31,8 @@ abstract class FirComponentCall : FirFunctionCall() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitComponentCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceTypeArguments(newTypeArguments: List) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirConstExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirConstExpression.kt index 4a610d163e9..bede511d0ac 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirConstExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirConstExpression.kt @@ -24,6 +24,8 @@ abstract class FirConstExpression : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitConstExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract fun replaceKind(newKind: ConstantValueKind) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirContinueExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirContinueExpression.kt index b7edca08998..32794889477 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirContinueExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirContinueExpression.kt @@ -23,6 +23,8 @@ abstract class FirContinueExpression : FirLoopJump() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitContinueExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirContinueExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirDelegatedConstructorCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirDelegatedConstructorCall.kt index a29ef2df1ee..61745a3d2a4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirDelegatedConstructorCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirDelegatedConstructorCall.kt @@ -28,6 +28,8 @@ abstract class FirDelegatedConstructorCall : FirPureAbstractElement(), FirResolv override fun accept(visitor: FirVisitor, data: D): R = visitor.visitDelegatedConstructorCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceArgumentList(newArgumentList: FirArgumentList) abstract fun replaceConstructedTypeRef(newConstructedTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirDoWhileLoop.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirDoWhileLoop.kt index 98f969b5fa1..8f007ec5fe4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirDoWhileLoop.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirDoWhileLoop.kt @@ -23,6 +23,8 @@ abstract class FirDoWhileLoop : FirLoop() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitDoWhileLoop(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirDoWhileLoop abstract override fun transformBlock(transformer: FirTransformer, data: D): FirDoWhileLoop diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirElvisExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirElvisExpression.kt index b99de9e13ad..6915561568a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirElvisExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirElvisExpression.kt @@ -25,6 +25,8 @@ abstract class FirElvisExpression : FirExpression(), FirResolvable { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitElvisExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceCalleeReference(newCalleeReference: FirReference) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirEqualityOperatorCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirEqualityOperatorCall.kt index 3f62111b3b6..024ce738c18 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirEqualityOperatorCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirEqualityOperatorCall.kt @@ -23,6 +23,8 @@ abstract class FirEqualityOperatorCall : FirExpression(), FirCall { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitEqualityOperatorCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceArgumentList(newArgumentList: FirArgumentList) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorExpression.kt index 61526bd57cc..4a36f5cde1c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorExpression.kt @@ -24,6 +24,8 @@ abstract class FirErrorExpression : FirExpression(), FirDiagnosticHolder { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitErrorExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirErrorExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorLoop.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorLoop.kt index 1f23373e3b3..e89b913e87e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorLoop.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorLoop.kt @@ -26,6 +26,8 @@ abstract class FirErrorLoop : FirLoop(), FirDiagnosticHolder { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitErrorLoop(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirErrorLoop abstract override fun transformBlock(transformer: FirTransformer, data: D): FirErrorLoop diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorResolvedQualifier.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorResolvedQualifier.kt index 3bd8faf6c9f..664f0cfb7dc 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorResolvedQualifier.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirErrorResolvedQualifier.kt @@ -34,6 +34,8 @@ abstract class FirErrorResolvedQualifier : FirResolvedQualifier(), FirDiagnostic override fun accept(visitor: FirVisitor, data: D): R = visitor.visitErrorResolvedQualifier(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceIsNullableLHSForCallableReference(newIsNullableLHSForCallableReference: Boolean) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirExpression.kt index 8e64b15ca15..249b55ad391 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirExpression.kt @@ -22,6 +22,8 @@ abstract class FirExpression : FirPureAbstractElement(), FirStatement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirExpressionWithSmartcast.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirExpressionWithSmartcast.kt index be45e8aee4a..eb32d3d79c3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirExpressionWithSmartcast.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirExpressionWithSmartcast.kt @@ -32,6 +32,8 @@ abstract class FirExpressionWithSmartcast : FirQualifiedAccessExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitExpressionWithSmartcast(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceCalleeReference(newCalleeReference: FirReference) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirFunctionCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirFunctionCall.kt index f463c4c2948..c1bd6c31f6f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirFunctionCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirFunctionCall.kt @@ -30,6 +30,8 @@ abstract class FirFunctionCall : FirQualifiedAccessExpression(), FirCall { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitFunctionCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceTypeArguments(newTypeArguments: List) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirGetClassCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirGetClassCall.kt index 1d33c1e2d2a..5a6517d5ce3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirGetClassCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirGetClassCall.kt @@ -23,6 +23,8 @@ abstract class FirGetClassCall : FirExpression(), FirCall { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitGetClassCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceArgumentList(newArgumentList: FirArgumentList) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirImplicitInvokeCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirImplicitInvokeCall.kt index 59431271d13..ec3e2a31c61 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirImplicitInvokeCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirImplicitInvokeCall.kt @@ -30,6 +30,8 @@ abstract class FirImplicitInvokeCall : FirFunctionCall() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitImplicitInvokeCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceTypeArguments(newTypeArguments: List) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirJump.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirJump.kt index 5434dfbde3d..b0d5583f029 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirJump.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirJump.kt @@ -24,6 +24,8 @@ abstract class FirJump : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitJump(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirJump diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLambdaArgumentExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLambdaArgumentExpression.kt index 8d47a28e930..0b299b8cc2f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLambdaArgumentExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLambdaArgumentExpression.kt @@ -23,6 +23,8 @@ abstract class FirLambdaArgumentExpression : FirWrappedArgumentExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitLambdaArgumentExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceExpression(newExpression: FirExpression) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLoop.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLoop.kt index 4d3895d5833..b5529c1d0f8 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLoop.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLoop.kt @@ -25,6 +25,8 @@ abstract class FirLoop : FirPureAbstractElement(), FirStatement, FirTargetElemen override fun accept(visitor: FirVisitor, data: D): R = visitor.visitLoop(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirLoop abstract fun transformBlock(transformer: FirTransformer, data: D): FirLoop diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLoopJump.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLoopJump.kt index 7f62f66d8bb..5dc5456b28d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLoopJump.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirLoopJump.kt @@ -23,6 +23,8 @@ abstract class FirLoopJump : FirJump() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitLoopJump(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirLoopJump diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirNamedArgumentExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirNamedArgumentExpression.kt index 61376411bdc..9057621c759 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirNamedArgumentExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirNamedArgumentExpression.kt @@ -25,6 +25,8 @@ abstract class FirNamedArgumentExpression : FirWrappedArgumentExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitNamedArgumentExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceExpression(newExpression: FirExpression) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirQualifiedAccess.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirQualifiedAccess.kt index 117a1e5f775..32fda493fde 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirQualifiedAccess.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirQualifiedAccess.kt @@ -26,6 +26,8 @@ interface FirQualifiedAccess : FirResolvable, FirStatement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitQualifiedAccess(this, data) + override fun replaceSource(newSource: FirSourceElement?) + override fun replaceCalleeReference(newCalleeReference: FirReference) fun replaceTypeArguments(newTypeArguments: List) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirQualifiedAccessExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirQualifiedAccessExpression.kt index d25a4eb6048..a8193163e92 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirQualifiedAccessExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirQualifiedAccessExpression.kt @@ -28,6 +28,8 @@ abstract class FirQualifiedAccessExpression : FirExpression(), FirQualifiedAcces override fun accept(visitor: FirVisitor, data: D): R = visitor.visitQualifiedAccessExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceCalleeReference(newCalleeReference: FirReference) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvable.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvable.kt index 87a22312269..137173f6bfc 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvable.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvable.kt @@ -21,6 +21,8 @@ interface FirResolvable : FirElement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvable(this, data) + override fun replaceSource(newSource: FirSourceElement?) + fun replaceCalleeReference(newCalleeReference: FirReference) fun transformCalleeReference(transformer: FirTransformer, data: D): FirResolvable diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedQualifier.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedQualifier.kt index 3bf76b2c2d6..7fd583c5a36 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedQualifier.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedQualifier.kt @@ -31,6 +31,8 @@ abstract class FirResolvedQualifier : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedQualifier(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract fun replaceIsNullableLHSForCallableReference(newIsNullableLHSForCallableReference: Boolean) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedReifiedParameterReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedReifiedParameterReference.kt index 2c1ca2c7ac3..3f5cff88833 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedReifiedParameterReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirResolvedReifiedParameterReference.kt @@ -23,6 +23,8 @@ abstract class FirResolvedReifiedParameterReference : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedReifiedParameterReference(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirResolvedReifiedParameterReference diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirReturnExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirReturnExpression.kt index f9ffbe4faed..498f9e26746 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirReturnExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirReturnExpression.kt @@ -25,6 +25,8 @@ abstract class FirReturnExpression : FirJump>() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitReturnExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirReturnExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSafeCallExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSafeCallExpression.kt index e1ba8ba64cf..314dac6a48e 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSafeCallExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSafeCallExpression.kt @@ -25,6 +25,8 @@ abstract class FirSafeCallExpression : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitSafeCallExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract fun replaceRegularQualifiedAccess(newRegularQualifiedAccess: FirQualifiedAccess) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSpreadArgumentExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSpreadArgumentExpression.kt index b514df4b57b..35965cf1da5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSpreadArgumentExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirSpreadArgumentExpression.kt @@ -23,6 +23,8 @@ abstract class FirSpreadArgumentExpression : FirWrappedArgumentExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitSpreadArgumentExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceExpression(newExpression: FirExpression) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirStatement.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirStatement.kt index dfbaef2e90d..395f19375b1 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirStatement.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirStatement.kt @@ -20,5 +20,7 @@ interface FirStatement : FirAnnotationContainer { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitStatement(this, data) + override fun replaceSource(newSource: FirSourceElement?) + override fun transformAnnotations(transformer: FirTransformer, data: D): FirStatement } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirStringConcatenationCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirStringConcatenationCall.kt index 173b4065fab..e2a0c82d62a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirStringConcatenationCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirStringConcatenationCall.kt @@ -22,6 +22,8 @@ abstract class FirStringConcatenationCall : FirCall, FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitStringConcatenationCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceArgumentList(newArgumentList: FirArgumentList) abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirThisReceiverExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirThisReceiverExpression.kt index b046b14bae4..5fbd1a12bb6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirThisReceiverExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirThisReceiverExpression.kt @@ -29,6 +29,8 @@ abstract class FirThisReceiverExpression : FirQualifiedAccessExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitThisReceiverExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceTypeArguments(newTypeArguments: List) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirThrowExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirThrowExpression.kt index a5420283ee9..7a8cfe98a3a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirThrowExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirThrowExpression.kt @@ -22,6 +22,8 @@ abstract class FirThrowExpression : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitThrowExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirThrowExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirTryExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirTryExpression.kt index 64bfe7ce52b..859ecaee995 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirTryExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirTryExpression.kt @@ -26,6 +26,8 @@ abstract class FirTryExpression : FirExpression(), FirResolvable { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTryExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceCalleeReference(newCalleeReference: FirReference) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirTypeOperatorCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirTypeOperatorCall.kt index 05163482283..4db5d250ce2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirTypeOperatorCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirTypeOperatorCall.kt @@ -24,6 +24,8 @@ abstract class FirTypeOperatorCall : FirExpression(), FirCall { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypeOperatorCall(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceArgumentList(newArgumentList: FirArgumentList) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirVarargArgumentsExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirVarargArgumentsExpression.kt index ae43a6a94be..09d2e65c225 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirVarargArgumentsExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirVarargArgumentsExpression.kt @@ -23,6 +23,8 @@ abstract class FirVarargArgumentsExpression : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitVarargArgumentsExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirVarargArgumentsExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirVariableAssignment.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirVariableAssignment.kt index 64b60dfcc87..2ce8bc9c7dd 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirVariableAssignment.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirVariableAssignment.kt @@ -29,6 +29,8 @@ abstract class FirVariableAssignment : FirPureAbstractElement(), FirQualifiedAcc override fun accept(visitor: FirVisitor, data: D): R = visitor.visitVariableAssignment(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceCalleeReference(newCalleeReference: FirReference) abstract override fun replaceTypeArguments(newTypeArguments: List) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenBranch.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenBranch.kt index 1f86663595b..335c18526b6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenBranch.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenBranch.kt @@ -22,6 +22,8 @@ abstract class FirWhenBranch : FirPureAbstractElement(), FirElement { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitWhenBranch(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract fun transformCondition(transformer: FirTransformer, data: D): FirWhenBranch abstract fun transformResult(transformer: FirTransformer, data: D): FirWhenBranch diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenExpression.kt index 54dcb8c6247..7565ae86ab9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenExpression.kt @@ -29,6 +29,8 @@ abstract class FirWhenExpression : FirExpression(), FirResolvable { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitWhenExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceCalleeReference(newCalleeReference: FirReference) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenSubjectExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenSubjectExpression.kt index 8536208a905..a586f2697e2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenSubjectExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhenSubjectExpression.kt @@ -23,6 +23,8 @@ abstract class FirWhenSubjectExpression : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitWhenSubjectExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirWhenSubjectExpression diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhileLoop.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhileLoop.kt index b23b0f2e6e1..ed573d573f9 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhileLoop.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWhileLoop.kt @@ -23,6 +23,8 @@ abstract class FirWhileLoop : FirLoop() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitWhileLoop(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirWhileLoop abstract override fun transformCondition(transformer: FirTransformer, data: D): FirWhileLoop diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedArgumentExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedArgumentExpression.kt index 2f16d913a84..1cac67d9182 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedArgumentExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedArgumentExpression.kt @@ -23,6 +23,8 @@ abstract class FirWrappedArgumentExpression : FirWrappedExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitWrappedArgumentExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceExpression(newExpression: FirExpression) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedDelegateExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedDelegateExpression.kt index bcf62bb0bc2..4918bdedfd1 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedDelegateExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedDelegateExpression.kt @@ -23,6 +23,8 @@ abstract class FirWrappedDelegateExpression : FirWrappedExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitWrappedDelegateExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract override fun replaceExpression(newExpression: FirExpression) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedExpression.kt index b0e6780643a..1b96c4271f6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirWrappedExpression.kt @@ -22,6 +22,8 @@ abstract class FirWrappedExpression : FirExpression() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitWrappedExpression(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) abstract fun replaceExpression(newExpression: FirExpression) diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt index 710e1c997ef..0f58b314bda 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirAnnotationCallImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var argumentList: FirArgumentList, override var calleeReference: FirReference, @@ -60,6 +60,10 @@ internal class FirAnnotationCallImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) {} override fun replaceArgumentList(newArgumentList: FirArgumentList) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArgumentListImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArgumentListImpl.kt index 3e57f13a075..c5bf78c009c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArgumentListImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArgumentListImpl.kt @@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirArgumentListImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val arguments: MutableList, ) : FirArgumentList() { override fun acceptChildren(visitor: FirVisitor, data: D) { @@ -32,4 +32,8 @@ internal class FirArgumentListImpl( arguments.transformInplace(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayOfCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayOfCallImpl.kt index c936c0109fc..0a094c6f66b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayOfCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirArrayOfCallImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirArrayOfCallImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override var argumentList: FirArgumentList, @@ -41,6 +41,10 @@ internal class FirArrayOfCallImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAssignmentOperatorStatementImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAssignmentOperatorStatementImpl.kt index 37ae9fdc110..c672cc7ee4f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAssignmentOperatorStatementImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAssignmentOperatorStatementImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirAssignmentOperatorStatementImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val operation: FirOperation, override var leftArgument: FirExpression, @@ -51,4 +51,8 @@ internal class FirAssignmentOperatorStatementImpl( rightArgument = rightArgument.transformSingle(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAugmentedArraySetCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAugmentedArraySetCallImpl.kt index c65d94f53d8..642761deacd 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAugmentedArraySetCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAugmentedArraySetCallImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirAugmentedArraySetCallImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var assignCall: FirFunctionCall, override var setGetBlock: FirBlock, @@ -47,6 +47,10 @@ internal class FirAugmentedArraySetCallImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceCalleeReference(newCalleeReference: FirReference) { calleeReference = newCalleeReference } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt index 94c5a8aaf4a..c6b40848f7b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBinaryLogicExpressionImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirBinaryLogicExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var leftOperand: FirExpression, override var rightOperand: FirExpression, @@ -63,6 +63,10 @@ internal class FirBinaryLogicExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt index 12e7635a005..df82a7b7bd7 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBlockImpl.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirBlockImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val statements: MutableList, ) : FirBlock() { @@ -53,6 +53,10 @@ internal class FirBlockImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBreakExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBreakExpressionImpl.kt index a1b8ac153ec..3d8304d0ee4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBreakExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirBreakExpressionImpl.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirBreakExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val target: FirTarget, ) : FirBreakExpression() { @@ -44,6 +44,10 @@ internal class FirBreakExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt index ea52d7f98d4..af2781d3e98 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCallableReferenceAccessImpl.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirCallableReferenceAccessImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override val typeArguments: MutableList, @@ -90,6 +90,10 @@ internal class FirCallableReferenceAccessImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt index d4d430a608d..d66f470853d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCatchImpl.kt @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirCatchImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var parameter: FirValueParameter, override var block: FirBlock, ) : FirCatch() { @@ -46,4 +46,8 @@ internal class FirCatchImpl( override fun transformOtherChildren(transformer: FirTransformer, data: D): FirCatchImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt index 8c4e7afcf74..a68b86d0c00 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckNotNullCallImpl.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirCheckNotNullCallImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override var argumentList: FirArgumentList, @@ -50,6 +50,10 @@ internal class FirCheckNotNullCallImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckedSafeCallSubjectImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckedSafeCallSubjectImpl.kt index 09e5f4db4da..dc469c5a5f7 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckedSafeCallSubjectImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirCheckedSafeCallSubjectImpl.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirCheckedSafeCallSubjectImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override val originalReceiverRef: FirExpressionRef, @@ -40,6 +40,10 @@ internal class FirCheckedSafeCallSubjectImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt index fd122e432a9..37beb7b48bc 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirClassReferenceExpressionImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirClassReferenceExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var classTypeRef: FirTypeRef, ) : FirClassReferenceExpression() { @@ -42,6 +42,10 @@ internal class FirClassReferenceExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComparisonExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComparisonExpressionImpl.kt index 7f92ad148fe..3428fe2b341 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComparisonExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComparisonExpressionImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirComparisonExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val operation: FirOperation, override var compareToCall: FirFunctionCall, @@ -45,6 +45,10 @@ internal class FirComparisonExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComponentCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComponentCallImpl.kt index 2f848510acb..2ae2ddca0af 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComponentCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirComponentCallImpl.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.fir.visitors.* @OptIn(FirImplementationDetail::class) internal class FirComponentCallImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val typeArguments: MutableList, override var dispatchReceiver: FirExpression, @@ -100,6 +100,10 @@ internal class FirComponentCallImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt index 2a9ca0b762b..bca7d6a4b19 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirConstExpressionImpl.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirConstExpressionImpl ( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var kind: ConstantValueKind, override val value: T, @@ -42,6 +42,10 @@ internal class FirConstExpressionImpl ( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirContinueExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirContinueExpressionImpl.kt index 3ab1ae16741..8a4e2c80000 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirContinueExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirContinueExpressionImpl.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirContinueExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val target: FirTarget, ) : FirContinueExpression() { @@ -44,6 +44,10 @@ internal class FirContinueExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt index ddd3071ecbd..0c32a301088 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDelegatedConstructorCallImpl.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirDelegatedConstructorCallImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var argumentList: FirArgumentList, override var constructedTypeRef: FirTypeRef, @@ -62,6 +62,10 @@ internal class FirDelegatedConstructorCallImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceArgumentList(newArgumentList: FirArgumentList) { argumentList = newArgumentList } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt index 550ff524b72..36efcd1d60f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirDoWhileLoopImpl.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirDoWhileLoopImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var block: FirBlock, override var condition: FirExpression, @@ -59,4 +59,8 @@ internal class FirDoWhileLoopImpl( label = label?.transformSingle(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElseIfTrueCondition.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElseIfTrueCondition.kt index 140c2a73b51..84222d904dd 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElseIfTrueCondition.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElseIfTrueCondition.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ class FirElseIfTrueCondition @FirImplementationDetail constructor( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, ) : FirExpression() { override var typeRef: FirTypeRef = FirImplicitBooleanTypeRef(source?.fakeElement(FirFakeSourceElementKind.ImplicitTypeRef)) @@ -42,6 +42,10 @@ class FirElseIfTrueCondition @FirImplementationDetail constructor( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElvisExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElvisExpressionImpl.kt index 80d9b2fc88f..21003d0f01a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElvisExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirElvisExpressionImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirElvisExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var calleeReference: FirReference, override var lhs: FirExpression, @@ -65,6 +65,10 @@ internal class FirElvisExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEmptyExpressionBlock.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEmptyExpressionBlock.kt index aca86b0e932..e2f4c295edf 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEmptyExpressionBlock.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEmptyExpressionBlock.kt @@ -47,6 +47,8 @@ class FirEmptyExpressionBlock : FirBlock() { return this } + override fun replaceSource(newSource: FirSourceElement?) {} + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEqualityOperatorCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEqualityOperatorCallImpl.kt index dc72c9d0313..5a4fcd417f7 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEqualityOperatorCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirEqualityOperatorCallImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirEqualityOperatorCallImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var argumentList: FirArgumentList, override val operation: FirOperation, @@ -45,6 +45,10 @@ internal class FirEqualityOperatorCallImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt index afe92ff17cf..e3af3c11049 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirErrorExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val diagnostic: ConeDiagnostic, ) : FirErrorExpression() { override var typeRef: FirTypeRef = FirErrorTypeRefImpl(source, null, ConeStubDiagnostic(diagnostic)) @@ -39,6 +39,10 @@ internal class FirErrorExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorLoopImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorLoopImpl.kt index 7467fe3e964..7959ea39190 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorLoopImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorLoopImpl.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirErrorLoopImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var label: FirLabel?, override val diagnostic: ConeDiagnostic, @@ -64,4 +64,8 @@ internal class FirErrorLoopImpl( label = label?.transformSingle(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorResolvedQualifierImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorResolvedQualifierImpl.kt index 37ff9f99fe8..31482e84955 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorResolvedQualifierImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorResolvedQualifierImpl.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirErrorResolvedQualifierImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val packageFqName: FqName, override val relativeClassFqName: FqName?, @@ -58,6 +58,10 @@ internal class FirErrorResolvedQualifierImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt index 4250d4ee468..9537bf1bf1f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionStub.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ class FirExpressionStub @FirImplementationDetail constructor( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, ) : FirExpression() { @@ -38,6 +38,10 @@ class FirExpressionStub @FirImplementationDetail constructor( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt index 865138167f6..de641ca9ab4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirFunctionCallImpl.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ open class FirFunctionCallImpl @FirImplementationDetail constructor( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override val typeArguments: MutableList, @@ -94,6 +94,10 @@ open class FirFunctionCallImpl @FirImplementationDetail constructor( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirGetClassCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirGetClassCallImpl.kt index d88da99e569..6cf966635c7 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirGetClassCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirGetClassCallImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirGetClassCallImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var argumentList: FirArgumentList, ) : FirGetClassCall() { @@ -45,6 +45,10 @@ internal class FirGetClassCallImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirImplicitInvokeCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirImplicitInvokeCallImpl.kt index 7ba8fec42da..7e0bb595614 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirImplicitInvokeCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirImplicitInvokeCallImpl.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirImplicitInvokeCallImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val typeArguments: MutableList, override var explicitReceiver: FirExpression?, @@ -95,6 +95,10 @@ internal class FirImplicitInvokeCallImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLambdaArgumentExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLambdaArgumentExpressionImpl.kt index add879e04db..326800e05a1 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLambdaArgumentExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLambdaArgumentExpressionImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirLambdaArgumentExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var expression: FirExpression, ) : FirLambdaArgumentExpression() { @@ -41,6 +41,10 @@ internal class FirLambdaArgumentExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) {} override fun replaceExpression(newExpression: FirExpression) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLazyBlock.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLazyBlock.kt index 6bf22535338..6629f9debdf 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLazyBlock.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLazyBlock.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ class FirLazyBlock @FirImplementationDetail constructor( - override val source: FirSourceElement?, + override var source: FirSourceElement?, ) : FirBlock() { override val annotations: List get() = error("FirLazyBlock should be calculated before accessing") override val statements: List get() = error("FirLazyBlock should be calculated before accessing") @@ -45,5 +45,9 @@ class FirLazyBlock @FirImplementationDetail constructor( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) {} } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLazyExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLazyExpression.kt index deb177a5057..aab48bc52f5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLazyExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLazyExpression.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ class FirLazyExpression @FirImplementationDetail constructor( - override val source: FirSourceElement?, + override var source: FirSourceElement?, ) : FirExpression() { override val typeRef: FirTypeRef get() = error("FirLazyExpression should be calculated before accessing") override val annotations: List get() = error("FirLazyExpression should be calculated before accessing") @@ -34,5 +34,9 @@ class FirLazyExpression @FirImplementationDetail constructor( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) {} } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirNamedArgumentExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirNamedArgumentExpressionImpl.kt index 74e4e225fa6..7822fb79384 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirNamedArgumentExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirNamedArgumentExpressionImpl.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirNamedArgumentExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var expression: FirExpression, override val isSpread: Boolean, @@ -43,6 +43,10 @@ internal class FirNamedArgumentExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) {} override fun replaceExpression(newExpression: FirExpression) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirQualifiedAccessExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirQualifiedAccessExpressionImpl.kt index c7529a84d74..03cf36cde93 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirQualifiedAccessExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirQualifiedAccessExpressionImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirQualifiedAccessExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override var calleeReference: FirReference, @@ -88,6 +88,10 @@ internal class FirQualifiedAccessExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt index 3ecfd5fddb2..e953d330701 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirResolvedQualifierImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override var packageFqName: FqName, @@ -57,6 +57,10 @@ internal class FirResolvedQualifierImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt index f6442b34a29..35aba9c7d38 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedReifiedParameterReferenceImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirResolvedReifiedParameterReferenceImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override val symbol: FirTypeParameterSymbol, @@ -39,6 +39,10 @@ internal class FirResolvedReifiedParameterReferenceImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirReturnExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirReturnExpressionImpl.kt index f9983b1fe30..039fb2db067 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirReturnExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirReturnExpressionImpl.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirReturnExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val target: FirTarget>, override var result: FirExpression, @@ -58,6 +58,10 @@ internal class FirReturnExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSafeCallExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSafeCallExpressionImpl.kt index 6c611be5e1d..5f9c7cca8ed 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSafeCallExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSafeCallExpressionImpl.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirSafeCallExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override var receiver: FirExpression, @@ -58,6 +58,10 @@ internal class FirSafeCallExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSpreadArgumentExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSpreadArgumentExpressionImpl.kt index 904b27436f9..6e18505cc42 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSpreadArgumentExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirSpreadArgumentExpressionImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirSpreadArgumentExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var expression: FirExpression, ) : FirSpreadArgumentExpression() { @@ -41,6 +41,10 @@ internal class FirSpreadArgumentExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) {} override fun replaceExpression(newExpression: FirExpression) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirStringConcatenationCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirStringConcatenationCallImpl.kt index 0e33cce4048..3af9c00fc3c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirStringConcatenationCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirStringConcatenationCallImpl.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirStringConcatenationCallImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var argumentList: FirArgumentList, ) : FirStringConcatenationCall() { @@ -45,6 +45,10 @@ internal class FirStringConcatenationCallImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceArgumentList(newArgumentList: FirArgumentList) { argumentList = newArgumentList } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThisReceiverExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThisReceiverExpressionImpl.kt index f162d8be3a9..0db9b2fe609 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThisReceiverExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThisReceiverExpressionImpl.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirThisReceiverExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override val typeArguments: MutableList, @@ -91,6 +91,10 @@ internal class FirThisReceiverExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThrowExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThrowExpressionImpl.kt index 360b98eb24d..72536b3e14f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThrowExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirThrowExpressionImpl.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirThrowExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var exception: FirExpression, ) : FirThrowExpression() { @@ -45,6 +45,10 @@ internal class FirThrowExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt index 67c48c01ef7..6db8340c4db 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTryExpressionImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirTryExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override var calleeReference: FirReference, @@ -77,6 +77,10 @@ internal class FirTryExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTypeOperatorCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTypeOperatorCallImpl.kt index 12021f59d81..556ff18d71c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTypeOperatorCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirTypeOperatorCallImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirTypeOperatorCallImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var argumentList: FirArgumentList, override val operation: FirOperation, @@ -58,6 +58,10 @@ internal class FirTypeOperatorCallImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirUnitExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirUnitExpression.kt index 8d3c91fc1a9..6d76cce4894 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirUnitExpression.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirUnitExpression.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ class FirUnitExpression @FirImplementationDetail constructor( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, ) : FirExpression() { override var typeRef: FirTypeRef = FirImplicitUnitTypeRef(source?.fakeElement(FirFakeSourceElementKind.ImplicitTypeRef)) @@ -42,6 +42,10 @@ class FirUnitExpression @FirImplementationDetail constructor( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt index fb49f2846c5..d7327e51310 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVarargArgumentsExpressionImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirVarargArgumentsExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override val arguments: MutableList, @@ -44,6 +44,10 @@ internal class FirVarargArgumentsExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt index d991bb23ab7..6dba8522ff3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirVariableAssignmentImpl.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirVariableAssignmentImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var calleeReference: FirReference, override val annotations: MutableList, override val typeArguments: MutableList, @@ -98,6 +98,10 @@ internal class FirVariableAssignmentImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceCalleeReference(newCalleeReference: FirReference) { calleeReference = newCalleeReference } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt index fba5bdbf534..30df5888d9c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenBranchImpl.kt @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirWhenBranchImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var condition: FirExpression, override var result: FirBlock, ) : FirWhenBranch() { @@ -46,4 +46,8 @@ internal class FirWhenBranchImpl( override fun transformOtherChildren(transformer: FirTransformer, data: D): FirWhenBranchImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt index adbc9991a88..e2e35df05fc 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenExpressionImpl.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirWhenExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val annotations: MutableList, override var calleeReference: FirReference, @@ -84,6 +84,10 @@ internal class FirWhenExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) { typeRef = newTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenSubjectExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenSubjectExpressionImpl.kt index ba475d3daf4..7377ca8c86b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenSubjectExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhenSubjectExpressionImpl.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirWhenSubjectExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val whenRef: FirExpressionRef, ) : FirWhenSubjectExpression() { @@ -39,5 +39,9 @@ internal class FirWhenSubjectExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) {} } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt index f9ef646d39b..6674e211839 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWhileLoopImpl.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirWhileLoopImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var label: FirLabel?, override var condition: FirExpression, @@ -59,4 +59,8 @@ internal class FirWhileLoopImpl( label = label?.transformSingle(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWrappedDelegateExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWrappedDelegateExpressionImpl.kt index e4e659d7767..f8729b7db81 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWrappedDelegateExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirWrappedDelegateExpressionImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirWrappedDelegateExpressionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override var expression: FirExpression, override var delegateProvider: FirExpression, @@ -43,6 +43,10 @@ internal class FirWrappedDelegateExpressionImpl( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) {} override fun replaceExpression(newExpression: FirExpression) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt index f90bfc8d2a5..ed4be05e7d6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/impl/FirLabelImpl.kt @@ -15,7 +15,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirLabelImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val name: String, ) : FirLabel() { override fun acceptChildren(visitor: FirVisitor, data: D) {} @@ -23,4 +23,8 @@ internal class FirLabelImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirLabelImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirBackingFieldReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirBackingFieldReference.kt index 616d4124fa5..3cac73775f3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirBackingFieldReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirBackingFieldReference.kt @@ -23,4 +23,6 @@ abstract class FirBackingFieldReference : FirResolvedNamedReference() { abstract override val resolvedSymbol: FirBackingFieldSymbol override fun accept(visitor: FirVisitor, data: D): R = visitor.visitBackingFieldReference(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirControlFlowGraphReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirControlFlowGraphReference.kt index 57cfed48234..ece4eea49bb 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirControlFlowGraphReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirControlFlowGraphReference.kt @@ -17,4 +17,6 @@ abstract class FirControlFlowGraphReference : FirReference() { abstract override val source: FirSourceElement? override fun accept(visitor: FirVisitor, data: D): R = visitor.visitControlFlowGraphReference(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirDelegateFieldReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirDelegateFieldReference.kt index 2a4b17e058c..e59dd83d848 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirDelegateFieldReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirDelegateFieldReference.kt @@ -23,4 +23,6 @@ abstract class FirDelegateFieldReference : FirResolvedNamedReference() { abstract override val resolvedSymbol: FirDelegateFieldSymbol<*> override fun accept(visitor: FirVisitor, data: D): R = visitor.visitDelegateFieldReference(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirErrorNamedReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirErrorNamedReference.kt index cd9ef957378..edf63eac169 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirErrorNamedReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirErrorNamedReference.kt @@ -24,4 +24,6 @@ abstract class FirErrorNamedReference : FirNamedReference(), FirDiagnosticHolder abstract override val diagnostic: ConeDiagnostic override fun accept(visitor: FirVisitor, data: D): R = visitor.visitErrorNamedReference(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirNamedReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirNamedReference.kt index b62ba95a4de..c4bb2fdce7a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirNamedReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirNamedReference.kt @@ -21,4 +21,6 @@ abstract class FirNamedReference : FirReference() { abstract val candidateSymbol: AbstractFirBasedSymbol<*>? override fun accept(visitor: FirVisitor, data: D): R = visitor.visitNamedReference(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirReference.kt index 1ef424d89c1..5c1385d42d8 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirReference.kt @@ -19,4 +19,6 @@ abstract class FirReference : FirPureAbstractElement(), FirElement { abstract override val source: FirSourceElement? override fun accept(visitor: FirVisitor, data: D): R = visitor.visitReference(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedCallableReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedCallableReference.kt index 37456c2481e..383322987b3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedCallableReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedCallableReference.kt @@ -26,4 +26,6 @@ abstract class FirResolvedCallableReference : FirResolvedNamedReference() { abstract val mappedArguments: CallableReferenceMappedArguments override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedCallableReference(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedNamedReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedNamedReference.kt index d8b18d5ff4c..49d80260fa0 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedNamedReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirResolvedNamedReference.kt @@ -22,4 +22,6 @@ abstract class FirResolvedNamedReference : FirNamedReference() { abstract val resolvedSymbol: AbstractFirBasedSymbol<*> override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedNamedReference(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirSuperReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirSuperReference.kt index 515e36dd2d0..01c8c41dd52 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirSuperReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirSuperReference.kt @@ -21,5 +21,7 @@ abstract class FirSuperReference : FirReference() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitSuperReference(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract fun replaceSuperTypeRef(newSuperTypeRef: FirTypeRef) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirThisReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirThisReference.kt index 484f4ed8b3a..da3aa2d240d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirThisReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/FirThisReference.kt @@ -21,5 +21,7 @@ abstract class FirThisReference : FirReference() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitThisReference(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract fun replaceBoundSymbol(newBoundSymbol: AbstractFirBasedSymbol<*>?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirBackingFieldReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirBackingFieldReferenceImpl.kt index 5649491a1fb..fa1d6321dd8 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirBackingFieldReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirBackingFieldReferenceImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirBackingFieldReferenceImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val candidateSymbol: AbstractFirBasedSymbol<*>?, override val resolvedSymbol: FirBackingFieldSymbol, ) : FirBackingFieldReference() { @@ -29,4 +29,8 @@ internal class FirBackingFieldReferenceImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirBackingFieldReferenceImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirDelegateFieldReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirDelegateFieldReferenceImpl.kt index 831cfb5b849..f3140c01cee 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirDelegateFieldReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirDelegateFieldReferenceImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirDelegateFieldReferenceImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val candidateSymbol: AbstractFirBasedSymbol<*>?, override val resolvedSymbol: FirDelegateFieldSymbol<*>, ) : FirDelegateFieldReference() { @@ -29,4 +29,8 @@ internal class FirDelegateFieldReferenceImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirDelegateFieldReferenceImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt index 9d513fb9f7c..c8805fe165c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirErrorNamedReferenceImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirErrorNamedReferenceImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val candidateSymbol: AbstractFirBasedSymbol<*>?, override val diagnostic: ConeDiagnostic, ) : FirErrorNamedReference() { @@ -29,4 +29,8 @@ internal class FirErrorNamedReferenceImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirErrorNamedReferenceImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt index 1ebe795ba49..f45a3d92f5b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitSuperReference.kt @@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirExplicitSuperReference( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val labelName: String?, override var superTypeRef: FirTypeRef, ) : FirSuperReference() { @@ -29,6 +29,10 @@ internal class FirExplicitSuperReference( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceSuperTypeRef(newSuperTypeRef: FirTypeRef) { superTypeRef = newSuperTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitThisReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitThisReference.kt index 12245b265dd..3cc30b9e700 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitThisReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirExplicitThisReference.kt @@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirExplicitThisReference( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val labelName: String?, ) : FirThisReference() { override var boundSymbol: AbstractFirBasedSymbol<*>? = null @@ -27,6 +27,10 @@ internal class FirExplicitThisReference( return this } + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } + override fun replaceBoundSymbol(newBoundSymbol: AbstractFirBasedSymbol<*>?) { boundSymbol = newBoundSymbol } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirImplicitThisReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirImplicitThisReference.kt index 94abbb83e27..a4804a0832c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirImplicitThisReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirImplicitThisReference.kt @@ -27,5 +27,7 @@ internal class FirImplicitThisReference( return this } + override fun replaceSource(newSource: FirSourceElement?) {} + override fun replaceBoundSymbol(newBoundSymbol: AbstractFirBasedSymbol<*>?) {} } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt index 63a2ef2e7ae..ac5c0755427 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirPropertyFromParameterResolvedNamedReference.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ class FirPropertyFromParameterResolvedNamedReference @FirImplementationDetail constructor( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val name: Name, override val resolvedSymbol: AbstractFirBasedSymbol<*>, ) : FirResolvedNamedReference() { @@ -29,4 +29,8 @@ class FirPropertyFromParameterResolvedNamedReference @FirImplementationDetail co override fun transformChildren(transformer: FirTransformer, data: D): FirPropertyFromParameterResolvedNamedReference { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt index bd5b475725f..6501a4b0ed0 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedCallableReferenceImpl.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirResolvedCallableReferenceImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val name: Name, override val resolvedSymbol: AbstractFirBasedSymbol<*>, override val inferredTypeArguments: MutableList, @@ -32,4 +32,8 @@ internal class FirResolvedCallableReferenceImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirResolvedCallableReferenceImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt index 35b2be66979..ba30c113084 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirResolvedNamedReferenceImpl.kt @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirResolvedNamedReferenceImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val name: Name, override val resolvedSymbol: AbstractFirBasedSymbol<*>, ) : FirResolvedNamedReference() { @@ -28,4 +28,8 @@ internal class FirResolvedNamedReferenceImpl( override fun transformChildren(transformer: FirTransformer, data: D): FirResolvedNamedReferenceImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt index ece8cb1607f..f36ad20d3c4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirSimpleNamedReference.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ open class FirSimpleNamedReference @FirImplementationDetail constructor( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val name: Name, override val candidateSymbol: AbstractFirBasedSymbol<*>?, ) : FirNamedReference() { @@ -27,4 +27,8 @@ open class FirSimpleNamedReference @FirImplementationDetail constructor( override fun transformChildren(transformer: FirTransformer, data: D): FirSimpleNamedReference { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirStubReference.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirStubReference.kt index 55035899e28..d7fdded199f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirStubReference.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/references/impl/FirStubReference.kt @@ -23,4 +23,6 @@ object FirStubReference : FirReference() { override fun transformChildren(transformer: FirTransformer, data: D): FirStubReference { return this } + + override fun replaceSource(newSource: FirSourceElement?) {} } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirDynamicTypeRef.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirDynamicTypeRef.kt index 3a31b1662e9..665a74e43a6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirDynamicTypeRef.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirDynamicTypeRef.kt @@ -21,5 +21,7 @@ abstract class FirDynamicTypeRef : FirTypeRefWithNullability() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitDynamicTypeRef(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirDynamicTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirErrorTypeRef.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirErrorTypeRef.kt index c74ff6d4101..3d915e58fd5 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirErrorTypeRef.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirErrorTypeRef.kt @@ -25,5 +25,7 @@ abstract class FirErrorTypeRef : FirResolvedTypeRef(), FirDiagnosticHolder { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitErrorTypeRef(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirErrorTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirFunctionTypeRef.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirFunctionTypeRef.kt index 35c7bd9e269..54407106229 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirFunctionTypeRef.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirFunctionTypeRef.kt @@ -26,5 +26,7 @@ abstract class FirFunctionTypeRef : FirTypeRefWithNullability() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitFunctionTypeRef(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirFunctionTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirImplicitTypeRef.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirImplicitTypeRef.kt index 4f041aa2f75..96ff637a5ec 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirImplicitTypeRef.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirImplicitTypeRef.kt @@ -20,5 +20,7 @@ abstract class FirImplicitTypeRef : FirTypeRef() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitImplicitTypeRef(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirImplicitTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirResolvedTypeRef.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirResolvedTypeRef.kt index 57f845fdb79..fdd99843721 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirResolvedTypeRef.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirResolvedTypeRef.kt @@ -22,5 +22,7 @@ abstract class FirResolvedTypeRef : FirTypeRef() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedTypeRef(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirResolvedTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirStarProjection.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirStarProjection.kt index 2c0492cc117..9f96f548855 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirStarProjection.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirStarProjection.kt @@ -17,4 +17,6 @@ abstract class FirStarProjection : FirTypeProjection() { abstract override val source: FirSourceElement? override fun accept(visitor: FirVisitor, data: D): R = visitor.visitStarProjection(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeProjection.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeProjection.kt index b864f690b65..7044e9eb995 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeProjection.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeProjection.kt @@ -19,4 +19,6 @@ abstract class FirTypeProjection : FirPureAbstractElement(), FirElement { abstract override val source: FirSourceElement? override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypeProjection(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeProjectionWithVariance.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeProjectionWithVariance.kt index e202e6e5f0c..7240863a3c2 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeProjectionWithVariance.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeProjectionWithVariance.kt @@ -20,4 +20,6 @@ abstract class FirTypeProjectionWithVariance : FirTypeProjection() { abstract val variance: Variance override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypeProjectionWithVariance(this, data) + + abstract override fun replaceSource(newSource: FirSourceElement?) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeRef.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeRef.kt index 9293bbfe203..c88dcf0487f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeRef.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeRef.kt @@ -22,5 +22,7 @@ abstract class FirTypeRef : FirPureAbstractElement(), FirAnnotationContainer { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypeRef(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeRefWithNullability.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeRefWithNullability.kt index c1158ec6664..5168815b7a6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeRefWithNullability.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirTypeRefWithNullability.kt @@ -21,5 +21,7 @@ abstract class FirTypeRefWithNullability : FirTypeRef() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitTypeRefWithNullability(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirTypeRefWithNullability } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirUserTypeRef.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirUserTypeRef.kt index 07dc3b6ea3f..dffcf72a133 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirUserTypeRef.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/FirUserTypeRef.kt @@ -22,5 +22,7 @@ abstract class FirUserTypeRef : FirTypeRefWithNullability() { override fun accept(visitor: FirVisitor, data: D): R = visitor.visitUserTypeRef(this, data) + abstract override fun replaceSource(newSource: FirSourceElement?) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirUserTypeRef } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt index e3079c8ddb3..95f4301099d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirDynamicTypeRefImpl.kt @@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirDynamicTypeRefImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val isMarkedNullable: Boolean, ) : FirDynamicTypeRef() { @@ -33,4 +33,8 @@ internal class FirDynamicTypeRefImpl( annotations.transformInplace(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt index 0a1f8d570cd..a6c7262ae4c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirErrorTypeRefImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var delegatedTypeRef: FirTypeRef?, override val diagnostic: ConeDiagnostic, ) : FirErrorTypeRef() { @@ -40,4 +40,8 @@ internal class FirErrorTypeRefImpl( annotations.transformInplace(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt index 8fd7160f4b6..a98ae553343 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirFunctionTypeRefImpl.kt @@ -18,7 +18,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirFunctionTypeRefImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val isMarkedNullable: Boolean, override var receiverTypeRef: FirTypeRef?, @@ -45,4 +45,8 @@ internal class FirFunctionTypeRefImpl( annotations.transformInplace(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirImplicitTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirImplicitTypeRefImpl.kt index 86a29ec3e89..140ee9835d6 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirImplicitTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirImplicitTypeRefImpl.kt @@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirImplicitTypeRefImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, ) : FirImplicitTypeRef() { override val annotations: List get() = emptyList() @@ -30,4 +30,8 @@ internal class FirImplicitTypeRefImpl( override fun transformAnnotations(transformer: FirTransformer, data: D): FirImplicitTypeRefImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt index 640f811ff4f..1568cbd82be 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ class FirResolvedTypeRefImpl @FirImplementationDetail constructor( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override val annotations: MutableList, override val type: ConeKotlinType, override var delegatedTypeRef: FirTypeRef?, @@ -37,4 +37,8 @@ class FirResolvedTypeRefImpl @FirImplementationDetail constructor( annotations.transformInplace(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt index c95cd6ae3ac..21067871845 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirStarProjectionImpl.kt @@ -15,11 +15,15 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirStarProjectionImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, ) : FirStarProjection() { override fun acceptChildren(visitor: FirVisitor, data: D) {} override fun transformChildren(transformer: FirTransformer, data: D): FirStarProjectionImpl { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypePlaceholderProjection.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypePlaceholderProjection.kt index 905f2272623..386377113f7 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypePlaceholderProjection.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypePlaceholderProjection.kt @@ -23,4 +23,6 @@ object FirTypePlaceholderProjection : FirTypeProjection() { override fun transformChildren(transformer: FirTransformer, data: D): FirTypePlaceholderProjection { return this } + + override fun replaceSource(newSource: FirSourceElement?) {} } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt index b9ccdbd9c61..f5e293cd1bf 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirTypeProjectionWithVarianceImpl.kt @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.fir.visitors.* */ internal class FirTypeProjectionWithVarianceImpl( - override val source: FirSourceElement?, + override var source: FirSourceElement?, override var typeRef: FirTypeRef, override val variance: Variance, ) : FirTypeProjectionWithVariance() { @@ -29,4 +29,8 @@ internal class FirTypeProjectionWithVarianceImpl( typeRef = typeRef.transformSingle(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + source = newSource + } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/contracts/impl/FirEmptyContractDescription.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/contracts/impl/FirEmptyContractDescription.kt index 94f381db4e7..bc6efa882cf 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/contracts/impl/FirEmptyContractDescription.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/contracts/impl/FirEmptyContractDescription.kt @@ -19,4 +19,7 @@ object FirEmptyContractDescription : FirContractDescription() { override fun transformChildren(transformer: FirTransformer, data: D): FirContractDescription { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDeclarationStatusImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDeclarationStatusImpl.kt index c56ccc8f62a..38dd6b19449 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDeclarationStatusImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirDeclarationStatusImpl.kt @@ -170,4 +170,7 @@ open class FirDeclarationStatusImpl( fun resolved(visibility: Visibility, modality: Modality): FirResolvedDeclarationStatusImpl { return FirResolvedDeclarationStatusImpl(visibility, modality, flags) } + + override fun replaceSource(newSource: FirSourceElement?) { + } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt index d6adcd91ade..f69d1749d74 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticProperty.kt @@ -149,4 +149,7 @@ class FirSyntheticProperty( override fun replaceInitializer(newInitializer: FirExpression?) { throw AssertionError("Mutation of synthetic property isn't supported") } + + override fun replaceSource(newSource: FirSourceElement?) { + } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt index ca23b2b789e..a48a63212f5 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/synthetic/FirSyntheticPropertyAccessor.kt @@ -146,4 +146,7 @@ class FirSyntheticPropertyAccessor( override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) { throw AssertionError("Mutation of synthetic property accessor isn't supported") } + + override fun replaceSource(newSource: FirSourceElement?) { + } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirArgumentUtil.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirArgumentUtil.kt index 5cb3d7fcf1f..5b9e3aca0ce 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirArgumentUtil.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirArgumentUtil.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.expressions +import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.builder.buildArgumentList import org.jetbrains.kotlin.fir.expressions.impl.FirArraySetArgumentList @@ -28,4 +29,8 @@ fun buildResolvedArgumentList(mapping: LinkedHashMap get() = emptyList() + + + override fun replaceSource(newSource: FirSourceElement?) { + } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetArgumentList.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetArgumentList.kt index ce2192eae14..e4581539885 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetArgumentList.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirArraySetArgumentList.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.expressions.FirAbstractArgumentList import org.jetbrains.kotlin.fir.expressions.FirExpression @@ -14,4 +15,7 @@ class FirArraySetArgumentList internal constructor( ) : FirAbstractArgumentList() { override val arguments: List get() = indexes + rValue + + override fun replaceSource(newSource: FirSourceElement?) { + } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionWithSmartcastImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionWithSmartcastImpl.kt index bcb7500a4c1..fa91ec35b86 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionWithSmartcastImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirExpressionWithSmartcastImpl.kt @@ -83,4 +83,7 @@ internal class FirExpressionWithSmartcastImpl( } override fun replaceTypeRef(newTypeRef: FirTypeRef) {} + + override fun replaceSource(newSource: FirSourceElement?) { + } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirNoReceiverExpression.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirNoReceiverExpression.kt index fecf4e1865b..e8befbb1a98 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirNoReceiverExpression.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirNoReceiverExpression.kt @@ -30,4 +30,7 @@ object FirNoReceiverExpression : FirExpression() { } override fun replaceTypeRef(newTypeRef: FirTypeRef) {} + + override fun replaceSource(newSource: FirSourceElement?) { + } } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedArgumentList.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedArgumentList.kt index caf5e50a2ce..39f403f7cde 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedArgumentList.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedArgumentList.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.expressions.impl +import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.FirAbstractArgumentList import org.jetbrains.kotlin.fir.expressions.FirArgumentList @@ -33,4 +34,7 @@ class FirResolvedArgumentList internal constructor( mapping = mapping.mapKeys { (k, _) -> k.transformSingle(transformer, data) } as LinkedHashMap return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirSingleExpressionBlock.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirSingleExpressionBlock.kt index 04815dfb3cb..24daea79c55 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirSingleExpressionBlock.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirSingleExpressionBlock.kt @@ -59,6 +59,9 @@ class FirSingleExpressionBlock( annotations.transformInplace(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } @Suppress("NOTHING_TO_INLINE") diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirStubStatement.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirStubStatement.kt index bfad41033d5..3da9db5d788 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirStubStatement.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirStubStatement.kt @@ -29,4 +29,7 @@ object FirStubStatement : FirPureAbstractElement(), FirStatement { override fun transformChildren(transformer: FirTransformer, data: D): FirElement { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/impl/FirReferenceForUnresolvedAnnotations.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/impl/FirReferenceForUnresolvedAnnotations.kt index c96807147f6..fb77a5b3026 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/impl/FirReferenceForUnresolvedAnnotations.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/impl/FirReferenceForUnresolvedAnnotations.kt @@ -19,4 +19,7 @@ object FirReferenceForUnresolvedAnnotations : FirReference() { override fun transformChildren(transformer: FirTransformer, data: D): FirReference { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/impl/FirReferencePlaceholderForResolvedAnnotations.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/impl/FirReferencePlaceholderForResolvedAnnotations.kt index 1bf48b3b655..6b62e5ca9cf 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/impl/FirReferencePlaceholderForResolvedAnnotations.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/references/impl/FirReferencePlaceholderForResolvedAnnotations.kt @@ -19,4 +19,7 @@ object FirReferencePlaceholderForResolvedAnnotations : FirReference() { override fun transformChildren(transformer: FirTransformer, data: D): FirReference { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt index bfe73d6b81d..1b879647eea 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirImplicitBuiltinTypeRef.kt @@ -43,6 +43,9 @@ sealed class FirImplicitBuiltinTypeRef( override fun transformAnnotations(transformer: FirTransformer, data: D): FirResolvedTypeRef { return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } class FirImplicitUnitTypeRef( diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirUserTypeRefImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirUserTypeRefImpl.kt index 7f6740bcfc7..96c4dc39c80 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirUserTypeRefImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirUserTypeRefImpl.kt @@ -41,4 +41,7 @@ class FirUserTypeRefImpl( annotations.transformInplace(transformer, data) return this } + + override fun replaceSource(newSource: FirSourceElement?) { + } } \ No newline at end of file diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt index c14d0f0b7f0..09121c8ffef 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuilder) { fun configureFields() = configure { AbstractFirTreeBuilder.baseFirElement.configure { - +field("source", sourceElementType, nullable = true) + +field("source", sourceElementType, nullable = true, withReplace = true) } annotationContainer.configure { From 5892646a275e3f051e569124f48bb448835bf2cc Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 17 Feb 2021 16:25:49 +0300 Subject: [PATCH 300/368] Change FirQualifiedAccess source to KtQualifiedExpression (if any) --- .../checkers/expression/FirExhaustiveWhenChecker.kt | 13 +++++++++---- .../fir/lightTree/converter/ExpressionsConverter.kt | 1 + .../jetbrains/kotlin/fir/builder/RawFirBuilder.kt | 1 + .../testData/diagnostics/tests/DeferredTypes.fir.kt | 2 +- .../tests/FunctionCalleeExpressions.fir.kt | 2 +- .../initializerScopeOfExtensionProperty.fir.kt | 2 +- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirExhaustiveWhenChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirExhaustiveWhenChecker.kt index ace54dbcc92..913081955df 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirExhaustiveWhenChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirExhaustiveWhenChecker.kt @@ -18,15 +18,20 @@ import org.jetbrains.kotlin.fir.expressions.isExhaustive object FirExhaustiveWhenChecker : FirWhenExpressionChecker() { override fun check(expression: FirWhenExpression, context: CheckerContext, reporter: DiagnosticReporter) { if (expression.usedAsExpression && !expression.isExhaustive) { - if (expression.source?.isIfExpression == true) { - reporter.reportOn(expression.source, FirErrors.INVALID_IF_AS_EXPRESSION, context) - } else { + val source = expression.source ?: return + if (source.isIfExpression) { + reporter.reportOn(source, FirErrors.INVALID_IF_AS_EXPRESSION, context) + return + } else if (source.isWhenExpression) { val missingCases = (expression.exhaustivenessStatus as ExhaustivenessStatus.NotExhaustive).reasons - reporter.reportOn(expression.source, FirErrors.NO_ELSE_IN_WHEN, missingCases, context) + reporter.reportOn(source, FirErrors.NO_ELSE_IN_WHEN, missingCases, context) } } } private val FirSourceElement.isIfExpression: Boolean get() = elementType == KtNodeTypes.IF + + private val FirSourceElement.isWhenExpression: Boolean + get() = elementType == KtNodeTypes.WHEN } diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt index 394b650ec39..0473bc56df1 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt @@ -499,6 +499,7 @@ class ExpressionsConverter( it.replaceExplicitReceiver(firReceiver) } + firSelector.replaceSource(dotQualifiedExpression.toFirSourceElement()) return firSelector } diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 7b47a505f95..25e02f27f9c 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -1985,6 +1985,7 @@ class RawFirBuilder( firSelector.replaceExplicitReceiver(receiver) } + firSelector.replaceSource(expression.toFirSourceElement()) return firSelector } diff --git a/compiler/testData/diagnostics/tests/DeferredTypes.fir.kt b/compiler/testData/diagnostics/tests/DeferredTypes.fir.kt index 3647a682a51..7febd7aed4c 100644 --- a/compiler/testData/diagnostics/tests/DeferredTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/DeferredTypes.fir.kt @@ -1,5 +1,5 @@ // NI_EXPECTED_FILE interface T { - val a = Foo.bar() + val a = Foo.bar() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt index 14ccbb2caa7..6a62617d900 100644 --- a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt @@ -72,7 +72,7 @@ fun main1() { 1."sdf" 1.{} - 1.if (true) {} + 1.if (true) {} } fun test() { diff --git a/compiler/testData/diagnostics/tests/scopes/initializerScopeOfExtensionProperty.fir.kt b/compiler/testData/diagnostics/tests/scopes/initializerScopeOfExtensionProperty.fir.kt index 7ce78c898ac..8ec4257a2cd 100644 --- a/compiler/testData/diagnostics/tests/scopes/initializerScopeOfExtensionProperty.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/initializerScopeOfExtensionProperty.fir.kt @@ -26,6 +26,6 @@ class C { val C.foo : C.D = D() -val C.bar : C.D = C().D() +val C.bar : C.D = C().D() val C.foo1 : C.D get() = D() From 5ca3ce9e371231a744e697b723d74c87bcd385de Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 17 Feb 2021 16:26:17 +0300 Subject: [PATCH 301/368] FIR: introduce & use SELECTOR_BY_QUALIFIED positioning strategy --- .../generator/diagnostics/DiagnosticData.kt | 1 + .../diagnostics/FirDiagnosticsList.kt | 6 +-- .../fir/analysis/diagnostics/FirErrors.kt | 6 +-- .../LightTreePositioningStrategies.kt | 37 +++++++++++++++++++ .../SourceElementPositioningStrategies.kt | 5 +++ .../diagnostics/PositioningStrategies.kt | 11 ++++++ 6 files changed, 60 insertions(+), 6 deletions(-) diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt index 280b6f124fc..e42699b4888 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt @@ -42,6 +42,7 @@ enum class PositioningStrategy(private val strategy: String) { IF_EXPRESSION("IF_EXPRESSION"), VARIANCE_MODIFIER("VARIANCE_MODIFIER"), LATEINIT_MODIFIER("LATEINIT_MODIFIER"), + SELECTOR_BY_QUALIFIED("SELECTOR_BY_QUALIFIED"), ; diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 8cb30a29927..7a2ea3c0abf 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -388,7 +388,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() { } val FUNCTION_CONTRACTS by object : DiagnosticGroup("Function contracts") { - val ERROR_IN_CONTRACT_DESCRIPTION by error { + val ERROR_IN_CONTRACT_DESCRIPTION by error(PositioningStrategy.SELECTOR_BY_QUALIFIED) { parameter("reason") } } @@ -401,7 +401,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() { val REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE by warning() val CAN_BE_VAL by warning(PositioningStrategy.VAL_OR_VAR_NODE) val CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT by warning(PositioningStrategy.OPERATOR) - val REDUNDANT_CALL_OF_CONVERSION_METHOD by warning() + val REDUNDANT_CALL_OF_CONVERSION_METHOD by warning(PositioningStrategy.SELECTOR_BY_QUALIFIED) val ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS by warning(PositioningStrategy.OPERATOR) val EMPTY_RANGE by warning() val REDUNDANT_SETTER_PARAMETER_TYPE by warning() @@ -409,7 +409,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() { val ASSIGNED_VALUE_IS_NEVER_READ by warning() val VARIABLE_INITIALIZER_IS_REDUNDANT by warning() val VARIABLE_NEVER_READ by warning(PositioningStrategy.DECLARATION_NAME) - val USELESS_CALL_ON_NOT_NULL by warning() + val USELESS_CALL_ON_NOT_NULL by warning(PositioningStrategy.SELECTOR_BY_QUALIFIED) } } diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 0133cf8126a..e0fd06ce1bc 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -244,7 +244,7 @@ object FirErrors { val INVALID_IF_AS_EXPRESSION by error0(SourceElementPositioningStrategies.IF_EXPRESSION) // Function contracts - val ERROR_IN_CONTRACT_DESCRIPTION by error1() + val ERROR_IN_CONTRACT_DESCRIPTION by error1(SourceElementPositioningStrategies.SELECTOR_BY_QUALIFIED) // Extended checkers val REDUNDANT_VISIBILITY_MODIFIER by warning0(SourceElementPositioningStrategies.VISIBILITY_MODIFIER) @@ -254,7 +254,7 @@ object FirErrors { val REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE by warning0() val CAN_BE_VAL by warning0(SourceElementPositioningStrategies.VAL_OR_VAR_NODE) val CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT by warning0(SourceElementPositioningStrategies.OPERATOR) - val REDUNDANT_CALL_OF_CONVERSION_METHOD by warning0() + val REDUNDANT_CALL_OF_CONVERSION_METHOD by warning0(SourceElementPositioningStrategies.SELECTOR_BY_QUALIFIED) val ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS by warning0(SourceElementPositioningStrategies.OPERATOR) val EMPTY_RANGE by warning0() val REDUNDANT_SETTER_PARAMETER_TYPE by warning0() @@ -262,6 +262,6 @@ object FirErrors { val ASSIGNED_VALUE_IS_NEVER_READ by warning0() val VARIABLE_INITIALIZER_IS_REDUNDANT by warning0() val VARIABLE_NEVER_READ by warning0(SourceElementPositioningStrategies.DECLARATION_NAME) - val USELESS_CALL_ON_NOT_NULL by warning0() + val USELESS_CALL_ON_NOT_NULL by warning0(SourceElementPositioningStrategies.SELECTOR_BY_QUALIFIED) } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt index f4b21c77cbb..da3031de9b1 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt @@ -335,6 +335,24 @@ object LightTreePositioningStrategies { } } + val SELECTOR_BY_QUALIFIED: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { + if (node.tokenType != KtNodeTypes.DOT_QUALIFIED_EXPRESSION && node.tokenType != KtNodeTypes.SAFE_ACCESS_EXPRESSION) { + return super.mark(node, startOffset, endOffset, tree) + } + val selector = tree.selector(node) + if (selector != null) { + return markElement(selector, startOffset, endOffset, tree, node) + } + return super.mark(node, startOffset, endOffset, tree) + } + } + val WHEN_EXPRESSION = object : LightTreePositioningStrategy() { override fun mark( node: LighterASTNode, @@ -448,6 +466,25 @@ private fun FlyweightCapableTreeStructure.defaultValue(node: Lig return null } +private fun FlyweightCapableTreeStructure.selector(node: LighterASTNode): LighterASTNode? { + val childrenRef = Ref>() + getChildren(node, childrenRef) + val children = childrenRef.get() ?: return null + var dotFound = false + for (child in children) { + if (child == null) continue + if (child.tokenType == KtTokens.DOT) { + dotFound = true + continue + } + if (dotFound && (child.tokenType == KtNodeTypes.CALL_EXPRESSION || child.tokenType == KtNodeTypes.REFERENCE_EXPRESSION)) { + return child + } + } + return null + +} + fun FlyweightCapableTreeStructure.findChildByType(node: LighterASTNode, type: IElementType): LighterASTNode? { val childrenRef = Ref>() getChildren(node, childrenRef) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt index 4d4e326d73f..804e1626282 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt @@ -103,6 +103,11 @@ object SourceElementPositioningStrategies { PositioningStrategies.DOT_BY_SELECTOR ) + val SELECTOR_BY_QUALIFIED = SourceElementPositioningStrategy( + LightTreePositioningStrategies.SELECTOR_BY_QUALIFIED, + PositioningStrategies.SELECTOR_BY_QUALIFIED + ) + val WHEN_EXPRESSION = SourceElementPositioningStrategy( LightTreePositioningStrategies.WHEN_EXPRESSION, PositioningStrategies.WHEN_EXPRESSION diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt index 65684cefd04..ee35b392ce8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt @@ -725,4 +725,15 @@ object PositioningStrategies { return super.mark(element) } } + + val SELECTOR_BY_QUALIFIED: PositioningStrategy = object : PositioningStrategy() { + override fun mark(element: PsiElement): List { + if (element is KtQualifiedExpression) { + when (val selectorExpression = element.selectorExpression) { + is KtCallExpression, is KtReferenceExpression -> return mark(selectorExpression) + } + } + return super.mark(element) + } + } } From 04caa5c61275ccb49f3b63a2f1431dc54f18b881 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 17 Feb 2021 16:26:34 +0300 Subject: [PATCH 302/368] Fix DEBUG_INFO_CALL positioning in FIR --- .../LightTreePositioningStrategies.kt | 2 +- .../fir/handlers/FirDiagnosticsHandler.kt | 57 ++++++++++++------- .../p-12/pos/2.1.fir.kt | 30 +++++----- 3 files changed, 53 insertions(+), 36 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt index da3031de9b1..b5ba01f5d06 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt @@ -466,7 +466,7 @@ private fun FlyweightCapableTreeStructure.defaultValue(node: Lig return null } -private fun FlyweightCapableTreeStructure.selector(node: LighterASTNode): LighterASTNode? { +fun FlyweightCapableTreeStructure.selector(node: LighterASTNode): LighterASTNode? { val childrenRef = Ref>() getChildren(node, childrenRef) val children = childrenRef.get() ?: return null diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt index 2eefc1a3f02..5071bea1172 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.coneTypeSafe import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitorVoid import org.jetbrains.kotlin.name.FqNameUnsafe +import org.jetbrains.kotlin.psi.KtDotQualifiedExpression import org.jetbrains.kotlin.resolve.AnalyzingUtils import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives @@ -180,6 +181,31 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes Renderers.renderCallInfo(fqName, getTypeOfCall(reference, resolvedSymbol)) } + private fun DebugInfoDiagnosticFactory1.getPositionedElement(sourceElement: FirSourceElement): FirSourceElement { + return if (this === DebugInfoDiagnosticFactory1.CALL + && sourceElement.elementType == KtNodeTypes.DOT_QUALIFIED_EXPRESSION + ) { + if (sourceElement is FirPsiSourceElement<*>) { + val psi = (sourceElement.psi as KtDotQualifiedExpression).selectorExpression + psi?.let { FirRealPsiSourceElement(it) } ?: sourceElement + } else { + val tree = sourceElement.treeStructure + val selector = tree.selector(sourceElement.lighterASTNode) + if (selector == null) { + sourceElement + } else { + val startDelta = tree.getStartOffset(selector) - tree.getStartOffset(sourceElement.lighterASTNode) + val endDelta = tree.getEndOffset(selector) - tree.getEndOffset(sourceElement.lighterASTNode) + FirLightSourceElement( + selector, sourceElement.startOffset + startDelta, sourceElement.endOffset + endDelta, tree + ) + } + } + } else { + sourceElement + } + } + private inline fun DebugInfoDiagnosticFactory1.createDebugInfoDiagnostic( element: FirElement, diagnosedRangesToDiagnosticNames: Map>, @@ -187,31 +213,22 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes ): FirDiagnosticWithParameters1? { val sourceElement = element.source ?: return null if (sourceElement.kind !in allowedKindsForDebugInfo) return null + // Lambda argument is always (?) duplicated by function literal // Block expression is always (?) duplicated by single block expression if (sourceElement.elementType == KtNodeTypes.LAMBDA_ARGUMENT || sourceElement.elementType == KtNodeTypes.BLOCK) return null - if (diagnosedRangesToDiagnosticNames[sourceElement.startOffset..sourceElement.endOffset]?.contains(this.name) != true) return null + // Unfortunately I had to repeat positioning strategy logic here + // (we need to check diagnostic range before applying it) + val positionedElement = getPositionedElement(sourceElement) + if (diagnosedRangesToDiagnosticNames[positionedElement.startOffset..positionedElement.endOffset]?.contains(this.name) != true) { + return null + } val argumentText = argument() - return when (sourceElement) { - is FirPsiSourceElement<*> -> FirPsiDiagnosticWithParameters1( - sourceElement, - argumentText, - severity, - FirDiagnosticFactory1( - name, - severity, - ) - ) - is FirLightSourceElement -> FirLightDiagnosticWithParameters1( - sourceElement, - argumentText, - severity, - FirDiagnosticFactory1( - name, - severity - ) - ) + val factory = FirDiagnosticFactory1, PsiElement, String>(name, severity) + return when (positionedElement) { + is FirPsiSourceElement<*> -> FirPsiDiagnosticWithParameters1(positionedElement, argumentText, severity, factory) + is FirLightSourceElement -> FirLightDiagnosticWithParameters1(positionedElement, argumentText, severity, factory) } } diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-12/pos/2.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-12/pos/2.1.fir.kt index 8dc04d634b0..011f6984143 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-12/pos/2.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-12/pos/2.1.fir.kt @@ -10,11 +10,11 @@ fun case1(case: Case1) { //to (1.1) case.boo(1) //(1.1) return type is String - case.boo(1) + case.boo(1) //to (1.1) case.boo(x = 1) //(1.1) return type is String - case.boo(x = 1) + case.boo(x = 1) } @@ -35,11 +35,11 @@ fun case2(case: Case2) { //to (1.1) case.boo(1, 2) //(1.1) return type is String - case.boo(1, 2) + case.boo(1, 2) //to (1.1) case.boo(x = 1, y = 2) //(1.1) return type is String - case.boo(x = 1, y = 2) + case.boo(x = 1, y = 2) } // TESTCASE NUMBER: 3 @@ -52,11 +52,11 @@ fun case3(case: Case3) { //to (1.1) case.boo(1, 2) //(1.1) return type is String - case.boo(1, 2) + case.boo(1, 2) //to (1.1) case.boo(x = 1, y = 2) //(1.1) return type is String - case.boo(x = 1, y = 2) + case.boo(x = 1, y = 2) } // TESTCASE NUMBER: 4 @@ -71,11 +71,11 @@ fun case4(case: Case4) { //to (1.1) case.plus(1) //(1.1) return type is String - case.plus(1) + case.plus(1) //to (1.1) case.plus(x = 1) //(1.1) return type is String - case.plus(x = 1) + case.plus(x = 1) //as operator call case + 1 //to (1.1) case+1 @@ -91,7 +91,7 @@ class Case5 { fun case(list: List) { list.foo(1) - list.foo(1) + list.foo(1) } } @@ -103,7 +103,7 @@ class Case6 { fun case(list: List) { list.foo(1) - list.foo(1) + list.foo(1) } } @@ -115,7 +115,7 @@ class Case7 { fun case(list: List) { list.foo(1, 1) - list.foo(1, 1) + list.foo(1, 1) } } @@ -127,7 +127,7 @@ class Case8() { fun testcase8(case: Case8) { case.foo(1, 1) - case.foo(1, 1) + case.foo(1, 1) } // TESTCASE NUMBER: 9 @@ -138,7 +138,7 @@ class Case9() { fun testcase9(case: Case9) { case.xoo(1, 1) - case.xoo(1, 1) + case.xoo(1, 1) } // TESTCASE NUMBER: 10 @@ -149,7 +149,7 @@ class Case10() { fun testcase10(case: Case10) { case.xoo(1, 1) - case.xoo(1, 1) + case.xoo(1, 1) } // TESTCASE NUMBER: 11 @@ -160,5 +160,5 @@ class Case11() { fun testcase11(case: Case11) { case.xoo(1, 1) - case.xoo(1, 1) + case.xoo(1, 1) } From 5ffa72f1faca0e3994dc0492f2e305447479b367 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 18 Feb 2021 11:08:46 +0300 Subject: [PATCH 303/368] FIR: change DOT_BY_SELECTOR to DOT_BY_QUALIFIED strategy --- .../checkers/generator/diagnostics/DiagnosticData.kt | 2 +- .../generator/diagnostics/FirDiagnosticsList.kt | 2 +- .../kotlin/fir/analysis/diagnostics/FirErrors.kt | 2 +- .../diagnostics/LightTreePositioningStrategies.kt | 12 +++--------- .../SourceElementPositioningStrategies.kt | 6 +++--- .../kotlin/diagnostics/PositioningStrategies.kt | 10 +++------- 6 files changed, 12 insertions(+), 22 deletions(-) diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt index e42699b4888..6ca5292d888 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt @@ -36,7 +36,7 @@ enum class PositioningStrategy(private val strategy: String) { PARAMETER_VARARG_MODIFIER("PARAMETER_VARARG_MODIFIER"), DECLARATION_RETURN_TYPE("DECLARATION_RETURN_TYPE"), OVERRIDE_MODIFIER("OVERRIDE_MODIFIER"), - DOT_BY_SELECTOR("DOT_BY_SELECTOR"), + DOT_BY_QUALIFIED("DOT_BY_QUALIFIED"), OPEN_MODIFIER("OPEN_MODIFIER"), WHEN_EXPRESSION("WHEN_EXPRESSION"), IF_EXPRESSION("IF_EXPRESSION"), diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 7a2ea3c0abf..3ca0d8635e2 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -361,7 +361,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() { } val NULLABILITY by object : DiagnosticGroup("Nullability") { - val UNSAFE_CALL by error(PositioningStrategy.DOT_BY_SELECTOR) { + val UNSAFE_CALL by error(PositioningStrategy.DOT_BY_QUALIFIED) { parameter("receiverType") } val UNSAFE_IMPLICIT_INVOKE_CALL by error { diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index e0fd06ce1bc..30eb6beba1e 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -234,7 +234,7 @@ object FirErrors { val WRONG_IMPLIES_CONDITION by warning0() // Nullability - val UNSAFE_CALL by error1(SourceElementPositioningStrategies.DOT_BY_SELECTOR) + val UNSAFE_CALL by error1(SourceElementPositioningStrategies.DOT_BY_QUALIFIED) val UNSAFE_IMPLICIT_INVOKE_CALL by error1() val UNSAFE_INFIX_CALL by error3() val UNSAFE_OPERATOR_CALL by error3() diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt index b5ba01f5d06..d48905957ae 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt @@ -315,23 +315,17 @@ object LightTreePositioningStrategies { } } - val DOT_BY_SELECTOR: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { + val DOT_BY_QUALIFIED: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { override fun mark( node: LighterASTNode, startOffset: Int, endOffset: Int, tree: FlyweightCapableTreeStructure ): List { - if (node.tokenType != KtNodeTypes.REFERENCE_EXPRESSION && node.tokenType != KtNodeTypes.CALL_EXPRESSION) { - // TODO: normally CALL_EXPRESSION should not be here. In PSI we have REFERENCE_EXPRESSION even for x.bar() case - // Remove CALL_EXPRESSION from here and repeat code below twice (see PSI counterpart) when fixed + if (node.tokenType != KtNodeTypes.DOT_QUALIFIED_EXPRESSION) { return super.mark(node, startOffset, endOffset, tree) } - val parentNode = tree.getParent(node) ?: return super.mark(node, startOffset, endOffset, tree) - if (parentNode.tokenType == KtNodeTypes.DOT_QUALIFIED_EXPRESSION) { - return markElement(tree.dotOperator(parentNode) ?: node, startOffset, endOffset, tree, node) - } - return super.mark(node, startOffset, endOffset, tree) + return markElement(tree.dotOperator(node) ?: node, startOffset, endOffset, tree, node) } } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt index 804e1626282..6e006527cb2 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt @@ -98,9 +98,9 @@ object SourceElementPositioningStrategies { PositioningStrategies.PARAMETER_VARARG_MODIFIER ) - val DOT_BY_SELECTOR = SourceElementPositioningStrategy( - LightTreePositioningStrategies.DOT_BY_SELECTOR, - PositioningStrategies.DOT_BY_SELECTOR + val DOT_BY_QUALIFIED = SourceElementPositioningStrategy( + LightTreePositioningStrategies.DOT_BY_QUALIFIED, + PositioningStrategies.DOT_BY_QUALIFIED ) val SELECTOR_BY_QUALIFIED = SourceElementPositioningStrategy( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt index ee35b392ce8..3848d8afb95 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt @@ -711,15 +711,11 @@ object PositioningStrategies { } } - val DOT_BY_SELECTOR: PositioningStrategy = object : PositioningStrategy() { + val DOT_BY_QUALIFIED: PositioningStrategy = object : PositioningStrategy() { override fun mark(element: PsiElement): List { when (element) { - is KtNameReferenceExpression -> { - var parent = element - repeat(2) { - parent = parent.parent - (parent as? KtDotQualifiedExpression)?.operationTokenNode?.psi?.let { return mark(it) } - } + is KtDotQualifiedExpression -> { + return mark(element.operationTokenNode.psi) } } return super.mark(element) From 0accaf0f30110f4eb963a9e59a72805ff9ab8264 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 19 Feb 2021 15:19:22 +0300 Subject: [PATCH 304/368] FIR: report resolve-time errors on qualified access instead of reference --- .../checkers/context/CheckerContext.kt | 22 ++++++++++++++++++- .../collectors/AbstractDiagnosticCollector.kt | 19 ++++++++++++++++ .../ErrorNodeDiagnosticCollectorComponent.kt | 3 ++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/context/CheckerContext.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/context/CheckerContext.kt index 50f8ae30f35..02bdebb26c5 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/context/CheckerContext.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/context/CheckerContext.kt @@ -11,17 +11,18 @@ import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentSetOf import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess import org.jetbrains.kotlin.fir.resolve.ImplicitReceiverStack import org.jetbrains.kotlin.fir.resolve.PersistentImplicitReceiverStack import org.jetbrains.kotlin.fir.resolve.SessionHolder import org.jetbrains.kotlin.fir.resolve.calls.ImplicitReceiverValue -import org.jetbrains.kotlin.fir.resolve.calls.InapplicableArgumentDiagnostic import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator import org.jetbrains.kotlin.name.Name abstract class CheckerContext { abstract val implicitReceiverStack: ImplicitReceiverStack abstract val containingDeclarations: List + abstract val qualifiedAccesses: List abstract val sessionHolder: SessionHolder abstract val returnTypeCalculator: ReturnTypeCalculator abstract val suppressedDiagnostics: Set @@ -48,6 +49,7 @@ abstract class CheckerContext { class PersistentCheckerContext private constructor( override val implicitReceiverStack: PersistentImplicitReceiverStack, override val containingDeclarations: PersistentList, + override val qualifiedAccesses: PersistentList, override val sessionHolder: SessionHolder, override val returnTypeCalculator: ReturnTypeCalculator, override val suppressedDiagnostics: PersistentSet, @@ -58,6 +60,7 @@ class PersistentCheckerContext private constructor( constructor(sessionHolder: SessionHolder, returnTypeCalculator: ReturnTypeCalculator) : this( PersistentImplicitReceiverStack(), persistentListOf(), + persistentListOf(), sessionHolder, returnTypeCalculator, persistentSetOf(), @@ -70,6 +73,7 @@ class PersistentCheckerContext private constructor( return PersistentCheckerContext( implicitReceiverStack.add(name, value), containingDeclarations, + qualifiedAccesses, sessionHolder, returnTypeCalculator, suppressedDiagnostics, @@ -83,6 +87,21 @@ class PersistentCheckerContext private constructor( return PersistentCheckerContext( implicitReceiverStack, containingDeclarations.add(declaration), + qualifiedAccesses, + sessionHolder, + returnTypeCalculator, + suppressedDiagnostics, + allInfosSuppressed, + allWarningsSuppressed, + allErrorsSuppressed + ) + } + + fun addQualifiedAccess(qualifiedAccess: FirQualifiedAccess): PersistentCheckerContext { + return PersistentCheckerContext( + implicitReceiverStack, + containingDeclarations, + qualifiedAccesses.add(qualifiedAccess), sessionHolder, returnTypeCalculator, suppressedDiagnostics, @@ -102,6 +121,7 @@ class PersistentCheckerContext private constructor( return PersistentCheckerContext( implicitReceiverStack, containingDeclarations, + qualifiedAccesses, sessionHolder, returnTypeCalculator, suppressedDiagnostics.addAll(diagnosticNames), diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollector.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollector.kt index 8591c9865dd..679b77a82cc 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollector.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollector.kt @@ -208,6 +208,14 @@ abstract class AbstractDiagnosticCollector( resolvedTypeRef.delegatedTypeRef?.accept(this, data) } + override fun visitFunctionCall(functionCall: FirFunctionCall, data: Nothing?) { + visitWithQualifiedAccess(functionCall) + } + + override fun visitQualifiedAccessExpression(qualifiedAccessExpression: FirQualifiedAccessExpression, data: Nothing?) { + visitWithQualifiedAccess(qualifiedAccessExpression) + } + private inline fun visitWithDeclaration( declaration: FirDeclaration, block: () -> Unit = { declaration.acceptChildren(this, null) } @@ -237,6 +245,17 @@ abstract class AbstractDiagnosticCollector( } } } + + private fun visitWithQualifiedAccess(qualifiedAccess: FirQualifiedAccess) { + val existingContext = context + context = context.addQualifiedAccess(qualifiedAccess) + try { + qualifiedAccess.runComponents() + qualifiedAccess.acceptChildren(this, null) + } finally { + context = existingContext + } + } } protected open fun onDeclarationEnter(declaration: FirDeclaration): DiagnosticCollectorDeclarationAction = diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt index 97fe8d669e2..87a7ba8203f 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt @@ -34,7 +34,8 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect } override fun visitErrorNamedReference(errorNamedReference: FirErrorNamedReference, data: CheckerContext) { - val source = errorNamedReference.source ?: return + val source = data.qualifiedAccesses.lastOrNull()?.source?.takeIf { it.elementType == KtNodeTypes.DOT_QUALIFIED_EXPRESSION } + ?: errorNamedReference.source ?: return // Don't report duplicated unresolved reference on annotation entry (already reported on its type) if (source.elementType == KtNodeTypes.ANNOTATION_ENTRY && errorNamedReference.diagnostic is ConeUnresolvedNameError) return reportFirDiagnostic(errorNamedReference.diagnostic, source, reporter, data) From 34c90aab3b8f926a92be5402b763e2d0c7f01e91 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 18 Feb 2021 11:54:22 +0300 Subject: [PATCH 305/368] FIR: introduce & use REFERENCE_BY_QUALIFIER positioning strategy --- .../arguments/ambiguityOnJavaOverride.kt | 2 +- .../testData/resolve/arguments/default.kt | 8 ++-- .../resolve/arguments/defaultFromOverrides.kt | 4 +- .../resolve/arguments/integerLiteralTypes.kt | 8 ++-- .../resolve/arguments/javaArrayVariance.kt | 2 +- .../testData/resolve/arguments/lambda.kt | 14 +++--- .../arguments/lambdaInUnresolvedCall.kt | 8 ++-- .../arguments/operatorsOverLiterals.kt | 38 +++++++-------- .../testData/resolve/arguments/simple.kt | 12 ++--- .../testData/resolve/arguments/vararg.kt | 8 ++-- .../testData/resolve/asImports.kt | 4 +- .../resolve/callResolution/errorCandidates.kt | 6 +-- .../callResolution/lambdaAsReceiver.kt | 2 +- .../resolve/cfg/flowFromInplaceLambda.kt | 12 ++--- .../resolve/diagnostics/abstractSuperCall.kt | 4 +- ...llInPresenseOfNonAbstractMethodInParent.kt | 2 +- .../cyclicConstructorDelegationCall.kt | 2 +- .../explicitDelegationCallRequired.kt | 6 +-- .../instanceAccessBeforeSuperCall.kt | 2 +- .../resolve/diagnostics/notASupertype.kt | 2 +- .../diagnostics/sealedClassConstructorCall.kt | 2 +- .../diagnostics/superIsNotAnExpression.kt | 2 +- .../resolve/diagnostics/superNotAvailable.kt | 12 ++--- .../diagnostics/typeArgumentsNotAllowed.kt | 4 +- .../resolve/diagnostics/upperBoundViolated.kt | 2 +- .../positive/exhaustiveness_enumJava.kt | 6 +-- .../positive/exhaustiveness_sealedSubClass.kt | 6 +-- .../CallBasedInExpressionGenerator.kt | 14 +++--- .../testData/resolve/expresssions/access.kt | 4 +- .../resolve/expresssions/baseQualifier.kt | 4 +- .../resolve/expresssions/enumEntryUse.kt | 2 +- .../expresssions/inference/typeParameters.kt | 2 +- .../expresssions/inference/typeParameters2.kt | 2 +- .../expresssions/invoke/threeReceivers.kt | 2 +- .../resolve/expresssions/localObjects.kt | 2 +- .../resolve/expresssions/nestedVisibility.kt | 12 ++--- .../resolve/expresssions/privateVisibility.kt | 18 ++++---- .../expresssions/protectedVisibility.kt | 6 +-- .../expresssions/receiverConsistency.kt | 4 +- .../testData/resolve/fromBuilder/enums.kt | 6 +-- .../testData/resolve/incorrectSuperCall.kt | 2 +- .../inference/nullableIntegerLiteralType.kt | 4 +- .../inference/receiverWithCapturedType.kt | 2 +- .../testData/resolve/innerClasses/inner.kt | 6 +-- .../resolve/innerClasses/innerTypes.kt | 6 +-- .../testData/resolve/innerClasses/simple.kt | 4 +- .../testData/resolve/kt41984.kt | 2 +- .../resolve/lambdaArgInScopeFunction.kt | 4 +- .../resolve/lambdaPropertyTypeInference.kt | 8 ++-- .../testData/resolve/nestedClassContructor.kt | 2 +- .../testData/resolve/overrides/simple.kt | 2 +- .../overrides/supertypeGenericsComplex.kt | 2 +- .../definitelyNotNullAndOriginalType.kt | 2 +- .../problems/inaccessibleJavaGetter.kt | 4 +- .../problems/multipleJavaClassesInOneFile.kt | 2 +- .../syntheticPropertiesForJavaAnnotations.kt | 2 +- .../genericSamInferenceFromExpectType.kt | 4 +- .../realConstructorFunction.kt | 8 ++-- .../resolve/samConversions/genericSam.kt | 4 +- .../resolve/samConversions/kotlinSam.kt | 8 ++-- .../notSamBecauseOfSupertype.kt | 8 ++-- .../smartcasts/booleans/booleanOperators.kt | 14 +++--- .../boundSmartcasts/boundSmartcasts.kt | 4 +- .../testData/resolve/smartcasts/casts.kt | 16 +++---- .../smartcasts/controlStructures/returns.kt | 10 ++-- .../resolve/smartcasts/loops/endlessLoops.kt | 2 +- .../resolve/smartcasts/orInWhenBranch.kt | 6 +-- .../smartcasts/receivers/implicitReceivers.kt | 36 +++++++-------- .../resolve/smartcasts/safeCalls/safeCalls.kt | 2 +- .../resolve/typeAliasWithTypeArguments.kt | 10 ++-- .../visibility/singletonConstructors.kt | 6 +-- .../callableReferences/companions.kt | 6 +-- ...llableReferencesAfterAllSimpleArguments.kt | 4 +- .../callableReferences/implicitTypes.kt | 2 +- .../callableReferences/javaStatic.kt | 2 +- .../manyInnermanyOuterCandidatesAmbiguity.kt | 2 +- .../good/returnsImplies/booleanOperators.kt | 4 +- .../resolveWithStdlib/j+k/JavaVisibility2.kt | 6 +-- .../j+k/KJKComplexHierarchyWithNested.kt | 4 +- .../j+k/KotlinClassParameter.kt | 2 +- .../j+k/KotlinClassParameterGeneric.kt | 4 +- .../problems/KJKComplexHierarchyNestedLoop.kt | 8 ++-- .../generator/diagnostics/DiagnosticData.kt | 1 + .../diagnostics/FirDiagnosticsList.kt | 15 +++--- .../fir/analysis/diagnostics/FirErrors.kt | 14 +++--- .../LightTreePositioningStrategies.kt | 34 ++++++++++++++ .../SourceElementPositioningStrategies.kt | 5 ++ .../diagnostics/PositioningStrategies.kt | 16 +++++++ ...tedGetSetPropertyDelegateConvention.fir.kt | 4 +- .../tests/FunctionCalleeExpressions.fir.kt | 46 +++++++++---------- .../annotations/options/targets/field.fir.kt | 2 +- .../function/fakeOverrideType.fir.kt | 2 +- .../fieldAsClassDelegate.fir.kt | 2 +- ...ocalVariablesWithTypeParameters_1_3.fir.kt | 2 +- ...ocalVariablesWithTypeParameters_1_4.fir.kt | 2 +- .../namedFunAsLastExpressionInBlock.fir.kt | 2 +- .../incompleteTypeInference.fir.kt | 4 +- .../inference/extensionProperty.fir.kt | 4 +- .../inference/manyIncompleteCandidates.fir.kt | 2 +- .../tests/delegatedProperty/kt4640.fir.kt | 2 +- .../delegatedProperty/missedGetter.fir.kt | 2 +- .../propertyDefferedType.fir.kt | 2 +- .../provideDelegate/hostAndReceiver2.fir.kt | 2 +- .../thisOfNothingNullableType.fir.kt | 2 +- .../thisOfNothingType.fir.kt | 4 +- .../delegatedProperty/twoGetMethods.fir.kt | 2 +- .../typeMismatchForGetWithGeneric.fir.kt | 4 +- .../typeMismatchForThisGetParameter.fir.kt | 4 +- .../wrongCountOfParametersInGet.fir.kt | 4 +- .../throwOutCandidatesByReceiver.fir.kt | 2 +- .../functionLiterals/DeprecatedSyntax.fir.kt | 4 +- ...t6541_extensionForExtensionFunction.fir.kt | 2 +- .../valWithNoNameInBlock.fir.kt | 2 +- .../inference/invokeLambdaAsFunction.fir.kt | 2 +- .../testData/diagnostics/tests/kt435.fir.kt | 2 +- .../diagnostics/tests/objects/Objects.fir.kt | 4 +- .../delegatedProperties.fir.kt | 2 +- .../calleeExpressionAsCallExpression.fir.kt | 2 +- .../tests/regressions/kt26303.fir.kt | 2 +- .../invoke/errors/ambiguityForInvoke.fir.kt | 2 +- .../invoke/errors/invisibleInvoke.fir.kt | 2 +- .../receiverPresenceErrorForInvoke.fir.kt | 2 +- .../errors/typeInferenceErrorForInvoke.fir.kt | 2 +- .../invoke/errors/unresolvedInvoke.fir.kt | 2 +- .../invoke/errors/unsafeCallWithInvoke.fir.kt | 2 +- .../wrongReceiverForInvokeOnExpression.fir.kt | 10 ++-- .../errors/wrongReceiverTypeForInvoke.fir.kt | 2 +- .../resolve/invoke/invokeAndSmartCast.fir.kt | 8 ++-- ...OnVariableWithExtensionFunctionType.fir.kt | 12 ++--- .../diagnostics/tests/safeCall.fir.kt | 15 ------ .../testData/diagnostics/tests/safeCall.kt | 1 + .../headerCallChecker/operatorCall.fir.kt | 2 +- .../implicitSuperCallErrorsIfPrimary.fir.kt | 2 +- .../nestedExtendsInner.fir.kt | 2 +- ...reportResolutionErrorOnImplicitOnce.fir.kt | 2 +- .../operator-call/p-4/neg/1.1.fir.kt | 4 +- .../p-17/neg/2.1.fir.kt | 6 +-- .../p-17/neg/2.2.fir.kt | 6 +-- 138 files changed, 415 insertions(+), 372 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/safeCall.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/ambiguityOnJavaOverride.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/ambiguityOnJavaOverride.kt index 616ba08d947..ac36f03e9f6 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/ambiguityOnJavaOverride.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/ambiguityOnJavaOverride.kt @@ -15,5 +15,5 @@ class B : A() { } fun test(b: B) { - b.foo("") + b.foo("") } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/default.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/default.kt index d9ac68a53ae..bf5a1904af2 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/default.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/default.kt @@ -8,19 +8,19 @@ fun test() { foo(1, 2.0, true) foo(1, third = true) - foo() - foo(0, 0.0, false, "") + foo() + foo(0, 0.0, false, "") bar(1, third = true) bar(1, 2.0, true) bar(1, 2.0, true, "my") - bar(1, true) + bar(1, true) baz(1) baz(1, "my", "yours") baz(1, z = true) - baz(0, "", false) + baz(0, "", false) } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/defaultFromOverrides.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/defaultFromOverrides.kt index af4ff520d6b..6995c3c4d61 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/defaultFromOverrides.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/defaultFromOverrides.kt @@ -15,8 +15,8 @@ fun foo(a: A) { a.foo() a.foo(1) - a.bar() - a.bar("") + a.bar() + a.bar("") a.bar(y = 1) a.bar("", 2) } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.kt index 59b75b27414..0aa726d7740 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.kt @@ -17,9 +17,9 @@ fun test_1() { } fun test_2() { - takeInt(10000000000) + takeInt(10000000000) takeLong(10000000000) - takeByte(1000) + takeByte(1000) } fun test_3() { @@ -35,8 +35,8 @@ fun test_4() { } fun test_5() { - takeString(1) - takeString(run { 1 }) + takeString(1) + takeString(run { 1 }) } annotation class Ann(val x: Byte) diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/javaArrayVariance.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/javaArrayVariance.kt index b6916223877..5972c59efdb 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/javaArrayVariance.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/javaArrayVariance.kt @@ -13,6 +13,6 @@ fun takeOutA(array: Array) {} fun test(array: Array) { A.take(array) - takeA(array) + takeA(array) takeOutA(array) } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/lambda.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/lambda.kt index 99f98ae6f6c..efbfd0fe827 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/lambda.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/lambda.kt @@ -10,8 +10,8 @@ fun test() { foo({}) // Bad - foo(1) {} - foo(f = {}) {} + foo(1) {} + foo(f = {}) {} // OK bar(1) {} @@ -20,15 +20,15 @@ fun test() { bar(x = 1, f = {}) // Bad - bar {} - bar({}) + bar {} + bar({}) // OK baz(other = false, f = {}) baz({}, false) // Bad - baz {} - baz() {} - baz(other = false) {} + baz {} + baz() {} + baz(other = false) {} } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/lambdaInUnresolvedCall.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/lambdaInUnresolvedCall.kt index f867a56997e..99ee3e6cfa0 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/lambdaInUnresolvedCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/lambdaInUnresolvedCall.kt @@ -1,14 +1,14 @@ fun materialize(): R = null!! fun test_1() { - myRun { + myRun { val x = 1 x * 2 - } + } } fun test_2() { - myRun { + myRun { materialize() - } + } } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/operatorsOverLiterals.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/operatorsOverLiterals.kt index 445ecf3ff4d..242b333b0a0 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/operatorsOverLiterals.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/operatorsOverLiterals.kt @@ -31,33 +31,33 @@ fun test_3() { fun takeByte(b: Byte) {} fun test_4() { - takeByte(1 + 1) - takeByte(1 + 127) - takeByte(1 - 1) - takeByte(-100 - 100) - takeByte(10 * 10) - takeByte(100 * 100) - taleByte(10 / 10) - takeByte(100 % 10) - takeByte(1000 % 10) - takeByte(1000 and 100) - takeByte(128 and 511) - takeByte(100 or 100) - takeByte(1000 or 0) - takeByte(511 xor 511) - takeByte(512 xor 511) + takeByte(1 + 1) + takeByte(1 + 127) + takeByte(1 - 1) + takeByte(-100 - 100) + takeByte(10 * 10) + takeByte(100 * 100) + taleByte(10 / 10) + takeByte(100 % 10) + takeByte(1000 % 10) + takeByte(1000 and 100) + takeByte(128 and 511) + takeByte(100 or 100) + takeByte(1000 or 0) + takeByte(511 xor 511) + takeByte(512 xor 511) } fun test_5() { takeByte(-1) takeByte(+1) - takeByte(1.inv()) + takeByte(1.inv()) } fun test_6() { - takeByte(run { 127 + 1 }) - takeByte(1 + run { 1 }) - takeByte(run { 1 + 1 }) + takeByte(run { 127 + 1 }) + takeByte(1 + run { 1 }) + takeByte(run { 1 + 1 }) 1 + 1 run { 1 } 1 + run { 1 } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/simple.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/simple.kt index d669fd5ef8a..737e67d3b8e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/simple.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/simple.kt @@ -7,11 +7,11 @@ fun test() { foo(1, second = 3.14, third = false, fourth = "!?") foo(third = false, second = 2.71, fourth = "?!", first = 0) - foo() - foo(0.0, false, 0, "") + foo() + foo(0.0, false, 0, "") foo(1, 2.0, third = true, "") - foo(second = 0.0, first = 0, fourth = "") - foo(first = 0.0, second = 0, third = "", fourth = false) - foo(first = 0, second = 0.0, third = false, fourth = "", first = 1) - foo(0, 0.0, false, foth = "") + foo(second = 0.0, first = 0, fourth = "") + foo(first = 0.0, second = 0, third = "", fourth = false) + foo(first = 0, second = 0.0, third = false, fourth = "", first = 1) + foo(0, 0.0, false, foth = "") } diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/vararg.kt b/compiler/fir/analysis-tests/testData/resolve/arguments/vararg.kt index ecafa19ebb0..f42aee5067d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/vararg.kt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/vararg.kt @@ -7,11 +7,11 @@ fun test() { foo(1, "my", "yours") foo(1, *arrayOf("my", "yours")) - foo("") - foo(1, 2) + foo("") + foo(1, 2) bar(1, z = true, y = *arrayOf("my", "yours")) - bar(0, z = false, y = "", y = "other") - bar(0, "", true) + bar(0, z = false, y = "", y = "other") + bar(0, "", true) } diff --git a/compiler/fir/analysis-tests/testData/resolve/asImports.kt b/compiler/fir/analysis-tests/testData/resolve/asImports.kt index 33826641a61..8847a4c7fc4 100644 --- a/compiler/fir/analysis-tests/testData/resolve/asImports.kt +++ b/compiler/fir/analysis-tests/testData/resolve/asImports.kt @@ -11,9 +11,9 @@ class A { import foo.A as B fun test_1() { - val a = A() + val a = A() val b = B() // should be OK - val c: B = A() + val c: B = A() } fun test_2(b: B) { diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/errorCandidates.kt b/compiler/fir/analysis-tests/testData/resolve/callResolution/errorCandidates.kt index 8ce85a18c6e..390901c0302 100644 --- a/compiler/fir/analysis-tests/testData/resolve/callResolution/errorCandidates.kt +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/errorCandidates.kt @@ -9,11 +9,11 @@ fun bar(x: B) {} fun test(c: C) { // Argument mapping error - foo("") + foo("") // Ambiguity - bar(c) + bar(c) // Unresolved reference - baz() + baz() } diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/lambdaAsReceiver.kt b/compiler/fir/analysis-tests/testData/resolve/callResolution/lambdaAsReceiver.kt index c6cc6917af0..543f908a55b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/callResolution/lambdaAsReceiver.kt +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/lambdaAsReceiver.kt @@ -9,6 +9,6 @@ fun main1() { } fun main2() { - { "" }.bar() + { "" }.bar() "".bar() } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.kt b/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.kt index be90f5a38d6..f91d92380d2 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.kt +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/flowFromInplaceLambda.kt @@ -19,7 +19,7 @@ fun test_2(x: Any, y: Any) { val a = select( id( run { - y.inc() // Bad + y.inc() // Bad x as Int } ), @@ -39,14 +39,14 @@ fun test_3(x: Any, y: Any) { val a = select( id( run { - y.inc() // Bad + y.inc() // Bad x as Int materialize() } ), run { y as Int - x.inc() // Bad + x.inc() // Bad y.inc() // OK 1 } @@ -60,19 +60,19 @@ fun test_4(x: Any, y: Any) { val a = select( id( myRun { - y.inc() // Bad + y.inc() // Bad x as Int } ), y as Int, myRun { - x.inc() // Bad + x.inc() // Bad y.inc() // OK 1 } ) - takeInt(x) // Bad + takeInt(x) // Bad takeInt(y) // OK takeInt(a) // Bad } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/abstractSuperCall.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/abstractSuperCall.kt index 18abcc097c6..4c7e16469db 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/abstractSuperCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/abstractSuperCall.kt @@ -22,7 +22,7 @@ class B : A() { } fun g() { - super.f() + super.f() super.t() super.x @@ -32,7 +32,7 @@ class B : A() { abstract class J : A() { fun r() { - super.f() + super.f() super.t() super.x diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/abstractSuperCallInPresenseOfNonAbstractMethodInParent.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/abstractSuperCallInPresenseOfNonAbstractMethodInParent.kt index 9ad38609849..23e7fc1dfcb 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/abstractSuperCallInPresenseOfNonAbstractMethodInParent.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/abstractSuperCallInPresenseOfNonAbstractMethodInParent.kt @@ -13,5 +13,5 @@ open class B { class A : IWithToString, B() { override fun toString(): String = super.toString() // resolve to Any.toString override fun foo(): String = super.foo() // resolve to B.foo() - override fun bar(): String = super.bar() // should be an error + override fun bar(): String = super.bar() // should be an error } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt index 3e0bcb593bf..120b6037dca 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt @@ -63,5 +63,5 @@ class M { } class U : M { - constructor() + constructor() } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt index 89391c3f554..2aa050d6cd7 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt @@ -3,16 +3,16 @@ class A(x: Int) { } class B : A { - constructor() + constructor() constructor(z: String) : this() } class C : A(20) { - constructor() + constructor() constructor(z: String) : this() } class D() : A(20) { - constructor(x: Int) + constructor(x: Int) constructor(z: String) : this() } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt index ecc452d60ca..bd69a862cac 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt @@ -1,5 +1,5 @@ class A { - constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} + constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} fun getSomeInt() = 10 var keker = "test" } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.kt index 4e8a13c2ee7..7d5354dc497 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.kt @@ -4,7 +4,7 @@ class A { class B : A { fun g() { - super.f() + super.f() super.f() } } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.kt index f0f7d5dc473..c4717ff1394 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.kt @@ -1,3 +1,3 @@ sealed class A -val b = A() +val b = A() diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt index 22f7caf5bcd..f41d78a6551 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt @@ -4,7 +4,7 @@ class B: A() { fun act() { super() - invoke() + invoke() super { println('weird') diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.kt index 1ca40411257..62de59fefa9 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superNotAvailable.kt @@ -1,20 +1,20 @@ fun String.f() { - super@f.compareTo("") - super.compareTo("") + super@f.compareTo("") + super.compareTo("") } fun foo() { super - super.foo() - super.foo() + super.foo() + super.foo() } class A { fun act() { - println("Test") + println("Test") } fun String.fact() { - println("Fest") + println("Fest") } } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.kt index c01d19b07bc..796fdcbfc0d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.kt @@ -17,8 +17,8 @@ object Best { } -val a = rest.MyClass -val b = Best.MyClass +val a = rest.MyClass +val b = Best.MyClass class B class C<Boolean>> : B<F<Boolean>>() diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt index 9e0ce9dcbfc..82d44bb7e8b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt @@ -45,4 +45,4 @@ val test8 = NL() class NumberPhile(x: T) val np1 = NumberPhile(10) -val np2 = NumberPhile("Test") +val np2 = NumberPhile("Test") diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_enumJava.kt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_enumJava.kt index 463216e5e5f..07ab6b5a49d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_enumJava.kt +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_enumJava.kt @@ -10,13 +10,13 @@ fun test_1(e: JavaEnum) { val a = when (e) { JavaEnum.A -> 1 JavaEnum.B -> 2 - }.plus(0) + }.plus(0) val b = when (e) { JavaEnum.A -> 1 JavaEnum.B -> 2 is String -> 3 - }.plus(0) + }.plus(0) val c = when (e) { JavaEnum.A -> 1 @@ -35,7 +35,7 @@ fun test_2(e: JavaEnum?) { JavaEnum.A -> 1 JavaEnum.B -> 2 JavaEnum.C -> 3 - }.plus(0) + }.plus(0) val a = when (e) { JavaEnum.A -> 1 diff --git a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.kt b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.kt index 9beeb8a7276..e7c9a2027b2 100644 --- a/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.kt +++ b/compiler/fir/analysis-tests/testData/resolve/exhaustiveness/positive/exhaustiveness_sealedSubClass.kt @@ -35,18 +35,18 @@ fun test_2(e: A) { val a = when (e) { is D -> 1 is E -> 2 - }.plus(0) + }.plus(0) val b = when (e) { is B -> 1 is D -> 2 is E -> 3 - }.plus(0) + }.plus(0) val c = when (e) { is B -> 1 is D -> 2 - }.plus(0) + }.plus(0) val d = when (e) { is C -> 1 diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/CallBasedInExpressionGenerator.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/CallBasedInExpressionGenerator.kt index 7fa0c9cc927..abb4cda0e57 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/CallBasedInExpressionGenerator.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/CallBasedInExpressionGenerator.kt @@ -14,27 +14,27 @@ class CallBasedInExpressionGenerator( val codegen: ExpressionCodegen, operatorReference: KtSimpleNameExpression ) : InExpressionGenerator { - private val resolvedCall = operatorReference.getResolvedCallWithAssert(codegen.bindingContext) - private val isInverted = operatorReference.getReferencedNameElementType() == KtTokens.NOT_IN + private val resolvedCall = operatorReference.getResolvedCallWithAssert(codegen.bindingContext) + private val isInverted = operatorReference.getReferencedNameElementType() == KtTokens.NOT_IN override fun generate(argument: StackValue): BranchedValue = - gen(argument).let { if (isInverted) Invert(it) else it } + gen(argument).let { if (isInverted) Invert(it) else it } private fun gen(argument: StackValue): BranchedValue = object : BranchedValue(argument, null, argument.type, Opcodes.IFEQ) { override fun putSelector(type: Type, kotlinType: KotlinType?, v: InstructionAdapter) { invokeFunction(v) - coerceTo(type, kotlinType, v) + coerceTo(type, kotlinType, v) } override fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) { invokeFunction(v) - v.visitJumpInsn(if (jumpIfFalse) Opcodes.IFEQ else Opcodes.IFNE, jumpLabel) + v.visitJumpInsn(if (jumpIfFalse) Opcodes.IFEQ else Opcodes.IFNE, jumpLabel) } private fun invokeFunction(v: InstructionAdapter) { - val result = codegen.invokeFunction(resolvedCall.call, resolvedCall, none()) - result.put(result.type, result.kotlinType, v) + val result = codegen.invokeFunction(resolvedCall.call, resolvedCall, none()) + result.put(result.type, result.kotlinType, v) } } } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/access.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/access.kt index 88236e7ebc8..ead6b21eda9 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/access.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/access.kt @@ -43,7 +43,7 @@ fun f() { val d = "" val c = c - abc() + abc() fun bcd() {} @@ -57,7 +57,7 @@ fun f() { dcb() } - dcb() + dcb() abc() } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/baseQualifier.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/baseQualifier.kt index cbc2599b9f9..8df28862e89 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/baseQualifier.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/baseQualifier.kt @@ -20,6 +20,6 @@ fun test() { JavaClass.bar() val errC = BB.C - val errBarViaBB = BB.bar() - val errBarViaAA = AA.bar() + val errBarViaBB = BB.bar() + val errBarViaAA = AA.bar() } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/enumEntryUse.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/enumEntryUse.kt index e20e2c8f8e4..a9d5bb7a440 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/enumEntryUse.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/enumEntryUse.kt @@ -18,5 +18,5 @@ fun test() { useEnum(TestEnum.THIRD) useVararg(TestEnum.FIRST, TestEnum.SECOND) - useVararg(1, 2, 3, 4, 5) + useVararg(1, 2, 3, 4, 5) } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/inference/typeParameters.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/inference/typeParameters.kt index ad6516e7254..651ca4c1e6f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/inference/typeParameters.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/inference/typeParameters.kt @@ -7,5 +7,5 @@ fun foo(t: T) = t fun main(fooImpl: FooImpl, bar: Bar) { val a = foo(fooImpl) - val b = foo(bar) + val b = foo(bar) } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/inference/typeParameters2.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/inference/typeParameters2.kt index a44c5a04324..f4bf4ac52f5 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/inference/typeParameters2.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/inference/typeParameters2.kt @@ -6,6 +6,6 @@ fun foo(t: T) = t fun main(fooImpl: FooImpl, fooBarImpl: FooBarImpl) { - val a = foo(fooBarImpl) + val a = foo(fooBarImpl) val b = foo(fooImpl) } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/invoke/threeReceivers.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/invoke/threeReceivers.kt index 50171203e9a..e5081adbb98 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/invoke/threeReceivers.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/invoke/threeReceivers.kt @@ -17,6 +17,6 @@ class Foo { // this@Foo is dispatch receiver of foobar // Foo/foobar is dispatch receiver of invoke // this@chk is extension receiver of invoke - buz.foobar() + buz.foobar() } } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt index cf10589374f..a90af6e1282 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt @@ -18,4 +18,4 @@ fun test() { B.foo() } -val bb = B.foo() +val bb = B.foo() diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/nestedVisibility.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/nestedVisibility.kt index 960d7239e02..73ed9de9800 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/nestedVisibility.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/nestedVisibility.kt @@ -11,8 +11,8 @@ open class Outer { class Derived : Outer() { fun foo() { - Outer.PrivateNested() - super.PrivateInner() + Outer.PrivateNested() + super.PrivateInner() Outer.ProtectedNested() super.ProtectedInner() @@ -23,11 +23,11 @@ class Derived : Outer() { } fun foo() { - Outer.PrivateNested() - Outer().PrivateInner() + Outer.PrivateNested() + Outer().PrivateInner() - Outer.ProtectedNested() - Outer().ProtectedInner() + Outer.ProtectedNested() + Outer().ProtectedInner() Outer.PublicNested() Outer().PublicInner() diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/privateVisibility.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/privateVisibility.kt index f1426b42391..c61aef1fbcf 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/privateVisibility.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/privateVisibility.kt @@ -9,21 +9,21 @@ private class Private { bar() Nested() fromCompanion() - NotCompanion.foo() // hidden + NotCompanion.foo() // hidden } inner class Inner { fun foo() { bar() fromCompanion() - NotCompanion.foo() // hidden + NotCompanion.foo() // hidden } } private class Nested { fun foo() { fromCompanion() - NotCompanion.foo() // hidden + NotCompanion.foo() // hidden } } @@ -54,7 +54,7 @@ fun withLocals() { Local().baz() - Local().bar() // hidden + Local().bar() // hidden } fun test() { @@ -62,14 +62,14 @@ fun test() { Private().baz() Private().Inner() - Private().bar() // hidden - Private.Nested() // hidden - Private.fromCompanion() // hidden + Private().bar() // hidden + Private.Nested() // hidden + Private.fromCompanion() // hidden } // FILE: second.kt fun secondTest() { - foo() // hidden - Private() // hidden + foo() // hidden + Private() // hidden } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/protectedVisibility.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/protectedVisibility.kt index 537f0fd2009..f27cce779d2 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/protectedVisibility.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/protectedVisibility.kt @@ -31,7 +31,7 @@ class Derived : Protected() { fun foo() { bar() Nested().foo() - Nested().bar() // hidden + Nested().bar() // hidden fromCompanion() protectedFromCompanion() @@ -48,8 +48,8 @@ fun test() { Protected().baz() Protected().Inner() - Protected().bar() // hidden - Protected.Nested() // hidden + Protected().bar() // hidden + Protected.Nested() // hidden } open class Generic(val x: T) { diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/receiverConsistency.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/receiverConsistency.kt index 86ab1c8ab94..e95a3e3bf6a 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/receiverConsistency.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/receiverConsistency.kt @@ -6,7 +6,7 @@ class C { class Nested { fun test() { - err() + err() } } } @@ -17,5 +17,5 @@ fun test() { c.bar() val err = C() - err.foo() + err.foo() } diff --git a/compiler/fir/analysis-tests/testData/resolve/fromBuilder/enums.kt b/compiler/fir/analysis-tests/testData/resolve/fromBuilder/enums.kt index 0e6ac864eb4..b651fd02343 100644 --- a/compiler/fir/analysis-tests/testData/resolve/fromBuilder/enums.kt +++ b/compiler/fir/analysis-tests/testData/resolve/fromBuilder/enums.kt @@ -9,17 +9,17 @@ enum class Order { enum class Planet(val m: Double, internal val r: Double) { MERCURY(1.0, 2.0) { override fun sayHello() { - println("Hello!!!") + println("Hello!!!") } }, VENERA(3.0, 4.0) { override fun sayHello() { - println("Ola!!!") + println("Ola!!!") } }, EARTH(5.0, 6.0) { override fun sayHello() { - println("Privet!!!") + println("Privet!!!") } }; diff --git a/compiler/fir/analysis-tests/testData/resolve/incorrectSuperCall.kt b/compiler/fir/analysis-tests/testData/resolve/incorrectSuperCall.kt index 50c694c5335..923a96486fc 100644 --- a/compiler/fir/analysis-tests/testData/resolve/incorrectSuperCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/incorrectSuperCall.kt @@ -15,7 +15,7 @@ class C : A, B() { override fun foo() { super.foo() - super.bar() // should be ambiguity (NB: really we should have overridden bar in C) + super.bar() // should be ambiguity (NB: really we should have overridden bar in C) super.baz() // Ok baz() // Ok diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/nullableIntegerLiteralType.kt b/compiler/fir/analysis-tests/testData/resolve/inference/nullableIntegerLiteralType.kt index 51b826f6b5a..14fcd4dd0ff 100644 --- a/compiler/fir/analysis-tests/testData/resolve/inference/nullableIntegerLiteralType.kt +++ b/compiler/fir/analysis-tests/testData/resolve/inference/nullableIntegerLiteralType.kt @@ -4,10 +4,10 @@ fun takeInt(x: Int) {} fun test_1(b: Boolean) { val x = if (b) 1 else null - takeInt(x) + takeInt(x) } fun test_2(b: Boolean, y: Int) { val x = if (b) y else null - takeInt(x) + takeInt(x) } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.kt b/compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.kt index 281eb062606..0a52fd88247 100644 --- a/compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.kt +++ b/compiler/fir/analysis-tests/testData/resolve/inference/receiverWithCapturedType.kt @@ -24,7 +24,7 @@ fun test_1_3(resolvedCall: ResolvedCall) { } fun test_2_1(resolvedCall: ResolvedCall, d: CallableDescriptor) { - val x = resolvedCall.updateD(d) // should fail + val x = resolvedCall.updateD(d) // should fail } fun test_2_2(resolvedCall: ResolvedCall, d: CallableDescriptor) { diff --git a/compiler/fir/analysis-tests/testData/resolve/innerClasses/inner.kt b/compiler/fir/analysis-tests/testData/resolve/innerClasses/inner.kt index 1c6aaf68ba1..d6758a13e51 100644 --- a/compiler/fir/analysis-tests/testData/resolve/innerClasses/inner.kt +++ b/compiler/fir/analysis-tests/testData/resolve/innerClasses/inner.kt @@ -23,7 +23,7 @@ class Owner { o.foo() foo() this@Owner.foo() - this.err() + this.err() } } } @@ -31,8 +31,8 @@ class Owner { fun test() { val o = Owner() o.foo() - val err = Owner.Inner() - err.baz() + val err = Owner.Inner() + err.baz() val i = o.Inner() i.gau() } diff --git a/compiler/fir/analysis-tests/testData/resolve/innerClasses/innerTypes.kt b/compiler/fir/analysis-tests/testData/resolve/innerClasses/innerTypes.kt index 8c866732348..6e298256607 100644 --- a/compiler/fir/analysis-tests/testData/resolve/innerClasses/innerTypes.kt +++ b/compiler/fir/analysis-tests/testData/resolve/innerClasses/innerTypes.kt @@ -12,10 +12,10 @@ val rr = Outer().Inner() val rrq = Boxed().substitute() fun check() { - accept(Outer().Inner()) // illegal - accept(Outer().Inner()) // illegal + accept(Outer().Inner()) // illegal + accept(Outer().Inner()) // illegal accept(Outer().Inner()) // ok - accept(Boxed().substitute()) // illegal + accept(Boxed().substitute()) // illegal accept(Boxed().substitute()) // ok } diff --git a/compiler/fir/analysis-tests/testData/resolve/innerClasses/simple.kt b/compiler/fir/analysis-tests/testData/resolve/innerClasses/simple.kt index 0046ca0b2b2..d10a2c4c0f0 100644 --- a/compiler/fir/analysis-tests/testData/resolve/innerClasses/simple.kt +++ b/compiler/fir/analysis-tests/testData/resolve/innerClasses/simple.kt @@ -22,8 +22,8 @@ class Owner { } fun err() { - foo() - this.foo() + foo() + this.foo() } } } diff --git a/compiler/fir/analysis-tests/testData/resolve/kt41984.kt b/compiler/fir/analysis-tests/testData/resolve/kt41984.kt index 41180d7f030..e693f6acce1 100644 --- a/compiler/fir/analysis-tests/testData/resolve/kt41984.kt +++ b/compiler/fir/analysis-tests/testData/resolve/kt41984.kt @@ -26,6 +26,6 @@ open class B : A() { fun test_1(b: B, x: Int, inv: Inv) { b.take(x) - b.take(null) + b.take(null) b.takeInv(inv) } diff --git a/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.kt b/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.kt index 6cbf919f1ec..16b0ad25478 100644 --- a/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.kt +++ b/compiler/fir/analysis-tests/testData/resolve/lambdaArgInScopeFunction.kt @@ -21,7 +21,7 @@ fun case1(kotlinClass: KotlinClass?) { {it} } - lambda.checkType { _>() } + lambda.checkType { _>() } } // TESTCASE NUMBER: 2 fun case2(kotlinClass: KotlinClass) { @@ -36,5 +36,5 @@ fun case2(kotlinClass: KotlinClass) { {it} } - lambda.checkType { _>() } + lambda.checkType { _>() } } diff --git a/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.kt b/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.kt index 03ce460d5d4..8bae96c5e36 100644 --- a/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.kt +++ b/compiler/fir/analysis-tests/testData/resolve/lambdaPropertyTypeInference.kt @@ -26,9 +26,9 @@ fun case1(javaClass: JavaClass?) { validType.checkType { _>() } //ok - invalidType.checkType { _>() } //(!!!) + invalidType.checkType { _>() } //(!!!) - Case1(javaClass).x.checkType { _>() } //(!!!) + Case1(javaClass).x.checkType { _>() } //(!!!) } class Case1(val javaClass: JavaClass?) { @@ -55,9 +55,9 @@ fun case2(kotlinClass: KotlinClass?) { validType.checkType { _>() } //ok - invalidType.checkType { _>() } //(!!!) + invalidType.checkType { _>() } //(!!!) - Case2(kotlinClass).x.checkType { _>() } //(!!!) + Case2(kotlinClass).x.checkType { _>() } //(!!!) } class Case2(val kotlinClass: KotlinClass?) { diff --git a/compiler/fir/analysis-tests/testData/resolve/nestedClassContructor.kt b/compiler/fir/analysis-tests/testData/resolve/nestedClassContructor.kt index 0f5bdbfd63e..076512e710a 100644 --- a/compiler/fir/analysis-tests/testData/resolve/nestedClassContructor.kt +++ b/compiler/fir/analysis-tests/testData/resolve/nestedClassContructor.kt @@ -17,7 +17,7 @@ class D : A.C() { val a = A() val ac = A.C() - val c = C() // shouldn't resolve + val c = C() // shouldn't resolve } } diff --git a/compiler/fir/analysis-tests/testData/resolve/overrides/simple.kt b/compiler/fir/analysis-tests/testData/resolve/overrides/simple.kt index a956ba7e5e9..f87bf8fb820 100644 --- a/compiler/fir/analysis-tests/testData/resolve/overrides/simple.kt +++ b/compiler/fir/analysis-tests/testData/resolve/overrides/simple.kt @@ -14,7 +14,7 @@ class B : A() { fun test() { foo() bar() - buz() + buz() } } diff --git a/compiler/fir/analysis-tests/testData/resolve/overrides/supertypeGenericsComplex.kt b/compiler/fir/analysis-tests/testData/resolve/overrides/supertypeGenericsComplex.kt index b7e5ab8f445..5fd73df0428 100644 --- a/compiler/fir/analysis-tests/testData/resolve/overrides/supertypeGenericsComplex.kt +++ b/compiler/fir/analysis-tests/testData/resolve/overrides/supertypeGenericsComplex.kt @@ -10,5 +10,5 @@ class C : Base() fun f(list: MutableList, s: MutableList) { C().f(list, s) - C().f(s, list) + C().f(s, list) } diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/definitelyNotNullAndOriginalType.kt b/compiler/fir/analysis-tests/testData/resolve/problems/definitelyNotNullAndOriginalType.kt index 384164d4d76..0230fdf919f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems/definitelyNotNullAndOriginalType.kt +++ b/compiler/fir/analysis-tests/testData/resolve/problems/definitelyNotNullAndOriginalType.kt @@ -11,5 +11,5 @@ public interface SLRUMap { // FILE: main.kt fun SLRUMap.getOrPut(value: V) { - takeV(value) + takeV(value) } diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/inaccessibleJavaGetter.kt b/compiler/fir/analysis-tests/testData/resolve/problems/inaccessibleJavaGetter.kt index c7645a90525..44ef3776643 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems/inaccessibleJavaGetter.kt +++ b/compiler/fir/analysis-tests/testData/resolve/problems/inaccessibleJavaGetter.kt @@ -20,7 +20,7 @@ class WrappedPropertyDescriptor : PropertyDescriptor { fun test() { val descriptor = WrappedPropertyDescriptor() val res1 = descriptor.setter - val res2 = descriptor.getSetter() // Should be error + val res2 = descriptor.getSetter() // Should be error val res3 = descriptor.isDelegated - val res4 = descriptor.isDelegated() // Should be error + val res4 = descriptor.isDelegated() // Should be error } diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/multipleJavaClassesInOneFile.kt b/compiler/fir/analysis-tests/testData/resolve/problems/multipleJavaClassesInOneFile.kt index 704db700550..1ba85216a6c 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems/multipleJavaClassesInOneFile.kt +++ b/compiler/fir/analysis-tests/testData/resolve/problems/multipleJavaClassesInOneFile.kt @@ -10,5 +10,5 @@ class Another {} fun test() { val some = Some() - val another = Another() + val another = Another() } diff --git a/compiler/fir/analysis-tests/testData/resolve/properties/syntheticPropertiesForJavaAnnotations.kt b/compiler/fir/analysis-tests/testData/resolve/properties/syntheticPropertiesForJavaAnnotations.kt index 0c98ff8eb99..30c39006a34 100644 --- a/compiler/fir/analysis-tests/testData/resolve/properties/syntheticPropertiesForJavaAnnotations.kt +++ b/compiler/fir/analysis-tests/testData/resolve/properties/syntheticPropertiesForJavaAnnotations.kt @@ -10,5 +10,5 @@ public @interface Ann { fun test(ann: Ann) { ann.value - ann.value() // should be an error + ann.value() // should be an error } diff --git a/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSamInferenceFromExpectType.kt b/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSamInferenceFromExpectType.kt index 2316e66886c..dda848e2b85 100644 --- a/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSamInferenceFromExpectType.kt +++ b/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSamInferenceFromExpectType.kt @@ -18,9 +18,9 @@ fun main() { x.toInt().toString() }) - foo2(MyFunction { x: Int -> + foo2(MyFunction { x: Int -> x.toString() - }) + }) foo3( MyFunction { x -> diff --git a/compiler/fir/analysis-tests/testData/resolve/samConstructors/realConstructorFunction.kt b/compiler/fir/analysis-tests/testData/resolve/samConstructors/realConstructorFunction.kt index b3fa3fb01dc..d2426e224ed 100644 --- a/compiler/fir/analysis-tests/testData/resolve/samConstructors/realConstructorFunction.kt +++ b/compiler/fir/analysis-tests/testData/resolve/samConstructors/realConstructorFunction.kt @@ -10,13 +10,13 @@ fun foo(m: MyRunnable) {} fun MyRunnable(x: (Int) -> Boolean) = 1 fun main() { - foo(MyRunnable { x -> + foo(MyRunnable { x -> x > 1 - }) + }) - foo(MyRunnable({ it > 1 })) + foo(MyRunnable({ it > 1 })) val x = { x: Int -> x > 1 } - foo(MyRunnable(x)) + foo(MyRunnable(x)) } diff --git a/compiler/fir/analysis-tests/testData/resolve/samConversions/genericSam.kt b/compiler/fir/analysis-tests/testData/resolve/samConversions/genericSam.kt index 78977c1f58b..c4eac6be67d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/samConversions/genericSam.kt +++ b/compiler/fir/analysis-tests/testData/resolve/samConversions/genericSam.kt @@ -21,9 +21,9 @@ fun main() { x.toInt().toString() } - JavaUsage.foo2 { x: Int -> + JavaUsage.foo2 { x: Int -> x.toString() - } + } JavaUsage.foo3( { x -> diff --git a/compiler/fir/analysis-tests/testData/resolve/samConversions/kotlinSam.kt b/compiler/fir/analysis-tests/testData/resolve/samConversions/kotlinSam.kt index cca6f7e9917..5fb027ccb83 100644 --- a/compiler/fir/analysis-tests/testData/resolve/samConversions/kotlinSam.kt +++ b/compiler/fir/analysis-tests/testData/resolve/samConversions/kotlinSam.kt @@ -29,11 +29,11 @@ fun main() { foo1 { x -> x > 1 } foo1(f) - foo2 { x -> x > 1 } - foo2(f) + foo2 { x -> x > 1 } + foo2(f) - foo3 { x -> x > 1 } - foo3(f) + foo3 { x -> x > 1 } + foo3(f) foo4 { x -> x > 1 } foo4(f) diff --git a/compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.kt b/compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.kt index da5d1c5b163..016843b8718 100644 --- a/compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.kt +++ b/compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.kt @@ -18,14 +18,14 @@ public class JavaUsage { fun foo(m: MyRunnable) {} fun main() { - JavaUsage.foo { + JavaUsage.foo { x -> x > 1 - } + } - JavaUsage.foo({ it > 1 }) + JavaUsage.foo({ it > 1 }) val x = { x: Int -> x > 1 } - JavaUsage.foo(x) + JavaUsage.foo(x) } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/booleanOperators.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/booleanOperators.kt index e45272656a6..4f293d49cd0 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/booleanOperators.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans/booleanOperators.kt @@ -24,8 +24,8 @@ fun test_1(x: Any) { fun test_2(x: Any) { if (x is B || x is C) { x.foo() - x.bar() - x.baz() + x.bar() + x.baz() } } @@ -59,26 +59,26 @@ fun test_6(x: Any) { fun test_7(x: Any) { if (x is A || false) { // TODO: should be smartcast - x.foo() + x.foo() } } fun test_8(x: Any) { if (false || x is A) { // TODO: should be smartcast - x.foo() + x.foo() } } fun test_9(x: Any) { if (x is A || true) { - x.foo() + x.foo() } } fun test_10(x: Any) { if (true || x is A) { - x.foo() + x.foo() } } @@ -86,7 +86,7 @@ fun test_10(x: Any) { fun test_11(x: Any, b: Boolean) { if (false && x is A) { - x.foo() + x.foo() } } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt index f6e34990a98..e7be4c1de50 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcasts.kt @@ -30,7 +30,7 @@ fun test_3(x: Any, y: Any) { } z = y if (y is B) { - z.foo() + z.foo() z.bar() } } @@ -40,7 +40,7 @@ fun test_4(y: Any) { x as Int x.inc() x = y - x.inc() + x.inc() if (y is A) { x.foo() y.foo() diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/casts.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/casts.kt index dfb08e48fb6..b8dadae553d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/casts.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/casts.kt @@ -15,31 +15,31 @@ fun test_3(b: Boolean, x: Any?) { if (b && x as Boolean) { x.not() } - x.not() + x.not() if (b && x as Boolean == true) { x.not() } - x.not() + x.not() if (b || x as Boolean) { - x.not() + x.not() } - x.not() + x.not() } fun test_4(b: Any) { if (b as? Boolean != null) { b.not() } else { - b.not() + b.not() } - b.not() + b.not() if (b as? Boolean == null) { - b.not() + b.not() } else { b.not() } - b.not() + b.not() } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returns.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returns.kt index 58f167ec50d..cacf8dcd98e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returns.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/controlStructures/returns.kt @@ -36,8 +36,8 @@ fun test_2(x: Any) { else -> return } x.foo() - x.bar() - x.baz() + x.bar() + x.baz() } fun test_3(x: Any) { @@ -45,9 +45,9 @@ fun test_3(x: Any) { x is B -> x.bar() x is C -> x.baz() } - x.foo() - x.bar() - x.baz() + x.foo() + x.bar() + x.baz() } fun runHigherOrder(f: () -> T): T = f() diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/endlessLoops.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/endlessLoops.kt index bc94abdb650..1776f00f971 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/endlessLoops.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/loops/endlessLoops.kt @@ -44,7 +44,7 @@ fun test_4(x: Any, b: Boolean) { } break } - x.foo() // No smartcast + x.foo() // No smartcast } fun test_5(x: Any, b: Boolean) { diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/orInWhenBranch.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/orInWhenBranch.kt index 50a6d0cc510..36f096e22e1 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/orInWhenBranch.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/orInWhenBranch.kt @@ -4,19 +4,19 @@ fun String.foo() {} fun test_1(a: Any?) { when (a) { - is String, is Any -> a.foo() // Should be Bad + is String, is Any -> a.foo() // Should be Bad } } fun test_2(a: Any?) { if (a is String || a is Any) { - a.foo() // Should be Bad + a.foo() // Should be Bad } } fun test_3(a: Any?, b: Boolean) { when (a) { - is String, b -> a.foo() // Should be Bad + is String, b -> a.foo() // Should be Bad } } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/implicitReceivers.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/implicitReceivers.kt index f13a9b24ca5..b1ddb729fcc 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/implicitReceivers.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/implicitReceivers.kt @@ -14,23 +14,23 @@ fun Any?.test_1() { this.foo() foo() } else { - this.foo() - foo() + this.foo() + foo() } - this.foo() - foo() + this.foo() + foo() } fun Any?.test_2() { if (this !is A) { - this.foo() - foo() + this.foo() + foo() } else { this.foo() foo() } - this.foo() - foo() + this.foo() + foo() } fun test_3(a: Any, b: Any, c: Any) { @@ -49,13 +49,13 @@ fun test_3(a: Any, b: Any, c: Any) { fun Any?.test_4() { if (this !is A) { - this.foo() - foo() - this.bar() - bar() + this.foo() + foo() + this.bar() + bar() } else if (this !is B) { - this.bar() - bar() + this.bar() + bar() this.foo() foo() } else { @@ -64,10 +64,10 @@ fun Any?.test_4() { this.bar() bar() } - this.foo() - foo() - this.bar() - bar() + this.foo() + foo() + this.bar() + bar() } fun Any.test_5(): Int = when { diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.kt index 83a74410769..3c681bde320 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/safeCalls.kt @@ -22,7 +22,7 @@ fun test_3(x: Any) { (x as? A)?.bar(x)?.foo(x.bool())?.let { x.bool() } - x.bool() + x.bool() } fun test_4(x: A?) { diff --git a/compiler/fir/analysis-tests/testData/resolve/typeAliasWithTypeArguments.kt b/compiler/fir/analysis-tests/testData/resolve/typeAliasWithTypeArguments.kt index 997d46d1aaa..5a6f706a61e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/typeAliasWithTypeArguments.kt +++ b/compiler/fir/analysis-tests/testData/resolve/typeAliasWithTypeArguments.kt @@ -42,7 +42,7 @@ fun test_2(inv: Inv2) { fun test_3(inv: Inv3) { inv.k().foo() - inv.t().bar() + inv.t().bar() inv.t().baz() } @@ -74,21 +74,21 @@ typealias Invariant1 = Invariant fun test_5(a: A, in1: In1, in2: In1, in3: In1) { in1.take(a) in2.take(a) - in3.take(a) + in3.take(a) } fun test_6(a: A, out1: Out1, out2: Out1, out3: Out1) { out1.value().foo() - out2.value().foo() + out2.value().foo() out3.value().foo() } fun test_7(a: A, inv1: Invariant1, inv2: Invariant1, inv3: Invariant1) { inv1.value().foo() - inv2.value().foo() + inv2.value().foo() inv3.value().foo() inv1.take(a) inv2.take(a) - inv3.take(a) + inv3.take(a) } diff --git a/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.kt b/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.kt index 5fc9f86fa4d..51a43a129e8 100644 --- a/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.kt +++ b/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.kt @@ -2,12 +2,12 @@ class A { companion object Comp {} fun foo() { - Comp() + Comp() } } object B { - private val x = B() + private val x = B() } class D { @@ -26,6 +26,6 @@ enum class E { }; fun foo() { - X() + X() } } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt index bb474ca35cb..17ef4ed5510 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/companions.kt @@ -31,16 +31,16 @@ fun main() { foo1(KotlinClass::baz) foo2(KotlinClass::baz) // Ambiguity (companion/class) - foo3(KotlinClass::baz) + foo3(KotlinClass::baz) // Type mismatch - foo1(KotlinClass::bar) + foo1(KotlinClass::bar) foo2(KotlinClass::bar) foo3(KotlinClass::bar) foo1(KotlinClass2::bar) // Type mismatch - foo2(KotlinClass2::bar) + foo2(KotlinClass2::bar) foo3(KotlinClass2::bar) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.kt index 4c5cb7ea24d..b2332695285 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/fromBasicDiagnosticTests/resolveCallableReferencesAfterAllSimpleArguments.kt @@ -7,6 +7,6 @@ fun bar(f: (T) -> Unit, e: T) {} fun baz(e: T, f: (T) -> Unit) {} fun test(a: A, b: B) { - baz(a, ::fooB) - bar(::fooB, a) + baz(a, ::fooB) + bar(::fooB, a) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.kt index 3d563c207fd..189e45d3611 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.kt @@ -3,5 +3,5 @@ fun use(x: (T) -> R): (T) -> R = x fun foo() = use(::bar) fun bar(x: String) = 1 -fun loop1() = use(::loop2) +fun loop1() = use(::loop2) fun loop2() = loop1() diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/javaStatic.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/javaStatic.kt index 04a617ff483..b3057626abe 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/javaStatic.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/javaStatic.kt @@ -16,5 +16,5 @@ fun foo3(x: (String) -> Int) {} fun main() { foo1(JavaClass::bar) foo2(JavaClass::bar) - foo3(JavaClass::bar) + foo3(JavaClass::bar) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt index 3ba452fd246..10944f406ca 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/manyInnermanyOuterCandidatesAmbiguity.kt @@ -6,5 +6,5 @@ fun bar(): Int = 1 fun bar(x: String): Int = 1 fun main() { - foo(::bar) + foo(::bar) } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/booleanOperators.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/booleanOperators.kt index 3029d26ca7b..e310196c7fe 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/booleanOperators.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/contracts/fromSource/good/returnsImplies/booleanOperators.kt @@ -59,8 +59,8 @@ fun test_2(x: Any) { fun test_3(x: Any) { myRequireOr(x is B, x is C) x.foo() // OK - x.bar() // Error - x.baz() // Error + x.bar() // Error + x.baz() // Error } fun test_4(x: Any) { diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/JavaVisibility2.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/JavaVisibility2.kt index 32b967e2377..46bc2d36099 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/JavaVisibility2.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/JavaVisibility2.kt @@ -27,8 +27,8 @@ class A { val p3 = JavaProtected().javaPProtectedPackage fun test() { - JavaProtected.javaMProtectedStatic() - JavaPackageLocal.javaMPackage() + JavaProtected.javaMProtectedStatic() + JavaPackageLocal.javaMPackage() } } @@ -39,7 +39,7 @@ class B : JavaProtected() { fun test() { JavaProtected.javaMProtectedStatic() - JavaPackageLocal.javaMPackage() + JavaPackageLocal.javaMPackage() } } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KJKComplexHierarchyWithNested.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KJKComplexHierarchyWithNested.kt index 99df059cf1c..e8c12d5cbf3 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KJKComplexHierarchyWithNested.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KJKComplexHierarchyWithNested.kt @@ -5,9 +5,9 @@ fun main(k: KSub, vString: SuperClass.NestedInSuperClass, vInt: SuperCla k.getImpl().nestedI(vString) // TODO: Support parametrisized inner classes - k.getImpl().nestedI(vInt) + k.getImpl().nestedI(vInt) k.getNestedSubClass().nested("") - k.getNestedSubClass().nested(1) + k.getNestedSubClass().nested(1) } // FILE: J1.java diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KotlinClassParameter.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KotlinClassParameter.kt index c9c89e70850..c2256f265e2 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KotlinClassParameter.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KotlinClassParameter.kt @@ -9,5 +9,5 @@ public class JavaClass { // FILE: K2.kt fun main() { JavaClass.baz(KotlinClass()) - JavaClass.baz("") + JavaClass.baz("") } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KotlinClassParameterGeneric.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KotlinClassParameterGeneric.kt index 972831a8220..970b06ffc7e 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KotlinClassParameterGeneric.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/KotlinClassParameterGeneric.kt @@ -10,6 +10,6 @@ public class JavaClass { fun main() { JavaClass.baz(KotlinClass()) JavaClass.baz(KotlinClass()) - JavaClass.baz(KotlinClass()) - JavaClass.baz("") + JavaClass.baz(KotlinClass()) + JavaClass.baz("") } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/KJKComplexHierarchyNestedLoop.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/KJKComplexHierarchyNestedLoop.kt index a28bf427821..151031d03c9 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/KJKComplexHierarchyNestedLoop.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/KJKComplexHierarchyNestedLoop.kt @@ -2,11 +2,11 @@ class K2: J1() { class Q : Nested() fun bar() { - foo() - baz() + foo() + baz() - superClass() - superI() + superClass() + superI() } } diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt index 6ca5292d888..0e24e36d23b 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/DiagnosticData.kt @@ -43,6 +43,7 @@ enum class PositioningStrategy(private val strategy: String) { VARIANCE_MODIFIER("VARIANCE_MODIFIER"), LATEINIT_MODIFIER("LATEINIT_MODIFIER"), SELECTOR_BY_QUALIFIED("SELECTOR_BY_QUALIFIED"), + REFERENCE_BY_QUALIFIED("REFERENCE_BY_QUALIFIED"), ; diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 3ca0d8635e2..a0b79fab942 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -45,10 +45,10 @@ object DIAGNOSTICS_LIST : DiagnosticList() { } val UNRESOLVED by object : DiagnosticGroup("Unresolved") { - val HIDDEN by error { + val HIDDEN by error(PositioningStrategy.REFERENCE_BY_QUALIFIED) { parameter>("hidden") } - val UNRESOLVED_REFERENCE by error { + val UNRESOLVED_REFERENCE by error(PositioningStrategy.REFERENCE_BY_QUALIFIED) { parameter("reference") } val UNRESOLVED_LABEL by error() @@ -62,7 +62,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() { val SUPER by object : DiagnosticGroup("Super") { val SUPER_IS_NOT_AN_EXPRESSION by error() val SUPER_NOT_AVAILABLE by error() - val ABSTRACT_SUPER_CALL by error() + val ABSTRACT_SUPER_CALL by error(PositioningStrategy.REFERENCE_BY_QUALIFIED) val INSTANCE_ACCESS_BEFORE_SUPER_CALL by error { parameter("target") } @@ -152,20 +152,21 @@ object DIAGNOSTICS_LIST : DiagnosticList() { } val APPLICABILITY by object : DiagnosticGroup("Applicability") { - val NONE_APPLICABLE by error { + val NONE_APPLICABLE by error(PositioningStrategy.REFERENCE_BY_QUALIFIED) { parameter>>("candidates") } - val INAPPLICABLE_CANDIDATE by error { + val INAPPLICABLE_CANDIDATE by error(PositioningStrategy.REFERENCE_BY_QUALIFIED) { parameter>("candidate") } + val INAPPLICABLE_LATEINIT_MODIFIER by error(PositioningStrategy.LATEINIT_MODIFIER) { parameter("reason") } } val AMBIGUIRY by object : DiagnosticGroup("Ambiguity") { - val AMBIGUITY by error { + val AMBIGUITY by error(PositioningStrategy.REFERENCE_BY_QUALIFIED) { parameter>>("candidates") } val ASSIGN_OPERATOR_AMBIGUITY by error { @@ -364,7 +365,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() { val UNSAFE_CALL by error(PositioningStrategy.DOT_BY_QUALIFIED) { parameter("receiverType") } - val UNSAFE_IMPLICIT_INVOKE_CALL by error { + val UNSAFE_IMPLICIT_INVOKE_CALL by error(PositioningStrategy.REFERENCE_BY_QUALIFIED) { parameter("receiverType") } val UNSAFE_INFIX_CALL by error { diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 30eb6beba1e..0c04d5c6dcc 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -63,8 +63,8 @@ object FirErrors { val DELEGATION_IN_INTERFACE by error0() // Unresolved - val HIDDEN by error1>() - val UNRESOLVED_REFERENCE by error1() + val HIDDEN by error1>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED) + val UNRESOLVED_REFERENCE by error1(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED) val UNRESOLVED_LABEL by error0() val DESERIALIZATION_ERROR by error0() val ERROR_FROM_JAVA_RESOLUTION by error0() @@ -75,7 +75,7 @@ object FirErrors { // Super val SUPER_IS_NOT_AN_EXPRESSION by error0() val SUPER_NOT_AVAILABLE by error0() - val ABSTRACT_SUPER_CALL by error0() + val ABSTRACT_SUPER_CALL by error0(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED) val INSTANCE_ACCESS_BEFORE_SUPER_CALL by error1() // Supertypes @@ -139,12 +139,12 @@ object FirErrors { val REDUNDANT_OPEN_IN_INTERFACE by warning0(SourceElementPositioningStrategies.OPEN_MODIFIER) // Applicability - val NONE_APPLICABLE by error1>>() - val INAPPLICABLE_CANDIDATE by error1>() + val NONE_APPLICABLE by error1>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED) + val INAPPLICABLE_CANDIDATE by error1>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED) val INAPPLICABLE_LATEINIT_MODIFIER by error1(SourceElementPositioningStrategies.LATEINIT_MODIFIER) // Ambiguity - val AMBIGUITY by error1>>() + val AMBIGUITY by error1>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED) val ASSIGN_OPERATOR_AMBIGUITY by error1>>() // Types & type parameters @@ -235,7 +235,7 @@ object FirErrors { // Nullability val UNSAFE_CALL by error1(SourceElementPositioningStrategies.DOT_BY_QUALIFIED) - val UNSAFE_IMPLICIT_INVOKE_CALL by error1() + val UNSAFE_IMPLICIT_INVOKE_CALL by error1(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED) val UNSAFE_INFIX_CALL by error3() val UNSAFE_OPERATOR_CALL by error3() diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt index d48905957ae..00b2921b796 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt @@ -347,6 +347,32 @@ object LightTreePositioningStrategies { } } + val REFERENCE_BY_QUALIFIED: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { + if (node.tokenType == KtNodeTypes.CALL_EXPRESSION || node.tokenType == KtNodeTypes.CONSTRUCTOR_DELEGATION_CALL) { + return markElement(tree.referenceExpression(node) ?: node, startOffset, endOffset, tree, node) + } + if (node.tokenType != KtNodeTypes.DOT_QUALIFIED_EXPRESSION && node.tokenType != KtNodeTypes.SAFE_ACCESS_EXPRESSION) { + return super.mark(node, startOffset, endOffset, tree) + } + val selector = tree.selector(node) + if (selector != null) { + when (selector.tokenType) { + KtNodeTypes.REFERENCE_EXPRESSION -> + return markElement(selector, startOffset, endOffset, tree, node) + KtNodeTypes.CALL_EXPRESSION, KtNodeTypes.CONSTRUCTOR_DELEGATION_CALL -> + return markElement(tree.referenceExpression(selector) ?: selector, startOffset, endOffset, tree, node) + } + } + return super.mark(node, startOffset, endOffset, tree) + } + } + val WHEN_EXPRESSION = object : LightTreePositioningStrategy() { override fun mark( node: LighterASTNode, @@ -400,6 +426,14 @@ private fun FlyweightCapableTreeStructure.nameIdentifier(node: L private fun FlyweightCapableTreeStructure.operationReference(node: LighterASTNode): LighterASTNode? = findChildByType(node, KtNodeTypes.OPERATION_REFERENCE) +private fun FlyweightCapableTreeStructure.referenceExpression(node: LighterASTNode): LighterASTNode? { + val childrenRef = Ref>() + getChildren(node, childrenRef) + return childrenRef.get()?.firstOrNull { + it?.tokenType == KtNodeTypes.REFERENCE_EXPRESSION || it?.tokenType == KtNodeTypes.CONSTRUCTOR_DELEGATION_REFERENCE + } +} + private fun FlyweightCapableTreeStructure.rightParenthesis(node: LighterASTNode): LighterASTNode? = findChildByType(node, KtTokens.RPAR) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt index 6e006527cb2..489dcb6b5d7 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt @@ -108,6 +108,11 @@ object SourceElementPositioningStrategies { PositioningStrategies.SELECTOR_BY_QUALIFIED ) + val REFERENCE_BY_QUALIFIED = SourceElementPositioningStrategy( + LightTreePositioningStrategies.REFERENCE_BY_QUALIFIED, + PositioningStrategies.REFERENCE_BY_QUALIFIED + ) + val WHEN_EXPRESSION = SourceElementPositioningStrategy( LightTreePositioningStrategies.WHEN_EXPRESSION, PositioningStrategies.WHEN_EXPRESSION diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt index 3848d8afb95..2d1cdd07752 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt @@ -732,4 +732,20 @@ object PositioningStrategies { return super.mark(element) } } + + val REFERENCE_BY_QUALIFIED: PositioningStrategy = object : PositioningStrategy() { + override fun mark(element: PsiElement): List { + when (element) { + is KtQualifiedExpression -> { + when (val selectorExpression = element.selectorExpression) { + is KtCallExpression -> return mark(selectorExpression.calleeExpression ?: selectorExpression) + is KtReferenceExpression -> return mark(selectorExpression) + } + } + is KtCallExpression -> return mark(element.calleeExpression ?: element) + is KtConstructorDelegationCall -> return mark(element.calleeExpression ?: element) + } + return super.mark(element) + } + } } diff --git a/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.fir.kt b/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.fir.kt index c067f6bb367..2da4f2f2f99 100644 --- a/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.fir.kt +++ b/compiler/testData/diagnostics/tests/DeprecatedGetSetPropertyDelegateConvention.fir.kt @@ -33,8 +33,8 @@ operator fun CustomDelegate3.setValue(thisRef: Any?, prop: KProperty<*>, value: class Example { - var a by CustomDelegate() - val aval by CustomDelegate() + var a by CustomDelegate() + val aval by CustomDelegate() var b by OkDelegate() var c by CustomDelegate2() var d by CustomDelegate3() diff --git a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt index 6a62617d900..29bae925d54 100644 --- a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.fir.kt @@ -28,20 +28,20 @@ fun fooT2() : (t : T) -> T { fun main(args : Array) { args.foo()() - args.foo1()() - a.foo1()() + args.foo1()() + a.foo1()() a.foo1()(a) args.foo1()(1) - args.foo1()("1") - a.foo1()("1") + args.foo1()("1") + a.foo1()("1") a.foo1()(a) foo2()({}) foo2(){} (foo2()){} - (foo2()){x -> } - foo2()({x -> }) + (foo2()){x -> } + foo2()({x -> }) val a = fooT1(1)() checkSubtype(a) @@ -50,25 +50,25 @@ fun main(args : Array) { checkSubtype(b) fooT2()(1) // : Any? - 1() - 1{} - 1(){} + 1() + 1{} + 1(){} } fun f() : Int.() -> Unit = {} fun main1() { - 1.(fun Int.() = 1)(); + 1.(fun Int.() = 1)(); {1}(); (fun (x : Int) = x)(1) - 1.(fun Int.(x : Int) = x)(1); + 1.(fun Int.(x : Int) = x)(1); l@{1}() - 1.((fun Int.() = 1))() - 1.(f())() - 1.if(true){f()}else{f()}() - 1.if(true)(fun Int.() {})else{f()}() + 1.((fun Int.() = 1))() + 1.(f())() + 1.if(true){f()}else{f()}() + 1.if(true)(fun Int.() {})else{f()}() - 1."sdf"() + 1."sdf"() 1."sdf" 1.{} @@ -76,12 +76,12 @@ fun main1() { } fun test() { - {x : Int -> 1}(); - (fun Int.() = 1)() - "sd".(fun Int.() = 1)() + {x : Int -> 1}(); + (fun Int.() = 1)() + "sd".(fun Int.() = 1)() val i : Int? = null - i.(fun Int.() = 1)(); - {}() - 1?.(fun Int.() = 1)() - 1.{}() + i.(fun Int.() = 1)(); + {}() + 1?.(fun Int.() = 1)() + 1.{}() } diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/field.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/field.fir.kt index f4bdfdadd4c..892c511bd7b 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/field.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/field.fir.kt @@ -28,7 +28,7 @@ abstract class My(@Field arg: Int, @Field val w: Int) { fun foo() {} @Field - val v: Int by Delegates.lazy { 42 } + val v: Int by Delegates.lazy { 42 } } enum class Your { diff --git a/compiler/testData/diagnostics/tests/callableReference/function/fakeOverrideType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/function/fakeOverrideType.fir.kt index 89bbbfa27c2..f2dac1b0c43 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/fakeOverrideType.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/fakeOverrideType.fir.kt @@ -13,5 +13,5 @@ class B : A() { fun test() { B::foo checkType { _>() } - (B::hashCode)("No.") + (B::hashCode)("No.") } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt index 28cae30c997..9a21bc9308d 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/fieldAsClassDelegate.fir.kt @@ -29,7 +29,7 @@ private fun lazy(init: () -> T): kotlin.Lazy { } object DefaultHttpClientWithBy : HttpClient by client { - val client by lazy { HttpClientImpl() } + val client by lazy { HttpClientImpl() } } object DefaultFqHttpClient : HttpClient by DefaultFqHttpClient.client { diff --git a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt index 5539b97ee64..7276f6c9207 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt @@ -11,7 +11,7 @@ fun test() { const val a3 = 0 lateinit val a4 = 0 val a5 by Delegate() - val a6 by Delegate<T>() + val a6 by Delegate<T>() } class Delegate { diff --git a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt index e86865131dd..8d09b2a5612 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt @@ -11,7 +11,7 @@ fun test() { const val a3 = 0 lateinit val a4 = 0 val a5 by Delegate() - val a6 by Delegate<T>() + val a6 by Delegate<T>() } class Delegate { diff --git a/compiler/testData/diagnostics/tests/declarationChecks/namedFunAsLastExpressionInBlock.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/namedFunAsLastExpressionInBlock.fir.kt index 991fc0fe076..7ad3ec07b8b 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/namedFunAsLastExpressionInBlock.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/namedFunAsLastExpressionInBlock.fir.kt @@ -45,7 +45,7 @@ fun test() { x4 checkType { _>() } { y: Int -> fun named14(): Int {return 1} } - val b = (fun named15(): Boolean { return true })() + val b = (fun named15(): Boolean { return true })() baz(fun named16(){}) } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.fir.kt index 12ee9c9e9e1..36688c7fa71 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.fir.kt @@ -5,10 +5,10 @@ import kotlin.reflect.KProperty class A class D { - val c: Int by IncorrectThis() + val c: Int by IncorrectThis() } -val cTopLevel: Int by IncorrectThis() +val cTopLevel: Int by IncorrectThis() class IncorrectThis { fun get(t: Any?, p: KProperty<*>): Int { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.fir.kt index a2b3d2a91a0..bbe1ab30618 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.fir.kt @@ -4,10 +4,10 @@ package foo import kotlin.reflect.KProperty open class A { - val B.w: Int by MyProperty() + val B.w: Int by MyProperty() } -val B.r: Int by MyProperty() +val B.r: Int by MyProperty() val A.e: Int by MyProperty() diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/manyIncompleteCandidates.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/manyIncompleteCandidates.fir.kt index 6fc5a1d7f20..9039756c190 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/manyIncompleteCandidates.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/manyIncompleteCandidates.fir.kt @@ -5,7 +5,7 @@ package test import first.* import second.* -val a12 by A() +val a12 by A() // FILE: first.kt package first diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/kt4640.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/kt4640.fir.kt index beac5cea63f..fb962e9965d 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/kt4640.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/kt4640.fir.kt @@ -8,4 +8,4 @@ class ValueWrapper() fun setValue(v: Int) { backingValue = v } } -val foo by ValueWrapper() +val foo by ValueWrapper() diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/missedGetter.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/missedGetter.fir.kt index 270badeb52d..2433947dafe 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/missedGetter.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/missedGetter.fir.kt @@ -1,3 +1,3 @@ -val a: Int by A() +val a: Int by A() class A diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.fir.kt index 7ad8d8e86df..90b54acd693 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.fir.kt @@ -5,7 +5,7 @@ import kotlin.reflect.KProperty class B { - val c by Delegate(ag) + val c by Delegate(ag) } class Delegate(val init: T) { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.fir.kt index 6fb1bd69fdd..840e8feb846 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.fir.kt @@ -10,5 +10,5 @@ object T2 { operator fun Foo.getValue(receiver: String, p: Any?): T = TODO() val String.test1: String by delegate() - val test2: String by delegate() + val test2: String by delegate() } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.fir.kt index 3a826e00878..a52285427e2 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.fir.kt @@ -4,7 +4,7 @@ import kotlin.reflect.KProperty class A { - var a: Int by Delegate() + var a: Int by Delegate() } var aTopLevel: Int by Delegate() diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.fir.kt index 405dee83558..69230fdcd4a 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.fir.kt @@ -4,10 +4,10 @@ import kotlin.reflect.KProperty class A { - var a: Int by Delegate() + var a: Int by Delegate() } -var aTopLevel: Int by Delegate() +var aTopLevel: Int by Delegate() class Delegate { fun getValue(t: Nothing, p: KProperty<*>): Int { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/twoGetMethods.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/twoGetMethods.fir.kt index d7a9c9067f1..b9cac34cd3c 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/twoGetMethods.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/twoGetMethods.fir.kt @@ -3,7 +3,7 @@ import kotlin.reflect.KProperty class A { - val c: Int by Delegate() + val c: Int by Delegate() } class Delegate { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetWithGeneric.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetWithGeneric.fir.kt index fc65950992f..aa603f3f806 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetWithGeneric.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetWithGeneric.fir.kt @@ -5,10 +5,10 @@ import kotlin.reflect.KProperty class A class B { - val b: Int by Delegate() + val b: Int by Delegate() } -val bTopLevel: Int by Delegate() +val bTopLevel: Int by Delegate() class C { val c: Int by Delegate() diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.fir.kt index 8058a494f55..41ba3d5bafe 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.fir.kt @@ -4,10 +4,10 @@ import kotlin.reflect.KProperty class B { - val b: Int by Delegate() + val b: Int by Delegate() } -val bTopLevel: Int by Delegate() +val bTopLevel: Int by Delegate() class A diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.fir.kt index 1a8e7d9ffb3..f9f35f93c16 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.fir.kt @@ -3,10 +3,10 @@ import kotlin.reflect.KProperty class A { - val a: Int by Delegate() + val a: Int by Delegate() } -val aTopLevel: Int by Delegate() +val aTopLevel: Int by Delegate() class Delegate { fun getValue(t: Any?, p: KProperty<*>, a: Int): Int { diff --git a/compiler/testData/diagnostics/tests/extensions/throwOutCandidatesByReceiver.fir.kt b/compiler/testData/diagnostics/tests/extensions/throwOutCandidatesByReceiver.fir.kt index 138db690973..5e36f04c40f 100644 --- a/compiler/testData/diagnostics/tests/extensions/throwOutCandidatesByReceiver.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/throwOutCandidatesByReceiver.fir.kt @@ -35,7 +35,7 @@ fun test4() { // should be an error on receiver, shouldn't be thrown away fun test5() { - 1.(fun String.()=1)() + 1.(fun String.()=1)() } fun R?.sure() : R = this!! diff --git a/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.fir.kt index 8111b18415b..85ce9597a68 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.fir.kt @@ -1,9 +1,9 @@ // !WITH_NEW_INFERENCE val receiver = { Int.() -> } -val receiverWithParameter = { Int.(a) -> } +val receiverWithParameter = { Int.(a) -> } val receiverAndReturnType = { Int.(): Int -> 5 } -val receiverAndReturnTypeWithParameter = { Int.(a: Int): Int -> 5 } +val receiverAndReturnTypeWithParameter = { Int.(a: Int): Int -> 5 } val returnType = { (): Int -> 5 } val returnTypeWithParameter = { (b: Int): Int -> 5 } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/kt6541_extensionForExtensionFunction.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/kt6541_extensionForExtensionFunction.fir.kt index db815efa470..64001baabe3 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/kt6541_extensionForExtensionFunction.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/kt6541_extensionForExtensionFunction.fir.kt @@ -7,4 +7,4 @@ object Z { infix fun add(b : Foo.() -> Unit) : Z = Z } -val t2 = Z add { } { } +val t2 = Z add { } { } diff --git a/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameInBlock.fir.kt b/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameInBlock.fir.kt index 26b87f01991..8d48bd43e6f 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameInBlock.fir.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameInBlock.fir.kt @@ -40,7 +40,7 @@ fun foo() { property1 = 1 val - propertyWithBy by lazy { 1 } + propertyWithBy by lazy { 1 } val propertyWithType: Int diff --git a/compiler/testData/diagnostics/tests/inference/invokeLambdaAsFunction.fir.kt b/compiler/testData/diagnostics/tests/inference/invokeLambdaAsFunction.fir.kt index 7d238420de8..89d7abf1986 100644 --- a/compiler/testData/diagnostics/tests/inference/invokeLambdaAsFunction.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/invokeLambdaAsFunction.fir.kt @@ -2,6 +2,6 @@ fun test1(i: Int) = { i -> i }(i) -fun test2() = { i -> i }() +fun test2() = { i -> i }() fun test3() = { i -> i }(1) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/kt435.fir.kt b/compiler/testData/diagnostics/tests/kt435.fir.kt index aec09116fa8..c24f1f89f78 100644 --- a/compiler/testData/diagnostics/tests/kt435.fir.kt +++ b/compiler/testData/diagnostics/tests/kt435.fir.kt @@ -3,5 +3,5 @@ fun Any.foo1() : (i : Int) -> Unit { } fun test(a : Any) { - a.foo1()() + a.foo1()() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/objects/Objects.fir.kt b/compiler/testData/diagnostics/tests/objects/Objects.fir.kt index fcaee4376e2..2b8bb4061c0 100644 --- a/compiler/testData/diagnostics/tests/objects/Objects.fir.kt +++ b/compiler/testData/diagnostics/tests/objects/Objects.fir.kt @@ -6,13 +6,13 @@ package toplevelObjectDeclarations class T : Foo {} - object A : Foo { + object A : Foo { val x : Int = 2 fun test() : Int { return x + foo() } - } + } object B : A {} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.fir.kt index 6b6b626d5a5..d8b760b83c7 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.fir.kt @@ -19,5 +19,5 @@ public class J { // FILE: k.kt var A by J.staticNN -var B by J.staticN +var B by J.staticN var C by J.staticJ \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/qualifiedExpression/calleeExpressionAsCallExpression.fir.kt b/compiler/testData/diagnostics/tests/qualifiedExpression/calleeExpressionAsCallExpression.fir.kt index bcc9b5931bc..e1d94c8f043 100644 --- a/compiler/testData/diagnostics/tests/qualifiedExpression/calleeExpressionAsCallExpression.fir.kt +++ b/compiler/testData/diagnostics/tests/qualifiedExpression/calleeExpressionAsCallExpression.fir.kt @@ -1,2 +1,2 @@ // !WITH_NEW_INFERENCE -val unwrapped = some<sdf()()::unwrap +val unwrapped = some<sdf()()::unwrap diff --git a/compiler/testData/diagnostics/tests/regressions/kt26303.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt26303.fir.kt index dbfa13fb0f5..39472371d47 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt26303.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt26303.fir.kt @@ -14,5 +14,5 @@ import foo.foo as invoke import foo.invoke fun main(args: Array) { - 42() + 42() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/ambiguityForInvoke.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/ambiguityForInvoke.fir.kt index dd3251bb346..ab2ff938366 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/ambiguityForInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/ambiguityForInvoke.fir.kt @@ -7,5 +7,5 @@ fun Int.invoke(a: Any, i: Int) {} fun foo(i: Int) { i(1, 1) - 5(1, 2) + 5(1, 2) } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/invisibleInvoke.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/invisibleInvoke.fir.kt index d11dc63cba4..46c0ce68894 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/invisibleInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/invisibleInvoke.fir.kt @@ -6,5 +6,5 @@ class My { fun My.foo(i: Int) { i("") - 1("") + 1("") } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.kt index 107f01d0c61..e02acf7781b 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/receiverPresenceErrorForInvoke.fir.kt @@ -7,5 +7,5 @@ fun test1(f: String.() -> Unit) { fun test2(f: (Int) -> Int) { 1.f(2) - 2.(f)(2) + 2.(f)(2) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/typeInferenceErrorForInvoke.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/typeInferenceErrorForInvoke.fir.kt index 0874328e546..40954777dd8 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/typeInferenceErrorForInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/typeInferenceErrorForInvoke.fir.kt @@ -10,5 +10,5 @@ fun foo(s: String, ai: A) { s(ai) - ""(ai) + ""(ai) } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/unresolvedInvoke.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/unresolvedInvoke.fir.kt index 0874f5b7d95..c42be06db89 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/unresolvedInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/unresolvedInvoke.fir.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION fun foo(i: Int) { i() - 1() + 1() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/unsafeCallWithInvoke.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/unsafeCallWithInvoke.fir.kt index 27539cd2175..cde534b69f7 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/unsafeCallWithInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/unsafeCallWithInvoke.fir.kt @@ -6,5 +6,5 @@ operator fun String.invoke(i: Int) {} fun foo(s: String?) { s(1) - (s ?: null)(1) + (s ?: null)(1) } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.kt index 85b8d534ef0..5a3559b9135 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverForInvokeOnExpression.fir.kt @@ -1,17 +1,17 @@ // !WITH_NEW_INFERENCE fun test1() { - 1. (fun String.(i: Int) = i )(1) - 1.(label@ fun String.(i: Int) = i )(1) + 1. (fun String.(i: Int) = i )(1) + 1.(label@ fun String.(i: Int) = i )(1) } fun test2(f: String.(Int) -> Unit) { - 11.(f)(1) - 11.(f)() + 11.(f)(1) + 11.(f)() } fun test3() { fun foo(): String.(Int) -> Unit = {} - 1.(foo())(1) + 1.(foo())(1) } diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverTypeForInvoke.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverTypeForInvoke.fir.kt index e99d2def1c2..e8d87240b9e 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverTypeForInvoke.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/errors/wrongReceiverTypeForInvoke.fir.kt @@ -6,5 +6,5 @@ fun String.invoke(i: Int) {} fun foo(i: Int) { i(1) - 1(1) + 1(1) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt index 41aeacd7829..8af8d45ccec 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/invokeAndSmartCast.fir.kt @@ -2,17 +2,17 @@ class A(val x: (String.() -> Unit)?) fun test(a: A) { if (a.x != null) { - "".(a.x)() + "".(a.x)() a.x("") // todo (a.x)("") } - "".(a.x)() + "".(a.x)() a.x("") - (a.x)("") + (a.x)("") with("") { a.x() - (a.x)() + (a.x)() if (a.x != null) { a.x() // todo (a.x)() diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/invokeOnVariableWithExtensionFunctionType.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/invokeOnVariableWithExtensionFunctionType.fir.kt index 52919c92464..2ee6ca48bc2 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/invokeOnVariableWithExtensionFunctionType.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/invokeOnVariableWithExtensionFunctionType.fir.kt @@ -8,7 +8,7 @@ class B val A.foo: B.() -> Unit get() = {} fun test(a: A, b: B) { - b.(a.foo)() + b.(a.foo)() (a.foo)(b) a.foo(b) @@ -17,7 +17,7 @@ fun test(a: A, b: B) { b.(foo)() - (b.foo)() + (b.foo)() foo(b) (foo)(b) @@ -25,7 +25,7 @@ fun test(a: A, b: B) { with(b) { a.foo() - a.(foo)() + a.(foo)() (a.foo)() @@ -50,7 +50,7 @@ class A { class B fun test(a: A, b: B) { - b.(a.foo)() + b.(a.foo)() (a.foo)(b) a.foo(b) @@ -59,7 +59,7 @@ fun test(a: A, b: B) { b.(foo)() - (b.foo)() + (b.foo)() foo(b) (foo)(b) @@ -67,7 +67,7 @@ fun test(a: A, b: B) { with(b) { a.foo() - a.(foo)() + a.(foo)() (a.foo)() diff --git a/compiler/testData/diagnostics/tests/safeCall.fir.kt b/compiler/testData/diagnostics/tests/safeCall.fir.kt deleted file mode 100644 index 6e02bc3303b..00000000000 --- a/compiler/testData/diagnostics/tests/safeCall.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -// !WITH_NEW_INFERENCE - -fun f(s: String, action: (String.() -> Unit)?) { - s.foo().bar().action() -} - -fun String.foo() = "" - -fun String.bar() = "" - -// -------------------------------------------------------- - -val functions: Map Any> = TODO() - -fun run(name: String) = functions[name]() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/safeCall.kt b/compiler/testData/diagnostics/tests/safeCall.kt index 66185463af1..3c822ca8f69 100644 --- a/compiler/testData/diagnostics/tests/safeCall.kt +++ b/compiler/testData/diagnostics/tests/safeCall.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !WITH_NEW_INFERENCE fun f(s: String, action: (String.() -> Unit)?) { diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt index 6f999a9d56c..dd21d05a845 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/headerCallChecker/operatorCall.fir.kt @@ -5,7 +5,7 @@ class D : C { { val s = "" s() - ""() + ""() 42 }()) diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.fir.kt index a91d28edfc5..dabba36c8a7 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.fir.kt @@ -2,6 +2,6 @@ open class A(p1: String) class B() : A("") { - constructor(s: String) { + constructor(s: String) { } } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/nestedExtendsInner.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/nestedExtendsInner.fir.kt index c0ca6c46513..478b4d07216 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/nestedExtendsInner.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/nestedExtendsInner.fir.kt @@ -2,6 +2,6 @@ class A { open inner class Inner class Nested : Inner { - constructor() + constructor() } } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt index 6c9596db92b..f2ab1ac6ddf 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt @@ -2,5 +2,5 @@ open class A(p1: String, p2: String, p3: String, p4: String, p5: String) class B : A { - constructor(s: String) + constructor(s: String) } diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/neg/1.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/neg/1.1.fir.kt index 456fc81b1a0..1190f320a02 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/neg/1.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/building-the-overload-candidate-set-ocs/operator-call/p-4/neg/1.1.fir.kt @@ -17,7 +17,7 @@ fun case1() { } class B() { - val p: String by Delegate() // DELEGATE_SPECIAL_FUNCTION_MISSING expected + val p: String by Delegate() // DELEGATE_SPECIAL_FUNCTION_MISSING expected } class Delegate { @@ -42,7 +42,7 @@ fun case2() { } class B() { - var p: String by Delegate() // DELEGATE_SPECIAL_FUNCTION_MISSING expected + var p: String by Delegate() // DELEGATE_SPECIAL_FUNCTION_MISSING expected } class Delegate { diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-17/neg/2.1.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-17/neg/2.1.fir.kt index 4db6e3767ce..7df09612c75 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-17/neg/2.1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-17/neg/2.1.fir.kt @@ -17,7 +17,7 @@ operator fun I2.invoke(): String = TODO() fun case1(a: A) { a.invoke() a() - A()() + A()() } // FILE: TestCase2.kt @@ -36,7 +36,7 @@ fun case1(a: I) { a.invoke() a() - val x = object : I {} () + val x = object : I {} () } // FILE: TestCase3.kt @@ -56,5 +56,5 @@ fun case1(a: I) { a.invoke{} a{} - val x = object : I {} {} + val x = object : I {} {} } diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-17/neg/2.2.fir.kt b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-17/neg/2.2.fir.kt index d29f42599bf..9b65fd3866a 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-17/neg/2.2.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/choosing-the-most-specific-candidate-from-the-overload-candidate-set/algorithm-of-msc-selection/p-17/neg/2.2.fir.kt @@ -17,7 +17,7 @@ operator fun I2.invoke(): String = TODO() fun case1(a: A) { a.invoke() a() - A()() + A()() } // FILE: TestCase2.kt @@ -36,7 +36,7 @@ fun case1(a: I) { a.invoke() a() - val x = object : I {} () + val x = object : I {} () } // FILE: TestCase3.kt @@ -56,5 +56,5 @@ fun case1(a: I) { a.invoke{} a{} - val x = object : I {} {} + val x = object : I {} {} } From 239a44b30c74cff7ea727ab53b7d2754993a683f Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 18 Feb 2021 12:55:29 +0300 Subject: [PATCH 306/368] FIR: forbid reporting inapplicable-likes on implicit constructors --- .../diagnostics/cyclicConstructorDelegationCall.kt | 2 +- .../diagnostics/explicitDelegationCallRequired.kt | 6 +++--- .../ErrorNodeDiagnosticCollectorComponent.kt | 4 ++++ .../headerClass/explicitConstructorDelegation.fir.kt | 2 +- .../errorsOnEmptyDelegationCall.fir.kt | 6 +++--- .../implicitSuperCallErrorsIfPrimary.fir.kt | 7 ------- .../implicitSuperCallErrorsIfPrimary.kt | 1 + .../secondaryConstructors/nestedExtendsInner.fir.kt | 2 +- .../reportResolutionErrorOnImplicitOnce.fir.kt | 2 +- .../superSecondaryNonExisting.fir.kt | 10 ---------- .../secondaryConstructors/superSecondaryNonExisting.kt | 1 + 11 files changed, 16 insertions(+), 27 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt index 120b6037dca..0ff6c499e81 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt @@ -63,5 +63,5 @@ class M { } class U : M { - constructor() + constructor() } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt index 2aa050d6cd7..a78d7ed62a4 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt @@ -3,16 +3,16 @@ class A(x: Int) { } class B : A { - constructor() + constructor() constructor(z: String) : this() } class C : A(20) { - constructor() + constructor() constructor(z: String) : this() } class D() : A(20) { - constructor(x: Int) + constructor(x: Int) constructor(z: String) : this() } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt index 87a7ba8203f..8d970dd29e2 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.analysis.collectors.components import org.jetbrains.kotlin.KtNodeTypes +import org.jetbrains.kotlin.fir.FirFakeSourceElementKind import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector @@ -73,6 +74,9 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect } } + if (source.kind == FirFakeSourceElementKind.ImplicitConstructor) { + return + } val coneDiagnostic = diagnostic.toFirDiagnostic(source) reporter.report(coneDiagnostic, context) } diff --git a/compiler/testData/diagnostics/tests/multiplatform/headerClass/explicitConstructorDelegation.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/headerClass/explicitConstructorDelegation.fir.kt index eabd11e3505..6584b6fe29c 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/headerClass/explicitConstructorDelegation.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/headerClass/explicitConstructorDelegation.fir.kt @@ -8,7 +8,7 @@ expect open class A { } expect class B : A { - constructor(i: Int) + constructor(i: Int) constructor() : super("B") } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/errorsOnEmptyDelegationCall.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/errorsOnEmptyDelegationCall.fir.kt index 87af2354284..f8ff7c69fa7 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/errorsOnEmptyDelegationCall.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/errorsOnEmptyDelegationCall.fir.kt @@ -2,7 +2,7 @@ open class B0(x: Int) class A0 : B0 { - constructor() + constructor() constructor(x: Int) : super() } @@ -26,7 +26,7 @@ open class B2 { } class A2 : B2 { - constructor() + constructor() constructor(x: Int) : super() } @@ -37,6 +37,6 @@ open class B3 { } class A3 : B3 { - constructor() + constructor() constructor(x: Int) : super() } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.fir.kt deleted file mode 100644 index dabba36c8a7..00000000000 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.fir.kt +++ /dev/null @@ -1,7 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -open class A(p1: String) - -class B() : A("") { - constructor(s: String) { - } -} diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.kt index 4c620d5da70..570ce819269 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/implicitSuperCallErrorsIfPrimary.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER open class A(p1: String) diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/nestedExtendsInner.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/nestedExtendsInner.fir.kt index 478b4d07216..a9321da314d 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/nestedExtendsInner.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/nestedExtendsInner.fir.kt @@ -2,6 +2,6 @@ class A { open inner class Inner class Nested : Inner { - constructor() + constructor() } } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt index f2ab1ac6ddf..85667e1cc22 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/reportResolutionErrorOnImplicitOnce.fir.kt @@ -2,5 +2,5 @@ open class A(p1: String, p2: String, p3: String, p4: String, p5: String) class B : A { - constructor(s: String) + constructor(s: String) } diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.fir.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.fir.kt deleted file mode 100644 index accb18c92dc..00000000000 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.fir.kt +++ /dev/null @@ -1,10 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -open class B(x: Double) { - constructor(x: Int): this(1.0) - constructor(x: String): this(1.0) -} -interface C -class A : B, C { - constructor(): super(' ') - constructor(x: Int) -} diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.kt b/compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.kt index 3609fa8a6d4..de71c4c026a 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.kt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/superSecondaryNonExisting.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER open class B(x: Double) { constructor(x: Int): this(1.0) From 5066a90f6f30fac6b13817ddeae76f8cf39ce038 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 18 Feb 2021 13:34:33 +0300 Subject: [PATCH 307/368] FIR2IR: fix offsets for qualified expressions --- .../kotlin/fir/backend/ConversionUtils.kt | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index 211c6b3f440..b09979741ad 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirConstExpression +import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.references.FirThisReference @@ -47,6 +48,7 @@ import org.jetbrains.kotlin.ir.types.impl.IrErrorTypeImpl import org.jetbrains.kotlin.ir.util.SymbolTable import org.jetbrains.kotlin.ir.util.functions import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.KtQualifiedExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffsetSkippingComments import org.jetbrains.kotlin.types.ConstantValueKind @@ -56,9 +58,24 @@ import org.jetbrains.kotlin.util.OperatorNameConventions internal fun FirElement.convertWithOffsets( f: (startOffset: Int, endOffset: Int) -> T ): T { - if (psi is PsiCompiledElement) return f(UNDEFINED_OFFSET, UNDEFINED_OFFSET) - val startOffset = psi?.startOffsetSkippingComments ?: UNDEFINED_OFFSET - val endOffset = psi?.endOffset ?: UNDEFINED_OFFSET + val psi = psi + if (psi is PsiCompiledElement || psi == null) return f(UNDEFINED_OFFSET, UNDEFINED_OFFSET) + val startOffset = psi.startOffsetSkippingComments + val endOffset = psi.endOffset + return f(startOffset, endOffset) +} + +internal fun FirQualifiedAccess.convertWithOffsets( + f: (startOffset: Int, endOffset: Int) -> T +): T { + val psi = psi + if (psi is PsiCompiledElement || psi == null) return f(UNDEFINED_OFFSET, UNDEFINED_OFFSET) + val startOffset = if (psi is KtQualifiedExpression) { + (psi.selectorExpression ?: psi).startOffsetSkippingComments + } else { + psi.startOffsetSkippingComments + } + val endOffset = psi.endOffset return f(startOffset, endOffset) } From 588b1354f60c3057f6886f19b8f5d235926d867c Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 18 Feb 2021 16:03:34 +0300 Subject: [PATCH 308/368] FIR IDE: fix reference shortening regarding new qualified sources --- .../frontend/api/fir/components/KtFirReferenceShortener.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt index 41dff03299d..0653e64c602 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirReferenceShortener.kt @@ -326,8 +326,8 @@ private class ElementsToShortenCollector(private val shorteningContext: FirShort private fun processFunctionCall(functionCall: FirFunctionCall) { if (!canBePossibleToDropReceiver(functionCall)) return - val callExpression = functionCall.psi as? KtCallExpression ?: return - val qualifiedCallExpression = callExpression.getDotQualifiedExpressionForSelector() ?: return + val qualifiedCallExpression = functionCall.psi as? KtDotQualifiedExpression ?: return + val callExpression = qualifiedCallExpression.selectorExpression as? KtCallExpression ?: return val calleeReference = functionCall.calleeReference val callableId = findUnambiguousReferencedCallableId(calleeReference) ?: return From 54139b83cee83e5b58d8f6116757381e54720adb Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 18 Feb 2021 16:25:13 +0300 Subject: [PATCH 309/368] FIR: fix EXPRESSION_REQUIRED positioning --- .../fir/checkers/generator/diagnostics/FirDiagnosticsList.kt | 2 +- .../org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt | 2 +- .../org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index a0b79fab942..5b20f6504c4 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -36,7 +36,7 @@ object DIAGNOSTICS_LIST : DiagnosticList() { val GENERAL_SYNTAX by object : DiagnosticGroup("General syntax") { val ILLEGAL_CONST_EXPRESSION by error() val ILLEGAL_UNDERSCORE by error() - val EXPRESSION_REQUIRED by error() + val EXPRESSION_REQUIRED by error(PositioningStrategy.SELECTOR_BY_QUALIFIED) val BREAK_OR_CONTINUE_OUTSIDE_A_LOOP by error() val NOT_A_LOOP_LABEL by error() val VARIABLE_EXPECTED by error() diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 0c04d5c6dcc..602d1cc9137 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -55,7 +55,7 @@ object FirErrors { // General syntax val ILLEGAL_CONST_EXPRESSION by error0() val ILLEGAL_UNDERSCORE by error0() - val EXPRESSION_REQUIRED by error0() + val EXPRESSION_REQUIRED by error0(SourceElementPositioningStrategies.SELECTOR_BY_QUALIFIED) val BREAK_OR_CONTINUE_OUTSIDE_A_LOOP by error0() val NOT_A_LOOP_LABEL by error0() val VARIABLE_EXPECTED by error0() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt index 2d1cdd07752..602933b4938 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt @@ -726,7 +726,7 @@ object PositioningStrategies { override fun mark(element: PsiElement): List { if (element is KtQualifiedExpression) { when (val selectorExpression = element.selectorExpression) { - is KtCallExpression, is KtReferenceExpression -> return mark(selectorExpression) + is KtElement -> return mark(selectorExpression) } } return super.mark(element) From 7fdc1c7b21706e4af9f38a70afef600a55cb1c18 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 18 Feb 2021 16:56:06 +0300 Subject: [PATCH 310/368] Fix RawFirBuilderTotalKotlinTestCase.testPsiConsistency --- .../kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt b/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt index 635204ce4c5..e1d46c67170 100644 --- a/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt +++ b/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt @@ -258,6 +258,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() { it is KtStringTemplateExpression && it.entries.size <= 1 || it is KtDestructuringDeclaration && it.parent is KtParameter || it is KtArrayAccessExpression && it.parent is KtBinaryExpression || + it is KtCallExpression && it.parent is KtQualifiedExpression || it is KtNameReferenceExpression && (it.parent is KtUserType || it.parent is KtInstanceExpressionWithLabel || it.parent is KtValueArgumentName || it.parent is KtTypeConstraint) || From 7c080395f2e6f5296249ae43876fb20c369c612c Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 19 Feb 2021 15:21:53 +0300 Subject: [PATCH 311/368] FIR: minor test data fixes --- .../testData/resolve/diagnostics/superIsNotAnExpression.kt | 2 +- .../testData/resolve/expresssions/privateObjectLiteral.kt | 2 +- .../nullabilityWarnings/delegatedProperties.fir.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt index f41d78a6551..5537e7af33f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt @@ -7,7 +7,7 @@ class B: A() { invoke() super { - println('weird') + println('weird') } } } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.kt index 45f71375792..d7e191dbdfe 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/privateObjectLiteral.kt @@ -9,5 +9,5 @@ class C { fun foo() = 13 } - val w = z.foo() // ERROR! + val w = z.foo() // ERROR! } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.fir.kt index d8b760b83c7..c7009ad980b 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.fir.kt @@ -19,5 +19,5 @@ public class J { // FILE: k.kt var A by J.staticNN -var B by J.staticN +var B by J.staticN var C by J.staticJ \ No newline at end of file From 3571074da40e2a33e05c0d979bb55dab94d5ac2b Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 19 Feb 2021 15:41:41 +0300 Subject: [PATCH 312/368] Update FIR-IDE diagnostic components --- .../api/fir/diagnostics/KtFirDataClassConverters.kt | 7 +++++++ .../idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt | 5 +++++ .../frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt index ed2d4f80ff2..18fb99ce669 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -242,6 +242,13 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirErrors.SUPERTYPE_NOT_A_CLASS_OR_INTERFACE) { firDiagnostic -> + SupertypeNotAClassOrInterfaceImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } add(FirErrors.CONSTRUCTOR_IN_OBJECT) { firDiagnostic -> ConstructorInObjectImpl( firDiagnostic as FirPsiDiagnostic<*>, diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt index 59e6aea5ba1..057409db49a 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -178,6 +178,11 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { override val diagnosticClass get() = SealedSupertypeInLocalClass::class } + abstract class SupertypeNotAClassOrInterface : KtFirDiagnostic() { + override val diagnosticClass get() = SupertypeNotAClassOrInterface::class + abstract val reason: String + } + abstract class ConstructorInObject : KtFirDiagnostic() { override val diagnosticClass get() = ConstructorInObject::class } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index 18d7cad5c93..2a6bd32af2d 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -278,6 +278,14 @@ internal class SealedSupertypeInLocalClassImpl( override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) } +internal class SupertypeNotAClassOrInterfaceImpl( + override val reason: String, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.SupertypeNotAClassOrInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) +} + internal class ConstructorInObjectImpl( firDiagnostic: FirPsiDiagnostic<*>, override val token: ValidityToken, From af4d30068683e214b2a62318158eacbabd3bf246 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Fri, 19 Feb 2021 12:39:56 +0100 Subject: [PATCH 313/368] Use nullability from approximated local type in AbstractTypeApproximator --- .../src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt index f72fdde9826..c2c0ebca922 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/types/AbstractTypeApproximator.kt @@ -174,6 +174,7 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon stubTypesEqualToAnything = false ) return AbstractTypeChecker.findCorrespondingSupertypes(typeCheckerContext, type, superConstructor).first() + .withNullability(type.isMarkedNullable()) } private fun isIntersectionTypeEffectivelyNothing(constructor: IntersectionTypeConstructorMarker): Boolean { From 42103b7363b451165b720b93d653d1ebceedd8d8 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Fri, 19 Feb 2021 13:09:01 +0100 Subject: [PATCH 314/368] FIR IDE: use correct denotable type approximator --- ...icitTypeForCallableDeclarationIntention.kt | 4 +- .../idea/frontend/api/KtAnalysisSession.kt | 8 +- .../frontend/api/components/KtTypeProvider.kt | 2 +- .../api/fir/components/KtFirTypeProvider.kt | 7 +- .../api/fir/types/PublicTypeApproximator.kt | 127 ++---------------- 5 files changed, 26 insertions(+), 122 deletions(-) diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/intentions/declarations/HLSpecifyExplicitTypeForCallableDeclarationIntention.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/intentions/declarations/HLSpecifyExplicitTypeForCallableDeclarationIntention.kt index 4203415e257..6c41a54aabe 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/intentions/declarations/HLSpecifyExplicitTypeForCallableDeclarationIntention.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/intentions/declarations/HLSpecifyExplicitTypeForCallableDeclarationIntention.kt @@ -8,12 +8,10 @@ package org.jetbrains.kotlin.idea.fir.intentions.declarations import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.fir.api.* import org.jetbrains.kotlin.idea.fir.api.applicator.HLApplicabilityRange -import org.jetbrains.kotlin.idea.fir.api.applicator.applicabilityTarget import org.jetbrains.kotlin.idea.fir.api.applicator.inputProvider import org.jetbrains.kotlin.idea.fir.api.applicator.with import org.jetbrains.kotlin.idea.fir.applicators.ApplicabilityRanges import org.jetbrains.kotlin.idea.fir.applicators.CallableReturnTypeUpdaterApplicator -import org.jetbrains.kotlin.idea.frontend.api.types.* import org.jetbrains.kotlin.psi.* class HLSpecifyExplicitTypeForCallableDeclarationIntention : @@ -31,7 +29,7 @@ class HLSpecifyExplicitTypeForCallableDeclarationIntention : override val inputProvider = inputProvider { declaration -> val returnType = declaration.getReturnKtType() - val denotableType = returnType.approximateToPublicDenotable() ?: return@inputProvider null + val denotableType = returnType.approximateToSuperPublicDenotable() ?: returnType with(CallableReturnTypeUpdaterApplicator.Type) { createByKtType(denotableType) } } } \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt index 73c559ada86..5f0ee715544 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt @@ -105,7 +105,13 @@ abstract class KtAnalysisSession(final override val token: ValidityToken) : Vali val builtinTypes: KtBuiltinTypes get() = typeProvider.builtinTypes - fun KtType.approximateToPublicDenotable(): KtType? = typeProvider.approximateToPublicDenotable(this) + /** + * Approximates [KtType] with the a supertype which can be rendered in a source code + * + * Return `null` if the type do not need approximation and can be rendered as is + * Otherwise, for type `T` return type `S` such `T <: S` and `T` and every it type argument is [org.jetbrains.kotlin.idea.frontend.api.types.KtDenotableType]` + */ + fun KtType.approximateToSuperPublicDenotable(): KtType? = typeProvider.approximateToSuperPublicDenotableType(this) fun KtClassOrObjectSymbol.buildSelfClassType(): KtType = typeProvider.buildSelfClassType(this) diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeProvider.kt index e90bd35b6f6..1f69c3d56fb 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeProvider.kt @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.idea.frontend.api.types.KtType abstract class KtTypeProvider : KtAnalysisSessionComponent() { abstract val builtinTypes: KtBuiltinTypes - abstract fun approximateToPublicDenotable(type: KtType): KtType? + abstract fun approximateToSuperPublicDenotableType(type: KtType): KtType? abstract fun buildSelfClassType(symbol: KtClassOrObjectSymbol): KtType } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirTypeProvider.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirTypeProvider.kt index 224965245be..c109af8e63c 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirTypeProvider.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirTypeProvider.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents +import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl import org.jetbrains.kotlin.idea.frontend.api.ValidityToken @@ -18,6 +19,7 @@ import org.jetbrains.kotlin.idea.frontend.api.fir.types.KtFirType import org.jetbrains.kotlin.idea.frontend.api.fir.types.PublicTypeApproximator import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassOrObjectSymbol import org.jetbrains.kotlin.idea.frontend.api.types.KtType +import org.jetbrains.kotlin.types.TypeApproximatorConfiguration internal class KtFirTypeProvider( override val analysisSession: KtFirAnalysisSession, @@ -26,14 +28,14 @@ internal class KtFirTypeProvider( override val builtinTypes: KtBuiltinTypes = KtFirBuiltInTypes(analysisSession.firResolveState.rootModuleSession.builtinTypes, analysisSession.firSymbolBuilder, token) - override fun approximateToPublicDenotable(type: KtType): KtType? { + override fun approximateToSuperPublicDenotableType(type: KtType): KtType? { require(type is KtFirType) val coneType = type.coneType val approximatedConeType = PublicTypeApproximator.approximateTypeToPublicDenotable( coneType, - rootModuleSession.inferenceComponents.ctx, rootModuleSession ) + return approximatedConeType?.asKtType() } @@ -50,3 +52,4 @@ internal class KtFirTypeProvider( return type.asKtType() } } + diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/types/PublicTypeApproximator.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/types/PublicTypeApproximator.kt index 419793ce5cf..a9df2bd452d 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/types/PublicTypeApproximator.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/types/PublicTypeApproximator.kt @@ -6,128 +6,25 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.types import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.declarations.* -import org.jetbrains.kotlin.fir.resolve.calls.fullyExpandedClass -import org.jetbrains.kotlin.fir.resolve.lookupSuperTypes -import org.jetbrains.kotlin.fir.resolve.toSymbol -import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl -import org.jetbrains.kotlin.types.AbstractTypeChecker -import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.TypeApproximatorConfiguration internal object PublicTypeApproximator { fun approximateTypeToPublicDenotable( type: ConeKotlinType, - context: ConeInferenceContext, session: FirSession, - ): ConeKotlinType? = approximate(type, context, session) as ConeKotlinType? - - private fun approximate( - type: ConeKotlinType, - context: ConeInferenceContext, - session: FirSession, - ): ConeTypeProjection? = when (type) { - is ConeFlexibleType -> approximate(type.upperBound, context, session) - is ConeCapturedType -> type - is ConeDefinitelyNotNullType -> ConeDefinitelyNotNullType( - approximate( - type.original, - context, - session, - ) as ConeKotlinType - ) - is ConeIntegerLiteralType -> type - is ConeIntersectionType -> context.commonSuperTypeOrNull(type.intersectedTypes.toList())?.let { approximate(it, context, session) } - is ConeLookupTagBasedType -> when (type) { - is ConeTypeParameterType -> type - is ConeClassErrorType -> null - is ConeClassLikeTypeImpl -> approximateClassLikeType(type, context, session) - else -> error("Unexpected type ${type::class}") - } - is ConeStubType -> null + ): ConeKotlinType? { + val approximator = session.inferenceComponents.approximator + return approximator.approximateToSuperType(type, PublicApproximatorConfiguration) as ConeKotlinType? } - private fun approximateClassLikeType( - typeImpl: ConeClassLikeTypeImpl, - context: ConeInferenceContext, - session: FirSession, - ): ConeTypeProjection? { - val regularClass = typeImpl.classOrAnonymousClass(session) ?: return null - val type = if (needApproximationAsSuperType(regularClass)) { - firstSuperType(regularClass, session) ?: return null - } else { - typeImpl - } - - val typeClassifier = type.classOrAnonymousClass(session) ?: return null - - val typeArguments = approximateTypeParameters(type, typeClassifier, context, session)?.toTypedArray() ?: return null - return ConeClassLikeTypeImpl( - type.lookupTag, - typeArguments, - type.isNullable, - type.attributes - ) - } - - private fun approximateTypeParameters( - type: ConeClassLikeTypeImpl, - typeClassifier: FirClass<*>, - context: ConeInferenceContext, - session: FirSession - ): List? { - val result = mutableListOf() - if (type.typeArguments.size != typeClassifier.typeParameters.size) return null - for ((typeArg, typeParam) in type.typeArguments.zip(typeClassifier.typeParameters)) { - val variance = (typeParam as? FirTypeParameter)?.variance ?: return null - result += approximateTypeProjection(typeArg, context, session, variance) ?: return null - } - return result - } - - private fun firstSuperType(regularClass: FirClass<*>, session: FirSession): ConeClassLikeTypeImpl? { - val superTypes = lookupSuperTypes(regularClass, lookupInterfaces = true, deep = false, session, substituteTypes = true) - return superTypes.first() as? ConeClassLikeTypeImpl - } - - fun ConeClassLikeTypeImpl.classOrAnonymousClass(session: FirSession): FirClass<*>? { - val fir = lookupTag.toSymbol(session)?.fir ?: return null - if (fir is FirAnonymousObject) return fir - else return fir.fullyExpandedClass(session) - } - - private fun needApproximationAsSuperType(fir: FirClass<*>) = when (fir) { - is FirRegularClass -> fir.isLocal - is FirAnonymousObject -> true - else -> false - } - - private fun approximateTypeProjection( - typeProjection: ConeTypeProjection, - context: ConeInferenceContext, - session: FirSession, - variance: Variance, - ): ConeTypeProjection? { - val type = when (typeProjection) { - ConeStarProjection -> return ConeStarProjection - is ConeKotlinTypeProjection -> typeProjection.type - else -> error("Unexpected type ${typeProjection::class}") - } - val newType = when (val new = approximate(type, context, session)) { - ConeStarProjection -> return ConeStarProjection - is ConeKotlinTypeProjection -> new.type - null -> return null - else -> error("Unexpected type ${new::class}") - } - return when (variance) { - Variance.INVARIANT -> when { - with(context) { newType.typeConstructor().isAnyConstructor() } -> ConeStarProjection - AbstractTypeChecker.equalTypes(context, type, newType) -> newType - else -> ConeStarProjection - } - Variance.IN_VARIANCE -> if (AbstractTypeChecker.isSubtypeOf(context, newType, type)) newType else ConeStarProjection - Variance.OUT_VARIANCE -> if (AbstractTypeChecker.isSubtypeOf(context, type, newType)) newType else ConeStarProjection - } + private object PublicApproximatorConfiguration : TypeApproximatorConfiguration.AllFlexibleSameValue() { + override val allFlexible: Boolean get() = false + override val errorType: Boolean get() = true + override val definitelyNotNullType: Boolean get() = false + override val integerLiteralType: Boolean get() = true + override val intersectionTypesInContravariantPositions: Boolean get() = true + override val localTypes: Boolean get() = true } } \ No newline at end of file From 141b6b0e5503272d018ac69e6d9d1d6d704002f3 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Fri, 19 Feb 2021 14:33:11 +0100 Subject: [PATCH 315/368] FIR IDE: use different .after testdata for AbstractHLIntentionTest.kt --- .../kotlin/idea/intentions/AbstractHLIntentionTest.kt | 10 ++++++++++ .../innerTypeParameter.kt.after.fir | 9 +++++++++ .../localClassInSecondTypeParameter.kt.after.fir | 6 ++++++ .../localClassInTypeParameter.kt.after.fir | 5 +++++ .../specifyTypeExplicitly/outClass2.kt.after.fir | 8 ++++++++ .../specifyTypeExplicitly/outClass3.kt.after.fir | 8 ++++++++ .../kotlin/idea/intentions/AbstractIntentionTest.kt | 5 +++-- .../kotlin/idea/intentions/AbstractIntentionTest2.kt | 4 +++- 8 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 idea/testData/intentions/specifyTypeExplicitly/innerTypeParameter.kt.after.fir create mode 100644 idea/testData/intentions/specifyTypeExplicitly/localClassInSecondTypeParameter.kt.after.fir create mode 100644 idea/testData/intentions/specifyTypeExplicitly/localClassInTypeParameter.kt.after.fir create mode 100644 idea/testData/intentions/specifyTypeExplicitly/outClass2.kt.after.fir create mode 100644 idea/testData/intentions/specifyTypeExplicitly/outClass3.kt.after.fir diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/intentions/AbstractHLIntentionTest.kt b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/intentions/AbstractHLIntentionTest.kt index 884387b470c..aa67d98cdfd 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/intentions/AbstractHLIntentionTest.kt +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/intentions/AbstractHLIntentionTest.kt @@ -12,6 +12,12 @@ import java.io.File abstract class AbstractHLIntentionTest : AbstractIntentionTest() { override fun intentionFileName() = ".firIntention" + + override fun afterFileNameSuffix(ktFilePath: File): String { + return if (ktFilePath.resolveSibling(ktFilePath.name + AFTER_FIR_EXTENSION).exists()) AFTER_FIR_EXTENSION + else super.afterFileNameSuffix(ktFilePath) + } + override fun isFirPlugin() = true override fun doTestFor(mainFile: File, pathToFiles: Map, intentionAction: IntentionAction, fileText: String) { @@ -22,4 +28,8 @@ abstract class AbstractHLIntentionTest : AbstractIntentionTest() { override fun checkForErrorsAfter(fileText: String) {} override fun checkForErrorsBefore(fileText: String) {} + + companion object { + private const val AFTER_FIR_EXTENSION = ".after.fir" + } } \ No newline at end of file diff --git a/idea/testData/intentions/specifyTypeExplicitly/innerTypeParameter.kt.after.fir b/idea/testData/intentions/specifyTypeExplicitly/innerTypeParameter.kt.after.fir new file mode 100644 index 00000000000..6c187205bd9 --- /dev/null +++ b/idea/testData/intentions/specifyTypeExplicitly/innerTypeParameter.kt.after.fir @@ -0,0 +1,9 @@ +class A +class B +class C +class D +class E +private fun test(): () -> C, out B>>>> = { + class Local + C, B>>>>() +} \ No newline at end of file diff --git a/idea/testData/intentions/specifyTypeExplicitly/localClassInSecondTypeParameter.kt.after.fir b/idea/testData/intentions/specifyTypeExplicitly/localClassInSecondTypeParameter.kt.after.fir new file mode 100644 index 00000000000..68604b27263 --- /dev/null +++ b/idea/testData/intentions/specifyTypeExplicitly/localClassInSecondTypeParameter.kt.after.fir @@ -0,0 +1,6 @@ +class F +class TestClass +private fun test(): () -> TestClass = { + class Local + TestClass() +} \ No newline at end of file diff --git a/idea/testData/intentions/specifyTypeExplicitly/localClassInTypeParameter.kt.after.fir b/idea/testData/intentions/specifyTypeExplicitly/localClassInTypeParameter.kt.after.fir new file mode 100644 index 00000000000..c005d75915c --- /dev/null +++ b/idea/testData/intentions/specifyTypeExplicitly/localClassInTypeParameter.kt.after.fir @@ -0,0 +1,5 @@ +class TestClass +private fun test(): () -> TestClass = { + class Local + TestClass() +} \ No newline at end of file diff --git a/idea/testData/intentions/specifyTypeExplicitly/outClass2.kt.after.fir b/idea/testData/intentions/specifyTypeExplicitly/outClass2.kt.after.fir new file mode 100644 index 00000000000..0e4e2f1d906 --- /dev/null +++ b/idea/testData/intentions/specifyTypeExplicitly/outClass2.kt.after.fir @@ -0,0 +1,8 @@ +open class F +class B +class K + +private fun check(): () -> B> = { + class Local : F() + B>() +} \ No newline at end of file diff --git a/idea/testData/intentions/specifyTypeExplicitly/outClass3.kt.after.fir b/idea/testData/intentions/specifyTypeExplicitly/outClass3.kt.after.fir new file mode 100644 index 00000000000..a1b183155dc --- /dev/null +++ b/idea/testData/intentions/specifyTypeExplicitly/outClass3.kt.after.fir @@ -0,0 +1,8 @@ +open class F +class B +class K + +private fun check(): () -> B> = { + class Local : F() + B>() +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest.kt index 553e89c28cf..0f6c6b125db 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest.kt @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.KotlinTestUtils import org.junit.Assert import java.io.File +import java.nio.file.Path import java.util.* import java.util.concurrent.CompletableFuture import java.util.concurrent.TimeUnit @@ -39,7 +40,7 @@ import java.util.concurrent.TimeUnit abstract class AbstractIntentionTest : KotlinLightCodeInsightFixtureTestCase() { protected open fun intentionFileName(): String = ".intention" - protected open fun afterFileNameSuffix(): String = ".after" + protected open fun afterFileNameSuffix(ktFilePath: File): String = ".after" protected open fun isApplicableDirectiveName(): String = "IS_APPLICABLE" @@ -193,7 +194,7 @@ abstract class AbstractIntentionTest : KotlinLightCodeInsightFixtureTestCase() { // Don't bother checking if it should have failed. if (shouldFailString.isEmpty()) { for ((filePath, value) in pathToFiles) { - val canonicalPathToExpectedFile = filePath + afterFileNameSuffix() + val canonicalPathToExpectedFile = filePath + afterFileNameSuffix(mainFile) if (filePath == mainFilePath) { try { myFixture.checkResultByFile(canonicalPathToExpectedFile) diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest2.kt b/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest2.kt index 1846a7cf07d..16700ee307d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest2.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/AbstractIntentionTest2.kt @@ -5,9 +5,11 @@ package org.jetbrains.kotlin.idea.intentions +import java.io.File + abstract class AbstractIntentionTest2 : AbstractIntentionTest() { override fun intentionFileName() = ".intention2" - override fun afterFileNameSuffix() = ".after2" + override fun afterFileNameSuffix(ktFilePath: File) = ".after2" override fun intentionTextDirectiveName() = "INTENTION_TEXT_2" override fun isApplicableDirectiveName() = "IS_APPLICABLE_2" } From ca4ec997ee8678a282f4e406c94186a33056f028 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Fri, 19 Feb 2021 16:40:54 +0100 Subject: [PATCH 316/368] FIR IDE: split KtAnalysisSession into mixins --- .../idea/frontend/api/KtAnalysisSession.kt | 217 ++++-------------- .../components/KtAnalysisSessionComponent.kt | 4 +- .../api/components/KtAnalysisSessionMixIn.kt | 12 + .../frontend/api/components/KtCallResolver.kt | 9 + .../KtCompletionCandidateChecker.kt | 15 +- .../api/components/KtDiagnosticProvider.kt | 9 + .../KtExpressionHandlingComponent.kt | 14 -- .../components/KtExpressionInfoProvider.kt | 18 ++ .../components/KtExpressionTypeProvider.kt | 11 + .../api/components/KtReferenceResolveMixIn.kt | 24 ++ .../api/components/KtReferenceShortener.kt | 5 + .../api/components/KtScopeProvider.kt | 23 ++ .../api/components/KtSmartCastProvider.kt | 8 + .../api/components/KtSubtypingComponent.kt | 11 + .../KtSymbolContainingDeclarationProvider.kt | 7 +- .../KtSymbolDeclarationOverridesProvider.kt | 49 ++-- .../frontend/api/components/KtSymbolsMixIn.kt | 14 ++ .../frontend/api/components/KtTypeProvider.kt | 18 +- .../frontend/api/components/KtTypeRenderer.kt | 5 + .../frontend/api/symbols/KtSymbolProvider.kt | 58 ++++- .../frontend/api/fir/KtFirAnalysisSession.kt | 43 ++-- .../KtFirAnalysisSessionComponent.kt | 16 +- .../fir/components/KtFirDiagnosticProvider.kt | 16 -- ...nent.kt => KtFirExpressionInfoProvider.kt} | 7 +- .../fir/components/KtFirSmartcastProvider.kt | 5 +- ...cConverter.kt => KtDiagnosticConverter.kt} | 0 26 files changed, 364 insertions(+), 254 deletions(-) create mode 100644 idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtAnalysisSessionMixIn.kt delete mode 100644 idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionHandlingComponent.kt create mode 100644 idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionInfoProvider.kt create mode 100644 idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceResolveMixIn.kt create mode 100644 idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolsMixIn.kt rename idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/{KtFirExpressionHandlingComponent.kt => KtFirExpressionInfoProvider.kt} (84%) rename idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/{DiagnosticConverter.kt => KtDiagnosticConverter.kt} (100%) diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt index 5f0ee715544..4c4c866000f 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt @@ -5,24 +5,9 @@ package org.jetbrains.kotlin.idea.frontend.api -import com.intellij.openapi.util.TextRange -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.idea.frontend.api.calls.KtCall import org.jetbrains.kotlin.idea.frontend.api.components.* -import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnostic -import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi -import org.jetbrains.kotlin.idea.frontend.api.scopes.* import org.jetbrains.kotlin.idea.frontend.api.symbols.* -import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithDeclarations -import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithKind -import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithMembers import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer -import org.jetbrains.kotlin.idea.frontend.api.types.KtType -import org.jetbrains.kotlin.idea.references.KtReference -import org.jetbrains.kotlin.idea.references.KtSimpleReference -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* /** @@ -37,175 +22,69 @@ import org.jetbrains.kotlin.psi.* * * To create analysis session consider using [analyze] */ -abstract class KtAnalysisSession(final override val token: ValidityToken) : ValidityTokenOwner { - protected abstract val smartCastProvider: KtSmartCastProvider - protected abstract val diagnosticProvider: KtDiagnosticProvider - protected abstract val scopeProvider: KtScopeProvider - protected abstract val containingDeclarationProvider: KtSymbolContainingDeclarationProvider - protected abstract val symbolProvider: KtSymbolProvider - protected abstract val callResolver: KtCallResolver - protected abstract val completionCandidateChecker: KtCompletionCandidateChecker - protected abstract val symbolDeclarationOverridesProvider: KtSymbolDeclarationOverridesProvider - protected abstract val referenceShortener: KtReferenceShortener +abstract class KtAnalysisSession(final override val token: ValidityToken) : ValidityTokenOwner, + KtSmartCastProviderMixIn, + KtCallResolverMixIn, + KtDiagnosticProviderMixIn, + KtScopeProviderMixIn, + KtCompletionCandidateCheckerMixIn, + KtTypeRendererMixIn, + KtSymbolDeclarationOverridesProviderMixIn, + KtExpressionTypeProviderMixIn, + KtTypeProviderMixIn, + KtSymbolProviderMixIn, + KtSymbolContainingDeclarationProviderMixIn, + KtSubtypingComponentMixIn, + KtExpressionInfoProviderMixIn, + KtSymbolsMixIn, + KtReferenceResolveMixIn, + KtReferenceShortenerMixIn { - @Suppress("LeakingThis") - - protected open val typeRenderer: KtTypeRenderer = KtDefaultTypeRenderer(this, token) - protected abstract val expressionTypeProvider: KtExpressionTypeProvider - protected abstract val typeProvider: KtTypeProvider - protected abstract val subtypingComponent: KtSubtypingComponent - protected abstract val expressionHandlingComponent: KtExpressionHandlingComponent + override val analysisSession: KtAnalysisSession get() = this abstract fun createContextDependentCopy(originalKtFile: KtFile, fakeKtElement: KtElement): KtAnalysisSession + internal val smartCastProvider: KtSmartCastProvider get() = smartCastProviderImpl + protected abstract val smartCastProviderImpl: KtSmartCastProvider - /** - * Return a list of **all** symbols which are overridden by symbol - * - * E.g, if we have `A.foo` overrides `B.foo` overrides `C.foo`, all two super declarations `B.foo`, `C.foo` will be returned - * - * Unwraps substituted overridden symbols (see [org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbolOrigin.INTERSECTION_OVERRIDE]) - * - * @see getDirectlyOverriddenSymbols - */ - fun KtCallableSymbol.getAllOverriddenSymbols(): List = - symbolDeclarationOverridesProvider.getAllOverriddenSymbols(this) + internal val diagnosticProvider: KtDiagnosticProvider get() = diagnosticProviderImpl + protected abstract val diagnosticProviderImpl: KtDiagnosticProvider - /** - * Return a list of symbols which are **directly** overridden by symbol - ** - * E.g, if we have `A.foo` overrides `B.foo` overrides `C.foo`, only declarations directly overriden `B.foo` will be returned - * - * Unwraps substituted overridden symbols (see [org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbolOrigin.INTERSECTION_OVERRIDE]) - * - * @see getAllOverriddenSymbols - */ - fun KtCallableSymbol.getDirectlyOverriddenSymbols(): List = - symbolDeclarationOverridesProvider.getDirectlyOverriddenSymbols(this) + internal val scopeProvider: KtScopeProvider get() = scopeProviderImpl + protected abstract val scopeProviderImpl: KtScopeProvider - fun KtCallableSymbol.getIntersectionOverriddenSymbols(): Collection = - symbolDeclarationOverridesProvider.getIntersectionOverriddenSymbols(this) + internal val containingDeclarationProvider: KtSymbolContainingDeclarationProvider get() = containingDeclarationProviderImpl + protected abstract val containingDeclarationProviderImpl: KtSymbolContainingDeclarationProvider - fun KtExpression.getSmartCast(): KtType? = smartCastProvider.getSmartCastedToType(this) + internal val symbolProvider: KtSymbolProvider get() = symbolProviderImpl + protected abstract val symbolProviderImpl: KtSymbolProvider - fun KtExpression.getImplicitReceiverSmartCast(): Collection = - smartCastProvider.getImplicitReceiverSmartCast(this) + internal val callResolver: KtCallResolver get() = callResolverImpl + protected abstract val callResolverImpl: KtCallResolver - fun KtExpression.getKtType(): KtType = expressionTypeProvider.getKtExpressionType(this) + internal val completionCandidateChecker: KtCompletionCandidateChecker get() = completionCandidateCheckerImpl + protected abstract val completionCandidateCheckerImpl: KtCompletionCandidateChecker - fun KtDeclaration.getReturnKtType(): KtType = expressionTypeProvider.getReturnTypeForKtDeclaration(this) + internal val symbolDeclarationOverridesProvider: KtSymbolDeclarationOverridesProvider get() = symbolDeclarationOverridesProviderImpl + protected abstract val symbolDeclarationOverridesProviderImpl: KtSymbolDeclarationOverridesProvider - infix fun KtType.isEqualTo(other: KtType): Boolean = subtypingComponent.isEqualTo(this, other) + internal val referenceShortener: KtReferenceShortener get() = referenceShortenerImpl + protected abstract val referenceShortenerImpl: KtReferenceShortener - infix fun KtType.isSubTypeOf(superType: KtType): Boolean = subtypingComponent.isSubTypeOf(this, superType) - infix fun KtType.isNotSubTypeOf(superType: KtType): Boolean = !subtypingComponent.isSubTypeOf(this, superType) + @Suppress("LeakingThis") + protected open val typeRendererImpl: KtTypeRenderer = KtDefaultTypeRenderer(this, token) + internal val typeRenderer: KtTypeRenderer get() = typeRendererImpl - fun PsiElement.getExpectedType(): KtType? = expressionTypeProvider.getExpectedType(this) + internal val expressionTypeProvider: KtExpressionTypeProvider get() = expressionTypeProviderImpl + protected abstract val expressionTypeProviderImpl: KtExpressionTypeProvider - val builtinTypes: KtBuiltinTypes get() = typeProvider.builtinTypes + internal val typeProvider: KtTypeProvider get() = typeProviderImpl + protected abstract val typeProviderImpl: KtTypeProvider - /** - * Approximates [KtType] with the a supertype which can be rendered in a source code - * - * Return `null` if the type do not need approximation and can be rendered as is - * Otherwise, for type `T` return type `S` such `T <: S` and `T` and every it type argument is [org.jetbrains.kotlin.idea.frontend.api.types.KtDenotableType]` - */ - fun KtType.approximateToSuperPublicDenotable(): KtType? = typeProvider.approximateToSuperPublicDenotableType(this) + internal val subtypingComponent: KtSubtypingComponent get() = subtypingComponentImpl + protected abstract val subtypingComponentImpl: KtSubtypingComponent - fun KtClassOrObjectSymbol.buildSelfClassType(): KtType = typeProvider.buildSelfClassType(this) - - fun KtElement.getDiagnostics(filter: KtDiagnosticCheckerFilter): Collection = - diagnosticProvider.getDiagnosticsForElement(this, filter) - - fun KtFile.collectDiagnosticsForFile(filter: KtDiagnosticCheckerFilter): Collection> = - diagnosticProvider.collectDiagnosticsForFile(this, filter) - - fun KtSymbolWithKind.getContainingSymbol(): KtSymbolWithKind? = containingDeclarationProvider.getContainingDeclaration(this) - - fun KtSymbolWithMembers.getMemberScope(): KtMemberScope = scopeProvider.getMemberScope(this) - - fun KtSymbolWithMembers.getDeclaredMemberScope(): KtDeclaredMemberScope = scopeProvider.getDeclaredMemberScope(this) - - fun KtFileSymbol.getFileScope(): KtDeclarationScope = scopeProvider.getFileScope(this) - - fun KtPackageSymbol.getPackageScope(): KtPackageScope = scopeProvider.getPackageScope(this) - - fun List.asCompositeScope(): KtCompositeScope = scopeProvider.getCompositeScope(this) - - fun KtType.getTypeScope(): KtScope? = scopeProvider.getTypeScope(this) - - fun KtFile.getScopeContextForPosition(positionInFakeFile: KtElement): KtScopeContext = - scopeProvider.getScopeContextForPosition(this, positionInFakeFile) - - fun KtDeclaration.getSymbol(): KtSymbol = symbolProvider.getSymbol(this) - - fun KtParameter.getParameterSymbol(): KtParameterSymbol = symbolProvider.getParameterSymbol(this) - - fun KtNamedFunction.getFunctionSymbol(): KtFunctionSymbol = symbolProvider.getFunctionSymbol(this) - - fun KtConstructor<*>.getConstructorSymbol(): KtConstructorSymbol = symbolProvider.getConstructorSymbol(this) - - fun KtTypeParameter.getTypeParameterSymbol(): KtTypeParameterSymbol = symbolProvider.getTypeParameterSymbol(this) - - fun KtTypeAlias.getTypeAliasSymbol(): KtTypeAliasSymbol = symbolProvider.getTypeAliasSymbol(this) - - fun KtEnumEntry.getEnumEntrySymbol(): KtEnumEntrySymbol = symbolProvider.getEnumEntrySymbol(this) - - fun KtNamedFunction.getAnonymousFunctionSymbol(): KtAnonymousFunctionSymbol = symbolProvider.getAnonymousFunctionSymbol(this) - - fun KtLambdaExpression.getAnonymousFunctionSymbol(): KtAnonymousFunctionSymbol = symbolProvider.getAnonymousFunctionSymbol(this) - - fun KtProperty.getVariableSymbol(): KtVariableSymbol = symbolProvider.getVariableSymbol(this) - - fun KtObjectLiteralExpression.getAnonymousObjectSymbol(): KtAnonymousObjectSymbol = symbolProvider.getAnonymousObjectSymbol(this) - - fun KtClassOrObject.getClassOrObjectSymbol(): KtClassOrObjectSymbol = symbolProvider.getClassOrObjectSymbol(this) - - fun KtPropertyAccessor.getPropertyAccessorSymbol(): KtPropertyAccessorSymbol = symbolProvider.getPropertyAccessorSymbol(this) - - fun KtFile.getFileSymbol(): KtFileSymbol = symbolProvider.getFileSymbol(this) - - /** - * @return symbol with specified [this@getClassOrObjectSymbolByClassId] or `null` in case such symbol is not found - */ - fun ClassId.getCorrespondingToplevelClassOrObjectSymbol(): KtClassOrObjectSymbol? = symbolProvider.getClassOrObjectSymbolByClassId(this) - - fun FqName.getContainingCallableSymbolsWithName(name: Name): Sequence = symbolProvider.getTopLevelCallableSymbols(this, name) - - fun KtSymbolPointer.restoreSymbol(): S? = restoreSymbol(this@KtAnalysisSession) - - fun KtCallExpression.resolveCall(): KtCall? = callResolver.resolveCall(this) - - fun KtBinaryExpression.resolveCall(): KtCall? = callResolver.resolveCall(this) - - fun KtReference.resolveToSymbols(): Collection { - check(this is KtSymbolBasedReference) { "To get reference symbol the one should be KtSymbolBasedReference" } - return this@KtAnalysisSession.resolveToSymbols() - } - - fun KtSimpleReference<*>.resolveToSymbol(): KtSymbol? { - check(this is KtSymbolBasedReference) { "To get reference symbol the one should be KtSymbolBasedReference but was ${this::class}" } - return resolveToSymbols().singleOrNull() - } - - fun KtCallableSymbol.checkExtensionIsSuitable( - originalPsiFile: KtFile, - psiFakeCompletionExpression: KtSimpleNameExpression, - psiReceiverExpression: KtExpression?, - ): Boolean = completionCandidateChecker.checkExtensionFitsCandidate( - this, - originalPsiFile, - psiFakeCompletionExpression, - psiReceiverExpression - ) - - fun KtType.render(options: KtTypeRendererOptions = KtTypeRendererOptions.DEFAULT): String = - typeRenderer.render(this, options) - - fun KtReturnExpression.getReturnTargetSymbol(): KtCallableSymbol? = - expressionHandlingComponent.getReturnExpressionTargetSymbol(this) - - fun collectPossibleReferenceShortenings(file: KtFile, selection: TextRange): ShortenCommand = - referenceShortener.collectShortenings(file, selection) -} + internal val expressionInfoProvider: KtExpressionInfoProvider get() = expressionInfoProviderImpl + protected abstract val expressionInfoProviderImpl: KtExpressionInfoProvider +} \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtAnalysisSessionComponent.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtAnalysisSessionComponent.kt index a326fa0786b..2f644f48a2d 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtAnalysisSessionComponent.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtAnalysisSessionComponent.kt @@ -6,9 +6,9 @@ package org.jetbrains.kotlin.idea.frontend.api.components import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession -import org.jetbrains.kotlin.idea.frontend.api.ValidityToken import org.jetbrains.kotlin.idea.frontend.api.ValidityTokenOwner abstract class KtAnalysisSessionComponent : ValidityTokenOwner { protected abstract val analysisSession: KtAnalysisSession -} \ No newline at end of file +} + diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtAnalysisSessionMixIn.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtAnalysisSessionMixIn.kt new file mode 100644 index 00000000000..7ee3f0fbfff --- /dev/null +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtAnalysisSessionMixIn.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2010-2021 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.idea.frontend.api.components + +import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession + +interface KtAnalysisSessionMixIn { + val analysisSession: KtAnalysisSession +} \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtCallResolver.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtCallResolver.kt index cd213ab28fb..ee27e0b8d4e 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtCallResolver.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtCallResolver.kt @@ -12,4 +12,13 @@ import org.jetbrains.kotlin.psi.KtCallExpression abstract class KtCallResolver : KtAnalysisSessionComponent() { abstract fun resolveCall(call: KtCallExpression): KtCall? abstract fun resolveCall(call: KtBinaryExpression): KtCall? +} + +interface KtCallResolverMixIn : KtAnalysisSessionMixIn { + fun KtCallExpression.resolveCall(): KtCall? = + analysisSession.callResolver.resolveCall(this) + + fun KtBinaryExpression.resolveCall(): KtCall? = + analysisSession.callResolver.resolveCall(this) + } \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtCompletionCandidateChecker.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtCompletionCandidateChecker.kt index ed147559dce..2d9d6ab0c6f 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtCompletionCandidateChecker.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtCompletionCandidateChecker.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.idea.frontend.api.components -import com.intellij.psi.PsiElement import org.jetbrains.kotlin.idea.frontend.api.symbols.KtCallableSymbol import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.KtFile @@ -18,4 +17,18 @@ abstract class KtCompletionCandidateChecker : KtAnalysisSessionComponent() { nameExpression: KtSimpleNameExpression, possibleExplicitReceiver: KtExpression?, ): Boolean +} + +interface KtCompletionCandidateCheckerMixIn : KtAnalysisSessionMixIn { + fun KtCallableSymbol.checkExtensionIsSuitable( + originalPsiFile: KtFile, + psiFakeCompletionExpression: KtSimpleNameExpression, + psiReceiverExpression: KtExpression?, + ): Boolean = + analysisSession.completionCandidateChecker.checkExtensionFitsCandidate( + this, + originalPsiFile, + psiFakeCompletionExpression, + psiReceiverExpression + ) } \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt index 7964d4e3c17..4b7f58a581b 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.idea.frontend.api.components +import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnostic import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile @@ -14,6 +15,14 @@ abstract class KtDiagnosticProvider : KtAnalysisSessionComponent() { abstract fun collectDiagnosticsForFile(ktFile: KtFile, filter: KtDiagnosticCheckerFilter): Collection> } +interface KtDiagnosticProviderMixIn : KtAnalysisSessionMixIn { + fun KtElement.getDiagnostics(filter: KtDiagnosticCheckerFilter): Collection = + analysisSession.diagnosticProvider.getDiagnosticsForElement(this, filter) + + fun KtFile.collectDiagnosticsForFile(filter: KtDiagnosticCheckerFilter): Collection> = + analysisSession.diagnosticProvider.collectDiagnosticsForFile(this, filter) +} + enum class KtDiagnosticCheckerFilter { ONLY_COMMON_CHECKERS, ONLY_EXTENDED_CHECKERS, diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionHandlingComponent.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionHandlingComponent.kt deleted file mode 100644 index 74a5c7a46f1..00000000000 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionHandlingComponent.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2010-2020 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.idea.frontend.api.components - -import org.jetbrains.kotlin.idea.frontend.api.symbols.KtCallableSymbol -import org.jetbrains.kotlin.idea.frontend.api.symbols.KtFunctionLikeSymbol -import org.jetbrains.kotlin.psi.KtReturnExpression - -abstract class KtExpressionHandlingComponent : KtAnalysisSessionComponent() { - abstract fun getReturnExpressionTargetSymbol(returnExpression: KtReturnExpression): KtCallableSymbol? -} \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionInfoProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionInfoProvider.kt new file mode 100644 index 00000000000..d0a63e81235 --- /dev/null +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionInfoProvider.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2020 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.idea.frontend.api.components + +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtCallableSymbol +import org.jetbrains.kotlin.psi.KtReturnExpression + +abstract class KtExpressionInfoProvider : KtAnalysisSessionComponent() { + abstract fun getReturnExpressionTargetSymbol(returnExpression: KtReturnExpression): KtCallableSymbol? +} + +interface KtExpressionInfoProviderMixIn : KtAnalysisSessionMixIn { + fun KtReturnExpression.getReturnTargetSymbol(): KtCallableSymbol? = + analysisSession.expressionInfoProvider.getReturnExpressionTargetSymbol(this) +} \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionTypeProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionTypeProvider.kt index 5a4de47792b..96b66e5a110 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionTypeProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtExpressionTypeProvider.kt @@ -17,3 +17,14 @@ abstract class KtExpressionTypeProvider : KtAnalysisSessionComponent() { abstract fun getExpectedType(expression: PsiElement): KtType? } + +interface KtExpressionTypeProviderMixIn : KtAnalysisSessionMixIn { + fun KtExpression.getKtType(): KtType = + analysisSession.expressionTypeProvider.getKtExpressionType(this) + + fun KtDeclaration.getReturnKtType(): KtType = + analysisSession.expressionTypeProvider.getReturnTypeForKtDeclaration(this) + + fun PsiElement.getExpectedType(): KtType? = + analysisSession.expressionTypeProvider.getExpectedType(this) +} diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceResolveMixIn.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceResolveMixIn.kt new file mode 100644 index 00000000000..84e8fc1d116 --- /dev/null +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceResolveMixIn.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2010-2021 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.idea.frontend.api.components + +import org.jetbrains.kotlin.idea.frontend.api.KtSymbolBasedReference +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer +import org.jetbrains.kotlin.idea.references.KtReference +import org.jetbrains.kotlin.idea.references.KtSimpleReference + +interface KtReferenceResolveMixIn : KtAnalysisSessionMixIn { + fun KtReference.resolveToSymbols(): Collection { + check(this is KtSymbolBasedReference) { "To get reference symbol the one should be KtSymbolBasedReference" } + return analysisSession.resolveToSymbols() + } + + fun KtSimpleReference<*>.resolveToSymbol(): KtSymbol? { + check(this is KtSymbolBasedReference) { "To get reference symbol the one should be KtSymbolBasedReference but was ${this::class}" } + return resolveToSymbols().singleOrNull() + } +} \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt index 311f50194c0..564bc27f00b 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtReferenceShortener.kt @@ -12,6 +12,11 @@ abstract class KtReferenceShortener : KtAnalysisSessionComponent() { abstract fun collectShortenings(file: KtFile, selection: TextRange): ShortenCommand } +interface KtReferenceShortenerMixIn : KtAnalysisSessionMixIn { + fun collectPossibleReferenceShortenings(file: KtFile, selection: TextRange): ShortenCommand = + analysisSession.referenceShortener.collectShortenings(file, selection) +} + interface ShortenCommand { fun invokeShortening() } \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtScopeProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtScopeProvider.kt index 169fe140677..0cba32841d2 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtScopeProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtScopeProvider.kt @@ -29,4 +29,27 @@ abstract class KtScopeProvider : KtAnalysisSessionComponent() { ): KtScopeContext } +interface KtScopeProviderMixIn : KtAnalysisSessionMixIn { + fun KtSymbolWithMembers.getMemberScope(): KtMemberScope = + analysisSession.scopeProvider.getMemberScope(this) + + fun KtSymbolWithMembers.getDeclaredMemberScope(): KtDeclaredMemberScope = + analysisSession.scopeProvider.getDeclaredMemberScope(this) + + fun KtFileSymbol.getFileScope(): KtDeclarationScope = + analysisSession.scopeProvider.getFileScope(this) + + fun KtPackageSymbol.getPackageScope(): KtPackageScope = + analysisSession.scopeProvider.getPackageScope(this) + + fun List.asCompositeScope(): KtCompositeScope = + analysisSession.scopeProvider.getCompositeScope(this) + + fun KtType.getTypeScope(): KtScope? = + analysisSession.scopeProvider.getTypeScope(this) + + fun KtFile.getScopeContextForPosition(positionInFakeFile: KtElement): KtScopeContext = + analysisSession.scopeProvider.getScopeContextForPosition(this, positionInFakeFile) +} + data class KtScopeContext(val scopes: KtCompositeScope, val implicitReceiversTypes: List) diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSmartCastProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSmartCastProvider.kt index 415804c1af2..f1a1b604c41 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSmartCastProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSmartCastProvider.kt @@ -12,4 +12,12 @@ import org.jetbrains.kotlin.psi.KtExpression abstract class KtSmartCastProvider : KtAnalysisSessionComponent() { abstract fun getSmartCastedToType(expression: KtExpression): KtType? abstract fun getImplicitReceiverSmartCast(expression: KtExpression): Collection +} + +interface KtSmartCastProviderMixIn : KtAnalysisSessionMixIn { + fun KtExpression.getSmartCast(): KtType? = + analysisSession.smartCastProvider.getSmartCastedToType(this) + + fun KtExpression.getImplicitReceiverSmartCast(): Collection = + analysisSession.smartCastProvider.getImplicitReceiverSmartCast(this) } \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSubtypingComponent.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSubtypingComponent.kt index 58c0e33ef24..3f412cdde6e 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSubtypingComponent.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSubtypingComponent.kt @@ -10,4 +10,15 @@ import org.jetbrains.kotlin.idea.frontend.api.types.KtType abstract class KtSubtypingComponent : KtAnalysisSessionComponent() { abstract fun isEqualTo(first: KtType, second: KtType): Boolean abstract fun isSubTypeOf(subType: KtType, superType: KtType): Boolean +} + +interface KtSubtypingComponentMixIn : KtAnalysisSessionMixIn { + infix fun KtType.isEqualTo(other: KtType): Boolean = + analysisSession.subtypingComponent.isEqualTo(this, other) + + infix fun KtType.isSubTypeOf(superType: KtType): Boolean = + analysisSession.subtypingComponent.isSubTypeOf(this, superType) + + infix fun KtType.isNotSubTypeOf(superType: KtType): Boolean = + !analysisSession.subtypingComponent.isSubTypeOf(this, superType) } \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolContainingDeclarationProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolContainingDeclarationProvider.kt index eea4d4181f5..0ce5ac09520 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolContainingDeclarationProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolContainingDeclarationProvider.kt @@ -8,11 +8,16 @@ package org.jetbrains.kotlin.idea.frontend.api.components import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithKind abstract class KtSymbolContainingDeclarationProvider : KtAnalysisSessionComponent() { + abstract fun getContainingDeclaration(symbol: KtSymbolWithKind): KtSymbolWithKind? +} + +interface KtSymbolContainingDeclarationProviderMixIn : KtAnalysisSessionMixIn { /** * Returns containing declaration for symbol: * for top-level declarations returns null * for class members returns containing class * for local declaration returns declaration it was declared it */ - abstract fun getContainingDeclaration(symbol: KtSymbolWithKind): KtSymbolWithKind? + fun KtSymbolWithKind.getContainingSymbol(): KtSymbolWithKind? = + analysisSession.containingDeclarationProvider.getContainingDeclaration(this) } \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolDeclarationOverridesProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolDeclarationOverridesProvider.kt index e93c087fbac..f619768a90d 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolDeclarationOverridesProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolDeclarationOverridesProvider.kt @@ -10,24 +10,37 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassOrObjectSymbol import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol abstract class KtSymbolDeclarationOverridesProvider : KtAnalysisSessionComponent() { - /** - * Returns symbols that are overridden by requested - */ - abstract fun getAllOverriddenSymbols( - callableSymbol: T, - ): List + abstract fun getAllOverriddenSymbols(callableSymbol: T): List + abstract fun getDirectlyOverriddenSymbols(callableSymbol: T): List - /** - * Returns symbols that are overridden by requested - */ - abstract fun getDirectlyOverriddenSymbols( - callableSymbol: T, - ): List - - - /** - * If [symbol] origin is [org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbolOrigin.INTERSECTION_OVERRIDE] - * Then returns the symbols which [symbol] overrides, otherwise empty collection - */ abstract fun getIntersectionOverriddenSymbols(symbol: KtCallableSymbol): Collection +} + +interface KtSymbolDeclarationOverridesProviderMixIn : KtAnalysisSessionMixIn { + /** + * Return a list of **all** symbols which are overridden by symbol + * + * E.g, if we have `A.foo` overrides `B.foo` overrides `C.foo`, all two super declarations `B.foo`, `C.foo` will be returned + * + * Unwraps substituted overridden symbols (see [org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbolOrigin.INTERSECTION_OVERRIDE]) + * + * @see getDirectlyOverriddenSymbols + */ + fun KtCallableSymbol.getAllOverriddenSymbols(): List = + analysisSession.symbolDeclarationOverridesProvider.getAllOverriddenSymbols(this) + + /** + * Return a list of symbols which are **directly** overridden by symbol + ** + * E.g, if we have `A.foo` overrides `B.foo` overrides `C.foo`, only declarations directly overriden `B.foo` will be returned + * + * Unwraps substituted overridden symbols (see [org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbolOrigin.INTERSECTION_OVERRIDE]) + * + * @see getAllOverriddenSymbols + */ + fun KtCallableSymbol.getDirectlyOverriddenSymbols(): List = + analysisSession.symbolDeclarationOverridesProvider.getDirectlyOverriddenSymbols(this) + + fun KtCallableSymbol.getIntersectionOverriddenSymbols(): Collection = + analysisSession.symbolDeclarationOverridesProvider.getIntersectionOverriddenSymbols(this) } \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolsMixIn.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolsMixIn.kt new file mode 100644 index 00000000000..ec38c2908ce --- /dev/null +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolsMixIn.kt @@ -0,0 +1,14 @@ +/* + * Copyright 2010-2021 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.idea.frontend.api.components + +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.pointers.KtSymbolPointer + +interface KtSymbolsMixIn : KtAnalysisSessionMixIn { + @Suppress("DEPRECATION") + fun KtSymbolPointer.restoreSymbol(): S? = restoreSymbol(analysisSession) +} \ No newline at end of file diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeProvider.kt index 1f69c3d56fb..f701df11bcd 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeProvider.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.idea.frontend.api.components -import org.jetbrains.kotlin.builtins.functions.FunctionClassKind import org.jetbrains.kotlin.idea.frontend.api.ValidityTokenOwner import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassOrObjectSymbol import org.jetbrains.kotlin.idea.frontend.api.types.KtType @@ -18,6 +17,23 @@ abstract class KtTypeProvider : KtAnalysisSessionComponent() { abstract fun buildSelfClassType(symbol: KtClassOrObjectSymbol): KtType } +interface KtTypeProviderMixIn : KtAnalysisSessionMixIn { + val builtinTypes: KtBuiltinTypes + get() = analysisSession.typeProvider.builtinTypes + + /** + * Approximates [KtType] with the a supertype which can be rendered in a source code + * + * Return `null` if the type do not need approximation and can be rendered as is + * Otherwise, for type `T` return type `S` such `T <: S` and `T` and every it type argument is [org.jetbrains.kotlin.idea.frontend.api.types.KtDenotableType]` + */ + fun KtType.approximateToSuperPublicDenotable(): KtType? = + analysisSession.typeProvider.approximateToSuperPublicDenotableType(this) + + fun KtClassOrObjectSymbol.buildSelfClassType(): KtType = + analysisSession.typeProvider.buildSelfClassType(this) + +} @Suppress("PropertyName") abstract class KtBuiltinTypes : ValidityTokenOwner { diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeRenderer.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeRenderer.kt index 3f9770b03ce..2aa371b0c6d 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeRenderer.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtTypeRenderer.kt @@ -14,6 +14,11 @@ abstract class KtTypeRenderer : KtAnalysisSessionComponent() { abstract fun render(type: KtType, options: KtTypeRendererOptions): String } +interface KtTypeRendererMixIn : KtAnalysisSessionMixIn { + fun KtType.render(options: KtTypeRendererOptions = KtTypeRendererOptions.DEFAULT): String = + analysisSession.typeRenderer.render(this, options) +} + data class KtTypeRendererOptions( val renderFqNames: Boolean, val renderFunctionTypes: Boolean diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/symbols/KtSymbolProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/symbols/KtSymbolProvider.kt index c4381a90d6e..6d15de3665c 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/symbols/KtSymbolProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/symbols/KtSymbolProvider.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.idea.frontend.api.symbols import org.jetbrains.kotlin.idea.frontend.api.components.KtAnalysisSessionComponent +import org.jetbrains.kotlin.idea.frontend.api.components.KtAnalysisSessionMixIn import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -43,10 +44,61 @@ abstract class KtSymbolProvider : KtAnalysisSessionComponent() { abstract fun getClassOrObjectSymbol(psi: KtClassOrObject): KtClassOrObjectSymbol abstract fun getPropertyAccessorSymbol(psi: KtPropertyAccessor): KtPropertyAccessorSymbol - /** - * @return symbol with specified [classId] or `null` in case such symbol is not found - */ abstract fun getClassOrObjectSymbolByClassId(classId: ClassId): KtClassOrObjectSymbol? abstract fun getTopLevelCallableSymbols(packageFqName: FqName, name: Name): Sequence +} + +interface KtSymbolProviderMixIn : KtAnalysisSessionMixIn { + fun KtDeclaration.getSymbol(): KtSymbol = + analysisSession.symbolProvider.getSymbol(this) + + fun KtParameter.getParameterSymbol(): KtParameterSymbol = + analysisSession.symbolProvider.getParameterSymbol(this) + + fun KtNamedFunction.getFunctionSymbol(): KtFunctionSymbol = + analysisSession.symbolProvider.getFunctionSymbol(this) + + fun KtConstructor<*>.getConstructorSymbol(): KtConstructorSymbol = + analysisSession.symbolProvider.getConstructorSymbol(this) + + fun KtTypeParameter.getTypeParameterSymbol(): KtTypeParameterSymbol = + analysisSession.symbolProvider.getTypeParameterSymbol(this) + + fun KtTypeAlias.getTypeAliasSymbol(): KtTypeAliasSymbol = + analysisSession.symbolProvider.getTypeAliasSymbol(this) + + fun KtEnumEntry.getEnumEntrySymbol(): KtEnumEntrySymbol = + analysisSession.symbolProvider.getEnumEntrySymbol(this) + + fun KtNamedFunction.getAnonymousFunctionSymbol(): KtAnonymousFunctionSymbol = + analysisSession.symbolProvider.getAnonymousFunctionSymbol(this) + + fun KtLambdaExpression.getAnonymousFunctionSymbol(): KtAnonymousFunctionSymbol = + analysisSession.symbolProvider.getAnonymousFunctionSymbol(this) + + fun KtProperty.getVariableSymbol(): KtVariableSymbol = + analysisSession.symbolProvider.getVariableSymbol(this) + + fun KtObjectLiteralExpression.getAnonymousObjectSymbol(): KtAnonymousObjectSymbol = + analysisSession.symbolProvider.getAnonymousObjectSymbol(this) + + fun KtClassOrObject.getClassOrObjectSymbol(): KtClassOrObjectSymbol = + analysisSession.symbolProvider.getClassOrObjectSymbol(this) + + fun KtPropertyAccessor.getPropertyAccessorSymbol(): KtPropertyAccessorSymbol = + analysisSession.symbolProvider.getPropertyAccessorSymbol(this) + + fun KtFile.getFileSymbol(): KtFileSymbol = + analysisSession.symbolProvider.getFileSymbol(this) + + /** + * @return symbol with specified [this@getClassOrObjectSymbolByClassId] or `null` in case such symbol is not found + */ + fun ClassId.getCorrespondingToplevelClassOrObjectSymbol(): KtClassOrObjectSymbol? = + analysisSession.symbolProvider.getClassOrObjectSymbolByClassId(this) + + fun FqName.getContainingCallableSymbolsWithName(name: Name): Sequence = + analysisSession.symbolProvider.getTopLevelCallableSymbols(this, name) + } \ No newline at end of file diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtFirAnalysisSession.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtFirAnalysisSession.kt index 4a9a1f25955..dd9560b0c9a 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtFirAnalysisSession.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/KtFirAnalysisSession.kt @@ -16,13 +16,11 @@ import org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession import org.jetbrains.kotlin.idea.frontend.api.ReadActionConfinementValidityToken import org.jetbrains.kotlin.idea.frontend.api.ValidityToken import org.jetbrains.kotlin.idea.frontend.api.assertIsValidAndAccessible -import org.jetbrains.kotlin.idea.frontend.api.components.* import org.jetbrains.kotlin.idea.frontend.api.fir.components.* import org.jetbrains.kotlin.idea.frontend.api.fir.symbols.KtFirSymbolProvider import org.jetbrains.kotlin.idea.frontend.api.fir.utils.EnclosingDeclarationContext import org.jetbrains.kotlin.idea.frontend.api.fir.utils.recordCompletionContext import org.jetbrains.kotlin.idea.frontend.api.fir.utils.threadLocal -import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbolProvider import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile @@ -38,22 +36,33 @@ private constructor( assertIsValidAndAccessible() } - override val smartCastProvider: KtSmartCastProvider = KtFirSmartcastProvider(this, token) - override val expressionTypeProvider: KtExpressionTypeProvider = KtFirExpressionTypeProvider(this, token) - public override val diagnosticProvider: KtDiagnosticProvider = KtFirDiagnosticProvider(this, token) - override val containingDeclarationProvider = KtFirSymbolContainingDeclarationProvider(this, token) - override val callResolver: KtCallResolver = KtFirCallResolver(this, token) - override val scopeProvider by threadLocal { KtFirScopeProvider(this, firSymbolBuilder, project, firResolveState, token) } - override val symbolProvider: KtSymbolProvider = - KtFirSymbolProvider(this, firResolveState.rootModuleSession.symbolProvider, firResolveState, firSymbolBuilder, token) - override val completionCandidateChecker: KtCompletionCandidateChecker = KtFirCompletionCandidateChecker(this, token) - override val symbolDeclarationOverridesProvider: KtSymbolDeclarationOverridesProvider = - KtFirSymbolDeclarationOverridesProvider(this, token) - override val referenceShortener: KtReferenceShortener = KtFirReferenceShortener(this, token, firResolveState) + override val smartCastProviderImpl = KtFirSmartcastProvider(this, token) - override val expressionHandlingComponent: KtExpressionHandlingComponent = KtFirExpressionHandlingComponent(this, token) - override val typeProvider: KtTypeProvider = KtFirTypeProvider(this, token) - override val subtypingComponent: KtSubtypingComponent = KtFirSubtypingComponent(this, token) + override val expressionTypeProviderImpl = KtFirExpressionTypeProvider(this, token) + + override val diagnosticProviderImpl = KtFirDiagnosticProvider(this, token) + + override val containingDeclarationProviderImpl = KtFirSymbolContainingDeclarationProvider(this, token) + + override val callResolverImpl = KtFirCallResolver(this, token) + + override val scopeProviderImpl by threadLocal { KtFirScopeProvider(this, firSymbolBuilder, project, firResolveState, token) } + + override val symbolProviderImpl = + KtFirSymbolProvider(this, firResolveState.rootModuleSession.symbolProvider, firResolveState, firSymbolBuilder, token) + + override val completionCandidateCheckerImpl = KtFirCompletionCandidateChecker(this, token) + + override val symbolDeclarationOverridesProviderImpl = + KtFirSymbolDeclarationOverridesProvider(this, token) + + override val referenceShortenerImpl = KtFirReferenceShortener(this, token, firResolveState) + + override val expressionInfoProviderImpl = KtFirExpressionInfoProvider(this, token) + + override val typeProviderImpl = KtFirTypeProvider(this, token) + + override val subtypingComponentImpl = KtFirSubtypingComponent(this, token) override fun createContextDependentCopy(originalKtFile: KtFile, fakeKtElement: KtElement): KtAnalysisSession { check(context == KtFirAnalysisSessionContext.DefaultContext) { diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt index c3e8ab530e8..1c0b26ef2c7 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt @@ -7,29 +7,37 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic +import org.jetbrains.kotlin.fir.analysis.diagnostics.toFirDiagnostic import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.ConeTypeCheckerContext +import org.jetbrains.kotlin.idea.frontend.api.ValidityTokenOwner +import org.jetbrains.kotlin.idea.frontend.api.components.KtAnalysisSessionComponent import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnostic import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession +import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KT_DIAGNOSTIC_CONVERTER internal interface KtFirAnalysisSessionComponent { val analysisSession: KtFirAnalysisSession val rootModuleSession: FirSession get() = analysisSession.firResolveState.rootModuleSession - val firSymbolBuilder get() = analysisSession.firSymbolBuilder val firResolveState get() = analysisSession.firResolveState + fun ConeKotlinType.asKtType() = analysisSession.firSymbolBuilder.buildKtType(this) fun FirPsiDiagnostic<*>.asKtDiagnostic(): KtDiagnosticWithPsi<*> = - (analysisSession.diagnosticProvider as KtFirDiagnosticProvider).firDiagnosticAsKtDiagnostic(this) + KT_DIAGNOSTIC_CONVERTER.convert(analysisSession, this as FirDiagnostic<*>) - fun ConeDiagnostic.asKtDiagnostic(source: FirSourceElement): KtDiagnostic? = - (analysisSession.diagnosticProvider as KtFirDiagnosticProvider).coneDiagnosticAsKtDiagnostic(this, source) + fun ConeDiagnostic.asKtDiagnostic(source: FirSourceElement): KtDiagnosticWithPsi<*>? { + val firDiagnostic = toFirDiagnostic(source) ?: return null + check(firDiagnostic is FirPsiDiagnostic<*>) + return firDiagnostic.asKtDiagnostic() + } fun createTypeCheckerContext() = ConeTypeCheckerContext( isErrorTypeEqualsToAnything = true, diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt index 68bdd683e01..d25456b908c 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt @@ -5,12 +5,6 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.fir.FirSourceElement -import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic -import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic -import org.jetbrains.kotlin.fir.analysis.diagnostics.toFirDiagnostic -import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic import org.jetbrains.kotlin.idea.fir.low.level.api.api.DiagnosticCheckerFilter import org.jetbrains.kotlin.idea.fir.low.level.api.api.collectDiagnosticsForFile import org.jetbrains.kotlin.idea.fir.low.level.api.api.getDiagnostics @@ -19,7 +13,6 @@ import org.jetbrains.kotlin.idea.frontend.api.components.KtDiagnosticCheckerFilt import org.jetbrains.kotlin.idea.frontend.api.components.KtDiagnosticProvider import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession -import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KT_DIAGNOSTIC_CONVERTER import org.jetbrains.kotlin.idea.frontend.api.withValidityAssertion import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile @@ -38,19 +31,10 @@ internal class KtFirDiagnosticProvider( override fun collectDiagnosticsForFile(ktFile: KtFile, filter: KtDiagnosticCheckerFilter): Collection> = ktFile.collectDiagnosticsForFile(firResolveState, filter.asLLFilter()).map { it.asKtDiagnostic() } - fun firDiagnosticAsKtDiagnostic(diagnostic: FirPsiDiagnostic<*>): KtDiagnosticWithPsi<*> { - return KT_DIAGNOSTIC_CONVERTER.convert(analysisSession, diagnostic as FirDiagnostic<*>) - } private fun KtDiagnosticCheckerFilter.asLLFilter() = when (this) { KtDiagnosticCheckerFilter.ONLY_COMMON_CHECKERS -> DiagnosticCheckerFilter.ONLY_COMMON_CHECKERS KtDiagnosticCheckerFilter.ONLY_EXTENDED_CHECKERS -> DiagnosticCheckerFilter.ONLY_EXTENDED_CHECKERS KtDiagnosticCheckerFilter.EXTENDED_AND_COMMON_CHECKERS -> DiagnosticCheckerFilter.EXTENDED_AND_COMMON_CHECKERS } - - fun coneDiagnosticAsKtDiagnostic(coneDiagnostic: ConeDiagnostic, source: FirSourceElement): KtDiagnosticWithPsi<*>? { - val firDiagnostic = coneDiagnostic.toFirDiagnostic(source) ?: return null - check(firDiagnostic is FirPsiDiagnostic<*>) - return firDiagnosticAsKtDiagnostic(firDiagnostic) - } } \ No newline at end of file diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirExpressionHandlingComponent.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirExpressionInfoProvider.kt similarity index 84% rename from idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirExpressionHandlingComponent.kt rename to idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirExpressionInfoProvider.kt index d8048dcb056..7fdb4052891 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirExpressionHandlingComponent.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirExpressionInfoProvider.kt @@ -8,16 +8,15 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components import org.jetbrains.kotlin.fir.expressions.FirReturnExpression import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFirSafe import org.jetbrains.kotlin.idea.frontend.api.ValidityToken -import org.jetbrains.kotlin.idea.frontend.api.components.KtExpressionHandlingComponent +import org.jetbrains.kotlin.idea.frontend.api.components.KtExpressionInfoProvider import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession import org.jetbrains.kotlin.idea.frontend.api.symbols.KtCallableSymbol -import org.jetbrains.kotlin.idea.frontend.api.symbols.KtFunctionLikeSymbol import org.jetbrains.kotlin.psi.KtReturnExpression -internal class KtFirExpressionHandlingComponent( +internal class KtFirExpressionInfoProvider( override val analysisSession: KtFirAnalysisSession, override val token: ValidityToken, -) : KtExpressionHandlingComponent(), KtFirAnalysisSessionComponent { +) : KtExpressionInfoProvider(), KtFirAnalysisSessionComponent { override fun getReturnExpressionTargetSymbol(returnExpression: KtReturnExpression): KtCallableSymbol? { val fir = returnExpression.getOrBuildFirSafe(firResolveState) ?: return null val firTargetSymbol = fir.target.labeledElement diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSmartcastProvider.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSmartcastProvider.kt index 25dc4adc57f..2b416a98c45 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSmartcastProvider.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSmartcastProvider.kt @@ -10,13 +10,10 @@ import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.coneTypeSafe import org.jetbrains.kotlin.idea.fir.low.level.api.api.getOrBuildFirSafe -import org.jetbrains.kotlin.idea.frontend.api.ImplicitReceiverSmartCast -import org.jetbrains.kotlin.idea.frontend.api.ImplicitReceiverSmartcastKind -import org.jetbrains.kotlin.idea.frontend.api.ValidityToken +import org.jetbrains.kotlin.idea.frontend.api.* import org.jetbrains.kotlin.idea.frontend.api.components.KtSmartCastProvider import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession import org.jetbrains.kotlin.idea.frontend.api.types.KtType -import org.jetbrains.kotlin.idea.frontend.api.withValidityAssertion import org.jetbrains.kotlin.psi.KtExpression internal class KtFirSmartcastProvider( diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/DiagnosticConverter.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtDiagnosticConverter.kt similarity index 100% rename from idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/DiagnosticConverter.kt rename to idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtDiagnosticConverter.kt From aa683d3b2acd1c8ef733d400088dbd1ab696ec8c Mon Sep 17 00:00:00 2001 From: "Aleksei.Cherepanov" Date: Mon, 1 Feb 2021 13:08:43 +0300 Subject: [PATCH 317/368] JPS: Fix JvmMultifileClass processing for IR backend #KT-44644 Fixed --- .../kotlin/incremental/IncrementalJvmCache.kt | 4 ++ .../build/IncrementalJvmJpsTestGenerated.java | 5 ++ .../kotlin/jps/build/KotlinBuilder.kt | 46 +++++++++++++++++-- .../build.log | 7 +-- .../other/multifileClassFileAdded/build.log | 17 ++++++- .../other/multifileClassFileChanged/build.log | 6 ++- .../other/multifileDependantUsage/build.log | 25 ++++++++++ .../other/multifileDependantUsage/partA.kt | 4 ++ .../other/multifileDependantUsage/partB.kt | 10 ++++ .../multifileDependantUsage/partB.kt.new.1 | 4 ++ .../multifileDependantUsage/usagePartB.kt | 1 + .../multifilePackagePartMethodAdded/build.log | 14 +++--- .../multifilePartsWithProperties/build.log | 8 +--- tests/mute-common.csv | 5 -- 14 files changed, 127 insertions(+), 29 deletions(-) create mode 100644 jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/build.log create mode 100644 jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partA.kt create mode 100644 jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partB.kt create mode 100644 jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partB.kt.new.1 create mode 100644 jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/usagePartB.kt diff --git a/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt b/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt index 84d75a417d6..35884af0d79 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt @@ -94,6 +94,10 @@ open class IncrementalJvmCache( fun sourcesByInternalName(internalName: String): Collection = internalNameToSource[internalName] + fun getAllPartsOfMultifileFacade(facade: JvmClassName): Collection? { + return multifileFacadeToParts[facade] + } + fun isMultifileFacade(className: JvmClassName): Boolean = className in multifileFacadeToParts diff --git a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalJvmJpsTestGenerated.java b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalJvmJpsTestGenerated.java index c8de15fe074..fcaad30416a 100644 --- a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalJvmJpsTestGenerated.java +++ b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/IncrementalJvmJpsTestGenerated.java @@ -2261,6 +2261,11 @@ public class IncrementalJvmJpsTestGenerated extends AbstractIncrementalJvmJpsTes runTest("jps-plugin/testData/incremental/withJava/other/multifilePartsWithProperties/"); } + @TestMetadata("multifileDependantUsage") + public void testMultifileDependantUsage() throws Exception { + runTest("jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/"); + } + @TestMetadata("optionalParameter") public void testOptionalParameter() throws Exception { runTest("jps-plugin/testData/incremental/withJava/other/optionalParameter/"); diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt index 04afe480d2c..7266485c1ca 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt @@ -29,6 +29,7 @@ import org.jetbrains.jps.incremental.ModuleLevelBuilder.ExitCode.* import org.jetbrains.jps.incremental.java.JavaBuilder import org.jetbrains.jps.model.JpsProject import org.jetbrains.kotlin.build.GeneratedFile +import org.jetbrains.kotlin.build.GeneratedJvmClass import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity @@ -48,6 +49,7 @@ import org.jetbrains.kotlin.jps.incremental.JpsLookupStorageManager import org.jetbrains.kotlin.jps.model.kotlinKind import org.jetbrains.kotlin.jps.targets.KotlinJvmModuleBuildTarget import org.jetbrains.kotlin.jps.targets.KotlinModuleBuildTarget +import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.preloading.ClassCondition import org.jetbrains.kotlin.utils.KotlinPaths @@ -439,6 +441,9 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { } val generatedFiles = getGeneratedFiles(context, chunk, environment.outputItemsCollector) + + markDirtyComplementaryMultifileClasses(generatedFiles, kotlinContext, incrementalCaches, fsOperations) + val kotlinTargets = kotlinContext.targetsBinding for ((target, outputItems) in generatedFiles) { val kotlinTarget = kotlinTargets[target] ?: error("Could not find Kotlin target for JPS target $target") @@ -526,14 +531,23 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { for (target in kotlinChunk.targets) { val cache = incrementalCaches[target] val jpsTarget = target.jpsModuleBuildTarget + val targetDirtyFiles = dirtyFilesHolder.byTarget[jpsTarget] - if (cache != null && targetDirtyFiles != null) { - val complementaryFiles = cache.getComplementaryFilesRecursive( - targetDirtyFiles.dirty.keys + targetDirtyFiles.removed - ) + val dirtyFiles = targetDirtyFiles.dirty.keys + targetDirtyFiles.removed + val complementaryFiles = cache.getComplementaryFilesRecursive(dirtyFiles) - fsOperations.markFilesForCurrentRound(jpsTarget, complementaryFiles) + // Get all parts of @JvmMultifileClass file for simultaneous rebuild + var dirtyMultifileClassFiles: Collection = emptyList() + if (cache is IncrementalJvmCache) { + dirtyMultifileClassFiles = cache.classesBySources(dirtyFiles) + .filter { cache.isMultifileFacade(it) } + .flatMap { cache.getAllPartsOfMultifileFacade(it).orEmpty() } + .flatMap { cache.sourcesByInternalName(it) } + .distinct() + .filter { !dirtyFiles.contains(it) } + } + fsOperations.markFilesForCurrentRound(jpsTarget, complementaryFiles + dirtyMultifileClassFiles) cache.markDirty(targetDirtyFiles.dirty.keys + targetDirtyFiles.removed) } @@ -666,6 +680,28 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) { lookupStorage.addAll(lookupTracker.lookups, lookupTracker.pathInterner.values) } } + + private fun markDirtyComplementaryMultifileClasses( + generatedFiles: Map>, + kotlinContext: KotlinCompileContext, + incrementalCaches: Map, JpsIncrementalCache>, + fsOperations: FSOperationsHelper + ) { + for ((target, files) in generatedFiles) { + val kotlinModuleBuilderTarget = kotlinContext.targetsBinding[target] ?: continue + val cache = incrementalCaches[kotlinModuleBuilderTarget] as? IncrementalJvmCache ?: continue + val generated = files.filterIsInstance() + val multifileClasses = generated.filter { it.outputClass.classHeader.kind == KotlinClassHeader.Kind.MULTIFILE_CLASS } + val expectedAllParts = multifileClasses.flatMap { cache.getAllPartsOfMultifileFacade(it.outputClass.className).orEmpty() } + if (multifileClasses.isEmpty()) continue + val actualParts = generated.filter { it.outputClass.classHeader.kind == KotlinClassHeader.Kind.MULTIFILE_CLASS_PART } + .map { it.outputClass.className.toString() } + if (!actualParts.containsAll(expectedAllParts)) { + fsOperations.markFiles(expectedAllParts.flatMap { cache.sourcesByInternalName(it) } + + multifileClasses.flatMap { it.sourceFiles }) + } + } + } } private class JpsICReporter : ICReporterBase() { diff --git a/jps-plugin/testData/incremental/withJava/other/multifileClassAddTopLevelFunWithDefault/build.log b/jps-plugin/testData/incremental/withJava/other/multifileClassAddTopLevelFunWithDefault/build.log index b13957b6b52..0a37a7011af 100644 --- a/jps-plugin/testData/incremental/withJava/other/multifileClassAddTopLevelFunWithDefault/build.log +++ b/jps-plugin/testData/incremental/withJava/other/multifileClassAddTopLevelFunWithDefault/build.log @@ -5,7 +5,11 @@ Cleaning output files: out/production/module/test/Test.class out/production/module/test/Test__BKt.class End of files +Cleaning output files: + out/production/module/test/Test__AKt.class +End of files Compiling files: + src/a.kt src/b.kt End of files Marked as dirty by Kotlin: @@ -14,12 +18,9 @@ Exit code: ADDITIONAL_PASS_REQUIRED ------------------------------------------ Cleaning output files: out/production/module/META-INF/module.kotlin_module - out/production/module/test/Test.class - out/production/module/test/Test__AKt.class out/production/module/usage/UsageKt.class End of files Compiling files: - src/a.kt src/usage.kt End of files Exit code: OK diff --git a/jps-plugin/testData/incremental/withJava/other/multifileClassFileAdded/build.log b/jps-plugin/testData/incremental/withJava/other/multifileClassFileAdded/build.log index 2fb46435909..063de2e6436 100644 --- a/jps-plugin/testData/incremental/withJava/other/multifileClassFileAdded/build.log +++ b/jps-plugin/testData/incremental/withJava/other/multifileClassFileAdded/build.log @@ -3,5 +3,20 @@ Compiling files: src/b.kt End of files -Exit code: OK +Marked as dirty by Kotlin: + src/a.kt + src/b.kt +Exit code: ADDITIONAL_PASS_REQUIRED ------------------------------------------ +Cleaning output files: + out/production/module/META-INF/module.kotlin_module + out/production/module/test/Test.class + out/production/module/test/Test__AKt.class + out/production/module/test/Test__BKt.class +End of files +Compiling files: + src/a.kt + src/b.kt +End of files +Exit code: OK +------------------------------------------ \ No newline at end of file diff --git a/jps-plugin/testData/incremental/withJava/other/multifileClassFileChanged/build.log b/jps-plugin/testData/incremental/withJava/other/multifileClassFileChanged/build.log index 0aeeb8ca95f..b9ec7f67acd 100644 --- a/jps-plugin/testData/incremental/withJava/other/multifileClassFileChanged/build.log +++ b/jps-plugin/testData/incremental/withJava/other/multifileClassFileChanged/build.log @@ -5,8 +5,12 @@ Cleaning output files: out/production/module/test/Test.class out/production/module/test/Test__BKt.class End of files +Cleaning output files: + out/production/module/test/Test__AKt.class +End of files Compiling files: + src/a.kt src/b.kt End of files Exit code: OK ------------------------------------------- +------------------------------------------ \ No newline at end of file diff --git a/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/build.log b/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/build.log new file mode 100644 index 00000000000..ea02e9ce400 --- /dev/null +++ b/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/build.log @@ -0,0 +1,25 @@ +================ Step #1 ================= + +Marked as dirty by Kotlin: + src/partB.kt + src/usagePartB.kt +Cleaning output files: + out/production/module/META-INF/module.kotlin_module + out/production/module/OuterClass$InnerClass.class + out/production/module/OuterClass.class + out/production/module/UsagePartBKt.class + out/production/module/Utils.class + out/production/module/Utils__PartBKt.class +End of files +Cleaning output files: + out/production/module/Utils__PartAKt.class +End of files +Compiling files: + src/partA.kt + src/partB.kt + src/usagePartB.kt +End of files +Exit code: ABORT +------------------------------------------ +COMPILATION FAILED +Unresolved reference: OuterClass \ No newline at end of file diff --git a/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partA.kt b/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partA.kt new file mode 100644 index 00000000000..457823b86a7 --- /dev/null +++ b/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partA.kt @@ -0,0 +1,4 @@ +@file:JvmName("Utils") +@file:JvmMultifileClass + +val aVal: Int get() = 0 \ No newline at end of file diff --git a/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partB.kt b/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partB.kt new file mode 100644 index 00000000000..bab0026e072 --- /dev/null +++ b/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partB.kt @@ -0,0 +1,10 @@ +@file:JvmName("Utils") +@file:JvmMultifileClass + +val bVal: Int get() = 0 + +class OuterClass{ + inner class InnerClass { + val getZero: Int get() = 0 + } +} \ No newline at end of file diff --git a/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partB.kt.new.1 b/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partB.kt.new.1 new file mode 100644 index 00000000000..27b19de3c69 --- /dev/null +++ b/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/partB.kt.new.1 @@ -0,0 +1,4 @@ +@file:JvmName("Utils") +@file:JvmMultifileClass + +val bVal: Int get() = 0 diff --git a/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/usagePartB.kt b/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/usagePartB.kt new file mode 100644 index 00000000000..306a92e2773 --- /dev/null +++ b/jps-plugin/testData/incremental/withJava/other/multifileDependantUsage/usagePartB.kt @@ -0,0 +1 @@ +fun zero() = OuterClass().InnerClass().getZero \ No newline at end of file diff --git a/jps-plugin/testData/incremental/withJava/other/multifilePackagePartMethodAdded/build.log b/jps-plugin/testData/incremental/withJava/other/multifilePackagePartMethodAdded/build.log index 86910844d44..d2f88033cbb 100644 --- a/jps-plugin/testData/incremental/withJava/other/multifilePackagePartMethodAdded/build.log +++ b/jps-plugin/testData/incremental/withJava/other/multifilePackagePartMethodAdded/build.log @@ -5,11 +5,16 @@ Cleaning output files: out/production/module/Utils.class out/production/module/Utils__PartBKt.class End of files +Cleaning output files: + out/production/module/Utils__PartAKt.class + out/production/module/Utils__PartCKt.class +End of files Compiling files: + src/partA.kt src/partB.kt + src/partC.kt End of files Marked as dirty by Kotlin: - src/partA.kt src/useFooF.kt src/useFooG.kt Exit code: ADDITIONAL_PASS_REQUIRED @@ -18,15 +23,10 @@ Cleaning output files: out/production/module/META-INF/module.kotlin_module out/production/module/UseFooFKt.class out/production/module/UseFooGKt.class - out/production/module/Utils.class - out/production/module/Utils__PartAKt.class - out/production/module/Utils__PartCKt.class End of files Compiling files: - src/partA.kt - src/partC.kt src/useFooF.kt src/useFooG.kt End of files Exit code: OK ------------------------------------------- +------------------------------------------ \ No newline at end of file diff --git a/jps-plugin/testData/incremental/withJava/other/multifilePartsWithProperties/build.log b/jps-plugin/testData/incremental/withJava/other/multifilePartsWithProperties/build.log index 260d0b077bf..2894c2c0a84 100644 --- a/jps-plugin/testData/incremental/withJava/other/multifilePartsWithProperties/build.log +++ b/jps-plugin/testData/incremental/withJava/other/multifilePartsWithProperties/build.log @@ -5,18 +5,12 @@ Cleaning output files: out/production/module/Utils.class out/production/module/Utils__PartBKt.class End of files -Compiling files: - src/partB.kt -End of files -Exit code: OK ------------------------------------------- Cleaning output files: - out/production/module/META-INF/module.kotlin_module - out/production/module/Utils.class out/production/module/Utils__PartAKt.class End of files Compiling files: src/partA.kt + src/partB.kt End of files Exit code: OK ------------------------------------------ \ No newline at end of file diff --git a/tests/mute-common.csv b/tests/mute-common.csv index edb53357168..bf13f1265df 100644 --- a/tests/mute-common.csv +++ b/tests/mute-common.csv @@ -86,11 +86,6 @@ org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.Jvm.testCircularDe org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.Jvm.testCircularDependencySamePackageUnchanged, Temporary muted due to problems with IC and JVM IR backend,, org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.Jvm.testCircularDependencyTopLevelFunctions, Temporary muted due to problems with IC and JVM IR backend,, org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.Jvm.testCircularDependencyWithAccessToInternal, Temporary muted due to problems with IC and JVM IR backend,, -org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.WithJava.Other.testMultifileClassAddTopLevelFunWithDefault, Temporary muted due to problems with IC and JVM IR backend,, -org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.WithJava.Other.testMultifileClassFileAdded, Temporary muted due to problems with IC and JVM IR backend,, -org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.WithJava.Other.testMultifileClassFileChanged, Temporary muted due to problems with IC and JVM IR backend,, -org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.WithJava.Other.testMultifilePackagePartMethodAdded, Temporary muted due to problems with IC and JVM IR backend,, -org.jetbrains.kotlin.jps.build.IncrementalJvmJpsTestGenerated.WithJava.Other.testMultifilePartsWithProperties, Temporary muted due to problems with IC and JVM IR backend,, org.jetbrains.kotlin.jps.build.KotlinJpsBuildTest.testCircularDependenciesDifferentPackages, Temporary muted due to problems with IC and JVM IR backend,, org.jetbrains.kotlin.jps.build.KotlinJpsBuildTest.testCircularDependenciesSamePackage, Temporary muted due to problems with IC and JVM IR backend,, org.jetbrains.kotlin.jps.build.KotlinJpsBuildTest.testCircularDependenciesSamePackageWithTests, Temporary muted due to problems with IC and JVM IR backend,, From d0eeb0535de2a6c4eb295a74f18be94db51b161d Mon Sep 17 00:00:00 2001 From: "Aleksei.Cherepanov" Date: Wed, 17 Feb 2021 16:16:59 +0300 Subject: [PATCH 318/368] Add synchronization to MultiClassFiles maps --- .../org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt b/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt index 35884af0d79..73fd16ca986 100644 --- a/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt +++ b/build-common/src/org/jetbrains/kotlin/incremental/IncrementalJvmCache.kt @@ -429,6 +429,8 @@ open class IncrementalJvmCache( private inner class MultifileClassFacadeMap(storageFile: File) : BasicStringMap>(storageFile, StringCollectionExternalizer) { + + @Synchronized operator fun set(className: JvmClassName, partNames: Collection) { storage[className.internalName] = partNames } @@ -439,6 +441,7 @@ open class IncrementalJvmCache( operator fun contains(className: JvmClassName): Boolean = className.internalName in storage + @Synchronized fun remove(className: JvmClassName) { storage.remove(className.internalName) } @@ -448,6 +451,8 @@ open class IncrementalJvmCache( private inner class MultifileClassPartMap(storageFile: File) : BasicStringMap(storageFile, EnumeratorStringDescriptor.INSTANCE) { + + @Synchronized fun set(partName: String, facadeName: String) { storage[partName] = facadeName } @@ -455,6 +460,7 @@ open class IncrementalJvmCache( fun get(partName: JvmClassName): String? = storage[partName.internalName] + @Synchronized fun remove(className: JvmClassName) { storage.remove(className.internalName) } From 026efca49faa3d69cac524f679d98234f458ec01 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 18 Feb 2021 10:20:35 +0300 Subject: [PATCH 319/368] [Test] Add helpers file with functions for inference testing --- .../helpers/inference/inferenceUtils.kt | 3 +++ .../test/directives/AdditionalFilesDirectives.kt | 7 +++++++ .../AdditionalDiagnosticsSourceFilesProvider.kt | 14 +++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 compiler/testData/diagnostics/helpers/inference/inferenceUtils.kt diff --git a/compiler/testData/diagnostics/helpers/inference/inferenceUtils.kt b/compiler/testData/diagnostics/helpers/inference/inferenceUtils.kt new file mode 100644 index 00000000000..29c941d6fb7 --- /dev/null +++ b/compiler/testData/diagnostics/helpers/inference/inferenceUtils.kt @@ -0,0 +1,3 @@ +fun id(x: K): K = x +fun materialize(): K = null!! +fun select(vararg values: K): K = values[0] diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/AdditionalFilesDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/AdditionalFilesDirectives.kt index 74e4d356c9d..0821ddc2f01 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/AdditionalFilesDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/AdditionalFilesDirectives.kt @@ -44,4 +44,11 @@ object AdditionalFilesDirectives : SimpleDirectivesContainer() { See directory ./compiler/tests-spec/helpers/ """.trimIndent() ) + + val INFERENCE_HELPERS by directive( + description = """ + Adds util functions for type checking + See file ./compiler/testData/diagnostics/helpers/inference/inferenceUtils.kt + """.trimIndent() + ) } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/AdditionalDiagnosticsSourceFilesProvider.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/AdditionalDiagnosticsSourceFilesProvider.kt index 57290e22d28..760b062dae7 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/AdditionalDiagnosticsSourceFilesProvider.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/sourceProviders/AdditionalDiagnosticsSourceFilesProvider.kt @@ -6,8 +6,11 @@ package org.jetbrains.kotlin.test.services.sourceProviders import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives +import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives.CHECK_TYPE +import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives.INFERENCE_HELPERS import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives +import org.jetbrains.kotlin.test.directives.model.SimpleDirective import org.jetbrains.kotlin.test.model.TestFile import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.services.AdditionalSourceProvider @@ -17,7 +20,10 @@ import java.io.File class AdditionalDiagnosticsSourceFilesProvider(testServices: TestServices) : AdditionalSourceProvider(testServices) { companion object { private const val HELPERS_PATH = "./compiler/testData/diagnostics/helpers" - private const val CHECK_TYPE_PATH = "$HELPERS_PATH/types/checkType.kt" + private val DIRECTIVE_TO_FILE_MAP: Map = mapOf( + CHECK_TYPE to "$HELPERS_PATH/types/checkType.kt", + INFERENCE_HELPERS to "$HELPERS_PATH/inference/inferenceUtils.kt" + ) } override val directives: List = @@ -26,8 +32,10 @@ class AdditionalDiagnosticsSourceFilesProvider(testServices: TestServices) : Add @OptIn(ExperimentalStdlibApi::class) override fun produceAdditionalFiles(globalDirectives: RegisteredDirectives, module: TestModule): List { return buildList { - if (containsDirective(globalDirectives, module, AdditionalFilesDirectives.CHECK_TYPE)) { - add(File(CHECK_TYPE_PATH).toTestFile()) + for ((directive, path) in DIRECTIVE_TO_FILE_MAP) { + if (directive in module.directives) { + add(File(path).toTestFile()) + } } } } From 1c0d862e406e874a753a1d8eba0c17392e3118c9 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 18 Feb 2021 11:19:08 +0300 Subject: [PATCH 320/368] [FIR] Don't smartcast variables to invisible types #KT-44802 Fixed --- ...TouchedTilContractsPhaseTestGenerated.java | 5 ++ .../smartcastToTypeParameter.fir.txt | 43 +++++++++++++++ .../smartcasts/smartcastToTypeParameter.kt | 34 ++++++++++++ .../runners/FirDiagnosticTestGenerated.java | 6 +++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 +++ ...irOldFrontendDiagnosticsTestGenerated.java | 12 +++++ .../analysis/cfa/FirReturnsImpliesAnalyzer.kt | 4 ++ .../FirBlackBoxCodegenTestGenerated.java | 6 +++ .../fir/java/FirJavaVisibilityChecker.kt | 6 +-- .../kotlin/fir/FirVisibilityChecker.kt | 23 +++++--- .../fir/resolve/dfa/FirDataFlowAnalyzer.kt | 28 +++++++++- .../kotlin/fir/resolve/dfa/LogicSystem.kt | 12 ++++- .../kotlin/fir/types/ConeInferenceContext.kt | 8 +-- .../codegen/box/smartCasts/kt44802.kt | 46 ++++++++++++++++ .../smartcastToInvisibleType_java.fir.kt | 53 +++++++++++++++++++ .../smartcastToInvisibleType_java.kt | 53 +++++++++++++++++++ .../smartcastToInvisibleType_java.txt | 39 ++++++++++++++ .../smartcastToInvisibleType_kotlin.fir.kt | 43 +++++++++++++++ .../smartcastToInvisibleType_kotlin.kt | 43 +++++++++++++++ .../smartcastToInvisibleType_kotlin.txt | 39 ++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 12 +++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 +++ .../IrBlackBoxCodegenTestGenerated.java | 6 +++ .../LightAnalysisModeTestGenerated.java | 5 ++ 24 files changed, 521 insertions(+), 17 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.kt create mode 100644 compiler/testData/codegen/box/smartCasts/kt44802.kt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.fir.kt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.kt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.txt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.fir.kt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.kt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.txt diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 641a17bb81e..a8cace9712f 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -2885,6 +2885,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.kt"); } + @TestMetadata("smartcastToTypeParameter.kt") + public void testSmartcastToTypeParameter() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.kt"); + } + @TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.fir.txt new file mode 100644 index 00000000000..bd24dd43109 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.fir.txt @@ -0,0 +1,43 @@ +FILE: smartcastToTypeParameter.kt + public abstract interface FirTypeScope : R|kotlin/Any| { + } + public abstract interface AbstractFirBasedSymbol|, R|FirDeclaration|> : R|kotlin/Any| { + public abstract val fir: R|E| + public get(): R|E| + + } + public abstract interface FirCallableSymbol|> : R|AbstractFirBasedSymbol| { + } + public abstract interface FirElement : R|kotlin/Any| { + } + public abstract interface FirSymbolOwner|, R|FirDeclaration|> : R|FirElement| { + public abstract val symbol: R|AbstractFirBasedSymbol| + public get(): R|AbstractFirBasedSymbol| + + } + public abstract interface FirDeclaration : R|FirElement| { + } + public abstract interface FirCallableDeclaration|> : R|FirDeclaration|, R|FirSymbolOwner| { + } + public abstract interface FirCallableMemberDeclaration|> : R|FirCallableDeclaration| { + } + private final inline fun |> computeBaseSymbols(symbol: R|S|, basedSymbol: R|S|, directOverridden: R|FirTypeScope.(S) -> kotlin/collections/List|): R|kotlin/Unit| { + } + public final fun R|FirCallableSymbol<*>|.dispatchReceiverClassOrNull(): R|kotlin/Boolean?| { + ^dispatchReceiverClassOrNull Boolean(true) + } + private final inline fun |, reified S : R|FirCallableSymbol|> createFakeOverriddenIfNeeded(originalSymbol: R|FirCallableSymbol<*>|, basedSymbol: R|S|, computeDirectOverridden: R|FirTypeScope.(S) -> kotlin/collections/List|, someCondition: R|kotlin/Boolean|): R|kotlin/Unit| { + when () { + (R|/originalSymbol| !is R|S|) -> { + ^createFakeOverriddenIfNeeded Unit + } + } + + when () { + ==(R|/originalSymbol|.R|/dispatchReceiverClassOrNull|(), Boolean(true)) && R|/someCondition| -> { + ^createFakeOverriddenIfNeeded Unit + } + } + + R|/computeBaseSymbols|(R|/originalSymbol|, R|/basedSymbol|, R|/computeDirectOverridden|) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.kt new file mode 100644 index 00000000000..47e65b2328e --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.kt @@ -0,0 +1,34 @@ +interface FirTypeScope + +interface AbstractFirBasedSymbol where E : FirSymbolOwner, E : FirDeclaration { + val fir: E +} + +interface FirCallableSymbol> : AbstractFirBasedSymbol + +interface FirElement +interface FirSymbolOwner : FirElement where E : FirSymbolOwner, E : FirDeclaration { + val symbol: AbstractFirBasedSymbol +} +interface FirDeclaration : FirElement +interface FirCallableDeclaration> : FirDeclaration, FirSymbolOwner +interface FirCallableMemberDeclaration> : FirCallableDeclaration + +private inline fun > computeBaseSymbols( + symbol: S, + basedSymbol: S, + directOverridden: FirTypeScope.(S) -> List +) {} + +fun FirCallableSymbol<*>.dispatchReceiverClassOrNull(): Boolean? = true + +private inline fun , reified S : FirCallableSymbol> createFakeOverriddenIfNeeded( + originalSymbol: FirCallableSymbol<*>, + basedSymbol: S, + computeDirectOverridden: FirTypeScope.(S) -> List, + someCondition: Boolean +) { + if (originalSymbol !is S) return + if (originalSymbol.dispatchReceiverClassOrNull() == true && someCondition) return + computeBaseSymbols(originalSymbol, basedSymbol, computeDirectOverridden) +} diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index c850c871cd3..c81aa91cb5d 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -3263,6 +3263,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.kt"); } + @Test + @TestMetadata("smartcastToTypeParameter.kt") + public void testSmartcastToTypeParameter() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.kt"); + } + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index d4bb412ad93..5fd9fb6cc41 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -3300,6 +3300,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToNothing.kt"); } + @Test + @TestMetadata("smartcastToTypeParameter.kt") + public void testSmartcastToTypeParameter() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/smartcasts/smartcastToTypeParameter.kt"); + } + @Nested @TestMetadata("compiler/fir/analysis-tests/testData/resolve/smartcasts/booleans") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index be4efe9b6a6..680ab4c470d 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -25651,6 +25651,18 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastOnSameFieldOfDifferentInstances.kt"); } + @Test + @TestMetadata("smartcastToInvisibleType_java.kt") + public void testSmartcastToInvisibleType_java() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.kt"); + } + + @Test + @TestMetadata("smartcastToInvisibleType_kotlin.kt") + public void testSmartcastToInvisibleType_kotlin() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.kt"); + } + @Test @TestMetadata("smartcastToNothingAfterCheckingForNull.kt") public void testSmartcastToNothingAfterCheckingForNull() throws Exception { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirReturnsImpliesAnalyzer.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirReturnsImpliesAnalyzer.kt index 9be1c19f66a..4108d964a8a 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirReturnsImpliesAnalyzer.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/cfa/FirReturnsImpliesAnalyzer.kt @@ -53,6 +53,10 @@ object FirReturnsImpliesAnalyzer : FirControlFlowChecker() { override fun updateAllReceivers(flow: PersistentFlow) = throw IllegalStateException("Update of all receivers is not possible for this logic system") + + override fun ConeKotlinType.isAcceptableForSmartcast(): Boolean { + return true + } } effects.forEach { effect -> diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 1d3841fa3bb..5abc0ae47ae 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -37668,6 +37668,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/smartCasts/kt42517.kt"); } + @Test + @TestMetadata("kt44802.kt") + public void testKt44802() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44802.kt"); + } + @Test @TestMetadata("kt44804.kt") public void testKt44804() throws Exception { diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaVisibilityChecker.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaVisibilityChecker.kt index 118346cea64..30e9a392e2b 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaVisibilityChecker.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/FirJavaVisibilityChecker.kt @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.fir.NoMutableState import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.getOwnerId -import org.jetbrains.kotlin.fir.resolve.calls.Candidate +import org.jetbrains.kotlin.fir.resolve.calls.ReceiverValue import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol @NoMutableState @@ -23,7 +23,7 @@ object FirJavaVisibilityChecker : FirVisibilityChecker() { symbol: AbstractFirBasedSymbol<*>, useSiteFile: FirFile, containingDeclarations: List, - candidate: Candidate, + dispatchReceiver: ReceiverValue?, session: FirSession ): Boolean { return when (declarationVisibility) { @@ -32,7 +32,7 @@ object FirJavaVisibilityChecker : FirVisibilityChecker() { true } else { val ownerId = symbol.getOwnerId() - ownerId != null && canSeeProtectedMemberOf(containingDeclarations, candidate.dispatchReceiverValue, ownerId, session) + ownerId != null && canSeeProtectedMemberOf(containingDeclarations, dispatchReceiver, ownerId, session) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirVisibilityChecker.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirVisibilityChecker.kt index d2531c45207..ba9583fb0aa 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirVisibilityChecker.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirVisibilityChecker.kt @@ -34,7 +34,7 @@ abstract class FirVisibilityChecker : FirSessionComponent { symbol: AbstractFirBasedSymbol<*>, useSiteFile: FirFile, containingDeclarations: List, - candidate: Candidate, + dispatchReceiver: ReceiverValue?, session: FirSession ): Boolean { return true @@ -45,8 +45,6 @@ abstract class FirVisibilityChecker : FirSessionComponent { declaration: T, candidate: Candidate ): Boolean where T : FirMemberDeclaration, T : FirSymbolOwner<*> { - val symbol = declaration.symbol - if (declaration is FirCallableDeclaration<*> && (declaration.isIntersectionOverride || declaration.isSubstitutionOverride)) { @Suppress("UNCHECKED_CAST") return isVisible(declaration.originalIfFakeOverride() as T, candidate) @@ -56,8 +54,19 @@ abstract class FirVisibilityChecker : FirSessionComponent { val useSiteFile = callInfo.containingFile val containingDeclarations = callInfo.containingDeclarations val session = callInfo.session - val provider = session.firProvider + return isVisible(declaration, session, useSiteFile, containingDeclarations, candidate.dispatchReceiverValue) + } + + fun isVisible( + declaration: T, + session: FirSession, + useSiteFile: FirFile, + containingDeclarations: List, + dispatchReceiver: ReceiverValue? + ): Boolean where T : FirMemberDeclaration, T : FirSymbolOwner<*> { + val provider = session.firProvider + val symbol = declaration.symbol return when (declaration.visibility) { Visibilities.Internal -> { declaration.session == session || session.moduleVisibilityChecker?.isInFriendModule(declaration) == true @@ -91,7 +100,7 @@ abstract class FirVisibilityChecker : FirSessionComponent { Visibilities.Protected -> { val ownerId = symbol.getOwnerId() - ownerId != null && canSeeProtectedMemberOf(containingDeclarations, candidate.dispatchReceiverValue, ownerId, session) + ownerId != null && canSeeProtectedMemberOf(containingDeclarations, dispatchReceiver, ownerId, session) } else -> platformVisibilityCheck( @@ -99,7 +108,7 @@ abstract class FirVisibilityChecker : FirSessionComponent { symbol, useSiteFile, containingDeclarations, - candidate, + dispatchReceiver, session ) } @@ -110,7 +119,7 @@ abstract class FirVisibilityChecker : FirSessionComponent { symbol: AbstractFirBasedSymbol<*>, useSiteFile: FirFile, containingDeclarations: List, - candidate: Candidate, + dispatchReceiver: ReceiverValue?, session: FirSession ): Boolean diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt index 5960fc3ca1a..c7be19bf2af 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt @@ -18,8 +18,7 @@ import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.languageVersionSettings import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference -import org.jetbrains.kotlin.fir.resolve.PersistentImplicitReceiverStack -import org.jetbrains.kotlin.fir.resolve.ResolutionMode +import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.dfa.cfg.* import org.jetbrains.kotlin.fir.resolve.dfa.contracts.buildContractFir import org.jetbrains.kotlin.fir.resolve.dfa.contracts.createArgumentsMapping @@ -31,6 +30,7 @@ import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.visibilityChecker import org.jetbrains.kotlin.fir.visitors.transformSingle import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -84,6 +84,9 @@ abstract class FirDataFlowAnalyzer( private val receiverStack: PersistentImplicitReceiverStack get() = components.implicitReceiverStack as PersistentImplicitReceiverStack + private val symbolProvider = components.session.symbolProvider + private val visibilityChecker = components.session.visibilityChecker + override val logicSystem: PersistentLogicSystem = object : PersistentLogicSystem(components.session.inferenceComponents.ctx) { override fun processUpdatedReceiverVariable(flow: PersistentFlow, variable: RealVariable) { @@ -109,6 +112,27 @@ abstract class FirDataFlowAnalyzer( } } } + + override fun ConeKotlinType.isAcceptableForSmartcast(): Boolean { + return when (this) { + is ConeClassLikeType -> { + val symbol = fullyExpandedType(components.session).lookupTag.toSymbol(components.session) ?: return false + val declaration = symbol.fir as? FirRegularClass ?: return true + visibilityChecker.isVisible( + declaration, + components.session, + components.context.file, + components.context.containers, + dispatchReceiver = null + ) + } + is ConeTypeParameterType -> true + is ConeFlexibleType -> lowerBound.isAcceptableForSmartcast() && upperBound.isAcceptableForSmartcast() + is ConeIntersectionType -> intersectedTypes.all { it.isAcceptableForSmartcast() } + is ConeDefinitelyNotNullType -> original.isAcceptableForSmartcast() + else -> false + } + } } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt index ed7d56fdac6..2516266317f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.dfa import org.jetbrains.kotlin.fir.types.ConeInferenceContext import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.canBeNull import org.jetbrains.kotlin.fir.types.commonSuperTypeOrNull abstract class Flow { @@ -59,6 +60,8 @@ abstract class LogicSystem(protected val context: ConeInferenceCont protected abstract fun getImplicationsWithVariable(flow: FLOW, variable: DataFlowVariable): Collection + protected abstract fun ConeKotlinType.isAcceptableForSmartcast(): Boolean + // ------------------------------- Callbacks for updating implicit receiver stack ------------------------------- abstract fun processUpdatedReceiverVariable(flow: FLOW, variable: RealVariable) @@ -150,7 +153,14 @@ abstract class LogicSystem(protected val context: ConeInferenceCont } } val result = mutableSetOf() - context.commonSuperTypeOrNull(intersectedTypes)?.let { result.add(it) } + context.commonSuperTypeOrNull(intersectedTypes)?.let { + if (it.isAcceptableForSmartcast()) { + result.add(it) + } else if (!it.canBeNull) { + result.add(context.anyType()) + } + Unit + } return result } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt index 7906f64405f..584bdfe76e7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/ConeInferenceContext.kt @@ -32,19 +32,19 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo val symbolProvider: FirSymbolProvider get() = session.symbolProvider - override fun nullableNothingType(): SimpleTypeMarker { + override fun nullableNothingType(): ConeClassLikeType { return session.builtinTypes.nullableNothingType.type } - override fun nullableAnyType(): SimpleTypeMarker { + override fun nullableAnyType(): ConeClassLikeType { return session.builtinTypes.nullableAnyType.type } - override fun nothingType(): SimpleTypeMarker { + override fun nothingType(): ConeClassLikeType { return session.builtinTypes.nothingType.type } - override fun anyType(): SimpleTypeMarker { + override fun anyType(): ConeClassLikeType { return session.builtinTypes.anyType.type } diff --git a/compiler/testData/codegen/box/smartCasts/kt44802.kt b/compiler/testData/codegen/box/smartCasts/kt44802.kt new file mode 100644 index 00000000000..4c77a142448 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/kt44802.kt @@ -0,0 +1,46 @@ +// TARGET_BACKEND: JVM +// ISSUE: KT-44802 + +// FILE: foo/Base.java +package foo; + +public interface Base { + String foo(); +} + +// FILE: foo/PackagePrivateInterface.java +package foo; + +interface PackagePrivateInterface extends Base {} + +// FILE: foo/A.java +package foo; + +public class A implements PackagePrivateInterface { + public String foo() { return "OK"; } +} + +// FILE: foo/B.java +package foo; + +public class B implements PackagePrivateInterface { + public String foo() { return "B"; } +} + +// FILE: foo/C.java +package foo; + +// FILE: main.kt +package bar + +import foo.Base +import foo.A +import foo.B + +fun testSmartcast(x: Base): String { + if (x !is A && x !is B) return "fail" + return x.foo() +} + +fun box() = testSmartcast(A()) + diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.fir.kt new file mode 100644 index 00000000000..a0ce2f40ebb --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.fir.kt @@ -0,0 +1,53 @@ +// ISSUE: KT-44802 +// INFERENCE_HELPERS + +// FILE: foo/PackagePrivateInterface.java +package foo; + +interface PackagePrivateInterface { + default void foo() {} +} + +// FILE: foo/A.java +package foo; + +public class A implements PackagePrivateInterface {} + +// FILE: foo/B.java +package foo; + +public class B implements PackagePrivateInterface {} + +// FILE: differentPackage.kt +package bar + +import foo.A +import foo.B +import select + +fun testSmartcast(x: Any) { + if (x is A || x is B) { + x.foo() + } +} + +fun testInference(a: A, b: B) { + val x = select(a, b) + x.foo() +} + +// FILE: samePackage.kt +package foo + +import select + +fun testSmartcast(x: Any) { + if (x is A || x is B) { + x.foo() + } +} + +fun testInference(a: A, b: B) { + val x = select(a, b) + x.foo() +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.kt b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.kt new file mode 100644 index 00000000000..9182e7ec8d1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.kt @@ -0,0 +1,53 @@ +// ISSUE: KT-44802 +// INFERENCE_HELPERS + +// FILE: foo/PackagePrivateInterface.java +package foo; + +interface PackagePrivateInterface { + default void foo() {} +} + +// FILE: foo/A.java +package foo; + +public class A implements PackagePrivateInterface {} + +// FILE: foo/B.java +package foo; + +public class B implements PackagePrivateInterface {} + +// FILE: differentPackage.kt +package bar + +import foo.A +import foo.B +import select + +fun testSmartcast(x: Any) { + if (x is A || x is B) { + x.foo() + } +} + +fun testInference(a: A, b: B) { + val x = select(a, b) + x.foo() +} + +// FILE: samePackage.kt +package foo + +import select + +fun testSmartcast(x: Any) { + if (x is A || x is B) { + x.foo() + } +} + +fun testInference(a: A, b: B) { + val x = select(a, b) + x.foo() +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.txt b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.txt new file mode 100644 index 00000000000..46bcdf49998 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.txt @@ -0,0 +1,39 @@ +package + +public fun id(/*0*/ x: K): K +public fun materialize(): K +public fun select(/*0*/ vararg values: K /*kotlin.Array*/): K + +package bar { + public fun testInference(/*0*/ a: foo.A, /*1*/ b: foo.B): kotlin.Unit + public fun testSmartcast(/*0*/ x: kotlin.Any): kotlin.Unit +} + +package foo { + public fun testInference(/*0*/ a: foo.A, /*1*/ b: foo.B): kotlin.Unit + public fun testSmartcast(/*0*/ x: kotlin.Any): kotlin.Unit + + public open class A : foo.PackagePrivateInterface { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class B : foo.PackagePrivateInterface { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ interface PackagePrivateInterface { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.fir.kt new file mode 100644 index 00000000000..f22cf8a5afa --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.fir.kt @@ -0,0 +1,43 @@ +// INFERENCE_HELPERS +// ISSUE: KT-44802 +// FILE: a.kt + +package foo +import select + +private interface PrivateInterface { + fun foo() {} +} + +class A : PrivateInterface +class B : PrivateInterface + +fun testSmartcast(x: Any) { + if (x is A || x is B) { + x.foo() + } +} + +fun testInference(a: A, b: B) { + val x = select(a, b) + x.foo() +} + +// FILE: main.kt + +package bar + +import foo.A +import foo.B +import select + +fun testSmartcast(x: Any) { + if (x is A || x is B) { + x.foo() + } +} + +fun testInference(a: A, b: B) { + val x = select(a, b) + x.foo() +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.kt b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.kt new file mode 100644 index 00000000000..76a61137e66 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.kt @@ -0,0 +1,43 @@ +// INFERENCE_HELPERS +// ISSUE: KT-44802 +// FILE: a.kt + +package foo +import select + +private interface PrivateInterface { + fun foo() {} +} + +class A : PrivateInterface +class B : PrivateInterface + +fun testSmartcast(x: Any) { + if (x is A || x is B) { + x.foo() + } +} + +fun testInference(a: A, b: B) { + val x = select(a, b) + x.foo() +} + +// FILE: main.kt + +package bar + +import foo.A +import foo.B +import select + +fun testSmartcast(x: Any) { + if (x is A || x is B) { + x.foo() + } +} + +fun testInference(a: A, b: B) { + val x = select(a, b) + x.foo() +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.txt b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.txt new file mode 100644 index 00000000000..8769813f4d7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.txt @@ -0,0 +1,39 @@ +package + +public fun id(/*0*/ x: K): K +public fun materialize(): K +public fun select(/*0*/ vararg values: K /*kotlin.Array*/): K + +package bar { + public fun testInference(/*0*/ a: foo.A, /*1*/ b: foo.B): kotlin.Unit + public fun testSmartcast(/*0*/ x: kotlin.Any): kotlin.Unit +} + +package foo { + public fun testInference(/*0*/ a: foo.A, /*1*/ b: foo.B): kotlin.Unit + public fun testSmartcast(/*0*/ x: kotlin.Any): kotlin.Unit + + public final class A : foo.PrivateInterface { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class B : foo.PrivateInterface { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + private interface PrivateInterface { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 99d2bb2e949..5dd7cce0ee2 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -25741,6 +25741,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastOnSameFieldOfDifferentInstances.kt"); } + @Test + @TestMetadata("smartcastToInvisibleType_java.kt") + public void testSmartcastToInvisibleType_java() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_java.kt"); + } + + @Test + @TestMetadata("smartcastToInvisibleType_kotlin.kt") + public void testSmartcastToInvisibleType_kotlin() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastToInvisibleType_kotlin.kt"); + } + @Test @TestMetadata("smartcastToNothingAfterCheckingForNull.kt") public void testSmartcastToNothingAfterCheckingForNull() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 04cd5241f1a..f6cf267f639 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -37668,6 +37668,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/smartCasts/kt42517.kt"); } + @Test + @TestMetadata("kt44802.kt") + public void testKt44802() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44802.kt"); + } + @Test @TestMetadata("kt44804.kt") public void testKt44804() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 3ee926efb95..45d24688c10 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -37668,6 +37668,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/smartCasts/kt42517.kt"); } + @Test + @TestMetadata("kt44802.kt") + public void testKt44802() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44802.kt"); + } + @Test @TestMetadata("kt44804.kt") public void testKt44804() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index e155f40e682..1b704cb4793 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -30120,6 +30120,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/smartCasts/kt42517.kt"); } + @TestMetadata("kt44802.kt") + public void testKt44802() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/kt44802.kt"); + } + @TestMetadata("kt44804.kt") public void testKt44804() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/kt44804.kt"); From 469252f6b40d86b29822d37fd27f023f197242de Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 19 Feb 2021 17:47:44 +0300 Subject: [PATCH 321/368] [FIR] Don't create smartcast node if smartcasted type is equal to original type --- .../kotlin/fir/resolve/ResolveUtils.kt | 5 +- .../castsInsideCoroutineInference.fir.kt.txt | 3 +- .../castsInsideCoroutineInference.fir.txt | 3 +- .../diagnostics/notLinked/dfa/neg/11.fir.kt | 16 ++-- .../diagnostics/notLinked/dfa/neg/12.fir.kt | 8 +- .../diagnostics/notLinked/dfa/neg/13.fir.kt | 12 +-- .../diagnostics/notLinked/dfa/neg/15.fir.kt | 16 ++-- .../diagnostics/notLinked/dfa/neg/18.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/21.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/23.fir.kt | 4 +- .../diagnostics/notLinked/dfa/neg/24.fir.kt | 8 +- .../diagnostics/notLinked/dfa/neg/26.fir.kt | 44 +++++------ .../diagnostics/notLinked/dfa/neg/3.fir.kt | 30 ++++---- .../diagnostics/notLinked/dfa/neg/33.fir.kt | 2 +- .../diagnostics/notLinked/dfa/neg/34.fir.kt | 40 +++++----- .../diagnostics/notLinked/dfa/neg/35.fir.kt | 36 ++++----- .../diagnostics/notLinked/dfa/neg/37.fir.kt | 32 ++++---- .../diagnostics/notLinked/dfa/neg/38.fir.kt | 12 +-- .../diagnostics/notLinked/dfa/pos/1.fir.kt | 36 ++++----- .../diagnostics/notLinked/dfa/pos/12.fir.kt | 74 +++++++++---------- .../diagnostics/notLinked/dfa/pos/13.fir.kt | 70 +++++++++--------- .../diagnostics/notLinked/dfa/pos/14.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/30.fir.kt | 20 ++--- .../diagnostics/notLinked/dfa/pos/4.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/52.fir.kt | 22 +++--- .../diagnostics/notLinked/dfa/pos/64.fir.kt | 2 +- .../diagnostics/notLinked/dfa/pos/66.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/69.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/7.fir.kt | 22 +++--- .../diagnostics/notLinked/dfa/pos/71.fir.kt | 2 +- 30 files changed, 272 insertions(+), 271 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index 9aeaaf3d4db..74d519269e0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -243,11 +243,12 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: AbstractFirBasedSymbol< fun BodyResolveComponents.transformQualifiedAccessUsingSmartcastInfo(qualifiedAccessExpression: FirQualifiedAccessExpression): FirQualifiedAccessExpression { val typesFromSmartCast = dataFlowAnalyzer.getTypeUsingSmartcastInfo(qualifiedAccessExpression) ?: return qualifiedAccessExpression + val originalType = qualifiedAccessExpression.resultType.coneType val allTypes = typesFromSmartCast.also { - it += qualifiedAccessExpression.resultType.coneType + it += originalType } val intersectedType = ConeTypeIntersector.intersectTypes(session.inferenceComponents.ctx, allTypes) - // TODO: add check that intersectedType is not equal to original type + if (intersectedType == originalType) return qualifiedAccessExpression val intersectedTypeRef = buildResolvedTypeRef { source = qualifiedAccessExpression.resultType.source?.fakeElement(FirFakeSourceElementKind.SmartCastedTypeRef) type = intersectedType diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt index 20df7d23208..7d69636b8db 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.kt.txt @@ -3,7 +3,7 @@ fun scopedFlow(@BuilderInference block: @ExtensionFunctionType Suspen return flow(block = local suspend fun FlowCollector.() { val collector: FlowCollector = flowScope(block = local suspend fun CoroutineScope.() { - block.invoke(p1 = , p2 = collector /*as FlowCollector */) + block.invoke(p1 = , p2 = collector) } ) } @@ -141,3 +141,4 @@ interface SendChannel { abstract suspend fun send(e: E) } + diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt index 3000008ef91..51368d44897 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt @@ -25,8 +25,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt CALL 'public abstract fun invoke (p1: P1 of kotlin.coroutines.SuspendFunction2, p2: P2 of kotlin.coroutines.SuspendFunction2): R of kotlin.coroutines.SuspendFunction2 [suspend,operator] declared in kotlin.coroutines.SuspendFunction2' type=kotlin.Unit origin=null $this: GET_VAR 'block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> declared in .scopedFlow' type=@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.CoroutineScope, .FlowCollector.scopedFlow>, kotlin.Unit> origin=VARIABLE_AS_FUNCTION p1: GET_VAR ': .CoroutineScope declared in .scopedFlow..' type=.CoroutineScope origin=null - p2: TYPE_OP type=.FlowCollector origin=IMPLICIT_CAST typeOperand=.FlowCollector - GET_VAR 'val collector: .FlowCollector [val] declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null + p2: GET_VAR 'val collector: .FlowCollector [val] declared in .scopedFlow.' type=.FlowCollector.scopedFlow> origin=null FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction2<.FlowCollector.onCompletion>, kotlin.Throwable?, kotlin.Unit>) returnType:.Flow.onCompletion> TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] $receiver: VALUE_PARAMETER name: type:.Flow.onCompletion> diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt index 7a9e67c7ab5..835c827a936 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/11.fir.kt @@ -25,8 +25,8 @@ fun case_3() { var x: Boolean? = true if (x is Boolean) { funWithAnyArg(try { x = null; true } catch (e: Exception) { false }) - x - x.not() + x + x.not() } } @@ -35,8 +35,8 @@ fun case_4() { var x: Boolean? = true if (x != null) { false || when { else -> {x = null; true} } - x - x.not() + x + x.not() } } @@ -57,8 +57,8 @@ fun case_6() { var x: Boolean? = true x as Boolean if (if (true) { x = null; true } else { false }) { - x - x.not() + x + x.not() } } @@ -68,6 +68,6 @@ fun case_7() { x!! if (if (true) { x = null; true } else { false }) {} - x - x.not() + x + x.not() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/12.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/12.fir.kt index ac6cd9a935d..6855de1205a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/12.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/12.fir.kt @@ -6,7 +6,7 @@ fun case_1() { var x: Int? = 11 x!! - try {x = null;} finally { x += 10; } + try {x = null;} finally { x += 10; } } // TESTCASE NUMBER: 2 @@ -18,7 +18,7 @@ fun case_2() { } catch (e: Exception) { x = null } - x.not() + x.not() } } @@ -31,7 +31,7 @@ fun case_3() { } catch (e: Exception) { x = null } - x.not() + x.not() } } @@ -42,5 +42,5 @@ fun case_4() { try { x = null } finally { } - x.not() + x.not() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt index 16525fa04cf..7e2d5a9980f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/13.fir.kt @@ -14,16 +14,16 @@ fun case_1(x: Class?) { fun case_2() { var x: Class? = 10 x!! - x(if (true) {x=null;0} else 0, x) - x - x.fun_1() + x(if (true) {x=null;0} else 0, x) + x + x.fun_1() } // TESTCASE NUMBER: 3 fun case_3() { var x: Class? = Class() x!! - val y = x[if (true) {x=null;0} else 0, x[0]] - x - x.fun_1() + val y = x[if (true) {x=null;0} else 0, x[0]] + x + x.fun_1() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt index c64857f04cc..6e15f53f9f1 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/15.fir.kt @@ -37,8 +37,8 @@ fun case_3() { var x: Boolean? = true if (x != null) { false || when { else -> { x = null; true} } - x - x.not() + x + x.not() } } @@ -64,7 +64,7 @@ fun case_4() { fun case_5() { var x: Boolean? = true if (x != null) { - when { else -> { x = null; false} } || x.not() + when { else -> { x = null; false} } || x.not() } } @@ -88,7 +88,7 @@ fun case_6() { fun case_7() { var x: Boolean? = true if (x != null) { - (if (true) {x = null; null} else true) ?: x.not() + (if (true) {x = null; null} else true) ?: x.not() } } @@ -96,7 +96,7 @@ fun case_7() { fun case_8(y: MutableList) { var x: Boolean? = true if (x != null) { - y[if (true) {x = null;0} else 0] = x + y[if (true) {x = null;0} else 0] = x } } @@ -109,8 +109,8 @@ fun case_9() { var x: Boolean? = true if (x is Boolean) { funWithAnyArg(try { x = null; true } catch (e: Exception) { false }) - x - x.not() + x + x.not() } } @@ -122,7 +122,7 @@ fun case_9() { fun case_10() { var x: Boolean? = true if (x is Boolean) { - select(if (true) {x = null;Class()} else Class()).prop_9 = x.not() + select(if (true) {x = null;Class()} else Class()).prop_9 = x.not() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt index 3131236c2e5..c3de82369bd 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/18.fir.kt @@ -50,7 +50,7 @@ fun case_4(x: Interface1?) { y as Interface2 y = null fun foo() { - y.itest2() + y.itest2() } y = x foo() @@ -62,7 +62,7 @@ fun case_5(x: Interface1?) { y as Interface2 y = null fun foo() { - y.itest2() + y.itest2() } y = x foo() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/21.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/21.fir.kt index 05f3312dcc5..ffd0875039f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/21.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/21.fir.kt @@ -13,7 +13,7 @@ class Case1 { val y = this if (y.x != null) { x = null - x + x this.x y.x y.x.inv() @@ -34,7 +34,7 @@ class Case2 { val y = this if (y.x == null) { x = 11 - x + x this.x y.x y.x.inv() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt index 824509b6e92..2f8844df640 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/23.fir.kt @@ -61,8 +61,8 @@ inline fun case_6() { var x: T? = 10 as T if (x is K) { x = null - x.equals(10) - x + x.equals(10) + x println(1) } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/24.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/24.fir.kt index 9a5d4c663f4..8c8cb291b57 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/24.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/24.fir.kt @@ -15,8 +15,8 @@ fun case_1() { } catch (e: Exception) { x = null } - x - x.not() + x + x.not() } } @@ -31,8 +31,8 @@ fun case_2() { try { x = null } finally { } - x - x.not() + x + x.not() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt index 54118ea35c6..fbc59bb9911 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/26.fir.kt @@ -10,18 +10,18 @@ fun case_1() { var x: MutableList? = mutableListOf(1) x!! - ? & kotlin.collections.MutableList")!>x[if (true) {x=null;0} else 0] += ? & kotlin.collections.MutableList?")!>x[0] - ? & kotlin.collections.MutableList?")!>x - ? & kotlin.collections.MutableList?")!>x[0].inv() + ? & kotlin.collections.MutableList")!>x[if (true) {x=null;0} else 0] += ?")!>x[0] + ?")!>x + ?")!>x[0].inv() } // TESTCASE NUMBER: 2 fun case_2() { var x: MutableList? = mutableListOf(1) x!! - ? & kotlin.collections.MutableList")!>x[if (true) {x=null;0} else 0] = ? & kotlin.collections.MutableList?")!>x[0] - ? & kotlin.collections.MutableList?")!>x - ? & kotlin.collections.MutableList?")!>x[0].inv() + ? & kotlin.collections.MutableList")!>x[if (true) {x=null;0} else 0] = ?")!>x[0] + ?")!>x + ?")!>x[0].inv() } // TESTCASE NUMBER: 3 @@ -29,8 +29,8 @@ fun case_3() { var x: MutableList? = mutableListOf(1) x!! ? & kotlin.collections.MutableList")!>x[0] = if (true) {x=null;0} else 0 - ? & kotlin.collections.MutableList?")!>x - ? & kotlin.collections.MutableList?")!>x[0].inv() + ?")!>x + ?")!>x[0].inv() } /* @@ -41,9 +41,9 @@ fun case_3() { fun case_4() { var x: Class? = Class() x!! - val y = x[if (true) {x=null;0} else 0, x[0]] - x - x[0].inv() + val y = x[if (true) {x=null;0} else 0, x[0]] + x + x[0].inv() } /* @@ -54,17 +54,17 @@ fun case_4() { fun case_5() { var x: Class? = Class() x!! - x(if (true) {x=null;0} else 0, x) - x.fun_1() + x(if (true) {x=null;0} else 0, x) + x.fun_1() } // TESTCASE NUMBER: 6 fun case_6() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0][>? & kotlin.collections.MutableList>?")!>x[0][0]] += 10 - >? & kotlin.collections.MutableList>?")!>x - >? & kotlin.collections.MutableList>?")!>x[0][0].inv() + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0][>?")!>x[0][0]] += 10 + >?")!>x + >?")!>x[0][0].inv() } /* @@ -75,22 +75,22 @@ fun case_6() { fun case_7() { var x: Class? = Class() x!! - x(if (true) {x=null;0} else 0)(x) - x.fun_1() + x(if (true) {x=null;0} else 0)(x) + x.fun_1() } // TESTCASE NUMBER: 8 fun case_8() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].addAll(1, >? & kotlin.collections.MutableList>?")!>x[0]) + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].addAll(1, >?")!>x[0]) } // TESTCASE NUMBER: 9 fun case_9() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].subList(0, 2)[>? & kotlin.collections.MutableList>?")!>x[0][0]] + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].subList(0, 2)[>?")!>x[0][0]] } /* @@ -101,7 +101,7 @@ fun case_9() { fun case_10() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - >? & kotlin.collections.MutableList>")!>x.subList(if (true) {x=null;0} else 0, 2)[>? & kotlin.collections.MutableList>?")!>x[0][0]] + >? & kotlin.collections.MutableList>")!>x.subList(if (true) {x=null;0} else 0, 2)[>?")!>x[0][0]] } /* @@ -112,5 +112,5 @@ fun case_10() { fun case_11() { var x: MutableList>? = mutableListOf(mutableListOf(1)) x!! - >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].subList(>? & kotlin.collections.MutableList>?")!>x[0][0], 2) + >? & kotlin.collections.MutableList>")!>x[if (true) {x=null;0} else 0].subList(>?")!>x[0][0], 2) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt index 3a0a0ca8a49..ea8cef6a0d9 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/3.fir.kt @@ -13,8 +13,8 @@ fun case_1(x: Nothing?) { // TESTCASE NUMBER: 2 fun case_2(x: Nothing) { if (x is Unit) { - x - x.inv() + x + x.inv() } } @@ -29,16 +29,16 @@ fun case_3(x: Nothing?) { // TESTCASE NUMBER: 4 fun case_4(x: Nothing) { if (x !is EnumClass) else { - x - x.fun_1() + x + x.fun_1() } } // TESTCASE NUMBER: 5 fun case_5(x: Nothing?) { if (!(x !is Class.NestedClass?)) { - x - x?.prop_4 + x + x?.prop_4 } } @@ -53,24 +53,24 @@ fun case_6(x: Nothing?) { // TESTCASE NUMBER: 7 fun case_7(x: Nothing) { if (!(x is DeepObject.A.B.C.D.E.F.G.J)) else { - x - x.prop_1 + x + x.prop_1 } } // TESTCASE NUMBER: 8 fun case_8(x: Nothing?) { if (!(x is Int?)) else { - x - x?.inv() + x + x?.inv() } } // TESTCASE NUMBER: 9 fun case_9(x: Nothing?) { if (!!(x !is TypealiasNullableStringIndirect?)) else { - x - x?.length + x + x?.length } } @@ -86,8 +86,8 @@ fun case_10(x: Nothing?) { // TESTCASE NUMBER: 11 fun case_11(x: Nothing?) { if (x is SealedMixedChildObject1?) { - x - x?.prop_1 - x?.prop_2 + x + x?.prop_1 + x?.prop_2 } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/33.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/33.fir.kt index 714f64ad3c0..09f7ad29aa3 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/33.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/33.fir.kt @@ -57,6 +57,6 @@ fun case_4(x: Int?) { fun case_5(x: Int?) { if (x == null) { var y = x - nullableStringArg(y) + nullableStringArg(y) } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt index 82010624f7a..92bca11edee 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/34.fir.kt @@ -13,8 +13,8 @@ fun case_1() { x = null break } - x - x.length + x + x.length } /* @@ -28,8 +28,8 @@ fun case_3() { x = null break } - x - x.length + x + x.length } /* @@ -43,8 +43,8 @@ fun case_4() { x = null break } - x - x.not() + x + x.not() } // TESTCASE NUMBER: 5 @@ -56,8 +56,8 @@ fun case_5() { x = null break } - x - x.not() + x + x.not() } // TESTCASE NUMBER: 6 @@ -141,8 +141,8 @@ fun case_12() { x = null break } while (true && x!!) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 13 @@ -154,8 +154,8 @@ fun case_13() { x = null break } while (false && x!!) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 14 @@ -167,8 +167,8 @@ fun case_14() { x = null break } while (true || x!!) - x - x.not() + x + x.not() } // TESTCASE NUMBER: 15 @@ -180,8 +180,8 @@ fun case_15() { x = null break } while (!(false && x!!)) - x - x.not() + x + x.not() } /* @@ -194,8 +194,8 @@ fun case_16() { while (x!! && if (true) {x = null; true} else true) { break } - x - x.not() + x + x.not() } /* @@ -208,6 +208,6 @@ fun case_17() { while (x!! && if (true) {x = null; true} else true) { break } - x - x.not() + x + x.not() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/35.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/35.fir.kt index 74c65c8446c..4edde03cecb 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/35.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/35.fir.kt @@ -11,8 +11,8 @@ fun case_1() { var x: String? x = "Test" println("${if (true) x = null else 1}") - x - x.length + x + x.length } /* @@ -24,8 +24,8 @@ fun case_2() { var x: String? x = "Test" println("${try { x = null } finally { }}") - x - x.length + x + x.length } /* @@ -37,8 +37,8 @@ fun case_3() { var x: String? x = "Test" println("${try { } finally { x = null }}") - x - x.length + x + x.length } /* @@ -50,8 +50,8 @@ fun case_4() { var x: String? x = "Test" println("${try { x = null } catch (e: Exception) { } finally { }}") - x - x.length + x + x.length } /* @@ -63,8 +63,8 @@ fun case_5() { var x: String? x = "Test" println("${try { } catch (e: Exception) { x = null } finally { }}") - x - x.length + x + x.length } /* @@ -76,8 +76,8 @@ fun case_6() { var x: String? x = "Test" println("${try { } catch (e: Exception) { } finally { x = null }}") - x - x.length + x + x.length } /* @@ -89,8 +89,8 @@ fun case_7() { var x: String? x = "Test" println("${try { x = null } catch (e: Exception) { }}") - x - x.length + x + x.length } /* @@ -102,8 +102,8 @@ fun case_8() { var x: String? x = "Test" println("${try { } catch (e: Exception) { x = null }}") - x - x.length + x + x.length } /* @@ -115,6 +115,6 @@ fun case_9() { var x: String? x = "Test" println("${when (null) { else -> x = null } }") - x - x.length + x + x.length } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt index c8976901980..5f1948ef40d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/37.fir.kt @@ -12,8 +12,8 @@ fun case_1() { if (x != null) { x x++ - x - x.equals(10) + x + x.equals(10) } } @@ -27,8 +27,8 @@ fun case_2() { x = Class() x x-- - x - x.equals(10) + x + x.equals(10) } /* @@ -41,8 +41,8 @@ fun case_3() { x!! x --x - x - x.equals(10) + x + x.equals(10) } /* @@ -55,8 +55,8 @@ fun case_4() { x as Class x ++x - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 5 @@ -65,8 +65,8 @@ fun case_5() { x as Class x x = x + x - x - x.equals(10) + x + x.equals(10) } // TESTCASE NUMBER: 6 @@ -75,8 +75,8 @@ fun case_6() { if (x is Class) { x x = x - x - x - x.equals(10) + x + x.equals(10) } } @@ -90,8 +90,8 @@ fun case_7() { x = Class() x x += x - x - x.equals(10) + x + x.equals(10) } /* @@ -104,6 +104,6 @@ fun case_8() { x!! x x -= x - x - x.equals(10) + x + x.equals(10) } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/38.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/38.fir.kt index c427c09fcf6..310fcb05941 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/38.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/38.fir.kt @@ -145,8 +145,8 @@ fun case_9() { inner@ do { x = null } while (x != null) - x - x.length + x + x.length } } @@ -158,8 +158,8 @@ fun case_10() { inner@ do { x = null } while (true) - x - x.length + x + x.length } } @@ -172,7 +172,7 @@ fun case_11() { x = null break } while (x == null) - x - x.length + x + x.length } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt index 7acc5f215f0..31b1bb2a01f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/1.fir.kt @@ -304,16 +304,16 @@ fun case_14() { // TESTCASE NUMBER: 15 fun case_15(x: EmptyObject) { val t = if (x === null) "" else { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } @@ -1302,8 +1302,8 @@ open class Case29(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (w != null || this.w != null) this.w s = null - s.hashCode() - s + s.hashCode() + s if (s != null) s if (this.s != null) s if (s != null || this.s != null) s @@ -2346,8 +2346,8 @@ sealed class Case30(a: Int?, val b: Float?, private val c: Unit?, protected val if (w != null || this.w != null) this.w s = null - s.hashCode() - s + s.hashCode() + s if (s != null) s if (this.s != null) s if (s != null || this.s != null) s @@ -3391,8 +3391,8 @@ enum class Case31(a: Int?, val b: Float?, private val c: Unit?, protected val d: if (w != null || this.w != null) this.w s = null - s.hashCode() - s + s.hashCode() + s if (s != null) s if (this.s != null) s if (s != null || this.s != null) s @@ -4039,8 +4039,8 @@ object Case32 { if (w != null || this.w != null) this.w s = null - s.hashCode() - s + s.hashCode() + s if (s != null) s if (this.s != null) s if (s != null || this.s != null) s diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt index 5f1af413a73..cb71cdfb613 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt @@ -320,17 +320,17 @@ fun T.case_8() { // TESTCASE NUMBER: 9 fun T.case_9() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.toByte() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.toByte() equals(null) @@ -567,18 +567,18 @@ fun T.case_12() where T : Number?, T: Interface1? { */ fun T.case_13() where T : Out<*>?, T: Comparable { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.compareTo(null) + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.compareTo(null) equals(null) @@ -3494,18 +3494,18 @@ fun T.case_56() where T : Number?, T: Interface1? { */ fun T.case_57() where T : Out<*>?, T: Comparable { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.compareTo(null) + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.compareTo(null) equals(null) @@ -3818,8 +3818,8 @@ fun Nothing?.case_62() { // TESTCASE NUMBER: 63 fun Nothing.case_63() { if (this != null) { - this - this.hashCode() + this + this.hashCode() hashCode() apply { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt index 23c7c7c13e9..a9b32599c67 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.fir.kt @@ -388,17 +388,17 @@ fun case_8(x: T) { // TESTCASE NUMBER: 9 fun case_9(x: T) { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.toByte() + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.toByte() x.equals(null) @@ -683,18 +683,18 @@ fun case_12(x: T) where T : Number?, T: Interface1? { */ fun case_13(x: T) where T : Out<*>?, T: Comparable { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.get() - x.compareTo(null) + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.get() + x.compareTo(null) x.equals(null) @@ -3987,18 +3987,18 @@ fun case_56(x: T) where T : Number?, T: Interface1? { */ fun case_57(x: T) where T : Out<*>?, T: Comparable { if (x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() - x.get() - x.compareTo(null) + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() + x.get() + x.compareTo(null) x.equals(null) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt index 30b8dec3d50..dfaf1aefbae 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt @@ -5,7 +5,7 @@ // TESTCASE NUMBER: 1 fun case_1(vararg x: Int?) { if (x != null) { - & kotlin.Array")!>x + ")!>x x[0] } } @@ -30,7 +30,7 @@ fun case_2(vararg x: Int?) { // TESTCASE NUMBER: 3 fun case_3(vararg x: T?) { if (x != null) { - & kotlin.Array")!>x + ")!>x x[0] } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt index fab49cb5607..c909df2713c 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/30.fir.kt @@ -99,11 +99,11 @@ fun case_6(x: Class?) { */ fun case_7(x: Class) { if (x!!.prop_8?.prop_8?.prop_8?.prop_8 != null) { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } @@ -114,11 +114,11 @@ fun case_7(x: Class) { */ fun case_8(x: Class) { if (x!!.prop_8?.prop_8?.prop_8?.prop_8 != null) { - x - x.prop_8 - x.prop_8.prop_8 - x.prop_8.prop_8.prop_8 - x.prop_8.prop_8.prop_8.prop_8 + x + x.prop_8 + x.prop_8.prop_8 + x.prop_8.prop_8.prop_8 + x.prop_8.prop_8.prop_8.prop_8 } } // TESTCASE NUMBER: 9 diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt index 4465240a87b..9d02e24f57a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/4.fir.kt @@ -63,7 +63,7 @@ fun case_6(x: EmptyClass) { // TESTCASE NUMBER: 7 fun case_7() { - if (anonymousTypeProperty == null || anonymousTypeProperty == null) { + if (anonymousTypeProperty == null || anonymousTypeProperty == null) { anonymousTypeProperty } } @@ -258,7 +258,7 @@ fun case_23(a: ((Float) -> Int), b: Float) { if (a == null && b == null) { val x = a(b) if (x !== null) { - x + x } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/52.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/52.fir.kt index 9415700500e..08af6541739 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/52.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/52.fir.kt @@ -12,7 +12,7 @@ fun case_1(x: Int?) = x fun case_1() { var x: Int? = 10 x = null - case_1(x) + case_1(x) } // TESTCASE NUMBER: 2 @@ -21,7 +21,7 @@ fun case_2(x: Nothing?) = x fun case_2() { var x: Int? = 10 x = null - case_2(x) + case_2(x) } // TESTCASE NUMBER: 3 @@ -29,7 +29,7 @@ fun case_3(x: String?) = x fun case_3() { var x: Int? = 10 x = null - case_3(x) + case_3(x) } /* @@ -42,7 +42,7 @@ fun Int?.case_4() = this fun case_4() { var x: Int? = 10 x = null - x.case_4() + x.case_4() } // TESTCASE NUMBER: 5 @@ -51,7 +51,7 @@ fun Nothing?.case_5() = this fun case_5() { var x: Int? = 10 x = null - x.case_5() + x.case_5() } // TESTCASE NUMBER: 6 @@ -59,7 +59,7 @@ fun String?.case_6() = this fun case_6() { var x: Int? = 10 x = null - x.case_6() + x.case_6() } /* @@ -72,7 +72,7 @@ fun T.case_7() = this fun case_7() { var x: Int? = 10 x = null - x.case_7() + x.case_7() } // TESTCASE NUMBER: 8 @@ -81,7 +81,7 @@ fun T.case_8() = this fun case_8() { var x: Int? = 10 x = null - x.case_8() + x.case_8() } // TESTCASE NUMBER: 9 @@ -89,7 +89,7 @@ fun T.case_9() = this fun case_9() { var x: Int? = 10 x = null - x.case_9() + x.case_9() } /* @@ -102,7 +102,7 @@ fun T?.case_10() = this fun case_10() { var x: Int? = 10 x = null - x.case_10() + x.case_10() } // TESTCASE NUMBER: 11 @@ -110,5 +110,5 @@ fun T?.case_11() = this fun case_11() { var x: Int? = 10 x = null - x.case_11() + x.case_11() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt index d2e5de161c9..f24a90f7e97 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/64.fir.kt @@ -16,7 +16,7 @@ class Case1 { if (x == null) { x = getT() } - x + x return x } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt index 09ba8fc695b..2fcf9954b1a 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/66.fir.kt @@ -79,8 +79,8 @@ fun case_6(x: Any?) { when (x) { is Nothing? -> return is Any? -> { - x - x.equals(10) + x + x.equals(10) } } x diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt index 24ad68a1d8d..f0885dadbdd 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/69.fir.kt @@ -36,7 +36,7 @@ fun case_4(x: Any?) { // TESTCASE NUMBER: 5 fun case_5(x: Class) { if (x!!.prop_8 != null) { - x - x.prop_8.prop_8 + x + x.prop_8.prop_8 } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt index 76b0c3c5964..63fe7a9a7b9 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/7.fir.kt @@ -131,17 +131,17 @@ fun case_7() { // TESTCASE NUMBER: 8 fun case_8(x: TypealiasString) { - if (x !== null && x != null) { - x - x.equals(null) - x.propT - x.propAny - x.propNullableT - x.propNullableAny - x.funT() - x.funAny() - x.funNullableT() - x.funNullableAny() + if (x !== null && x != null) { + x + x.equals(null) + x.propT + x.propAny + x.propNullableT + x.propNullableAny + x.funT() + x.funAny() + x.funNullableT() + x.funNullableAny() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt index f10b4dc77aa..158f8704143 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/71.fir.kt @@ -42,6 +42,6 @@ fun case_2(): Int { var c: Int = 0 c = 0 - c + c return c } From cd8f597e2f606fdaf68b9a93d25397f80bc547d1 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 19 Feb 2021 18:39:41 +0300 Subject: [PATCH 322/368] [FIR] Fix building callable reference adaptation against flexible types #KT-45052 Fixed --- .../referenceToJavaStdlib.fir.txt | 13 +++++++++++++ .../referenceToJavaStdlib.kt | 18 ++++++++++++++++++ .../runners/FirDiagnosticTestGenerated.java | 6 ++++++ ...rDiagnosticsWithLightTreeTestGenerated.java | 6 ++++++ .../calls/CallableReferenceResolution.kt | 8 ++++++-- 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.fir.txt new file mode 100644 index 00000000000..aca23b12b77 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.fir.txt @@ -0,0 +1,13 @@ +FILE: referenceToJavaStdlib.kt + public final fun detectDirsWithTestsMapFileOnly(file: R|java/io/File|): R|kotlin/collections/List| { + Q|java/nio/file/Files|.R|java/nio/file/Files.walk|(R|/file|.R|java/io/File.toPath|()).R|SubstitutionOverride!>, java/util/stream/Stream!>?>!|>|(Q|java/nio/file/Files|::R|java/nio/file/Files.isRegularFile|) + } + public abstract interface A : R|kotlin/Any| { + } + public final fun foo(x: R|A|, vararg strings: R|kotlin/Array|): R|kotlin/Unit| { + } + public final fun takeFunWithA(func: R|(A) -> kotlin/Unit|): R|kotlin/Unit| { + } + public final fun test(): R|kotlin/Unit| { + R|/takeFunWithA|(::R|/foo|) + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt new file mode 100644 index 00000000000..1c6ebf46b09 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt @@ -0,0 +1,18 @@ +// ISSUE: KT-45052 +// FULL_JDK +// JVM_TARGET: 1.8 + +import java.io.File +import java.nio.file.Files + +fun detectDirsWithTestsMapFileOnly(file: File): List { + Files.walk(file.toPath()).filter(Files::isRegularFile) +} + +interface A +fun foo(x: A, vararg strings: String) {} +fun takeFunWithA(func: (A) -> Unit) {} + +fun test() { + takeFunWithA(::foo) +} diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index c81aa91cb5d..d37a0c193b4 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -4177,6 +4177,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/properties.kt"); } + @Test + @TestMetadata("referenceToJavaStdlib.kt") + public void testReferenceToJavaStdlib() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt"); + } + @Test @TestMetadata("sam.kt") public void testSam() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index 5fd9fb6cc41..833c3109e8f 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -4231,6 +4231,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/properties.kt"); } + @Test + @TestMetadata("referenceToJavaStdlib.kt") + public void testReferenceToJavaStdlib() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt"); + } + @Test @TestMetadata("sam.kt") public void testSam() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt index d4e99ef8e13..183ad083dc3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallableReferenceResolution.kt @@ -97,8 +97,12 @@ private fun buildReflectionType( is FirFunction -> { val unboundReferenceTarget = if (receiverType != null) 1 else 0 val callableReferenceAdaptation = - context.bodyResolveComponents - .getCallableReferenceAdaptation(context.session, fir, candidate.callInfo.expectedType, unboundReferenceTarget) + context.bodyResolveComponents.getCallableReferenceAdaptation( + context.session, + fir, + candidate.callInfo.expectedType?.lowerBoundIfFlexible(), + unboundReferenceTarget + ) val parameters = mutableListOf() From 1a0be3ee4053c95ea20d6e5ab0e4cb1b4b9ba4cb Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 17 Feb 2021 11:13:59 +0300 Subject: [PATCH 323/368] Fix FirAnnotationArgumentChecker (String + ... case) #KT-44995 Fixed --- .../nonConstValInAnnotationArgument.fir.txt | 15 +++++++++++++++ .../nonConstValInAnnotationArgument.kt | 8 ++++++++ .../declaration/FirAnnotationArgumentChecker.kt | 3 ++- .../kotlin/fir/symbols/StandardClassIds.kt | 1 + .../collectionLiteralsWithConstants.kt | 1 - 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/nonConstValInAnnotationArgument.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/nonConstValInAnnotationArgument.fir.txt index fb134019b74..475470bd1dd 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/nonConstValInAnnotationArgument.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/nonConstValInAnnotationArgument.fir.txt @@ -17,3 +17,18 @@ FILE: nonConstValInAnnotationArgument.kt public get(): R|kotlin/Int| @R|Ann|((R|/foo|, R|/foo|.R|kotlin/String.plus|(R|/cnst|.R|kotlin/Any.toString|()))) public final fun test(): R|kotlin/Unit| { } + public final const val A: R|kotlin/String| = String(foo) + public get(): R|kotlin/String| + public final const val B: R|kotlin/Int| = Int(100) + public get(): R|kotlin/Int| + public final annotation class S : R|kotlin/Annotation| { + public constructor(s: R|kotlin/String|): R|S| { + super() + } + + public final val s: R|kotlin/String| = R|/s| + public get(): R|kotlin/String| + + } + @R|S|(R|/A|.R|kotlin/String.plus|(R|/B|)) public final fun foo(): R|kotlin/Unit| { + } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/nonConstValInAnnotationArgument.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/nonConstValInAnnotationArgument.kt index ae88b8599f9..8a9dfbb7c40 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/nonConstValInAnnotationArgument.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/nonConstValInAnnotationArgument.kt @@ -11,3 +11,11 @@ const val cnst = 2 ) ) fun test() {} + +const val A = "foo" +const val B = 100 + +annotation class S(val s: String) + +@S(A + B) +fun foo() {} \ No newline at end of file diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationArgumentChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationArgumentChecker.kt index c0465b574f3..c6648eb6e3f 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationArgumentChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationArgumentChecker.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperatorCall import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.symbols.StandardClassIds.primitiveTypesAndString import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.name.Name @@ -168,7 +169,7 @@ object FirAnnotationArgumentChecker : FirBasicDeclarationChecker() { if (calleeReference.name == PLUS && expClassId != receiverClassId - && (expClassId !in StandardClassIds.primitiveTypes || receiverClassId !in StandardClassIds.primitiveTypes) + && (expClassId !in primitiveTypesAndString || receiverClassId !in primitiveTypesAndString) ) return FirErrors.ANNOTATION_ARGUMENT_MUST_BE_CONST diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt index 6b66168a79a..bf07f94a11f 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt @@ -71,6 +71,7 @@ object StandardClassIds { Byte, Short, Int, Long, Float, Double ) + val primitiveTypesAndString = primitiveTypes + String val primitiveArrayTypeByElementType = primitiveTypes.associate { id -> id to id.shortClassName.primitiveArrayId() } val elementTypeByPrimitiveArrayType = primitiveArrayTypeByElementType.inverseMap() diff --git a/compiler/testData/codegen/box/collectionLiterals/collectionLiteralsWithConstants.kt b/compiler/testData/codegen/box/collectionLiterals/collectionLiteralsWithConstants.kt index 3b1c07084ef..c565aab7244 100644 --- a/compiler/testData/codegen/box/collectionLiterals/collectionLiteralsWithConstants.kt +++ b/compiler/testData/codegen/box/collectionLiterals/collectionLiteralsWithConstants.kt @@ -1,4 +1,3 @@ -// IGNORE_FIR_DIAGNOSTICS // WITH_REFLECT // TARGET_BACKEND: JVM From 31b9be2d01bde1eb54cb79ed4bcf0c46ad09f29b Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 3 Feb 2021 20:22:57 +0300 Subject: [PATCH 324/368] FIR: Extract ConeKotlinType::scopeForSupertype --- .../kotlin/fir/scopes/KotlinScopeProvider.kt | 56 +++++++++++-------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt index 14632038c67..f99b51b8620 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.types.ConeClassErrorType import org.jetbrains.kotlin.fir.types.ConeClassLikeType +import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.coneType import org.jetbrains.kotlin.name.ClassId @@ -40,21 +41,7 @@ class KotlinScopeProvider( val delegateFields = klass.declarations.filterIsInstance().filter { it.isSynthetic } val scopes = lookupSuperTypes(klass, lookupInterfaces = true, deep = false, useSiteSession = useSiteSession) .mapNotNull { useSiteSuperType -> - if (useSiteSuperType is ConeClassErrorType) return@mapNotNull null - val symbol = useSiteSuperType.lookupTag.toSymbol(useSiteSession) - if (symbol is FirRegularClassSymbol) { - val delegateField = delegateFields.find { it.returnTypeRef.coneType == useSiteSuperType } - symbol.fir.scopeForSupertype( - substitutor(symbol, useSiteSuperType, useSiteSession), - useSiteSession, scopeSession, delegateField, - subClass = klass, - decoratedDeclaredMemberScope - ).let { - it as? FirTypeScope ?: error("$it is expected to be FirOverrideAwareScope") - } - } else { - null - } + useSiteSuperType.scopeForSupertype(useSiteSession, scopeSession, klass, decoratedDeclaredMemberScope, delegateFields) } FirClassUseSiteMemberScope( useSiteSession, @@ -67,12 +54,6 @@ class KotlinScopeProvider( } } - private fun substitutor(symbol: FirRegularClassSymbol, type: ConeClassLikeType, useSiteSession: FirSession): ConeSubstitutor { - if (type.typeArguments.isEmpty()) return ConeSubstitutor.Empty - val originalSubstitution = createSubstitution(symbol.fir.typeParameters, type, useSiteSession) - return substitutorByMap(originalSubstitution) - } - override fun getStaticMemberScopeForCallables( klass: FirClass<*>, useSiteSession: FirSession, @@ -118,7 +99,38 @@ fun FirClass<*>.scopeForClass( isFromExpectClass = false ) -private fun FirClass<*>.scopeForSupertype( +fun ConeKotlinType.scopeForSupertype( + useSiteSession: FirSession, + scopeSession: ScopeSession, + subClass: FirClass<*>, + declaredMemberScope: FirScope, + delegateFields: List?, +): FirTypeScope? { + if (this !is ConeClassLikeType) return null + if (this is ConeClassErrorType) return null + val symbol = lookupTag.toSymbol(useSiteSession) + return if (symbol is FirRegularClassSymbol) { + val delegateField = delegateFields?.find { it.returnTypeRef.coneType == this } + symbol.fir.scopeForSupertype( + substitutor(symbol, this, useSiteSession), + useSiteSession, scopeSession, delegateField, + subClass = subClass, + declaredMemberScope + ).let { + it as? FirTypeScope ?: error("$it is expected to be FirOverrideAwareScope") + } + } else { + null + } +} + +private fun substitutor(symbol: FirRegularClassSymbol, type: ConeClassLikeType, useSiteSession: FirSession): ConeSubstitutor { + if (type.typeArguments.isEmpty()) return ConeSubstitutor.Empty + val originalSubstitution = createSubstitution(symbol.fir.typeParameters, type, useSiteSession) + return substitutorByMap(originalSubstitution) +} + +fun FirClass<*>.scopeForSupertype( substitutor: ConeSubstitutor, useSiteSession: FirSession, scopeSession: ScopeSession, From 6766c8fe47f6dff884a9df2aa3f18ce63a8d1467 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 3 Feb 2021 20:29:18 +0300 Subject: [PATCH 325/368] FIR: Simplify supertypes scopes computation --- .../kotlin/fir/java/JavaScopeProvider.kt | 36 ++++++++----------- .../kotlin/fir/resolve/SupertypeUtils.kt | 33 +++++++++++++++++ 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt index ecec05abe0f..75942656fde 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt @@ -36,7 +36,7 @@ class JavaScopeProvider( scopeSession: ScopeSession ): FirTypeScope { val symbol = klass.symbol as FirRegularClassSymbol - val enhancementScope = buildJavaEnhancementScope(useSiteSession, symbol, scopeSession, mutableSetOf()) + val enhancementScope = buildJavaEnhancementScope(useSiteSession, symbol, scopeSession) if (klass.classKind == ClassKind.ANNOTATION_CLASS) { return buildSyntheticScopeForAnnotations(useSiteSession, symbol, scopeSession, enhancementScope) } @@ -57,14 +57,13 @@ class JavaScopeProvider( private fun buildJavaEnhancementScope( useSiteSession: FirSession, symbol: FirRegularClassSymbol, - scopeSession: ScopeSession, - visitedSymbols: MutableSet> + scopeSession: ScopeSession ): JavaClassMembersEnhancementScope { return scopeSession.getOrBuild(symbol, JAVA_ENHANCEMENT) { JavaClassMembersEnhancementScope( useSiteSession, symbol, - buildUseSiteMemberScopeWithJavaTypes(symbol.fir, useSiteSession, scopeSession, visitedSymbols) + buildUseSiteMemberScopeWithJavaTypes(symbol.fir, useSiteSession, scopeSession) ) } } @@ -81,27 +80,20 @@ class JavaScopeProvider( regularClass: FirRegularClass, useSiteSession: FirSession, scopeSession: ScopeSession, - visitedSymbols: MutableSet> ): JavaClassUseSiteMemberScope { return scopeSession.getOrBuild(regularClass.symbol, JAVA_USE_SITE) { val declaredScope = buildDeclaredMemberScope(regularClass) val wrappedDeclaredScope = declaredMemberScopeDecorator(regularClass, declaredScope, useSiteSession, scopeSession) - val superTypeEnhancementScopes = - lookupSuperTypes(regularClass, lookupInterfaces = true, deep = false, useSiteSession = useSiteSession) - .mapNotNull { useSiteSuperType -> - if (useSiteSuperType is ConeClassErrorType) return@mapNotNull null - val symbol = useSiteSuperType.lookupTag.toSymbol(useSiteSession) - if (symbol is FirRegularClassSymbol && visitedSymbols.add(symbol)) { - // We need JavaClassEnhancementScope here to have already enhanced signatures from supertypes - val scope = buildJavaEnhancementScope(useSiteSession, symbol, scopeSession, visitedSymbols) - visitedSymbols.remove(symbol) - useSiteSuperType.wrapSubstitutionScopeIfNeed( - useSiteSession, scope, symbol.fir, scopeSession, derivedClass = regularClass - ) - } else { - null - } - } + val superTypes = + if (regularClass.isThereLoopInSupertypes(useSiteSession)) + listOf(StandardClassIds.Any.toConeKotlinType(emptyArray(), isNullable = false)) + else + lookupSuperTypes(regularClass, lookupInterfaces = true, deep = false, useSiteSession = useSiteSession) + + val superTypeScopes = superTypes.mapNotNull { + it.scopeForSupertype(useSiteSession, scopeSession, subClass = regularClass, wrappedDeclaredScope, delegateFields = null) + } + JavaClassUseSiteMemberScope( regularClass, useSiteSession, FirTypeIntersectionScope.prepareIntersectionScope( @@ -111,7 +103,7 @@ class JavaScopeProvider( if (regularClass is FirJavaClass) regularClass.javaTypeParameterStack else JavaTypeParameterStack.EMPTY ), - superTypeEnhancementScopes, + superTypeScopes, regularClass.defaultType(), ), wrappedDeclaredScope ) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt index 50098901189..8d21e25afb6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SupertypeUtils.kt @@ -42,6 +42,39 @@ fun lookupSuperTypes( } } +fun FirClass<*>.isThereLoopInSupertypes(session: FirSession): Boolean { + val visitedSymbols: MutableSet> = mutableSetOf() + val inProcess: MutableSet> = mutableSetOf() + + var isThereLoop = false + + fun dfs(current: FirClassifierSymbol<*>) { + if (current in visitedSymbols) return + if (!inProcess.add(current)) { + isThereLoop = true + return + } + + when (val fir = current.fir) { + is FirClass<*> -> { + fir.superConeTypes.forEach { + it.lookupTag.toSymbol(session)?.let(::dfs) + } + } + is FirTypeAlias -> { + fir.expandedConeType?.lookupTag?.toSymbol(session)?.let(::dfs) + } + } + + visitedSymbols.add(current) + inProcess.remove(current) + } + + dfs(symbol) + + return isThereLoop +} + fun lookupSuperTypes( symbol: FirClassifierSymbol<*>, lookupInterfaces: Boolean, From 04f53d6a23faec8676b7721344239af3adaa3fbc Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 3 Feb 2021 20:40:03 +0300 Subject: [PATCH 326/368] FIR: Simplify JavaScopeProvider ::wrapScopeWithJvmMapped is only needed for built-in classes defined in Kotlin --- .../jetbrains/kotlin/fir/java/JavaScopeProvider.kt | 14 +++----------- .../kotlin/fir/java/JavaSymbolProvider.kt | 3 +-- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt index 75942656fde..3af2ec36321 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt @@ -22,12 +22,6 @@ import org.jetbrains.kotlin.utils.DFS import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult class JavaScopeProvider( - val declaredMemberScopeDecorator: ( - klass: FirClass<*>, - declaredMemberScope: FirScope, - useSiteSession: FirSession, - scopeSession: ScopeSession - ) -> FirScope = { _, declaredMemberScope, _, _ -> declaredMemberScope }, val symbolProvider: JavaSymbolProvider ) : FirScopeProvider() { override fun getUseSiteMemberScope( @@ -83,7 +77,6 @@ class JavaScopeProvider( ): JavaClassUseSiteMemberScope { return scopeSession.getOrBuild(regularClass.symbol, JAVA_USE_SITE) { val declaredScope = buildDeclaredMemberScope(regularClass) - val wrappedDeclaredScope = declaredMemberScopeDecorator(regularClass, declaredScope, useSiteSession, scopeSession) val superTypes = if (regularClass.isThereLoopInSupertypes(useSiteSession)) listOf(StandardClassIds.Any.toConeKotlinType(emptyArray(), isNullable = false)) @@ -91,7 +84,7 @@ class JavaScopeProvider( lookupSuperTypes(regularClass, lookupInterfaces = true, deep = false, useSiteSession = useSiteSession) val superTypeScopes = superTypes.mapNotNull { - it.scopeForSupertype(useSiteSession, scopeSession, subClass = regularClass, wrappedDeclaredScope, delegateFields = null) + it.scopeForSupertype(useSiteSession, scopeSession, subClass = regularClass, declaredScope, delegateFields = null) } JavaClassUseSiteMemberScope( @@ -105,7 +98,7 @@ class JavaScopeProvider( ), superTypeScopes, regularClass.defaultType(), - ), wrappedDeclaredScope + ), declaredScope ) } } @@ -130,7 +123,6 @@ class JavaScopeProvider( return scopeSession.getOrBuild(klass.symbol, JAVA_ENHANCEMENT_FOR_STATIC) { val declaredScope = buildDeclaredMemberScope(klass) - val wrappedDeclaredScope = declaredMemberScopeDecorator(klass, declaredScope, useSiteSession, scopeSession) val superClassScope = klass.findJavaSuperClass()?.let { (it.scopeProvider as? JavaScopeProvider) @@ -147,7 +139,7 @@ class JavaScopeProvider( klass.symbol, JavaClassStaticUseSiteScope( useSiteSession, - declaredMemberScope = wrappedDeclaredScope, + declaredMemberScope = declaredScope, superClassScope, superTypesScopes, klass.javaTypeParameterStack ) diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt index 179ce39b4c1..1704d13f076 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt @@ -24,7 +24,6 @@ import org.jetbrains.kotlin.fir.resolve.constructType import org.jetbrains.kotlin.fir.resolve.defaultType import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProviderInternals -import org.jetbrains.kotlin.fir.resolve.scopes.wrapScopeWithJvmMapped import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.ConeClassLikeType @@ -66,7 +65,7 @@ class JavaSymbolProvider( private val packageCache = session.firCachesFactory.createCache(::findPackage) private val knownClassNamesInPackage = session.firCachesFactory.createCache?>(::getKnownClassNames) - private val scopeProvider = JavaScopeProvider(::wrapScopeWithJvmMapped, this) + private val scopeProvider = JavaScopeProvider(this) private val facade: KotlinJavaPsiFacade get() = KotlinJavaPsiFacade.getInstance(project) private val parentClassTypeParameterStackCache = mutableMapOf() From 5d5228cfc59068b4d376ee584c55fadbb16312e0 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 3 Feb 2021 20:41:27 +0300 Subject: [PATCH 327/368] FIR: Require FirJavaClass in JavaScopeProvider --- .../kotlin/fir/java/JavaScopeProvider.kt | 18 +++++++++--------- .../java/scopes/JavaClassUseSiteMemberScope.kt | 16 +++------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt index 3af2ec36321..b1692be052d 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaScopeProvider.kt @@ -11,13 +11,10 @@ import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass import org.jetbrains.kotlin.fir.java.scopes.* import org.jetbrains.kotlin.fir.resolve.* -import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.scopes.FirScopeProvider -import org.jetbrains.kotlin.fir.scopes.FirTypeScope +import org.jetbrains.kotlin.fir.scopes.* import org.jetbrains.kotlin.fir.scopes.impl.* -import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol -import org.jetbrains.kotlin.fir.types.ConeClassErrorType import org.jetbrains.kotlin.utils.DFS import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult @@ -54,10 +51,14 @@ class JavaScopeProvider( scopeSession: ScopeSession ): JavaClassMembersEnhancementScope { return scopeSession.getOrBuild(symbol, JAVA_ENHANCEMENT) { + val firJavaClass = symbol.fir + require(firJavaClass is FirJavaClass) { + "${firJavaClass.classId} is expected to be FirJavaClass, but ${firJavaClass::class} found" + } JavaClassMembersEnhancementScope( useSiteSession, symbol, - buildUseSiteMemberScopeWithJavaTypes(symbol.fir, useSiteSession, scopeSession) + buildUseSiteMemberScopeWithJavaTypes(firJavaClass, useSiteSession, scopeSession) ) } } @@ -71,7 +72,7 @@ class JavaScopeProvider( } private fun buildUseSiteMemberScopeWithJavaTypes( - regularClass: FirRegularClass, + regularClass: FirJavaClass, useSiteSession: FirSession, scopeSession: ScopeSession, ): JavaClassUseSiteMemberScope { @@ -93,8 +94,7 @@ class JavaScopeProvider( useSiteSession, JavaOverrideChecker( useSiteSession, - if (regularClass is FirJavaClass) regularClass.javaTypeParameterStack - else JavaTypeParameterStack.EMPTY + regularClass.javaTypeParameterStack ), superTypeScopes, regularClass.defaultType(), diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt index 545ccce2980..19d7470f1c5 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt @@ -10,7 +10,6 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty import org.jetbrains.kotlin.fir.declarations.synthetic.buildSyntheticProperty -import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack import org.jetbrains.kotlin.fir.java.declarations.* import org.jetbrains.kotlin.fir.resolve.FirJavaSyntheticNamesProvider import org.jetbrains.kotlin.fir.resolve.calls.syntheticNamesProvider @@ -28,18 +27,16 @@ import org.jetbrains.kotlin.load.java.structure.impl.JavaPrimitiveTypeImpl import org.jetbrains.kotlin.name.Name class JavaClassUseSiteMemberScope( - klass: FirRegularClass, + klass: FirJavaClass, session: FirSession, superTypesScope: FirTypeScope, declaredMemberScope: FirScope ) : AbstractFirUseSiteMemberScope( session, - JavaOverrideChecker(session, if (klass is FirJavaClass) klass.javaTypeParameterStack else JavaTypeParameterStack.EMPTY), + JavaOverrideChecker(session, klass.javaTypeParameterStack), superTypesScope, declaredMemberScope ) { - internal val symbol = klass.symbol - internal fun bindOverrides(name: Name) { val overrideCandidates = mutableSetOf() declaredMemberScope.processFunctionsByName(name) { @@ -141,18 +138,11 @@ class JavaClassUseSiteMemberScope( } override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { - val getterNames = if (symbol.fir is FirJavaClass) { - FirJavaSyntheticNamesProvider.possibleGetterNamesByPropertyName(name) - } else { - emptyList() - } + val getterNames = FirJavaSyntheticNamesProvider.possibleGetterNamesByPropertyName(name) return processAccessorFunctionsAndPropertiesByName(name, getterNames, processor) } override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) { - if (symbol.fir !is FirJavaClass) { - return super.processFunctionsByName(name, processor) - } val potentialPropertyNames = session.syntheticNamesProvider.possiblePropertyNamesByAccessorName(name) val accessors = mutableListOf() val getterName by lazy { session.syntheticNamesProvider.getterNameBySetterName(name) ?: name } From 893b1045ba4d2ff6fc35589da1f4e3fb3f76e050 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 17 Feb 2021 14:51:08 +0300 Subject: [PATCH 328/368] Move some common parts from BuiltinMethodsWithDifferentJvmName to SpecialGenericSignatures --- .../kotlin/load/java/BuiltinSpecialProperties.kt | 3 +++ .../kotlin/load/java/SpecialGenericSignatures.kt | 11 ++++++++++- ...JavaIncompatibilityRulesOverridabilityCondition.kt | 2 +- .../java/lazy/descriptors/LazyJavaClassMemberScope.kt | 4 ++-- .../kotlin/load/java/specialBuiltinMembers.kt | 7 ------- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/BuiltinSpecialProperties.kt b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/BuiltinSpecialProperties.kt index 8106c8a504b..b508b2bdbb0 100644 --- a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/BuiltinSpecialProperties.kt +++ b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/BuiltinSpecialProperties.kt @@ -26,6 +26,9 @@ object BuiltinSpecialProperties { PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP.entries .map { Pair(it.key.shortName(), it.value) } .groupBy({ it.second }, { it.first }) + .mapValues { + it.value.distinct() + } val SPECIAL_FQ_NAMES: Set = PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP.keys val SPECIAL_SHORT_NAMES: Set = SPECIAL_FQ_NAMES.map(FqName::shortName).toSet() diff --git a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/SpecialGenericSignatures.kt b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/SpecialGenericSignatures.kt index 9122e9113c7..6314884ae22 100644 --- a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/SpecialGenericSignatures.kt +++ b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/SpecialGenericSignatures.kt @@ -132,5 +132,14 @@ open class SpecialGenericSignatures { .map { Pair(it.key.name, it.value) } .groupBy({ it.second }, { it.first }) + fun getBuiltinFunctionNamesByJvmName(name: Name): List = + JVM_SHORT_NAME_TO_BUILTIN_SHORT_NAMES_MAP[name] ?: emptyList() + + val Name.sameAsBuiltinMethodWithErasedValueParameters: Boolean + get() = this in ERASED_VALUE_PARAMETERS_SHORT_NAMES + + val Name.sameAsRenamedInJvmBuiltin: Boolean + get() = this in ORIGINAL_SHORT_NAMES + } -} \ No newline at end of file +} diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaIncompatibilityRulesOverridabilityCondition.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaIncompatibilityRulesOverridabilityCondition.kt index 527e1d0b474..b4bd7c9d3d5 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaIncompatibilityRulesOverridabilityCondition.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JavaIncompatibilityRulesOverridabilityCondition.kt @@ -18,8 +18,8 @@ package org.jetbrains.kotlin.load.java import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.load.java.BuiltinMethodsWithDifferentJvmName.sameAsRenamedInJvmBuiltin import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.sameAsBuiltinMethodWithErasedValueParameters +import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.sameAsRenamedInJvmBuiltin import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor import org.jetbrains.kotlin.load.kotlin.JvmType diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index 4cef902b5ee..c19ec5ba853 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -29,9 +29,9 @@ import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.incremental.record import org.jetbrains.kotlin.load.java.* import org.jetbrains.kotlin.load.java.BuiltinMethodsWithDifferentJvmName.isRemoveAtByIndex -import org.jetbrains.kotlin.load.java.BuiltinMethodsWithDifferentJvmName.sameAsRenamedInJvmBuiltin import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.sameAsBuiltinMethodWithErasedValueParameters import org.jetbrains.kotlin.load.java.ClassicBuiltinSpecialProperties.getBuiltinSpecialPropertyGetterName +import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.sameAsRenamedInJvmBuiltin import org.jetbrains.kotlin.load.java.components.DescriptorResolverUtils.resolveOverridesForNonStaticMembers import org.jetbrains.kotlin.load.java.components.TypeUsage import org.jetbrains.kotlin.load.java.descriptors.* @@ -203,7 +203,7 @@ class LazyJavaClassMemberScope( } private fun SimpleFunctionDescriptor.doesOverrideRenamedBuiltins(): Boolean { - return BuiltinMethodsWithDifferentJvmName.getBuiltinFunctionNamesByJvmName(name).any { + return SpecialGenericSignatures.getBuiltinFunctionNamesByJvmName(name).any { // e.g. 'removeAt' or 'toInt' builtinName -> val builtinSpecialFromSuperTypes = diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt index e6bcc318b23..6060877a930 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/specialBuiltinMembers.kt @@ -71,9 +71,6 @@ object BuiltinMethodsWithSpecialGenericSignature : SpecialGenericSignatures() { } object BuiltinMethodsWithDifferentJvmName : SpecialGenericSignatures() { - val Name.sameAsRenamedInJvmBuiltin: Boolean - get() = this in ORIGINAL_SHORT_NAMES - fun getJvmName(functionDescriptor: SimpleFunctionDescriptor): Name? { return SIGNATURE_TO_JVM_REPRESENTATION_NAME[functionDescriptor.computeJvmSignature() ?: return null] } @@ -84,10 +81,6 @@ object BuiltinMethodsWithDifferentJvmName : SpecialGenericSignatures() { } != null } - fun getBuiltinFunctionNamesByJvmName(name: Name): List = - JVM_SHORT_NAME_TO_BUILTIN_SHORT_NAMES_MAP[name] ?: emptyList() - - val SimpleFunctionDescriptor.isRemoveAtByIndex: Boolean get() = name.asString() == "removeAt" && computeJvmSignature() == REMOVE_AT_NAME_AND_SIGNATURE.signature } From 3e420ca4e32b13d02fd163530f515344fa26aef1 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 17 Feb 2021 16:06:42 +0300 Subject: [PATCH 329/368] FIR: Introduce FirDeclarationOrigin.BuiltIns --- .../kotlin/fir/deserialization/ClassDeserialization.kt | 5 +++-- .../fir/resolve/providers/impl/FirBuiltinSymbolProvider.kt | 1 + .../deserialization/KotlinDeserializedJvmSymbolsProvider.kt | 4 ++-- .../kotlin/fir/declarations/FirDeclarationOrigin.kt | 1 + .../kotlin/idea/frontend/api/fir/symbols/KtFirSymbol.kt | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt index 478fba4b5ba..5b9871b835c 100644 --- a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt +++ b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt @@ -52,6 +52,7 @@ fun deserializeClassToSymbol( scopeProvider: FirScopeProvider, parentContext: FirDeserializationContext? = null, containerSource: DeserializedContainerSource? = null, + origin: FirDeclarationOrigin = FirDeclarationOrigin.Library, deserializeNestedClass: (ClassId, FirDeserializationContext) -> FirRegularClassSymbol? ) { val flags = classProto.flags @@ -94,7 +95,7 @@ fun deserializeClassToSymbol( } buildRegularClass { this.session = session - origin = FirDeclarationOrigin.Library + this.origin = origin name = classId.shortClassName this.status = status classKind = ProtoEnumFlags.classKind(kind) @@ -151,7 +152,7 @@ fun deserializeClassToSymbol( val enumType = ConeClassLikeTypeImpl(symbol.toLookupTag(), emptyArray(), false) val property = buildEnumEntry { this.session = session - origin = FirDeclarationOrigin.Library + this.origin = FirDeclarationOrigin.Library returnTypeRef = buildResolvedTypeRef { type = enumType } name = enumEntryName this.symbol = FirVariableSymbol(CallableId(classId, enumEntryName)) diff --git a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirBuiltinSymbolProvider.kt b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirBuiltinSymbolProvider.kt index 0b933862dbe..50ace5464c2 100644 --- a/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirBuiltinSymbolProvider.kt +++ b/compiler/fir/fir-deserialization/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirBuiltinSymbolProvider.kt @@ -303,6 +303,7 @@ class FirBuiltinSymbolProvider(session: FirSession, val kotlinScopeProvider: Kot classId, classProto, symbol, nameResolver, session, null, kotlinScopeProvider, parentContext, null, + origin = FirDeclarationOrigin.BuiltIns, this::findAndDeserializeClass, ) } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt index ab7f0ab23d0..36f6d1fd49e 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt @@ -200,7 +200,7 @@ class KotlinDeserializedJvmSymbolsProvider( JvmBinaryAnnotationDeserializer(session, kotlinClass.kotlinJvmBinaryClass, kotlinClass.byteContent), kotlinScopeProvider, parentContext, KotlinJvmBinarySourceElement(kotlinClass.kotlinJvmBinaryClass), - this::getClass + deserializeNestedClass = this::getClass, ) return symbol to kotlinClass @@ -287,4 +287,4 @@ private class KnownNameInPackageCache(session: FirSession, private val javaClass val knownNames = knownClassNamesInPackage.getValue(classId.packageFqName) ?: return false return classId.relativeClassName.topLevelName() !in knownNames } -} \ No newline at end of file +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationOrigin.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationOrigin.kt index 647d5105767..a5fd73e6af8 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationOrigin.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirDeclarationOrigin.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.declarations sealed class FirDeclarationOrigin(val fromSupertypes: Boolean = false) { object Source : FirDeclarationOrigin() object Library : FirDeclarationOrigin() + object BuiltIns : FirDeclarationOrigin() object Java : FirDeclarationOrigin() object Synthetic : FirDeclarationOrigin() object SamConstructor : FirDeclarationOrigin() diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/symbols/KtFirSymbol.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/symbols/KtFirSymbol.kt index 7d77acd3aaa..14498662260 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/symbols/KtFirSymbol.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/symbols/KtFirSymbol.kt @@ -32,7 +32,7 @@ private tailrec fun FirDeclaration.ktSymbolOrigin(): KtSymbolOrigin = when (orig KtSymbolOrigin.SOURCE_MEMBER_GENERATED } else KtSymbolOrigin.SOURCE } - FirDeclarationOrigin.Library -> KtSymbolOrigin.LIBRARY + FirDeclarationOrigin.Library, FirDeclarationOrigin.BuiltIns -> KtSymbolOrigin.LIBRARY FirDeclarationOrigin.Java -> KtSymbolOrigin.JAVA FirDeclarationOrigin.SamConstructor -> KtSymbolOrigin.SAM_CONSTRUCTOR FirDeclarationOrigin.Enhancement -> KtSymbolOrigin.JAVA From 23705a269ff248e8d6f2ecd32601ddaf006631e0 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 17 Feb 2021 16:21:22 +0300 Subject: [PATCH 330/368] FIR: Fix supertype scopes for local classes Do not use ClassId as it can't be a key for local classes --- .../kotlin/fir/scopes/KotlinScopeProvider.kt | 6 +++--- .../impl/ConeClassLookupTagWithFixedSymbol.kt | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt index f99b51b8620..dc676fd8c74 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt @@ -13,12 +13,12 @@ import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap import org.jetbrains.kotlin.fir.scopes.impl.* import org.jetbrains.kotlin.fir.symbols.CallableId +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.types.ConeClassErrorType import org.jetbrains.kotlin.fir.types.ConeClassLikeType import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.coneType -import org.jetbrains.kotlin.name.ClassId class KotlinScopeProvider( val declaredMemberScopeDecorator: ( @@ -72,7 +72,7 @@ class KotlinScopeProvider( data class ConeSubstitutionScopeKey( - val classId: ClassId?, val isFromExpectClass: Boolean, val substitutor: ConeSubstitutor + val lookupTag: ConeClassLikeLookupTag, val isFromExpectClass: Boolean, val substitutor: ConeSubstitutor ) : ScopeSessionKey, FirClassSubstitutionScope>() data class DelegatedMemberScopeKey(val callableId: CallableId) : ScopeSessionKey() @@ -166,7 +166,7 @@ private fun FirClass<*>.scopeForClassImpl( if (substitutor == ConeSubstitutor.Empty) return basicScope return scopeSession.getOrBuild( - this, ConeSubstitutionScopeKey(classFirDispatchReceiver.classId, isFromExpectClass, substitutor) + this, ConeSubstitutionScopeKey(classFirDispatchReceiver.symbol.toLookupTag(), isFromExpectClass, substitutor) ) { FirClassSubstitutionScope( useSiteSession, basicScope, substitutor, classFirDispatchReceiver.defaultType(), diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/ConeClassLookupTagWithFixedSymbol.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/ConeClassLookupTagWithFixedSymbol.kt index f72b296dcd2..5d6b8a07cf8 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/ConeClassLookupTagWithFixedSymbol.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/symbols/impl/ConeClassLookupTagWithFixedSymbol.kt @@ -8,7 +8,22 @@ package org.jetbrains.kotlin.fir.symbols.impl import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.name.ClassId -data class ConeClassLookupTagWithFixedSymbol( +class ConeClassLookupTagWithFixedSymbol( override val classId: ClassId, val symbol: FirClassSymbol<*> -) : ConeClassLikeLookupTag() \ No newline at end of file +) : ConeClassLikeLookupTag() { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as ConeClassLookupTagWithFixedSymbol + + if (symbol != other.symbol) return false + + return true + } + + override fun hashCode(): Int { + return symbol.hashCode() + } +} From 4b0aeb71057894141782a5d45fd332ae7738ad11 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 17 Feb 2021 18:08:16 +0300 Subject: [PATCH 331/368] FIR2IR: Support initialSignatureDescriptor It will be used for overrides of renamed special built-ins during signature mapping to obtain initial signature --- .../fir/lazy/AbstractFir2IrLazyFunction.kt | 21 +++++++++++++++++-- .../fir/lazy/Fir2IrLazyPropertyAccessor.kt | 14 ++++++++++++- .../fir/lazy/Fir2IrLazySimpleFunction.kt | 7 ++++++- .../java/enhancement/SignatureEnhancement.kt | 9 +++++++- .../org/jetbrains/kotlin/fir/ClassMembers.kt | 3 +++ 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/AbstractFir2IrLazyFunction.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/AbstractFir2IrLazyFunction.kt index c2d9b9e09bf..3abcb2334a2 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/AbstractFir2IrLazyFunction.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/AbstractFir2IrLazyFunction.kt @@ -14,13 +14,18 @@ import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.symbols.Fir2IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyFunctionBase import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar import org.jetbrains.kotlin.ir.expressions.IrBody +import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.util.DeclarationStubGenerator +import org.jetbrains.kotlin.ir.util.TypeTranslator import org.jetbrains.kotlin.ir.util.isObject import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.resolve.annotations.JVM_STATIC_ANNOTATION_FQ_NAME +import kotlin.properties.ReadWriteProperty abstract class AbstractFir2IrLazyFunction( components: Fir2IrComponents, @@ -29,7 +34,7 @@ abstract class AbstractFir2IrLazyFunction( override var origin: IrDeclarationOrigin, override val symbol: Fir2IrSimpleFunctionSymbol, override val isFakeOverride: Boolean -) : IrSimpleFunction(), AbstractFir2IrLazyDeclaration, Fir2IrComponents by components { +) : IrSimpleFunction(), AbstractFir2IrLazyDeclaration, IrLazyFunctionBase, Fir2IrComponents by components { override lateinit var typeParameters: List override lateinit var parent: IrDeclarationParent @@ -94,7 +99,19 @@ abstract class AbstractFir2IrLazyFunction( } } + override val stubGenerator: DeclarationStubGenerator + get() = error("Should not be called") + override val typeTranslator: TypeTranslator + get() = error("Should not be called") + + override val factory: IrFactory + get() = super.factory + + override fun createLazyAnnotations(): ReadWriteProperty> { + return super.createLazyAnnotations() + } + companion object { private val JVM_STATIC_CLASS_ID = ClassId.topLevel(JVM_STATIC_ANNOTATION_FQ_NAME) } -} \ No newline at end of file +} diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyPropertyAccessor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyPropertyAccessor.kt index a954f94cbd2..bec9694e3f3 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyPropertyAccessor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyPropertyAccessor.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.lazy import org.jetbrains.kotlin.fir.backend.* import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticPropertyAccessor import org.jetbrains.kotlin.fir.symbols.Fir2IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar @@ -81,7 +82,18 @@ class Fir2IrLazyPropertyAccessor( } override var overriddenSymbols: List by lazyVar { - firParentProperty.generateOverriddenAccessorSymbols(firParentClass, !isSetter, session, scopeSession, declarationStorage) + firParentProperty.generateOverriddenAccessorSymbols( + firParentClass, + !isSetter, + session, + scopeSession, + declarationStorage, + fakeOverrideGenerator + ) + } + + override val initialSignatureFunction: IrFunction? by lazy { + (fir as? FirSyntheticPropertyAccessor)?.delegate?.let { declarationStorage.getIrFunctionSymbol(it.symbol).owner } } override val containerSource: DeserializedContainerSource? diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt index 3a02aad285e..30c2d974326 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.lazy import org.jetbrains.kotlin.fir.backend.* import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.initialSignatureAttr import org.jetbrains.kotlin.fir.symbols.Fir2IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar @@ -72,7 +73,11 @@ class Fir2IrLazySimpleFunction( parent.declarations fakeOverrideGenerator.getOverriddenSymbols(this)?.let { return@lazyVar it } } - fir.generateOverriddenFunctionSymbols(firParent, session, scopeSession, declarationStorage) + fir.generateOverriddenFunctionSymbols(firParent, session, scopeSession, declarationStorage, fakeOverrideGenerator) + } + + override val initialSignatureFunction: IrFunction? by lazy { + (fir.initialSignatureAttr as? FirFunction<*>)?.symbol?.let { declarationStorage.getIrFunctionSymbol(it).owner } } override val containerSource: DeserializedContainerSource? diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt index 9359dd373bd..a3839b387b6 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty import org.jetbrains.kotlin.fir.declarations.synthetic.buildSyntheticProperty +import org.jetbrains.kotlin.fir.initialSignatureAttr import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack import org.jetbrains.kotlin.fir.java.declarations.* import org.jetbrains.kotlin.fir.render @@ -55,7 +56,13 @@ class FirSignatureEnhancement( function: FirFunctionSymbol<*>, name: Name? ): FirFunctionSymbol<*> { - return enhancements.getOrPut(function) { enhance(function, name) } as FirFunctionSymbol<*> + return enhancements.getOrPut(function) { + enhance(function, name).also { enhancedVersion -> + (enhancedVersion.fir.initialSignatureAttr as? FirSimpleFunction)?.let { + enhancedVersion.fir.initialSignatureAttr = enhancedFunction(it.symbol, it.name).fir + } + } + } as FirFunctionSymbol<*> } fun enhancedProperty(property: FirVariableSymbol<*>, name: Name): FirVariableSymbol<*> { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt index 70886469e9b..ed307ebf44b 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/ClassMembers.kt @@ -70,3 +70,6 @@ var > private object IntersectionOverrideOriginalKey : FirDeclarationDataKey() var > D.originalForIntersectionOverrideAttr: D? by FirDeclarationDataRegistry.data(IntersectionOverrideOriginalKey) + +private object InitialSignatureKey : FirDeclarationDataKey() +var FirCallableDeclaration<*>.initialSignatureAttr: FirCallableDeclaration<*>? by FirDeclarationDataRegistry.data(InitialSignatureKey) From 45018ea4685e73040f25d1237b153f882fe22cb3 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 17 Feb 2021 18:31:57 +0300 Subject: [PATCH 332/368] FIR: Rework loading overrides of special built-in methods from Java Some of the changed data is correct, but some diagnostics are incorrect Corner cases like having both contains(Object) and contains(String) within implementation of Collection is not supported --- .../fir/java/declarations/FirJavaMethod.kt | 29 ++ .../declarations/FirJavaValueParameter.kt | 21 + .../java/enhancement/SignatureEnhancement.kt | 9 +- .../JavaClassMembersEnhancementScope.kt | 98 +--- .../scopes/JavaClassUseSiteMemberScope.kt | 472 ++++++++++++++---- .../fir/java/scopes/JavaOverrideChecker.kt | 40 +- .../kotlin/fir/scopes/jvm/DescriptorUtils.kt | 80 ++- .../kotlin/fir/scopes/jvm/JvmMappedScope.kt | 6 +- .../impl/AbstractFirUseSiteMemberScope.kt | 2 +- .../jetbrains/kotlin/fir/scopes/FirScope.kt | 9 + .../collectionStringImpl.fir.kt | 85 ++++ .../collectionStringImpl.kt | 1 - .../j+k/collectionOverrides/contains.fir.kt | 12 +- .../collectionOverrides/containsAll.fir.kt | 6 +- .../containsAndOverload.fir.kt | 12 +- .../irrelevantMapGetAbstract.fir.kt | 19 + .../irrelevantMapGetAbstract.kt | 1 - .../collectionOverrides/removeAtInt.fir.kt | 32 -- .../j+k/collectionOverrides/removeAtInt.kt | 1 + .../tests/j+k/finalCollectionSize.fir.kt | 12 - .../tests/j+k/finalCollectionSize.kt | 1 + .../primitiveOverrides/specializedMap.fir.kt | 113 +++++ .../j+k/primitiveOverrides/specializedMap.kt | 1 - .../modality/ModalityOfFakeOverrides.fir.txt | 2 - .../memberScopeByFqName/java.lang.String.txt | 33 +- 25 files changed, 725 insertions(+), 372 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/j+k/collectionOverrides/collectionStringImpl.fir.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/collectionOverrides/irrelevantMapGetAbstract.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/j+k/finalCollectionSize.fir.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/primitiveOverrides/specializedMap.fir.kt diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt index 7ffd4bc1c43..d4089a48b0d 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaMethod.kt @@ -43,6 +43,9 @@ import org.jetbrains.kotlin.util.OperatorNameConventions.ITERATOR import org.jetbrains.kotlin.util.OperatorNameConventions.NEXT import org.jetbrains.kotlin.util.OperatorNameConventions.SET import org.jetbrains.kotlin.util.OperatorNameConventions.UNARY_OPERATION_NAMES +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract import kotlin.properties.Delegates @OptIn(FirImplementationDetail::class) @@ -227,3 +230,29 @@ class FirJavaMethodBuilder : FirFunctionBuilder, FirTypeParametersOwnerBuilder, inline fun buildJavaMethod(init: FirJavaMethodBuilder.() -> Unit): FirJavaMethod { return FirJavaMethodBuilder().apply(init).build() } + +@OptIn(ExperimentalContracts::class) +inline fun buildJavaMethodCopy(original: FirSimpleFunction, init: FirJavaMethodBuilder.() -> Unit): FirJavaMethod { + contract { + callsInPlace(init, InvocationKind.EXACTLY_ONCE) + } + val copyBuilder = FirJavaMethodBuilder() + copyBuilder.source = original.source + copyBuilder.session = original.session + copyBuilder.resolvePhase = original.resolvePhase + copyBuilder.attributes = original.attributes.copy() + copyBuilder.returnTypeRef = original.returnTypeRef + copyBuilder.valueParameters.addAll(original.valueParameters) + copyBuilder.body = original.body + copyBuilder.status = original.status + copyBuilder.dispatchReceiverType = original.dispatchReceiverType + copyBuilder.name = original.name + copyBuilder.symbol = original.symbol + copyBuilder.annotations.addAll(original.annotations) + copyBuilder.typeParameters.addAll(original.typeParameters) + val annotations = original.annotations + copyBuilder.annotationBuilder = { annotations } + return copyBuilder + .apply(init) + .build() +} diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt index bfef6f8fc9e..7653fe7f6be 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/declarations/FirJavaValueParameter.kt @@ -20,6 +20,9 @@ import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.fir.visitors.FirVisitor import org.jetbrains.kotlin.fir.visitors.transformSingle import org.jetbrains.kotlin.name.Name +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract @OptIn(FirImplementationDetail::class) class FirJavaValueParameter @FirImplementationDetail constructor( @@ -174,3 +177,21 @@ class FirJavaValueParameterBuilder { inline fun buildJavaValueParameter(init: FirJavaValueParameterBuilder.() -> Unit): FirJavaValueParameter { return FirJavaValueParameterBuilder().apply(init).build() } + +@OptIn(ExperimentalContracts::class) +inline fun buildJavaValueParameterCopy(original: FirValueParameter, init: FirJavaValueParameterBuilder.() -> Unit): FirValueParameter { + contract { + callsInPlace(init, InvocationKind.EXACTLY_ONCE) + } + val copyBuilder = FirJavaValueParameterBuilder() + copyBuilder.source = original.source + copyBuilder.session = original.session + copyBuilder.attributes = original.attributes.copy() + copyBuilder.returnTypeRef = original.returnTypeRef + copyBuilder.name = original.name + val annotations = original.annotations + copyBuilder.annotationBuilder = { annotations } + copyBuilder.defaultValue = original.defaultValue + copyBuilder.isVararg = original.isVararg + return copyBuilder.apply(init).build() +} diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt index a3839b387b6..8df2a9d4d76 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.fir.declarations.synthetic.buildSyntheticProperty import org.jetbrains.kotlin.fir.initialSignatureAttr import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack import org.jetbrains.kotlin.fir.java.declarations.* +import org.jetbrains.kotlin.fir.java.toConeKotlinTypeProbablyFlexible import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.scopes.jvm.computeJvmDescriptor import org.jetbrains.kotlin.fir.symbols.CallableId @@ -165,7 +166,10 @@ class FirSignatureEnhancement( val memberContext = context.copyWithNewDefaultTypeQualifiers(typeQualifierResolver, jsr305State, firMethod.annotations) val predefinedEnhancementInfo = - SignatureBuildingComponents.signature(owner.symbol.classId, firMethod.computeJvmDescriptor()).let { signature -> + SignatureBuildingComponents.signature( + owner.symbol.classId, + firMethod.computeJvmDescriptor { it.toConeKotlinTypeProbablyFlexible(session, javaTypeParameterStack) } + ).let { signature -> PREDEFINED_FUNCTION_ENHANCEMENT_INFO_BY_SIGNATURE[signature] } @@ -308,6 +312,9 @@ class FirSignatureEnhancement( ownerParameter: FirJavaValueParameter, index: Int ): FirResolvedTypeRef { + if (ownerParameter.returnTypeRef is FirResolvedTypeRef) { + return ownerParameter.returnTypeRef as FirResolvedTypeRef + } val signatureParts = ownerFunction.partsForValueParameter( typeQualifierResolver, overriddenMembers, diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassMembersEnhancementScope.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassMembersEnhancementScope.kt index fcedee9c6df..81db4df3827 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassMembersEnhancementScope.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassMembersEnhancementScope.kt @@ -5,31 +5,17 @@ package org.jetbrains.kotlin.fir.java.scopes -import org.jetbrains.kotlin.builtins.StandardNames -import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration -import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.java.enhancement.FirSignatureEnhancement -import org.jetbrains.kotlin.fir.resolve.lookupSuperTypes import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.scopes.FirTypeScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction -import org.jetbrains.kotlin.fir.scopes.impl.FirFakeOverrideGenerator -import org.jetbrains.kotlin.fir.scopes.jvm.computeJvmDescriptorReplacingKotlinToJava -import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag -import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.load.java.SpecialGenericSignatures -import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.ERASED_COLLECTION_PARAMETER_SIGNATURES -import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.ERASED_VALUE_PARAMETERS_SHORT_NAMES -import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.ERASED_VALUE_PARAMETERS_SIGNATURES -import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.utils.addToStdlib.safeAs class JavaClassMembersEnhancementScope( session: FirSession, @@ -62,91 +48,10 @@ class JavaClassMembersEnhancementScope( return super.processPropertiesByName(name, processor) } - private fun FirSimpleFunction.changeSignatureIfErasedValueParameter(): FirSimpleFunction { - val typeParameters = owner.fir.typeParameters - if (typeParameters.isEmpty() || name !in ERASED_VALUE_PARAMETERS_SHORT_NAMES) { - return this - } - val jvmDescriptor = this.computeJvmDescriptorReplacingKotlinToJava().replace( - "kotlin/collections/Collection", - "java/util/Collection" - ) - if (ERASED_VALUE_PARAMETERS_SIGNATURES.none { it.endsWith(jvmDescriptor) }) { - return this - } - val superClassIds = listOfNotNull(symbol.callableId.classId) + - lookupSuperTypes(owner, lookupInterfaces = true, deep = true, useSiteSession = session).map { it.lookupTag.classId } - for (superClassId in superClassIds) { - val javaClassId = JavaToKotlinClassMap.mapKotlinToJava(superClassId.asSingleFqName().toUnsafe()) ?: superClassId - val newParameterTypes: List = when (val fqJvmDescriptor = "${javaClassId.asString()}.$jvmDescriptor") { - in ERASED_COLLECTION_PARAMETER_SIGNATURES -> { - valueParameters.map { - val typeParameter = typeParameters.first() - ConeClassLikeLookupTagImpl(ClassId.topLevel(StandardNames.FqNames.collection)).constructClassType( - arrayOf( - ConeTypeParameterLookupTag(typeParameter.symbol).constructType(emptyArray(), isNullable = false) - ), isNullable = false - ) - } - } - in ERASED_VALUE_PARAMETERS_SIGNATURES -> { - val specialSignatureInfo = SpecialGenericSignatures.getSpecialSignatureInfo(fqJvmDescriptor) - if (!specialSignatureInfo.isObjectReplacedWithTypeParameter) { - return this - } - valueParameters.mapIndexed { i, valueParameter -> - val classLikeType = - valueParameter.returnTypeRef.coneTypeSafe()?.lowerBoundIfFlexible().safeAs() - if (classLikeType?.lookupTag?.classId == StandardClassIds.Any) { - val typeParameterIndex = if (name.asString() == "containsValue") 1 else i - val typeParameter = typeParameters.getOrNull(typeParameterIndex) ?: typeParameters.first() - val type = ConeTypeParameterLookupTag(typeParameter.symbol).constructType( - emptyArray(), valueParameter.returnTypeRef.isMarkedNullable == true - ) - if (valueParameter.returnTypeRef.coneType is ConeFlexibleType) { - ConeFlexibleType( - type.withAttributes( - type.attributes.withFlexibleUnless { - it.hasEnhancedNullability - } - ), - type.withNullability(ConeNullability.NULLABLE) - ) - } else { - type - } - } else { - null - } - } - } - else -> { - continue - } - } - if (newParameterTypes.none { it != null }) { - return this - } - - return FirFakeOverrideGenerator.createCopyForFirFunction( - FirNamedFunctionSymbol(symbol.callableId), - this, - session, - FirDeclarationOrigin.Enhancement, - newParameterTypes = valueParameters.zip(newParameterTypes).map { (valueParameter, newType) -> - newType ?: valueParameter.returnTypeRef.coneType - }, - newDispatchReceiverType = dispatchReceiverType, - ) - - } - return this - } - override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) { useSiteMemberScope.processFunctionsByName(name) process@{ original -> val symbol = signatureEnhancement.enhancedFunction(original, name) - val enhancedFunction = (symbol.fir as? FirSimpleFunction)?.changeSignatureIfErasedValueParameter() + val enhancedFunction = (symbol.fir as? FirSimpleFunction) val enhancedFunctionSymbol = enhancedFunction?.symbol ?: symbol if (enhancedFunctionSymbol is FirNamedFunctionSymbol) { @@ -162,7 +67,6 @@ class JavaClassMembersEnhancementScope( private fun FirCallableMemberDeclaration<*>.overriddenMembers(name: Name): List> { val backMap = overrideBindCache.getOrPut(name) { - useSiteMemberScope.bindOverrides(name) useSiteMemberScope .overrideByBase .toList() diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt index 19d7470f1c5..5ad62bd582a 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaClassUseSiteMemberScope.kt @@ -5,26 +5,30 @@ package org.jetbrains.kotlin.fir.java.scopes -import com.intellij.lang.jvm.types.JvmPrimitiveTypeKind -import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty import org.jetbrains.kotlin.fir.declarations.synthetic.buildSyntheticProperty import org.jetbrains.kotlin.fir.java.declarations.* -import org.jetbrains.kotlin.fir.resolve.FirJavaSyntheticNamesProvider -import org.jetbrains.kotlin.fir.resolve.calls.syntheticNamesProvider -import org.jetbrains.kotlin.fir.scopes.FirScope -import org.jetbrains.kotlin.fir.scopes.FirTypeScope -import org.jetbrains.kotlin.fir.scopes.getContainingCallableNamesIfPresent -import org.jetbrains.kotlin.fir.scopes.getContainingClassifierNamesIfPresent +import org.jetbrains.kotlin.fir.java.toConeKotlinTypeProbablyFlexible +import org.jetbrains.kotlin.fir.resolve.toSymbol +import org.jetbrains.kotlin.fir.scopes.* import org.jetbrains.kotlin.fir.scopes.impl.AbstractFirUseSiteMemberScope +import org.jetbrains.kotlin.fir.scopes.jvm.computeJvmDescriptor +import org.jetbrains.kotlin.fir.scopes.jvm.computeJvmSignature import org.jetbrains.kotlin.fir.symbols.CallableId +import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.* -import org.jetbrains.kotlin.fir.types.isUnit -import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef -import org.jetbrains.kotlin.load.java.structure.JavaPrimitiveType -import org.jetbrains.kotlin.load.java.structure.impl.JavaPrimitiveTypeImpl +import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.load.java.BuiltinSpecialProperties +import org.jetbrains.kotlin.load.java.JvmAbi +import org.jetbrains.kotlin.load.java.SpecialGenericSignatures +import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.ERASED_COLLECTION_PARAMETER_NAMES +import org.jetbrains.kotlin.load.java.SpecialGenericSignatures.Companion.sameAsBuiltinMethodWithErasedValueParameters +import org.jetbrains.kotlin.load.java.getPropertyNamesCandidatesByAccessorName import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.types.AbstractTypeChecker +import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult class JavaClassUseSiteMemberScope( klass: FirJavaClass, @@ -37,15 +41,8 @@ class JavaClassUseSiteMemberScope( superTypesScope, declaredMemberScope ) { - internal fun bindOverrides(name: Name) { - val overrideCandidates = mutableSetOf() - declaredMemberScope.processFunctionsByName(name) { - overrideCandidates += it - } - superTypesScope.processFunctionsByName(name) { - it.getOverridden(overrideCandidates) - } - } + private val typeParameterStack = klass.javaTypeParameterStack + private val specialFunctions = hashMapOf>() override fun getCallableNames(): Set { return declaredMemberScope.getContainingCallableNamesIfPresent() + superTypesScope.getCallableNames() @@ -72,99 +69,378 @@ class JavaClassUseSiteMemberScope( }.symbol } - private fun processAccessorFunctionsAndPropertiesByName( - propertyName: Name, - getterNames: List, - processor: (FirVariableSymbol<*>) -> Unit - ) { - val overrideCandidates = mutableSetOf>() - declaredMemberScope.processPropertiesByName(propertyName) { variableSymbol -> - if (variableSymbol.isStatic) return@processPropertiesByName - overrideCandidates += variableSymbol + override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { + val fields = mutableSetOf>() + val fieldNames = mutableSetOf() + + // fields + declaredMemberScope.processPropertiesByName(name) processor@{ variableSymbol -> + if (variableSymbol.isStatic) return@processor + fields += variableSymbol + fieldNames += variableSymbol.fir.name processor(variableSymbol) } - for (getterName in getterNames) { - var getterSymbol: FirNamedFunctionSymbol? = null - var setterSymbol: FirNamedFunctionSymbol? = null - declaredMemberScope.processFunctionsByName(getterName) { functionSymbol -> - if (getterSymbol == null) { - val function = functionSymbol.fir - if (!function.isStatic && function.valueParameters.isEmpty()) { - getterSymbol = functionSymbol - } - } - } - val setterName = session.syntheticNamesProvider.setterNameByGetterName(getterName) - if (getterSymbol != null && setterName != null) { - declaredMemberScope.processFunctionsByName(setterName) { functionSymbol -> - if (setterSymbol == null) { - val function = functionSymbol.fir - if (!function.isStatic && function.valueParameters.size == 1) { - val returnTypeRef = function.returnTypeRef - if (returnTypeRef.isUnit) { - // Unit return type - setterSymbol = functionSymbol - } else if (returnTypeRef is FirJavaTypeRef) { - // Void/void return type - when (val returnType = returnTypeRef.type) { - is JavaPrimitiveTypeImpl -> - if (returnType.psi.kind == JvmPrimitiveTypeKind.VOID) { - setterSymbol = functionSymbol - } - is JavaPrimitiveType -> - if (returnType.type == null) { - setterSymbol = functionSymbol - } - } - } - } - } - } - val accessorSymbol = generateAccessorSymbol(getterSymbol!!, setterSymbol, propertyName) - overrideCandidates += accessorSymbol - } - } + val fromSupertypes = superTypesScope.getProperties(name) - superTypesScope.processPropertiesByName(propertyName) { - when (val overriddenBy = it.getOverridden(overrideCandidates)) { - null -> processor(it) - is FirAccessorSymbol -> processor(overriddenBy) - is FirPropertySymbol -> if (it is FirPropertySymbol) { - directOverriddenProperties.getOrPut(overriddenBy) { mutableListOf() }.add(it) + for (propertyFromSupertype in fromSupertypes) { + if (propertyFromSupertype is FirFieldSymbol) { + if (propertyFromSupertype.fir.name !in fieldNames) { + processor(propertyFromSupertype) } + continue + } + if (propertyFromSupertype !is FirPropertySymbol) continue + val overrideInClass = propertyFromSupertype.createOverridePropertyIfExists(declaredMemberScope) + when { + overrideInClass != null -> { + directOverriddenProperties.getOrPut(overrideInClass) { mutableListOf() }.add(propertyFromSupertype) + overrideByBase[propertyFromSupertype] = overrideInClass + processor(overrideInClass) + } + else -> processor(propertyFromSupertype) } } } - override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) { - val getterNames = FirJavaSyntheticNamesProvider.possibleGetterNamesByPropertyName(name) - return processAccessorFunctionsAndPropertiesByName(name, getterNames, processor) + private fun FirVariableSymbol<*>.createOverridePropertyIfExists(scope: FirScope): FirPropertySymbol? { + if (this !is FirPropertySymbol || !doesClassOverridesProperty(this, scope)) return null + + val getterSymbol = this.findGetterOverride(scope)!! + val setterSymbol = + if (this.fir.isVar) + this.findSetterOverride(scope)!! + else + null + + return generateAccessorSymbol(getterSymbol, setterSymbol, fir.name) + } + + private fun doesClassOverridesProperty( + propertySymbolFromSupertype: FirPropertySymbol, + scope: FirScope, + ): Boolean { + val getter = propertySymbolFromSupertype.findGetterOverride(scope) + val setter = propertySymbolFromSupertype.findSetterOverride(scope) + + if (getter == null) return false + if (!propertySymbolFromSupertype.fir.isVar) return true + + return setter != null && setter.fir.modality == getter.fir.modality + } + + private fun FirPropertySymbol.findGetterOverride( + scope: FirScope, + ): FirNamedFunctionSymbol? { + val specialGetterName = getBuiltinSpecialPropertyGetterName() + if (specialGetterName != null) { + return findGetterByName(specialGetterName.asString(), scope) + } + + return findGetterByName(JvmAbi.getterName(fir.name.asString()), scope) + } + + private fun FirPropertySymbol.findGetterByName( + getterName: String, + scope: FirScope, + ): FirNamedFunctionSymbol? { + val propertyFromSupertype = fir + val expectedReturnType = propertyFromSupertype.returnTypeRef.coneTypeSafe() + return scope.getFunctions(Name.identifier(getterName)).firstNotNullResult factory@{ candidateSymbol -> + val candidate = candidateSymbol.fir + if (candidate.valueParameters.isNotEmpty()) return@factory null + + val candidateReturnType = candidate.returnTypeRef.toConeKotlinTypeProbablyFlexible(session, typeParameterStack) + + candidateSymbol.takeIf { + // TODO: Decide something for the case when property type is not computed yet + expectedReturnType == null || AbstractTypeChecker.isSubtypeOf(session.typeContext, candidateReturnType, expectedReturnType) + } + } + } + + private fun FirPropertySymbol.findSetterOverride( + scope: FirScope, + ): FirNamedFunctionSymbol? { + val propertyType = fir.returnTypeRef.coneTypeSafe() ?: return null + return scope.getFunctions(Name.identifier(JvmAbi.setterName(fir.name.asString()))).firstNotNullResult factory@{ candidateSymbol -> + val candidate = candidateSymbol.fir + if (candidate.valueParameters.size != 1) return@factory null + + if (!candidate.returnTypeRef.toConeKotlinTypeProbablyFlexible(session, typeParameterStack).isUnit) return@factory null + + val parameterType = + candidate.valueParameters.single().returnTypeRef.toConeKotlinTypeProbablyFlexible(session, typeParameterStack) + + candidateSymbol.takeIf { + AbstractTypeChecker.equalTypes(session.typeContext, parameterType, propertyType) + } + } + } + + private fun FirPropertySymbol.getBuiltinSpecialPropertyGetterName(): Name? { + var result: Name? = null + + superTypesScope.processOverriddenPropertiesAndSelf(this) { overridden -> + val fqName = overridden.fir.containingClass()?.classId?.asSingleFqName()?.child(overridden.fir.name) + + BuiltinSpecialProperties.PROPERTY_FQ_NAME_TO_JVM_GETTER_NAME_MAP[fqName]?.let { name -> + result = name + return@processOverriddenPropertiesAndSelf ProcessorAction.STOP + } + + ProcessorAction.NEXT + } + + return result } override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) { - val potentialPropertyNames = session.syntheticNamesProvider.possiblePropertyNamesByAccessorName(name) - val accessors = mutableListOf() - val getterName by lazy { session.syntheticNamesProvider.getterNameBySetterName(name) ?: name } - for (potentialPropertyName in potentialPropertyNames) { - processAccessorFunctionsAndPropertiesByName(potentialPropertyName, listOf(getterName)) { - if (it is FirAccessorSymbol) { - accessors += it - } - } - } - if (accessors.isEmpty()) { + val potentialPropertyNames = getPropertyNamesCandidatesByAccessorName(name) + + val renamedSpecialBuiltInNames = SpecialGenericSignatures.getBuiltinFunctionNamesByJvmName(name) + + if (potentialPropertyNames.isEmpty() && renamedSpecialBuiltInNames.isEmpty() && + !name.sameAsBuiltinMethodWithErasedValueParameters + ) { return super.processFunctionsByName(name, processor) } - super.processFunctionsByName(name) { functionSymbol -> - if (accessors.none { accessorSymbol -> - val syntheticProperty = accessorSymbol.fir as FirSyntheticProperty - syntheticProperty.getter.delegate === functionSymbol.fir || - syntheticProperty.setter?.delegate === functionSymbol.fir - } + + val overriddenProperties = potentialPropertyNames.flatMap(this::getProperties).filterIsInstance() + + specialFunctions.getOrPut(name) { + doProcessSpecialFunctions(name, overriddenProperties, renamedSpecialBuiltInNames) + }.forEach { + processor(it) + } + } + + private fun doProcessSpecialFunctions( + name: Name, + overriddenProperties: List, + renamedSpecialBuiltInNames: List + ): List { + val result = mutableListOf() + + declaredMemberScope.processFunctionsByName(name) { functionSymbol -> + if (functionSymbol.isStatic) return@processFunctionsByName + if (overriddenProperties.none { it.isOverriddenInClassBy(functionSymbol) } && + !functionSymbol.doesOverrideRenamedBuiltins(renamedSpecialBuiltInNames) && + !functionSymbol.shouldBeVisibleAsOverrideOfBuiltInWithErasedValueParameters() ) { - processor(functionSymbol) + result += functionSymbol + } + } + + addOverriddenSpecialMethods(name, result, declaredMemberScope) + + val overrideCandidates = result.toMutableSet() + + superTypesScope.processFunctionsByName(name) { + val overriddenBy = it.getOverridden(overrideCandidates) + if (overriddenBy == null) { + result += it + } + } + + return result + } + + private fun FirPropertySymbol.isOverriddenInClassBy(functionSymbol: FirNamedFunctionSymbol): Boolean { + val fir = fir as? FirSyntheticProperty ?: return false + + return fir.getter.delegate.symbol == functionSymbol || fir.setter?.delegate?.symbol == functionSymbol + } + + private fun addOverriddenSpecialMethods( + name: Name, + result: MutableList, + scope: FirScope, + ) { + superTypesScope.processFunctionsByName(name) { fromSupertype -> + obtainOverrideForBuiltinWithDifferentJvmName(fromSupertype, scope, name)?.let { + directOverriddenFunctions[it] = listOf(fromSupertype) + overrideByBase[fromSupertype] = it + result += it + } + + obtainOverrideForBuiltInWithErasedValueParametersInJava(fromSupertype, scope)?.let { + directOverriddenFunctions[it] = listOf(fromSupertype) + overrideByBase[fromSupertype] = it + result += it } } } + + private fun obtainOverrideForBuiltinWithDifferentJvmName( + symbol: FirNamedFunctionSymbol, + scope: FirScope, + name: Name, + ): FirNamedFunctionSymbol? { + val overriddenBuiltin = symbol.getOverriddenBuiltinWithDifferentJvmName() ?: return null + + val nameInJava = + SpecialGenericSignatures.SIGNATURE_TO_JVM_REPRESENTATION_NAME[overriddenBuiltin.fir.computeJvmSignature() ?: return null] + ?: return null + + for (candidateSymbol in scope.getFunctions(nameInJava)) { + val candidateFir = candidateSymbol.fir + val renamedCopy = buildJavaMethodCopy(candidateFir) { + this.name = name + this.symbol = FirNamedFunctionSymbol(CallableId(candidateFir.symbol.callableId.classId!!, name)) + }.apply { + initialSignatureAttr = candidateFir + } + + if (overrideChecker.isOverriddenFunction(renamedCopy, overriddenBuiltin.fir)) { + return renamedCopy.symbol + } + } + + return null + } + + private fun obtainOverrideForBuiltInWithErasedValueParametersInJava( + symbol: FirNamedFunctionSymbol, + scope: FirScope, + ): FirNamedFunctionSymbol? { + val overriddenBuiltin = + symbol.getOverriddenBuiltinFunctionWithErasedValueParametersInJava() + ?: return null + + return createOverrideForBuiltinFunctionWithErasedParameterIfNeeded(symbol, overriddenBuiltin, scope) + } + + private fun createOverrideForBuiltinFunctionWithErasedParameterIfNeeded( + fromSupertype: FirNamedFunctionSymbol, + overriddenBuiltin: FirNamedFunctionSymbol, + scope: FirScope, + ): FirNamedFunctionSymbol? { + return scope.getFunctions(overriddenBuiltin.fir.name).firstOrNull { candidateOverride -> + candidateOverride.fir.computeJvmDescriptor() == overriddenBuiltin.fir.computeJvmDescriptor() && + candidateOverride.hasErasedParameters() + }?.let { override -> + buildJavaMethodCopy(override.fir) { + this.valueParameters.clear() + override.fir.valueParameters.zip(fromSupertype.fir.valueParameters) + .mapTo(this.valueParameters) { (overrideParameter, parameterFromSupertype) -> + buildJavaValueParameterCopy(overrideParameter) { + this@buildJavaValueParameterCopy.returnTypeRef = parameterFromSupertype.returnTypeRef + } + } + + symbol = FirNamedFunctionSymbol(override.callableId) + }.apply { + initialSignatureAttr = override.fir + }.symbol + } + } + + // It's either overrides Collection.contains(Object) or Collection.containsAll(Collection) or similar methods + private fun FirNamedFunctionSymbol.hasErasedParameters(): Boolean { + val valueParameter = fir.valueParameters.first() + val parameterType = valueParameter.returnTypeRef.toConeKotlinTypeProbablyFlexible(session, typeParameterStack) + val upperBound = parameterType.upperBoundIfFlexible() + if (upperBound !is ConeClassLikeType) return false + + if (fir.name.asString() in ERASED_COLLECTION_PARAMETER_NAMES) { + require(upperBound.lookupTag.classId == StandardClassIds.Collection) { + "Unexpected type: ${upperBound.lookupTag.classId}" + } + + return upperBound.typeArguments.singleOrNull() is ConeStarProjection + } + + return upperBound.classId == StandardClassIds.Any + } + + private fun FirNamedFunctionSymbol.doesOverrideRenamedBuiltins(renamedSpecialBuiltInNames: List): Boolean { + return renamedSpecialBuiltInNames.any { + // e.g. 'removeAt' or 'toInt' + builtinName -> + val builtinSpecialFromSuperTypes = + getFunctionsFromSupertypes(builtinName).filter { it.getOverriddenBuiltinWithDifferentJvmName() != null } + if (builtinSpecialFromSuperTypes.isEmpty()) return@any false + + val currentJvmDescriptor = fir.computeJvmDescriptor(customName = builtinName.asString()) + + builtinSpecialFromSuperTypes.any { builtinSpecial -> + builtinSpecial.fir.computeJvmDescriptor() == currentJvmDescriptor + } + } + } + + private fun FirFunction<*>.computeJvmSignature(): String? { + return computeJvmSignature { it.toConeKotlinTypeProbablyFlexible(session, typeParameterStack) } + } + + private fun FirFunction<*>.computeJvmDescriptor(customName: String? = null, includeReturnType: Boolean = false): String { + return computeJvmDescriptor(customName, includeReturnType) { + it.toConeKotlinTypeProbablyFlexible( + session, + typeParameterStack + ) + } + } + + private fun getFunctionsFromSupertypes(name: Name): List { + val result = mutableListOf() + superTypesScope.processFunctionsByName(name) { + result += it + } + + return result + } + + private fun FirNamedFunctionSymbol.getOverriddenBuiltinWithDifferentJvmName(): FirNamedFunctionSymbol? { + var result: FirNamedFunctionSymbol? = null + + superTypesScope.processOverriddenFunctions(this) { + if (!it.isFromBuiltInClass(session)) return@processOverriddenFunctions ProcessorAction.NEXT + if (SpecialGenericSignatures.SIGNATURE_TO_JVM_REPRESENTATION_NAME.containsKey( + it.fir.computeJvmSignature() + ) + ) { + result = it + return@processOverriddenFunctions ProcessorAction.STOP + } + + ProcessorAction.NEXT + } + + return result + } + + private fun FirNamedFunctionSymbol.shouldBeVisibleAsOverrideOfBuiltInWithErasedValueParameters(): Boolean { + val name = fir.name + if (!name.sameAsBuiltinMethodWithErasedValueParameters) return false + val candidatesToOverride = + getFunctionsFromSupertypes(name).mapNotNull { + it.getOverriddenBuiltinFunctionWithErasedValueParametersInJava() + } + + val jvmDescriptor = fir.computeJvmDescriptor() + + return candidatesToOverride.any { candidate -> + candidate.fir.computeJvmDescriptor() == jvmDescriptor && this.hasErasedParameters() + } + } + + private fun FirNamedFunctionSymbol.getOverriddenBuiltinFunctionWithErasedValueParametersInJava(): FirNamedFunctionSymbol? { + var result: FirNamedFunctionSymbol? = null + + superTypesScope.processOverriddenFunctionsAndSelf(this) { + if (it.fir.computeJvmSignature() in SpecialGenericSignatures.ERASED_VALUE_PARAMETERS_SIGNATURES) { + result = it + return@processOverriddenFunctionsAndSelf ProcessorAction.STOP + } + + ProcessorAction.NEXT + } + + return result + } } + +private fun FirCallableSymbol<*>.isFromBuiltInClass(session: FirSession) = + dispatchReceiverClassOrNull()?.toSymbol(session)?.fir?.origin == FirDeclarationOrigin.BuiltIns diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt index d3dd4558737..0c451d1bfea 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt @@ -15,11 +15,9 @@ import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractOverrideChecker -import org.jetbrains.kotlin.fir.scopes.jvm.computeJvmDescriptor import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.typeContext import org.jetbrains.kotlin.fir.types.* -import org.jetbrains.kotlin.load.java.SpecialGenericSignatures class JavaOverrideChecker internal constructor( private val session: FirSession, @@ -30,11 +28,10 @@ class JavaOverrideChecker internal constructor( private fun isEqualTypes( candidateType: ConeKotlinType, baseType: ConeKotlinType, - substitutor: ConeSubstitutor, - mayBeSpecialBuiltIn: Boolean + substitutor: ConeSubstitutor ): Boolean { - if (candidateType is ConeFlexibleType) return isEqualTypes(candidateType.lowerBound, baseType, substitutor, mayBeSpecialBuiltIn) - if (baseType is ConeFlexibleType) return isEqualTypes(candidateType, baseType.lowerBound, substitutor, mayBeSpecialBuiltIn) + if (candidateType is ConeFlexibleType) return isEqualTypes(candidateType.lowerBound, baseType, substitutor) + if (baseType is ConeFlexibleType) return isEqualTypes(candidateType, baseType.lowerBound, substitutor) if (candidateType is ConeClassLikeType && baseType is ConeClassLikeType) { val candidateTypeClassId = candidateType.fullyExpandedType(session).lookupTag.classId.let { it.readOnlyToMutable() ?: it } val baseTypeClassId = baseType.fullyExpandedType(session).lookupTag.classId.let { it.readOnlyToMutable() ?: it } @@ -49,22 +46,11 @@ class JavaOverrideChecker internal constructor( return isEqualArrayElementTypeProjections( candidateType.typeArguments.single(), baseType.typeArguments.single(), - substitutor, - mayBeSpecialBuiltIn + substitutor ) } return true } - // TODO: handle the situation in more proper way - // Typical case: class EnumMap implements Map - // We have containsKey(Object) in Map which is enhanced to containsKey(K) in supertype scope - // In EnumMap we have overridden containsKey(Object) which is not yet enhanced - // K may be substituted but after that we will get containsKey(Enum) from supertype, which still does not match... - if (mayBeSpecialBuiltIn && baseType is ConeTypeParameterType && - candidateType is ConeClassLikeType && candidateType.classId == StandardClassIds.Any - ) { - return true - } return with(context) { areEqualTypeConstructors( substitutor.substituteOrSelf(candidateType).typeConstructor(), @@ -76,25 +62,22 @@ class JavaOverrideChecker internal constructor( private fun isEqualTypes( candidateTypeRef: FirTypeRef, baseTypeRef: FirTypeRef, - substitutor: ConeSubstitutor, - mayBeSpecialBuiltIn: Boolean = false + substitutor: ConeSubstitutor ) = isEqualTypes( candidateTypeRef.toConeKotlinTypeProbablyFlexible(session, javaTypeParameterStack), baseTypeRef.toConeKotlinTypeProbablyFlexible(session, javaTypeParameterStack), - substitutor, - mayBeSpecialBuiltIn + substitutor ) private fun isEqualArrayElementTypeProjections( candidateTypeProjection: ConeTypeProjection, baseTypeProjection: ConeTypeProjection, - substitutor: ConeSubstitutor, - mayBeSpecialBuiltIn: Boolean + substitutor: ConeSubstitutor ): Boolean = when { candidateTypeProjection is ConeKotlinTypeProjection && baseTypeProjection is ConeKotlinTypeProjection -> candidateTypeProjection.kind == baseTypeProjection.kind && - isEqualTypes(candidateTypeProjection.type, baseTypeProjection.type, substitutor, mayBeSpecialBuiltIn) + isEqualTypes(candidateTypeProjection.type, baseTypeProjection.type, substitutor) candidateTypeProjection is ConeStarProjection && baseTypeProjection is ConeStarProjection -> true else -> false } @@ -169,13 +152,8 @@ class JavaOverrideChecker internal constructor( if (overrideCandidate.valueParameters.size != baseParameterTypes.size) return false val substitutor = buildTypeParametersSubstitutorIfCompatible(overrideCandidate, baseDeclaration) ?: return false - - val jvmDescriptor by lazy { baseDeclaration.computeJvmDescriptor() } - val mayBeSpecialBuiltIn = - baseDeclaration.name in SpecialGenericSignatures.ERASED_VALUE_PARAMETERS_SHORT_NAMES && - SpecialGenericSignatures.ERASED_VALUE_PARAMETERS_SIGNATURES.any { it.endsWith(jvmDescriptor) } return overrideCandidate.valueParameters.zip(baseParameterTypes).all { (paramFromJava, baseType) -> - isEqualTypes(paramFromJava.returnTypeRef, baseType, substitutor, mayBeSpecialBuiltIn) + isEqualTypes(paramFromJava.returnTypeRef, baseType, substitutor) } } diff --git a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt index 3857ebc7a84..8509c3afd82 100644 --- a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt +++ b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/DescriptorUtils.kt @@ -5,6 +5,9 @@ package org.jetbrains.kotlin.fir.scopes.jvm +import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap +import org.jetbrains.kotlin.fir.containingClass +import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration import org.jetbrains.kotlin.fir.declarations.FirFunction import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.symbols.StandardClassIds @@ -12,68 +15,44 @@ import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.FirImplicitAnyTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitNullableAnyTypeRef import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef -import org.jetbrains.kotlin.load.java.structure.JavaClass -import org.jetbrains.kotlin.load.java.structure.JavaClassifierType import org.jetbrains.kotlin.load.java.structure.JavaPrimitiveType -import org.jetbrains.kotlin.load.java.structure.JavaTypeParameter +import org.jetbrains.kotlin.load.kotlin.SignatureBuildingComponents import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName -fun FirFunction<*>.computeJvmDescriptorReplacingKotlinToJava(): String = - computeJvmDescriptor() - .replace("kotlin/Any", "java/lang/Object") - .replace("kotlin/String", "java/lang/String") - .replace("kotlin/Throwable", "java/lang/Throwable") +fun FirFunction<*>.computeJvmSignature(typeConversion: (FirTypeRef) -> ConeKotlinType? = FirTypeRef::coneTypeSafe): String? { + if (this !is FirCallableMemberDeclaration<*>) return null + val containingClass = containingClass() ?: return null -fun FirFunction<*>.computeJvmDescriptor(): String = buildString { - if (this@computeJvmDescriptor is FirSimpleFunction) { - append(name.asString()) + return SignatureBuildingComponents.signature(containingClass.classId, computeJvmDescriptor(typeConversion = typeConversion)) +} + +fun FirFunction<*>.computeJvmDescriptor( + customName: String? = null, + includeReturnType: Boolean = true, + typeConversion: (FirTypeRef) -> ConeKotlinType? = FirTypeRef::coneTypeSafe +): String = buildString { + if (customName != null) { + append(customName) } else { - append("") + if (this@computeJvmDescriptor is FirSimpleFunction) { + append(name.asString()) + } else { + append("") + } } append("(") for (parameter in valueParameters) { - appendErasedType(parameter.returnTypeRef) + typeConversion(parameter.returnTypeRef)?.let(this::appendConeType) } append(")") - if (this@computeJvmDescriptor !is FirSimpleFunction || returnTypeRef.isVoid()) { - append("V") - } else { - appendErasedType(returnTypeRef) - } -} - -// TODO: primitive types, arrays, etc. -private fun StringBuilder.appendErasedType(typeRef: FirTypeRef) { - fun appendClass(klass: JavaClass) { - klass.fqName?.let { - append("L") - append(it.asString().replace(".", "/")) - append(";") - } - } - - when (typeRef) { - is FirResolvedTypeRef -> appendConeType(typeRef.type) - is FirJavaTypeRef -> { - when (val javaType = typeRef.type) { - is JavaClassifierType -> { - when (val classifier = javaType.classifier) { - is JavaClass -> appendClass(classifier) - is JavaTypeParameter -> { - val representative = classifier.upperBounds.firstOrNull { it.classifier is JavaClass } - if (representative == null) { - append("Ljava/lang/Object;") - } else { - appendClass(representative.classifier as JavaClass) - } - } - else -> return - } - } - } + if (includeReturnType) { + if (this@computeJvmDescriptor !is FirSimpleFunction || returnTypeRef.isVoid()) { + append("V") + } else { + typeConversion(returnTypeRef)?.let(this::appendConeType) } } } @@ -101,7 +80,8 @@ private fun StringBuilder.appendConeType(coneType: ConeKotlinType) { } fun appendClassLikeType(type: ConeClassLikeType) { - val classId = type.lookupTag.classId + val baseClassId = type.lookupTag.classId + val classId = JavaToKotlinClassMap.mapKotlinToJava(baseClassId.asSingleFqName().toUnsafe()) ?: baseClassId if (classId == StandardClassIds.Array) { append("[") type.typeArguments.forEach { typeArg -> diff --git a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/JvmMappedScope.kt b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/JvmMappedScope.kt index 62a08051b3c..cf7ed1b6c21 100644 --- a/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/JvmMappedScope.kt +++ b/compiler/fir/jvm/src/org/jetbrains/kotlin/fir/scopes/jvm/JvmMappedScope.kt @@ -29,11 +29,11 @@ class JvmMappedScope( } val declaredSignatures by lazy { - declared.mapTo(mutableSetOf()) { it.fir.computeJvmDescriptorReplacingKotlinToJava() } + declared.mapTo(mutableSetOf()) { it.fir.computeJvmDescriptor() } } javaMappedClassUseSiteScope.processFunctionsByName(name) { symbol -> - val jvmSignature = symbol.fir.computeJvmDescriptorReplacingKotlinToJava() + val jvmSignature = symbol.fir.computeJvmDescriptor() if (jvmSignature in visibleMethods && jvmSignature !in declaredSignatures) { processor(symbol) } @@ -49,7 +49,7 @@ class JvmMappedScope( val hiddenConstructors = signatures.hiddenConstructors if (hiddenConstructors.isNotEmpty()) { javaMappedClassUseSiteScope.processDeclaredConstructors { symbol -> - val jvmSignature = symbol.fir.computeJvmDescriptorReplacingKotlinToJava() + val jvmSignature = symbol.fir.computeJvmDescriptor() if (jvmSignature !in hiddenConstructors) { processor(symbol) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirUseSiteMemberScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirUseSiteMemberScope.kt index ca22a5f4dc1..e1c2e6d99f7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirUseSiteMemberScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirUseSiteMemberScope.kt @@ -19,7 +19,7 @@ abstract class AbstractFirUseSiteMemberScope( ) : AbstractFirOverrideScope(session, overrideChecker) { private val functions = hashMapOf>() - private val directOverriddenFunctions = hashMapOf>() + protected val directOverriddenFunctions = hashMapOf>() protected val directOverriddenProperties = hashMapOf>() override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt index 835b8d15e63..ca1d6e293c1 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirScope.kt @@ -61,6 +61,15 @@ fun FirTypeScope.processOverriddenFunctionsAndSelf( return processOverriddenFunctions(functionSymbol, processor) } +fun FirTypeScope.processOverriddenPropertiesAndSelf( + propertySymbol: FirPropertySymbol, + processor: (FirPropertySymbol) -> ProcessorAction +): ProcessorAction { + if (!processor(propertySymbol)) return ProcessorAction.STOP + + return processOverriddenProperties(propertySymbol, processor) +} + enum class ProcessorAction { STOP, NEXT, diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/collectionStringImpl.fir.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/collectionStringImpl.fir.kt new file mode 100644 index 00000000000..6dcb7e4ed52 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/collectionStringImpl.fir.kt @@ -0,0 +1,85 @@ +// FILE: CollectionStringImpl.java + +import java.util.Collection; +import java.util.Iterator; + +public class CollectionStringImpl implements Collection { + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + + @Override + public Iterator iterator() { + return null; + } + + + @Override + public Object[] toArray() { + return new Object[0]; + } + + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(String s) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + public boolean contains(String o) { + return true; + } +} + +// FILE: main.kt + +fun test(x: CollectionStringImpl) { + x.contains("") + (x as Collection).contains("") +} diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/collectionStringImpl.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/collectionStringImpl.kt index 13e04293af0..08b86b53d45 100644 --- a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/collectionStringImpl.kt +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/collectionStringImpl.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // FILE: CollectionStringImpl.java import java.util.Collection; diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/contains.fir.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/contains.fir.kt index 00249856f38..574fa9177aa 100644 --- a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/contains.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/contains.fir.kt @@ -40,14 +40,14 @@ fun foo( 1 in a b.contains("") - b.contains(1) + b.contains(1) "" in b - 1 in b + 1 in b ic.contains("") - ic.contains(1) + ic.contains(1) "" in ic - 1 in ic + 1 in ic ka.contains("") ka.contains(1) @@ -55,9 +55,9 @@ fun foo( 1 in ka kb.contains("") - kb.contains(1) + kb.contains(1) "" in kb - 1 in kb + 1 in kb al.contains("") al.contains(1) diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAll.fir.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAll.fir.kt index 7b3f6352e90..6d8492519a4 100644 --- a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAll.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAll.fir.kt @@ -40,16 +40,16 @@ fun foo( a.containsAll(ca) b.containsAll(cs) - b.containsAll(ca) + b.containsAll(ca) ic.containsAll(cs) - ic.containsAll(ca) + ic.containsAll(ca) ka.containsAll(cs) ka.containsAll(ca) kb.containsAll(cs) - kb.containsAll(ca) + kb.containsAll(ca) al.containsAll(cs) al.containsAll(ca) diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAndOverload.fir.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAndOverload.fir.kt index 14ba0abc693..71d078632c4 100644 --- a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAndOverload.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/containsAndOverload.fir.kt @@ -12,13 +12,13 @@ abstract class KA : A() { } fun foo(a: A, ka: KA) { - a.contains("") - a.contains(1) - "" in a - 1 in a + a.contains("") + a.contains(1) + "" in a + 1 in a ka.contains("") - ka.contains(1) + ka.contains(1) "" in ka - 1 in ka + 1 in ka } diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/irrelevantMapGetAbstract.fir.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/irrelevantMapGetAbstract.fir.kt new file mode 100644 index 00000000000..055a7d36daf --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/irrelevantMapGetAbstract.fir.kt @@ -0,0 +1,19 @@ +// FILE: Dict.java + +public abstract class Dict { + abstract public V get(Object key); +} + +// FILE: MHashtable.java + +abstract public class MHashtable extends Dict implements java.util.Map { + public V get(Object key) { return null; } +} + +// FILE: main.kt + +abstract class C1 : MHashtable() + +abstract class C2 : MHashtable() { + override fun get(key: String) = 1 +} diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/irrelevantMapGetAbstract.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/irrelevantMapGetAbstract.kt index 586d232e4f4..409e6ed8c49 100644 --- a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/irrelevantMapGetAbstract.kt +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/irrelevantMapGetAbstract.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // FILE: Dict.java public abstract class Dict { diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.fir.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.fir.kt deleted file mode 100644 index f57ecfdb76a..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.fir.kt +++ /dev/null @@ -1,32 +0,0 @@ -// JAVAC_EXPECTED_FILE -// FILE: A.java -abstract public class A extends B { - public Integer removeAt(int x) { } - public boolean remove(Integer x) { } -} - -// FILE: main.kt -import java.util.*; - -abstract class B : MutableList, AbstractList() { - override fun removeAt(index: Int): Int = null!! - override fun remove(element: Int): Boolean = null!! -} - -abstract class D : AbstractList() { - // removeAt() doesn't exist in java/util/AbstractList, it's a - // fake override of the method from kotlin/collections/MutableList - override fun removeAt(index: Int): Int = null!! - // AbstractList::remove() should return Int here. No fake overrides created. - // This may be a bug because the old compiler doesn't report a diagnostic here. - override fun remove(element: Int): Boolean = null!! -} - -fun main(a: A, b: B, c: ArrayList) { - a.remove(1) - a.removeAt(0) - b.remove(1) - b.removeAt(0) - c.remove(1) - c.removeAt(0) -} diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.kt index 8510bc01ac0..581138898ae 100644 --- a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.kt +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JAVAC_EXPECTED_FILE // FILE: A.java abstract public class A extends B { diff --git a/compiler/testData/diagnostics/tests/j+k/finalCollectionSize.fir.kt b/compiler/testData/diagnostics/tests/j+k/finalCollectionSize.fir.kt deleted file mode 100644 index 8eba11c0bc3..00000000000 --- a/compiler/testData/diagnostics/tests/j+k/finalCollectionSize.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -// JAVAC_EXPECTED_FILE -// FILE: A.java - -abstract public class A extends java.util.ArrayList { - public final int size() { return 0; } -} - -// FILE: main.kt - -class B : A() { - override val size: Int = 1 -} diff --git a/compiler/testData/diagnostics/tests/j+k/finalCollectionSize.kt b/compiler/testData/diagnostics/tests/j+k/finalCollectionSize.kt index fc53d7be086..2b918487101 100644 --- a/compiler/testData/diagnostics/tests/j+k/finalCollectionSize.kt +++ b/compiler/testData/diagnostics/tests/j+k/finalCollectionSize.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // JAVAC_EXPECTED_FILE // FILE: A.java diff --git a/compiler/testData/diagnostics/tests/j+k/primitiveOverrides/specializedMap.fir.kt b/compiler/testData/diagnostics/tests/j+k/primitiveOverrides/specializedMap.fir.kt new file mode 100644 index 00000000000..2bfe4e906af --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/primitiveOverrides/specializedMap.fir.kt @@ -0,0 +1,113 @@ +// FILE: AbstractSpecializedMap.java +public abstract class AbstractSpecializedMap implements java.util.Map { + public abstract double put(int x, double y); + public abstract double remove(int k); + public abstract double get(int k); + + public abstract boolean containsKey(int k); + public boolean containsKey(Object x) { + return false; + } + + public abstract boolean containsValue(double v); + public boolean containsValue(Object x) { + return false; + } +} + +// FILE: SpecializedMap.java +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +public class SpecializedMap extends AbstractSpecializedMap { + public double put(int x, double y) { + return 123.0; + } + + @Override + public Double get(Object key) { + return null; + } + + @Override + public Double put(Integer key, Double value) { + return null; + } + + public double remove(int k) { + return 456.0; + } + + + public Double remove(Object ok) { + return null; + } + + + public double get(int k) { + return 789.0; + } + + public boolean containsKey(int k) { + return true; + } + + public boolean containsValue(double v) { + return true; + } + + @Override + public void putAll(Map m) { + } + + @Override + public void clear() { + + } + + @NotNull + @Override + public Set keySet() { + return null; + } + + @NotNull + @Override + public Collection values() { + return null; + } + + @NotNull + @Override + public Set> entrySet() { + return null; + } + + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } +} + +// FILE: main.kt +fun foo(x: SpecializedMap) { + x.containsKey(1) + x.containsKey(null) + + x.get(2) + x.get(null) + + x.remove(3) + x.remove(null) + + x.put(4, 5.0) + x.put(4, null) +} diff --git a/compiler/testData/diagnostics/tests/j+k/primitiveOverrides/specializedMap.kt b/compiler/testData/diagnostics/tests/j+k/primitiveOverrides/specializedMap.kt index f26f5d83449..1aaaa82660d 100644 --- a/compiler/testData/diagnostics/tests/j+k/primitiveOverrides/specializedMap.kt +++ b/compiler/testData/diagnostics/tests/j+k/primitiveOverrides/specializedMap.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // FILE: AbstractSpecializedMap.java public abstract class AbstractSpecializedMap implements java.util.Map { public abstract double put(int x, double y); diff --git a/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.fir.txt b/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.fir.txt index a3f0016c51b..b5baee9257a 100644 --- a/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.fir.txt +++ b/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.fir.txt @@ -1,8 +1,6 @@ public open class ModalityOfFakeOverrides : R|java/util/AbstractList!>| { @R|java/lang/Override|() @R|org/jetbrains/annotations/NotNull|() public open operator fun get(index: R|kotlin/Int|): R|@EnhancedNullability kotlin/String| - @R|java/lang/Override|() public open fun size(): R|kotlin/Int| - public constructor(): R|test/ModalityOfFakeOverrides| } diff --git a/idea/idea-frontend-fir/testData/memberScopeByFqName/java.lang.String.txt b/idea/idea-frontend-fir/testData/memberScopeByFqName/java.lang.String.txt index 0e037893735..5ac4a2205df 100644 --- a/idea/idea-frontend-fir/testData/memberScopeByFqName/java.lang.String.txt +++ b/idea/idea-frontend-fir/testData/memberScopeByFqName/java.lang.String.txt @@ -52,46 +52,25 @@ KtFirJavaFieldSymbol: symbolKind: MEMBER visibility: PRIVATE -KtFirFunctionSymbol: +KtFirSyntheticJavaPropertySymbol: annotatedType: [] kotlin/Int annotationClassIds: [] annotations: [] callableIdIfNonLocal: java.lang.String.length dispatchType: java/lang/String - isExtension: false - isExternal: false - isInline: false - isOperator: false - isOverride: false - isSuspend: false - modality: OPEN - name: length - origin: JAVA - receiverType: null - symbolKind: MEMBER - typeParameters: [] - valueParameters: [] - visibility: PUBLIC - -KtFirKotlinPropertySymbol: - annotatedType: [] kotlin/Int - annotationClassIds: [] - annotations: [] - callableIdIfNonLocal: kotlin.CharSequence.length - dispatchType: kotlin/CharSequence getter: KtFirPropertyGetterSymbol() - hasBackingField: false + hasBackingField: true hasGetter: true hasSetter: false initializer: null - isConst: false isExtension: false - isLateInit: false isOverride: false isVal: true - modality: ABSTRACT + javaGetterName: length + javaSetterName: null + modality: OPEN name: length - origin: LIBRARY + origin: JAVA_SYNTHETIC_PROPERTY receiverType: null setter: null symbolKind: MEMBER From fb8314f6e765ebb2a2871dee2dd2b69050575fc8 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 17 Feb 2021 18:33:00 +0300 Subject: [PATCH 333/368] FIR: Fix enhancement of property overrides accessors in Java --- .../kotlin/fir/java/enhancement/SignatureEnhancement.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt index 8df2a9d4d76..67a31d94e8b 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/SignatureEnhancement.kt @@ -118,7 +118,7 @@ class FirSignatureEnhancement( val getterDelegate = firElement.getter.delegate val enhancedGetterSymbol = if (getterDelegate is FirJavaMethod) { enhanceMethod( - getterDelegate, accessorSymbol.accessorId, accessorSymbol.accessorId.callableName + getterDelegate, getterDelegate.symbol.callableId, getterDelegate.name, ) } else { getterDelegate.symbol @@ -126,7 +126,7 @@ class FirSignatureEnhancement( val setterDelegate = firElement.setter?.delegate val enhancedSetterSymbol = if (setterDelegate is FirJavaMethod) { enhanceMethod( - setterDelegate, accessorSymbol.accessorId, accessorSymbol.accessorId.callableName + setterDelegate, setterDelegate.symbol.callableId, setterDelegate.name, ) } else { setterDelegate?.symbol From d339096ac337993e9d37fe1f1aa33f0cbfb450ba Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 17 Feb 2021 18:40:23 +0300 Subject: [PATCH 334/368] FIR2IR: Introduce and use declarationStorage.getOrCreateIrConstructor It's necessary because constructors of LazyIrClass annotations may be referenced before members are processed --- .../jetbrains/kotlin/fir/backend/Fir2IrConverter.kt | 4 ++-- .../kotlin/fir/backend/Fir2IrDeclarationStorage.kt | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt index dcb27fa4ade..38fa69a1d12 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt @@ -123,7 +123,7 @@ class Fir2IrConverter( irClass: IrClass = classifierStorage.getCachedIrClass(regularClass)!! ): IrClass { val irConstructor = regularClass.getPrimaryConstructorIfAny()?.let { - declarationStorage.createIrConstructor(it, irClass, isLocal = regularClass.isLocal) + declarationStorage.getOrCreateIrConstructor(it, irClass, isLocal = regularClass.isLocal) } if (irConstructor != null) { irClass.declarations += irConstructor @@ -219,7 +219,7 @@ class Fir2IrConverter( } } is FirConstructor -> if (!declaration.isPrimary) { - declarationStorage.createIrConstructor( + declarationStorage.getOrCreateIrConstructor( declaration, parent as IrClass, isLocal = isLocal ) } else { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 14cff99b06a..13f55300f78 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -544,6 +544,16 @@ class Fir2IrDeclarationStorage( return created } + fun getOrCreateIrConstructor( + constructor: FirConstructor, + irParent: IrClass, + origin: IrDeclarationOrigin = IrDeclarationOrigin.DEFINED, + isLocal: Boolean = false + ): IrConstructor { + getCachedIrConstructor(constructor)?.let { return it } + return createIrConstructor(constructor, irParent, origin, isLocal) + } + private fun declareIrAccessor( signature: IdSignature?, containerSource: DeserializedContainerSource?, From a883833941a4e804372f1bb2a843330b852febfc Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 17 Feb 2021 19:02:15 +0300 Subject: [PATCH 335/368] FIR2IR: Use IrDeclarationOrigin.FAKE_OVERRIDE for non-source classes --- .../kotlin/fir/backend/Fir2IrDeclarationStorage.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 13f55300f78..ce237866e02 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -1019,7 +1019,7 @@ class Fir2IrDeclarationStorage( getCachedIrFunction(fir)?.let { return it.symbol } val irParent = findIrParent(fir) val parentOrigin = (irParent as? IrDeclaration)?.origin ?: IrDeclarationOrigin.DEFINED - val declarationOrigin = computeDeclarationOrigin(firFunctionSymbol, parentOrigin, irParent) + val declarationOrigin = computeDeclarationOrigin(firFunctionSymbol, parentOrigin) createIrFunction(fir, irParent, origin = declarationOrigin).symbol } is FirSimpleFunction -> { @@ -1106,7 +1106,7 @@ class Fir2IrDeclarationStorage( signature }?.let { return it.symbol } val parentOrigin = (irParent as? IrDeclaration)?.origin ?: IrDeclarationOrigin.DEFINED - val declarationOrigin = computeDeclarationOrigin(firSymbol, parentOrigin, irParent) + val declarationOrigin = computeDeclarationOrigin(firSymbol, parentOrigin) // TODO: package fragment members (?) val parent = irParent if (parent is Fir2IrLazyClass) { @@ -1124,17 +1124,14 @@ class Fir2IrDeclarationStorage( private fun computeDeclarationOrigin( symbol: FirCallableSymbol<*>, - parentOrigin: IrDeclarationOrigin, - irParent: IrDeclarationParent? + parentOrigin: IrDeclarationOrigin ): IrDeclarationOrigin { - return if (irParent.isSourceClass() && (symbol.fir.isIntersectionOverride || symbol.fir.isSubstitutionOverride)) + return if (symbol.fir.isIntersectionOverride || symbol.fir.isSubstitutionOverride) IrDeclarationOrigin.FAKE_OVERRIDE else parentOrigin } - private fun IrDeclarationParent?.isSourceClass() = this is IrClass && this !is Fir2IrLazyClass && this !is IrLazyClass - fun getIrFieldSymbol(firFieldSymbol: FirFieldSymbol): IrSymbol { val fir = firFieldSymbol.fir val irProperty = fieldCache[fir] ?: run { From fd146e3eed929df5fb6473645e5e34f08cd8955e Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 17 Feb 2021 19:04:04 +0300 Subject: [PATCH 336/368] FIR2IR: Copy annotations from original declarations to fake overrides --- .../jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt | 4 +++- .../box/compileKotlinAgainstKotlin/annotationInInterface.kt | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index ce237866e02..04c2eb35488 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -1193,7 +1193,9 @@ class Fir2IrDeclarationStorage( } private fun IrMutableAnnotationContainer.convertAnnotationsFromLibrary(firAnnotationContainer: FirAnnotationContainer) { - if ((firAnnotationContainer as? FirDeclaration)?.isFromLibrary == true) { + if ((firAnnotationContainer as? FirDeclaration)?.isFromLibrary == true || + (firAnnotationContainer is FirCallableMemberDeclaration<*> && firAnnotationContainer.isSubstitutionOrIntersectionOverride) + ) { annotationGenerator.generate(this, firAnnotationContainer) } } diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationInInterface.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationInInterface.kt index 3fa31f3de8b..f7b4995fb69 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationInInterface.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/annotationInInterface.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_STDLIB // WITH_REFLECT From a750d9466ec5f2bf00e44e4387c8946cee0e5e94 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Thu, 18 Feb 2021 09:53:54 +0300 Subject: [PATCH 337/368] FIR2IR: Rework resulted overridden-relation structure The difference is how we deal with intermediate fake overrides E.g., in case interface A { /* $1 */ fun foo() } interface B : A { /* $2 */ fake_override fun foo() } interface C : B { /* $3 */ override fun foo() } We've got FIR declarations only for $1 and $3, but we've got a fake override for $2 in IR. Previously, override $3 had $1 as its overridden IR symbol, just because FIR declaration of $3 doesn't know anything about $2. Now, when generating IR for $2, we save the necessary information and using it for $3, so it has $2 as overridden. So, it's consistent with the overridden structure of FE 1.0 and this structure is necessary prerequisite for proper building of bridges for special built-ins. --- .../kotlin/fir/backend/ConversionUtils.kt | 82 ++++++++--- .../fir/backend/Fir2IrDeclarationStorage.kt | 62 ++++++++- .../generators/ClassMemberGenerator.kt | 4 +- .../generators/DelegatedMemberGenerator.kt | 19 ++- .../generators/FakeOverrideGenerator.kt | 117 +++++++++++++--- .../fir/lazy/Fir2IrLazySimpleFunction.kt | 2 +- .../FirBlackBoxCodegenTestGenerated.java | 6 + .../extendJavaCollections/abstractMap.kt | 1 - .../extendJavaCollections/abstractSet.kt | 1 - .../extendJavaCollections/hashMap.kt | 1 - .../extendJavaCollections/hashSet.kt | 1 - .../mutabilityMarkerInterfaces.kt | 1 - .../addCollectionStubWithCovariantOverride.kt | 4 +- .../javaCollectionWithRemovePrimitiveInt.kt | 1 - .../codegen/box/specialBuiltins/bridges.kt | 1 - .../box/specialBuiltins/complexMapImpl.kt | 131 ++++++++++++++++++ .../specialBuiltins/specialBridgeModality.kt | 1 - .../codegen/box/traits/defaultImplCall.kt | 1 - .../genericParameterBridge/abstractList.kt | 1 - .../interfaces/traitImplGeneratedOnce.kt | 1 - .../codegen/bytecodeText/mapGetOrDefault.kt | 3 +- .../codegen/BlackBoxCodegenTestGenerated.java | 6 + .../IrBlackBoxCodegenTestGenerated.java | 6 + .../LightAnalysisModeTestGenerated.java | 5 + 24 files changed, 389 insertions(+), 69 deletions(-) create mode 100644 compiler/testData/codegen/box/specialBuiltins/complexMapImpl.kt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index b09979741ad..730ddf598da 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.* +import org.jetbrains.kotlin.fir.backend.generators.FakeOverrideGenerator import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall @@ -24,11 +25,8 @@ import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.SyntheticPropertySymbol import org.jetbrains.kotlin.fir.resolve.calls.originalConstructorIfTypeAlias import org.jetbrains.kotlin.fir.resolve.providers.FirProvider -import org.jetbrains.kotlin.fir.scopes.ProcessorAction +import org.jetbrains.kotlin.fir.scopes.* import org.jetbrains.kotlin.fir.scopes.impl.delegatedWrapperData -import org.jetbrains.kotlin.fir.scopes.processDirectlyOverriddenFunctions -import org.jetbrains.kotlin.fir.scopes.processDirectlyOverriddenProperties -import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope import org.jetbrains.kotlin.fir.symbols.AccessorSymbol import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* @@ -292,45 +290,89 @@ internal fun FirSimpleFunction.generateOverriddenFunctionSymbols( containingClass: FirClass<*>, session: FirSession, scopeSession: ScopeSession, - declarationStorage: Fir2IrDeclarationStorage + declarationStorage: Fir2IrDeclarationStorage, + fakeOverrideGenerator: FakeOverrideGenerator, ): List { + val superClasses = containingClass.getSuperTypesAsIrClasses(declarationStorage) ?: return emptyList() + val scope = containingClass.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = true) scope.processFunctionsByName(name) {} val overriddenSet = mutableSetOf() - scope.processDirectlyOverriddenFunctions(symbol) { + scope.processOverriddenFunctionsFromSuperClasses(symbol, containingClass) { if (it.fir.visibility == Visibilities.Private) { - return@processDirectlyOverriddenFunctions ProcessorAction.NEXT + return@processOverriddenFunctionsFromSuperClasses ProcessorAction.NEXT + } + + for (overridden in fakeOverrideGenerator.getOverriddenSymbolsInSupertypes(it, superClasses)) { + overriddenSet += overridden } - val overridden = declarationStorage.getIrFunctionSymbol(it.unwrapFakeOverrides()) - overriddenSet += overridden as IrSimpleFunctionSymbol ProcessorAction.NEXT } + return overriddenSet.toList() } +fun FirTypeScope.processOverriddenFunctionsFromSuperClasses( + functionSymbol: FirNamedFunctionSymbol, + containingClass: FirClass<*>, + processor: (FirNamedFunctionSymbol) -> ProcessorAction +): ProcessorAction = processDirectOverriddenFunctionsWithBaseScope(functionSymbol) { overridden, baseScope -> + val unwrapped = + overridden.fir.delegatedWrapperData?.takeIf { it.containingClass == containingClass.symbol.toLookupTag() }?.wrapped?.symbol + ?: overridden + + if (unwrapped.containingClass() == containingClass.symbol.toLookupTag()) { + baseScope.processOverriddenFunctionsFromSuperClasses(unwrapped, containingClass, processor) + } else { + processor(overridden) + } +} + +fun FirTypeScope.processOverriddenPropertiesFromSuperClasses( + propertySymbol: FirPropertySymbol, + containingClass: FirClass<*>, + processor: (FirPropertySymbol) -> ProcessorAction +): ProcessorAction = processDirectOverriddenPropertiesWithBaseScope(propertySymbol) { overridden, baseScope -> + if (overridden.containingClass() == containingClass.symbol.toLookupTag()) { + baseScope.processOverriddenPropertiesFromSuperClasses(overridden, containingClass, processor) + } else { + processor(overridden) + } +} + +private fun FirClass<*>.getSuperTypesAsIrClasses( + declarationStorage: Fir2IrDeclarationStorage +): Set? { + val irClass = + declarationStorage.classifierStorage.getIrClassSymbol(symbol).owner as? IrClass ?: return null + + return irClass.superTypes.mapNotNull { it.classifierOrNull?.owner as? IrClass }.toSet() +} + internal fun FirProperty.generateOverriddenAccessorSymbols( containingClass: FirClass<*>, isGetter: Boolean, session: FirSession, scopeSession: ScopeSession, - declarationStorage: Fir2IrDeclarationStorage + declarationStorage: Fir2IrDeclarationStorage, + fakeOverrideGenerator: FakeOverrideGenerator, ): List { val scope = containingClass.unsubstitutedScope(session, scopeSession, withForcedTypeCalculator = true) scope.processPropertiesByName(name) {} val overriddenSet = mutableSetOf() - scope.processDirectlyOverriddenProperties(symbol) { - if (it is FirAccessorSymbol || it.fir.visibility == Visibilities.Private) { - return@processDirectlyOverriddenProperties ProcessorAction.NEXT + val superClasses = containingClass.getSuperTypesAsIrClasses(declarationStorage) ?: return emptyList() + + scope.processOverriddenPropertiesFromSuperClasses(symbol, containingClass) { + if (it.fir.visibility == Visibilities.Private) { + return@processOverriddenPropertiesFromSuperClasses ProcessorAction.NEXT } - val unwrapped = - it.fir.delegatedWrapperData?.takeIf { it.containingClass == containingClass.symbol.toLookupTag() }?.wrapped?.symbol ?: it - - val overriddenProperty = declarationStorage.getIrPropertySymbol(unwrapped.unwrapFakeOverrides()) as IrPropertySymbol - val overriddenAccessor = if (isGetter) overriddenProperty.owner.getter?.symbol else overriddenProperty.owner.setter?.symbol - if (overriddenAccessor != null) { - overriddenSet += overriddenAccessor + for (overriddenProperty in fakeOverrideGenerator.getOverriddenSymbolsInSupertypes(it, superClasses)) { + val overriddenAccessor = if (isGetter) overriddenProperty.owner.getter?.symbol else overriddenProperty.owner.setter?.symbol + if (overriddenAccessor != null) { + overriddenSet += overriddenAccessor + } } ProcessorAction.NEXT } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 04c2eb35488..77c3c4f438b 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -76,6 +76,23 @@ class Fir2IrDeclarationStorage( private val propertyCache = ConcurrentHashMap() + // interface A { /* $1 */ fun foo() } + // interface B : A { + // /* $2 */ fake_override fun foo() + // } + // interface C : B { + // /* $3 */ override fun foo() + // } + // + // We've got FIR declarations only for $1 and $3, but we've got a fake override for $2 in IR + // and just to simplify things we create a synthetic FIR for $2, while it can't be referenced from other FIR nodes. + // + // But when we binding overrides for $3, we want it had $2 ad it's overridden, + // so remember that in class B there's a fake override $2 for real $1. + // + // Thus we may obtain it by fakeOverridesInClass[ir(B)][fir(A::foo)] -> fir(B::foo) + private val fakeOverridesInClass = mutableMapOf, FirCallableDeclaration<*>>>() + // For pure fields (from Java) only private val fieldToPropertyCache = ConcurrentHashMap() @@ -633,7 +650,7 @@ class Fir2IrDeclarationStorage( } if (correspondingProperty is Fir2IrLazyProperty && !isFakeOverride && thisReceiverOwner != null) { this.overriddenSymbols = correspondingProperty.fir.generateOverriddenAccessorSymbols( - correspondingProperty.containingClass, !isSetter, session, scopeSession, declarationStorage + correspondingProperty.containingClass, !isSetter, session, scopeSession, declarationStorage, fakeOverrideGenerator ) } } @@ -835,6 +852,23 @@ class Fir2IrDeclarationStorage( delegatedReverseCache[irProperty] = property } + internal fun saveFakeOverrideInClass( + irClass: IrClass, + callableDeclaration: FirCallableDeclaration<*>, + fakeOverride: FirCallableDeclaration<*> + ) { + fakeOverridesInClass.getOrPut(irClass, ::mutableMapOf)[callableDeclaration] = fakeOverride + } + + fun getFakeOverrideInClass( + irClass: IrClass, + callableDeclaration: FirCallableDeclaration<*> + ): FirCallableDeclaration<*>? { + // Init lazy class if necessary + irClass.declarations + return fakeOverridesInClass[irClass]?.get(callableDeclaration) + } + fun getCachedIrField(field: FirField): IrField? = fieldCache[field] fun createIrFieldAndDelegatedMembers(field: FirField, owner: FirClass<*>, irClass: IrClass): IrField { @@ -1108,13 +1142,27 @@ class Fir2IrDeclarationStorage( val parentOrigin = (irParent as? IrDeclaration)?.origin ?: IrDeclarationOrigin.DEFINED val declarationOrigin = computeDeclarationOrigin(firSymbol, parentOrigin) // TODO: package fragment members (?) - val parent = irParent - if (parent is Fir2IrLazyClass) { - assert(parentOrigin != IrDeclarationOrigin.DEFINED) { - "Should not have reference to public API uncached property from source code" + when (val parent = irParent) { + is Fir2IrLazyClass -> { + assert(parentOrigin != IrDeclarationOrigin.DEFINED) { + "Should not have reference to public API uncached property from source code" + } + signature?.let { + return createIrLazyDeclaration(it, parent, declarationOrigin).symbol + } } - signature?.let { - return createIrLazyDeclaration(it, parent, declarationOrigin).symbol + is IrLazyClass -> { + val unwrapped = fir.unwrapFakeOverrides() + if (unwrapped !== fir) { + when (unwrapped) { + is FirSimpleFunction -> { + return getIrFunctionSymbol(unwrapped.symbol) + } + is FirProperty -> { + return getIrPropertySymbol(unwrapped.symbol) + } + } + } } } return createIrDeclaration(irParent, declarationOrigin).apply { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt index 0b709411cfb..4a76e3b3a6b 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt @@ -144,7 +144,7 @@ internal class ClassMemberGenerator( } if (irFunction is IrSimpleFunction && firFunction is FirSimpleFunction && containingClass != null) { irFunction.overriddenSymbols = firFunction.generateOverriddenFunctionSymbols( - containingClass, session, scopeSession, declarationStorage + containingClass, session, scopeSession, declarationStorage, fakeOverrideGenerator ) } } @@ -254,7 +254,7 @@ internal class ClassMemberGenerator( } if (containingClass != null) { this.overriddenSymbols = property.generateOverriddenAccessorSymbols( - containingClass, isGetter, session, scopeSession, declarationStorage + containingClass, isGetter, session, scopeSession, declarationStorage, fakeOverrideGenerator ) } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt index 5bba834af73..5bc798de0f9 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DelegatedMemberGenerator.kt @@ -132,7 +132,13 @@ internal class DelegatedMemberGenerator( containingClass = firSubClass.symbol.toLookupTag() ) delegateFunction.overriddenSymbols = - delegateOverride.generateOverriddenFunctionSymbols(firSubClass, session, scopeSession, declarationStorage) + delegateOverride.generateOverriddenFunctionSymbols( + firSubClass, + session, + scopeSession, + declarationStorage, + fakeOverrideGenerator + ) .filter { it.owner != delegateFunction } annotationGenerator.generate(delegateFunction, delegateOverride) @@ -201,13 +207,20 @@ internal class DelegatedMemberGenerator( delegateProperty.getter!!.body = createDelegateBody(irField, delegateProperty.getter!!, superProperty.getter!!) delegateProperty.getter!!.overriddenSymbols = - firDelegateProperty.generateOverriddenAccessorSymbols(firSubClass, isGetter = true, session, scopeSession, declarationStorage) + firDelegateProperty.generateOverriddenAccessorSymbols( + firSubClass, + isGetter = true, + session, + scopeSession, + declarationStorage, + fakeOverrideGenerator + ) annotationGenerator.generate(delegateProperty.getter!!, firDelegateProperty) if (delegateProperty.isVar) { delegateProperty.setter!!.body = createDelegateBody(irField, delegateProperty.setter!!, superProperty.setter!!) delegateProperty.setter!!.overriddenSymbols = firDelegateProperty.generateOverriddenAccessorSymbols( - firSubClass, isGetter = false, session, scopeSession, declarationStorage + firSubClass, isGetter = false, session, scopeSession, declarationStorage, fakeOverrideGenerator ) annotationGenerator.generate(delegateProperty.setter!!, firDelegateProperty) } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt index 18602971925..a58abdb4f4c 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/FakeOverrideGenerator.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.backend.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.resolve.defaultType +import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.scopes.* import org.jetbrains.kotlin.fir.scopes.impl.FirFakeOverrideGenerator import org.jetbrains.kotlin.fir.scopes.impl.delegatedWrapperData @@ -21,11 +22,10 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol -import org.jetbrains.kotlin.ir.types.IrErrorType -import org.jetbrains.kotlin.ir.types.IrSimpleType -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.IrTypeProjection +import org.jetbrains.kotlin.ir.symbols.IrSymbol +import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.IdSignature +import org.jetbrains.kotlin.ir.util.parentAsClass import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities class FakeOverrideGenerator( @@ -147,30 +147,34 @@ class FakeOverrideGenerator( val origin = IrDeclarationOrigin.FAKE_OVERRIDE val baseSymbol = originalSymbol.unwrapSubstitutionAndIntersectionOverrides() as S - val baseDeclaration = when { + + val (fakeOverrideFirDeclaration, baseFirSymbolsForFakeOverride) = when { originalSymbol.fir.origin.fromSupertypes && originalSymbol.dispatchReceiverClassOrNull() == classLookupTag -> { - // Substitution case - originalDeclaration + // Substitution or intersection case + // We have already a FIR declaration for such fake override + originalDeclaration to computeBaseSymbols(originalSymbol, computeDirectOverridden, scope, classLookupTag) } originalDeclaration.allowsToHaveFakeOverrideIn(klass) -> { // Trivial fake override case + // We've got no relevant declaration in FIR world for such a fake override in current class, thus we're creating it here val fakeOverrideSymbol = createFakeOverrideSymbol(originalDeclaration, baseSymbol) + declarationStorage.saveFakeOverrideInClass(irClass, originalDeclaration, fakeOverrideSymbol.fir) classifierStorage.preCacheTypeParameters(originalDeclaration) - fakeOverrideSymbol.fir + fakeOverrideSymbol.fir to listOf(originalSymbol) } else -> { return } } - val irDeclaration = cachedIrDeclaration(baseDeclaration) { + val irDeclaration = cachedIrDeclaration(fakeOverrideFirDeclaration) { // Sometimes we can have clashing here when FIR substitution/intersection override // have the same signature. // Now we avoid this problem by signature caching, // so both FIR overrides correspond to one IR fake override - signatureComposer.composeSignature(baseDeclaration) + signatureComposer.composeSignature(fakeOverrideFirDeclaration) }?.takeIf { it.parent == irClass } ?: createIrDeclaration( - baseDeclaration, + fakeOverrideFirDeclaration, irClass, /* thisReceiverOwner = */ declarationStorage.findIrParent(baseSymbol.fir) as? IrClass, origin, @@ -179,18 +183,20 @@ class FakeOverrideGenerator( if (containsErrorTypes(irDeclaration)) { return } - baseSymbols[irDeclaration] = computeBaseSymbols(originalSymbol, baseSymbol, computeDirectOverridden, scope, classLookupTag) + baseSymbols[irDeclaration] = baseFirSymbolsForFakeOverride result += irDeclaration } private inline fun > computeBaseSymbols( symbol: S, - basedSymbol: S, directOverridden: FirTypeScope.(S) -> List, scope: FirTypeScope, containingClass: ConeClassLikeLookupTag, ): List { - if (symbol.fir.origin != FirDeclarationOrigin.IntersectionOverride) return listOf(basedSymbol) + if (symbol.fir.origin == FirDeclarationOrigin.SubstitutionOverride) { + return listOf(symbol.originalForSubstitutionOverride!!) + } + return scope.directOverridden(symbol).map { // Unwrapping should happen only for fake overrides members from the same class, not from supertypes if (it.dispatchReceiverClassOrNull() != containingClass) return@map it @@ -204,8 +210,78 @@ class FakeOverrideGenerator( } } - internal fun getOverriddenSymbols(function: IrSimpleFunction): List? { - return baseFunctionSymbols[function]?.map { declarationStorage.getIrFunctionSymbol(it) as IrSimpleFunctionSymbol } + internal fun getOverriddenSymbolsForFakeOverride(function: IrSimpleFunction): List? { + val baseSymbols = baseFunctionSymbols[function] ?: return null + return getOverriddenSymbolsInSupertypes( + function, + baseSymbols + ) { declarationStorage.getIrFunctionSymbol(it) as IrSimpleFunctionSymbol } + } + + internal fun getOverriddenSymbolsInSupertypes( + overridden: FirNamedFunctionSymbol, + superClasses: Set, + ): List { + return getOverriddenSymbolsInSupertypes( + overridden, + superClasses + ) { declarationStorage.getIrFunctionSymbol(it) as IrSimpleFunctionSymbol } + } + + internal fun getOverriddenSymbolsInSupertypes( + overridden: FirPropertySymbol, + superClasses: Set, + ): List { + return getOverriddenSymbolsInSupertypes( + overridden, superClasses + ) { declarationStorage.getIrPropertySymbol(it) as IrPropertySymbol } + } + + private fun > getOverriddenSymbolsInSupertypes( + declaration: I, + baseSymbols: List, + irProducer: (F) -> S, + ): List { + val irClass = declaration.parentAsClass + val superClasses = irClass.superTypes.mapNotNull { it.classifierOrNull?.owner as? IrClass }.toSet() + + return baseSymbols.flatMap { overridden -> + getOverriddenSymbolsInSupertypes(overridden, superClasses, irProducer) + }.distinct() + } + + private fun , S : IrSymbol> getOverriddenSymbolsInSupertypes( + overridden: F, + superClasses: Set, + irProducer: (F) -> S + ): List { + val overriddenContainingClass = + overridden.containingClass()?.toSymbol(session)?.fir as? FirClass<*> ?: return emptyList() + + val overriddenContainingIrClass = + declarationStorage.classifierStorage.getIrClassSymbol(overriddenContainingClass.symbol).owner as? IrClass + ?: return emptyList() + + return if (overriddenContainingIrClass in superClasses) { + // `overridden` was a FIR declaration in some of the supertypes + listOf(irProducer(overridden)) + } else { + // There were no FIR declaration in supertypes, but we know that we have fake overrides in some of them + superClasses.mapNotNull { + declarationStorage.getFakeOverrideInClass(it, overridden.fir)?.let { fakeOverrideInClass -> + @Suppress("UNCHECKED_CAST") + irProducer(fakeOverrideInClass.symbol as F) + } + }.run { + // TODO: Get rid of this hack + // It's only needed for built-in super classes, because they are built via descriptors and + // don't register fake overrides at org.jetbrains.kotlin.fir.backend.Fir2IrDeclarationStorage.fakeOverridesInClass + if (isEmpty()) + listOf(irProducer(overridden)) + else + this + } + } } fun bindOverriddenSymbols(declarations: List) { @@ -213,7 +289,7 @@ class FakeOverrideGenerator( if (declaration.origin != IrDeclarationOrigin.FAKE_OVERRIDE) continue when (declaration) { is IrSimpleFunction -> { - val baseSymbols = getOverriddenSymbols(declaration)!! + val baseSymbols = getOverriddenSymbolsForFakeOverride(declaration)!! declaration.withFunction { overriddenSymbols = baseSymbols } @@ -249,9 +325,10 @@ class FakeOverrideGenerator( isVar: Boolean, firOverriddenSymbols: List ): IrProperty { - val overriddenIrProperties = firOverriddenSymbols.mapNotNull { - (declarationStorage.getIrPropertySymbol(it) as? IrPropertySymbol)?.owner - } + val overriddenIrProperties = getOverriddenSymbolsInSupertypes(this, firOverriddenSymbols) { + declarationStorage.getIrPropertySymbol(it) as IrPropertySymbol + }.map { it.owner } + getter?.apply { overriddenSymbols = overriddenIrProperties.mapNotNull { it.getter?.symbol } } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt index 30c2d974326..cba4f9b9642 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt @@ -71,7 +71,7 @@ class Fir2IrLazySimpleFunction( val parent = parent if (isFakeOverride && parent is Fir2IrLazyClass) { parent.declarations - fakeOverrideGenerator.getOverriddenSymbols(this)?.let { return@lazyVar it } + fakeOverrideGenerator.getOverriddenSymbolsForFakeOverride(this)?.let { return@lazyVar it } } fir.generateOverriddenFunctionSymbols(firParent, session, scopeSession, declarationStorage, fakeOverrideGenerator) } diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 5abc0ae47ae..9cf4c768fe8 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -37768,6 +37768,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/specialBuiltins/commonBridgesTarget.kt"); } + @Test + @TestMetadata("complexMapImpl.kt") + public void testComplexMapImpl() throws Exception { + runTest("compiler/testData/codegen/box/specialBuiltins/complexMapImpl.kt"); + } + @Test @TestMetadata("emptyList.kt") public void testEmptyList() throws Exception { diff --git a/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractMap.kt b/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractMap.kt index 18bb26f2000..0447f569b20 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractMap.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractMap.kt @@ -1,6 +1,5 @@ // DONT_TARGET_EXACT_BACKEND: WASM // WASM_MUTE_REASON: STDLIB_COLLECTIONS -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM import java.util.AbstractMap diff --git a/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractSet.kt b/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractSet.kt index 74898483503..35220c7c15b 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractSet.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractSet.kt @@ -1,6 +1,5 @@ // DONT_TARGET_EXACT_BACKEND: WASM // WASM_MUTE_REASON: STDLIB_COLLECTIONS -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // IGNORE_BACKEND: NATIVE class A : HashSet() diff --git a/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/hashMap.kt b/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/hashMap.kt index 24eabb0410c..87117ba74a9 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/hashMap.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/hashMap.kt @@ -1,6 +1,5 @@ // DONT_TARGET_EXACT_BACKEND: WASM // WASM_MUTE_REASON: STDLIB_COLLECTIONS -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // IGNORE_BACKEND: NATIVE class A : HashMap() diff --git a/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/hashSet.kt b/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/hashSet.kt index 74898483503..35220c7c15b 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/hashSet.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/hashSet.kt @@ -1,6 +1,5 @@ // DONT_TARGET_EXACT_BACKEND: WASM // WASM_MUTE_REASON: STDLIB_COLLECTIONS -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // IGNORE_BACKEND: NATIVE class A : HashSet() diff --git a/compiler/testData/codegen/box/casts/mutableCollections/mutabilityMarkerInterfaces.kt b/compiler/testData/codegen/box/casts/mutableCollections/mutabilityMarkerInterfaces.kt index b8bef669c95..743a5f31cc1 100644 --- a/compiler/testData/codegen/box/casts/mutableCollections/mutabilityMarkerInterfaces.kt +++ b/compiler/testData/codegen/box/casts/mutableCollections/mutabilityMarkerInterfaces.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/collections/addCollectionStubWithCovariantOverride.kt b/compiler/testData/codegen/box/collections/addCollectionStubWithCovariantOverride.kt index 06b6217706d..c30c17b2c97 100644 --- a/compiler/testData/codegen/box/collections/addCollectionStubWithCovariantOverride.kt +++ b/compiler/testData/codegen/box/collections/addCollectionStubWithCovariantOverride.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - abstract class AbstractAdd { abstract fun add(s: String): Any } @@ -23,4 +21,4 @@ fun test2(a: AbstractStringCollection) = a.add("K") as String fun box() = - test1(StringCollection()) + test2(StringCollection()) \ No newline at end of file + test1(StringCollection()) + test2(StringCollection()) diff --git a/compiler/testData/codegen/box/collections/javaCollectionWithRemovePrimitiveInt.kt b/compiler/testData/codegen/box/collections/javaCollectionWithRemovePrimitiveInt.kt index 15c4643bd45..7768bd068eb 100644 --- a/compiler/testData/codegen/box/collections/javaCollectionWithRemovePrimitiveInt.kt +++ b/compiler/testData/codegen/box/collections/javaCollectionWithRemovePrimitiveInt.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // FILE: javaCollectionWithRemovePrimitiveInt.kt diff --git a/compiler/testData/codegen/box/specialBuiltins/bridges.kt b/compiler/testData/codegen/box/specialBuiltins/bridges.kt index ebad83489a5..a09f84857e8 100644 --- a/compiler/testData/codegen/box/specialBuiltins/bridges.kt +++ b/compiler/testData/codegen/box/specialBuiltins/bridges.kt @@ -1,6 +1,5 @@ // DONT_TARGET_EXACT_BACKEND: WASM // WASM_MUTE_REASON: STDLIB_COLLECTIONS -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // IGNORE_BACKEND: NATIVE diff --git a/compiler/testData/codegen/box/specialBuiltins/complexMapImpl.kt b/compiler/testData/codegen/box/specialBuiltins/complexMapImpl.kt new file mode 100644 index 00000000000..0dc7fce94a4 --- /dev/null +++ b/compiler/testData/codegen/box/specialBuiltins/complexMapImpl.kt @@ -0,0 +1,131 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME + +// binary representation of fractional part of phi = (sqrt(5) - 1) / 2 +private const val MAGIC: Int = 0x9E3779B9L.toInt() // ((sqrt(5.0) - 1) / 2 * pow(2.0, 32.0)).toLong().toString(16) +private const val MAX_SHIFT = 27 +private const val THRESHOLD = ((1L shl 31) - 1).toInt() // 50% fill factor for speed +private val EMPTY_ARRAY = arrayOf() + + +// For more details see for Knuth's multiplicative hash with golden ratio +// Shortly, we're trying to keep distribution of it uniform independently of input +// It's necessary because we use very simple linear probing +@Suppress("NOTHING_TO_INLINE") +private inline fun Any.computeHash(shift: Int) = ((hashCode() * MAGIC) ushr shift) shl 1 + + +internal class OpenAddressLinearProbingHashTable : AbstractMutableMap() { + // fields be initialized later in `clear()` + + // capacity = 1 << (32 - shift) + private var shift = 0 + // keys are stored in even elements, values are in odd ones + private var array = EMPTY_ARRAY + private var size_ = 0 + + init { + clear() + } + + override val size + get() = size_ + + override fun get(key: K): V? { + var i = key.computeHash(shift) + var k = array[i] + + while (true) { + if (k === null) return null + @Suppress("UNCHECKED_CAST") + if (k == key) return array[i + 1] as V + if (i == 0) { + i = array.size + } + i -= 2 + k = array[i] + } + } + + /** + * Never returns previous values + */ + override fun put(key: K, value: V): V? { + if (put(array, shift, key, value)) { + if (++size_ >= (THRESHOLD ushr shift)) { + rehash() + } + } + + return null + } + + private fun rehash() { + val newShift = maxOf(shift - 3, 0) + val newArraySize = 1 shl (33 - newShift) + val newArray = arrayOfNulls(newArraySize) + + var i = 0 + val arraySize = array.size + while (i < arraySize) { + val key = array[i] + if (key != null) { + put(newArray, newShift, key, array[i + 1]) + } + i += 2 + } + + shift = newShift + array = newArray + } + + override fun clear() { + shift = MAX_SHIFT + array = arrayOfNulls(1 shl (33 - shift)) + + size_ = 0 + } + + override val entries: MutableSet> + get() { + + throw IllegalStateException("OpenAddressLinearProbingHashTable::entries is not supported and hardly will be") + } + + private class Entry(override val key: K, override val value: V) : MutableMap.MutableEntry { + override fun setValue(newValue: V): V = throw UnsupportedOperationException("This Entry is not mutable.") + } + + companion object { + // Change to "true" to be able to see the contents of the map in debugger views + private const val DEBUG = false + } +} + +private fun put(array: Array, aShift: Int, key: Any, value: Any?): Boolean { + var i = key.computeHash(aShift) + + while (true) { + val k = array[i] + if (k == null) { + array[i] = key + array[i + 1] = value + return true + } + if (k == key) break + if (i == 0) { + i = array.size + } + i -= 2 + } + + array[i + 1] = value + + return false +} + +fun box(): String { + val map = OpenAddressLinearProbingHashTable() + map.put("O", "K") + return "O" + map["O"] +} diff --git a/compiler/testData/codegen/box/specialBuiltins/specialBridgeModality.kt b/compiler/testData/codegen/box/specialBuiltins/specialBridgeModality.kt index d19b1e9fced..fa05e9afb2a 100644 --- a/compiler/testData/codegen/box/specialBuiltins/specialBridgeModality.kt +++ b/compiler/testData/codegen/box/specialBuiltins/specialBridgeModality.kt @@ -1,5 +1,4 @@ // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR import java.util.AbstractMap diff --git a/compiler/testData/codegen/box/traits/defaultImplCall.kt b/compiler/testData/codegen/box/traits/defaultImplCall.kt index 6b0eed7c16a..d3ebe55a400 100644 --- a/compiler/testData/codegen/box/traits/defaultImplCall.kt +++ b/compiler/testData/codegen/box/traits/defaultImplCall.kt @@ -1,5 +1,4 @@ // !JVM_DEFAULT_MODE: disable -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // First item on Android is `java.lang.Thread.getStackTrace` diff --git a/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/abstractList.kt b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/abstractList.kt index 58c312ddee0..474ecbc0b74 100644 --- a/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/abstractList.kt +++ b/compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/abstractList.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR abstract class A3 : java.util.AbstractList() abstract class A4 : java.util.AbstractList() { override fun contains(o: W): Boolean { diff --git a/compiler/testData/codegen/bytecodeText/interfaces/traitImplGeneratedOnce.kt b/compiler/testData/codegen/bytecodeText/interfaces/traitImplGeneratedOnce.kt index 0c0c81ce6ac..e308c0d92dc 100644 --- a/compiler/testData/codegen/bytecodeText/interfaces/traitImplGeneratedOnce.kt +++ b/compiler/testData/codegen/bytecodeText/interfaces/traitImplGeneratedOnce.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun foo() = 42 } diff --git a/compiler/testData/codegen/bytecodeText/mapGetOrDefault.kt b/compiler/testData/codegen/bytecodeText/mapGetOrDefault.kt index c8eff9871ee..c954bdaf1b8 100644 --- a/compiler/testData/codegen/bytecodeText/mapGetOrDefault.kt +++ b/compiler/testData/codegen/bytecodeText/mapGetOrDefault.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // JVM_TARGET: 1.8 // WITH_RUNTIME // FULL_JDK @@ -38,4 +37,4 @@ class MyMap: TestMap() // JVM_IR_TEMPLATES: // 1 public bridge getOrDefault\(Ljava/lang/String;Ljava/lang/String;\)Ljava/lang/String; -// 1 public final bridge getOrDefault\(Ljava/lang/Object;Ljava/lang/String;\)Ljava/lang/String; \ No newline at end of file +// 1 public final bridge getOrDefault\(Ljava/lang/Object;Ljava/lang/String;\)Ljava/lang/String; diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index f6cf267f639..9747a653863 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -37768,6 +37768,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/specialBuiltins/commonBridgesTarget.kt"); } + @Test + @TestMetadata("complexMapImpl.kt") + public void testComplexMapImpl() throws Exception { + runTest("compiler/testData/codegen/box/specialBuiltins/complexMapImpl.kt"); + } + @Test @TestMetadata("emptyList.kt") public void testEmptyList() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 45d24688c10..23fb86aa543 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -37768,6 +37768,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/specialBuiltins/commonBridgesTarget.kt"); } + @Test + @TestMetadata("complexMapImpl.kt") + public void testComplexMapImpl() throws Exception { + runTest("compiler/testData/codegen/box/specialBuiltins/complexMapImpl.kt"); + } + @Test @TestMetadata("emptyList.kt") public void testEmptyList() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 1b704cb4793..9be202977b2 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -30208,6 +30208,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/specialBuiltins/commonBridgesTarget.kt"); } + @TestMetadata("complexMapImpl.kt") + public void testComplexMapImpl() throws Exception { + runTest("compiler/testData/codegen/box/specialBuiltins/complexMapImpl.kt"); + } + @TestMetadata("emptyList.kt") public void testEmptyList() throws Exception { runTest("compiler/testData/codegen/box/specialBuiltins/emptyList.kt"); From 377a0aa237beebbddd674d80e6f64c93253c2084 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 17 Feb 2021 17:56:18 +0300 Subject: [PATCH 338/368] FIR2IR: Adjust test data for updated overridden structure --- .../specialBridgesInDependencies.kt | 1 - .../codegen/box/smartCasts/kt44814.fir.txt | 48 ++--- .../classes/annotationClasses.fir.kt.txt | 31 ---- .../irText/classes/annotationClasses.fir.txt | 115 ------------ .../ir/irText/classes/annotationClasses.kt | 1 + ...rderingInDelegatingConstructorCall.fir.txt | 12 +- .../ir/irText/classes/classes.fir.txt | 6 +- .../ir/irText/classes/cloneable.fir.txt | 28 +-- .../delegatedGenericImplementation.fir.kt.txt | 1 - .../delegatedGenericImplementation.fir.txt | 12 +- .../delegatedImplementation.fir.kt.txt | 1 - .../classes/delegatedImplementation.fir.txt | 27 +-- ...edImplementationOfJavaInterface.fir.kt.txt | 1 - ...gatedImplementationOfJavaInterface.fir.txt | 6 +- ...lementationWithExplicitOverride.fir.kt.txt | 1 - ...ImplementationWithExplicitOverride.fir.txt | 12 +- ...structorCallToTypeAliasConstructor.fir.txt | 12 +- ...torCallsInSecondaryConstructors.fir.kt.txt | 27 --- ...ructorCallsInSecondaryConstructors.fir.txt | 48 ----- ...ConstructorCallsInSecondaryConstructors.kt | 1 + .../testData/ir/irText/classes/enum.fir.txt | 42 ++--- .../irText/classes/enumClassModality.fir.txt | 67 ++++--- .../classes/enumWithMultipleCtors.fir.txt | 14 +- .../classes/enumWithSecondaryCtor.fir.txt | 28 +-- .../fakeOverridesForJavaStaticMembers.fir.txt | 6 +- ...otNullOnDelegatedImplementation.fir.kt.txt | 1 - ...itNotNullOnDelegatedImplementation.fir.txt | 60 ++++--- .../ir/irText/classes/innerClass.fir.txt | 6 +- .../ir/irText/classes/kt19306.fir.txt | 6 +- .../ir/irText/classes/kt43217.fir.kt.txt | 1 - .../ir/irText/classes/kt43217.fir.txt | 22 ++- .../classes/objectLiteralExpressions.fir.txt | 28 +-- .../classes/objectWithInitializers.fir.kt.txt | 28 --- .../classes/objectWithInitializers.fir.txt | 65 ------- .../irText/classes/objectWithInitializers.kt | 1 + ...tructorWithSuperConstructorCall.fir.kt.txt | 47 ----- ...onstructorWithSuperConstructorCall.fir.txt | 107 ------------ ...maryConstructorWithSuperConstructorCall.kt | 1 + .../classes/qualifiedSuperCalls.fir.txt | 9 +- .../irText/classes/sealedClasses.fir.kt.txt | 47 ----- .../ir/irText/classes/sealedClasses.fir.txt | 113 ------------ .../ir/irText/classes/sealedClasses.kt | 1 + ...orWithInitializersFromClassBody.fir.kt.txt | 47 ----- ...uctorWithInitializersFromClassBody.fir.txt | 92 ---------- ...onstructorWithInitializersFromClassBody.kt | 1 + .../ir/irText/classes/superCalls.fir.txt | 4 +- .../irText/classes/superCallsComposed.fir.txt | 9 +- ...nnotationsInAnnotationArguments.fir.kt.txt | 28 --- .../annotationsInAnnotationArguments.fir.txt | 90 ---------- .../annotationsInAnnotationArguments.kt | 1 + .../annotationsOnDelegatedMembers.fir.kt.txt | 1 - .../annotationsOnDelegatedMembers.fir.txt | 12 +- ...tionsWithDefaultParameterValues.fir.kt.txt | 31 ---- ...otationsWithDefaultParameterValues.fir.txt | 65 ------- .../annotationsWithDefaultParameterValues.kt | 1 + ...annotationsWithVarargParameters.fir.kt.txt | 19 -- .../annotationsWithVarargParameters.fir.txt | 41 ----- .../annotationsWithVarargParameters.kt | 1 + .../arrayInAnnotationArguments.fir.kt.txt | 25 --- .../arrayInAnnotationArguments.fir.txt | 67 ------- .../annotations/arrayInAnnotationArguments.kt | 1 + .../classLiteralInAnnotation.fir.kt.txt | 20 --- .../classLiteralInAnnotation.fir.txt | 52 ------ .../annotations/classLiteralInAnnotation.kt | 1 + .../classesWithAnnotations.fir.txt | 12 +- ...xpressionsInAnnotationArguments.fir.kt.txt | 19 -- ...stExpressionsInAnnotationArguments.fir.txt | 46 ----- .../constExpressionsInAnnotationArguments.kt | 1 + .../constructorsWithAnnotations.fir.kt.txt | 22 --- .../constructorsWithAnnotations.fir.txt | 56 ------ .../constructorsWithAnnotations.kt | 1 + .../delegateFieldWithAnnotations.fir.kt.txt | 13 -- .../delegateFieldWithAnnotations.fir.txt | 38 ---- .../delegateFieldWithAnnotations.kt | 1 + ...edPropertyAccessorsWithAnnotations.fir.txt | 6 +- .../enumEntriesWithAnnotations.fir.txt | 20 +-- .../enumsInAnnotationArguments.fir.txt | 6 +- .../fieldsWithAnnotations.fir.kt.txt | 16 -- .../annotations/fieldsWithAnnotations.fir.txt | 57 ------ .../annotations/fieldsWithAnnotations.kt | 1 + .../annotations/fileAnnotations.fir.kt.txt | 11 -- .../annotations/fileAnnotations.fir.txt | 33 ---- .../annotations/fileAnnotations.kt | 1 + .../functionsWithAnnotations.fir.kt.txt | 11 -- .../functionsWithAnnotations.fir.txt | 33 ---- .../annotations/functionsWithAnnotations.kt | 1 + .../inheritingDeprecation.fir.kt.txt | 1 - .../annotations/inheritingDeprecation.fir.txt | 22 ++- ...DelegatedPropertiesWithAnnotations.fir.txt | 6 +- ...ipleAnnotationsInSquareBrackets.fir.kt.txt | 20 --- ...ultipleAnnotationsInSquareBrackets.fir.txt | 55 ------ .../multipleAnnotationsInSquareBrackets.kt | 1 + ...tructorParameterWithAnnotations.fir.kt.txt | 17 -- ...onstructorParameterWithAnnotations.fir.txt | 50 ------ ...maryConstructorParameterWithAnnotations.kt | 1 + .../propertiesWithAnnotations.fir.kt.txt | 12 -- .../propertiesWithAnnotations.fir.txt | 40 ----- .../annotations/propertiesWithAnnotations.kt | 1 + ...sFromClassHeaderWithAnnotations.fir.kt.txt | 28 --- ...sorsFromClassHeaderWithAnnotations.fir.txt | 86 --------- ...AccessorsFromClassHeaderWithAnnotations.kt | 1 + ...ropertyAccessorsWithAnnotations.fir.kt.txt | 34 ---- .../propertyAccessorsWithAnnotations.fir.txt | 81 --------- .../propertyAccessorsWithAnnotations.kt | 1 + ...ySetterParameterWithAnnotations.fir.kt.txt | 23 --- ...ertySetterParameterWithAnnotations.fir.txt | 75 -------- .../propertySetterParameterWithAnnotations.kt | 1 + .../receiverParameterWithAnnotations.fir.txt | 6 +- ...preadOperatorInAnnotationArguments.fir.txt | 6 +- .../typeAliasesWithAnnotations.fir.txt | 6 +- .../typeParametersWithAnnotations.fir.txt | 6 +- .../valueParametersWithAnnotations.fir.kt.txt | 23 --- .../valueParametersWithAnnotations.fir.txt | 67 ------- .../valueParametersWithAnnotations.kt | 1 + .../varargsInAnnotationArguments.fir.kt.txt | 35 ---- .../varargsInAnnotationArguments.fir.txt | 97 ---------- .../varargsInAnnotationArguments.kt | 1 + .../variablesWithAnnotations.fir.txt | 6 +- .../irText/declarations/fakeOverrides.fir.txt | 12 +- .../inlineCollectionOfInlineClass.fir.txt | 6 +- .../ir/irText/declarations/kt35550.fir.kt.txt | 1 - .../ir/irText/declarations/kt35550.fir.txt | 6 +- .../localClassWithOverrides.fir.txt | 6 +- .../expectClassInherited.fir.txt | 12 +- .../multiplatform/expectedSealedClass.fir.txt | 12 +- .../parameters/delegatedMembers.fir.kt.txt | 1 - .../parameters/delegatedMembers.fir.txt | 6 +- .../typeParameterBoundedBySubclass.fir.kt.txt | 38 ---- .../typeParameterBoundedBySubclass.fir.txt | 90 ---------- .../typeParameterBoundedBySubclass.kt | 1 + .../caoWithAdaptationForSam.fir.kt.txt | 1 - .../caoWithAdaptationForSam.fir.txt | 6 +- ...ericLocalClassConstructorReference.fir.txt | 12 +- ...emberReferenceWithAdaptedArguments.fir.txt | 6 +- .../expressions/enumEntryAsReceiver.fir.txt | 14 +- ...umEntryReferenceFromEnumEntryClass.fir.txt | 14 +- .../funInterface/partialSam.fir.txt | 12 +- ...ieldReferenceWithIntersectionTypes.fir.txt | 42 +++-- .../jvmInstanceFieldReference.fir.txt | 6 +- .../ir/irText/expressions/kt16904.fir.txt | 12 +- .../ir/irText/expressions/kt16905.fir.txt | 12 +- .../ir/irText/expressions/kt30020.fir.txt | 18 +- .../ir/irText/expressions/kt35730.fir.txt | 6 +- .../multipleThisReferences.fir.txt | 6 +- .../objectByNameInsideObject.fir.kt.txt | 32 ---- .../objectByNameInsideObject.fir.txt | 72 -------- .../expressions/objectByNameInsideObject.kt | 1 + ...InClosureInSuperConstructorCall.fir.kt.txt | 24 --- ...nceInClosureInSuperConstructorCall.fir.txt | 62 ------- ...eferenceInClosureInSuperConstructorCall.kt | 1 + .../setFieldWithImplicitCast.fir.txt | 6 +- .../signedToUnsignedConversions.fir.txt | 6 +- .../thisOfGenericOuterClass.fir.txt | 6 +- ...ectInNestedClassConstructorCall.fir.kt.txt | 39 ----- ...ObjectInNestedClassConstructorCall.fir.txt | 103 ----------- ...RefToObjectInNestedClassConstructorCall.kt | 1 + .../thisReferenceBeforeClassDeclared.fir.txt | 12 +- .../expressions/useImportedMember.fir.txt | 9 +- .../firProblems/AbstractMutableMap.fir.txt | 106 +++++------ .../AnnotationInAnnotation.fir.kt.txt | 29 --- .../AnnotationInAnnotation.fir.txt | 90 ---------- .../firProblems/AnnotationInAnnotation.kt | 1 + .../firProblems/AnnotationLoader.fir.txt | 18 +- .../ClashResolutionDescriptor.fir.txt | 2 +- .../irText/firProblems/DeepCopyIrTree.fir.txt | 15 +- ...elegationAndInheritanceFromJava.fir.kt.txt | 1 - .../DelegationAndInheritanceFromJava.fir.txt | 34 ++-- .../Fir2IrClassifierStorage.fir.txt | 12 +- .../irText/firProblems/FirBuilder.fir.kt.txt | 1 - .../ir/irText/firProblems/FirBuilder.fir.txt | 14 +- .../firProblems/ImplicitReceiverStack.fir.txt | 17 +- .../firProblems/InnerClassInAnonymous.fir.txt | 6 +- .../ir/irText/firProblems/Modality.fir.kt.txt | 1 - .../ir/irText/firProblems/Modality.fir.txt | 12 +- .../ir/irText/firProblems/MultiList.fir.txt | 165 ++++++++---------- .../firProblems/SignatureClash.fir.kt.txt | 1 - .../irText/firProblems/SignatureClash.fir.txt | 12 +- .../firProblems/SimpleTypeMarker.fir.kt.txt | 39 ----- .../firProblems/SimpleTypeMarker.fir.txt | 96 ---------- .../ir/irText/firProblems/SimpleTypeMarker.kt | 1 + .../firProblems/candidateSymbol.fir.txt | 9 +- .../ir/irText/firProblems/kt19251.fir.txt | 2 +- .../ir/irText/firProblems/kt43342.fir.txt | 9 +- .../ir/irText/firProblems/putIfAbsent.fir.txt | 2 +- .../firProblems/readWriteProperty.fir.txt | 6 +- .../typeVariableAfterBuildMap.fir.txt | 54 +++--- .../regressions/integerCoercionToT.fir.txt | 12 +- .../ir/irText/singletons/enumEntry.fir.txt | 14 +- .../genericClassInDifferentModule.fir.txt | 6 +- .../ir/irText/stubs/javaInnerClass.fir.txt | 6 +- .../castsInsideCoroutineInference.fir.txt | 15 +- .../genericDelegatedDeepProperty.fir.txt | 24 +-- .../irText/types/genericFunWithStar.fir.txt | 21 ++- .../irText/types/intersectionType2_NI.fir.txt | 18 +- .../irText/types/intersectionType2_OI.fir.txt | 18 +- .../irText/types/intersectionType3_NI.fir.txt | 30 ++-- .../irText/types/intersectionType3_OI.fir.txt | 30 ++-- .../irText/types/javaWildcardType.fir.kt.txt | 1 - .../ir/irText/types/javaWildcardType.fir.txt | 9 +- .../types/rawTypeInSignature.fir.kt.txt | 1 - .../irText/types/rawTypeInSignature.fir.txt | 6 +- .../types/receiverOfIntersectionType.fir.txt | 30 ++-- .../smartCastOnFakeOverrideReceiver.fir.txt | 12 +- 203 files changed, 856 insertions(+), 3799 deletions(-) delete mode 100644 compiler/testData/ir/irText/classes/annotationClasses.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/classes/annotationClasses.fir.txt delete mode 100644 compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.txt delete mode 100644 compiler/testData/ir/irText/classes/objectWithInitializers.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/classes/objectWithInitializers.fir.txt delete mode 100644 compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.fir.txt delete mode 100644 compiler/testData/ir/irText/classes/sealedClasses.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/classes/sealedClasses.fir.txt delete mode 100644 compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/fileAnnotations.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/fileAnnotations.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.fir.txt delete mode 100644 compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.txt delete mode 100644 compiler/testData/ir/irText/expressions/objectByNameInsideObject.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/expressions/objectByNameInsideObject.fir.txt delete mode 100644 compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.fir.txt delete mode 100644 compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.txt delete mode 100644 compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.fir.txt delete mode 100644 compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.txt diff --git a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/specialBridgesInDependencies.kt b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/specialBridgesInDependencies.kt index c4da7c0d992..052d420492b 100644 --- a/compiler/testData/codegen/box/compileKotlinAgainstKotlin/specialBridgesInDependencies.kt +++ b/compiler/testData/codegen/box/compileKotlinAgainstKotlin/specialBridgesInDependencies.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // MODULE: lib // FILE: A.kt diff --git a/compiler/testData/codegen/box/smartCasts/kt44814.fir.txt b/compiler/testData/codegen/box/smartCasts/kt44814.fir.txt index 3a7a063cd9d..86950d654bf 100644 --- a/compiler/testData/codegen/box/smartCasts/kt44814.fir.txt +++ b/compiler/testData/codegen/box/smartCasts/kt44814.fir.txt @@ -93,16 +93,16 @@ FILE fqName: fileName:/kt44814.kt receiver: GET_VAR ': .FirPsiSourceElement declared in .FirPsiSourceElement.' type=.FirPsiSourceElement origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .FirSourceElement $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .FirSourceElement $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .FirSourceElement $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:FirLightSourceElement modality:FINAL visibility:public superTypes:[.FirSourceElement] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirLightSourceElement @@ -140,16 +140,16 @@ FILE fqName: fileName:/kt44814.kt receiver: GET_VAR ': .FirLightSourceElement declared in .FirLightSourceElement.' type=.FirLightSourceElement origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .FirSourceElement $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .FirSourceElement $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .FirSourceElement $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:PsiElement modality:OPEN visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.PsiElement @@ -318,16 +318,16 @@ FILE fqName: fileName:/kt44814.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:KtModifierList modality:FINAL visibility:public superTypes:[.PsiElement]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .PsiElement $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .PsiElement $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .PsiElement $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:KtModifierListOwner modality:FINAL visibility:public superTypes:[.PsiElement] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KtModifierListOwner @@ -348,16 +348,16 @@ FILE fqName: fileName:/kt44814.kt receiver: GET_VAR ': .KtModifierListOwner declared in .KtModifierListOwner.' type=.KtModifierListOwner origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .PsiElement $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .PsiElement $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .PsiElement $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:FirModifier modality:SEALED visibility:internal superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirModifier.FirModifier> @@ -415,16 +415,16 @@ FILE fqName: fileName:/kt44814.kt $this: VALUE_PARAMETER name: type:.FirModifier.FirModifier> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .FirModifier $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .FirModifier $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .FirModifier $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:FirLightModifier modality:FINAL visibility:public superTypes:[.FirModifier<.LighterASTNode>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirModifier.FirLightModifier @@ -463,16 +463,16 @@ FILE fqName: fileName:/kt44814.kt $this: VALUE_PARAMETER name: type:.FirModifier.FirModifier> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .FirModifier $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .FirModifier $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .FirModifier $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -531,16 +531,16 @@ FILE fqName: fileName:/kt44814.kt $this: VALUE_PARAMETER name: type:.FirModifierList FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .FirModifierList $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .FirModifierList $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .FirModifierList $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:FirLightModifierList modality:FINAL visibility:public superTypes:[.FirModifierList] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirModifierList.FirLightModifierList @@ -580,16 +580,16 @@ FILE fqName: fileName:/kt44814.kt $this: VALUE_PARAMETER name: type:.FirModifierList FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .FirModifierList $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .FirModifierList $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .FirModifierList $this: VALUE_PARAMETER name: type:kotlin.Any CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FirModifierList.Companion diff --git a/compiler/testData/ir/irText/classes/annotationClasses.fir.kt.txt b/compiler/testData/ir/irText/classes/annotationClasses.fir.kt.txt deleted file mode 100644 index d6e3ed1c3ef..00000000000 --- a/compiler/testData/ir/irText/classes/annotationClasses.fir.kt.txt +++ /dev/null @@ -1,31 +0,0 @@ -annotation class Test1 : Annotation { - constructor(x: Int) /* primary */ - val x: Int - field = x - get - -} - -annotation class Test2 : Annotation { - constructor(x: Int = 0) /* primary */ - val x: Int - field = x - get - -} - -annotation class Test3 : Annotation { - constructor(x: Test1) /* primary */ - val x: Test1 - field = x - get - -} - -annotation class Test4 : Annotation { - constructor(vararg xs: Int) /* primary */ - val xs: IntArray - field = xs - get - -} diff --git a/compiler/testData/ir/irText/classes/annotationClasses.fir.txt b/compiler/testData/ir/irText/classes/annotationClasses.fir.txt deleted file mode 100644 index dbedffd8016..00000000000 --- a/compiler/testData/ir/irText/classes/annotationClasses.fir.txt +++ /dev/null @@ -1,115 +0,0 @@ -FILE fqName: fileName:/annotationClasses.kt - CLASS ANNOTATION_CLASS name:Test1 modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test1 - CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:.Test1 [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Int - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Int declared in .Test1.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.Int - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Test1 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Test1' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .Test1 declared in .Test1.' type=.Test1 origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ANNOTATION_CLASS name:Test2 modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test2 - CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:.Test2 [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Int - EXPRESSION_BODY - CONST Int type=kotlin.Int value=0 - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Int declared in .Test2.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test2) returnType:kotlin.Int - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Test2 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Test2' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ANNOTATION_CLASS name:Test3 modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test3 - CONSTRUCTOR visibility:public <> (x:.Test1) returnType:.Test3 [primary] - VALUE_PARAMETER name:x index:0 type:.Test1 - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:.Test1 visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: .Test1 declared in .Test3.' type=.Test1 origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test3) returnType:.Test1 - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Test3 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): .Test1 declared in .Test3' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:.Test1 visibility:private [final]' type=.Test1 origin=null - receiver: GET_VAR ': .Test3 declared in .Test3.' type=.Test3 origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ANNOTATION_CLASS name:Test4 modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test4 - CONSTRUCTOR visibility:public <> (xs:kotlin.IntArray) returnType:.Test4 [primary] - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - PROPERTY name:xs visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.IntArray visibility:private [final] - EXPRESSION_BODY - GET_VAR 'xs: kotlin.IntArray [vararg] declared in .Test4.' type=kotlin.IntArray origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test4) returnType:kotlin.IntArray - correspondingProperty: PROPERTY name:xs visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Test4 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.IntArray declared in .Test4' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.IntArray visibility:private [final]' type=kotlin.IntArray origin=null - receiver: GET_VAR ': .Test4 declared in .Test4.' type=.Test4 origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/annotationClasses.kt b/compiler/testData/ir/irText/classes/annotationClasses.kt index ebcb48a4829..006fbbb26d2 100644 --- a/compiler/testData/ir/irText/classes/annotationClasses.kt +++ b/compiler/testData/ir/irText/classes/annotationClasses.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class Test1(val x: Int) annotation class Test2(val x: Int = 0) diff --git a/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.fir.txt b/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.fir.txt index f1ac04f0cda..5478d994d4a 100644 --- a/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.fir.txt +++ b/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.fir.txt @@ -67,16 +67,16 @@ FILE fqName: fileName:/argumentReorderingInDelegatingConstructorCall.kt $this: VALUE_PARAMETER name: type:.Base FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.Base] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test2 @@ -112,14 +112,14 @@ FILE fqName: fileName:/argumentReorderingInDelegatingConstructorCall.kt $this: VALUE_PARAMETER name: type:.Base FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/classes.fir.txt b/compiler/testData/ir/irText/classes/classes.fir.txt index 2fc797d5660..8293bfe4f20 100644 --- a/compiler/testData/ir/irText/classes/classes.fir.txt +++ b/compiler/testData/ir/irText/classes/classes.fir.txt @@ -57,16 +57,16 @@ FILE fqName: fileName:/classes.kt CONSTRUCTOR visibility:public <> () returnType:.TestAnnotationClass [primary] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any CLASS ENUM_CLASS name:TestEnumClass modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnumClass>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnumClass diff --git a/compiler/testData/ir/irText/classes/cloneable.fir.txt b/compiler/testData/ir/irText/classes/cloneable.fir.txt index 1e1f2c778b5..622026dbc3c 100644 --- a/compiler/testData/ir/irText/classes/cloneable.fir.txt +++ b/compiler/testData/ir/irText/classes/cloneable.fir.txt @@ -11,16 +11,16 @@ FILE fqName: fileName:/cloneable.kt $this: VALUE_PARAMETER name: type:kotlin.Cloneable FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Cloneable $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Cloneable $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Cloneable $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Cloneable] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.I @@ -30,16 +30,16 @@ FILE fqName: fileName:/cloneable.kt $this: VALUE_PARAMETER name: type:kotlin.Cloneable FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Cloneable $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Cloneable $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Cloneable $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.I] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C @@ -49,20 +49,20 @@ FILE fqName: fileName:/cloneable.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.I]' FUN FAKE_OVERRIDE name:clone visibility:protected modality:OPEN <> ($this:kotlin.Cloneable) returnType:kotlin.Any [fake_override] overridden: - protected open fun clone (): kotlin.Any declared in kotlin.Cloneable + protected open fun clone (): kotlin.Any [fake_override] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Cloneable FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:OC modality:FINAL visibility:public superTypes:[.I] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.OC @@ -72,21 +72,21 @@ FILE fqName: fileName:/cloneable.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:OC modality:FINAL visibility:public superTypes:[.I]' FUN name:clone visibility:protected modality:FINAL <> ($this:.OC) returnType:.OC overridden: - protected open fun clone (): kotlin.Any declared in kotlin.Cloneable + protected open fun clone (): kotlin.Any [fake_override] declared in .I $this: VALUE_PARAMETER name: type:.OC BLOCK_BODY RETURN type=kotlin.Nothing from='protected final fun clone (): .OC declared in .OC' CONSTRUCTOR_CALL 'public constructor () [primary] declared in .OC' type=.OC origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt index 73650a6c7c9..9f16438211d 100644 --- a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt @@ -68,4 +68,3 @@ class Test2 : IBase { set } - diff --git a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.txt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.txt index 0cb00f8c810..f76947455fd 100644 --- a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.txt +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.txt @@ -110,16 +110,16 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt GET_VAR 'i: .IBase.Test1> declared in .Test1.' type=.IBase.Test1> origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.IBase] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test2 @@ -211,14 +211,14 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt value: GET_VAR ': .IBase declared in .Test2.' type=.IBase origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/delegatedImplementation.fir.kt.txt b/compiler/testData/ir/irText/classes/delegatedImplementation.fir.kt.txt index 32d05a7406b..c1ee102d667 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementation.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementation.fir.kt.txt @@ -149,4 +149,3 @@ class Test2 : IBase, IOther { local /* final field */ val <$$delegate_1>: IOther = otherImpl(x0 = "", y0 = 42) } - diff --git a/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt b/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt index 747f419f513..55f4ba84ea4 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementation.fir.txt @@ -51,16 +51,16 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:IOther modality:ABSTRACT visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IOther @@ -182,16 +182,16 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IOther $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IOther $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IOther $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .otherImpl.' type=.otherImpl. origin=OBJECT_LITERAL CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[.IBase] @@ -236,16 +236,16 @@ FILE fqName: fileName:/delegatedImplementation.kt GET_OBJECT 'CLASS OBJECT name:BaseImpl modality:FINAL visibility:public superTypes:[.IBase]' type=.BaseImpl FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.IBase; .IOther] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test2 @@ -366,14 +366,17 @@ FILE fqName: fileName:/delegatedImplementation.kt y0: CONST Int type=kotlin.Int value=42 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IBase + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IOther $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IBase + public open fun hashCode (): kotlin.Int [fake_override] declared in .IOther $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IBase + public open fun toString (): kotlin.String [fake_override] declared in .IOther $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.kt.txt b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.kt.txt index fb36d5785c8..9dbc002b18e 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.kt.txt @@ -37,4 +37,3 @@ class Test : J { private get } - diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.txt b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.txt index 5cd15a79d17..105e2ee38fb 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.txt @@ -83,14 +83,14 @@ FILE fqName: fileName:/delegatedImplementationOfJavaInterface.kt receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.kt.txt b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.kt.txt index 0c91c731dfd..6958dbd5e25 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.kt.txt @@ -35,4 +35,3 @@ class C : IFooBar { } } - diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt index 96935a1c251..17a7770f373 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.fir.txt @@ -36,16 +36,16 @@ FILE fqName: fileName:/delegatedImplementationWithExplicitOverride.kt BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFooBar $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFooBar $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFooBar $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.IFooBar] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C @@ -71,14 +71,14 @@ FILE fqName: fileName:/delegatedImplementationWithExplicitOverride.kt BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFooBar $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFooBar $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFooBar $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/delegatingConstructorCallToTypeAliasConstructor.fir.txt b/compiler/testData/ir/irText/classes/delegatingConstructorCallToTypeAliasConstructor.fir.txt index a7a00fa27f3..693f321d8cc 100644 --- a/compiler/testData/ir/irText/classes/delegatingConstructorCallToTypeAliasConstructor.fir.txt +++ b/compiler/testData/ir/irText/classes/delegatingConstructorCallToTypeAliasConstructor.fir.txt @@ -50,16 +50,16 @@ FILE fqName: fileName:/delegatingConstructorCallToTypeAliasConstructor.kt $this: VALUE_PARAMETER name: type:.Cell.Cell> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Cell $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Cell $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Cell $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:C2 modality:FINAL visibility:public superTypes:[.Cell] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C2 @@ -77,14 +77,14 @@ FILE fqName: fileName:/delegatingConstructorCallToTypeAliasConstructor.kt $this: VALUE_PARAMETER name: type:.Cell.Cell> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Cell $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Cell $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Cell $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.kt.txt b/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.kt.txt deleted file mode 100644 index 4aa34fe4a53..00000000000 --- a/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.kt.txt +++ /dev/null @@ -1,27 +0,0 @@ -open class Base { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - -} - -class Test : Base { - constructor() { - super/*Base*/() - /* () */ - - } - - constructor(xx: Int) { - super/*Base*/() - /* () */ - - } - - constructor(xx: Short) { - this/*Test*/() - } - -} diff --git a/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.txt b/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.txt deleted file mode 100644 index adb2b637ce8..00000000000 --- a/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.fir.txt +++ /dev/null @@ -1,48 +0,0 @@ -FILE fqName: fileName:/delegatingConstructorCallsInSecondaryConstructors.kt - CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base - CONSTRUCTOR visibility:public <> () returnType:.Base [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.Base] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test - CONSTRUCTOR visibility:public <> () returnType:.Test - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.Base]' - CONSTRUCTOR visibility:public <> (xx:kotlin.Int) returnType:.Test - VALUE_PARAMETER name:xx index:0 type:kotlin.Int - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.Base]' - CONSTRUCTOR visibility:public <> (xx:kotlin.Short) returnType:.Test - VALUE_PARAMETER name:xx index:0 type:kotlin.Short - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .Test' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.kt b/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.kt index 3ac39d297bd..585782dcb56 100644 --- a/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.kt +++ b/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL open class Base class Test : Base { diff --git a/compiler/testData/ir/irText/classes/enum.fir.txt b/compiler/testData/ir/irText/classes/enum.fir.txt index b6d1571880c..fe08f1dad00 100644 --- a/compiler/testData/ir/irText/classes/enum.fir.txt +++ b/compiler/testData/ir/irText/classes/enum.fir.txt @@ -146,37 +146,37 @@ FILE fqName: fileName:/enum.kt message: CONST String type=kotlin.String value="Hello, world!" FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .TestEnum3 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.TestEnum3) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .TestEnum3): kotlin.Int [fake_override,operator] declared in .TestEnum3 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.TestEnum3 FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .TestEnum3 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .TestEnum3 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .TestEnum3 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .TestEnum3 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .TestEnum3 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN name:foo visibility:public modality:ABSTRACT <> ($this:.TestEnum3) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.TestEnum3 @@ -263,37 +263,37 @@ FILE fqName: fileName:/enum.kt $this: VALUE_PARAMETER name: type:.TestEnum4 FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.TestEnum4) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .TestEnum4): kotlin.Int [fake_override,operator] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.TestEnum4 FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum ENUM_ENTRY name:TEST2 init: EXPRESSION_BODY @@ -335,37 +335,37 @@ FILE fqName: fileName:/enum.kt $this: VALUE_PARAMETER name: type:.TestEnum4 FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.TestEnum4) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .TestEnum4): kotlin.Int [fake_override,operator] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.TestEnum4 FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .TestEnum4 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN name:foo visibility:public modality:ABSTRACT <> ($this:.TestEnum4) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.TestEnum4 diff --git a/compiler/testData/ir/irText/classes/enumClassModality.fir.txt b/compiler/testData/ir/irText/classes/enumClassModality.fir.txt index 24d6924a6bc..a2025cff398 100644 --- a/compiler/testData/ir/irText/classes/enumClassModality.fir.txt +++ b/compiler/testData/ir/irText/classes/enumClassModality.fir.txt @@ -180,40 +180,40 @@ FILE fqName: fileName:/enumClassModality.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:private superTypes:[.TestOpenEnum1]' FUN name:toString visibility:public modality:FINAL <> ($this:.TestOpenEnum1.X1) returnType:kotlin.String overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .TestOpenEnum1 $this: VALUE_PARAMETER name: type:.TestOpenEnum1.X1 BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun toString (): kotlin.String declared in .TestOpenEnum1.X1' CONST String type=kotlin.String value="X1" FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .TestOpenEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.TestOpenEnum1) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .TestOpenEnum1): kotlin.Int [fake_override,operator] declared in .TestOpenEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.TestOpenEnum1 FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .TestOpenEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .TestOpenEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .TestOpenEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .TestOpenEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<.TestOpenEnum1> SYNTHETIC_BODY kind=ENUM_VALUES @@ -277,37 +277,37 @@ FILE fqName: fileName:/enumClassModality.kt BLOCK_BODY FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .TestOpenEnum2 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.TestOpenEnum2) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .TestOpenEnum2): kotlin.Int [fake_override,operator] declared in .TestOpenEnum2 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.TestOpenEnum2 FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .TestOpenEnum2 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .TestOpenEnum2 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .TestOpenEnum2 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .TestOpenEnum2 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .TestOpenEnum2 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN name:foo visibility:public modality:OPEN <> ($this:.TestOpenEnum2) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.TestOpenEnum2 @@ -374,37 +374,37 @@ FILE fqName: fileName:/enumClassModality.kt BLOCK_BODY FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .TestAbstractEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.TestAbstractEnum1) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .TestAbstractEnum1): kotlin.Int [fake_override,operator] declared in .TestAbstractEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.TestAbstractEnum1 FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .TestAbstractEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .TestAbstractEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .TestAbstractEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .TestAbstractEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .TestAbstractEnum1 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN name:foo visibility:public modality:ABSTRACT <> ($this:.TestAbstractEnum1) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.TestAbstractEnum1 @@ -482,45 +482,42 @@ FILE fqName: fileName:/enumClassModality.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:private superTypes:[.TestAbstractEnum2]' FUN name:foo visibility:public modality:FINAL <> ($this:.TestAbstractEnum2.X1) returnType:kotlin.Unit overridden: - public abstract fun foo (): kotlin.Unit declared in .IFoo + public abstract fun foo (): kotlin.Unit [fake_override] declared in .TestAbstractEnum2 $this: VALUE_PARAMETER name: type:.TestAbstractEnum2.X1 BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .TestAbstractEnum2 $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .TestAbstractEnum2 $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .TestAbstractEnum2 $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .TestAbstractEnum2 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.TestAbstractEnum2) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .TestAbstractEnum2): kotlin.Int [fake_override,operator] declared in .TestAbstractEnum2 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.TestAbstractEnum2 PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .TestAbstractEnum2 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .TestAbstractEnum2 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<.TestAbstractEnum2> SYNTHETIC_BODY kind=ENUM_VALUES @@ -533,18 +530,18 @@ FILE fqName: fileName:/enumClassModality.kt $this: VALUE_PARAMETER name: type:.IFoo FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo public final fun hashCode (): kotlin.Int declared in kotlin.Enum $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo public open fun toString (): kotlin.String declared in kotlin.Enum $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] diff --git a/compiler/testData/ir/irText/classes/enumWithMultipleCtors.fir.txt b/compiler/testData/ir/irText/classes/enumWithMultipleCtors.fir.txt index cef61fee30f..0ec5904d398 100644 --- a/compiler/testData/ir/irText/classes/enumWithMultipleCtors.fir.txt +++ b/compiler/testData/ir/irText/classes/enumWithMultipleCtors.fir.txt @@ -50,37 +50,37 @@ FILE fqName: fileName:/enumWithMultipleCtors.kt VALUE_PARAMETER name: index:0 type:kotlin.String FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.A) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .A): kotlin.Int [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.A FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Enum ENUM_ENTRY name:Z init: EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt b/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt index 62e56bc6984..b0c54a52978 100644 --- a/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt +++ b/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt @@ -176,37 +176,37 @@ FILE fqName: fileName:/enumWithSecondaryCtor.kt $this: VALUE_PARAMETER name: type:.Test2 FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.Test2) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .Test2): kotlin.Int [fake_override,operator] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.Test2 FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum ENUM_ENTRY name:ONE init: EXPRESSION_BODY @@ -233,37 +233,37 @@ FILE fqName: fileName:/enumWithSecondaryCtor.kt $this: VALUE_PARAMETER name: type:.Test2 FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.Test2) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .Test2): kotlin.Int [fake_override,operator] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.Test2 FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .Test2 $this: VALUE_PARAMETER name: type:kotlin.Enum CONSTRUCTOR visibility:private <> () returnType:.Test2 BLOCK_BODY diff --git a/compiler/testData/ir/irText/classes/fakeOverridesForJavaStaticMembers.fir.txt b/compiler/testData/ir/irText/classes/fakeOverridesForJavaStaticMembers.fir.txt index d287a433f45..152facfd184 100644 --- a/compiler/testData/ir/irText/classes/fakeOverridesForJavaStaticMembers.fir.txt +++ b/compiler/testData/ir/irText/classes/fakeOverridesForJavaStaticMembers.fir.txt @@ -7,14 +7,14 @@ FILE fqName: fileName:/fakeOverridesForJavaStaticMembers.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[a.Base]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in a.Base $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in a.Base $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in a.Base $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.kt.txt b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.kt.txt index f6da264d0a5..229572c961a 100644 --- a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.kt.txt @@ -121,4 +121,3 @@ class TestK4 : IFoo { local /* final field */ val <$$delegate_0>: IFoo = K4() } - diff --git a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.txt b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.txt index da87507f689..54fc55c0915 100644 --- a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.txt +++ b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.fir.txt @@ -28,16 +28,16 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt $this: VALUE_PARAMETER name: type:.JFoo FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .JFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .JFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .JFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:K2 modality:FINAL visibility:public superTypes:[.JFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K2 @@ -55,16 +55,16 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt $this: GET_VAR ': .K2 declared in .K2.foo' type=.K2 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .JFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .JFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .JFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:K3 modality:FINAL visibility:public superTypes:[.JUnrelatedFoo; .IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K3 @@ -79,16 +79,19 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt $this: VALUE_PARAMETER name: type:.IFoo FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .JUnrelatedFoo + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .JUnrelatedFoo + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .JUnrelatedFoo + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:K4 modality:FINAL visibility:public superTypes:[.JUnrelatedFoo; .IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K4 @@ -107,16 +110,19 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt $this: GET_VAR ': .K4 declared in .K4.foo' type=.K4 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .JUnrelatedFoo + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .JUnrelatedFoo + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .JUnrelatedFoo + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:TestJFoo modality:FINAL visibility:public superTypes:[.IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestJFoo @@ -138,16 +144,16 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JFoo' type=.JFoo origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:TestK1 modality:FINAL visibility:public superTypes:[.IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK1 @@ -169,16 +175,16 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K1' type=.K1 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:TestK2 modality:FINAL visibility:public superTypes:[.IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK2 @@ -200,16 +206,16 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K2' type=.K2 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:TestK3 modality:FINAL visibility:public superTypes:[.IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK3 @@ -231,16 +237,16 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K3' type=.K3 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:TestK4 modality:FINAL visibility:public superTypes:[.IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestK4 @@ -262,14 +268,14 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K4' type=.K4 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/innerClass.fir.txt b/compiler/testData/ir/irText/classes/innerClass.fir.txt index 6f730652ab5..0e0739bd678 100644 --- a/compiler/testData/ir/irText/classes/innerClass.fir.txt +++ b/compiler/testData/ir/irText/classes/innerClass.fir.txt @@ -35,16 +35,16 @@ FILE fqName: fileName:/innerClass.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DerivedInnerClass modality:FINAL visibility:public [inner] superTypes:[.Outer.TestInnerClass]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Outer.TestInnerClass $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Outer.TestInnerClass $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Outer.TestInnerClass $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/classes/kt19306.fir.txt b/compiler/testData/ir/irText/classes/kt19306.fir.txt index 0720e5c09c4..8e7d13f4ed2 100644 --- a/compiler/testData/ir/irText/classes/kt19306.fir.txt +++ b/compiler/testData/ir/irText/classes/kt19306.fir.txt @@ -62,14 +62,14 @@ FILE fqName:test2 fileName:/kt19306_test2.kt $this: VALUE_PARAMETER name: type:test1.A FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in test1.A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in test1.A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in test1.A $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/kt43217.fir.kt.txt b/compiler/testData/ir/irText/classes/kt43217.fir.kt.txt index 867a43b41d9..239b95026ed 100644 --- a/compiler/testData/ir/irText/classes/kt43217.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/kt43217.fir.kt.txt @@ -38,4 +38,3 @@ class C : DoubleExpression { } } - diff --git a/compiler/testData/ir/irText/classes/kt43217.fir.txt b/compiler/testData/ir/irText/classes/kt43217.fir.txt index 7a16b0895ec..3495c843784 100644 --- a/compiler/testData/ir/irText/classes/kt43217.fir.txt +++ b/compiler/testData/ir/irText/classes/kt43217.fir.txt @@ -17,28 +17,31 @@ FILE fqName: fileName:/kt43217.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.DoubleExpression]' FUN name:get visibility:public modality:FINAL <> ($this:.A.b.) returnType:kotlin.Double [operator] overridden: - public abstract fun get (): @[FlexibleNullability] T of .ObservableValue [operator] declared in .ObservableValue + public abstract fun get (): @[FlexibleNullability] kotlin.Double [fake_override,operator] declared in .DoubleExpression $this: VALUE_PARAMETER name: type:.A.b. BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun get (): kotlin.Double [operator] declared in .A.b.' CONST Double type=kotlin.Double value=0.0 FUN FAKE_OVERRIDE name:isEqualTo visibility:public modality:OPEN <> ($this:.DoubleExpression, value:kotlin.Double) returnType:@[EnhancedNullability] kotlin.Any [fake_override] + annotations: + NotNull(value = ) + Override overridden: public open fun isEqualTo (value: kotlin.Double): @[EnhancedNullability] kotlin.Any declared in .DoubleExpression $this: VALUE_PARAMETER name: type:.DoubleExpression VALUE_PARAMETER name:value index:0 type:kotlin.Double FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .DoubleExpression $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .DoubleExpression $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .DoubleExpression $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .A.b.' type=.A.b. origin=OBJECT_LITERAL FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.A) returnType:.A.b. @@ -69,26 +72,29 @@ FILE fqName: fileName:/kt43217.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.DoubleExpression]' FUN name:get visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Double [operator] overridden: - public abstract fun get (): @[FlexibleNullability] T of .ObservableValue [operator] declared in .ObservableValue + public abstract fun get (): @[FlexibleNullability] kotlin.Double [fake_override,operator] declared in .DoubleExpression $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun get (): kotlin.Double [operator] declared in .C' CONST Double type=kotlin.Double value=0.0 FUN FAKE_OVERRIDE name:isEqualTo visibility:public modality:OPEN <> ($this:.DoubleExpression, value:kotlin.Double) returnType:@[EnhancedNullability] kotlin.Any [fake_override] + annotations: + NotNull(value = ) + Override overridden: public open fun isEqualTo (value: kotlin.Double): @[EnhancedNullability] kotlin.Any declared in .DoubleExpression $this: VALUE_PARAMETER name: type:.DoubleExpression VALUE_PARAMETER name:value index:0 type:kotlin.Double FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .DoubleExpression $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .DoubleExpression $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .DoubleExpression $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt b/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt index d37fe51b879..15296d4707e 100644 --- a/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt +++ b/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt @@ -64,16 +64,16 @@ FILE fqName: fileName:/objectLiteralExpressions.kt message: CONST String type=kotlin.String value="foo" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test2.' type=.test2. origin=OBJECT_LITERAL FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:.IFoo @@ -100,16 +100,16 @@ FILE fqName: fileName:/objectLiteralExpressions.kt $this: VALUE_PARAMETER name: type:.IFoo FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:test3 visibility:public modality:FINAL <> ($this:.Outer) returnType:.Outer.Inner $this: VALUE_PARAMETER name: type:.Outer @@ -125,23 +125,23 @@ FILE fqName: fileName:/objectLiteralExpressions.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Outer.Inner]' FUN name:foo visibility:public modality:FINAL <> ($this:.Outer.test3.) returnType:kotlin.Unit overridden: - public abstract fun foo (): kotlin.Unit declared in .IFoo + public abstract fun foo (): kotlin.Unit [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:.Outer.test3. BLOCK_BODY CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="foo" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Outer.test3.' type=.Outer.test3. origin=OBJECT_LITERAL FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] @@ -171,22 +171,22 @@ FILE fqName: fileName:/objectLiteralExpressions.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Outer.Inner]' FUN name:foo visibility:public modality:FINAL <> ($this:.test4.) returnType:kotlin.Unit overridden: - public abstract fun foo (): kotlin.Unit declared in .IFoo + public abstract fun foo (): kotlin.Unit [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:.test4. BLOCK_BODY CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="foo" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test4.' type=.test4. origin=OBJECT_LITERAL diff --git a/compiler/testData/ir/irText/classes/objectWithInitializers.fir.kt.txt b/compiler/testData/ir/irText/classes/objectWithInitializers.fir.kt.txt deleted file mode 100644 index 2ea6b369681..00000000000 --- a/compiler/testData/ir/irText/classes/objectWithInitializers.fir.kt.txt +++ /dev/null @@ -1,28 +0,0 @@ -abstract class Base { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - -} - -object Test : Base { - private constructor() /* primary */ { - super/*Base*/() - /* () */ - - } - - val x: Int - field = 1 - get - - val y: Int - get - - init { - .#y = .() - } - -} diff --git a/compiler/testData/ir/irText/classes/objectWithInitializers.fir.txt b/compiler/testData/ir/irText/classes/objectWithInitializers.fir.txt deleted file mode 100644 index bd4cc693893..00000000000 --- a/compiler/testData/ir/irText/classes/objectWithInitializers.fir.txt +++ /dev/null @@ -1,65 +0,0 @@ -FILE fqName: fileName:/objectWithInitializers.kt - CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base - CONSTRUCTOR visibility:public <> () returnType:.Base [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS OBJECT name:Test modality:FINAL visibility:public superTypes:[.Base] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test - CONSTRUCTOR visibility:private <> () returnType:.Test [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Test modality:FINAL visibility:public superTypes:[.Base]' - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - CONST Int type=kotlin.Int value=1 - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test) returnType:kotlin.Int - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Test - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Test' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null - PROPERTY name:y visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test) returnType:kotlin.Int - correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Test - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Test' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null - ANONYMOUS_INITIALIZER isStatic=false - BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=null - receiver: GET_VAR ': .Test declared in .Test' type=.Test origin=null - value: CALL 'public final fun (): kotlin.Int declared in .Test' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR ': .Test declared in .Test' type=.Test origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/objectWithInitializers.kt b/compiler/testData/ir/irText/classes/objectWithInitializers.kt index c049dc75b64..6f01631c002 100644 --- a/compiler/testData/ir/irText/classes/objectWithInitializers.kt +++ b/compiler/testData/ir/irText/classes/objectWithInitializers.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL abstract class Base object Test : Base() { diff --git a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.fir.kt.txt b/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.fir.kt.txt deleted file mode 100644 index ad72db20377..00000000000 --- a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.fir.kt.txt +++ /dev/null @@ -1,47 +0,0 @@ -open class Base { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - -} - -class TestImplicitPrimaryConstructor : Base { - constructor() /* primary */ { - super/*Base*/() - /* () */ - - } - -} - -class TestExplicitPrimaryConstructor : Base { - constructor() /* primary */ { - super/*Base*/() - /* () */ - - } - -} - -class TestWithDelegatingConstructor : Base { - constructor(x: Int, y: Int) /* primary */ { - super/*Base*/() - /* () */ - - } - - val x: Int - field = x - get - - val y: Int - field = y - get - - constructor(x: Int) { - this/*TestWithDelegatingConstructor*/(x = x, y = 0) - } - -} diff --git a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.fir.txt b/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.fir.txt deleted file mode 100644 index 5a05a1b67fc..00000000000 --- a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.fir.txt +++ /dev/null @@ -1,107 +0,0 @@ -FILE fqName: fileName:/primaryConstructorWithSuperConstructorCall.kt - CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base - CONSTRUCTOR visibility:public <> () returnType:.Base [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:TestImplicitPrimaryConstructor modality:FINAL visibility:public superTypes:[.Base] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestImplicitPrimaryConstructor - CONSTRUCTOR visibility:public <> () returnType:.TestImplicitPrimaryConstructor [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestImplicitPrimaryConstructor modality:FINAL visibility:public superTypes:[.Base]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:TestExplicitPrimaryConstructor modality:FINAL visibility:public superTypes:[.Base] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestExplicitPrimaryConstructor - CONSTRUCTOR visibility:public <> () returnType:.TestExplicitPrimaryConstructor [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestExplicitPrimaryConstructor modality:FINAL visibility:public superTypes:[.Base]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:TestWithDelegatingConstructor modality:FINAL visibility:public superTypes:[.Base] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestWithDelegatingConstructor - CONSTRUCTOR visibility:public <> (x:kotlin.Int, y:kotlin.Int) returnType:.TestWithDelegatingConstructor [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Int - VALUE_PARAMETER name:y index:1 type:kotlin.Int - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestWithDelegatingConstructor modality:FINAL visibility:public superTypes:[.Base]' - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Int declared in .TestWithDelegatingConstructor.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestWithDelegatingConstructor) returnType:kotlin.Int - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestWithDelegatingConstructor - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .TestWithDelegatingConstructor' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .TestWithDelegatingConstructor declared in .TestWithDelegatingConstructor.' type=.TestWithDelegatingConstructor origin=null - PROPERTY name:y visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'y: kotlin.Int declared in .TestWithDelegatingConstructor.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestWithDelegatingConstructor) returnType:kotlin.Int - correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestWithDelegatingConstructor - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .TestWithDelegatingConstructor' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .TestWithDelegatingConstructor declared in .TestWithDelegatingConstructor.' type=.TestWithDelegatingConstructor origin=null - CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:.TestWithDelegatingConstructor - VALUE_PARAMETER name:x index:0 type:kotlin.Int - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (x: kotlin.Int, y: kotlin.Int) [primary] declared in .TestWithDelegatingConstructor' - x: GET_VAR 'x: kotlin.Int declared in .TestWithDelegatingConstructor.' type=kotlin.Int origin=null - y: CONST Int type=kotlin.Int value=0 - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.kt b/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.kt index 4c1b4a019fc..84a3154bec8 100644 --- a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.kt +++ b/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL open class Base class TestImplicitPrimaryConstructor : Base() diff --git a/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt b/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt index 8b0a5db9427..b57f9e0f031 100644 --- a/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt +++ b/compiler/testData/ir/irText/classes/qualifiedSuperCalls.fir.txt @@ -81,14 +81,17 @@ FILE fqName: fileName:/qualifiedSuperCalls.kt $this: GET_VAR ': .CBoth declared in .CBoth.' type=.CBoth origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .ILeft + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IRight $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .ILeft + public open fun hashCode (): kotlin.Int [fake_override] declared in .IRight $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .ILeft + public open fun toString (): kotlin.String [fake_override] declared in .IRight $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/sealedClasses.fir.kt.txt b/compiler/testData/ir/irText/classes/sealedClasses.fir.kt.txt deleted file mode 100644 index 4bb99510fdf..00000000000 --- a/compiler/testData/ir/irText/classes/sealedClasses.fir.kt.txt +++ /dev/null @@ -1,47 +0,0 @@ -sealed class Expr { - protected constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - class Const : Expr { - constructor(number: Double) /* primary */ { - super/*Expr*/() - /* () */ - - } - - val number: Double - field = number - get - - } - - class Sum : Expr { - constructor(e1: Expr, e2: Expr) /* primary */ { - super/*Expr*/() - /* () */ - - } - - val e1: Expr - field = e1 - get - - val e2: Expr - field = e2 - get - - } - - object NotANumber : Expr { - private constructor() /* primary */ { - super/*Expr*/() - /* () */ - - } - - } - -} diff --git a/compiler/testData/ir/irText/classes/sealedClasses.fir.txt b/compiler/testData/ir/irText/classes/sealedClasses.fir.txt deleted file mode 100644 index 5b19df65239..00000000000 --- a/compiler/testData/ir/irText/classes/sealedClasses.fir.txt +++ /dev/null @@ -1,113 +0,0 @@ -FILE fqName: fileName:/sealedClasses.kt - CLASS CLASS name:Expr modality:SEALED visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Expr - CONSTRUCTOR visibility:protected <> () returnType:.Expr [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Expr modality:SEALED visibility:public superTypes:[kotlin.Any]' - CLASS CLASS name:Const modality:FINAL visibility:public superTypes:[.Expr] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Expr.Const - CONSTRUCTOR visibility:public <> (number:kotlin.Double) returnType:.Expr.Const [primary] - VALUE_PARAMETER name:number index:0 type:kotlin.Double - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .Expr' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Const modality:FINAL visibility:public superTypes:[.Expr]' - PROPERTY name:number visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:number type:kotlin.Double visibility:private [final] - EXPRESSION_BODY - GET_VAR 'number: kotlin.Double declared in .Expr.Const.' type=kotlin.Double origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Expr.Const) returnType:kotlin.Double - correspondingProperty: PROPERTY name:number visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Expr.Const - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Double declared in .Expr.Const' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:number type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null - receiver: GET_VAR ': .Expr.Const declared in .Expr.Const.' type=.Expr.Const origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:Sum modality:FINAL visibility:public superTypes:[.Expr] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Expr.Sum - CONSTRUCTOR visibility:public <> (e1:.Expr, e2:.Expr) returnType:.Expr.Sum [primary] - VALUE_PARAMETER name:e1 index:0 type:.Expr - VALUE_PARAMETER name:e2 index:1 type:.Expr - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .Expr' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Sum modality:FINAL visibility:public superTypes:[.Expr]' - PROPERTY name:e1 visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:e1 type:.Expr visibility:private [final] - EXPRESSION_BODY - GET_VAR 'e1: .Expr declared in .Expr.Sum.' type=.Expr origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Expr.Sum) returnType:.Expr - correspondingProperty: PROPERTY name:e1 visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Expr.Sum - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): .Expr declared in .Expr.Sum' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:e1 type:.Expr visibility:private [final]' type=.Expr origin=null - receiver: GET_VAR ': .Expr.Sum declared in .Expr.Sum.' type=.Expr.Sum origin=null - PROPERTY name:e2 visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:e2 type:.Expr visibility:private [final] - EXPRESSION_BODY - GET_VAR 'e2: .Expr declared in .Expr.Sum.' type=.Expr origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Expr.Sum) returnType:.Expr - correspondingProperty: PROPERTY name:e2 visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Expr.Sum - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): .Expr declared in .Expr.Sum' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:e2 type:.Expr visibility:private [final]' type=.Expr origin=null - receiver: GET_VAR ': .Expr.Sum declared in .Expr.Sum.' type=.Expr.Sum origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS OBJECT name:NotANumber modality:FINAL visibility:public superTypes:[.Expr] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Expr.NotANumber - CONSTRUCTOR visibility:private <> () returnType:.Expr.NotANumber [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'protected constructor () [primary] declared in .Expr' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:NotANumber modality:FINAL visibility:public superTypes:[.Expr]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/sealedClasses.kt b/compiler/testData/ir/irText/classes/sealedClasses.kt index f1561ef6b68..1b59fb65501 100644 --- a/compiler/testData/ir/irText/classes/sealedClasses.kt +++ b/compiler/testData/ir/irText/classes/sealedClasses.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL sealed class Expr { class Const(val number: Double) : Expr() class Sum(val e1: Expr, val e2: Expr) : Expr() diff --git a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.kt.txt b/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.kt.txt deleted file mode 100644 index 997168e114f..00000000000 --- a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.kt.txt +++ /dev/null @@ -1,47 +0,0 @@ -open class Base { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - -} - -class TestProperty : Base { - val x: Int - field = 0 - get - - constructor() { - super/*Base*/() - /* () */ - - } - -} - -class TestInitBlock : Base { - val x: Int - get - - init { - .#x = 0 - } - - constructor() { - super/*Base*/() - /* () */ - - } - - constructor(z: Any) { - super/*Base*/() - /* () */ - - } - - constructor(y: Int) { - this/*TestInitBlock*/() - } - -} diff --git a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.txt b/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.txt deleted file mode 100644 index 4107a0ef868..00000000000 --- a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.fir.txt +++ /dev/null @@ -1,92 +0,0 @@ -FILE fqName: fileName:/secondaryConstructorWithInitializersFromClassBody.kt - CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base - CONSTRUCTOR visibility:public <> () returnType:.Base [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:TestProperty modality:FINAL visibility:public superTypes:[.Base] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestProperty - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - CONST Int type=kotlin.Int value=0 - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestProperty) returnType:kotlin.Int - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestProperty - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .TestProperty' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .TestProperty declared in .TestProperty.' type=.TestProperty origin=null - CONSTRUCTOR visibility:public <> () returnType:.TestProperty - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestProperty modality:FINAL visibility:public superTypes:[.Base]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:TestInitBlock modality:FINAL visibility:public superTypes:[.Base] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestInitBlock - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestInitBlock) returnType:kotlin.Int - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestInitBlock - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .TestInitBlock' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .TestInitBlock declared in .TestInitBlock.' type=.TestInitBlock origin=null - ANONYMOUS_INITIALIZER isStatic=false - BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=null - receiver: GET_VAR ': .TestInitBlock declared in .TestInitBlock' type=.TestInitBlock origin=null - value: CONST Int type=kotlin.Int value=0 - CONSTRUCTOR visibility:public <> () returnType:.TestInitBlock - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestInitBlock modality:FINAL visibility:public superTypes:[.Base]' - CONSTRUCTOR visibility:public <> (z:kotlin.Any) returnType:.TestInitBlock - VALUE_PARAMETER name:z index:0 type:kotlin.Any - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestInitBlock modality:FINAL visibility:public superTypes:[.Base]' - CONSTRUCTOR visibility:public <> (y:kotlin.Int) returnType:.TestInitBlock - VALUE_PARAMETER name:y index:0 type:kotlin.Int - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in .TestInitBlock' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.kt b/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.kt index f7e834e0247..f747eac2677 100644 --- a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.kt +++ b/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL open class Base class TestProperty : Base { diff --git a/compiler/testData/ir/irText/classes/superCalls.fir.txt b/compiler/testData/ir/irText/classes/superCalls.fir.txt index 290e4398d0e..6fa9681fe6d 100644 --- a/compiler/testData/ir/irText/classes/superCalls.fir.txt +++ b/compiler/testData/ir/irText/classes/superCalls.fir.txt @@ -65,10 +65,10 @@ FILE fqName: fileName:/superCalls.kt $this: VALUE_PARAMETER name: type:.Base FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/superCallsComposed.fir.txt b/compiler/testData/ir/irText/classes/superCallsComposed.fir.txt index 1514301a285..9092b993b0e 100644 --- a/compiler/testData/ir/irText/classes/superCallsComposed.fir.txt +++ b/compiler/testData/ir/irText/classes/superCallsComposed.fir.txt @@ -80,14 +80,17 @@ FILE fqName: fileName:/superCallsComposed.kt $this: GET_VAR ': .Derived declared in .Derived.' type=.Derived origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Base + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .BaseI $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Base + public open fun hashCode (): kotlin.Int [fake_override] declared in .BaseI $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Base + public open fun toString (): kotlin.String [fake_override] declared in .BaseI $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.fir.kt.txt deleted file mode 100644 index ac5cb764f23..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.fir.kt.txt +++ /dev/null @@ -1,28 +0,0 @@ -annotation class A1 : Annotation { - constructor(x: Int) /* primary */ - val x: Int - field = x - get - -} - -annotation class A2 : Annotation { - constructor(a: A1) /* primary */ - val a: A1 - field = a - get - -} - -annotation class AA : Annotation { - constructor(xs: Array) /* primary */ - val xs: Array - field = xs - get - -} - -@A2(a = A1(x = 42)) -@AA(xs = [A1(x = 1), A1(x = 2)]) -fun test() { -} diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.fir.txt b/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.fir.txt deleted file mode 100644 index 1069d93a2d4..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.fir.txt +++ /dev/null @@ -1,90 +0,0 @@ -FILE fqName: fileName:/annotationsInAnnotationArguments.kt - CLASS ANNOTATION_CLASS name:A1 modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A1 - CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:.A1 [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Int - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Int declared in .A1.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A1) returnType:kotlin.Int - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A1 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .A1' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .A1 declared in .A1.' type=.A1 origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ANNOTATION_CLASS name:A2 modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A2 - CONSTRUCTOR visibility:public <> (a:.A1) returnType:.A2 [primary] - VALUE_PARAMETER name:a index:0 type:.A1 - PROPERTY name:a visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:a type:.A1 visibility:private [final] - EXPRESSION_BODY - GET_VAR 'a: .A1 declared in .A2.' type=.A1 origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A2) returnType:.A1 - correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A2 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): .A1 declared in .A2' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:.A1 visibility:private [final]' type=.A1 origin=null - receiver: GET_VAR ': .A2 declared in .A2.' type=.A2 origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ANNOTATION_CLASS name:AA modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.AA - CONSTRUCTOR visibility:public <> (xs:kotlin.Array<.A1>) returnType:.AA [primary] - VALUE_PARAMETER name:xs index:0 type:kotlin.Array<.A1> - PROPERTY name:xs visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array<.A1> visibility:private [final] - EXPRESSION_BODY - GET_VAR 'xs: kotlin.Array<.A1> declared in .AA.' type=kotlin.Array<.A1> origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.AA) returnType:kotlin.Array<.A1> - correspondingProperty: PROPERTY name:xs visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.AA - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Array<.A1> declared in .AA' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array<.A1> visibility:private [final]' type=kotlin.Array<.A1> origin=null - receiver: GET_VAR ': .AA declared in .AA.' type=.AA origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A2(a = A1(x = '42')) - AA(xs = [A1(x = '1'), A1(x = '2')]) - BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.kt b/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.kt index 8856a65604e..d5a940723a2 100644 --- a/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.kt +++ b/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class A1(val x: Int) annotation class A2(val a: A1) annotation class AA(val xs: Array) diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsOnDelegatedMembers.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/annotationsOnDelegatedMembers.fir.kt.txt index 29030292342..843837c836c 100644 --- a/compiler/testData/ir/irText/declarations/annotations/annotationsOnDelegatedMembers.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/annotations/annotationsOnDelegatedMembers.fir.kt.txt @@ -51,4 +51,3 @@ class DFoo : IFoo { local /* final field */ val <$$delegate_0>: IFoo = d } - diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsOnDelegatedMembers.fir.txt b/compiler/testData/ir/irText/declarations/annotations/annotationsOnDelegatedMembers.fir.txt index 0fc194a84d1..754ee9e4373 100644 --- a/compiler/testData/ir/irText/declarations/annotations/annotationsOnDelegatedMembers.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/annotationsOnDelegatedMembers.fir.txt @@ -4,16 +4,16 @@ FILE fqName: fileName:/annotationsOnDelegatedMembers.kt CONSTRUCTOR visibility:public <> () returnType:.Ann [primary] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo @@ -114,14 +114,14 @@ FILE fqName: fileName:/annotationsOnDelegatedMembers.kt GET_VAR 'd: .IFoo declared in .DFoo.' type=.IFoo origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.fir.kt.txt deleted file mode 100644 index 3e2c5ad151c..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.fir.kt.txt +++ /dev/null @@ -1,31 +0,0 @@ -annotation class A : Annotation { - constructor(x: String = "", y: Int = 42) /* primary */ - val x: String - field = x - get - - val y: Int - field = y - get - -} - -@A(x = "abc", y = 123) -fun test1() { -} - -@A(x = "def") -fun test2() { -} - -@A(x = "ghi") -fun test3() { -} - -@A(, y = 456) -fun test4() { -} - -@A -fun test5() { -} diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.fir.txt b/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.fir.txt deleted file mode 100644 index 1fac627a538..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.fir.txt +++ /dev/null @@ -1,65 +0,0 @@ -FILE fqName: fileName:/annotationsWithDefaultParameterValues.kt - CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A - CONSTRUCTOR visibility:public <> (x:kotlin.String, y:kotlin.Int) returnType:.A [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.String - EXPRESSION_BODY - CONST String type=kotlin.String value="" - VALUE_PARAMETER name:y index:1 type:kotlin.Int - EXPRESSION_BODY - CONST Int type=kotlin.Int value=42 - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.String declared in .A.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.String - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .A' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .A declared in .A.' type=.A origin=null - PROPERTY name:y visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'y: kotlin.Int declared in .A.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Int - correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .A' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .A declared in .A.' type=.A origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A(x = 'abc', y = '123') - BLOCK_BODY - FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A(x = 'def', y = ) - BLOCK_BODY - FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A(x = 'ghi', y = ) - BLOCK_BODY - FUN name:test4 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A(x = , y = '456') - BLOCK_BODY - FUN name:test5 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A(x = , y = ) - BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.kt b/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.kt index 99bfca373cb..e68ee4f23fc 100644 --- a/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.kt +++ b/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class A(val x: String = "", val y: Int = 42) @A("abc", 123) fun test1() {} diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.fir.kt.txt deleted file mode 100644 index 0d5ed9fb16e..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.fir.kt.txt +++ /dev/null @@ -1,19 +0,0 @@ -annotation class A : Annotation { - constructor(vararg xs: String) /* primary */ - val xs: Array - field = xs - get - -} - -@A(xs = ["abc", "def"]) -fun test1() { -} - -@A(xs = ["abc"]) -fun test2() { -} - -@A(xs = []) -fun test3() { -} diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.fir.txt b/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.fir.txt deleted file mode 100644 index 6d944b63a77..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.fir.txt +++ /dev/null @@ -1,41 +0,0 @@ -FILE fqName: fileName:/annotationsWithVarargParameters.kt - CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A - CONSTRUCTOR visibility:public <> (xs:kotlin.Array) returnType:.A [primary] - VALUE_PARAMETER name:xs index:0 type:kotlin.Array varargElementType:kotlin.String [vararg] - PROPERTY name:xs visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array visibility:private [final] - EXPRESSION_BODY - GET_VAR 'xs: kotlin.Array [vararg] declared in .A.' type=kotlin.Array origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Array - correspondingProperty: PROPERTY name:xs visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Array declared in .A' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array visibility:private [final]' type=kotlin.Array origin=null - receiver: GET_VAR ': .A declared in .A.' type=.A origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A(xs = ['abc', 'def']) - BLOCK_BODY - FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A(xs = ['abc']) - BLOCK_BODY - FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A(xs = []) - BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.kt b/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.kt index efce4a1ef4b..f8b5ececad5 100644 --- a/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.kt +++ b/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class A(vararg val xs: String) @A("abc", "def") fun test1() {} diff --git a/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.fir.kt.txt deleted file mode 100644 index d03a05dbf1f..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.fir.kt.txt +++ /dev/null @@ -1,25 +0,0 @@ -annotation class TestAnnWithIntArray : Annotation { - constructor(x: IntArray) /* primary */ - val x: IntArray - field = x - get - -} - -annotation class TestAnnWithStringArray : Annotation { - constructor(x: Array) /* primary */ - val x: Array - field = x - get - -} - -@TestAnnWithIntArray(x = [1, 2, 3]) -@TestAnnWithStringArray(x = ["a", "b", "c"]) -fun test1() { -} - -@TestAnnWithIntArray(x = [4, 5, 6]) -@TestAnnWithStringArray(x = ["d", "e", "f"]) -fun test2() { -} diff --git a/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.fir.txt b/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.fir.txt deleted file mode 100644 index abfc0109994..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.fir.txt +++ /dev/null @@ -1,67 +0,0 @@ -FILE fqName: fileName:/arrayInAnnotationArguments.kt - CLASS ANNOTATION_CLASS name:TestAnnWithIntArray modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAnnWithIntArray - CONSTRUCTOR visibility:public <> (x:kotlin.IntArray) returnType:.TestAnnWithIntArray [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.IntArray - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.IntArray visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.IntArray declared in .TestAnnWithIntArray.' type=kotlin.IntArray origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestAnnWithIntArray) returnType:kotlin.IntArray - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestAnnWithIntArray - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.IntArray declared in .TestAnnWithIntArray' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.IntArray visibility:private [final]' type=kotlin.IntArray origin=null - receiver: GET_VAR ': .TestAnnWithIntArray declared in .TestAnnWithIntArray.' type=.TestAnnWithIntArray origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ANNOTATION_CLASS name:TestAnnWithStringArray modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAnnWithStringArray - CONSTRUCTOR visibility:public <> (x:kotlin.Array) returnType:.TestAnnWithStringArray [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Array - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Array visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Array declared in .TestAnnWithStringArray.' type=kotlin.Array origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestAnnWithStringArray) returnType:kotlin.Array - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestAnnWithStringArray - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Array declared in .TestAnnWithStringArray' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Array visibility:private [final]' type=kotlin.Array origin=null - receiver: GET_VAR ': .TestAnnWithStringArray declared in .TestAnnWithStringArray.' type=.TestAnnWithStringArray origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - TestAnnWithIntArray(x = ['1', '2', '3']) - TestAnnWithStringArray(x = ['a', 'b', 'c']) - BLOCK_BODY - FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - TestAnnWithIntArray(x = ['4', '5', '6']) - TestAnnWithStringArray(x = ['d', 'e', 'f']) - BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.kt b/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.kt index 3891bbe5403..94b2acf029c 100644 --- a/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.kt +++ b/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class TestAnnWithIntArray(val x: IntArray) annotation class TestAnnWithStringArray(val x: Array) diff --git a/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.kt.txt deleted file mode 100644 index 5244da04b7a..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.kt.txt +++ /dev/null @@ -1,20 +0,0 @@ -annotation class A : Annotation { - constructor(klass: KClass<*>) /* primary */ - val klass: KClass<*> - field = klass - get - -} - -class C { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - -} - -@A(klass = C::class) -fun test1() { -} diff --git a/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt b/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt deleted file mode 100644 index 5b46815152c..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.fir.txt +++ /dev/null @@ -1,52 +0,0 @@ -FILE fqName: fileName:/classLiteralInAnnotation.kt - CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A - CONSTRUCTOR visibility:public <> (klass:kotlin.reflect.KClass<*>) returnType:.A [primary] - VALUE_PARAMETER name:klass index:0 type:kotlin.reflect.KClass<*> - PROPERTY name:klass visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:klass type:kotlin.reflect.KClass<*> visibility:private [final] - EXPRESSION_BODY - GET_VAR 'klass: kotlin.reflect.KClass<*> declared in .A.' type=kotlin.reflect.KClass<*> origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.reflect.KClass<*> - correspondingProperty: PROPERTY name:klass visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.reflect.KClass<*> declared in .A' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:klass type:kotlin.reflect.KClass<*> visibility:private [final]' type=kotlin.reflect.KClass<*> origin=null - receiver: GET_VAR ': .A declared in .A.' type=.A origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C - CONSTRUCTOR visibility:public <> () returnType:.C [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A(klass = CLASS_REFERENCE 'CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<.C>) - BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.kt b/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.kt index ac36ee4a594..e6cb4f8f6eb 100644 --- a/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.kt +++ b/compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL import kotlin.reflect.KClass annotation class A(val klass: KClass<*>) diff --git a/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.fir.txt index 92d7b457aa4..beb78aa886d 100644 --- a/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.fir.txt @@ -16,16 +16,16 @@ FILE fqName: fileName:/classesWithAnnotations.kt receiver: GET_VAR ': .TestAnn declared in .TestAnn.' type=.TestAnn origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:TestClass modality:FINAL visibility:public superTypes:[kotlin.Any] annotations: @@ -181,14 +181,14 @@ FILE fqName: fileName:/classesWithAnnotations.kt CONSTRUCTOR visibility:public <> () returnType:.TestAnnotation [primary] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.fir.kt.txt deleted file mode 100644 index d1e9b133d95..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.fir.kt.txt +++ /dev/null @@ -1,19 +0,0 @@ -const val ONE: Int - field = 1 - get - -annotation class A : Annotation { - constructor(x: Int) /* primary */ - val x: Int - field = x - get - -} - -@A(x = 1) -fun test1() { -} - -@A(x = 2) -fun test2() { -} diff --git a/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.fir.txt b/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.fir.txt deleted file mode 100644 index 23daef248c2..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.fir.txt +++ /dev/null @@ -1,46 +0,0 @@ -FILE fqName: fileName:/constExpressionsInAnnotationArguments.kt - PROPERTY name:ONE visibility:public modality:FINAL [const,val] - FIELD PROPERTY_BACKING_FIELD name:ONE type:kotlin.Int visibility:public [final,static] - EXPRESSION_BODY - CONST Int type=kotlin.Int value=1 - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int - correspondingProperty: PROPERTY name:ONE visibility:public modality:FINAL [const,val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:ONE type:kotlin.Int visibility:public [final,static]' type=kotlin.Int origin=null - CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A - CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:.A [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Int - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Int declared in .A.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Int - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .A' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .A declared in .A.' type=.A origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A(x = '1') - BLOCK_BODY - FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A(x = '2') - BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.kt b/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.kt index 0e952d252a1..5154118df01 100644 --- a/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.kt +++ b/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL const val ONE = 1 annotation class A(val x: Int) diff --git a/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.fir.kt.txt deleted file mode 100644 index d73410ec5ad..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.fir.kt.txt +++ /dev/null @@ -1,22 +0,0 @@ -annotation class TestAnn : Annotation { - constructor(x: Int) /* primary */ - val x: Int - field = x - get - -} - -class TestClass { - @TestAnn(x = 1) - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - @TestAnn(x = 2) - constructor(x: Int) { - this/*TestClass*/() - } - -} diff --git a/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.fir.txt deleted file mode 100644 index 32cb7dd44ea..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.fir.txt +++ /dev/null @@ -1,56 +0,0 @@ -FILE fqName: fileName:/constructorsWithAnnotations.kt - CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAnn - CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:.TestAnn [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Int - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Int declared in .TestAnn.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestAnn) returnType:kotlin.Int - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestAnn - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .TestAnn' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .TestAnn declared in .TestAnn.' type=.TestAnn origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:TestClass modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestClass - CONSTRUCTOR visibility:public <> () returnType:.TestClass [primary] - annotations: - TestAnn(x = '1') - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestClass modality:FINAL visibility:public superTypes:[kotlin.Any]' - CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:.TestClass - annotations: - TestAnn(x = '2') - VALUE_PARAMETER name:x index:0 type:kotlin.Int - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .TestClass' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.kt index aecb53bec18..913c85b4786 100644 --- a/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.kt +++ b/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class TestAnn(val x: Int) class TestClass @TestAnn(1) constructor() { diff --git a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.kt.txt deleted file mode 100644 index 50f94ade6b1..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.kt.txt +++ /dev/null @@ -1,13 +0,0 @@ -annotation class Ann : Annotation { - constructor() /* primary */ - -} - -val test1: Int /* by */ - field = lazy(initializer = local fun (): Int { - return 42 - } -) - get(): Int { - return #test1$delegate.getValue(thisRef = null, property = ::test1) - } diff --git a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt deleted file mode 100644 index 2ec48ff8f2d..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt +++ /dev/null @@ -1,38 +0,0 @@ -FILE fqName: fileName:/delegateFieldWithAnnotations.kt - CLASS ANNOTATION_CLASS name:Ann modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Ann - CONSTRUCTOR visibility:public <> () returnType:.Ann [primary] - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static] - annotations: - Ann - EXPRESSION_BODY - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null - : kotlin.Int - initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test1$delegate' - CONST Int type=kotlin.Int value=42 - FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int - correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null - : kotlin.Int - $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static]' type=kotlin.Lazy origin=null - thisRef: CONST Null type=kotlin.Nothing? value=null - property: PROPERTY_REFERENCE 'public final test1: kotlin.Int [delegated,val]' field=null getter='public final fun (): kotlin.Int declared in ' setter=null type=kotlin.reflect.KProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE diff --git a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.kt index 58bafe00761..877139a92db 100644 --- a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.kt +++ b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // WITH_RUNTIME annotation class Ann diff --git a/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.fir.txt index fd1b84fb997..9ef5b20cb74 100644 --- a/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.fir.txt @@ -16,16 +16,16 @@ FILE fqName: fileName:/delegatedPropertyAccessorsWithAnnotations.kt receiver: GET_VAR ': .A declared in .A.' type=.A origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Cell modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Cell diff --git a/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.fir.txt index 207e8867064..fba4adb9f6a 100644 --- a/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.fir.txt @@ -16,16 +16,16 @@ FILE fqName: fileName:/enumEntriesWithAnnotations.kt receiver: GET_VAR ': .TestAnn declared in .TestAnn.' type=.TestAnn origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any CLASS ENUM_CLASS name:TestEnum modality:OPEN visibility:public superTypes:[kotlin.Enum<.TestEnum>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum @@ -65,37 +65,37 @@ FILE fqName: fileName:/enumEntriesWithAnnotations.kt receiver: GET_VAR ': .TestEnum.ENTRY2 declared in .TestEnum.ENTRY2.' type=.TestEnum.ENTRY2 origin=null FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .TestEnum $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.TestEnum) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .TestEnum): kotlin.Int [fake_override,operator] declared in .TestEnum $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.TestEnum FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .TestEnum $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .TestEnum $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .TestEnum $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .TestEnum $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .TestEnum $this: VALUE_PARAMETER name: type:kotlin.Enum FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<.TestEnum> SYNTHETIC_BODY kind=ENUM_VALUES diff --git a/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt b/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt index 74c3e2fc012..7aaebcca15d 100644 --- a/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt @@ -74,16 +74,16 @@ FILE fqName: fileName:/enumsInAnnotationArguments.kt receiver: GET_VAR ': .TestAnn declared in .TestAnn.' type=.TestAnn origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit annotations: diff --git a/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.fir.kt.txt deleted file mode 100644 index 65cf9cc5679..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.fir.kt.txt +++ /dev/null @@ -1,16 +0,0 @@ -annotation class TestAnn : Annotation { - constructor(x: String) /* primary */ - val x: String - field = x - get - -} - -val testVal: String - field = "a val" - get - -var testVar: String - field = "a var" - get - set diff --git a/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.fir.txt deleted file mode 100644 index 9cfd18f104c..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.fir.txt +++ /dev/null @@ -1,57 +0,0 @@ -FILE fqName: fileName:/fieldsWithAnnotations.kt - CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAnn - CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:.TestAnn [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.String - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.String declared in .TestAnn.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestAnn) returnType:kotlin.String - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestAnn - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .TestAnn' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .TestAnn declared in .TestAnn.' type=.TestAnn origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - PROPERTY name:testVal visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:testVal type:kotlin.String visibility:private [final,static] - annotations: - TestAnn(x = 'testVal.field') - EXPRESSION_BODY - CONST String type=kotlin.String value="a val" - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String - correspondingProperty: PROPERTY name:testVal visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVal type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null - PROPERTY name:testVar visibility:public modality:FINAL [var] - FIELD PROPERTY_BACKING_FIELD name:testVar type:kotlin.String visibility:private [static] - annotations: - TestAnn(x = 'testVar.field') - EXPRESSION_BODY - CONST String type=kotlin.String value="a var" - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String - correspondingProperty: PROPERTY name:testVar visibility:public modality:FINAL [var] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVar type:kotlin.String visibility:private [static]' type=kotlin.String origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.String) returnType:kotlin.Unit - correspondingProperty: PROPERTY name:testVar visibility:public modality:FINAL [var] - VALUE_PARAMETER name: index:0 type:kotlin.String - BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVar type:kotlin.String visibility:private [static]' type=kotlin.Unit origin=null - value: GET_VAR ': kotlin.String declared in .' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.kt index fb5312cb742..89ccd96d306 100644 --- a/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.kt +++ b/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class TestAnn(val x: String) @field:TestAnn("testVal.field") diff --git a/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.fir.kt.txt deleted file mode 100644 index 2c6453f4a48..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.fir.kt.txt +++ /dev/null @@ -1,11 +0,0 @@ -@file:A(x = "File annotation") -package test - -@Target(allowedTargets = [AnnotationTarget.FILE]) -annotation class A : Annotation { - constructor(x: String) /* primary */ - val x: String - field = x - get - -} diff --git a/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.fir.txt deleted file mode 100644 index 90b5a715de1..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.fir.txt +++ /dev/null @@ -1,33 +0,0 @@ -FILE fqName:test fileName:/fileAnnotations.kt - annotations: - A(x = 'File annotation') - CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Annotation] - annotations: - Target(allowedTargets = [GET_ENUM 'ENUM_ENTRY IR_EXTERNAL_DECLARATION_STUB name:FILE' type=kotlin.annotation.AnnotationTarget]) - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:test.A - CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:test.A [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.String - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.String declared in test.A.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:test.A) returnType:kotlin.String - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:test.A - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in test.A' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': test.A declared in test.A.' type=test.A origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.kt index 10b54831ab0..2d13836dc82 100644 --- a/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.kt +++ b/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL @file:A("File annotation") package test diff --git a/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.fir.kt.txt deleted file mode 100644 index fb9f4d773c6..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.fir.kt.txt +++ /dev/null @@ -1,11 +0,0 @@ -annotation class TestAnn : Annotation { - constructor(x: Int) /* primary */ - val x: Int - field = x - get - -} - -@TestAnn(x = 42) -fun testSimpleFunction() { -} diff --git a/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.fir.txt deleted file mode 100644 index 30e62918a6d..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.fir.txt +++ /dev/null @@ -1,33 +0,0 @@ -FILE fqName: fileName:/functionsWithAnnotations.kt - CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAnn - CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:.TestAnn [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Int - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Int declared in .TestAnn.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestAnn) returnType:kotlin.Int - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestAnn - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .TestAnn' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .TestAnn declared in .TestAnn.' type=.TestAnn origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:testSimpleFunction visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - TestAnn(x = '42') - BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.kt index f9dd83e72b9..ddc5a5e8e1f 100644 --- a/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.kt +++ b/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class TestAnn(val x: Int) @TestAnn(42) fun testSimpleFunction() {} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/inheritingDeprecation.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/inheritingDeprecation.fir.kt.txt index 9061db9158a..498f25fe25a 100644 --- a/compiler/testData/ir/irText/declarations/annotations/inheritingDeprecation.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/annotations/inheritingDeprecation.fir.kt.txt @@ -63,4 +63,3 @@ class ExplicitOverride : IFoo { } } - diff --git a/compiler/testData/ir/irText/declarations/annotations/inheritingDeprecation.fir.txt b/compiler/testData/ir/irText/declarations/annotations/inheritingDeprecation.fir.txt index ac03ff1228d..d343db72db3 100644 --- a/compiler/testData/ir/irText/declarations/annotations/inheritingDeprecation.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/inheritingDeprecation.fir.txt @@ -73,16 +73,16 @@ FILE fqName: fileName:/inheritingDeprecation.kt GET_VAR 'foo: .IFoo declared in .Delegated.' type=.IFoo origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:DefaultImpl modality:FINAL visibility:public superTypes:[.IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DefaultImpl @@ -91,12 +91,16 @@ FILE fqName: fileName:/inheritingDeprecation.kt DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DefaultImpl modality:FINAL visibility:public superTypes:[.IFoo]' PROPERTY FAKE_OVERRIDE name:prop visibility:public modality:OPEN [fake_override,val] + annotations: + Deprecated(message = '', replaceWith = , level = ) FUN FAKE_OVERRIDE name: visibility:public modality:OPEN <> ($this:.IFoo) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:prop visibility:public modality:OPEN [fake_override,val] overridden: public open fun (): kotlin.String declared in .IFoo $this: VALUE_PARAMETER name: type:.IFoo PROPERTY FAKE_OVERRIDE name:extProp visibility:public modality:OPEN [fake_override,val] + annotations: + Deprecated(message = '', replaceWith = , level = ) FUN FAKE_OVERRIDE name: visibility:public modality:OPEN <> ($this:.IFoo, $receiver:kotlin.String) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:extProp visibility:public modality:OPEN [fake_override,val] overridden: @@ -105,16 +109,16 @@ FILE fqName: fileName:/inheritingDeprecation.kt $receiver: VALUE_PARAMETER name: type:kotlin.String FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:ExplicitOverride modality:FINAL visibility:public superTypes:[.IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ExplicitOverride @@ -143,14 +147,14 @@ FILE fqName: fileName:/inheritingDeprecation.kt CONST String type=kotlin.String value="" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt index 93831b6e718..c4944e0938b 100644 --- a/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt @@ -16,16 +16,16 @@ FILE fqName: fileName:/localDelegatedPropertiesWithAnnotations.kt receiver: GET_VAR ': .A declared in .A.' type=.A origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:foo visibility:public modality:FINAL <> (m:kotlin.collections.Map) returnType:kotlin.Unit VALUE_PARAMETER name:m index:0 type:kotlin.collections.Map diff --git a/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.fir.kt.txt deleted file mode 100644 index 583d890bf3e..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.fir.kt.txt +++ /dev/null @@ -1,20 +0,0 @@ -annotation class A1 : Annotation { - constructor() /* primary */ - -} - -annotation class A2 : Annotation { - constructor() /* primary */ - -} - -annotation class A3 : Annotation { - constructor() /* primary */ - -} - -@A1 -@A2 -@A3 -fun test() { -} diff --git a/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.fir.txt b/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.fir.txt deleted file mode 100644 index 394a5f7591c..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.fir.txt +++ /dev/null @@ -1,55 +0,0 @@ -FILE fqName: fileName:/multipleAnnotationsInSquareBrackets.kt - CLASS ANNOTATION_CLASS name:A1 modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A1 - CONSTRUCTOR visibility:public <> () returnType:.A1 [primary] - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ANNOTATION_CLASS name:A2 modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A2 - CONSTRUCTOR visibility:public <> () returnType:.A2 [primary] - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ANNOTATION_CLASS name:A3 modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A3 - CONSTRUCTOR visibility:public <> () returnType:.A3 [primary] - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A1 - A2 - A3 - BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.kt b/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.kt index 09a1dec3c10..411240b887b 100644 --- a/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.kt +++ b/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class A1 annotation class A2 annotation class A3 diff --git a/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.fir.kt.txt deleted file mode 100644 index d5cc5c32c3a..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.fir.kt.txt +++ /dev/null @@ -1,17 +0,0 @@ -annotation class Ann : Annotation { - constructor() /* primary */ - -} - -class Test { - constructor(@Ann x: Int) /* primary */ { - super/*Any*/() - /* () */ - - } - - val x: Int - field = x - get - -} diff --git a/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.fir.txt deleted file mode 100644 index 714ebbe7873..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.fir.txt +++ /dev/null @@ -1,50 +0,0 @@ -FILE fqName: fileName:/primaryConstructorParameterWithAnnotations.kt - CLASS ANNOTATION_CLASS name:Ann modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Ann - CONSTRUCTOR visibility:public <> () returnType:.Ann [primary] - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test - CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:.Test [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Int - annotations: - Ann - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any]' - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Int declared in .Test.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Test) returnType:kotlin.Int - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Test - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Test' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.kt index 1388d1ae923..6247da2e1d0 100644 --- a/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.kt +++ b/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class Ann class Test(@param:Ann val x: Int) \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.fir.kt.txt deleted file mode 100644 index 3006aada3f3..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.fir.kt.txt +++ /dev/null @@ -1,12 +0,0 @@ -annotation class TestAnn : Annotation { - constructor(x: String) /* primary */ - val x: String - field = x - get - -} - -@TestAnn(x = "testVal.property") -val testVal: String - field = "" - get diff --git a/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.fir.txt deleted file mode 100644 index 194a39b472f..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.fir.txt +++ /dev/null @@ -1,40 +0,0 @@ -FILE fqName: fileName:/propertiesWithAnnotations.kt - CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAnn - CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:.TestAnn [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.String - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.String declared in .TestAnn.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestAnn) returnType:kotlin.String - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestAnn - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .TestAnn' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .TestAnn declared in .TestAnn.' type=.TestAnn origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - PROPERTY name:testVal visibility:public modality:FINAL [val] - annotations: - TestAnn(x = 'testVal.property') - FIELD PROPERTY_BACKING_FIELD name:testVal type:kotlin.String visibility:private [final,static] - EXPRESSION_BODY - CONST String type=kotlin.String value="" - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String - correspondingProperty: PROPERTY name:testVal visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:testVal type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.kt index 26aaa52951a..5e555af5cc7 100644 --- a/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.kt +++ b/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class TestAnn(val x: String) @TestAnn("testVal.property") diff --git a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.fir.kt.txt deleted file mode 100644 index 3340c0f3884..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.fir.kt.txt +++ /dev/null @@ -1,28 +0,0 @@ -annotation class A : Annotation { - constructor(x: String) /* primary */ - val x: String - field = x - get - -} - -class C { - constructor(x: Int, y: Int) /* primary */ { - super/*Any*/() - /* () */ - - } - - val x: Int - field = x - @A(x = "C.x.get") - get - - var y: Int - field = y - @A(x = "C.y.get") - get - @A(x = "C.y.set") - set - -} diff --git a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.fir.txt deleted file mode 100644 index dc4ad470de6..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.fir.txt +++ /dev/null @@ -1,86 +0,0 @@ -FILE fqName: fileName:/propertyAccessorsFromClassHeaderWithAnnotations.kt - CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A - CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:.A [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.String - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.String declared in .A.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.String - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .A' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .A declared in .A.' type=.A origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C - CONSTRUCTOR visibility:public <> (x:kotlin.Int, y:kotlin.Int) returnType:.C [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Int - VALUE_PARAMETER name:y index:1 type:kotlin.Int - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Int declared in .C.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int - annotations: - A(x = 'C.x.get') - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.C - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - PROPERTY name:y visibility:public modality:FINAL [var] - FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private - EXPRESSION_BODY - GET_VAR 'y: kotlin.Int declared in .C.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int - annotations: - A(x = 'C.y.get') - correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [var] - $this: VALUE_PARAMETER name: type:.C - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private' type=kotlin.Int origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C, :kotlin.Int) returnType:kotlin.Unit - annotations: - A(x = 'C.y.set') - correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [var] - $this: VALUE_PARAMETER name: type:.C - VALUE_PARAMETER name: index:0 type:kotlin.Int - BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private' type=kotlin.Unit origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - value: GET_VAR ': kotlin.Int declared in .C.' type=kotlin.Int origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.kt index 5f1a8a586d9..1f0cd78b7a3 100644 --- a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.kt +++ b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class A(val x: String) class C( diff --git a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.fir.kt.txt deleted file mode 100644 index 441a53b5564..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.fir.kt.txt +++ /dev/null @@ -1,34 +0,0 @@ -annotation class TestAnn : Annotation { - constructor(x: String) /* primary */ - val x: String - field = x - get - -} - -val test1: String - @TestAnn(x = "test1.get") - get(): String { - return "" - } - -var test2: String - @TestAnn(x = "test2.get") - get(): String { - return "" - } - @TestAnn(x = "test2.set") - set(value: String) { - } - -val test3: String - field = "" - @TestAnn(x = "test3.get") - get - -var test4: String - field = "" - @TestAnn(x = "test4.get") - get - @TestAnn(x = "test4.set") - set diff --git a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.fir.txt deleted file mode 100644 index e31ba1a60ac..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.fir.txt +++ /dev/null @@ -1,81 +0,0 @@ -FILE fqName: fileName:/propertyAccessorsWithAnnotations.kt - CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAnn - CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:.TestAnn [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.String - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.String declared in .TestAnn.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestAnn) returnType:kotlin.String - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestAnn - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .TestAnn' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .TestAnn declared in .TestAnn.' type=.TestAnn origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - PROPERTY name:test1 visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL <> () returnType:kotlin.String - annotations: - TestAnn(x = 'test1.get') - correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in ' - CONST String type=kotlin.String value="" - PROPERTY name:test2 visibility:public modality:FINAL [var] - FUN name: visibility:public modality:FINAL <> () returnType:kotlin.String - annotations: - TestAnn(x = 'test2.get') - correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [var] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in ' - CONST String type=kotlin.String value="" - FUN name: visibility:public modality:FINAL <> (value:kotlin.String) returnType:kotlin.Unit - annotations: - TestAnn(x = 'test2.set') - correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [var] - VALUE_PARAMETER name:value index:0 type:kotlin.String - BLOCK_BODY - PROPERTY name:test3 visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.String visibility:private [final,static] - EXPRESSION_BODY - CONST String type=kotlin.String value="" - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String - annotations: - TestAnn(x = 'test3.get') - correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.String visibility:private [final,static]' type=kotlin.String origin=null - PROPERTY name:test4 visibility:public modality:FINAL [var] - FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.String visibility:private [static] - EXPRESSION_BODY - CONST String type=kotlin.String value="" - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String - annotations: - TestAnn(x = 'test4.get') - correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [var] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.String visibility:private [static]' type=kotlin.String origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.String) returnType:kotlin.Unit - annotations: - TestAnn(x = 'test4.set') - correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [var] - VALUE_PARAMETER name: index:0 type:kotlin.String - BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.String visibility:private [static]' type=kotlin.Unit origin=null - value: GET_VAR ': kotlin.String declared in .' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.kt index 0bef9dfbb0c..a06050efc3c 100644 --- a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.kt +++ b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class TestAnn(val x: String) val test1: String diff --git a/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.fir.kt.txt deleted file mode 100644 index e64e83fcde1..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.fir.kt.txt +++ /dev/null @@ -1,23 +0,0 @@ -annotation class AnnParam : Annotation { - constructor() /* primary */ - -} - -var p: Int - field = 0 - get - set - -class C { - constructor(p: Int) /* primary */ { - super/*Any*/() - /* () */ - - } - - var p: Int - field = p - get - set - -} diff --git a/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.fir.txt deleted file mode 100644 index 7bf17de435c..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.fir.txt +++ /dev/null @@ -1,75 +0,0 @@ -FILE fqName: fileName:/propertySetterParameterWithAnnotations.kt - CLASS ANNOTATION_CLASS name:AnnParam modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.AnnParam - CONSTRUCTOR visibility:public <> () returnType:.AnnParam [primary] - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - PROPERTY name:p visibility:public modality:FINAL [var] - FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:private [static] - EXPRESSION_BODY - CONST Int type=kotlin.Int value=0 - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int - correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [var] - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:private [static]' type=kotlin.Int origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit - correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [var] - VALUE_PARAMETER name: index:0 type:kotlin.Int - annotations: - AnnParam - BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:private [static]' type=kotlin.Unit origin=null - value: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null - CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C - CONSTRUCTOR visibility:public <> (p:kotlin.Int) returnType:.C [primary] - VALUE_PARAMETER name:p index:0 type:kotlin.Int - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' - PROPERTY name:p visibility:public modality:FINAL [var] - FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:private - EXPRESSION_BODY - GET_VAR 'p: kotlin.Int declared in .C.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int - correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [var] - $this: VALUE_PARAMETER name: type:.C - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:private' type=kotlin.Int origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C, :kotlin.Int) returnType:kotlin.Unit - correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [var] - $this: VALUE_PARAMETER name: type:.C - VALUE_PARAMETER name: index:0 type:kotlin.Int - annotations: - AnnParam - BLOCK_BODY - SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:private' type=kotlin.Unit origin=null - receiver: GET_VAR ': .C declared in .C.' type=.C origin=null - value: GET_VAR ': kotlin.Int declared in .C.' type=kotlin.Int origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.kt index 9a227055b3d..5f901e369b0 100644 --- a/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.kt +++ b/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class AnnParam @setparam:AnnParam diff --git a/compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.fir.txt index 8dca0ece3a7..28baf8774c9 100644 --- a/compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.fir.txt @@ -4,16 +4,16 @@ FILE fqName: fileName:/receiverParameterWithAnnotations.kt CONSTRUCTOR visibility:public <> () returnType:.Ann [primary] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A diff --git a/compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.fir.txt b/compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.fir.txt index 663810ef6b1..6d7221b37dc 100644 --- a/compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.fir.txt @@ -16,16 +16,16 @@ FILE fqName: fileName:/spreadOperatorInAnnotationArguments.kt receiver: GET_VAR ': .A declared in .A.' type=.A origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit annotations: diff --git a/compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.fir.txt index ddf6d821efa..4e2b96758a1 100644 --- a/compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.fir.txt @@ -21,14 +21,14 @@ FILE fqName: fileName:/typeAliasesWithAnnotations.kt receiver: GET_VAR ': .TestAnn declared in .TestAnn.' type=.TestAnn origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.fir.txt index 6dfe0bee4e2..d4be2240d71 100644 --- a/compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.fir.txt @@ -6,16 +6,16 @@ FILE fqName: fileName:/typeParametersWithAnnotations.kt CONSTRUCTOR visibility:public <> () returnType:.Anno [primary] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:foo visibility:public modality:FINAL () returnType:kotlin.Unit TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] diff --git a/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.fir.kt.txt deleted file mode 100644 index 15710f9363f..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.fir.kt.txt +++ /dev/null @@ -1,23 +0,0 @@ -annotation class TestAnn : Annotation { - constructor(x: String) /* primary */ - val x: String - field = x - get - -} - -fun testFun(@TestAnn(x = "testFun.x") x: Int) { -} - -class TestClassConstructor1 { - constructor(@TestAnn(x = "TestClassConstructor1.x") x: Int) /* primary */ { - super/*Any*/() - /* () */ - - } - - val xx: Int - field = x - get - -} diff --git a/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.fir.txt deleted file mode 100644 index f49c36e3736..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.fir.txt +++ /dev/null @@ -1,67 +0,0 @@ -FILE fqName: fileName:/valueParametersWithAnnotations.kt - CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAnn - CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:.TestAnn [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.String - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.String declared in .TestAnn.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestAnn) returnType:kotlin.String - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestAnn - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .TestAnn' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .TestAnn declared in .TestAnn.' type=.TestAnn origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:testFun visibility:public modality:FINAL <> (x:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER name:x index:0 type:kotlin.Int - annotations: - TestAnn(x = 'testFun.x') - BLOCK_BODY - CLASS CLASS name:TestClassConstructor1 modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestClassConstructor1 - CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:.TestClassConstructor1 [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Int - annotations: - TestAnn(x = 'TestClassConstructor1.x') - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestClassConstructor1 modality:FINAL visibility:public superTypes:[kotlin.Any]' - PROPERTY name:xx visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:xx type:kotlin.Int visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Int declared in .TestClassConstructor1.' type=kotlin.Int origin=null - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestClassConstructor1) returnType:kotlin.Int - correspondingProperty: PROPERTY name:xx visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.TestClassConstructor1 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .TestClassConstructor1' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xx type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null - receiver: GET_VAR ': .TestClassConstructor1 declared in .TestClassConstructor1.' type=.TestClassConstructor1 origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.kt index 93bd42aee37..9366968c552 100644 --- a/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.kt +++ b/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class TestAnn(val x: String) fun testFun(@TestAnn("testFun.x") x: Int) {} diff --git a/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.fir.kt.txt deleted file mode 100644 index 42a3957deb9..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.fir.kt.txt +++ /dev/null @@ -1,35 +0,0 @@ -annotation class A1 : Annotation { - constructor(vararg xs: Int) /* primary */ - val xs: IntArray - field = xs - get - -} - -annotation class A2 : Annotation { - constructor(vararg xs: String) /* primary */ - val xs: Array - field = xs - get - -} - -annotation class AA : Annotation { - constructor(vararg xs: A1) /* primary */ - val xs: Array - field = xs - get - -} - -@A1(xs = [1, 2, 3]) -@A2(xs = ["a", "b", "c"]) -@AA(xs = [A1(xs = [4]), A1(xs = [5]), A1(xs = [6])]) -fun test1() { -} - -@A1(xs = []) -@A2(xs = []) -@AA(xs = []) -fun test2() { -} diff --git a/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.fir.txt b/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.fir.txt deleted file mode 100644 index ee0ab3b4832..00000000000 --- a/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.fir.txt +++ /dev/null @@ -1,97 +0,0 @@ -FILE fqName: fileName:/varargsInAnnotationArguments.kt - CLASS ANNOTATION_CLASS name:A1 modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A1 - CONSTRUCTOR visibility:public <> (xs:kotlin.IntArray) returnType:.A1 [primary] - VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] - PROPERTY name:xs visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.IntArray visibility:private [final] - EXPRESSION_BODY - GET_VAR 'xs: kotlin.IntArray [vararg] declared in .A1.' type=kotlin.IntArray origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A1) returnType:kotlin.IntArray - correspondingProperty: PROPERTY name:xs visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A1 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.IntArray declared in .A1' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.IntArray visibility:private [final]' type=kotlin.IntArray origin=null - receiver: GET_VAR ': .A1 declared in .A1.' type=.A1 origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ANNOTATION_CLASS name:A2 modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A2 - CONSTRUCTOR visibility:public <> (xs:kotlin.Array) returnType:.A2 [primary] - VALUE_PARAMETER name:xs index:0 type:kotlin.Array varargElementType:kotlin.String [vararg] - PROPERTY name:xs visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array visibility:private [final] - EXPRESSION_BODY - GET_VAR 'xs: kotlin.Array [vararg] declared in .A2.' type=kotlin.Array origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A2) returnType:kotlin.Array - correspondingProperty: PROPERTY name:xs visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.A2 - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Array declared in .A2' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array visibility:private [final]' type=kotlin.Array origin=null - receiver: GET_VAR ': .A2 declared in .A2.' type=.A2 origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ANNOTATION_CLASS name:AA modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.AA - CONSTRUCTOR visibility:public <> (xs:kotlin.Array.A1>) returnType:.AA [primary] - VALUE_PARAMETER name:xs index:0 type:kotlin.Array.A1> varargElementType:.A1 [vararg] - PROPERTY name:xs visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array.A1> visibility:private [final] - EXPRESSION_BODY - GET_VAR 'xs: kotlin.Array.A1> [vararg] declared in .AA.' type=kotlin.Array.A1> origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.AA) returnType:kotlin.Array.A1> - correspondingProperty: PROPERTY name:xs visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.AA - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Array.A1> declared in .AA' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array.A1> visibility:private [final]' type=kotlin.Array.A1> origin=null - receiver: GET_VAR ': .AA declared in .AA.' type=.AA origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A1(xs = ['1', '2', '3']) - A2(xs = ['a', 'b', 'c']) - AA(xs = [A1(xs = ['4']), A1(xs = ['5']), A1(xs = ['6'])]) - BLOCK_BODY - FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit - annotations: - A1(xs = []) - A2(xs = []) - AA(xs = []) - BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.kt b/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.kt index 883bb290868..cae61cb3c09 100644 --- a/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.kt +++ b/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL annotation class A1(vararg val xs: Int) annotation class A2(vararg val xs: String) annotation class AA(vararg val xs: A1) diff --git a/compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.fir.txt index 0fca625bac8..fd3b6a836f1 100644 --- a/compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.fir.txt @@ -16,16 +16,16 @@ FILE fqName: fileName:/variablesWithAnnotations.kt receiver: GET_VAR ': .TestAnn declared in .TestAnn.' type=.TestAnn origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/fakeOverrides.fir.txt b/compiler/testData/ir/irText/declarations/fakeOverrides.fir.txt index 2ccd40848ce..d71257392aa 100644 --- a/compiler/testData/ir/irText/declarations/fakeOverrides.fir.txt +++ b/compiler/testData/ir/irText/declarations/fakeOverrides.fir.txt @@ -88,14 +88,20 @@ FILE fqName: fileName:/fakeOverrides.kt VALUE_PARAMETER name:x index:0 type:kotlin.String FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .CFoo + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFooStr + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IBar $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .CFoo + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFooStr + public open fun hashCode (): kotlin.Int [fake_override] declared in .IBar $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .CFoo + public open fun toString (): kotlin.String [fake_override] declared in .IFooStr + public open fun toString (): kotlin.String [fake_override] declared in .IBar $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.fir.txt b/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.fir.txt index 38dd5a8740c..29cacc42a47 100644 --- a/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.fir.txt +++ b/compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.fir.txt @@ -89,6 +89,7 @@ FILE fqName: fileName:/inlineCollectionOfInlineClass.kt overridden: public abstract fun (): kotlin.Int declared in kotlin.collections.Set public abstract fun (): kotlin.Int declared in kotlin.collections.Collection + public abstract fun (): kotlin.Int [fake_override] declared in kotlin.collections.MutableSet $this: VALUE_PARAMETER name: type:.InlineMutableSet BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .InlineMutableSet' @@ -97,7 +98,7 @@ FILE fqName: fileName:/inlineCollectionOfInlineClass.kt $this: GET_VAR ': .InlineMutableSet declared in .InlineMutableSet.' type=.InlineMutableSet origin=null FUN name:contains visibility:public modality:FINAL <> ($this:.InlineMutableSet, element:.IT) returnType:kotlin.Boolean [operator] overridden: - public abstract fun contains (element: E of kotlin.collections.Set): kotlin.Boolean [operator] declared in kotlin.collections.Set + public abstract fun contains (element: E of kotlin.collections.MutableSet): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.MutableSet $this: VALUE_PARAMETER name: type:.InlineMutableSet VALUE_PARAMETER name:element index:0 type:.IT BLOCK_BODY @@ -108,7 +109,7 @@ FILE fqName: fileName:/inlineCollectionOfInlineClass.kt element: GET_VAR 'element: .IT declared in .InlineMutableSet.contains' type=.IT origin=null FUN name:containsAll visibility:public modality:FINAL <> ($this:.InlineMutableSet, elements:kotlin.collections.Collection<.IT>) returnType:kotlin.Boolean overridden: - public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.Set + public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean [fake_override] declared in kotlin.collections.MutableSet $this: VALUE_PARAMETER name: type:.InlineMutableSet VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<.IT> BLOCK_BODY @@ -121,6 +122,7 @@ FILE fqName: fileName:/inlineCollectionOfInlineClass.kt overridden: public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Set public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Collection + public abstract fun isEmpty (): kotlin.Boolean [fake_override] declared in kotlin.collections.MutableSet $this: VALUE_PARAMETER name: type:.InlineMutableSet BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun isEmpty (): kotlin.Boolean declared in .InlineMutableSet' diff --git a/compiler/testData/ir/irText/declarations/kt35550.fir.kt.txt b/compiler/testData/ir/irText/declarations/kt35550.fir.kt.txt index 90017fc08b0..1e4aa765a55 100644 --- a/compiler/testData/ir/irText/declarations/kt35550.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/kt35550.fir.kt.txt @@ -21,4 +21,3 @@ class A : I { local /* final field */ val <$$delegate_0>: I = i } - diff --git a/compiler/testData/ir/irText/declarations/kt35550.fir.txt b/compiler/testData/ir/irText/declarations/kt35550.fir.txt index d453e82a9ef..c14dc8698a9 100644 --- a/compiler/testData/ir/irText/declarations/kt35550.fir.txt +++ b/compiler/testData/ir/irText/declarations/kt35550.fir.txt @@ -50,14 +50,14 @@ FILE fqName: fileName:/kt35550.kt GET_VAR 'i: .I declared in .A.' type=.I origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/localClassWithOverrides.fir.txt b/compiler/testData/ir/irText/declarations/localClassWithOverrides.fir.txt index 0f36a69e29b..b4420dd5abd 100644 --- a/compiler/testData/ir/irText/declarations/localClassWithOverrides.fir.txt +++ b/compiler/testData/ir/irText/declarations/localClassWithOverrides.fir.txt @@ -83,14 +83,14 @@ FILE fqName: fileName:/localClassWithOverrides.kt value: GET_VAR ': kotlin.Int declared in .outer.Local.' type=kotlin.Int origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .outer.ALocal $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .outer.ALocal $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .outer.ALocal $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/multiplatform/expectClassInherited.fir.txt b/compiler/testData/ir/irText/declarations/multiplatform/expectClassInherited.fir.txt index 68ad264bf1f..de932280fe8 100644 --- a/compiler/testData/ir/irText/declarations/multiplatform/expectClassInherited.fir.txt +++ b/compiler/testData/ir/irText/declarations/multiplatform/expectClassInherited.fir.txt @@ -30,16 +30,16 @@ FILE fqName: fileName:/expectClassInherited.kt VALUE_PARAMETER name:s index:0 type:kotlin.String FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [expect,fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [expect,fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [expect,fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A @@ -80,14 +80,14 @@ FILE fqName: fileName:/expectClassInherited.kt BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt index 9f4ae699881..eb9586bd561 100644 --- a/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt +++ b/compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.fir.txt @@ -20,16 +20,16 @@ FILE fqName: fileName:/expectedSealedClass.kt CONSTRUCTOR visibility:public <> () returnType:.Add [primary,expect] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [expect,fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Ops $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [expect,fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Ops $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [expect,fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Ops $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Ops modality:SEALED visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Ops @@ -58,14 +58,14 @@ FILE fqName: fileName:/expectedSealedClass.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Add modality:FINAL visibility:public superTypes:[.Ops]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Ops $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Ops $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Ops $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.kt.txt b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.kt.txt index 5a876d4c310..85126984874 100644 --- a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.kt.txt @@ -30,4 +30,3 @@ class Test : IBase { local /* final field */ val <$$delegate_0>: IBase = impl } - diff --git a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt index a6077d73000..cff1f2ce1b6 100644 --- a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.fir.txt @@ -75,14 +75,14 @@ FILE fqName: fileName:/delegatedMembers.kt GET_VAR 'impl: .IBase.Test> declared in .Test.' type=.IBase.Test> origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.kt.txt b/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.kt.txt deleted file mode 100644 index b070d0dcb67..00000000000 --- a/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.kt.txt +++ /dev/null @@ -1,38 +0,0 @@ -abstract class Base1 { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - -} - -class Derived1 : Base1 { - constructor() /* primary */ { - super/*Base1*/() - /* () */ - - } - -} - -abstract class Base2 { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - fun foo(x: T) { - } - -} - -class Derived2 : Base2 { - constructor() /* primary */ { - super/*Base2*/() - /* () */ - - } - -} diff --git a/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.txt b/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.txt deleted file mode 100644 index a64a5960d4f..00000000000 --- a/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.fir.txt +++ /dev/null @@ -1,90 +0,0 @@ -FILE fqName: fileName:/typeParameterBoundedBySubclass.kt - CLASS CLASS name:Base1 modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base1.Base1> - TYPE_PARAMETER name:T index:0 variance: superTypes:[.Derived1] - CONSTRUCTOR visibility:public <> () returnType:.Base1.Base1> [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base1 modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[.Base1<.Derived1>] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived1 - CONSTRUCTOR visibility:public <> () returnType:.Derived1 [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base1' - : .Derived1 - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[.Base1<.Derived1>]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:Base2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base2 - CONSTRUCTOR visibility:public <> () returnType:.Base2 [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' - FUN name:foo visibility:public modality:FINAL ($this:.Base2, x:T of .Base2.foo) returnType:kotlin.Unit - TYPE_PARAMETER name:T index:0 variance: superTypes:[.Derived2] - $this: VALUE_PARAMETER name: type:.Base2 - VALUE_PARAMETER name:x index:0 type:T of .Base2.foo - BLOCK_BODY - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:Derived2 modality:FINAL visibility:public superTypes:[.Base2] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived2 - CONSTRUCTOR visibility:public <> () returnType:.Derived2 [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Base2' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived2 modality:FINAL visibility:public superTypes:[.Base2]' - FUN FAKE_OVERRIDE name:foo visibility:public modality:FINAL ($this:.Base2, x:T of .Derived2.foo) returnType:kotlin.Unit [fake_override] - overridden: - public final fun foo (x: T of .Base2.foo): kotlin.Unit declared in .Base2 - TYPE_PARAMETER name:T index:0 variance: superTypes:[.Derived2] - $this: VALUE_PARAMETER name: type:.Base2 - VALUE_PARAMETER name:x index:0 type:T of .Derived2.foo - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.kt b/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.kt index 80701c9f1c4..5e5b3e954a1 100644 --- a/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.kt +++ b/compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL abstract class Base1 class Derived1 : Base1() diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt index c5798a0e780..11b0ca2a342 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.kt.txt @@ -87,4 +87,3 @@ fun test6(a: Any) { <>.set(i = <> /*as Function1 */, newValue = <>.get(i = <> /*as Function1 */).plus(other = 1)) } } - diff --git a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt index bb7afd74455..6bac604577d 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.fir.txt @@ -26,16 +26,16 @@ FILE fqName: fileName:/caoWithAdaptationForSam.kt VALUE_PARAMETER name:i index:0 type:kotlin.Int FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A diff --git a/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.fir.txt index 446c9cdb584..36b1feac8f1 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.fir.txt @@ -99,16 +99,16 @@ FILE fqName: fileName:/genericLocalClassConstructorReference.kt $this: VALUE_PARAMETER name: type:.L.L> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .L $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .L $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .L $this: VALUE_PARAMETER name: type:kotlin.Any RETURN type=kotlin.Nothing from='public final fun (): .L.> declared in ' CALL 'public final fun foo2 (t1: T1 of .foo2, t2: T2 of .foo2, bb: kotlin.Function2.foo2, T2 of .foo2, R of .foo2>): R of .foo2 declared in ' type=..PLocal.> origin=null @@ -155,16 +155,16 @@ FILE fqName: fileName:/genericLocalClassConstructorReference.kt $this: VALUE_PARAMETER name: type:.L.L> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .L $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .L $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .L $this: VALUE_PARAMETER name: type:kotlin.Any RETURN type=kotlin.Nothing from='public final fun fn (): .L.fn> declared in ' CALL 'public final fun foo2 (t1: T1 of .foo2, t2: T2 of .foo2, bb: kotlin.Function2.foo2, T2 of .foo2, R of .foo2>): R of .foo2 declared in ' type=.fn.FLocal.fn> origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt index ddd260c9264..4a81167d623 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.fir.txt @@ -46,16 +46,16 @@ FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt CONST Int type=kotlin.Int value=1 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:testUnbound visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt b/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt index a453560cc03..6b8378f92cf 100644 --- a/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt +++ b/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt @@ -46,37 +46,37 @@ FILE fqName: fileName:/enumEntryAsReceiver.kt receiver: GET_VAR ': .X.B declared in .X.B.' type=.X.B origin=null FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .X $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.X) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .X): kotlin.Int [fake_override,operator] declared in .X $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.X FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .X $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .X $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .X $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .X $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .X $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY name:value visibility:public modality:ABSTRACT [val] FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.X) returnType:kotlin.Function0 diff --git a/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt b/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt index 9fd5e2f0765..5ad701fef62 100644 --- a/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt +++ b/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt @@ -111,37 +111,37 @@ FILE fqName: fileName:/enumEntryReferenceFromEnumEntryClass.kt receiver: GET_VAR ': .MyEnum.Z declared in .MyEnum.Z.' type=.MyEnum.Z origin=null FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .MyEnum $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.MyEnum) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .MyEnum): kotlin.Int [fake_override,operator] declared in .MyEnum $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.MyEnum FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .MyEnum $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .MyEnum $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .MyEnum $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .MyEnum $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .MyEnum $this: VALUE_PARAMETER name: type:kotlin.Enum FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<.MyEnum> SYNTHETIC_BODY kind=ENUM_VALUES diff --git a/compiler/testData/ir/irText/expressions/funInterface/partialSam.fir.txt b/compiler/testData/ir/irText/expressions/funInterface/partialSam.fir.txt index e4654ff03e5..036d2c6e3b2 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/partialSam.fir.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/partialSam.fir.txt @@ -77,16 +77,16 @@ FILE fqName: fileName:/partialSam.kt CONST Int type=kotlin.Int value=1 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Fn $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Fn $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Fn $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .fsi.' type=.fsi. origin=OBJECT_LITERAL FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:.Fn @@ -116,16 +116,16 @@ FILE fqName: fileName:/partialSam.kt CONST String type=kotlin.String value="" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Fn $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Fn $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Fn $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .fis.' type=.fis. origin=OBJECT_LITERAL FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:.Fn diff --git a/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.txt b/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.txt index 3a5abfe7978..cc6144dec77 100644 --- a/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.txt +++ b/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.txt @@ -22,16 +22,19 @@ FILE fqName: fileName:/jvmFieldWithIntersectionTypes.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[.JFieldOwner; .IFoo]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .JFieldOwner + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .JFieldOwner + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .JFieldOwner + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Derived2 modality:FINAL visibility:public superTypes:[.JFieldOwner; .IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived2 @@ -41,16 +44,19 @@ FILE fqName: fileName:/jvmFieldWithIntersectionTypes.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived2 modality:FINAL visibility:public superTypes:[.JFieldOwner; .IFoo]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .JFieldOwner + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .JFieldOwner + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .JFieldOwner + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Mid modality:OPEN visibility:public superTypes:[.JFieldOwner] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Mid @@ -60,16 +66,16 @@ FILE fqName: fileName:/jvmFieldWithIntersectionTypes.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Mid modality:OPEN visibility:public superTypes:[.JFieldOwner]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .JFieldOwner $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .JFieldOwner $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .JFieldOwner $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:DerivedThroughMid1 modality:FINAL visibility:public superTypes:[.Mid; .IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DerivedThroughMid1 @@ -79,16 +85,19 @@ FILE fqName: fileName:/jvmFieldWithIntersectionTypes.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DerivedThroughMid1 modality:FINAL visibility:public superTypes:[.Mid; .IFoo]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Mid + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Mid + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Mid + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:DerivedThroughMid2 modality:FINAL visibility:public superTypes:[.Mid; .IFoo] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DerivedThroughMid2 @@ -98,16 +107,19 @@ FILE fqName: fileName:/jvmFieldWithIntersectionTypes.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DerivedThroughMid2 modality:FINAL visibility:public superTypes:[.Mid; .IFoo]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Mid + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Mid + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Mid + public open fun toString (): kotlin.String [fake_override] declared in .IFoo $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:test visibility:public modality:FINAL <> (b:kotlin.Boolean) returnType:kotlin.Unit VALUE_PARAMETER name:b index:0 type:kotlin.Boolean diff --git a/compiler/testData/ir/irText/expressions/jvmInstanceFieldReference.fir.txt b/compiler/testData/ir/irText/expressions/jvmInstanceFieldReference.fir.txt index 1490d7e8bbd..184df7e7665 100644 --- a/compiler/testData/ir/irText/expressions/jvmInstanceFieldReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/jvmInstanceFieldReference.fir.txt @@ -25,14 +25,14 @@ FILE fqName: fileName:/Derived.kt value: GET_VAR 'value: kotlin.Int declared in .Derived.setValue' type=kotlin.Int origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/kt16904.fir.txt b/compiler/testData/ir/irText/expressions/kt16904.fir.txt index d63b5407a1d..3cc9d4f4ebb 100644 --- a/compiler/testData/ir/irText/expressions/kt16904.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt16904.fir.txt @@ -107,16 +107,16 @@ FILE fqName: fileName:/kt16904.kt VALUE_PARAMETER name: index:0 type:kotlin.Int FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.J] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test2 @@ -131,14 +131,14 @@ FILE fqName: fileName:/kt16904.kt value: CONST Int type=kotlin.Int value=42 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/kt16905.fir.txt b/compiler/testData/ir/irText/expressions/kt16905.fir.txt index 1777070f720..041a3f6d943 100644 --- a/compiler/testData/ir/irText/expressions/kt16905.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt16905.fir.txt @@ -36,16 +36,16 @@ FILE fqName: fileName:/kt16905.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:InnerDerived0 modality:FINAL visibility:public [inner] superTypes:[.Outer.Inner]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:InnerDerived1 modality:FINAL visibility:public [inner] superTypes:[.Outer.Inner] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Outer.InnerDerived1 @@ -57,16 +57,16 @@ FILE fqName: fileName:/kt16905.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:InnerDerived1 modality:FINAL visibility:public [inner] superTypes:[.Outer.Inner]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/expressions/kt30020.fir.txt b/compiler/testData/ir/irText/expressions/kt30020.fir.txt index d45c3e9edb3..0c4f918e191 100644 --- a/compiler/testData/ir/irText/expressions/kt30020.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt30020.fir.txt @@ -198,44 +198,42 @@ FILE fqName: fileName:/kt30020.kt VALUE_PARAMETER name:toIndex index:1 type:kotlin.Int FUN FAKE_OVERRIDE name:contains visibility:public modality:ABSTRACT <> ($this:kotlin.collections.List, element:kotlin.Int) returnType:kotlin.Boolean [fake_override,operator] overridden: - public abstract fun contains (element: E of kotlin.collections.List): kotlin.Boolean [operator] declared in kotlin.collections.List + public abstract fun contains (element: E of kotlin.collections.MutableList): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.MutableList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:element index:0 type:kotlin.Int FUN FAKE_OVERRIDE name:containsAll visibility:public modality:ABSTRACT <> ($this:kotlin.collections.List, elements:kotlin.collections.Collection) returnType:kotlin.Boolean [fake_override] overridden: - public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.List + public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean [fake_override] declared in kotlin.collections.MutableList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection FUN FAKE_OVERRIDE name:get visibility:public modality:ABSTRACT <> ($this:kotlin.collections.List, index:kotlin.Int) returnType:kotlin.Int [fake_override,operator] overridden: - public abstract fun get (index: kotlin.Int): E of kotlin.collections.List [operator] declared in kotlin.collections.List + public abstract fun get (index: kotlin.Int): E of kotlin.collections.MutableList [fake_override,operator] declared in kotlin.collections.MutableList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:index index:0 type:kotlin.Int FUN FAKE_OVERRIDE name:indexOf visibility:public modality:ABSTRACT <> ($this:kotlin.collections.List, element:kotlin.Int) returnType:kotlin.Int [fake_override] overridden: - public abstract fun indexOf (element: E of kotlin.collections.List): kotlin.Int declared in kotlin.collections.List + public abstract fun indexOf (element: E of kotlin.collections.MutableList): kotlin.Int [fake_override] declared in kotlin.collections.MutableList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:element index:0 type:kotlin.Int FUN FAKE_OVERRIDE name:isEmpty visibility:public modality:ABSTRACT <> ($this:kotlin.collections.List) returnType:kotlin.Boolean [fake_override] overridden: - public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.List - public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Collection + public abstract fun isEmpty (): kotlin.Boolean [fake_override] declared in kotlin.collections.MutableList $this: VALUE_PARAMETER name: type:kotlin.collections.List FUN FAKE_OVERRIDE name:iterator visibility:public modality:ABSTRACT <> ($this:kotlin.collections.MutableCollection) returnType:kotlin.collections.MutableIterator [fake_override,operator] overridden: - public abstract fun iterator (): kotlin.collections.MutableIterator [operator] declared in kotlin.collections.MutableCollection + public abstract fun iterator (): kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableList $this: VALUE_PARAMETER name: type:kotlin.collections.MutableCollection FUN FAKE_OVERRIDE name:lastIndexOf visibility:public modality:ABSTRACT <> ($this:kotlin.collections.List, element:kotlin.Int) returnType:kotlin.Int [fake_override] overridden: - public abstract fun lastIndexOf (element: E of kotlin.collections.List): kotlin.Int declared in kotlin.collections.List + public abstract fun lastIndexOf (element: E of kotlin.collections.MutableList): kotlin.Int [fake_override] declared in kotlin.collections.MutableList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:element index:0 type:kotlin.Int PROPERTY FAKE_OVERRIDE name:size visibility:public modality:ABSTRACT [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:kotlin.collections.List) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:size visibility:public modality:ABSTRACT [fake_override,val] overridden: - public abstract fun (): kotlin.Int declared in kotlin.collections.List - public abstract fun (): kotlin.Int declared in kotlin.collections.Collection + public abstract fun (): kotlin.Int [fake_override] declared in kotlin.collections.MutableList $this: VALUE_PARAMETER name: type:kotlin.collections.List FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/expressions/kt35730.fir.txt b/compiler/testData/ir/irText/expressions/kt35730.fir.txt index 766f7ba62e2..db31dbdabd6 100644 --- a/compiler/testData/ir/irText/expressions/kt35730.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt35730.fir.txt @@ -29,16 +29,16 @@ FILE fqName: fileName:/kt35730.kt $this: VALUE_PARAMETER name: type:.Base FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt b/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt index 9c268ce684a..207aad641b5 100644 --- a/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt +++ b/compiler/testData/ir/irText/expressions/multipleThisReferences.fir.txt @@ -105,16 +105,16 @@ FILE fqName: fileName:/multipleThisReferences.kt $this: VALUE_PARAMETER name: type:.Outer.Inner FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Host.test.' type=.Host.test. origin=OBJECT_LITERAL FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] diff --git a/compiler/testData/ir/irText/expressions/objectByNameInsideObject.fir.kt.txt b/compiler/testData/ir/irText/expressions/objectByNameInsideObject.fir.kt.txt deleted file mode 100644 index 48a45ae537a..00000000000 --- a/compiler/testData/ir/irText/expressions/objectByNameInsideObject.fir.kt.txt +++ /dev/null @@ -1,32 +0,0 @@ -open class Base { - constructor(f1: Function0) /* primary */ { - super/*Any*/() - /* () */ - - } - - val f1: Function0 - field = f1 - get - -} - -object Thing : Base { - private constructor() /* primary */ { - super/*Base*/(f1 = local fun (): Any { - return Thing - } -) - /* () */ - - } - - fun test1(): Thing { - return Thing - } - - fun test2(): Thing { - return - } - -} diff --git a/compiler/testData/ir/irText/expressions/objectByNameInsideObject.fir.txt b/compiler/testData/ir/irText/expressions/objectByNameInsideObject.fir.txt deleted file mode 100644 index aae5f871fee..00000000000 --- a/compiler/testData/ir/irText/expressions/objectByNameInsideObject.fir.txt +++ /dev/null @@ -1,72 +0,0 @@ -FILE fqName: fileName:/objectByNameInsideObject.kt - CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base - CONSTRUCTOR visibility:public <> (f1:kotlin.Function0) returnType:.Base [primary] - VALUE_PARAMETER name:f1 index:0 type:kotlin.Function0 - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any]' - PROPERTY name:f1 visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:f1 type:kotlin.Function0 visibility:private [final] - EXPRESSION_BODY - GET_VAR 'f1: kotlin.Function0 declared in .Base.' type=kotlin.Function0 origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base) returnType:kotlin.Function0 - correspondingProperty: PROPERTY name:f1 visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Base - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Function0 declared in .Base' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:f1 type:kotlin.Function0 visibility:private [final]' type=kotlin.Function0 origin=null - receiver: GET_VAR ': .Base declared in .Base.' type=.Base origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS OBJECT name:Thing modality:FINAL visibility:public superTypes:[.Base] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Thing - CONSTRUCTOR visibility:private <> () returnType:.Thing [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (f1: kotlin.Function0) [primary] declared in .Base' - f1: FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Any declared in .Thing.' - GET_OBJECT 'CLASS OBJECT name:Thing modality:FINAL visibility:public superTypes:[.Base]' type=.Thing - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Thing modality:FINAL visibility:public superTypes:[.Base]' - FUN name:test1 visibility:public modality:FINAL <> ($this:.Thing) returnType:.Thing - $this: VALUE_PARAMETER name: type:.Thing - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test1 (): .Thing declared in .Thing' - GET_OBJECT 'CLASS OBJECT name:Thing modality:FINAL visibility:public superTypes:[.Base]' type=.Thing - FUN name:test2 visibility:public modality:FINAL <> ($this:.Thing) returnType:.Thing - $this: VALUE_PARAMETER name: type:.Thing - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test2 (): .Thing declared in .Thing' - GET_VAR ': .Thing declared in .Thing.test2' type=.Thing origin=null - PROPERTY FAKE_OVERRIDE name:f1 visibility:public modality:FINAL [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base) returnType:kotlin.Function0 [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:f1 visibility:public modality:FINAL [fake_override,val] - overridden: - public final fun (): kotlin.Function0 declared in .Base - $this: VALUE_PARAMETER name: type:.Base - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/objectByNameInsideObject.kt b/compiler/testData/ir/irText/expressions/objectByNameInsideObject.kt index 945c11ceea5..5c34a8779c0 100644 --- a/compiler/testData/ir/irText/expressions/objectByNameInsideObject.kt +++ b/compiler/testData/ir/irText/expressions/objectByNameInsideObject.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL open class Base(val f1: () -> Any) object Thing : Base({ Thing }) { diff --git a/compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.fir.kt.txt b/compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.fir.kt.txt deleted file mode 100644 index b2e99c61e65..00000000000 --- a/compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.fir.kt.txt +++ /dev/null @@ -1,24 +0,0 @@ -abstract class Base { - constructor(lambda: Function0) /* primary */ { - super/*Any*/() - /* () */ - - } - - val lambda: Function0 - field = lambda - get - -} - -object Test : Base { - private constructor() /* primary */ { - super/*Base*/(lambda = local fun (): Any { - return Test - } -) - /* () */ - - } - -} diff --git a/compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.fir.txt b/compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.fir.txt deleted file mode 100644 index e1328026ec5..00000000000 --- a/compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.fir.txt +++ /dev/null @@ -1,62 +0,0 @@ -FILE fqName: fileName:/objectReferenceInClosureInSuperConstructorCall.kt - CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base - CONSTRUCTOR visibility:public <> (lambda:kotlin.Function0) returnType:.Base [primary] - VALUE_PARAMETER name:lambda index:0 type:kotlin.Function0 - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' - PROPERTY name:lambda visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:lambda type:kotlin.Function0 visibility:private [final] - EXPRESSION_BODY - GET_VAR 'lambda: kotlin.Function0 declared in .Base.' type=kotlin.Function0 origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base) returnType:kotlin.Function0 - correspondingProperty: PROPERTY name:lambda visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Base - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Function0 declared in .Base' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:lambda type:kotlin.Function0 visibility:private [final]' type=kotlin.Function0 origin=null - receiver: GET_VAR ': .Base declared in .Base.' type=.Base origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS OBJECT name:Test modality:FINAL visibility:public superTypes:[.Base] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test - CONSTRUCTOR visibility:private <> () returnType:.Test [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (lambda: kotlin.Function0) [primary] declared in .Base' - lambda: FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.Any declared in .Test.' - GET_OBJECT 'CLASS OBJECT name:Test modality:FINAL visibility:public superTypes:[.Base]' type=.Test - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Test modality:FINAL visibility:public superTypes:[.Base]' - PROPERTY FAKE_OVERRIDE name:lambda visibility:public modality:FINAL [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base) returnType:kotlin.Function0 [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:lambda visibility:public modality:FINAL [fake_override,val] - overridden: - public final fun (): kotlin.Function0 declared in .Base - $this: VALUE_PARAMETER name: type:.Base - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.kt b/compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.kt index cfd4765eb86..599903f36e6 100644 --- a/compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.kt +++ b/compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL abstract class Base(val lambda: () -> Any) object Test : Base({ -> Test }) \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/setFieldWithImplicitCast.fir.txt b/compiler/testData/ir/irText/expressions/setFieldWithImplicitCast.fir.txt index 48831842144..48b9bc61f9f 100644 --- a/compiler/testData/ir/irText/expressions/setFieldWithImplicitCast.fir.txt +++ b/compiler/testData/ir/irText/expressions/setFieldWithImplicitCast.fir.txt @@ -20,14 +20,14 @@ FILE fqName: fileName:/Derived.kt GET_VAR 'v: kotlin.Any declared in .Derived.setValue' type=kotlin.Any origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.fir.txt b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.fir.txt index 4c2e1a69dca..3ff820c74a9 100644 --- a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.fir.txt +++ b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.fir.txt @@ -4,16 +4,16 @@ FILE fqName:kotlin.internal fileName:/signedToUnsignedConversions_annotation.kt CONSTRUCTOR visibility:public <> () returnType:kotlin.internal.ImplicitIntegerCoercion [primary] FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any FILE fqName: fileName:/signedToUnsignedConversions_test.kt PROPERTY name:IMPLICIT_INT visibility:public modality:FINAL [const,val] diff --git a/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt b/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt index 7fb309c1cbc..2d234e618c0 100644 --- a/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt +++ b/compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.fir.txt @@ -99,15 +99,15 @@ FILE fqName: fileName:/thisOfGenericOuterClass.kt $this: VALUE_PARAMETER name: type:.Outer.Inner.Outer> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test.' type=.test. origin=OBJECT_LITERAL diff --git a/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.kt.txt b/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.kt.txt deleted file mode 100644 index 17c69ed7c75..00000000000 --- a/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.kt.txt +++ /dev/null @@ -1,39 +0,0 @@ -open class Base { - constructor(x: Any) /* primary */ { - super/*Any*/() - /* () */ - - } - - val x: Any - field = x - get - -} - -object Host { - private constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - class Derived1 : Base { - constructor() /* primary */ { - super/*Base*/(x = Host) - /* () */ - - } - - } - - class Derived2 : Base { - constructor() /* primary */ { - super/*Base*/(x = Host) - /* () */ - - } - - } - -} diff --git a/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.txt b/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.txt deleted file mode 100644 index fd052bd276a..00000000000 --- a/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.fir.txt +++ /dev/null @@ -1,103 +0,0 @@ -FILE fqName: fileName:/thisRefToObjectInNestedClassConstructorCall.kt - CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base - CONSTRUCTOR visibility:public <> (x:kotlin.Any) returnType:.Base [primary] - VALUE_PARAMETER name:x index:0 type:kotlin.Any - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:OPEN visibility:public superTypes:[kotlin.Any]' - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: kotlin.Any declared in .Base.' type=kotlin.Any origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base) returnType:kotlin.Any - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Base - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .Base' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null - receiver: GET_VAR ': .Base declared in .Base.' type=.Base origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Host - CONSTRUCTOR visibility:private <> () returnType:.Host [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' - CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[.Base] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Host.Derived1 - CONSTRUCTOR visibility:public <> () returnType:.Host.Derived1 [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (x: kotlin.Any) [primary] declared in .Base' - x: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[.Base]' - PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base) returnType:kotlin.Any [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] - overridden: - public final fun (): kotlin.Any declared in .Base - $this: VALUE_PARAMETER name: type:.Base - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:Derived2 modality:FINAL visibility:public superTypes:[.Base] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Host.Derived2 - CONSTRUCTOR visibility:public <> () returnType:.Host.Derived2 [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (x: kotlin.Any) [primary] declared in .Base' - x: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived2 modality:FINAL visibility:public superTypes:[.Base]' - PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Base) returnType:kotlin.Any [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] - overridden: - public final fun (): kotlin.Any declared in .Base - $this: VALUE_PARAMETER name: type:.Base - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.kt b/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.kt index ad4a2c2e6fc..54bc885f4a2 100644 --- a/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.kt +++ b/compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL open class Base(val x: Any) object Host { diff --git a/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt b/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt index 6cb46148a8e..2f12e7ebccf 100644 --- a/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt +++ b/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt @@ -13,16 +13,16 @@ FILE fqName: fileName:/thisReferenceBeforeClassDeclared.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.WithCompanion]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .WithCompanion $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .WithCompanion $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .WithCompanion $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test.' type=.test. origin=OBJECT_LITERAL VAR name:test2 type:.test. [val] @@ -37,16 +37,16 @@ FILE fqName: fileName:/thisReferenceBeforeClassDeclared.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.WithCompanion]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .WithCompanion $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .WithCompanion $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .WithCompanion $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test.' type=.test. origin=OBJECT_LITERAL CLASS CLASS name:WithCompanion modality:OPEN visibility:public superTypes:[kotlin.Any] diff --git a/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt b/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt index 8f552817f4f..6dc97e095cd 100644 --- a/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt +++ b/compiler/testData/ir/irText/expressions/useImportedMember.fir.txt @@ -133,16 +133,19 @@ FILE fqName: fileName:/useImportedMember.kt $receiver: VALUE_PARAMETER name: type:T of .C. FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .BaseClass + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .BaseClass + public open fun hashCode (): kotlin.Int [fake_override] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .BaseClass + public open fun toString (): kotlin.String [fake_override] declared in .I $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:fromInterface visibility:public modality:OPEN ($this:.I.I>, $receiver:T of .C.fromInterface) returnType:T of .C.fromInterface [fake_override] overridden: diff --git a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt index 3e9e782bea2..4360aa0c2d9 100644 --- a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt +++ b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt @@ -12,6 +12,7 @@ FILE fqName: fileName:/AbstractMutableMap.kt FUN name:put visibility:public modality:FINAL <> ($this:.MyMap.MyMap, V of .MyMap>, key:K of .MyMap, value:V of .MyMap) returnType:V of .MyMap? overridden: public abstract fun put (key: K of kotlin.collections.AbstractMutableMap, value: V of kotlin.collections.AbstractMutableMap): V of kotlin.collections.AbstractMutableMap? declared in kotlin.collections.AbstractMutableMap + public open fun put (p0: K of kotlin.collections.AbstractMutableMap?, p1: V of kotlin.collections.AbstractMutableMap?): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:.MyMap.MyMap, V of .MyMap> VALUE_PARAMETER name:key index:0 type:K of .MyMap VALUE_PARAMETER name:value index:1 type:V of .MyMap @@ -22,7 +23,7 @@ FILE fqName: fileName:/AbstractMutableMap.kt FUN name: visibility:public modality:FINAL <> ($this:.MyMap.MyMap, V of .MyMap>) returnType:kotlin.collections.MutableSet.MyMap, V of .MyMap>> correspondingProperty: PROPERTY name:entries visibility:public modality:FINAL [val] overridden: - public abstract fun (): kotlin.collections.MutableSet> declared in kotlin.collections.MutableMap + public abstract fun (): kotlin.collections.MutableSet> [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:.MyMap.MyMap, V of .MyMap> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.collections.MutableSet.MyMap, V of .MyMap>> declared in .MyMap' @@ -30,156 +31,141 @@ FILE fqName: fileName:/AbstractMutableMap.kt : kotlin.collections.MutableMap.MutableEntry.MyMap, V of .MyMap> FUN FAKE_OVERRIDE name:clear visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap) returnType:kotlin.Unit [fake_override] overridden: - public abstract fun clear (): kotlin.Unit declared in kotlin.collections.MutableMap - public open fun clear (): kotlin.Unit declared in java.util.AbstractMap + public open fun clear (): kotlin.Unit [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.MutableMap FUN FAKE_OVERRIDE name:putAll visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap, from:kotlin.collections.Map.MyMap, V of .MyMap>) returnType:kotlin.Unit [fake_override] overridden: - public abstract fun putAll (from: kotlin.collections.Map): kotlin.Unit declared in kotlin.collections.MutableMap + public open fun putAll (from: kotlin.collections.Map): kotlin.Unit [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.MutableMap VALUE_PARAMETER name:from index:0 type:kotlin.collections.Map.MyMap, V of .MyMap> FUN FAKE_OVERRIDE name:remove visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap, key:K of .MyMap) returnType:V of .MyMap? [fake_override] overridden: - public abstract fun remove (key: K of kotlin.collections.MutableMap): V of kotlin.collections.MutableMap? declared in kotlin.collections.MutableMap + public open fun remove (key: K of kotlin.collections.AbstractMutableMap): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.MutableMap VALUE_PARAMETER name:key index:0 type:K of .MyMap FUN FAKE_OVERRIDE name:remove visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap, key:K of .MyMap, value:V of .MyMap) returnType:kotlin.Boolean [fake_override] + annotations: + SinceKotlin(version = '1.1') + PlatformDependent overridden: - public open fun remove (key: K of kotlin.collections.MutableMap, value: V of kotlin.collections.MutableMap): kotlin.Boolean declared in kotlin.collections.MutableMap + public open fun remove (key: K of kotlin.collections.AbstractMutableMap, value: V of kotlin.collections.AbstractMutableMap): kotlin.Boolean [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.MutableMap VALUE_PARAMETER name:key index:0 type:K of .MyMap VALUE_PARAMETER name:value index:1 type:V of .MyMap - PROPERTY FAKE_OVERRIDE name:keys visibility:public modality:ABSTRACT [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:kotlin.collections.MutableMap) returnType:kotlin.collections.MutableSet.MyMap> [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:keys visibility:public modality:ABSTRACT [fake_override,val] + PROPERTY FAKE_OVERRIDE name:keys visibility:public modality:OPEN [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap) returnType:kotlin.collections.MutableSet.MyMap> [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:keys visibility:public modality:OPEN [fake_override,val] overridden: - public abstract fun (): kotlin.collections.MutableSet declared in kotlin.collections.MutableMap + public open fun (): kotlin.collections.MutableSet [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.MutableMap - FUN FAKE_OVERRIDE name:values visibility:public modality:OPEN <> ($this:java.util.AbstractMap) returnType:kotlin.collections.Collection.MyMap?>? [fake_override] - overridden: - public open fun values (): kotlin.collections.Collection? declared in java.util.AbstractMap - $this: VALUE_PARAMETER name: type:java.util.AbstractMap - PROPERTY FAKE_OVERRIDE name:values visibility:public modality:ABSTRACT [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:kotlin.collections.MutableMap) returnType:kotlin.collections.MutableCollection.MyMap> [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:values visibility:public modality:ABSTRACT [fake_override,val] + PROPERTY FAKE_OVERRIDE name:values visibility:public modality:OPEN [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap) returnType:kotlin.collections.MutableCollection.MyMap> [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:values visibility:public modality:OPEN [fake_override,val] overridden: - public abstract fun (): kotlin.collections.MutableCollection declared in kotlin.collections.MutableMap + public open fun (): kotlin.collections.MutableCollection [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.MutableMap FUN FAKE_OVERRIDE name:replaceAll visibility:public modality:OPEN <> ($this:java.util.Map, p0:@[FlexibleNullability] java.util.function.BiFunction.MyMap?, in V of .MyMap?, out V of .MyMap?>) returnType:kotlin.Unit [fake_override] overridden: - public open fun replaceAll (p0: @[FlexibleNullability] java.util.function.BiFunction): kotlin.Unit declared in java.util.Map + public open fun replaceAll (p0: @[FlexibleNullability] java.util.function.BiFunction): kotlin.Unit [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:java.util.Map VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] java.util.function.BiFunction.MyMap?, in V of .MyMap?, out V of .MyMap?> FUN FAKE_OVERRIDE name:merge visibility:public modality:OPEN <> ($this:java.util.Map, p0:K of .MyMap, p1:V of .MyMap, p2:@[FlexibleNullability] java.util.function.BiFunction.MyMap?, in V of .MyMap?, out V of .MyMap?>) returnType:V of .MyMap? [fake_override] overridden: - public open fun merge (p0: @[FlexibleNullability] K of java.util.Map, p1: @[FlexibleNullability] V of java.util.Map, p2: @[FlexibleNullability] java.util.function.BiFunction): @[FlexibleNullability] V of java.util.Map? declared in java.util.Map + public open fun merge (p0: K of kotlin.collections.AbstractMutableMap, p1: V of kotlin.collections.AbstractMutableMap, p2: @[FlexibleNullability] java.util.function.BiFunction): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:java.util.Map VALUE_PARAMETER name:p0 index:0 type:K of .MyMap VALUE_PARAMETER name:p1 index:1 type:V of .MyMap VALUE_PARAMETER name:p2 index:2 type:@[FlexibleNullability] java.util.function.BiFunction.MyMap?, in V of .MyMap?, out V of .MyMap?> FUN FAKE_OVERRIDE name:computeIfPresent visibility:public modality:OPEN <> ($this:java.util.Map, p0:K of .MyMap, p1:@[FlexibleNullability] java.util.function.BiFunction.MyMap?, in V of .MyMap?, out V of .MyMap?>) returnType:V of .MyMap? [fake_override] overridden: - public open fun computeIfPresent (p0: @[FlexibleNullability] K of java.util.Map, p1: @[FlexibleNullability] java.util.function.BiFunction): @[FlexibleNullability] V of java.util.Map? declared in java.util.Map + public open fun computeIfPresent (p0: K of kotlin.collections.AbstractMutableMap, p1: @[FlexibleNullability] java.util.function.BiFunction): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:java.util.Map VALUE_PARAMETER name:p0 index:0 type:K of .MyMap VALUE_PARAMETER name:p1 index:1 type:@[FlexibleNullability] java.util.function.BiFunction.MyMap?, in V of .MyMap?, out V of .MyMap?> FUN FAKE_OVERRIDE name:putIfAbsent visibility:public modality:OPEN <> ($this:java.util.Map, p0:K of .MyMap, p1:V of .MyMap) returnType:V of .MyMap? [fake_override] overridden: - public open fun putIfAbsent (p0: @[FlexibleNullability] K of java.util.Map, p1: @[FlexibleNullability] V of java.util.Map): @[FlexibleNullability] V of java.util.Map? declared in java.util.Map + public open fun putIfAbsent (p0: K of kotlin.collections.AbstractMutableMap, p1: V of kotlin.collections.AbstractMutableMap): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:java.util.Map VALUE_PARAMETER name:p0 index:0 type:K of .MyMap VALUE_PARAMETER name:p1 index:1 type:V of .MyMap - FUN FAKE_OVERRIDE name:replace visibility:public modality:OPEN <> ($this:java.util.Map, p0:K of .MyMap?, p1:V of .MyMap?, p2:V of .MyMap?) returnType:kotlin.Boolean [fake_override] + FUN FAKE_OVERRIDE name:replace visibility:public modality:OPEN <> ($this:java.util.Map, p0:K of .MyMap, p1:V of .MyMap, p2:V of .MyMap) returnType:kotlin.Boolean [fake_override] overridden: - public open fun replace (p0: K of java.util.Map?, p1: V of java.util.Map?, p2: V of java.util.Map?): kotlin.Boolean declared in java.util.Map + public open fun replace (p0: K of kotlin.collections.AbstractMutableMap, p1: V of kotlin.collections.AbstractMutableMap, p2: V of kotlin.collections.AbstractMutableMap): kotlin.Boolean [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:java.util.Map - VALUE_PARAMETER name:p0 index:0 type:K of .MyMap? - VALUE_PARAMETER name:p1 index:1 type:V of .MyMap? - VALUE_PARAMETER name:p2 index:2 type:V of .MyMap? + VALUE_PARAMETER name:p0 index:0 type:K of .MyMap + VALUE_PARAMETER name:p1 index:1 type:V of .MyMap + VALUE_PARAMETER name:p2 index:2 type:V of .MyMap FUN FAKE_OVERRIDE name:replace visibility:public modality:OPEN <> ($this:java.util.Map, p0:K of .MyMap, p1:V of .MyMap) returnType:V of .MyMap? [fake_override] overridden: - public open fun replace (p0: @[FlexibleNullability] K of java.util.Map, p1: @[FlexibleNullability] V of java.util.Map): @[FlexibleNullability] V of java.util.Map? declared in java.util.Map + public open fun replace (p0: K of kotlin.collections.AbstractMutableMap, p1: V of kotlin.collections.AbstractMutableMap): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:java.util.Map VALUE_PARAMETER name:p0 index:0 type:K of .MyMap VALUE_PARAMETER name:p1 index:1 type:V of .MyMap FUN FAKE_OVERRIDE name:computeIfAbsent visibility:public modality:OPEN <> ($this:java.util.Map, p0:K of .MyMap, p1:@[FlexibleNullability] java.util.function.Function.MyMap?, out V of .MyMap?>) returnType:V of .MyMap [fake_override] overridden: - public open fun computeIfAbsent (p0: @[FlexibleNullability] K of java.util.Map, p1: @[FlexibleNullability] java.util.function.Function): @[FlexibleNullability] V of java.util.Map declared in java.util.Map + public open fun computeIfAbsent (p0: K of kotlin.collections.AbstractMutableMap, p1: @[FlexibleNullability] java.util.function.Function): V of kotlin.collections.AbstractMutableMap [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:java.util.Map VALUE_PARAMETER name:p0 index:0 type:K of .MyMap VALUE_PARAMETER name:p1 index:1 type:@[FlexibleNullability] java.util.function.Function.MyMap?, out V of .MyMap?> FUN FAKE_OVERRIDE name:compute visibility:public modality:OPEN <> ($this:java.util.Map, p0:K of .MyMap, p1:@[FlexibleNullability] java.util.function.BiFunction.MyMap?, in V of .MyMap?, out V of .MyMap?>) returnType:V of .MyMap? [fake_override] overridden: - public open fun compute (p0: @[FlexibleNullability] K of java.util.Map, p1: @[FlexibleNullability] java.util.function.BiFunction): @[FlexibleNullability] V of java.util.Map? declared in java.util.Map + public open fun compute (p0: K of kotlin.collections.AbstractMutableMap, p1: @[FlexibleNullability] java.util.function.BiFunction): V of kotlin.collections.AbstractMutableMap? [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:java.util.Map VALUE_PARAMETER name:p0 index:0 type:K of .MyMap VALUE_PARAMETER name:p1 index:1 type:@[FlexibleNullability] java.util.function.BiFunction.MyMap?, in V of .MyMap?, out V of .MyMap?> FUN FAKE_OVERRIDE name:containsKey visibility:public modality:OPEN <> ($this:kotlin.collections.Map, key:K of .MyMap) returnType:kotlin.Boolean [fake_override] overridden: - public abstract fun containsKey (key: K of kotlin.collections.Map): kotlin.Boolean declared in kotlin.collections.Map + public open fun containsKey (key: K of kotlin.collections.AbstractMutableMap): kotlin.Boolean [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.Map VALUE_PARAMETER name:key index:0 type:K of .MyMap FUN FAKE_OVERRIDE name:containsValue visibility:public modality:OPEN <> ($this:kotlin.collections.Map, value:V of .MyMap) returnType:kotlin.Boolean [fake_override] overridden: - public abstract fun containsValue (value: V of kotlin.collections.Map): kotlin.Boolean declared in kotlin.collections.Map + public open fun containsValue (value: V of kotlin.collections.AbstractMutableMap): kotlin.Boolean [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.Map VALUE_PARAMETER name:value index:0 type:V of .MyMap FUN FAKE_OVERRIDE name:get visibility:public modality:OPEN <> ($this:kotlin.collections.Map, key:K of .MyMap) returnType:V of .MyMap? [fake_override,operator] overridden: - public abstract fun get (key: K of kotlin.collections.Map): V of kotlin.collections.Map? [operator] declared in kotlin.collections.Map + public open fun get (key: K of kotlin.collections.AbstractMutableMap): V of kotlin.collections.AbstractMutableMap? [fake_override,operator] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.Map VALUE_PARAMETER name:key index:0 type:K of .MyMap FUN FAKE_OVERRIDE name:getOrDefault visibility:public modality:OPEN <> ($this:kotlin.collections.Map, key:K of .MyMap, defaultValue:V of .MyMap) returnType:V of .MyMap [fake_override] + annotations: + SinceKotlin(version = '1.1') + PlatformDependent overridden: - public open fun getOrDefault (key: K of kotlin.collections.Map, defaultValue: V of kotlin.collections.Map): V of kotlin.collections.Map declared in kotlin.collections.Map + public open fun getOrDefault (key: K of kotlin.collections.AbstractMutableMap, defaultValue: V of kotlin.collections.AbstractMutableMap): V of kotlin.collections.AbstractMutableMap [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.Map VALUE_PARAMETER name:key index:0 type:K of .MyMap VALUE_PARAMETER name:defaultValue index:1 type:V of .MyMap FUN FAKE_OVERRIDE name:isEmpty visibility:public modality:OPEN <> ($this:kotlin.collections.Map) returnType:kotlin.Boolean [fake_override] overridden: - public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Map - public open fun isEmpty (): kotlin.Boolean declared in java.util.AbstractMap + public open fun isEmpty (): kotlin.Boolean [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.Map - FUN FAKE_OVERRIDE name:size visibility:public modality:OPEN <> ($this:java.util.AbstractMap) returnType:kotlin.Int [fake_override] - overridden: - public open fun size (): kotlin.Int declared in java.util.AbstractMap - $this: VALUE_PARAMETER name: type:java.util.AbstractMap - PROPERTY FAKE_OVERRIDE name:size visibility:public modality:ABSTRACT [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:kotlin.collections.Map) returnType:kotlin.Int [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:size visibility:public modality:ABSTRACT [fake_override,val] + PROPERTY FAKE_OVERRIDE name:size visibility:public modality:OPEN [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:OPEN <> ($this:kotlin.collections.Map) returnType:kotlin.Int [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:size visibility:public modality:OPEN [fake_override,val] overridden: - public abstract fun (): kotlin.Int declared in kotlin.collections.Map + public open fun (): kotlin.Int [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.collections.Map FUN FAKE_OVERRIDE name:forEach visibility:public modality:OPEN <> ($this:java.util.Map, p0:@[FlexibleNullability] java.util.function.BiConsumer.MyMap?, in V of .MyMap?>) returnType:kotlin.Unit [fake_override] overridden: - public open fun forEach (p0: @[FlexibleNullability] java.util.function.BiConsumer): kotlin.Unit declared in java.util.Map + public open fun forEach (p0: @[FlexibleNullability] java.util.function.BiConsumer): kotlin.Unit [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:java.util.Map VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] java.util.function.BiConsumer.MyMap?, in V of .MyMap?> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - public open fun equals (p0: @[FlexibleNullability] kotlin.Any?): kotlin.Boolean [operator] declared in java.util.AbstractMap + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - public open fun hashCode (): kotlin.Int declared in java.util.AbstractMap + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - public open fun toString (): @[FlexibleNullability] kotlin.String declared in java.util.AbstractMap + public open fun toString (): kotlin.String [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:keySet visibility:public modality:OPEN <> ($this:java.util.AbstractMap) returnType:kotlin.collections.Set.MyMap?>? [fake_override] - overridden: - public open fun keySet (): kotlin.collections.Set? declared in java.util.AbstractMap - $this: VALUE_PARAMETER name: type:java.util.AbstractMap - FUN FAKE_OVERRIDE name:entrySet visibility:public modality:ABSTRACT <> ($this:java.util.AbstractMap) returnType:kotlin.collections.Set.MyMap?, V of .MyMap?>?>? [fake_override] - overridden: - public abstract fun entrySet (): kotlin.collections.Set?>? declared in java.util.AbstractMap - $this: VALUE_PARAMETER name: type:java.util.AbstractMap FUN FAKE_OVERRIDE name:clone visibility:protected/*protected and package*/ modality:OPEN <> ($this:java.util.AbstractMap) returnType:kotlin.Any? [fake_override] overridden: - protected/*protected and package*/ open fun clone (): kotlin.Any? declared in java.util.AbstractMap + protected/*protected and package*/ open fun clone (): kotlin.Any? [fake_override] declared in kotlin.collections.AbstractMutableMap $this: VALUE_PARAMETER name: type:java.util.AbstractMap diff --git a/compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.fir.kt.txt b/compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.fir.kt.txt deleted file mode 100644 index e5d0f36e470..00000000000 --- a/compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.fir.kt.txt +++ /dev/null @@ -1,29 +0,0 @@ -annotation class Storage : Annotation { - constructor(value: String) /* primary */ - val value: String - field = value - get - -} - -annotation class State : Annotation { - constructor(name: String, storages: Array) /* primary */ - val name: String - field = name - get - - val storages: Array - field = storages - get - -} - -@State(name = "1", storages = [Storage(value = "HELLO")]) -class Test { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - -} diff --git a/compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.fir.txt b/compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.fir.txt deleted file mode 100644 index 5ee804ae50d..00000000000 --- a/compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.fir.txt +++ /dev/null @@ -1,90 +0,0 @@ -FILE fqName: fileName:/AnnotationInAnnotation.kt - CLASS ANNOTATION_CLASS name:Storage modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Storage - CONSTRUCTOR visibility:public <> (value:kotlin.String) returnType:.Storage [primary] - VALUE_PARAMETER name:value index:0 type:kotlin.String - PROPERTY name:value visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.String visibility:private [final] - EXPRESSION_BODY - GET_VAR 'value: kotlin.String declared in .Storage.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Storage) returnType:kotlin.String - correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Storage - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Storage' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .Storage declared in .Storage.' type=.Storage origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ANNOTATION_CLASS name:State modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.State - CONSTRUCTOR visibility:public <> (name:kotlin.String, storages:kotlin.Array<.Storage>) returnType:.State [primary] - VALUE_PARAMETER name:name index:0 type:kotlin.String - VALUE_PARAMETER name:storages index:1 type:kotlin.Array<.Storage> - PROPERTY name:name visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final] - EXPRESSION_BODY - GET_VAR 'name: kotlin.String declared in .State.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.State) returnType:kotlin.String - correspondingProperty: PROPERTY name:name visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.State - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .State' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .State declared in .State.' type=.State origin=null - PROPERTY name:storages visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:storages type:kotlin.Array<.Storage> visibility:private [final] - EXPRESSION_BODY - GET_VAR 'storages: kotlin.Array<.Storage> declared in .State.' type=kotlin.Array<.Storage> origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.State) returnType:kotlin.Array<.Storage> - correspondingProperty: PROPERTY name:storages visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.State - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Array<.Storage> declared in .State' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:storages type:kotlin.Array<.Storage> visibility:private [final]' type=kotlin.Array<.Storage> origin=null - receiver: GET_VAR ': .State declared in .State.' type=.State origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any] - annotations: - State(name = '1', storages = [Storage(value = 'HELLO')]) - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test - CONSTRUCTOR visibility:public <> () returnType:.Test [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.kt b/compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.kt index c7b07c1b040..f941e26c082 100644 --- a/compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.kt +++ b/compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: Some.java public class Some { diff --git a/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.txt b/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.txt index e450d609bc7..ecff130ab23 100644 --- a/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.txt +++ b/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.txt @@ -78,16 +78,16 @@ FILE fqName: fileName:/AnnotationLoader.kt $this: VALUE_PARAMETER name: type:.Visitor FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visitor $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visitor $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visitor $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .AnnotationLoader.loadAnnotation..visitArray.' type=.AnnotationLoader.loadAnnotation..visitArray. origin=OBJECT_LITERAL FUN name:visitAnnotation visibility:public modality:FINAL <> ($this:.AnnotationLoader.loadAnnotation.) returnType:.Visitor? @@ -136,16 +136,16 @@ FILE fqName: fileName:/AnnotationLoader.kt BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visitor $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visitor $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visitor $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .AnnotationLoader.loadAnnotation..visitAnnotation.' type=.AnnotationLoader.loadAnnotation..visitAnnotation. origin=OBJECT_LITERAL FUN name:foo visibility:private modality:FINAL <> ($this:.AnnotationLoader.loadAnnotation.) returnType:kotlin.Unit @@ -153,16 +153,16 @@ FILE fqName: fileName:/AnnotationLoader.kt BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visitor $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visitor $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visitor $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .AnnotationLoader.loadAnnotation.' type=.AnnotationLoader.loadAnnotation. origin=OBJECT_LITERAL FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] diff --git a/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt b/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt index 074f31191fa..a83ecfba126 100644 --- a/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt +++ b/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt @@ -152,7 +152,7 @@ FILE fqName: fileName:/ClashResolutionDescriptor.kt BLOCK type=kotlin.collections.Collection<.ComponentDescriptor> origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.collections.Collection<.ComponentDescriptor>? [val] TYPE_OP type=kotlin.collections.Collection<.ComponentDescriptor>? origin=SAFE_CAST typeOperand=kotlin.collections.Collection<.ComponentDescriptor> - CALL 'public open fun get (p0: K of java.util.HashMap?): @[FlexibleNullability] V of java.util.HashMap? [operator] declared in java.util.HashMap' type=kotlin.Any? origin=null + CALL 'public open fun get (p0: @[FlexibleNullability] K of java.util.HashMap?): @[FlexibleNullability] V of java.util.HashMap? [operator] declared in java.util.HashMap' type=kotlin.Any? origin=null $this: CALL 'private final fun (): java.util.HashMap declared in ' type=java.util.HashMap origin=GET_PROPERTY p0: CALL 'public final fun (): java.lang.Class.PlatformExtensionsClashResolver> declared in .PlatformExtensionsClashResolver' type=java.lang.Class.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension>>>>> origin=GET_PROPERTY $this: GET_VAR 'val resolver: .PlatformExtensionsClashResolver<*> [val] declared in .resolveClashesIfAny' type=.PlatformExtensionsClashResolver<*> origin=null diff --git a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.txt b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.txt index 4f07bf8fbd4..52315b38e74 100644 --- a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.txt +++ b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.txt @@ -49,16 +49,19 @@ FILE fqName: fileName:/DeepCopyIrTree.kt VALUE_PARAMETER name: index:0 type:kotlin.collections.List<.IrTypeParameter> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IrDeclaration + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IrDeclarationParent $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IrDeclaration + public open fun hashCode (): kotlin.Int [fake_override] declared in .IrDeclarationParent $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IrDeclaration + public open fun toString (): kotlin.String [fake_override] declared in .IrDeclarationParent $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:IrDeclaration modality:ABSTRACT visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrDeclaration @@ -83,16 +86,16 @@ FILE fqName: fileName:/DeepCopyIrTree.kt $this: VALUE_PARAMETER name: type:.IrTypeParameter FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IrDeclaration $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IrDeclaration $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IrDeclaration $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:IrDeclarationParent modality:ABSTRACT visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IrDeclarationParent diff --git a/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.kt.txt b/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.kt.txt index 5ae5a47c206..bc666aded76 100644 --- a/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.kt.txt @@ -57,4 +57,3 @@ class Impl : A, B { fun box(): String { return "OK" } - diff --git a/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.txt b/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.txt index 6d6bb4ab0cc..c3f06d5448d 100644 --- a/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.txt +++ b/compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.fir.txt @@ -8,7 +8,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Impl modality:FINAL visibility:public superTypes:[.Foo.A; .Foo.B]' FUN DELEGATED_MEMBER name:add visibility:public modality:OPEN <> ($this:.Impl, element:kotlin.String?) returnType:kotlin.Boolean overridden: - public abstract fun add (element: E of kotlin.collections.MutableSet): kotlin.Boolean declared in kotlin.collections.MutableSet + public abstract fun add (element: kotlin.String?): kotlin.Boolean [fake_override] declared in .Foo.A $this: VALUE_PARAMETER name: type:.Impl VALUE_PARAMETER name:element index:0 type:kotlin.String? BLOCK_BODY @@ -19,7 +19,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt element: GET_VAR 'element: kotlin.String? declared in .Impl.add' type=kotlin.String? origin=null FUN DELEGATED_MEMBER name:addAll visibility:public modality:OPEN <> ($this:.Impl, elements:kotlin.collections.Collection) returnType:kotlin.Boolean overridden: - public abstract fun addAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet + public abstract fun addAll (elements: kotlin.collections.Collection): kotlin.Boolean [fake_override] declared in .Foo.A $this: VALUE_PARAMETER name: type:.Impl VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection BLOCK_BODY @@ -30,7 +30,8 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt elements: GET_VAR 'elements: kotlin.collections.Collection declared in .Impl.addAll' type=kotlin.collections.Collection origin=null FUN DELEGATED_MEMBER name:clear visibility:public modality:OPEN <> ($this:.Impl) returnType:kotlin.Unit overridden: - public abstract fun clear (): kotlin.Unit declared in kotlin.collections.MutableSet + public abstract fun clear (): kotlin.Unit [fake_override] declared in .Foo.A + public abstract fun clear (): kotlin.Unit [fake_override] declared in .Foo.B $this: VALUE_PARAMETER name: type:.Impl BLOCK_BODY CALL 'public abstract fun clear (): kotlin.Unit declared in kotlin.collections.MutableSet' type=kotlin.Unit origin=null @@ -38,7 +39,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt receiver: GET_VAR ': .Impl declared in .Impl.clear' type=.Impl origin=null FUN DELEGATED_MEMBER name:iterator visibility:public modality:OPEN <> ($this:.Impl) returnType:kotlin.collections.MutableIterator [operator] overridden: - public abstract fun iterator (): kotlin.collections.MutableIterator [operator] declared in kotlin.collections.MutableSet + public abstract fun iterator (): kotlin.collections.MutableIterator [fake_override,operator] declared in .Foo.A $this: VALUE_PARAMETER name: type:.Impl BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun iterator (): kotlin.collections.MutableIterator [operator] declared in .Impl' @@ -47,7 +48,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt receiver: GET_VAR ': .Impl declared in .Impl.iterator' type=.Impl origin=null FUN DELEGATED_MEMBER name:remove visibility:public modality:OPEN <> ($this:.Impl, element:kotlin.String?) returnType:kotlin.Boolean overridden: - public abstract fun remove (element: E of kotlin.collections.MutableSet): kotlin.Boolean declared in kotlin.collections.MutableSet + public abstract fun remove (element: kotlin.String?): kotlin.Boolean [fake_override] declared in .Foo.A $this: VALUE_PARAMETER name: type:.Impl VALUE_PARAMETER name:element index:0 type:kotlin.String? BLOCK_BODY @@ -58,7 +59,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt element: GET_VAR 'element: kotlin.String? declared in .Impl.remove' type=kotlin.String? origin=null FUN DELEGATED_MEMBER name:removeAll visibility:public modality:OPEN <> ($this:.Impl, elements:kotlin.collections.Collection) returnType:kotlin.Boolean overridden: - public abstract fun removeAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet + public abstract fun removeAll (elements: kotlin.collections.Collection): kotlin.Boolean [fake_override] declared in .Foo.A $this: VALUE_PARAMETER name: type:.Impl VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection BLOCK_BODY @@ -69,7 +70,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt elements: GET_VAR 'elements: kotlin.collections.Collection declared in .Impl.removeAll' type=kotlin.collections.Collection origin=null FUN DELEGATED_MEMBER name:retainAll visibility:public modality:OPEN <> ($this:.Impl, elements:kotlin.collections.Collection) returnType:kotlin.Boolean overridden: - public abstract fun retainAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.MutableSet + public abstract fun retainAll (elements: kotlin.collections.Collection): kotlin.Boolean [fake_override] declared in .Foo.A $this: VALUE_PARAMETER name: type:.Impl VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection BLOCK_BODY @@ -80,7 +81,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt elements: GET_VAR 'elements: kotlin.collections.Collection declared in .Impl.retainAll' type=kotlin.collections.Collection origin=null FUN DELEGATED_MEMBER name:contains visibility:public modality:OPEN <> ($this:.Impl, element:kotlin.String?) returnType:kotlin.Boolean [operator] overridden: - public abstract fun contains (element: E of kotlin.collections.Set): kotlin.Boolean [operator] declared in kotlin.collections.Set + public abstract fun contains (element: kotlin.String?): kotlin.Boolean [fake_override,operator] declared in .Foo.A $this: VALUE_PARAMETER name: type:.Impl VALUE_PARAMETER name:element index:0 type:kotlin.String? BLOCK_BODY @@ -91,7 +92,7 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt element: GET_VAR 'element: kotlin.String? declared in .Impl.contains' type=kotlin.String? origin=null FUN DELEGATED_MEMBER name:containsAll visibility:public modality:OPEN <> ($this:.Impl, elements:kotlin.collections.Collection) returnType:kotlin.Boolean overridden: - public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean [fake_override] declared in kotlin.collections.MutableSet + public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean [fake_override] declared in .Foo.A $this: VALUE_PARAMETER name: type:.Impl VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection BLOCK_BODY @@ -102,7 +103,8 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt elements: GET_VAR 'elements: kotlin.collections.Collection declared in .Impl.containsAll' type=kotlin.collections.Collection origin=null FUN DELEGATED_MEMBER name:isEmpty visibility:public modality:OPEN <> ($this:.Impl) returnType:kotlin.Boolean overridden: - public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Set + public abstract fun isEmpty (): kotlin.Boolean [fake_override] declared in .Foo.A + public abstract fun isEmpty (): kotlin.Boolean [fake_override] declared in .Foo.B $this: VALUE_PARAMETER name: type:.Impl BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun isEmpty (): kotlin.Boolean declared in .Impl' @@ -113,7 +115,8 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Impl) returnType:kotlin.Int correspondingProperty: PROPERTY DELEGATED_MEMBER name:size visibility:public modality:OPEN [val] overridden: - public abstract fun (): kotlin.Int declared in kotlin.collections.Set + public abstract fun (): kotlin.Int [fake_override] declared in .Foo.A + public abstract fun (): kotlin.Int [fake_override] declared in .Foo.B $this: VALUE_PARAMETER name: type:.Impl BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .Impl' @@ -125,16 +128,19 @@ FILE fqName: fileName:/DelegationAndInheritanceFromJava.kt GET_VAR 'b: .Foo.B declared in .Impl.' type=.Foo.B origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Foo.A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Foo.B $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Foo.A + public open fun hashCode (): kotlin.Int [fake_override] declared in .Foo.B $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Foo.A + public open fun toString (): kotlin.String [fake_override] declared in .Foo.B $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY diff --git a/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.txt b/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.txt index 6ae4fdc9f10..26440e33b2d 100644 --- a/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.txt +++ b/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.txt @@ -94,16 +94,16 @@ FILE fqName: fileName:/Fir2IrClassifierStorage.kt value: GET_VAR ': .Fir2IrClassifierStorage declared in .Fir2IrComponentsStorage.' type=.Fir2IrClassifierStorage origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Fir2IrComponents $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Fir2IrComponents $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Fir2IrComponents $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Fir2IrClassifierStorage modality:FINAL visibility:public superTypes:[.Fir2IrComponents] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Fir2IrClassifierStorage @@ -163,14 +163,14 @@ FILE fqName: fileName:/Fir2IrClassifierStorage.kt receiver: GET_VAR ': .Fir2IrClassifierStorage declared in .Fir2IrClassifierStorage.' type=.Fir2IrClassifierStorage origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Fir2IrComponents $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Fir2IrComponents $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Fir2IrComponents $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/FirBuilder.fir.kt.txt b/compiler/testData/ir/irText/firProblems/FirBuilder.fir.kt.txt index aab5e1a0795..d56baa62270 100644 --- a/compiler/testData/ir/irText/firProblems/FirBuilder.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/FirBuilder.fir.kt.txt @@ -34,4 +34,3 @@ class DeclarationsConverter : BaseConverter { } } - diff --git a/compiler/testData/ir/irText/firProblems/FirBuilder.fir.txt b/compiler/testData/ir/irText/firProblems/FirBuilder.fir.txt index 107db8c8551..bf1de0cbdc6 100644 --- a/compiler/testData/ir/irText/firProblems/FirBuilder.fir.txt +++ b/compiler/testData/ir/irText/firProblems/FirBuilder.fir.txt @@ -45,16 +45,16 @@ FILE fqName: fileName:/FirBuilder.kt VALUE_PARAMETER name:block index:0 type:kotlin.Function0.BaseConverter.withCapturedTypeParameters> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .BaseFirBuilder $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .BaseFirBuilder $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .BaseFirBuilder $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:DeclarationsConverter modality:FINAL visibility:public superTypes:[.BaseConverter] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DeclarationsConverter @@ -64,20 +64,20 @@ FILE fqName: fileName:/FirBuilder.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DeclarationsConverter modality:FINAL visibility:public superTypes:[.BaseConverter]' FUN FAKE_OVERRIDE name:withCapturedTypeParameters visibility:public modality:FINAL ($this:.BaseFirBuilder.BaseFirBuilder>, block:kotlin.Function0.DeclarationsConverter.withCapturedTypeParameters>) returnType:T of .DeclarationsConverter.withCapturedTypeParameters [inline,fake_override] overridden: - public final fun withCapturedTypeParameters (block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>): T of .BaseFirBuilder.withCapturedTypeParameters [inline] declared in .BaseFirBuilder + public final fun withCapturedTypeParameters (block: kotlin.Function0.BaseConverter.withCapturedTypeParameters>): T of .BaseConverter.withCapturedTypeParameters [inline,fake_override] declared in .BaseConverter TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] $this: VALUE_PARAMETER name: type:.BaseFirBuilder.BaseFirBuilder> VALUE_PARAMETER name:block index:0 type:kotlin.Function0.DeclarationsConverter.withCapturedTypeParameters> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .BaseConverter $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .BaseConverter $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .BaseConverter $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.fir.txt b/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.fir.txt index 06ec0dfc0fe..f3d1264270e 100644 --- a/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.fir.txt +++ b/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.fir.txt @@ -85,16 +85,16 @@ FILE fqName: fileName:/ImplicitReceiverStack.kt receiver: GET_VAR ': .ImplicitReceiverValue.ImplicitReceiverValue> declared in .ImplicitReceiverValue.' type=.ImplicitReceiverValue.ImplicitReceiverValue> origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .ReceiverValue $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .ReceiverValue $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .ReceiverValue $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:ImplicitReceiverStack modality:ABSTRACT visibility:public superTypes:[kotlin.collections.Iterable<.ImplicitReceiverValue<*>>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ImplicitReceiverStack @@ -151,6 +151,7 @@ FILE fqName: fileName:/ImplicitReceiverStack.kt receiver: GET_VAR ': .PersistentImplicitReceiverStack declared in .PersistentImplicitReceiverStack.' type=.PersistentImplicitReceiverStack origin=null FUN name:iterator visibility:public modality:FINAL <> ($this:.PersistentImplicitReceiverStack) returnType:kotlin.collections.Iterator<.ImplicitReceiverValue<*>> [operator] overridden: + public abstract fun iterator (): kotlin.collections.Iterator<.ImplicitReceiverValue<*>> [fake_override,operator] declared in .ImplicitReceiverStack public abstract fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterable $this: VALUE_PARAMETER name: type:.PersistentImplicitReceiverStack BLOCK_BODY @@ -172,26 +173,26 @@ FILE fqName: fileName:/ImplicitReceiverStack.kt FUN FAKE_OVERRIDE name:forEach visibility:public modality:OPEN <> ($this:java.lang.Iterable, p0:java.util.function.Consumer.ImplicitReceiverValue<*>?>?) returnType:kotlin.Unit [fake_override] overridden: public open fun forEach (p0: java.util.function.Consumer.ImplicitReceiverValue<*>?>?): kotlin.Unit [fake_override] declared in .ImplicitReceiverStack - public open fun forEach (p0: java.util.function.Consumer?): kotlin.Unit declared in kotlin.collections.Iterable + public open fun forEach (p0: java.util.function.Consumer?): kotlin.Unit declared in java.lang.Iterable $this: VALUE_PARAMETER name: type:java.lang.Iterable VALUE_PARAMETER name:p0 index:0 type:java.util.function.Consumer.ImplicitReceiverValue<*>?>? FUN FAKE_OVERRIDE name:spliterator visibility:public modality:OPEN <> ($this:java.lang.Iterable) returnType:@[FlexibleNullability] java.util.Spliterator<.ImplicitReceiverValue<*>?> [fake_override] overridden: public open fun spliterator (): @[FlexibleNullability] java.util.Spliterator<.ImplicitReceiverValue<*>?> [fake_override] declared in .ImplicitReceiverStack - public open fun spliterator (): @[FlexibleNullability] java.util.Spliterator declared in kotlin.collections.Iterable + public open fun spliterator (): @[FlexibleNullability] java.util.Spliterator declared in java.lang.Iterable $this: VALUE_PARAMETER name: type:java.lang.Iterable FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .ImplicitReceiverStack $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .ImplicitReceiverStack $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .ImplicitReceiverStack $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:bar visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit VALUE_PARAMETER name:s index:0 type:kotlin.String diff --git a/compiler/testData/ir/irText/firProblems/InnerClassInAnonymous.fir.txt b/compiler/testData/ir/irText/firProblems/InnerClassInAnonymous.fir.txt index c6218892a32..eaa14083f8c 100644 --- a/compiler/testData/ir/irText/firProblems/InnerClassInAnonymous.fir.txt +++ b/compiler/testData/ir/irText/firProblems/InnerClassInAnonymous.fir.txt @@ -55,16 +55,16 @@ FILE fqName: fileName:/InnerClassInAnonymous.kt $this: VALUE_PARAMETER name: type:.box..Base FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .box..Base $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .box..Base $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .box..Base $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:Base modality:OPEN visibility:local [inner] superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.box..Base diff --git a/compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt b/compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt index 1c132ca400a..ff8d5231e28 100644 --- a/compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/Modality.fir.kt.txt @@ -67,4 +67,3 @@ object Final : Modality { } } - diff --git a/compiler/testData/ir/irText/firProblems/Modality.fir.txt b/compiler/testData/ir/irText/firProblems/Modality.fir.txt index 7a33c3b4ced..74070a9e7d3 100644 --- a/compiler/testData/ir/irText/firProblems/Modality.fir.txt +++ b/compiler/testData/ir/irText/firProblems/Modality.fir.txt @@ -136,16 +136,16 @@ FILE fqName: fileName:/Modality.kt CONST String type=kotlin.String value="FAIL" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .ResolutionPart $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .ResolutionPart $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .ResolutionPart $this: VALUE_PARAMETER name: type:kotlin.Any CLASS OBJECT name:Final modality:FINAL visibility:public superTypes:[.Modality] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Final @@ -155,14 +155,14 @@ FILE fqName: fileName:/Modality.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Final modality:FINAL visibility:public superTypes:[.Modality]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Modality $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Modality $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Modality $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/MultiList.fir.txt b/compiler/testData/ir/irText/firProblems/MultiList.fir.txt index e52739c3918..2f0b323d21b 100644 --- a/compiler/testData/ir/irText/firProblems/MultiList.fir.txt +++ b/compiler/testData/ir/irText/firProblems/MultiList.fir.txt @@ -197,13 +197,13 @@ FILE fqName: fileName:/MultiList.kt FUN FAKE_OVERRIDE name:contains visibility:public modality:OPEN <> ($this:kotlin.collections.List, element:.Some.SomeList>) returnType:kotlin.Boolean [fake_override,operator] overridden: public abstract fun contains (element: .Some.MyList>): kotlin.Boolean [fake_override,operator] declared in .MyList - public open fun contains (p0: E of java.util.ArrayList?): kotlin.Boolean [operator] declared in java.util.ArrayList + public open fun contains (p0: @[FlexibleNullability] E of java.util.ArrayList?): kotlin.Boolean [operator] declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:element index:0 type:.Some.SomeList> FUN FAKE_OVERRIDE name:containsAll visibility:public modality:OPEN <> ($this:kotlin.collections.List, elements:kotlin.collections.Collection<.Some.SomeList>>) returnType:kotlin.Boolean [fake_override] overridden: public abstract fun containsAll (elements: kotlin.collections.Collection<.Some.MyList>>): kotlin.Boolean [fake_override] declared in .MyList - public open fun containsAll (p0: kotlin.collections.Collection): kotlin.Boolean declared in java.util.ArrayList + public open fun containsAll (p0: kotlin.collections.Collection<@[FlexibleNullability] E of java.util.ArrayList?>): kotlin.Boolean [fake_override] declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<.Some.SomeList>> FUN FAKE_OVERRIDE name:get visibility:public modality:OPEN <> ($this:kotlin.collections.List, index:kotlin.Int) returnType:.Some.SomeList> [fake_override,operator] @@ -215,12 +215,12 @@ FILE fqName: fileName:/MultiList.kt FUN FAKE_OVERRIDE name:indexOf visibility:public modality:OPEN <> ($this:kotlin.collections.List, element:.Some.SomeList>) returnType:kotlin.Int [fake_override] overridden: public abstract fun indexOf (element: .Some.MyList>): kotlin.Int [fake_override] declared in .MyList - public open fun indexOf (p0: E of java.util.ArrayList?): kotlin.Int declared in java.util.ArrayList + public open fun indexOf (p0: @[FlexibleNullability] E of java.util.ArrayList?): kotlin.Int declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:element index:0 type:.Some.SomeList> FUN FAKE_OVERRIDE name:isEmpty visibility:public modality:OPEN <> ($this:kotlin.collections.List) returnType:kotlin.Boolean [fake_override] overridden: - public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.List + public abstract fun isEmpty (): kotlin.Boolean [fake_override] declared in .MyList public open fun isEmpty (): kotlin.Boolean declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:kotlin.collections.List FUN FAKE_OVERRIDE name:iterator visibility:public modality:OPEN <> ($this:java.util.ArrayList) returnType:@[FlexibleNullability] kotlin.collections.MutableIterator<.Some.SomeList>?> [fake_override,operator] @@ -231,7 +231,7 @@ FILE fqName: fileName:/MultiList.kt FUN FAKE_OVERRIDE name:lastIndexOf visibility:public modality:OPEN <> ($this:kotlin.collections.List, element:.Some.SomeList>) returnType:kotlin.Int [fake_override] overridden: public abstract fun lastIndexOf (element: .Some.MyList>): kotlin.Int [fake_override] declared in .MyList - public open fun lastIndexOf (p0: E of java.util.ArrayList?): kotlin.Int declared in java.util.ArrayList + public open fun lastIndexOf (p0: @[FlexibleNullability] E of java.util.ArrayList?): kotlin.Int declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:element index:0 type:.Some.SomeList> FUN FAKE_OVERRIDE name:listIterator visibility:public modality:OPEN <> ($this:java.util.ArrayList) returnType:@[FlexibleNullability] kotlin.collections.MutableListIterator<.Some.SomeList>?> [fake_override] @@ -252,16 +252,12 @@ FILE fqName: fileName:/MultiList.kt $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Int VALUE_PARAMETER name:p1 index:1 type:kotlin.Int - FUN FAKE_OVERRIDE name:size visibility:public modality:OPEN <> ($this:java.util.ArrayList) returnType:kotlin.Int [fake_override] - overridden: - public open fun size (): kotlin.Int declared in java.util.ArrayList - $this: VALUE_PARAMETER name: type:java.util.ArrayList - PROPERTY FAKE_OVERRIDE name:size visibility:public modality:ABSTRACT [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:kotlin.collections.List) returnType:kotlin.Int [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:size visibility:public modality:ABSTRACT [fake_override,val] + PROPERTY FAKE_OVERRIDE name:size visibility:public modality:OPEN [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:OPEN <> ($this:kotlin.collections.List) returnType:kotlin.Int [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:size visibility:public modality:OPEN [fake_override,val] overridden: - public abstract fun (): kotlin.Int declared in kotlin.collections.List - public abstract fun (): kotlin.Int [fake_override] declared in java.util.ArrayList + public abstract fun (): kotlin.Int [fake_override] declared in .MyList + public open fun (): kotlin.Int declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:kotlin.collections.List FUN FAKE_OVERRIDE name:spliterator visibility:public modality:OPEN <> ($this:java.util.Collection) returnType:@[FlexibleNullability] java.util.Spliterator<.Some.SomeList>?> [fake_override] overridden: @@ -286,18 +282,18 @@ FILE fqName: fileName:/MultiList.kt VALUE_PARAMETER name:p0 index:0 type:java.util.function.Consumer.Some.SomeList>?>? FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .MyList public open fun equals (p0: @[FlexibleNullability] kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .MyList public open fun hashCode (): kotlin.Int [fake_override] declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .MyList public open fun toString (): @[FlexibleNullability] kotlin.String [fake_override] declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:elementData visibility:public/*package*/ modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.Int) returnType:.Some.SomeList>? [fake_override] @@ -345,14 +341,9 @@ FILE fqName: fileName:/MultiList.kt $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Int VALUE_PARAMETER name:p1 index:1 type:.Some.SomeList>? - FUN FAKE_OVERRIDE name:remove visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.Int) returnType:.Some.SomeList>? [fake_override] - overridden: - public open fun remove (p0: kotlin.Int): E of java.util.ArrayList? declared in java.util.ArrayList - $this: VALUE_PARAMETER name: type:java.util.ArrayList - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int FUN FAKE_OVERRIDE name:remove visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:.Some.SomeList>?) returnType:kotlin.Boolean [fake_override] overridden: - public open fun remove (p0: E of java.util.ArrayList?): kotlin.Boolean declared in java.util.ArrayList + public open fun remove (p0: @[FlexibleNullability] E of java.util.ArrayList?): kotlin.Boolean declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:.Some.SomeList>? FUN FAKE_OVERRIDE name:clear visibility:public modality:OPEN <> ($this:java.util.ArrayList) returnType:kotlin.Unit [fake_override] @@ -376,21 +367,21 @@ FILE fqName: fileName:/MultiList.kt $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Int VALUE_PARAMETER name:p1 index:1 type:kotlin.Int - FUN FAKE_OVERRIDE name:removeAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.collections.Collection<.Some.SomeList>>) returnType:kotlin.Boolean [fake_override] + FUN FAKE_OVERRIDE name:removeAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.collections.Collection<.Some.SomeList>?>) returnType:kotlin.Boolean [fake_override] overridden: - public open fun removeAll (p0: kotlin.collections.Collection): kotlin.Boolean declared in java.util.ArrayList + public open fun removeAll (p0: kotlin.collections.Collection<@[FlexibleNullability] E of java.util.ArrayList?>): kotlin.Boolean declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:java.util.ArrayList - VALUE_PARAMETER name:p0 index:0 type:kotlin.collections.Collection<.Some.SomeList>> - FUN FAKE_OVERRIDE name:retainAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.collections.Collection<.Some.SomeList>>) returnType:kotlin.Boolean [fake_override] + VALUE_PARAMETER name:p0 index:0 type:kotlin.collections.Collection<.Some.SomeList>?> + FUN FAKE_OVERRIDE name:retainAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.collections.Collection<.Some.SomeList>?>) returnType:kotlin.Boolean [fake_override] overridden: - public open fun retainAll (p0: kotlin.collections.Collection): kotlin.Boolean declared in java.util.ArrayList + public open fun retainAll (p0: kotlin.collections.Collection<@[FlexibleNullability] E of java.util.ArrayList?>): kotlin.Boolean declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:java.util.ArrayList - VALUE_PARAMETER name:p0 index:0 type:kotlin.collections.Collection<.Some.SomeList>> - FUN FAKE_OVERRIDE name:removeIf visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:java.util.function.Predicate.Some.SomeList>?>?) returnType:kotlin.Boolean [fake_override] + VALUE_PARAMETER name:p0 index:0 type:kotlin.collections.Collection<.Some.SomeList>?> + FUN FAKE_OVERRIDE name:removeIf visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:@[FlexibleNullability] java.util.function.Predicate.Some.SomeList>?>) returnType:kotlin.Boolean [fake_override] overridden: - public open fun removeIf (p0: java.util.function.Predicate?): kotlin.Boolean declared in java.util.ArrayList + public open fun removeIf (p0: @[FlexibleNullability] java.util.function.Predicate): kotlin.Boolean declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:java.util.ArrayList - VALUE_PARAMETER name:p0 index:0 type:java.util.function.Predicate.Some.SomeList>?>? + VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] java.util.function.Predicate.Some.SomeList>?> FUN FAKE_OVERRIDE name:replaceAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:@[FlexibleNullability] java.util.function.UnaryOperator<.Some.SomeList>?>) returnType:kotlin.Unit [fake_override] overridden: public open fun replaceAll (p0: @[FlexibleNullability] java.util.function.UnaryOperator): kotlin.Unit declared in java.util.ArrayList @@ -403,7 +394,7 @@ FILE fqName: fileName:/MultiList.kt VALUE_PARAMETER name:p0 index:0 type:java.util.Comparator.Some.SomeList>?>? FUN FAKE_OVERRIDE name:removeAt visibility:public modality:ABSTRACT <> ($this:kotlin.collections.MutableList, index:kotlin.Int) returnType:.Some.SomeList>? [fake_override] overridden: - public abstract fun removeAt (index: kotlin.Int): E of kotlin.collections.MutableList declared in kotlin.collections.MutableList + public abstract fun removeAt (index: kotlin.Int): @[FlexibleNullability] E of java.util.ArrayList? [fake_override] declared in java.util.ArrayList $this: VALUE_PARAMETER name: type:kotlin.collections.MutableList VALUE_PARAMETER name:index index:0 type:kotlin.Int CLASS CLASS name:FinalList modality:FINAL visibility:public superTypes:[.SomeList] @@ -415,200 +406,186 @@ FILE fqName: fileName:/MultiList.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:FinalList modality:FINAL visibility:public superTypes:[.SomeList]' FUN FAKE_OVERRIDE name:contains visibility:public modality:OPEN <> ($this:kotlin.collections.List, element:.Some) returnType:kotlin.Boolean [fake_override,operator] overridden: - public abstract fun contains (element: E of kotlin.collections.List): kotlin.Boolean [operator] declared in kotlin.collections.List + public open fun contains (element: .Some.SomeList>): kotlin.Boolean [fake_override,operator] declared in .SomeList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:element index:0 type:.Some FUN FAKE_OVERRIDE name:containsAll visibility:public modality:OPEN <> ($this:kotlin.collections.List, elements:kotlin.collections.Collection<.Some>) returnType:kotlin.Boolean [fake_override] overridden: - public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.List + public open fun containsAll (elements: kotlin.collections.Collection<.Some.SomeList>>): kotlin.Boolean [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection<.Some> FUN FAKE_OVERRIDE name:get visibility:public modality:OPEN <> ($this:kotlin.collections.List, index:kotlin.Int) returnType:.Some [fake_override,operator] overridden: - public abstract fun get (index: kotlin.Int): E of kotlin.collections.List [operator] declared in kotlin.collections.List + public open fun get (index: kotlin.Int): .Some.SomeList> [fake_override,operator] declared in .SomeList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:index index:0 type:kotlin.Int FUN FAKE_OVERRIDE name:indexOf visibility:public modality:OPEN <> ($this:kotlin.collections.List, element:.Some) returnType:kotlin.Int [fake_override] overridden: - public abstract fun indexOf (element: E of kotlin.collections.List): kotlin.Int declared in kotlin.collections.List + public open fun indexOf (element: .Some.SomeList>): kotlin.Int [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:element index:0 type:.Some FUN FAKE_OVERRIDE name:isEmpty visibility:public modality:OPEN <> ($this:kotlin.collections.List) returnType:kotlin.Boolean [fake_override] overridden: - public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.List - public open fun isEmpty (): kotlin.Boolean declared in java.util.ArrayList + public open fun isEmpty (): kotlin.Boolean [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:kotlin.collections.List FUN FAKE_OVERRIDE name:iterator visibility:public modality:OPEN <> ($this:java.util.ArrayList) returnType:@[FlexibleNullability] kotlin.collections.MutableIterator<.Some?> [fake_override,operator] overridden: - public open fun iterator (): @[FlexibleNullability] kotlin.collections.MutableIterator [operator] declared in java.util.ArrayList + public open fun iterator (): @[FlexibleNullability] kotlin.collections.MutableIterator<.Some.SomeList>?> [fake_override,operator] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList FUN FAKE_OVERRIDE name:lastIndexOf visibility:public modality:OPEN <> ($this:kotlin.collections.List, element:.Some) returnType:kotlin.Int [fake_override] overridden: - public abstract fun lastIndexOf (element: E of kotlin.collections.List): kotlin.Int declared in kotlin.collections.List + public open fun lastIndexOf (element: .Some.SomeList>): kotlin.Int [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:kotlin.collections.List VALUE_PARAMETER name:element index:0 type:.Some FUN FAKE_OVERRIDE name:listIterator visibility:public modality:OPEN <> ($this:java.util.ArrayList) returnType:@[FlexibleNullability] kotlin.collections.MutableListIterator<.Some?> [fake_override] overridden: - public open fun listIterator (): @[FlexibleNullability] kotlin.collections.MutableListIterator declared in java.util.ArrayList + public open fun listIterator (): @[FlexibleNullability] kotlin.collections.MutableListIterator<.Some.SomeList>?> [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList FUN FAKE_OVERRIDE name:listIterator visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.Int) returnType:@[FlexibleNullability] kotlin.collections.MutableListIterator<.Some?> [fake_override] overridden: - public open fun listIterator (p0: kotlin.Int): @[FlexibleNullability] kotlin.collections.MutableListIterator declared in java.util.ArrayList + public open fun listIterator (p0: kotlin.Int): @[FlexibleNullability] kotlin.collections.MutableListIterator<.Some.SomeList>?> [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Int FUN FAKE_OVERRIDE name:subList visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.Int, p1:kotlin.Int) returnType:@[FlexibleNullability] kotlin.collections.MutableList<.Some?> [fake_override] overridden: - public open fun subList (p0: kotlin.Int, p1: kotlin.Int): @[FlexibleNullability] kotlin.collections.MutableList declared in java.util.ArrayList + public open fun subList (p0: kotlin.Int, p1: kotlin.Int): @[FlexibleNullability] kotlin.collections.MutableList<.Some.SomeList>?> [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Int VALUE_PARAMETER name:p1 index:1 type:kotlin.Int - FUN FAKE_OVERRIDE name:size visibility:public modality:OPEN <> ($this:java.util.ArrayList) returnType:kotlin.Int [fake_override] - overridden: - public open fun size (): kotlin.Int declared in java.util.ArrayList - $this: VALUE_PARAMETER name: type:java.util.ArrayList - PROPERTY FAKE_OVERRIDE name:size visibility:public modality:ABSTRACT [fake_override,val] - FUN FAKE_OVERRIDE name: visibility:public modality:ABSTRACT <> ($this:kotlin.collections.List) returnType:kotlin.Int [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:size visibility:public modality:ABSTRACT [fake_override,val] + PROPERTY FAKE_OVERRIDE name:size visibility:public modality:OPEN [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:OPEN <> ($this:kotlin.collections.List) returnType:kotlin.Int [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:size visibility:public modality:OPEN [fake_override,val] overridden: - public abstract fun (): kotlin.Int declared in kotlin.collections.List - public abstract fun (): kotlin.Int [fake_override] declared in java.util.ArrayList + public open fun (): kotlin.Int [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:kotlin.collections.List FUN FAKE_OVERRIDE name:spliterator visibility:public modality:OPEN <> ($this:java.util.Collection) returnType:@[FlexibleNullability] java.util.Spliterator<.Some?> [fake_override] overridden: - public open fun spliterator (): @[FlexibleNullability] java.util.Spliterator declared in java.util.Collection + public open fun spliterator (): @[FlexibleNullability] java.util.Spliterator<.Some.SomeList>?> [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.Collection FUN FAKE_OVERRIDE name:parallelStream visibility:public modality:OPEN <> ($this:java.util.Collection) returnType:@[FlexibleNullability] java.util.stream.Stream<.Some?> [fake_override] overridden: - public open fun parallelStream (): @[FlexibleNullability] java.util.stream.Stream declared in java.util.Collection + public open fun parallelStream (): @[FlexibleNullability] java.util.stream.Stream<.Some.SomeList>?> [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.Collection FUN FAKE_OVERRIDE name:stream visibility:public modality:OPEN <> ($this:java.util.Collection) returnType:@[FlexibleNullability] java.util.stream.Stream<.Some?> [fake_override] overridden: - public open fun stream (): @[FlexibleNullability] java.util.stream.Stream declared in java.util.Collection + public open fun stream (): @[FlexibleNullability] java.util.stream.Stream<.Some.SomeList>?> [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.Collection FUN FAKE_OVERRIDE name:forEach visibility:public modality:OPEN <> ($this:java.lang.Iterable, p0:java.util.function.Consumer.Some?>?) returnType:kotlin.Unit [fake_override] overridden: - public open fun forEach (p0: java.util.function.Consumer?): kotlin.Unit declared in java.lang.Iterable + public open fun forEach (p0: java.util.function.Consumer.Some.SomeList>?>?): kotlin.Unit [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.lang.Iterable VALUE_PARAMETER name:p0 index:0 type:java.util.function.Consumer.Some?>? FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - public open fun equals (p0: @[FlexibleNullability] kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in java.util.ArrayList + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .SomeList $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - public open fun hashCode (): kotlin.Int [fake_override] declared in java.util.ArrayList + public open fun hashCode (): kotlin.Int [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - public open fun toString (): @[FlexibleNullability] kotlin.String [fake_override] declared in java.util.ArrayList + public open fun toString (): kotlin.String [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:elementData visibility:public/*package*/ modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.Int) returnType:.Some? [fake_override] overridden: - public/*package*/ open fun elementData (p0: kotlin.Int): E of java.util.ArrayList? declared in java.util.ArrayList + public/*package*/ open fun elementData (p0: kotlin.Int): .Some.SomeList>? [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Int FUN FAKE_OVERRIDE name:trimToSize visibility:public modality:OPEN <> ($this:java.util.ArrayList) returnType:kotlin.Unit [fake_override] overridden: - public open fun trimToSize (): kotlin.Unit declared in java.util.ArrayList + public open fun trimToSize (): kotlin.Unit [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList FUN FAKE_OVERRIDE name:ensureCapacity visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.Int) returnType:kotlin.Unit [fake_override] overridden: - public open fun ensureCapacity (p0: kotlin.Int): kotlin.Unit declared in java.util.ArrayList + public open fun ensureCapacity (p0: kotlin.Int): kotlin.Unit [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Int FUN FAKE_OVERRIDE name:clone visibility:public modality:OPEN <> ($this:java.util.ArrayList) returnType:@[FlexibleNullability] kotlin.Any [fake_override] overridden: - public open fun clone (): @[FlexibleNullability] kotlin.Any declared in java.util.ArrayList + public open fun clone (): @[FlexibleNullability] kotlin.Any [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <> ($this:java.util.ArrayList) returnType:kotlin.Array? [fake_override] overridden: - public open fun toArray (): kotlin.Array? declared in java.util.ArrayList + public open fun toArray (): kotlin.Array? [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN ($this:java.util.ArrayList, p0:kotlin.Array.FinalList.toArray?>?) returnType:kotlin.Array.FinalList.toArray?>? [fake_override] overridden: - public open fun toArray (p0: kotlin.Array?): kotlin.Array? declared in java.util.ArrayList + public open fun toArray (p0: kotlin.Array.SomeList.toArray?>?): kotlin.Array.SomeList.toArray?>? [fake_override] declared in .SomeList TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Array.FinalList.toArray?>? FUN FAKE_OVERRIDE name:set visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.Int, p1:.Some?) returnType:.Some? [fake_override,operator] overridden: - public open fun set (p0: kotlin.Int, p1: E of java.util.ArrayList?): E of java.util.ArrayList? [operator] declared in java.util.ArrayList + public open fun set (p0: kotlin.Int, p1: .Some.SomeList>?): .Some.SomeList>? [fake_override,operator] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Int VALUE_PARAMETER name:p1 index:1 type:.Some? FUN FAKE_OVERRIDE name:add visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:.Some?) returnType:kotlin.Boolean [fake_override] overridden: - public open fun add (p0: E of java.util.ArrayList?): kotlin.Boolean declared in java.util.ArrayList + public open fun add (p0: .Some.SomeList>?): kotlin.Boolean [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:.Some? FUN FAKE_OVERRIDE name:add visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.Int, p1:.Some?) returnType:kotlin.Unit [fake_override] overridden: - public open fun add (p0: kotlin.Int, p1: E of java.util.ArrayList?): kotlin.Unit declared in java.util.ArrayList + public open fun add (p0: kotlin.Int, p1: .Some.SomeList>?): kotlin.Unit [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Int VALUE_PARAMETER name:p1 index:1 type:.Some? - FUN FAKE_OVERRIDE name:remove visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.Int) returnType:.Some? [fake_override] - overridden: - public open fun remove (p0: kotlin.Int): E of java.util.ArrayList? declared in java.util.ArrayList - $this: VALUE_PARAMETER name: type:java.util.ArrayList - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int FUN FAKE_OVERRIDE name:remove visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:.Some?) returnType:kotlin.Boolean [fake_override] overridden: - public open fun remove (p0: E of java.util.ArrayList?): kotlin.Boolean declared in java.util.ArrayList + public open fun remove (p0: .Some.SomeList>?): kotlin.Boolean [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:.Some? FUN FAKE_OVERRIDE name:clear visibility:public modality:OPEN <> ($this:java.util.ArrayList) returnType:kotlin.Unit [fake_override] overridden: - public open fun clear (): kotlin.Unit declared in java.util.ArrayList + public open fun clear (): kotlin.Unit [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList FUN FAKE_OVERRIDE name:addAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:@[FlexibleNullability] kotlin.collections.Collection.Some?>) returnType:kotlin.Boolean [fake_override] overridden: - public open fun addAll (p0: @[FlexibleNullability] kotlin.collections.Collection): kotlin.Boolean declared in java.util.ArrayList + public open fun addAll (p0: @[FlexibleNullability] kotlin.collections.Collection.Some.SomeList>?>): kotlin.Boolean [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] kotlin.collections.Collection.Some?> FUN FAKE_OVERRIDE name:addAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.Int, p1:@[FlexibleNullability] kotlin.collections.Collection.Some?>) returnType:kotlin.Boolean [fake_override] overridden: - public open fun addAll (p0: kotlin.Int, p1: @[FlexibleNullability] kotlin.collections.Collection): kotlin.Boolean declared in java.util.ArrayList + public open fun addAll (p0: kotlin.Int, p1: @[FlexibleNullability] kotlin.collections.Collection.Some.SomeList>?>): kotlin.Boolean [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Int VALUE_PARAMETER name:p1 index:1 type:@[FlexibleNullability] kotlin.collections.Collection.Some?> FUN FAKE_OVERRIDE name:removeRange visibility:protected/*protected and package*/ modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.Int, p1:kotlin.Int) returnType:kotlin.Unit [fake_override] overridden: - protected/*protected and package*/ open fun removeRange (p0: kotlin.Int, p1: kotlin.Int): kotlin.Unit declared in java.util.ArrayList + protected/*protected and package*/ open fun removeRange (p0: kotlin.Int, p1: kotlin.Int): kotlin.Unit [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:kotlin.Int VALUE_PARAMETER name:p1 index:1 type:kotlin.Int - FUN FAKE_OVERRIDE name:removeAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.collections.Collection<.Some>) returnType:kotlin.Boolean [fake_override] + FUN FAKE_OVERRIDE name:removeAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.collections.Collection<.Some?>) returnType:kotlin.Boolean [fake_override] overridden: - public open fun removeAll (p0: kotlin.collections.Collection): kotlin.Boolean declared in java.util.ArrayList + public open fun removeAll (p0: kotlin.collections.Collection<.Some.SomeList>?>): kotlin.Boolean [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList - VALUE_PARAMETER name:p0 index:0 type:kotlin.collections.Collection<.Some> - FUN FAKE_OVERRIDE name:retainAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.collections.Collection<.Some>) returnType:kotlin.Boolean [fake_override] + VALUE_PARAMETER name:p0 index:0 type:kotlin.collections.Collection<.Some?> + FUN FAKE_OVERRIDE name:retainAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:kotlin.collections.Collection<.Some?>) returnType:kotlin.Boolean [fake_override] overridden: - public open fun retainAll (p0: kotlin.collections.Collection): kotlin.Boolean declared in java.util.ArrayList + public open fun retainAll (p0: kotlin.collections.Collection<.Some.SomeList>?>): kotlin.Boolean [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList - VALUE_PARAMETER name:p0 index:0 type:kotlin.collections.Collection<.Some> - FUN FAKE_OVERRIDE name:removeIf visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:java.util.function.Predicate.Some?>?) returnType:kotlin.Boolean [fake_override] + VALUE_PARAMETER name:p0 index:0 type:kotlin.collections.Collection<.Some?> + FUN FAKE_OVERRIDE name:removeIf visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:@[FlexibleNullability] java.util.function.Predicate.Some?>) returnType:kotlin.Boolean [fake_override] overridden: - public open fun removeIf (p0: java.util.function.Predicate?): kotlin.Boolean declared in java.util.ArrayList + public open fun removeIf (p0: @[FlexibleNullability] java.util.function.Predicate.Some.SomeList>?>): kotlin.Boolean [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList - VALUE_PARAMETER name:p0 index:0 type:java.util.function.Predicate.Some?>? + VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] java.util.function.Predicate.Some?> FUN FAKE_OVERRIDE name:replaceAll visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:@[FlexibleNullability] java.util.function.UnaryOperator<.Some?>) returnType:kotlin.Unit [fake_override] overridden: - public open fun replaceAll (p0: @[FlexibleNullability] java.util.function.UnaryOperator): kotlin.Unit declared in java.util.ArrayList + public open fun replaceAll (p0: @[FlexibleNullability] java.util.function.UnaryOperator<.Some.SomeList>?>): kotlin.Unit [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] java.util.function.UnaryOperator<.Some?> FUN FAKE_OVERRIDE name:sort visibility:public modality:OPEN <> ($this:java.util.ArrayList, p0:java.util.Comparator.Some?>?) returnType:kotlin.Unit [fake_override] overridden: - public open fun sort (p0: java.util.Comparator?): kotlin.Unit declared in java.util.ArrayList + public open fun sort (p0: java.util.Comparator.Some.SomeList>?>?): kotlin.Unit [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:java.util.ArrayList VALUE_PARAMETER name:p0 index:0 type:java.util.Comparator.Some?>? FUN FAKE_OVERRIDE name:removeAt visibility:public modality:ABSTRACT <> ($this:kotlin.collections.MutableList, index:kotlin.Int) returnType:.Some? [fake_override] overridden: - public abstract fun removeAt (index: kotlin.Int): E of kotlin.collections.MutableList declared in kotlin.collections.MutableList + public abstract fun removeAt (index: kotlin.Int): .Some.SomeList>? [fake_override] declared in .SomeList $this: VALUE_PARAMETER name: type:kotlin.collections.MutableList VALUE_PARAMETER name:index index:0 type:kotlin.Int diff --git a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt index c526daa3155..8e59eaa7d2d 100644 --- a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt @@ -76,4 +76,3 @@ data class DataClass : Derived, Delegate { } } - diff --git a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.txt b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.txt index cb1dbac87ff..7e5a5f84ba8 100644 --- a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.txt +++ b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.txt @@ -53,16 +53,16 @@ FILE fqName: fileName:/SignatureClash.kt $this: VALUE_PARAMETER name: type:.Delegate FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:Derived modality:ABSTRACT visibility:public superTypes:[.Delegate] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived @@ -72,16 +72,16 @@ FILE fqName: fileName:/SignatureClash.kt $this: VALUE_PARAMETER name: type:.Delegate FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Delegate $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Delegate $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Delegate $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:DataClass modality:FINAL visibility:public [data] superTypes:[.Derived; .Delegate] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DataClass diff --git a/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.kt.txt b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.kt.txt deleted file mode 100644 index f58c86deb73..00000000000 --- a/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.kt.txt +++ /dev/null @@ -1,39 +0,0 @@ -interface SimpleTypeMarker { - -} - -class SimpleType : SimpleTypeMarker { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - fun foo(): String { - return "OK" - } - -} - -interface User { - fun SimpleTypeMarker.bar(): String { - require(value = is SimpleType) - return /*as SimpleType */.foo() - } - -} - -class UserImpl { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - fun SimpleTypeMarker.bar(): String { - require(value = is SimpleType) - return /*as SimpleType */.foo() - } - -} - diff --git a/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.txt b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.txt deleted file mode 100644 index 43d658ac456..00000000000 --- a/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.txt +++ /dev/null @@ -1,96 +0,0 @@ -FILE fqName: fileName:/SimpleTypeMarker.kt - CLASS INTERFACE name:SimpleTypeMarker modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.SimpleTypeMarker - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:SimpleType modality:FINAL visibility:public superTypes:[.SimpleTypeMarker] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.SimpleType - CONSTRUCTOR visibility:public <> () returnType:.SimpleType [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:SimpleType modality:FINAL visibility:public superTypes:[.SimpleTypeMarker]' - FUN name:foo visibility:public modality:FINAL <> ($this:.SimpleType) returnType:kotlin.String - $this: VALUE_PARAMETER name: type:.SimpleType - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.String declared in .SimpleType' - CONST String type=kotlin.String value="OK" - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS INTERFACE name:User modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.User - FUN name:bar visibility:public modality:OPEN <> ($this:.User, $receiver:.SimpleTypeMarker) returnType:kotlin.String - $this: VALUE_PARAMETER name: type:.User - $receiver: VALUE_PARAMETER name: type:.SimpleTypeMarker - BLOCK_BODY - CALL 'public final fun require (value: kotlin.Boolean): kotlin.Unit [inline] declared in kotlin.PreconditionsKt' type=kotlin.Unit origin=null - value: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.SimpleType - GET_VAR ': .SimpleTypeMarker declared in .User.bar' type=.SimpleTypeMarker origin=null - RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.String declared in .User' - CALL 'public final fun foo (): kotlin.String declared in .SimpleType' type=kotlin.String origin=null - $this: TYPE_OP type=.SimpleType origin=IMPLICIT_CAST typeOperand=.SimpleType - GET_VAR ': .SimpleTypeMarker declared in .User.bar' type=.SimpleTypeMarker origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS CLASS name:UserImpl modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.UserImpl - CONSTRUCTOR visibility:public <> () returnType:.UserImpl [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:UserImpl modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:bar visibility:public modality:FINAL <> ($this:.UserImpl, $receiver:.SimpleTypeMarker) returnType:kotlin.String - $this: VALUE_PARAMETER name: type:.UserImpl - $receiver: VALUE_PARAMETER name: type:.SimpleTypeMarker - BLOCK_BODY - CALL 'public final fun require (value: kotlin.Boolean): kotlin.Unit [inline] declared in kotlin.PreconditionsKt' type=kotlin.Unit origin=null - value: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.SimpleType - GET_VAR ': .SimpleTypeMarker declared in .UserImpl.bar' type=.SimpleTypeMarker origin=null - RETURN type=kotlin.Nothing from='public final fun bar (): kotlin.String declared in .UserImpl' - CALL 'public final fun foo (): kotlin.String declared in .SimpleType' type=kotlin.String origin=null - $this: TYPE_OP type=.SimpleType origin=IMPLICIT_CAST typeOperand=.SimpleType - GET_VAR ': .SimpleTypeMarker declared in .UserImpl.bar' type=.SimpleTypeMarker origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt index efce8922b20..43e549a3258 100644 --- a/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt +++ b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // WITH_RUNTIME interface SimpleTypeMarker diff --git a/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.txt b/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.txt index 5b064e770a5..9ee482fc545 100644 --- a/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.txt +++ b/compiler/testData/ir/irText/firProblems/candidateSymbol.fir.txt @@ -113,16 +113,19 @@ FILE fqName: fileName:/candidateSymbol.kt $this: VALUE_PARAMETER name: type:.FirCallableMemberDeclaration.FirCallableMemberDeclaration> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .FirSymbolOwner + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .FirDeclaration $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .FirSymbolOwner + public open fun hashCode (): kotlin.Int [fake_override] declared in .FirDeclaration $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .FirSymbolOwner + public open fun toString (): kotlin.String [fake_override] declared in .FirDeclaration $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:foo visibility:public modality:FINAL <> (candidate:.Candidate) returnType:kotlin.Unit VALUE_PARAMETER name:candidate index:0 type:.Candidate diff --git a/compiler/testData/ir/irText/firProblems/kt19251.fir.txt b/compiler/testData/ir/irText/firProblems/kt19251.fir.txt index c3a84e3562b..f2cf0e55ff7 100644 --- a/compiler/testData/ir/irText/firProblems/kt19251.fir.txt +++ b/compiler/testData/ir/irText/firProblems/kt19251.fir.txt @@ -14,7 +14,7 @@ FILE fqName: fileName:/test.kt RETURN type=kotlin.Nothing from='local final fun (it: kotlin.String?): kotlin.String? declared in .box' CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' - CALL 'public open fun computeIfAbsent (p0: K of kotlin.collections.MutableMap, p1: @[FlexibleNullability] java.util.function.Function): V of kotlin.collections.MutableMap declared in kotlin.collections.MutableMap' type=kotlin.String origin=null + CALL 'public open fun computeIfAbsent (p0: @[FlexibleNullability] K of java.util.Map, p1: @[FlexibleNullability] java.util.function.Function): @[FlexibleNullability] V of java.util.Map declared in java.util.Map' type=kotlin.String origin=null $this: GET_VAR 'val map: kotlin.collections.MutableMap<.Fun, kotlin.String> [val] declared in .box' type=kotlin.collections.MutableMap<.Fun, kotlin.String> origin=null p0: GET_VAR 'val fn: .Fun [val] declared in .box' type=.Fun origin=null p1: TYPE_OP type=@[FlexibleNullability] java.util.function.Function<.Fun?, kotlin.String?> origin=SAM_CONVERSION typeOperand=@[FlexibleNullability] java.util.function.Function<.Fun?, kotlin.String?> diff --git a/compiler/testData/ir/irText/firProblems/kt43342.fir.txt b/compiler/testData/ir/irText/firProblems/kt43342.fir.txt index a5076e5d6e0..268f0fc90a9 100644 --- a/compiler/testData/ir/irText/firProblems/kt43342.fir.txt +++ b/compiler/testData/ir/irText/firProblems/kt43342.fir.txt @@ -179,6 +179,9 @@ FILE fqName: fileName:/kt43342.kt $this: VALUE_PARAMETER name: type:.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> VALUE_PARAMETER name:key index:0 type:kotlin.String FUN FAKE_OVERRIDE name:getOrDefault visibility:public modality:OPEN <> ($this:.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo>, key:kotlin.String, defaultValue:kotlin.String) returnType:kotlin.String [fake_override] + annotations: + SinceKotlin(version = '1.1') + PlatformDependent overridden: public open fun getOrDefault (key: K of .ControlFlowInfo, defaultValue: V of .ControlFlowInfo): V of .ControlFlowInfo declared in .ControlFlowInfo $this: VALUE_PARAMETER name: type:.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> @@ -214,14 +217,14 @@ FILE fqName: fileName:/kt43342.kt $this: VALUE_PARAMETER name: type:.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .ControlFlowInfo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .ControlFlowInfo $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .ControlFlowInfo $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/putIfAbsent.fir.txt b/compiler/testData/ir/irText/firProblems/putIfAbsent.fir.txt index c3f972b808e..810b15fd1f9 100644 --- a/compiler/testData/ir/irText/firProblems/putIfAbsent.fir.txt +++ b/compiler/testData/ir/irText/firProblems/putIfAbsent.fir.txt @@ -16,7 +16,7 @@ FILE fqName: fileName:/putIfAbsent.kt : T of .Owner.foo : T of .Owner.foo TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public open fun putIfAbsent (p0: K of kotlin.collections.MutableMap, p1: V of kotlin.collections.MutableMap): V of kotlin.collections.MutableMap? declared in kotlin.collections.MutableMap' type=T of .Owner.foo? origin=null + CALL 'public open fun putIfAbsent (p0: @[FlexibleNullability] K of java.util.Map, p1: @[FlexibleNullability] V of java.util.Map): @[FlexibleNullability] V of java.util.Map? declared in java.util.Map' type=T of .Owner.foo? origin=null $this: GET_VAR 'val map: kotlin.collections.MutableMap.Owner.foo, T of .Owner.foo> [val] declared in .Owner.foo' type=kotlin.collections.MutableMap.Owner.foo, T of .Owner.foo> origin=null p0: GET_VAR 'x: T of .Owner.foo declared in .Owner.foo' type=T of .Owner.foo origin=null p1: GET_VAR 'y: T of .Owner.foo declared in .Owner.foo' type=T of .Owner.foo origin=null diff --git a/compiler/testData/ir/irText/firProblems/readWriteProperty.fir.txt b/compiler/testData/ir/irText/firProblems/readWriteProperty.fir.txt index 01d05d7d1cb..ae0aba9fcfe 100644 --- a/compiler/testData/ir/irText/firProblems/readWriteProperty.fir.txt +++ b/compiler/testData/ir/irText/firProblems/readWriteProperty.fir.txt @@ -185,16 +185,16 @@ FILE fqName: fileName:/readWriteProperty.kt $this: GET_VAR 'reference: .SettingReference.IdeWizard.setting, T of .IdeWizard.setting> declared in .IdeWizard.setting' type=.SettingReference.IdeWizard.setting, T of .IdeWizard.setting> origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.properties.ReadWriteProperty $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.properties.ReadWriteProperty $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in kotlin.properties.ReadWriteProperty $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .IdeWizard.setting.' type=.IdeWizard.setting..IdeWizard.setting, T of .IdeWizard.setting> origin=OBJECT_LITERAL FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] diff --git a/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.fir.txt b/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.fir.txt index 9873d8f2b43..ce24e7a2801 100644 --- a/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.fir.txt +++ b/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.fir.txt @@ -107,16 +107,16 @@ FILE fqName: fileName:/typeVariableAfterBuildMap.kt $this: VALUE_PARAMETER name: type:.Visibility FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any CLASS OBJECT name:PrivateToThis modality:FINAL visibility:public superTypes:[.Visibility] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Visibilities.PrivateToThis @@ -162,16 +162,16 @@ FILE fqName: fileName:/typeVariableAfterBuildMap.kt $this: VALUE_PARAMETER name: type:.Visibility FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any CLASS OBJECT name:Protected modality:FINAL visibility:public superTypes:[.Visibility] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Visibilities.Protected @@ -214,16 +214,16 @@ FILE fqName: fileName:/typeVariableAfterBuildMap.kt $this: VALUE_PARAMETER name: type:.Visibility FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any CLASS OBJECT name:Internal modality:FINAL visibility:public superTypes:[.Visibility] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Visibilities.Internal @@ -266,16 +266,16 @@ FILE fqName: fileName:/typeVariableAfterBuildMap.kt $this: VALUE_PARAMETER name: type:.Visibility FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any CLASS OBJECT name:Public modality:FINAL visibility:public superTypes:[.Visibility] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Visibilities.Public @@ -318,16 +318,16 @@ FILE fqName: fileName:/typeVariableAfterBuildMap.kt $this: VALUE_PARAMETER name: type:.Visibility FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any CLASS OBJECT name:Local modality:FINAL visibility:public superTypes:[.Visibility] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Visibilities.Local @@ -370,16 +370,16 @@ FILE fqName: fileName:/typeVariableAfterBuildMap.kt $this: VALUE_PARAMETER name: type:.Visibility FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any CLASS OBJECT name:Inherited modality:FINAL visibility:public superTypes:[.Visibility] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Visibilities.Inherited @@ -423,16 +423,16 @@ FILE fqName: fileName:/typeVariableAfterBuildMap.kt $this: VALUE_PARAMETER name: type:.Visibility FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any CLASS OBJECT name:InvisibleFake modality:FINAL visibility:public superTypes:[.Visibility] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Visibilities.InvisibleFake @@ -478,16 +478,16 @@ FILE fqName: fileName:/typeVariableAfterBuildMap.kt $this: VALUE_PARAMETER name: type:.Visibility FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any CLASS OBJECT name:Unknown modality:FINAL visibility:public superTypes:[.Visibility] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Visibilities.Unknown @@ -531,16 +531,16 @@ FILE fqName: fileName:/typeVariableAfterBuildMap.kt $this: VALUE_PARAMETER name: type:.Visibility FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Visibility $this: VALUE_PARAMETER name: type:kotlin.Any PROPERTY name:ORDERED_VISIBILITIES visibility:private modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:ORDERED_VISIBILITIES type:kotlin.collections.Map<.Visibility, kotlin.Int> visibility:private [final] diff --git a/compiler/testData/ir/irText/regressions/integerCoercionToT.fir.txt b/compiler/testData/ir/irText/regressions/integerCoercionToT.fir.txt index f6d21f1e33a..d1446801802 100644 --- a/compiler/testData/ir/irText/regressions/integerCoercionToT.fir.txt +++ b/compiler/testData/ir/irText/regressions/integerCoercionToT.fir.txt @@ -30,16 +30,16 @@ FILE fqName: fileName:/integerCoercionToT.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:CInt32VarX modality:FINAL visibility:public superTypes:[.CPointed]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .CPointed $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .CPointed $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .CPointed $this: VALUE_PARAMETER name: type:kotlin.Any PROPERTY name:value visibility:public modality:FINAL [var] FUN name: visibility:public modality:FINAL ($receiver:.CInt32VarX.>) returnType:T_INT of . @@ -75,16 +75,16 @@ FILE fqName: fileName:/integerCoercionToT.kt receiver: GET_VAR ': .IdType declared in .IdType.' type=.IdType origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .CPointed $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .CPointed $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .CPointed $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:foo visibility:public modality:FINAL <> (value:.IdType, cv:.CInt32VarX) returnType:kotlin.Unit VALUE_PARAMETER name:value index:0 type:.IdType diff --git a/compiler/testData/ir/irText/singletons/enumEntry.fir.txt b/compiler/testData/ir/irText/singletons/enumEntry.fir.txt index 0d3147e7259..ba39fe36fb1 100644 --- a/compiler/testData/ir/irText/singletons/enumEntry.fir.txt +++ b/compiler/testData/ir/irText/singletons/enumEntry.fir.txt @@ -45,37 +45,37 @@ FILE fqName: fileName:/enumEntry.kt $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: - protected final fun clone (): kotlin.Any declared in kotlin.Enum + protected final fun clone (): kotlin.Any [fake_override] declared in .Z $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.Z) returnType:kotlin.Int [fake_override,operator] overridden: - public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + public final fun compareTo (other: .Z): kotlin.Int [fake_override,operator] declared in .Z $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:.Z FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public final fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Enum + public final fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Z $this: VALUE_PARAMETER name: type:kotlin.Enum VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] overridden: - public final fun hashCode (): kotlin.Int declared in kotlin.Enum + public final fun hashCode (): kotlin.Int [fake_override] declared in .Z $this: VALUE_PARAMETER name: type:kotlin.Enum FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Enum + public open fun toString (): kotlin.String [fake_override] declared in .Z $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.String [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.String declared in kotlin.Enum + public final fun (): kotlin.String [fake_override] declared in .Z $this: VALUE_PARAMETER name: type:kotlin.Enum PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Int [fake_override] correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] overridden: - public final fun (): kotlin.Int declared in kotlin.Enum + public final fun (): kotlin.Int [fake_override] declared in .Z $this: VALUE_PARAMETER name: type:kotlin.Enum FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<.Z> SYNTHETIC_BODY kind=ENUM_VALUES diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.fir.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.fir.txt index 6c4b4159ebf..61e99d4c78a 100644 --- a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.fir.txt +++ b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.fir.txt @@ -130,14 +130,14 @@ FILE fqName: fileName:/genericClassInDifferentModule_m2.kt $this: VALUE_PARAMETER name: type:.Base.Base> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Base $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/stubs/javaInnerClass.fir.txt b/compiler/testData/ir/irText/stubs/javaInnerClass.fir.txt index 4c7ba6d3011..f44505a0230 100644 --- a/compiler/testData/ir/irText/stubs/javaInnerClass.fir.txt +++ b/compiler/testData/ir/irText/stubs/javaInnerClass.fir.txt @@ -23,14 +23,14 @@ FILE fqName: fileName:/javaInnerClass.kt $this: VALUE_PARAMETER name: type:.J FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt index 51368d44897..e902faac3ee 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt @@ -176,16 +176,16 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .FlowCollector $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .FlowCollector $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .FlowCollector $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:flow visibility:public modality:FINAL (block:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.flow>, kotlin.Unit>) returnType:.Flow.flow> annotations: @@ -325,16 +325,19 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt $this: VALUE_PARAMETER name: type:.ProducerScope.ProducerScope> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .CoroutineScope + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .SendChannel $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .CoroutineScope + public open fun hashCode (): kotlin.Int [fake_override] declared in .SendChannel $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .CoroutineScope + public open fun toString (): kotlin.String [fake_override] declared in .SendChannel $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:send visibility:public modality:ABSTRACT <> ($this:.SendChannel.SendChannel>, e:E of .ProducerScope) returnType:kotlin.Unit [suspend,fake_override] overridden: diff --git a/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.txt b/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.txt index 3e3d08e97bc..21eccadcd6a 100644 --- a/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.txt +++ b/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.txt @@ -141,16 +141,16 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt $this: GET_VAR ': .CR.CR> declared in .CR.foo' type=.CR.CR> origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IR $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IR $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IR $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:P modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.P.P, P2 of .P> @@ -259,16 +259,16 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt $this: GET_VAR 't: F22T of .additionalText$delegate..deepO$delegate..qux22 declared in .additionalText$delegate..deepO$delegate..qux22' type=F22T of .additionalText$delegate..deepO$delegate..qux22 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IDelegate1 $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IDelegate1 $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IDelegate1 $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .additionalText$delegate..deepO$delegate.' type=.additionalText$delegate..deepO$delegate..> origin=OBJECT_LITERAL FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.additionalText$delegate..>, $receiver:.Value., .CR.>>) returnType:T of . @@ -306,16 +306,16 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt $this: GET_VAR 't: .Value., .CR.>> declared in .additionalText$delegate..deepK$delegate..getValue' type=.Value., .CR.>> origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IDelegate1 $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IDelegate1 $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IDelegate1 $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .additionalText$delegate..deepK$delegate.' type=.additionalText$delegate..deepK$delegate..> origin=OBJECT_LITERAL FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.additionalText$delegate..>, $receiver:.Value., .CR.>>) returnType:T of . @@ -349,16 +349,16 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt $receiver: GET_VAR 't: .Value., .CR.>> declared in .additionalText$delegate..getValue' type=.Value., .CR.>> origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IDelegate1 $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IDelegate1 $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IDelegate1 $this: VALUE_PARAMETER name: type:kotlin.Any CONSTRUCTOR_CALL 'private constructor () [primary] declared in .additionalText$delegate.' type=.additionalText$delegate..> origin=OBJECT_LITERAL FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL ($receiver:.Value., .CR.>>) returnType:.P., T of .> diff --git a/compiler/testData/ir/irText/types/genericFunWithStar.fir.txt b/compiler/testData/ir/irText/types/genericFunWithStar.fir.txt index 109a47d9ca8..197c0e0b43f 100644 --- a/compiler/testData/ir/irText/types/genericFunWithStar.fir.txt +++ b/compiler/testData/ir/irText/types/genericFunWithStar.fir.txt @@ -18,31 +18,31 @@ FILE fqName: fileName:/genericFunWithStar.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:IBar modality:ABSTRACT visibility:public superTypes:[.IBase] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IBar FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IBase $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.I.I> @@ -84,14 +84,17 @@ FILE fqName: fileName:/genericFunWithStar.kt index: CONST Int type=kotlin.Int value=0 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IBar $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo + public open fun hashCode (): kotlin.Int [fake_override] declared in .IBar $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .IFoo + public open fun toString (): kotlin.String [fake_override] declared in .IBar $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt b/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt index 1e896b979cf..a3bb2095bca 100644 --- a/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt +++ b/compiler/testData/ir/irText/types/intersectionType2_NI.fir.txt @@ -38,16 +38,19 @@ FILE fqName: fileName:/intersectionType2_NI.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:OPEN visibility:public superTypes:[.Foo; .A<.B>]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Foo + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Foo + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Foo + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:C modality:OPEN visibility:public superTypes:[.Foo; .A<.C>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C @@ -57,16 +60,19 @@ FILE fqName: fileName:/intersectionType2_NI.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:OPEN visibility:public superTypes:[.Foo; .A<.C>]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Foo + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Foo + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Foo + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:run visibility:public modality:FINAL (fn:kotlin.Function0.run>) returnType:T of .run TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] diff --git a/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt b/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt index 58bfaab2c38..dea2cc66eb1 100644 --- a/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt +++ b/compiler/testData/ir/irText/types/intersectionType2_OI.fir.txt @@ -38,16 +38,19 @@ FILE fqName: fileName:/intersectionType2_OI.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:OPEN visibility:public superTypes:[.Foo; .A<.B>]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Foo + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Foo + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Foo + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:C modality:OPEN visibility:public superTypes:[.Foo; .A<.C>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C @@ -57,16 +60,19 @@ FILE fqName: fileName:/intersectionType2_OI.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:OPEN visibility:public superTypes:[.Foo; .A<.C>]' FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Foo + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .Foo + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .Foo + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:run visibility:public modality:FINAL (fn:kotlin.Function0.run>) returnType:T of .run TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] diff --git a/compiler/testData/ir/irText/types/intersectionType3_NI.fir.txt b/compiler/testData/ir/irText/types/intersectionType3_NI.fir.txt index 31eb32b5228..acd39dafb6b 100644 --- a/compiler/testData/ir/irText/types/intersectionType3_NI.fir.txt +++ b/compiler/testData/ir/irText/types/intersectionType3_NI.fir.txt @@ -70,61 +70,67 @@ FILE fqName: fileName:/intersectionType3_NI.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A1 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:A2 modality:ABSTRACT visibility:public superTypes:[.A] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A2 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:Z1 modality:ABSTRACT visibility:public superTypes:[.A; .B] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z1 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A + public open fun toString (): kotlin.String [fake_override] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:Z2 modality:ABSTRACT visibility:public superTypes:[.A; .B] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z2 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A + public open fun toString (): kotlin.String [fake_override] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:testInIs1 visibility:public modality:FINAL <> (x:.In<.A>, y:.In<.B>) returnType:kotlin.Boolean VALUE_PARAMETER name:x index:0 type:.In<.A> diff --git a/compiler/testData/ir/irText/types/intersectionType3_OI.fir.txt b/compiler/testData/ir/irText/types/intersectionType3_OI.fir.txt index 594186b643b..de72928776f 100644 --- a/compiler/testData/ir/irText/types/intersectionType3_OI.fir.txt +++ b/compiler/testData/ir/irText/types/intersectionType3_OI.fir.txt @@ -70,61 +70,67 @@ FILE fqName: fileName:/intersectionType3_OI.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A1 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:A2 modality:ABSTRACT visibility:public superTypes:[.A] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A2 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:Z1 modality:ABSTRACT visibility:public superTypes:[.A; .B] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z1 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A + public open fun toString (): kotlin.String [fake_override] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:Z2 modality:ABSTRACT visibility:public superTypes:[.A; .B] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z2 FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A + public open fun toString (): kotlin.String [fake_override] declared in .B $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:testInIs1 visibility:public modality:FINAL <> (x:.In<.A>, y:.In<.B>) returnType:kotlin.Boolean VALUE_PARAMETER name:x index:0 type:.In<.A> diff --git a/compiler/testData/ir/irText/types/javaWildcardType.fir.kt.txt b/compiler/testData/ir/irText/types/javaWildcardType.fir.kt.txt index 19c032519a3..19ca57d394e 100644 --- a/compiler/testData/ir/irText/types/javaWildcardType.fir.kt.txt +++ b/compiler/testData/ir/irText/types/javaWildcardType.fir.kt.txt @@ -49,4 +49,3 @@ class C : J, K { local /* final field */ val <$$delegate_1>: K = k } - diff --git a/compiler/testData/ir/irText/types/javaWildcardType.fir.txt b/compiler/testData/ir/irText/types/javaWildcardType.fir.txt index eb3ee656b68..de876a68c0e 100644 --- a/compiler/testData/ir/irText/types/javaWildcardType.fir.txt +++ b/compiler/testData/ir/irText/types/javaWildcardType.fir.txt @@ -116,14 +116,17 @@ FILE fqName: fileName:/javaWildcardType.kt GET_VAR 'k: .K declared in .C.' type=.K origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .J + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .K $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .J + public open fun hashCode (): kotlin.Int [fake_override] declared in .K $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .J + public open fun toString (): kotlin.String [fake_override] declared in .K $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/types/rawTypeInSignature.fir.kt.txt b/compiler/testData/ir/irText/types/rawTypeInSignature.fir.kt.txt index 0954b249933..328be181702 100644 --- a/compiler/testData/ir/irText/types/rawTypeInSignature.fir.kt.txt +++ b/compiler/testData/ir/irText/types/rawTypeInSignature.fir.kt.txt @@ -79,4 +79,3 @@ class KRaw : JRaw { local /* final field */ val <$$delegate_0>: JRaw = j } - diff --git a/compiler/testData/ir/irText/types/rawTypeInSignature.fir.txt b/compiler/testData/ir/irText/types/rawTypeInSignature.fir.txt index 276e36ae09e..fe8a7ab340b 100644 --- a/compiler/testData/ir/irText/types/rawTypeInSignature.fir.txt +++ b/compiler/testData/ir/irText/types/rawTypeInSignature.fir.txt @@ -165,14 +165,14 @@ FILE fqName: fileName:/rawTypeInSignature.kt GET_VAR 'j: .JRaw declared in .KRaw.' type=.JRaw origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .JRaw $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .JRaw $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .JRaw $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.txt b/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.txt index dcd60b86d5e..fa655228cc0 100644 --- a/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.txt +++ b/compiler/testData/ir/irText/types/receiverOfIntersectionType.fir.txt @@ -20,31 +20,31 @@ FILE fqName: fileName:/receiverOfIntersectionType.kt $this: VALUE_PARAMETER name: type:.I FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .K $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .K $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .K $this: VALUE_PARAMETER name: type:kotlin.Any CLASS INTERFACE name:J modality:ABSTRACT visibility:public superTypes:[.K] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.J FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .K $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .K $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .K $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:A modality:FINAL visibility:public superTypes:[.I; .J] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A @@ -59,16 +59,19 @@ FILE fqName: fileName:/receiverOfIntersectionType.kt BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .I + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .I + public open fun hashCode (): kotlin.Int [fake_override] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .I + public open fun toString (): kotlin.String [fake_override] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:B modality:FINAL visibility:public superTypes:[.I; .J] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B @@ -83,16 +86,19 @@ FILE fqName: fileName:/receiverOfIntersectionType.kt BLOCK_BODY FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .I + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .I + public open fun hashCode (): kotlin.Int [fake_override] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .I + public open fun toString (): kotlin.String [fake_override] declared in .J $this: VALUE_PARAMETER name: type:kotlin.Any FUN name:testIntersection visibility:public modality:FINAL <> (a:.A, b:.B) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:.A diff --git a/compiler/testData/ir/irText/types/smartCastOnFakeOverrideReceiver.fir.txt b/compiler/testData/ir/irText/types/smartCastOnFakeOverrideReceiver.fir.txt index 47812f5c45c..49b640ebd90 100644 --- a/compiler/testData/ir/irText/types/smartCastOnFakeOverrideReceiver.fir.txt +++ b/compiler/testData/ir/irText/types/smartCastOnFakeOverrideReceiver.fir.txt @@ -122,16 +122,16 @@ FILE fqName: fileName:/smartCastOnFakeOverrideReceiver.kt VALUE_PARAMETER name:x index:0 type:kotlin.Any FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .A $this: VALUE_PARAMETER name: type:kotlin.Any CLASS CLASS name:GA modality:OPEN visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.GA.GA> @@ -205,14 +205,14 @@ FILE fqName: fileName:/smartCastOnFakeOverrideReceiver.kt $this: VALUE_PARAMETER name: type:.GA.GA> FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .GA $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any + public open fun hashCode (): kotlin.Int [fake_override] declared in .GA $this: VALUE_PARAMETER name: type:kotlin.Any FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] overridden: - public open fun toString (): kotlin.String declared in kotlin.Any + public open fun toString (): kotlin.String [fake_override] declared in .GA $this: VALUE_PARAMETER name: type:kotlin.Any From e4c851e3ceb1584ef9a5b6b6ed8a93491ece83e7 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Thu, 18 Feb 2021 19:18:09 +0300 Subject: [PATCH 339/368] FIR2IR: Fix case of @JvmOverloads with subclass Avoid generating synthetic overrides in subclass It has been already working for PSI2IR because fake overrides there don't inherit default values for parameters, while they do it in FIR --- .../fir/backend/Fir2IrDeclarationStorage.kt | 12 +++++++----- .../kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt | 2 +- .../codegen/FirBlackBoxCodegenTestGenerated.java | 6 ++++++ .../testData/codegen/box/jvmOverloads/subClass.kt | 15 +++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/LightAnalysisModeTestGenerated.java | 5 +++++ 7 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 compiler/testData/codegen/box/jvmOverloads/subClass.kt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 77c3c4f438b..21abbb3edad 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -318,7 +318,8 @@ class Fir2IrDeclarationStorage( createIrParameter( valueParameter, index, useStubForDefaultValueStub = function !is FirConstructor || containingClass?.name != Name.identifier("Enum"), - typeContext + typeContext, + skipDefaultParameter = isFakeOverride ).apply { this.parent = parent } @@ -854,10 +855,10 @@ class Fir2IrDeclarationStorage( internal fun saveFakeOverrideInClass( irClass: IrClass, - callableDeclaration: FirCallableDeclaration<*>, + originalDeclaration: FirCallableDeclaration<*>, fakeOverride: FirCallableDeclaration<*> ) { - fakeOverridesInClass.getOrPut(irClass, ::mutableMapOf)[callableDeclaration] = fakeOverride + fakeOverridesInClass.getOrPut(irClass, ::mutableMapOf)[originalDeclaration] = fakeOverride } fun getFakeOverrideInClass( @@ -904,7 +905,8 @@ class Fir2IrDeclarationStorage( valueParameter: FirValueParameter, index: Int = UNDEFINED_PARAMETER_INDEX, useStubForDefaultValueStub: Boolean = true, - typeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT + typeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT, + skipDefaultParameter: Boolean = false, ): IrValueParameter { val origin = IrDeclarationOrigin.DEFINED val type = valueParameter.returnTypeRef.toIrType() @@ -917,7 +919,7 @@ class Fir2IrDeclarationStorage( isCrossinline = valueParameter.isCrossinline, isNoinline = valueParameter.isNoinline, isHidden = false, isAssignable = false ).apply { - if (valueParameter.defaultValue.let { + if (!skipDefaultParameter && valueParameter.defaultValue.let { it != null && (useStubForDefaultValueStub || it !is FirExpressionStub) } ) { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt index cba4f9b9642..f464e8caf81 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt @@ -58,7 +58,7 @@ class Fir2IrLazySimpleFunction( declarationStorage.enterScope(this) fir.valueParameters.mapIndexed { index, valueParameter -> declarationStorage.createIrParameter( - valueParameter, index, + valueParameter, index, skipDefaultParameter = isFakeOverride ).apply { this.parent = this@Fir2IrLazySimpleFunction } diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 9cf4c768fe8..d8000dd5812 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -22830,6 +22830,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/jvmOverloads/simpleJavaCall.kt"); } + @Test + @TestMetadata("subClass.kt") + public void testSubClass() throws Exception { + runTest("compiler/testData/codegen/box/jvmOverloads/subClass.kt"); + } + @Test @TestMetadata("typeParameters.kt") public void testTypeParameters() throws Exception { diff --git a/compiler/testData/codegen/box/jvmOverloads/subClass.kt b/compiler/testData/codegen/box/jvmOverloads/subClass.kt new file mode 100644 index 00000000000..c06b3eb61ea --- /dev/null +++ b/compiler/testData/codegen/box/jvmOverloads/subClass.kt @@ -0,0 +1,15 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME + +open class A { + @JvmOverloads + fun foo(x: String, y: String = "", z: String = "K"): String { + return x + y + z + } +} + +class B : A() + +fun box(): String { + return B().foo("O") +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 9747a653863..cb2bbd13aa2 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -22830,6 +22830,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/jvmOverloads/simpleJavaCall.kt"); } + @Test + @TestMetadata("subClass.kt") + public void testSubClass() throws Exception { + runTest("compiler/testData/codegen/box/jvmOverloads/subClass.kt"); + } + @Test @TestMetadata("typeParameters.kt") public void testTypeParameters() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 23fb86aa543..5dce4b17e56 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -22830,6 +22830,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/jvmOverloads/simpleJavaCall.kt"); } + @Test + @TestMetadata("subClass.kt") + public void testSubClass() throws Exception { + runTest("compiler/testData/codegen/box/jvmOverloads/subClass.kt"); + } + @Test @TestMetadata("typeParameters.kt") public void testTypeParameters() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 9be202977b2..43771bfe58f 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -19295,6 +19295,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/jvmOverloads/simpleJavaCall.kt"); } + @TestMetadata("subClass.kt") + public void testSubClass() throws Exception { + runTest("compiler/testData/codegen/box/jvmOverloads/subClass.kt"); + } + @TestMetadata("typeParameters.kt") public void testTypeParameters() throws Exception { runTest("compiler/testData/codegen/box/jvmOverloads/typeParameters.kt"); From 1fe0a1f160917033ce8a76f79a61e6d66dce07b7 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Fri, 19 Feb 2021 11:26:13 +0300 Subject: [PATCH 340/368] FIR: Fix interface delegation case via type alias --- .../FirBlackBoxCodegenTestGenerated.java | 6 ++++++ .../kotlin/fir/scopes/KotlinScopeProvider.kt | 8 +++----- .../org/jetbrains/kotlin/fir/types/TypeUtils.kt | 4 ++++ .../codegen/box/delegation/viaTypeAlias.kt | 17 +++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/LightAnalysisModeTestGenerated.java | 5 +++++ .../IrJsCodegenBoxES6TestGenerated.java | 5 +++++ .../semantics/IrJsCodegenBoxTestGenerated.java | 5 +++++ .../semantics/JsCodegenBoxTestGenerated.java | 5 +++++ .../IrCodegenBoxWasmTestGenerated.java | 5 +++++ 11 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 compiler/testData/codegen/box/delegation/viaTypeAlias.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index d8000dd5812..397bc16b02a 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -13176,6 +13176,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/delegation/simple1.0.kt"); } + @Test + @TestMetadata("viaTypeAlias.kt") + public void testViaTypeAlias() throws Exception { + runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt"); + } + @Test @TestMetadata("withDefaultParameters.kt") public void testWithDefaultParameters() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt index dc676fd8c74..24488ebd72c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/KotlinScopeProvider.kt @@ -15,10 +15,8 @@ import org.jetbrains.kotlin.fir.scopes.impl.* import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol -import org.jetbrains.kotlin.fir.types.ConeClassErrorType -import org.jetbrains.kotlin.fir.types.ConeClassLikeType -import org.jetbrains.kotlin.fir.types.ConeKotlinType -import org.jetbrains.kotlin.fir.types.coneType +import org.jetbrains.kotlin.fir.typeContext +import org.jetbrains.kotlin.fir.types.* class KotlinScopeProvider( val declaredMemberScopeDecorator: ( @@ -110,7 +108,7 @@ fun ConeKotlinType.scopeForSupertype( if (this is ConeClassErrorType) return null val symbol = lookupTag.toSymbol(useSiteSession) return if (symbol is FirRegularClassSymbol) { - val delegateField = delegateFields?.find { it.returnTypeRef.coneType == this } + val delegateField = delegateFields?.find { useSiteSession.typeContext.equalTypes(it.returnTypeRef.coneType, this) } symbol.fir.scopeForSupertype( substitutor(symbol, this, useSiteSession), useSiteSession, scopeSession, delegateField, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt index 95450c2de1b..005319e3f77 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator import org.jetbrains.kotlin.types.AbstractStrictEqualityTypeChecker import org.jetbrains.kotlin.types.AbstractTypeApproximator +import org.jetbrains.kotlin.types.AbstractTypeChecker import org.jetbrains.kotlin.types.TypeApproximatorConfiguration import org.jetbrains.kotlin.types.model.* @@ -44,6 +45,9 @@ fun ConeInferenceContext.intersectTypesOrNull(types: List): Cone } } +fun TypeCheckerProviderContext.equalTypes(a: ConeKotlinType, b: ConeKotlinType): Boolean = + AbstractTypeChecker.equalTypes(this, a, b) + fun ConeDefinitelyNotNullType.Companion.create(original: ConeKotlinType): ConeDefinitelyNotNullType? { return when { original is ConeDefinitelyNotNullType -> original diff --git a/compiler/testData/codegen/box/delegation/viaTypeAlias.kt b/compiler/testData/codegen/box/delegation/viaTypeAlias.kt new file mode 100644 index 00000000000..ee129ef353d --- /dev/null +++ b/compiler/testData/codegen/box/delegation/viaTypeAlias.kt @@ -0,0 +1,17 @@ +public interface MyMap { + fun get(k: K): V +} + +typealias MyMapAlias = MyMap + +abstract class A(val m: MyMapAlias) : MyMapAlias by m + +class B : A(object : MyMap { + override fun get(w: String): String { + return w + "K" + } +}) + +fun box(): String { + return B().get("O") +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index cb2bbd13aa2..373a84800e0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -13176,6 +13176,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/delegation/simple1.0.kt"); } + @Test + @TestMetadata("viaTypeAlias.kt") + public void testViaTypeAlias() throws Exception { + runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt"); + } + @Test @TestMetadata("withDefaultParameters.kt") public void testWithDefaultParameters() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 5dce4b17e56..c873259ea07 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -13176,6 +13176,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/delegation/simple1.0.kt"); } + @Test + @TestMetadata("viaTypeAlias.kt") + public void testViaTypeAlias() throws Exception { + runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt"); + } + @Test @TestMetadata("withDefaultParameters.kt") public void testWithDefaultParameters() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 43771bfe58f..91c7aec724b 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -10788,6 +10788,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/delegation/simple1.0.kt"); } + @TestMetadata("viaTypeAlias.kt") + public void testViaTypeAlias() throws Exception { + runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt"); + } + @TestMetadata("withDefaultParameters.kt") public void testWithDefaultParameters() throws Exception { runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 4169114a9ee..3cc777b392d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -9588,6 +9588,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @TestMetadata("viaTypeAlias.kt") + public void testViaTypeAlias() throws Exception { + runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt"); + } + @TestMetadata("withDefaultParameters.kt") public void testWithDefaultParameters() throws Exception { runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 015b67503e4..9279ac96e45 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -9073,6 +9073,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @TestMetadata("viaTypeAlias.kt") + public void testViaTypeAlias() throws Exception { + runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt"); + } + @TestMetadata("withDefaultParameters.kt") public void testWithDefaultParameters() throws Exception { runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 3ad154677cb..7025699905a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -9073,6 +9073,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @TestMetadata("viaTypeAlias.kt") + public void testViaTypeAlias() throws Exception { + runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt"); + } + @TestMetadata("withDefaultParameters.kt") public void testWithDefaultParameters() throws Exception { runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 503d850450b..e8831dec8ca 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -4252,6 +4252,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/delegation/kt8154.kt"); } + @TestMetadata("viaTypeAlias.kt") + public void testViaTypeAlias() throws Exception { + runTest("compiler/testData/codegen/box/delegation/viaTypeAlias.kt"); + } + @TestMetadata("withDefaultParameters.kt") public void testWithDefaultParameters() throws Exception { runTest("compiler/testData/codegen/box/delegation/withDefaultParameters.kt"); From 6e46b0a1c4be4db2f0338e890b27192eceb13d21 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Sat, 20 Feb 2021 11:24:09 +0300 Subject: [PATCH 341/368] Add test for KT-41917 (already fixed) --- .../delegates/kt41917.fir.txt | 50 +++++++++++++++++++ .../resolveWithStdlib/delegates/kt41917.kt | 23 +++++++++ .../runners/FirDiagnosticTestGenerated.java | 6 +++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 +++ 4 files changed, 85 insertions(+) create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.fir.txt new file mode 100644 index 00000000000..5ec004ee783 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.fir.txt @@ -0,0 +1,50 @@ +FILE: kt41917.kt + public final class DummyDelegate : R|kotlin/Any| { + public constructor(s: R|V|): R|DummyDelegate| { + super() + } + + public final val s: R|V| = R|/s| + public get(): R|V| + + public final operator fun getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|V| { + ^getValue this@R|/DummyDelegate|.R|/DummyDelegate.s| + } + + } + public final fun testImplicit(c: R|C|): R|kotlin/Int| { + ^testImplicit R|/c|.R|/A.implicit|.R|kotlin/String.length| + } + public final fun testExplicit(c: R|C|): R|kotlin/Int| { + ^testExplicit R|/c|.R|/A.explicit|.R|kotlin/String.length| + } + public open class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + public final val implicit: R|kotlin/String|by R|/DummyDelegate.DummyDelegate|(String(hello)) + public get(): R|kotlin/String| { + ^ this@R|/A|.D|/A.implicit|.R|SubstitutionOverride|(this@R|/A|, ::R|/A.implicit|) + } + + public final val explicit: R|kotlin/String|by R|/DummyDelegate.DummyDelegate|(String(hello)) + public get(): R|kotlin/String| { + ^ this@R|/A|.D|/A.explicit|.R|SubstitutionOverride|(this@R|/A|, ::R|/A.explicit|) + } + + } + public abstract interface B : R|kotlin/Any| { + public abstract val implicit: R|kotlin/String| + public get(): R|kotlin/String| + + public abstract val explicit: R|kotlin/String| + public get(): R|kotlin/String| + + } + public final class C : R|A|, R|B| { + public constructor(): R|C| { + super() + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt new file mode 100644 index 00000000000..4c5e43101f1 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt @@ -0,0 +1,23 @@ +import kotlin.reflect.KProperty + +class DummyDelegate(val s: V) { + operator fun getValue(thisRef: Any?, property: KProperty<*>): V { + return s + } +} + +fun testImplicit(c: C) = c.implicit.length // (1) +fun testExplicit(c: C) = c.explicit.length + +open class A { + val implicit by DummyDelegate("hello") + + val explicit: String by DummyDelegate("hello") +} + +interface B { + val implicit: String + val explicit: String +} + +class C : A(), B diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index d37a0c193b4..26d06adcd89 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -4613,6 +4613,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.kt"); } + @Test + @TestMetadata("kt41917.kt") + public void testKt41917() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt"); + } + @Test @TestMetadata("propertyWithFunctionalType.kt") public void testPropertyWithFunctionalType() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index 833c3109e8f..739203e8fc7 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -4680,6 +4680,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateWithAnonymousObject.kt"); } + @Test + @TestMetadata("kt41917.kt") + public void testKt41917() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/kt41917.kt"); + } + @Test @TestMetadata("propertyWithFunctionalType.kt") public void testPropertyWithFunctionalType() throws Exception { From 5568ceef689c2a7a231457d4280c505b96fd385d Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Sat, 20 Feb 2021 11:33:09 +0300 Subject: [PATCH 342/368] Add test for KT-37056 (already fixed) --- ...TouchedTilContractsPhaseTestGenerated.java | 5 ++ .../resolve/callResolution/kt37056.fir.txt | 58 +++++++++++++++++++ .../resolve/callResolution/kt37056.kt | 32 ++++++++++ .../runners/FirDiagnosticTestGenerated.java | 6 ++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 ++ 5 files changed, 107 insertions(+) create mode 100644 compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index a8cace9712f..20c20e84b29 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -715,6 +715,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/invokeWithReceiverAndArgument.kt"); } + @TestMetadata("kt37056.kt") + public void testKt37056() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt"); + } + @TestMetadata("lambdaAsReceiver.kt") public void testLambdaAsReceiver() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/lambdaAsReceiver.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.fir.txt b/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.fir.txt new file mode 100644 index 00000000000..f28f9da1a94 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.fir.txt @@ -0,0 +1,58 @@ +FILE: kt37056.kt + public final fun case1(a: R|A?|): R|kotlin/Unit| { + lval test: R|kotlin/String?| = R|/a|?.{ $subj$.R|kotlin/let|( = let@fun (it: R|A|): R|kotlin/String| { + Q|Case1|.R|/Case1.Companion.invoke|(R|/it|) + Q|Case1|.R|/Case1.Companion.invoke|(R|/it|) + ^ Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|()) + } + ) } + Q|Case1|.R|/Case1.Companion.invoke|(R|/A.A|()) + Q|Case1|.R|/Case1.Companion.invoke|(a = R|/A.A|()) + } + public final class Case1 : R|kotlin/Any| { + private constructor(a: R|A|): R|Case1| { + super() + } + + public final val a: R|A| = R|/a| + public get(): R|A| + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|Case1.Companion| { + super() + } + + public final operator fun invoke(a: R|A|): R|kotlin/String| { + ^invoke String() + } + + } + + } + public final fun case2(a: R|A|): R|kotlin/Unit| { + Q|Case2|.R|/Case2.Companion.invoke|(R|/a|) + Q|Case2|.R|/Case2.Companion.invoke|(a = R|/a|) + } + public final class Case2 : R|kotlin/Any| { + public constructor(): R|Case2| { + super() + } + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|Case2.Companion| { + super() + } + + public final operator fun invoke(a: R|A|): R|kotlin/String| { + ^invoke String() + } + + } + + } + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt b/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt new file mode 100644 index 00000000000..8258acf4bb3 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt @@ -0,0 +1,32 @@ +fun case1(a: A?) { + val test = a?.let { + + Case1.invoke(it) + + Case1(it) + + Case1(A()) + } + + Case1(A()) + Case1(a = A()) +} + +class Case1 private constructor(val a: A) { + companion object { + operator fun invoke(a: A) = "" + } +} + +fun case2(a: A) { + Case2(a) + Case2(a =a) +} + +class Case2 { + companion object { + operator fun invoke(a: A) = "" //(1) + } +} + +class A() \ No newline at end of file diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index 26d06adcd89..953aaffdbf1 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -827,6 +827,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/invokeWithReceiverAndArgument.kt"); } + @Test + @TestMetadata("kt37056.kt") + public void testKt37056() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt"); + } + @Test @TestMetadata("lambdaAsReceiver.kt") public void testLambdaAsReceiver() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index 739203e8fc7..694267105eb 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -834,6 +834,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/invokeWithReceiverAndArgument.kt"); } + @Test + @TestMetadata("kt37056.kt") + public void testKt37056() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/callResolution/kt37056.kt"); + } + @Test @TestMetadata("lambdaAsReceiver.kt") public void testLambdaAsReceiver() throws Exception { From bd2601f289dcbb94eb2e0a6d751b931765298b0d Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Mon, 1 Feb 2021 16:22:07 +0300 Subject: [PATCH 343/368] [JS IR] Extract adding of function call to another function [JS IR] Add option for dce mode [JS IR] Add logging to non useful declarations if appropriate dce mode [JS IR] Add mode with throwing exception [JS IR] unreachableDeclaration method is in rootDeclarations [JS IR] Add js extra help arg with dce mode and include debug.kt to compile unreachableMethod [JS IR] unreachableDeclaration as internal to not reproduce stdlib api [JS IR] Fix description of dce mode argument - Use console.error instead of console.log - Use JsError instead Kotlin exception for lightweight [JS IR] Remove body for throwing exception [JS IR] Remove default parameter in unreachableDeclaration [JS IR] Process without removing fields and declaration containers [JS IR] Rename dce mode on dce runtime diagnostic [JS IR] Use console.trace instead of console.error [JS IR] Extract JsError - Fix naming in prependFunctionCall - Fix description on runtime diagnostic argument - Using message collector instead of throwing exception [JS IR] Distinguish unreachableMethods for log and exception [JS IR] Extract checking of Kotlin packages of IrField ^KT-45059 fixed --- .../common/arguments/K2JSCompilerArguments.kt | 10 ++- .../arguments/K2JsArgumentConstants.java | 3 + .../jetbrains/kotlin/cli/js/K2JsIrCompiler.kt | 19 +++++ .../org/jetbrains/kotlin/ir/backend/js/Dce.kt | 78 ++++++++++++++++++- .../kotlin/ir/backend/js/JsIntrinsics.kt | 3 + .../ir/backend/js/JsIrBackendContext.kt | 2 + .../kotlin/ir/backend/js/compiler.kt | 3 + .../js/lower/PropertyLazyInitLowering.kt | 28 +------ .../kotlin/ir/backend/js/utils/misc.kt | 27 ++++++- compiler/testData/cli/js/jsExtraHelp.out | 2 + .../kotlin/js/config/DceRuntimeDiagnostic.kt | 24 ++++++ .../js-ir-minimal-for-test/build.gradle.kts | 1 - libraries/stdlib/js-ir/runtime/JsError.kt | 7 ++ libraries/stdlib/js-ir/runtime/dceUtils.kt | 16 ++++ 14 files changed, 189 insertions(+), 34 deletions(-) create mode 100644 js/js.frontend/src/org/jetbrains/kotlin/js/config/DceRuntimeDiagnostic.kt create mode 100644 libraries/stdlib/js-ir/runtime/JsError.kt create mode 100644 libraries/stdlib/js-ir/runtime/dceUtils.kt diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt index 2841ed056df..e86f9447da9 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt @@ -5,8 +5,7 @@ package org.jetbrains.kotlin.cli.common.arguments -import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.CALL -import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.NO_CALL +import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.* import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.config.ApiVersion @@ -126,6 +125,13 @@ class K2JSCompilerArguments : CommonCompilerArguments() { @Argument(value = "-Xir-dce", description = "Perform experimental dead code elimination") var irDce: Boolean by FreezableVar(false) + @Argument( + value = "-Xir-dce-runtime-diagnostic", + valueDescription = "{$DCE_RUNTIME_DIAGNOSTIC_LOG|$DCE_RUNTIME_DIAGNOSTIC_EXCEPTION}", + description = "Enable runtime diagnostics when performing DCE instead of removing declarations" + ) + var irDceRuntimeDiagnostic: String? by NullableStringFreezableVar(null) + @Argument(value = "-Xir-dce-driven", description = "Perform a more experimental faster dead code elimination") var irDceDriven: Boolean by FreezableVar(false) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JsArgumentConstants.java b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JsArgumentConstants.java index ea9a7d45ddd..822423006d4 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JsArgumentConstants.java +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JsArgumentConstants.java @@ -28,4 +28,7 @@ public interface K2JsArgumentConstants { String SOURCE_MAP_SOURCE_CONTENT_ALWAYS = "always"; String SOURCE_MAP_SOURCE_CONTENT_NEVER = "never"; String SOURCE_MAP_SOURCE_CONTENT_INLINING = "inlining"; + + String DCE_RUNTIME_DIAGNOSTIC_LOG = "log"; + String DCE_RUNTIME_DIAGNOSTIC_EXCEPTION = "exception"; } diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt index 9d08c4548bd..47209787023 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.cli.common.ExitCode.COMPILATION_ERROR import org.jetbrains.kotlin.cli.common.ExitCode.OK import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants +import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.* import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot import org.jetbrains.kotlin.cli.common.extensions.ScriptEvaluationExtension import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport @@ -259,12 +260,17 @@ class K2JsIrCompiler : CLICompiler() { mainArguments = mainCallArguments, generateFullJs = !arguments.irDce, generateDceJs = arguments.irDce, + dceRuntimeDiagnostic = DceRuntimeDiagnostic.resolve( + arguments.irDceRuntimeDiagnostic, + messageCollector + ), dceDriven = arguments.irDceDriven, multiModule = arguments.irPerModule, relativeRequirePath = true, propertyLazyInitialization = arguments.irPropertyLazyInitialization, ) + val jsCode = if (arguments.irDce && !arguments.irDceDriven) compiledModule.dceJsCode!! else compiledModule.jsCode!! outputFile.writeText(jsCode.mainModule) jsCode.dependencies.forEach { (name, content) -> @@ -422,6 +428,19 @@ class K2JsIrCompiler : CLICompiler() { } } +fun DceRuntimeDiagnostic.Companion.resolve( + value: String?, + messageCollector: MessageCollector +): DceRuntimeDiagnostic? = when (value?.toLowerCase()) { + DCE_RUNTIME_DIAGNOSTIC_LOG -> DceRuntimeDiagnostic.LOG + DCE_RUNTIME_DIAGNOSTIC_EXCEPTION -> DceRuntimeDiagnostic.EXCEPTION + null -> null + else -> { + messageCollector.report(STRONG_WARNING, "Unknown DCE runtime diagnostic '$value'") + null + } +} + fun messageCollectorLogger(collector: MessageCollector) = object : Logger { override fun warning(message: String) = collector.report(STRONG_WARNING, message) override fun error(message: String) = collector.report(ERROR, message) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt index 282cc71884e..564132fe6d7 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/Dce.kt @@ -7,7 +7,9 @@ package org.jetbrains.kotlin.ir.backend.js import org.jetbrains.kotlin.backend.common.ir.isMemberOfOpenClass import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.backend.js.export.isExported +import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder import org.jetbrains.kotlin.ir.backend.js.utils.* import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* @@ -20,7 +22,9 @@ import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid import org.jetbrains.kotlin.ir.visitors.acceptVoid +import org.jetbrains.kotlin.js.config.DceRuntimeDiagnostic import org.jetbrains.kotlin.js.config.JSConfigurationKeys +import org.jetbrains.kotlin.js.config.removingBody import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* @@ -34,7 +38,11 @@ fun eliminateDeadDeclarations( val usefulDeclarations = usefulDeclarations(allRoots, context) context.irFactory.stageController.unrestrictDeclarationListsAccess { - removeUselessDeclarations(modules, usefulDeclarations) + processUselessDeclarations( + modules, + usefulDeclarations, + context + ) } } @@ -47,7 +55,7 @@ private fun buildRoots(modules: Iterable, context: JsIrBackend (modules.flatMap { it.files } + context.packageLevelJsModules + context.externalPackageFragment.values).flatMapTo(mutableListOf()) { file -> file.declarations.flatMap { if (it is IrProperty) listOfNotNull(it.backingField, it.getter, it.setter) else listOf(it) } .filter { - it is IrField && it.initializer != null && it.fqNameWhenAvailable?.asString()?.startsWith("kotlin") != true + it is IrField && it.initializer != null && !it.isKotlinPackage() || it.isExported(context) || it.isEffectivelyExternal() || it is IrField && it.correspondingPropertySymbol?.owner?.isExported(context) == true @@ -57,6 +65,11 @@ private fun buildRoots(modules: Iterable, context: JsIrBackend rootDeclarations += context.testRoots.values + val dceRuntimeDiagnostic = context.dceRuntimeDiagnostic + if (dceRuntimeDiagnostic != null) { + rootDeclarations += dceRuntimeDiagnostic.unreachableDeclarationMethod(context).owner + } + JsMainFunctionDetector.getMainFunctionOrNull(modules.last())?.let { mainFunction -> rootDeclarations += mainFunction if (mainFunction.isSuspend) { @@ -67,7 +80,17 @@ private fun buildRoots(modules: Iterable, context: JsIrBackend return rootDeclarations } -private fun removeUselessDeclarations(modules: Iterable, usefulDeclarations: Set) { +private fun DceRuntimeDiagnostic.unreachableDeclarationMethod(context: JsIrBackendContext) = + when (this) { + DceRuntimeDiagnostic.LOG -> context.intrinsics.jsUnreachableDeclarationLog + DceRuntimeDiagnostic.EXCEPTION -> context.intrinsics.jsUnreachableDeclarationException + } + +private fun processUselessDeclarations( + modules: Iterable, + usefulDeclarations: Set, + context: JsIrBackendContext +) { modules.forEach { module -> module.files.forEach { it.acceptVoid(object : IrElementVisitorVoid { @@ -99,7 +122,7 @@ private fun removeUselessDeclarations(modules: Iterable, usefu private fun process(container: IrDeclarationContainer) { container.declarations.transformFlat { member -> if (member !in usefulDeclarations) { - emptyList() + member.processUselessDeclaration(context) } else { member.acceptVoid(this) null @@ -111,6 +134,53 @@ private fun removeUselessDeclarations(modules: Iterable, usefu } } +private fun IrDeclaration.processUselessDeclaration(context: JsIrBackendContext): List? { + return when { + context.dceRuntimeDiagnostic != null -> { + processWithDiagnostic(context) + return null + } + else -> emptyList() + } +} + +private fun IrDeclaration.processWithDiagnostic(context: JsIrBackendContext) { + when (this) { + is IrFunction -> processFunctionWithDiagnostic(context) + is IrField -> processFieldWithDiagnostic() + is IrDeclarationContainer -> declarations.forEach { it.processWithDiagnostic(context) } + } +} + +private fun IrFunction.processFunctionWithDiagnostic(context: JsIrBackendContext) { + val dceRuntimeDiagnostic = context.dceRuntimeDiagnostic!! + + val isRemovingBody = dceRuntimeDiagnostic.removingBody() + val targetMethod = dceRuntimeDiagnostic.unreachableDeclarationMethod(context) + val call = JsIrBuilder.buildCall( + target = targetMethod, + type = targetMethod.owner.returnType + ) + + if (isRemovingBody) { + body = context.irFactory.createBlockBody( + UNDEFINED_OFFSET, + UNDEFINED_OFFSET + ) + } + + body?.prependFunctionCall(call) +} + +private fun IrField.processFieldWithDiagnostic() { + if (initializer != null && isKotlinPackage()) { + initializer = null + } +} + +private fun IrField.isKotlinPackage() = + fqNameWhenAvailable?.asString()?.startsWith("kotlin") == true + // TODO refactor it, the function became too big. Please contact me (Zalim) before doing it. fun usefulDeclarations(roots: Iterable, context: JsIrBackendContext): Set { val printReachabilityInfo = diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt index 6ba799b9622..4327be9078d 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIntrinsics.kt @@ -162,6 +162,9 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC val jsImul = getInternalFunction("imul") + val jsUnreachableDeclarationLog = getInternalFunction("unreachableDeclarationLog") + val jsUnreachableDeclarationException = getInternalFunction("unreachableDeclarationException") + // Coroutines val jsCoroutineContext diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt index d0fd5431ce2..66dbd7d87b0 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/JsIrBackendContext.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.ir.symbols.impl.DescriptorlessExternalPackageFragmen import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.impl.IrDynamicTypeImpl import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.js.config.DceRuntimeDiagnostic import org.jetbrains.kotlin.js.config.ErrorTolerancePolicy import org.jetbrains.kotlin.js.config.JSConfigurationKeys import org.jetbrains.kotlin.name.FqName @@ -44,6 +45,7 @@ class JsIrBackendContext( override val configuration: CompilerConfiguration, // TODO: remove configuration from backend context override val scriptMode: Boolean = false, override val es6mode: Boolean = false, + val dceRuntimeDiagnostic: DceRuntimeDiagnostic? = null, val propertyLazyInitialization: Boolean = false, override val irFactory: IrFactory = IrFactoryImpl ) : JsCommonBackendContext { diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt index 8801d53a744..1edf24909ab 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/compiler.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator import org.jetbrains.kotlin.ir.util.noUnboundLeft +import org.jetbrains.kotlin.js.config.DceRuntimeDiagnostic import org.jetbrains.kotlin.library.KotlinLibrary import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult import org.jetbrains.kotlin.name.FqName @@ -45,6 +46,7 @@ fun compile( generateFullJs: Boolean = true, generateDceJs: Boolean = false, dceDriven: Boolean = false, + dceRuntimeDiagnostic: DceRuntimeDiagnostic? = null, es6mode: Boolean = false, multiModule: Boolean = false, relativeRequirePath: Boolean = false, @@ -70,6 +72,7 @@ fun compile( exportedDeclarations, configuration, es6mode = es6mode, + dceRuntimeDiagnostic = dceRuntimeDiagnostic, propertyLazyInitialization = propertyLazyInitialization, irFactory = irFactory ) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PropertyLazyInitLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PropertyLazyInitLowering.kt index 2985400d775..6c5ca289b56 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PropertyLazyInitLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PropertyLazyInitLowering.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext import org.jetbrains.kotlin.ir.backend.js.ir.JsIrArithBuilder import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder +import org.jetbrains.kotlin.ir.backend.js.utils.prependFunctionCall import org.jetbrains.kotlin.ir.util.isPure import org.jetbrains.kotlin.ir.builders.declarations.addFunction import org.jetbrains.kotlin.ir.builders.declarations.buildField @@ -74,7 +75,7 @@ class PropertyLazyInitLowering( when (container) { is IrSimpleFunction -> - irBody.addInitialization(initializationCall, container) + irBody.prependFunctionCall(initializationCall) is IrField -> { container .correspondingProperty @@ -83,7 +84,7 @@ class PropertyLazyInitLowering( ?.let { listOf(it.getter, it.setter) } ?.filterNotNull() ?.forEach { - irBody.addInitialization(initializationCall, it) + irBody.prependFunctionCall(initializationCall) } } } @@ -172,29 +173,6 @@ class PropertyLazyInitLowering( } } -private fun IrBody.addInitialization( - initCall: IrCall, - container: IrSimpleFunction -) { - when (this) { - is IrExpressionBody -> { - expression = JsIrBuilder.buildComposite( - type = container.returnType, - statements = listOf( - initCall, - expression - ) - ) - } - is IrBlockBody -> { - statements.add( - 0, - initCall - ) - } - } -} - private fun createIrGetField(field: IrField): IrGetField { return JsIrBuilder.buildGetField( symbol = field.symbol, diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/misc.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/misc.kt index 1cc9a52545f..c1daf564382 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/misc.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/utils/misc.kt @@ -11,8 +11,9 @@ import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext import org.jetbrains.kotlin.ir.backend.js.JsLoweredDeclarationOrigin import org.jetbrains.kotlin.ir.backend.js.export.isExported +import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl import org.jetbrains.kotlin.ir.types.IrType @@ -88,4 +89,26 @@ val IrValueDeclaration.isDispatchReceiver: Boolean if (parent is IrFunction && parent.dispatchReceiverParameter == this) return true return false - } \ No newline at end of file + } + +fun IrBody.prependFunctionCall( + call: IrCall +) { + when (this) { + is IrExpressionBody -> { + expression = JsIrBuilder.buildComposite( + type = expression.type, + statements = listOf( + call, + expression + ) + ) + } + is IrBlockBody -> { + statements.add( + 0, + call + ) + } + } +} \ No newline at end of file diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index b6134d27332..b67972707fb 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -11,6 +11,8 @@ where advanced options include: -Xir-dce-driven Perform a more experimental faster dead code elimination -Xir-dce-print-reachability-info Print declarations' reachability info to stdout during performing DCE + -Xir-dce-runtime-diagnostic={log|exception} + Enable runtime diagnostics when performing DCE instead of removing declarations -Xir-module-name= Specify a compilation module name for IR backend -Xir-only Disables pre-IR backend -Xir-per-module Splits generated .js per-module diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/config/DceRuntimeDiagnostic.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/config/DceRuntimeDiagnostic.kt new file mode 100644 index 00000000000..ee78d252589 --- /dev/null +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/config/DceRuntimeDiagnostic.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2010-2020 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.js.config + +enum class DceRuntimeDiagnostic { + LOG, + EXCEPTION; + + companion object +} + +fun DceRuntimeDiagnostic.removingBody(): Boolean { + return this != DceRuntimeDiagnostic.LOG +} + +fun DceRuntimeDiagnostic.dceRuntimeDiagnosticToArgumentOfUnreachableMethod(): Int { + return when (this) { + DceRuntimeDiagnostic.LOG -> 0 + DceRuntimeDiagnostic.EXCEPTION -> 1 + } +} diff --git a/libraries/stdlib/js-ir-minimal-for-test/build.gradle.kts b/libraries/stdlib/js-ir-minimal-for-test/build.gradle.kts index 9084fcb3aee..c6ec3258978 100644 --- a/libraries/stdlib/js-ir-minimal-for-test/build.gradle.kts +++ b/libraries/stdlib/js-ir-minimal-for-test/build.gradle.kts @@ -71,7 +71,6 @@ val jsMainSources by task { "libraries/stdlib/js/src/kotlin/console.kt", "libraries/stdlib/js/src/kotlin/coreDeprecated.kt", "libraries/stdlib/js/src/kotlin/date.kt", - "libraries/stdlib/js/src/kotlin/debug.kt", "libraries/stdlib/js/src/kotlin/grouping.kt", "libraries/stdlib/js/src/kotlin/json.kt", "libraries/stdlib/js/src/kotlin/promise.kt", diff --git a/libraries/stdlib/js-ir/runtime/JsError.kt b/libraries/stdlib/js-ir/runtime/JsError.kt new file mode 100644 index 00000000000..e3e516decc1 --- /dev/null +++ b/libraries/stdlib/js-ir/runtime/JsError.kt @@ -0,0 +1,7 @@ +/* + * Copyright 2010-2021 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. + */ + +@JsName("Error") +internal open external class JsError(message: String) : Throwable \ No newline at end of file diff --git a/libraries/stdlib/js-ir/runtime/dceUtils.kt b/libraries/stdlib/js-ir/runtime/dceUtils.kt new file mode 100644 index 00000000000..70e29301ffa --- /dev/null +++ b/libraries/stdlib/js-ir/runtime/dceUtils.kt @@ -0,0 +1,16 @@ +/* + * Copyright 2010-2021 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 kotlin.js + +import JsError + +internal fun unreachableDeclarationLog() { + console.asDynamic().trace("Unreachable declaration") +} + +internal fun unreachableDeclarationException() { + throw JsError("Unreachable declaration") +} \ No newline at end of file From 187d4998fa8ff3085c9b0586c6c0e511c1b1b43e Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Fri, 19 Feb 2021 17:28:17 +0300 Subject: [PATCH 344/368] [JS IR] Not cast to declaration parent in JsCodeOutlineLowering, use parent otherwise ^KT-45057 fixed --- .../js/lower/JsCodeOutliningLowering.kt | 7 ++++++- .../semantics/IrBoxJsES6TestGenerated.java | 5 +++++ .../ir/semantics/IrBoxJsTestGenerated.java | 5 +++++ .../js/test/semantics/BoxJsTestGenerated.java | 5 +++++ js/js.translator/testData/box/jsCode/init.kt | 21 +++++++++++++++++++ 5 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 js/js.translator/testData/box/jsCode/init.kt diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsCodeOutliningLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsCodeOutliningLowering.kt index 62c74bc1a21..d47dfbedbb3 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsCodeOutliningLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsCodeOutliningLowering.kt @@ -30,12 +30,14 @@ import org.jetbrains.kotlin.ir.expressions.IrContainerExpression import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.util.constructors +import org.jetbrains.kotlin.ir.util.dumpKotlinLike import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid import org.jetbrains.kotlin.js.backend.ast.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.addIfNotNull +import java.lang.IllegalStateException // Outlines `kotlin.js.js(code: String)` calls where JS code references Kotlin locals. // Makes locals usages explicit. @@ -164,7 +166,10 @@ private class JsCodeOutlineTransformer( } // We don't need this function's body. Using empty block body stub, because some code might expect all functions to have bodies. outlinedFunction.body = backendContext.irFactory.createBlockBody(UNDEFINED_OFFSET, UNDEFINED_OFFSET) - outlinedFunction.parent = container as IrDeclarationParent + outlinedFunction.parent = when (container) { + is IrDeclarationParent -> container + else -> container.parent + } kotlinLocalsUsedInJs.forEach { local -> outlinedFunction.addValueParameter { name = local.name diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java index 2431469a3cd..f242ccc9e68 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java @@ -5105,6 +5105,11 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test { runTest("js/js.translator/testData/box/jsCode/if.kt"); } + @TestMetadata("init.kt") + public void testInit() throws Exception { + runTest("js/js.translator/testData/box/jsCode/init.kt"); + } + @TestMetadata("invocation.kt") public void testInvocation() throws Exception { runTest("js/js.translator/testData/box/jsCode/invocation.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java index 902c771bee4..10b4993e6e8 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java @@ -5105,6 +5105,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest { runTest("js/js.translator/testData/box/jsCode/if.kt"); } + @TestMetadata("init.kt") + public void testInit() throws Exception { + runTest("js/js.translator/testData/box/jsCode/init.kt"); + } + @TestMetadata("invocation.kt") public void testInvocation() throws Exception { runTest("js/js.translator/testData/box/jsCode/invocation.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java index 74d0097f158..b0085c52349 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java @@ -5120,6 +5120,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { runTest("js/js.translator/testData/box/jsCode/if.kt"); } + @TestMetadata("init.kt") + public void testInit() throws Exception { + runTest("js/js.translator/testData/box/jsCode/init.kt"); + } + @TestMetadata("invocation.kt") public void testInvocation() throws Exception { runTest("js/js.translator/testData/box/jsCode/invocation.kt"); diff --git a/js/js.translator/testData/box/jsCode/init.kt b/js/js.translator/testData/box/jsCode/init.kt new file mode 100644 index 00000000000..f53e8569146 --- /dev/null +++ b/js/js.translator/testData/box/jsCode/init.kt @@ -0,0 +1,21 @@ +// EXPECTED_REACHABLE_NODES: 1282 +package foo + +class A { + var ok: String + + init { + var ok = "fail" + ok = js( + """ + ok = 'OK' + return ok + """ + ) + this.ok = ok + } +} + +fun box(): String { + return A().ok +} \ No newline at end of file From 387d84f82606198e3c3b3ca2ee020c8c8dd613b5 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Sat, 20 Feb 2021 11:07:48 +0300 Subject: [PATCH 345/368] JVM_IR indy-SAM: KT-45069 box lambda 'Unit' return type if needed --- .../FirBlackBoxCodegenTestGenerated.java | 78 +++++++++++++++++++ .../lower/indy/LambdaMetafactoryArguments.kt | 6 +- .../intReturnTypeAsNumber.kt | 16 ++++ .../nothingReturnTypeAsObject.kt | 25 ++++++ .../nothingReturnTypeAsString.kt | 25 ++++++ .../nullableNothingReturnTypeAsObject.kt | 28 +++++++ .../nullableNothingReturnTypeAsString.kt | 28 +++++++ .../voidReturnTypeAsObject.kt | 20 +++++ .../sam/intReturnTypeAsNumber.kt | 14 ++++ .../genericWithInProjection.kt | 18 +++++ .../genericWithStarProjection.kt | 16 ++++ .../specializedGenerics/inheritedWithChar.kt | 3 +- .../nothingReturnTypeAsGeneric.kt | 18 +++++ .../nothingReturnTypeAsString.kt | 18 +++++ .../specializedWithChar.kt | 16 ++++ .../specializedWithCharClass.kt | 14 ++++ .../codegen/BlackBoxCodegenTestGenerated.java | 78 +++++++++++++++++++ .../IrBlackBoxCodegenTestGenerated.java | 78 +++++++++++++++++++ .../LightAnalysisModeTestGenerated.java | 65 ++++++++++++++++ 19 files changed, 561 insertions(+), 3 deletions(-) create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/intReturnTypeAsNumber.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsObject.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsString.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsObject.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsString.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/voidReturnTypeAsObject.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/intReturnTypeAsNumber.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithInProjection.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithStarProjection.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsGeneric.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsString.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithChar.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithCharClass.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 397bc16b02a..334731fb4da 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -20021,6 +20021,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @Test + @TestMetadata("intReturnTypeAsNumber.kt") + public void testIntReturnTypeAsNumber() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/intReturnTypeAsNumber.kt"); + } + @Test @TestMetadata("nullabilityAssertions.kt") public void testNullabilityAssertions() throws Exception { @@ -20220,6 +20226,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt"); } + @Test + @TestMetadata("intReturnTypeAsNumber.kt") + public void testIntReturnTypeAsNumber() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/intReturnTypeAsNumber.kt"); + } + @Test @TestMetadata("localFunction1.kt") public void testLocalFunction1() throws Exception { @@ -20244,11 +20256,41 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt"); } + @Test + @TestMetadata("nothingReturnTypeAsObject.kt") + public void testNothingReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsObject.kt"); + } + + @Test + @TestMetadata("nothingReturnTypeAsString.kt") + public void testNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsString.kt"); + } + + @Test + @TestMetadata("nullableNothingReturnTypeAsObject.kt") + public void testNullableNothingReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsObject.kt"); + } + + @Test + @TestMetadata("nullableNothingReturnTypeAsString.kt") + public void testNullableNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsString.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt"); } + + @Test + @TestMetadata("voidReturnTypeAsObject.kt") + public void testVoidReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/voidReturnTypeAsObject.kt"); + } } @Nested @@ -20354,6 +20396,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt"); } + @Test + @TestMetadata("genericWithInProjection.kt") + public void testGenericWithInProjection() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithInProjection.kt"); + } + + @Test + @TestMetadata("genericWithStarProjection.kt") + public void testGenericWithStarProjection() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithStarProjection.kt"); + } + @Test @TestMetadata("inheritedWithChar.kt") public void testInheritedWithChar() throws Exception { @@ -20414,6 +20468,30 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixPrimitiveAndBoxed.kt"); } + @Test + @TestMetadata("nothingReturnTypeAsGeneric.kt") + public void testNothingReturnTypeAsGeneric() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsGeneric.kt"); + } + + @Test + @TestMetadata("nothingReturnTypeAsString.kt") + public void testNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsString.kt"); + } + + @Test + @TestMetadata("specializedWithChar.kt") + public void testSpecializedWithChar() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithChar.kt"); + } + + @Test + @TestMetadata("specializedWithCharClass.kt") + public void testSpecializedWithCharClass() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithCharClass.kt"); + } + @Test @TestMetadata("voidReturnTypeAsGeneric.kt") public void testVoidReturnTypeAsGeneric() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt index f23c451fc17..cf3433b9e14 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/indy/LambdaMetafactoryArguments.kt @@ -241,6 +241,8 @@ internal class LambdaMetafactoryArgumentsBuilder( } if (!checkTypeCompliesWithConstraint(implFun.returnType, constraints.returnType)) return false + if (implFun.returnType.isUnit() && !fakeInstanceMethod.returnType.isUnit()) + return false return true } @@ -278,7 +280,9 @@ internal class LambdaMetafactoryArgumentsBuilder( implParameter.type = implParameter.type.makeNullable() } } - if (constraints.returnType.requiresImplLambdaBoxing()) { + if (constraints.returnType.requiresImplLambdaBoxing() || + implFun.returnType.isUnit() && !fakeInstanceMethod.returnType.isUnit() + ) { implFun.returnType = implFun.returnType.makeNullable() } } diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/intReturnTypeAsNumber.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/intReturnTypeAsNumber.kt new file mode 100644 index 00000000000..12034f04bdc --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/intReturnTypeAsNumber.kt @@ -0,0 +1,16 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: intReturnTypeAsNumber.kt + +fun box(): String { + val num = Sam { 42 } + if (num.get() != 42) + return "Failed" + return "OK" +} + +// FILE: Sam.java +public interface Sam { + Number get(); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsObject.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsObject.kt new file mode 100644 index 00000000000..d57c0ceb449 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsObject.kt @@ -0,0 +1,25 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: nothingReturnTypeAsObject.kt + +fun interface IFoo { + fun foo(): T +} + +fun thr(s: String): Nothing = throw RuntimeException(s) + +fun box(): String { + try { + Sam(::thr).get("OK") + } catch (e: RuntimeException) { + return e.message!! + } + return "Failed" +} + + +// FILE: Sam.java +public interface Sam { + Object get(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsString.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsString.kt new file mode 100644 index 00000000000..0ced755167e --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsString.kt @@ -0,0 +1,25 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: nothingReturnTypeAsString.kt + +fun interface IFoo { + fun foo(): T +} + +fun thr(s: String): Nothing = throw RuntimeException(s) + +fun box(): String { + try { + Sam(::thr).get("OK") + } catch (e: RuntimeException) { + return e.message!! + } + return "Failed" +} + + +// FILE: Sam.java +public interface Sam { + String get(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsObject.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsObject.kt new file mode 100644 index 00000000000..36fa4eb8c9c --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsObject.kt @@ -0,0 +1,28 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: nullableNothingReturnTypeAsObject.kt + +fun interface IFoo { + fun foo(): T +} + +var t = "Failed" + +fun test(s: String): Nothing? { + t = s + return null +} + +fun box(): String { + val q = Sam(::test).get("OK") + if (q != null) + return "Failed: $q" + return t +} + + +// FILE: Sam.java +public interface Sam { + Object get(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsString.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsString.kt new file mode 100644 index 00000000000..f45b8ffeb3b --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsString.kt @@ -0,0 +1,28 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: nullableNothingReturnTypeAsString.kt + +fun interface IFoo { + fun foo(): T +} + +var t = "Failed" + +fun test(s: String): Nothing? { + t = s + return null +} + +fun box(): String { + val q = Sam(::test).get("OK") + if (q != null) + return "Failed: $q" + return t +} + + +// FILE: Sam.java +public interface Sam { + String get(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/voidReturnTypeAsObject.kt b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/voidReturnTypeAsObject.kt new file mode 100644 index 00000000000..550a82dd70c --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/voidReturnTypeAsObject.kt @@ -0,0 +1,20 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +// FILE: voidReturnTypeAsObject.kt +var t = "Failed" + +fun ok(s: String) { t = s } + +fun box(): String { + val r = Sam(::ok).get("OK") + if (r != Unit) { + return "Failed: $r" + } + return t +} + +// FILE: Sam.java +public interface Sam { + Object get(String s); +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/intReturnTypeAsNumber.kt b/compiler/testData/codegen/box/invokedynamic/sam/intReturnTypeAsNumber.kt new file mode 100644 index 00000000000..215988d3e0c --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/intReturnTypeAsNumber.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface INum { + fun get(): Number +} + +fun box(): String { + val num = INum { 42 } + if (num.get() != 42) + return "Failed" + return "OK" +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithInProjection.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithInProjection.kt new file mode 100644 index 00000000000..8ee40e71c35 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithInProjection.kt @@ -0,0 +1,18 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface Cmp { + fun compare(a: T, b: T): Int +} + +fun foo(comparator: Cmp, a: T, b: T) = comparator.compare(a, b) + +fun bar(x: Int, y: Int) = foo({ a, b -> a - b}, x, y) + +fun box(): String { + val t = bar(42, 117) + if (t != -75) + return "Failed: t=$t" + return "OK" +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithStarProjection.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithStarProjection.kt new file mode 100644 index 00000000000..84e5e2f6ccb --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithStarProjection.kt @@ -0,0 +1,16 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND_FIR: JVM_IR +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY +fun interface Cmp { + fun compare(a: T, b: T): Int +} + +fun cmp(c: Cmp<*>) = c + +fun box(): String { + val c = cmp { _, _ -> 0 } as Cmp + if (c.compare(1, 2) != 0) + return "Failed" + return "OK" +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt index aa997eb4743..1ad8a6c7630 100644 --- a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt @@ -1,7 +1,6 @@ // TARGET_BACKEND: JVM // JVM_TARGET: 1.8 // SAM_CONVERSIONS: INDY -// IGNORE_DEXING fun interface GenericToAny { fun invoke(x: T): Any @@ -12,4 +11,4 @@ fun interface GenericCharToAny : GenericToAny fun withK(fn: GenericCharToAny) = fn.invoke('K').toString() fun box(): String = - withK { "O" + it } \ No newline at end of file + withK { "O" + it } diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsGeneric.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsGeneric.kt new file mode 100644 index 00000000000..c69addcf1c4 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsGeneric.kt @@ -0,0 +1,18 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface IFoo { + fun foo(): T +} + +fun foo(iFoo: IFoo) = iFoo.foo() + +fun box(): String { + try { + foo { throw RuntimeException("OK") } + } catch (e: RuntimeException) { + return e.message!! + } + return "Failed" +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsString.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsString.kt new file mode 100644 index 00000000000..2c6280d91fc --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsString.kt @@ -0,0 +1,18 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface IFoo { + fun foo(): String +} + +fun foo(iFoo: IFoo) = iFoo.foo() + +fun box(): String { + try { + foo { throw RuntimeException("OK") } + } catch (e: RuntimeException) { + return e.message!! + } + return "Failed" +} diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithChar.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithChar.kt new file mode 100644 index 00000000000..3084b7761d5 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithChar.kt @@ -0,0 +1,16 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: INDY + +fun interface GenericToAny { + fun invoke(Inner: T): Any +} + +fun foo2(t: T, g: GenericToAny): Any = g.invoke(t) + +fun box(): String { + foo2('.') { } + return "OK" +} + + diff --git a/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithCharClass.kt b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithCharClass.kt new file mode 100644 index 00000000000..7366e524789 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithCharClass.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// SAM_CONVERSIONS: CLASS + +fun interface GenericToAny { + fun invoke(Inner: T): Any +} + +fun foo2(t: T, g: GenericToAny): Any = g.invoke(t) + +fun box(): String { + foo2('.') { } + return "OK" +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 373a84800e0..c33a85383c9 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -20021,6 +20021,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @Test + @TestMetadata("intReturnTypeAsNumber.kt") + public void testIntReturnTypeAsNumber() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/intReturnTypeAsNumber.kt"); + } + @Test @TestMetadata("nullabilityAssertions.kt") public void testNullabilityAssertions() throws Exception { @@ -20220,6 +20226,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt"); } + @Test + @TestMetadata("intReturnTypeAsNumber.kt") + public void testIntReturnTypeAsNumber() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/intReturnTypeAsNumber.kt"); + } + @Test @TestMetadata("localFunction1.kt") public void testLocalFunction1() throws Exception { @@ -20244,11 +20256,41 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt"); } + @Test + @TestMetadata("nothingReturnTypeAsObject.kt") + public void testNothingReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsObject.kt"); + } + + @Test + @TestMetadata("nothingReturnTypeAsString.kt") + public void testNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsString.kt"); + } + + @Test + @TestMetadata("nullableNothingReturnTypeAsObject.kt") + public void testNullableNothingReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsObject.kt"); + } + + @Test + @TestMetadata("nullableNothingReturnTypeAsString.kt") + public void testNullableNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsString.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt"); } + + @Test + @TestMetadata("voidReturnTypeAsObject.kt") + public void testVoidReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/voidReturnTypeAsObject.kt"); + } } @Nested @@ -20354,6 +20396,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt"); } + @Test + @TestMetadata("genericWithInProjection.kt") + public void testGenericWithInProjection() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithInProjection.kt"); + } + + @Test + @TestMetadata("genericWithStarProjection.kt") + public void testGenericWithStarProjection() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithStarProjection.kt"); + } + @Test @TestMetadata("inheritedWithChar.kt") public void testInheritedWithChar() throws Exception { @@ -20414,6 +20468,30 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixPrimitiveAndBoxed.kt"); } + @Test + @TestMetadata("nothingReturnTypeAsGeneric.kt") + public void testNothingReturnTypeAsGeneric() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsGeneric.kt"); + } + + @Test + @TestMetadata("nothingReturnTypeAsString.kt") + public void testNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsString.kt"); + } + + @Test + @TestMetadata("specializedWithChar.kt") + public void testSpecializedWithChar() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithChar.kt"); + } + + @Test + @TestMetadata("specializedWithCharClass.kt") + public void testSpecializedWithCharClass() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithCharClass.kt"); + } + @Test @TestMetadata("voidReturnTypeAsGeneric.kt") public void testVoidReturnTypeAsGeneric() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index c873259ea07..5868bc5ebc8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -20021,6 +20021,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @Test + @TestMetadata("intReturnTypeAsNumber.kt") + public void testIntReturnTypeAsNumber() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/intReturnTypeAsNumber.kt"); + } + @Test @TestMetadata("nullabilityAssertions.kt") public void testNullabilityAssertions() throws Exception { @@ -20220,6 +20226,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt"); } + @Test + @TestMetadata("intReturnTypeAsNumber.kt") + public void testIntReturnTypeAsNumber() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/intReturnTypeAsNumber.kt"); + } + @Test @TestMetadata("localFunction1.kt") public void testLocalFunction1() throws Exception { @@ -20244,11 +20256,41 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt"); } + @Test + @TestMetadata("nothingReturnTypeAsObject.kt") + public void testNothingReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsObject.kt"); + } + + @Test + @TestMetadata("nothingReturnTypeAsString.kt") + public void testNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsString.kt"); + } + + @Test + @TestMetadata("nullableNothingReturnTypeAsObject.kt") + public void testNullableNothingReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsObject.kt"); + } + + @Test + @TestMetadata("nullableNothingReturnTypeAsString.kt") + public void testNullableNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsString.kt"); + } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt"); } + + @Test + @TestMetadata("voidReturnTypeAsObject.kt") + public void testVoidReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/voidReturnTypeAsObject.kt"); + } } @Nested @@ -20354,6 +20396,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt"); } + @Test + @TestMetadata("genericWithInProjection.kt") + public void testGenericWithInProjection() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithInProjection.kt"); + } + + @Test + @TestMetadata("genericWithStarProjection.kt") + public void testGenericWithStarProjection() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithStarProjection.kt"); + } + @Test @TestMetadata("inheritedWithChar.kt") public void testInheritedWithChar() throws Exception { @@ -20414,6 +20468,30 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixPrimitiveAndBoxed.kt"); } + @Test + @TestMetadata("nothingReturnTypeAsGeneric.kt") + public void testNothingReturnTypeAsGeneric() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsGeneric.kt"); + } + + @Test + @TestMetadata("nothingReturnTypeAsString.kt") + public void testNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsString.kt"); + } + + @Test + @TestMetadata("specializedWithChar.kt") + public void testSpecializedWithChar() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithChar.kt"); + } + + @Test + @TestMetadata("specializedWithCharClass.kt") + public void testSpecializedWithCharClass() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithCharClass.kt"); + } + @Test @TestMetadata("voidReturnTypeAsGeneric.kt") public void testVoidReturnTypeAsGeneric() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 91c7aec724b..cdaebd624d9 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -16791,6 +16791,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/genericFunInterfaceWithPrimitive.kt"); } + @TestMetadata("intReturnTypeAsNumber.kt") + public void testIntReturnTypeAsNumber() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/intReturnTypeAsNumber.kt"); + } + @TestMetadata("nullabilityAssertions.kt") public void testNullabilityAssertions() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/nullabilityAssertions.kt"); @@ -16961,6 +16966,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/innerConstructorRef.kt"); } + @TestMetadata("intReturnTypeAsNumber.kt") + public void testIntReturnTypeAsNumber() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/intReturnTypeAsNumber.kt"); + } + @TestMetadata("localFunction1.kt") public void testLocalFunction1() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/localFunction1.kt"); @@ -16981,10 +16991,35 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nonTrivialReceiver.kt"); } + @TestMetadata("nothingReturnTypeAsObject.kt") + public void testNothingReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsObject.kt"); + } + + @TestMetadata("nothingReturnTypeAsString.kt") + public void testNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nothingReturnTypeAsString.kt"); + } + + @TestMetadata("nullableNothingReturnTypeAsObject.kt") + public void testNullableNothingReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsObject.kt"); + } + + @TestMetadata("nullableNothingReturnTypeAsString.kt") + public void testNullableNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/nullableNothingReturnTypeAsString.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/simple.kt"); } + + @TestMetadata("voidReturnTypeAsObject.kt") + public void testVoidReturnTypeAsObject() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/functionRefToJavaInterface/voidReturnTypeAsObject.kt"); + } } @TestMetadata("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature") @@ -17087,6 +17122,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/covariantOverrideWithNNothing.kt"); } + @TestMetadata("genericWithInProjection.kt") + public void testGenericWithInProjection() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithInProjection.kt"); + } + + @TestMetadata("genericWithStarProjection.kt") + public void testGenericWithStarProjection() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/genericWithStarProjection.kt"); + } + @TestMetadata("inheritedWithChar.kt") public void testInheritedWithChar() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/inheritedWithChar.kt"); @@ -17132,6 +17177,26 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/mixGenericArrayAndArrayOfString.kt"); } + @TestMetadata("nothingReturnTypeAsGeneric.kt") + public void testNothingReturnTypeAsGeneric() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsGeneric.kt"); + } + + @TestMetadata("nothingReturnTypeAsString.kt") + public void testNothingReturnTypeAsString() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/nothingReturnTypeAsString.kt"); + } + + @TestMetadata("specializedWithChar.kt") + public void testSpecializedWithChar() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithChar.kt"); + } + + @TestMetadata("specializedWithCharClass.kt") + public void testSpecializedWithCharClass() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/specializedWithCharClass.kt"); + } + @TestMetadata("voidReturnTypeAsGeneric.kt") public void testVoidReturnTypeAsGeneric() throws Exception { runTest("compiler/testData/codegen/box/invokedynamic/sam/specializedGenerics/voidReturnTypeAsGeneric.kt"); From 4e5647090e14063b557389f89cfb988b6fa4479d Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Thu, 18 Feb 2021 16:29:59 +0300 Subject: [PATCH 346/368] Approximate captured types in contravariant positions properly ^KT-43802 Fixed --- ...irOldFrontendDiagnosticsTestGenerated.java | 6 ++ .../kotlin/resolve/calls/CallCompleter.kt | 8 ++- .../resolve/calls/GenericCandidateResolver.kt | 8 ++- .../calls/inference/ConstraintSystemImpl.kt | 4 -- ...proximateContravariantCapturedTypes.fir.kt | 60 +++++++++++++++++++ .../approximateContravariantCapturedTypes.kt | 60 +++++++++++++++++++ .../approximateContravariantCapturedTypes.txt | 27 +++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 ++ .../kotlin/types/TypeSubstitution.kt | 9 +++ .../kotlin/types/TypeSubstitutor.java | 23 +++++++ 10 files changed, 205 insertions(+), 6 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.fir.kt create mode 100644 compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.kt create mode 100644 compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 680ab4c470d..387c875b7b2 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -12370,6 +12370,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/approximateBeforeFixation.kt"); } + @Test + @TestMetadata("approximateContravariantCapturedTypes.kt") + public void testApproximateContravariantCapturedTypes() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.kt"); + } + @Test @TestMetadata("avoidCreatingUselessCapturedTypes.kt") public void testAvoidCreatingUselessCapturedTypes() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index 554759a6af7..e27ac4b3977 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.resolve.calls import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType import org.jetbrains.kotlin.builtins.getValueParameterTypesFromFunctionType import org.jetbrains.kotlin.builtins.isFunctionOrSuspendFunctionType +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.contracts.EffectSystem import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor @@ -248,7 +249,12 @@ class CallCompleter( val system = builder.build() setConstraintSystem(system) - setResultingSubstitutor(system.resultingSubstitutor) + val isNewInferenceEnabled = effectSystem.languageVersionSettings.supportsFeature(LanguageFeature.NewInference) + val resultingSubstitutor = if (isNewInferenceEnabled) { + system.resultingSubstitutor.replaceWithContravariantApproximatingSubstitution() + } else system.resultingSubstitutor + + setResultingSubstitutor(resultingSubstitutor) } private fun MutableResolvedCall.updateResolutionStatusFromConstraintSystem( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index 32198514bcb..24a35e347cd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -347,7 +347,13 @@ class GenericCandidateResolver( } val resultingSystem = constraintSystem.build() resolvedCall.setConstraintSystem(resultingSystem) - resolvedCall.setResultingSubstitutor(resultingSystem.resultingSubstitutor) + + val isNewInferenceEnabled = languageVersionSettings.supportsFeature(LanguageFeature.NewInference) + val resultingSubstitutor = if (isNewInferenceEnabled) { + resultingSystem.resultingSubstitutor.replaceWithContravariantApproximatingSubstitution() + } else resultingSystem.resultingSubstitutor + + resolvedCall.setResultingSubstitutor(resultingSubstitutor) } // See KT-5385 diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index 524b09462cb..66b667ca1ae 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -151,10 +151,6 @@ internal class ConstraintSystemImpl( ) } - private class SubstitutionWithCapturedTypeApproximation(substitution: TypeSubstitution) : DelegatedTypeSubstitution(substitution) { - override fun approximateCapturedTypes() = true - } - private fun satisfyInitialConstraints(): Boolean { val substitutor = getSubstitutor(substituteOriginal = false) { ErrorUtils.createUninferredParameterType(it.originalTypeParameter) } fun KotlinType.substitute(): KotlinType? = substitutor.substitute(this, Variance.INVARIANT) diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.fir.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.fir.kt new file mode 100644 index 00000000000..f309d330487 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.fir.kt @@ -0,0 +1,60 @@ +class Foo(var x: T) { + fun setX1(y: T): T { + this.x = y + return y + } +} + +fun Foo.setX(y: T): T { + return y +} + +class Foo2(var x: T) { + fun setX1(y: T): T { + this.x = y + return y + } +} + +fun Foo2.setX(y: T): T { + this.x = y + return y +} + +fun Float.bar() {} + +fun test1() { + val fooSetRef = Foo<*>::setX + val foo = Foo(1f) + + fooSetRef.invoke(foo, 1) + + foo.x.bar() +} + +fun test2() { + val fooSetRef = , CapturedType(*), CapturedType(*)>")!>Foo<*>::setX1 + val foo = Foo(1f) + + fooSetRef.invoke(foo, 1) + + foo.x.bar() +} + +fun test3() { + val fooSetRef = Foo2<*>::setX + val foo = Foo2(1) + + fooSetRef.invoke(foo, "") + + foo.x.bar() +} + +fun test4() { + val fooSetRef = , CapturedType(*), CapturedType(*)>")!>Foo2<*>::setX1 + val foo = Foo2(1) + + fooSetRef.invoke(foo, "") + + foo.x.bar() +} diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.kt new file mode 100644 index 00000000000..966203018bb --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.kt @@ -0,0 +1,60 @@ +class Foo(var x: T) { + fun setX1(y: T): T { + this.x = y + return y + } +} + +fun Foo.setX(y: T): T { + return y +} + +class Foo2(var x: T) { + fun setX1(y: T): T { + this.x = y + return y + } +} + +fun Foo2.setX(y: T): T { + this.x = y + return y +} + +fun Float.bar() {} + +fun test1() { + val fooSetRef = , kotlin.Nothing, kotlin.Number>")!>Foo<*>::")!>setX + val foo = Foo(1f) + + fooSetRef.invoke(foo, 1) + + foo.x.bar() +} + +fun test2() { + val fooSetRef = , kotlin.Nothing, kotlin.Number>")!>Foo<*>::setX1 + val foo = Foo(1f) + + fooSetRef.invoke(foo, 1) + + foo.x.bar() +} + +fun test3() { + val fooSetRef = , kotlin.Nothing, kotlin.Any?>")!>Foo2<*>::")!>setX + val foo = Foo2(1) + + fooSetRef.invoke(foo, "") + + foo.x.bar() +} + +fun test4() { + val fooSetRef = , kotlin.Nothing, kotlin.Any?>")!>Foo2<*>::setX1 + val foo = Foo2(1) + + fooSetRef.invoke(foo, "") + + foo.x.bar() +} diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.txt b/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.txt new file mode 100644 index 00000000000..b3b5d87f1ec --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.txt @@ -0,0 +1,27 @@ +package + +public fun test1(): kotlin.Unit +public fun test2(): kotlin.Unit +public fun test3(): kotlin.Unit +public fun test4(): kotlin.Unit +public fun kotlin.Float.bar(): kotlin.Unit +public fun Foo2.setX(/*0*/ y: T): T +public fun Foo.setX(/*0*/ y: T): T + +public final class Foo { + public constructor Foo(/*0*/ x: T) + public final var x: T + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun setX1(/*0*/ y: T): T + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class Foo2 { + public constructor Foo2(/*0*/ x: T) + public final var x: T + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final fun setX1(/*0*/ y: T): T + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 5dd7cce0ee2..3a7ba5e4092 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -12376,6 +12376,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/approximateBeforeFixation.kt"); } + @Test + @TestMetadata("approximateContravariantCapturedTypes.kt") + public void testApproximateContravariantCapturedTypes() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/approximateContravariantCapturedTypes.kt"); + } + @Test @TestMetadata("avoidCreatingUselessCapturedTypes.kt") public void testAvoidCreatingUselessCapturedTypes() throws Exception { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt index cf9b1cc6ffd..835936ae961 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt @@ -85,6 +85,15 @@ abstract class TypeConstructorSubstitution : TypeSubstitution() { } } +class SubstitutionWithCapturedTypeApproximation(substitution: TypeSubstitution) : DelegatedTypeSubstitution(substitution) { + override fun approximateCapturedTypes() = true +} + +class SubstitutionWithContravariantCapturedTypeApproximation(substitution: TypeSubstitution) : DelegatedTypeSubstitution(substitution) { + override fun approximateCapturedTypes() = true + override fun approximateContravariantCapturedTypes() = true +} + class IndexedParametersSubstitution( val parameters: Array, val arguments: Array, diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java index da175c6f513..78737803f4f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java @@ -67,6 +67,29 @@ public class TypeSubstitutor implements TypeSubstitutorMarker { ); } + @NotNull + public TypeSubstitutor replaceWithContravariantApproximatingSubstitution() { + if (substitution instanceof SubstitutionWithCapturedTypeApproximation) { + return new TypeSubstitutor( + new SubstitutionWithContravariantCapturedTypeApproximation( + ((SubstitutionWithCapturedTypeApproximation) substitution).getSubstitution() + ) + ); + } + + if (substitution instanceof IndexedParametersSubstitution && !substitution.approximateContravariantCapturedTypes()) { + return new TypeSubstitutor( + new IndexedParametersSubstitution( + ((IndexedParametersSubstitution) substitution).getParameters(), + ((IndexedParametersSubstitution) substitution).getArguments(), + true + ) + ); + } + + return this; + } + @NotNull public static TypeSubstitutor createChainedSubstitutor(@NotNull TypeSubstitution first, @NotNull TypeSubstitution second) { return create(DisjointKeysUnionTypeSubstitution.create(first, second)); From ea2783eace486e37b95f062ece72ad4b9aa7e415 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Sat, 20 Feb 2021 15:26:01 +0300 Subject: [PATCH 347/368] [FIR] Fix generating `this` reference in delegated accessors There was a problem with delegated extension property with dispatch receiver that `this` in `getValue` call was set to dispatch receiver instead of extension one --- .../kotlin/fir/builder/ConversionUtils.kt | 18 ++-- .../delegateForExtPropertyInClass.kt | 1 - .../mixedArgumentSizes.kt | 3 +- .../provideDelegate/memberExtension.kt | 3 +- .../deepGenericDelegatedProperty.kt | 3 +- .../memberExtension.fir.kt.txt | 39 ------- .../provideDelegate/memberExtension.fir.txt | 102 ------------------ .../provideDelegate/memberExtension.kt | 1 + .../genericDelegatedDeepProperty.fir.txt | 4 +- 9 files changed, 15 insertions(+), 159 deletions(-) delete mode 100644 compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt diff --git a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt index cc5311b4a43..63be80096f5 100644 --- a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt +++ b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/ConversionUtils.kt @@ -309,8 +309,14 @@ fun FirPropertyBuilder.generateAccessorsByDelegate( * And for this case we can pass isForDelegateProviderCall to this reference * generator function */ - fun thisRef(isForDelegateProviderCall: Boolean = false): FirExpression = + fun thisRef(forDispatchReceiver: Boolean = false): FirExpression = when { + isExtension && !forDispatchReceiver -> buildThisReceiverExpression { + source = fakeSource + calleeReference = buildImplicitThisReference { + boundSymbol = this@generateAccessorsByDelegate.symbol + } + } ownerSymbol != null -> buildThisReceiverExpression { source = fakeSource calleeReference = buildImplicitThisReference { @@ -321,12 +327,6 @@ fun FirPropertyBuilder.generateAccessorsByDelegate( type = ownerSymbol.constructStarProjectedType(typeParameterNumber) } } - isExtension && !isForDelegateProviderCall -> buildThisReceiverExpression { - source = fakeSource - calleeReference = buildImplicitThisReference { - boundSymbol = this@generateAccessorsByDelegate.symbol - } - } else -> buildConstExpression(null, ConstantValueKind.Null, null) } @@ -336,7 +336,7 @@ fun FirPropertyBuilder.generateAccessorsByDelegate( resolvedSymbol = delegateFieldSymbol } if (ownerSymbol != null) { - dispatchReceiver = thisRef() + dispatchReceiver = thisRef(forDispatchReceiver = true) } } @@ -373,7 +373,7 @@ fun FirPropertyBuilder.generateAccessorsByDelegate( source = fakeSource name = PROVIDE_DELEGATE } - argumentList = buildBinaryArgumentList(thisRef(isForDelegateProviderCall = true), propertyRef()) + argumentList = buildBinaryArgumentList(thisRef(forDispatchReceiver = true), propertyRef()) } delegate = delegateBuilder.build() if (stubMode) return diff --git a/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt b/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt index 03986df0169..7cdaca652eb 100644 --- a/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt +++ b/compiler/testData/codegen/box/delegatedProperty/delegateForExtPropertyInClass.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR import kotlin.reflect.KProperty class Delegate { diff --git a/compiler/testData/codegen/box/delegatedProperty/optimizedDelegatedProperties/mixedArgumentSizes.kt b/compiler/testData/codegen/box/delegatedProperty/optimizedDelegatedProperties/mixedArgumentSizes.kt index 41a0a1ebd3e..5baa4cf3330 100644 --- a/compiler/testData/codegen/box/delegatedProperty/optimizedDelegatedProperties/mixedArgumentSizes.kt +++ b/compiler/testData/codegen/box/delegatedProperty/optimizedDelegatedProperties/mixedArgumentSizes.kt @@ -1,6 +1,5 @@ // !LANGUAGE: -NewInference -// IGNORE_BACKEND_FIR: JVM_IR inline operator fun Double.provideDelegate(thisRef: Any?, kProp: Any?) = this.toLong() inline operator fun Long.getValue(thisRef: Any?, kProp: Any?) = this.toInt() @@ -59,4 +58,4 @@ fun box(): String { x.test(intArray) return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/delegatedProperty/provideDelegate/memberExtension.kt b/compiler/testData/codegen/box/delegatedProperty/provideDelegate/memberExtension.kt index 2fb4088ed9d..b8f1051a749 100644 --- a/compiler/testData/codegen/box/delegatedProperty/provideDelegate/memberExtension.kt +++ b/compiler/testData/codegen/box/delegatedProperty/provideDelegate/memberExtension.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME object Host { @@ -13,4 +12,4 @@ object Host { val ok = "O".plusK } -fun box(): String = Host.ok \ No newline at end of file +fun box(): String = Host.ok diff --git a/compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.kt b/compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.kt index 9f682ba712d..db0654692ec 100644 --- a/compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.kt +++ b/compiler/testData/codegen/box/ir/serializationRegressions/deepGenericDelegatedProperty.kt @@ -1,6 +1,5 @@ // DONT_TARGET_EXACT_BACKEND: WASM // WASM_MUTE_REASON: PROPERTY_REFERENCES -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: NATIVE //For KT-6020 @@ -59,4 +58,4 @@ fun box(): String { val p = Value("O", CR("K")) val rr = p.additionalText return rr.p1 + rr.p2 -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.kt.txt b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.kt.txt deleted file mode 100644 index 175e23fdae8..00000000000 --- a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.kt.txt +++ /dev/null @@ -1,39 +0,0 @@ -object Host { - private constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - class StringDelegate { - constructor(s: String) /* primary */ { - super/*Any*/() - /* () */ - - } - - val s: String - field = s - get - - operator fun getValue(receiver: String, p: Any): String { - return receiver.plus(other = .()) - } - - } - - operator fun String.provideDelegate(host: Any?, p: Any): StringDelegate { - return StringDelegate(s = ) - } - - val String.plusK: String /* by */ - field = (, "K").provideDelegate(host = , p = Host::plusK) - get(): String { - return .#plusK$delegate.getValue(receiver = , p = Host::plusK) - } - - val ok: String - field = (, "O").() - get - -} diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt deleted file mode 100644 index d317677272b..00000000000 --- a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.fir.txt +++ /dev/null @@ -1,102 +0,0 @@ -FILE fqName: fileName:/memberExtension.kt - CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Host - CONSTRUCTOR visibility:private <> () returnType:.Host [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' - CLASS CLASS name:StringDelegate modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Host.StringDelegate - CONSTRUCTOR visibility:public <> (s:kotlin.String) returnType:.Host.StringDelegate [primary] - VALUE_PARAMETER name:s index:0 type:kotlin.String - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:StringDelegate modality:FINAL visibility:public superTypes:[kotlin.Any]' - PROPERTY name:s visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final] - EXPRESSION_BODY - GET_VAR 's: kotlin.String declared in .Host.StringDelegate.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host.StringDelegate) returnType:kotlin.String - correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Host.StringDelegate - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Host.StringDelegate' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .Host.StringDelegate declared in .Host.StringDelegate.' type=.Host.StringDelegate origin=null - FUN name:getValue visibility:public modality:FINAL <> ($this:.Host.StringDelegate, receiver:kotlin.String, p:kotlin.Any) returnType:kotlin.String [operator] - $this: VALUE_PARAMETER name: type:.Host.StringDelegate - VALUE_PARAMETER name:receiver index:0 type:kotlin.String - VALUE_PARAMETER name:p index:1 type:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun getValue (receiver: kotlin.String, p: kotlin.Any): kotlin.String [operator] declared in .Host.StringDelegate' - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS - $this: GET_VAR 'receiver: kotlin.String declared in .Host.StringDelegate.getValue' type=kotlin.String origin=null - other: CALL 'public final fun (): kotlin.String declared in .Host.StringDelegate' type=kotlin.String origin=GET_PROPERTY - $this: GET_VAR ': .Host.StringDelegate declared in .Host.StringDelegate.getValue' type=.Host.StringDelegate origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:provideDelegate visibility:public modality:FINAL <> ($this:.Host, $receiver:kotlin.String, host:kotlin.Any?, p:kotlin.Any) returnType:.Host.StringDelegate [operator] - $this: VALUE_PARAMETER name: type:.Host - $receiver: VALUE_PARAMETER name: type:kotlin.String - VALUE_PARAMETER name:host index:0 type:kotlin.Any? - VALUE_PARAMETER name:p index:1 type:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun provideDelegate (host: kotlin.Any?, p: kotlin.Any): .Host.StringDelegate [operator] declared in .Host' - CONSTRUCTOR_CALL 'public constructor (s: kotlin.String) [primary] declared in .Host.StringDelegate' type=.Host.StringDelegate origin=null - s: GET_VAR ': kotlin.String declared in .Host.provideDelegate' type=kotlin.String origin=null - PROPERTY name:plusK visibility:public modality:FINAL [delegated,val] - FIELD PROPERTY_DELEGATE name:plusK$delegate type:.Host.StringDelegate visibility:private [final] - EXPRESSION_BODY - CALL 'public final fun provideDelegate (host: kotlin.Any?, p: kotlin.Any): .Host.StringDelegate [operator] declared in .Host' type=.Host.StringDelegate origin=null - $this: GET_VAR ': .Host declared in .Host' type=.Host origin=null - $receiver: CONST String type=kotlin.String value="K" - host: GET_VAR ': .Host declared in .Host' type=.Host origin=null - p: PROPERTY_REFERENCE 'public final plusK: kotlin.String [delegated,val]' field=null getter='public final fun (): kotlin.String declared in .Host' setter=null type=kotlin.reflect.KProperty2.Host, kotlin.String> origin=PROPERTY_REFERENCE_FOR_DELEGATE - FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host, $receiver:kotlin.String) returnType:kotlin.String - correspondingProperty: PROPERTY name:plusK visibility:public modality:FINAL [delegated,val] - $this: VALUE_PARAMETER name: type:.Host - $receiver: VALUE_PARAMETER name: type:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Host' - CALL 'public final fun getValue (receiver: kotlin.String, p: kotlin.Any): kotlin.String [operator] declared in .Host.StringDelegate' type=kotlin.String origin=null - $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:plusK$delegate type:.Host.StringDelegate visibility:private [final]' type=.Host.StringDelegate origin=null - receiver: GET_VAR ': .Host declared in .Host.' type=.Host origin=null - receiver: GET_VAR ': .Host declared in .Host.' type=.Host origin=null - p: PROPERTY_REFERENCE 'public final plusK: kotlin.String [delegated,val]' field=null getter='public final fun (): kotlin.String declared in .Host' setter=null type=kotlin.reflect.KProperty2.Host, kotlin.String> origin=PROPERTY_REFERENCE_FOR_DELEGATE - PROPERTY name:ok visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:ok type:kotlin.String visibility:private [final] - EXPRESSION_BODY - CALL 'public final fun (): kotlin.String declared in .Host' type=kotlin.String origin=GET_PROPERTY - $this: GET_VAR ': .Host declared in .Host' type=.Host origin=null - $receiver: CONST String type=kotlin.String value="O" - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.String - correspondingProperty: PROPERTY name:ok visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Host - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Host' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:ok type:kotlin.String visibility:private [final]' type=kotlin.String origin=null - receiver: GET_VAR ': .Host declared in .Host.' type=.Host origin=null - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.kt b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.kt index bf538dbb143..28bbeaa82c2 100644 --- a/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.kt +++ b/compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL object Host { class StringDelegate(val s: String) { operator fun getValue(receiver: String, p: Any) = receiver + s diff --git a/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.txt b/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.txt index 21eccadcd6a..0787739c069 100644 --- a/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.txt +++ b/compiler/testData/ir/irText/types/genericDelegatedDeepProperty.fir.txt @@ -281,7 +281,7 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:deepO$delegate type:.additionalText$delegate..deepO$delegate..> visibility:private [final]' type=.additionalText$delegate..deepO$delegate..> origin=null receiver: TYPE_OP type=.additionalText$delegate. origin=IMPLICIT_CAST typeOperand=.additionalText$delegate. GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..' type=.additionalText$delegate..> origin=null - t: GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..' type=.additionalText$delegate..> origin=null + t: GET_VAR ': .Value., .CR.>> declared in .additionalText$delegate..' type=.Value., .CR.>> origin=null p: PROPERTY_REFERENCE 'private final deepO: T of . [delegated,val]' field=null getter='public final fun (): T of . declared in .additionalText$delegate.' setter=null type=kotlin.reflect.KProperty2<.Value., .CR.>>, *, T of .> origin=PROPERTY_REFERENCE_FOR_DELEGATE PROPERTY name:deepK visibility:private modality:FINAL [delegated,val] FIELD PROPERTY_DELEGATE name:deepK$delegate type:.additionalText$delegate..deepK$delegate..> visibility:private [final] @@ -328,7 +328,7 @@ FILE fqName: fileName:/genericDelegatedDeepProperty.kt $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:deepK$delegate type:.additionalText$delegate..deepK$delegate..> visibility:private [final]' type=.additionalText$delegate..deepK$delegate..> origin=null receiver: TYPE_OP type=.additionalText$delegate. origin=IMPLICIT_CAST typeOperand=.additionalText$delegate. GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..' type=.additionalText$delegate..> origin=null - t: GET_VAR ': .additionalText$delegate..> declared in .additionalText$delegate..' type=.additionalText$delegate..> origin=null + t: GET_VAR ': .Value., .CR.>> declared in .additionalText$delegate..' type=.Value., .CR.>> origin=null p: PROPERTY_REFERENCE 'private final deepK: T of . [delegated,val]' field=null getter='public final fun (): T of . declared in .additionalText$delegate.' setter=null type=kotlin.reflect.KProperty2<.Value., .CR.>>, *, T of .> origin=PROPERTY_REFERENCE_FOR_DELEGATE FUN name:getValue visibility:public modality:FINAL <> ($this:.additionalText$delegate..>, t:.Value., .CR.>>, p:kotlin.reflect.KProperty<*>) returnType:.P., T of .> [operator] overridden: From 13dfa5a8867168b3761850d0a13b0fe6e49dc7b4 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Sat, 20 Feb 2021 10:50:47 +0300 Subject: [PATCH 348/368] [FIR2IR] Add handling exceptions from Fir2Ir and reporting declaration where converter failed --- .../fir/backend/Fir2IrDeclarationStorage.kt | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index 21abbb3edad..5538d589258 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -51,6 +51,7 @@ import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource +import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments import org.jetbrains.kotlin.utils.threadLocal import java.util.concurrent.ConcurrentHashMap @@ -439,7 +440,7 @@ class Fir2IrDeclarationStorage( origin: IrDeclarationOrigin = IrDeclarationOrigin.DEFINED, isLocal: Boolean = false, containingClass: ConeClassLikeLookupTag? = null, - ): IrSimpleFunction { + ): IrSimpleFunction = convertCatching(function) { val simpleFunction = function as? FirSimpleFunction val isLambda = function.source?.elementType == KtNodeTypes.FUNCTION_LITERAL val updatedOrigin = when { @@ -505,7 +506,7 @@ class Fir2IrDeclarationStorage( fun createIrAnonymousInitializer( anonymousInitializer: FirAnonymousInitializer, irParent: IrClass - ): IrAnonymousInitializer { + ): IrAnonymousInitializer = convertCatching(anonymousInitializer) { return anonymousInitializer.convertWithOffsets { startOffset, endOffset -> symbolTable.declareAnonymousInitializer(startOffset, endOffset, IrDeclarationOrigin.DEFINED, irParent.descriptor).apply { this.parent = irParent @@ -539,7 +540,7 @@ class Fir2IrDeclarationStorage( irParent: IrClass, origin: IrDeclarationOrigin = IrDeclarationOrigin.DEFINED, isLocal: Boolean = false - ): IrConstructor { + ): IrConstructor = convertCatching(constructor) { val isPrimary = constructor.isPrimary classifierStorage.preCacheTypeParameters(constructor) val signature = if (isLocal) null else signatureComposer.composeSignature(constructor) @@ -595,7 +596,7 @@ class Fir2IrDeclarationStorage( endOffset: Int, isLocal: Boolean = false, containingClass: ConeClassLikeLookupTag? = null, - ): IrSimpleFunction { + ): IrSimpleFunction = convertCatching(propertyAccessor ?: property) { val prefix = if (isSetter) "set" else "get" val signature = if (isLocal) null else signatureComposer.composeAccessorSignature(property, isSetter, containingClass) val containerSource = (correspondingProperty as? IrProperty)?.containerSource @@ -667,7 +668,7 @@ class Fir2IrDeclarationStorage( isFinal: Boolean, firInitializerExpression: FirExpression?, type: IrType? = null - ): IrField { + ): IrField = convertCatching(property) { val inferredType = type ?: firInitializerExpression!!.typeRef.toIrType() return symbolTable.declareField( startOffset, endOffset, origin, descriptor, inferredType @@ -748,7 +749,7 @@ class Fir2IrDeclarationStorage( origin: IrDeclarationOrigin = IrDeclarationOrigin.DEFINED, isLocal: Boolean = false, containingClass: ConeClassLikeLookupTag? = null, - ): IrProperty { + ): IrProperty = convertCatching(property) { classifierStorage.preCacheTypeParameters(property) if (property.delegate != null) { val delegateReference = (property.delegate as? FirQualifiedAccess)?.calleeReference as? FirResolvedNamedReference @@ -882,7 +883,7 @@ class Fir2IrDeclarationStorage( private fun createIrField( field: FirField, origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_EXTERNAL_JAVA_DECLARATION_STUB - ): IrField { + ): IrField = convertCatching(field) { val type = field.returnTypeRef.toIrType() return field.convertWithOffsets { startOffset, endOffset -> irFactory.createField( @@ -907,7 +908,7 @@ class Fir2IrDeclarationStorage( useStubForDefaultValueStub: Boolean = true, typeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT, skipDefaultParameter: Boolean = false, - ): IrValueParameter { + ): IrValueParameter = convertCatching(valueParameter) { val origin = IrDeclarationOrigin.DEFINED val type = valueParameter.returnTypeRef.toIrType() val irParameter = valueParameter.convertWithOffsets { startOffset, endOffset -> @@ -954,7 +955,11 @@ class Fir2IrDeclarationStorage( isVar, isConst, isLateinit ) - fun createIrVariable(variable: FirVariable<*>, irParent: IrDeclarationParent, givenOrigin: IrDeclarationOrigin? = null): IrVariable { + fun createIrVariable( + variable: FirVariable<*>, + irParent: IrDeclarationParent, + givenOrigin: IrDeclarationOrigin? = null + ): IrVariable = convertCatching(variable) { val type = variable.returnTypeRef.toIrType() // Some temporary variables are produced in RawFirBuilder, but we consistently use special names for them. val origin = when { @@ -975,7 +980,10 @@ class Fir2IrDeclarationStorage( return irVariable } - fun createIrLocalDelegatedProperty(property: FirProperty, irParent: IrDeclarationParent): IrLocalDelegatedProperty { + fun createIrLocalDelegatedProperty( + property: FirProperty, + irParent: IrDeclarationParent + ): IrLocalDelegatedProperty = convertCatching(property) { val type = property.returnTypeRef.toIrType() val origin = IrDeclarationOrigin.DEFINED val irProperty = property.convertWithOffsets { startOffset, endOffset -> @@ -1256,4 +1264,12 @@ class Fir2IrDeclarationStorage( Name.identifier("valueOf") to IrSyntheticBodyKind.ENUM_VALUEOF ) } + + private inline fun convertCatching(element: FirElement, block: () -> R): R { + try { + return block() + } catch (e: Throwable) { + throw KotlinExceptionWithAttachments("Exception was thrown during transformation of ${element.render()}", e) + } + } } From d9be59ea97c95b2d9b4d5f305dd9e892d07cfc54 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Sat, 20 Feb 2021 16:59:08 +0300 Subject: [PATCH 349/368] [JS IR] JS code in init block only for js ir backend test --- .../kotlin/js/test/semantics/BoxJsTestGenerated.java | 5 ----- js/js.translator/testData/box/jsCode/init.kt | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java index b0085c52349..74d0097f158 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java @@ -5120,11 +5120,6 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { runTest("js/js.translator/testData/box/jsCode/if.kt"); } - @TestMetadata("init.kt") - public void testInit() throws Exception { - runTest("js/js.translator/testData/box/jsCode/init.kt"); - } - @TestMetadata("invocation.kt") public void testInvocation() throws Exception { runTest("js/js.translator/testData/box/jsCode/invocation.kt"); diff --git a/js/js.translator/testData/box/jsCode/init.kt b/js/js.translator/testData/box/jsCode/init.kt index f53e8569146..3020457c10b 100644 --- a/js/js.translator/testData/box/jsCode/init.kt +++ b/js/js.translator/testData/box/jsCode/init.kt @@ -1,4 +1,5 @@ -// EXPECTED_REACHABLE_NODES: 1282 +// TARGET_BACKEND: JS_IR + package foo class A { From 4643f12a5f122d3b394c7b1acf87b81549e4d557 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Sat, 20 Feb 2021 21:35:48 +0300 Subject: [PATCH 350/368] Ignore JVM test in Native backend --- compiler/testData/codegen/box/javaInterop/generics/kt42825.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/testData/codegen/box/javaInterop/generics/kt42825.kt b/compiler/testData/codegen/box/javaInterop/generics/kt42825.kt index 70ade460cbe..da1daecb5a6 100644 --- a/compiler/testData/codegen/box/javaInterop/generics/kt42825.kt +++ b/compiler/testData/codegen/box/javaInterop/generics/kt42825.kt @@ -1,6 +1,7 @@ // DONT_TARGET_EXACT_BACKEND: WASM // IGNORE_BACKEND: JS // IGNORE_BACKEND: JS_IR +// IGNORE_BACKEND: NATIVE // FILE: Processor.java public interface Processor { From 95a8c60a9ce122d388edd9131c53f69ff6c46408 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Sun, 21 Feb 2021 11:11:06 +0300 Subject: [PATCH 351/368] Ignore test in Native backend. Test overrides kotlin.Result --- compiler/testData/codegen/box/inlineClasses/result.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/testData/codegen/box/inlineClasses/result.kt b/compiler/testData/codegen/box/inlineClasses/result.kt index 9e9b036233b..b86ee2f1270 100644 --- a/compiler/testData/codegen/box/inlineClasses/result.kt +++ b/compiler/testData/codegen/box/inlineClasses/result.kt @@ -1,6 +1,7 @@ // IGNORE_BACKEND: WASM, JS_IR // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: ANDROID +// IGNORE_BACKEND: NATIVE // FILE: result.kt package kotlin From 073a50037049a4e0869085bf4acf7c29e56210e3 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Sun, 21 Feb 2021 11:12:33 +0300 Subject: [PATCH 352/368] Change order of WITH_RUNTIME and FILE. Wrong order brakes module pattern. --- .../testData/codegen/box/fakeOverride/privateFakeOverrides0.kt | 2 +- .../testData/codegen/box/fakeOverride/privateFakeOverrides1.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides0.kt b/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides0.kt index ada4c892a50..b4f805a0fe0 100644 --- a/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides0.kt +++ b/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides0.kt @@ -1,6 +1,6 @@ // MODULE: lib -// WITH_RUNTIME // FILE: lib.kt +// WITH_RUNTIME import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides1.kt b/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides1.kt index 6317714f618..b177cc918d0 100644 --- a/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides1.kt +++ b/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides1.kt @@ -1,6 +1,6 @@ // MODULE: lib -// WITH_RUNTIME // FILE: lib.kt +// WITH_RUNTIME import kotlin.test.assertEquals From d5ca285a7984d9bb21c841d3a890f4a967e26791 Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Tue, 16 Feb 2021 12:03:52 +0300 Subject: [PATCH 353/368] Move unhandledExceptionHook to kotlin code (#4704) --- .../backend.native/tests/build.gradle | 10 +++++++- .../tests/runtime/exceptions/custom_hook.kt | 24 ++++-------------- .../exceptions/exception_in_global_init.kt | 12 +++++++++ .../runtime/src/main/cpp/Exceptions.cpp | 25 ------------------- .../runtime/src/main/cpp/Exceptions.h | 3 +-- .../src/main/kotlin/kotlin/native/Runtime.kt | 14 ++++------- .../kotlin/native/concurrent/Atomics.kt | 13 ++++++++++ .../kotlin/native/internal/RuntimeUtils.kt | 23 +++++++++++------ .../test_support/cpp/CompilerGenerated.cpp | 2 +- 9 files changed, 62 insertions(+), 64 deletions(-) create mode 100644 kotlin-native/backend.native/tests/runtime/exceptions/exception_in_global_init.kt diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index f2d6430e992..fb5363322d1 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -2531,12 +2531,20 @@ standaloneTest("kt-37572") { } standaloneTest("custom_hook") { - enabled = (project.testTarget != 'wasm32') // Uses exceptions. + enabled = (project.testTarget != 'wasm32') && // Uses exceptions. + !isExperimentalMM // Experimental MM does not support freezing yet. goldValue = "value 42: Error\n" expectedExitStatus = 1 source = "runtime/exceptions/custom_hook.kt" } +standaloneTest("exception_in_global_init") { + enabled = (project.testTarget != 'wasm32') // Uses exceptions. + source = "runtime/exceptions/exception_in_global_init.kt" + expectedExitStatusChecker = { it != 0 } + outputChecker = { s -> s.contains("Uncaught Kotlin exception: kotlin.IllegalStateException: FAIL") && !s.contains("in kotlin main") } +} + standaloneTest("runtime_math_exceptions") { enabled = (project.testTarget != 'wasm32') source = "stdlib_external/numbers/MathExceptionTest.kt" diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/custom_hook.kt b/kotlin-native/backend.native/tests/runtime/exceptions/custom_hook.kt index 8ce6fe326aa..edb2c682a6e 100644 --- a/kotlin-native/backend.native/tests/runtime/exceptions/custom_hook.kt +++ b/kotlin-native/backend.native/tests/runtime/exceptions/custom_hook.kt @@ -6,31 +6,17 @@ import kotlin.test.* import kotlin.native.concurrent.* -fun setHookLegacyMM(hook: ReportUnhandledExceptionHook) : ReportUnhandledExceptionHook? { +fun main(args : Array) { assertFailsWith { setUnhandledExceptionHook { _ -> println("wrong") } } - return setUnhandledExceptionHook(hook.freeze()) -} - -fun setHookNewMM(hook: ReportUnhandledExceptionHook) : ReportUnhandledExceptionHook? { - return setUnhandledExceptionHook(hook) -} - -fun setHook(hook: ReportUnhandledExceptionHook) : ReportUnhandledExceptionHook? { - return when (kotlin.native.Platform.memoryModel) { - kotlin.native.MemoryModel.EXPERIMENTAL -> setHookNewMM(hook) - else -> setHookLegacyMM(hook) - } -} - -fun main() { val x = 42 - val old = setHook { + val old = setUnhandledExceptionHook({ throwable: Throwable -> println("value $x: ${throwable::class.simpleName}") - } + }.freeze()) assertNull(old) + throw Error("an error") -} +} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/exception_in_global_init.kt b/kotlin-native/backend.native/tests/runtime/exceptions/exception_in_global_init.kt new file mode 100644 index 00000000000..0e67064b833 --- /dev/null +++ b/kotlin-native/backend.native/tests/runtime/exceptions/exception_in_global_init.kt @@ -0,0 +1,12 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +import kotlin.test.* + +val p: Nothing = error("FAIL") + +fun main() { + println("in kotlin main") +} diff --git a/kotlin-native/runtime/src/main/cpp/Exceptions.cpp b/kotlin-native/runtime/src/main/cpp/Exceptions.cpp index 8fd6c4088c8..a4cf68769d5 100644 --- a/kotlin-native/runtime/src/main/cpp/Exceptions.cpp +++ b/kotlin-native/runtime/src/main/cpp/Exceptions.cpp @@ -48,14 +48,6 @@ namespace { -// RuntimeUtils.kt -extern "C" void ReportUnhandledException(KRef throwable); -extern "C" void ExceptionReporterLaunchpad(KRef reporter, KRef throwable); - -KRef currentUnhandledExceptionHook = nullptr; -int32_t currentUnhandledExceptionHookLock = 0; -int32_t currentUnhandledExceptionHookCookie = 0; - #if USE_GCC_UNWIND struct Backtrace { Backtrace(int count, int skip) : index(0), skipCount(skip) { @@ -220,23 +212,6 @@ void ThrowException(KRef exception) { #endif } -OBJ_GETTER(Kotlin_setUnhandledExceptionHook, KRef hook) { - RETURN_RESULT_OF(SwapHeapRefLocked, - ¤tUnhandledExceptionHook, currentUnhandledExceptionHook, hook, ¤tUnhandledExceptionHookLock, - ¤tUnhandledExceptionHookCookie); -} - -void OnUnhandledException(KRef throwable) { - ObjHolder handlerHolder; - auto* handler = SwapHeapRefLocked(¤tUnhandledExceptionHook, currentUnhandledExceptionHook, nullptr, - ¤tUnhandledExceptionHookLock, ¤tUnhandledExceptionHookCookie, handlerHolder.slot()); - if (handler == nullptr) { - ReportUnhandledException(throwable); - } else { - ExceptionReporterLaunchpad(handler, throwable); - } -} - namespace { class { diff --git a/kotlin-native/runtime/src/main/cpp/Exceptions.h b/kotlin-native/runtime/src/main/cpp/Exceptions.h index 551b2d89bcf..f115c5f9d42 100644 --- a/kotlin-native/runtime/src/main/cpp/Exceptions.h +++ b/kotlin-native/runtime/src/main/cpp/Exceptions.h @@ -28,11 +28,10 @@ OBJ_GETTER0(Kotlin_getCurrentStackTrace); OBJ_GETTER(GetStackTraceStrings, KConstRef stackTrace); -OBJ_GETTER(Kotlin_setUnhandledExceptionHook, KRef hook); - // Throws arbitrary exception. void ThrowException(KRef exception); +// RuntimeUtils.kt void OnUnhandledException(KRef throwable); RUNTIME_NORETURN void TerminateWithUnhandledException(KRef exception); diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt index 28e4c74872d..331a7ce90bd 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/Runtime.kt @@ -4,9 +4,8 @@ */ package kotlin.native -import kotlin.native.concurrent.isFrozen import kotlin.native.concurrent.InvalidMutabilityException -import kotlin.native.internal.Escapes +import kotlin.native.internal.UnhandledExceptionHookHolder /** * Initializes Kotlin runtime for the current thread, if not inited already. @@ -45,19 +44,16 @@ public typealias ReportUnhandledExceptionHook = Function1 * with custom exception hooks. */ public fun setUnhandledExceptionHook(hook: ReportUnhandledExceptionHook): ReportUnhandledExceptionHook? { - if (Platform.memoryModel != MemoryModel.EXPERIMENTAL && !hook.isFrozen) { + try { + return UnhandledExceptionHookHolder.hook.swap(hook) + } catch (e: InvalidMutabilityException) { throw InvalidMutabilityException("Unhandled exception hook must be frozen") } - return setUnhandledExceptionHook0(hook) } -@SymbolName("Kotlin_setUnhandledExceptionHook") -@Escapes(0b01) // escapes -external private fun setUnhandledExceptionHook0(hook: ReportUnhandledExceptionHook): ReportUnhandledExceptionHook? - /** * Compute stable wrt potential object relocations by the memory manager identity hash code. * @return 0 for `null` object, identity hash code otherwise. */ @SymbolName("Kotlin_Any_hashCode") -public external fun Any?.identityHashCode(): Int \ No newline at end of file +public external fun Any?.identityHashCode(): Int diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Atomics.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Atomics.kt index ed6ff354af8..1b28d5cfc49 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Atomics.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/concurrent/Atomics.kt @@ -283,6 +283,19 @@ public class AtomicReference { public override fun toString(): String = "${debugString(this)} -> ${debugString(value)}" + // TODO: Consider making this public. + internal fun swap(new: T): T { + while (true) { + val old = value + if (old === new) { + return old + } + if (compareAndSet(old, new)) { + return old + } + } + } + // Implementation details. @SymbolName("Kotlin_AtomicReference_set") private external fun setImpl(new: Any?): Unit diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt index f4cdde2d06d..2913c1f39b0 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt @@ -7,6 +7,7 @@ package kotlin.native.internal import kotlin.internal.getProgressionLastElement import kotlin.reflect.KClass +import kotlin.native.concurrent.AtomicReference @ExportForCppRuntime fun ThrowNullPointerException(): Nothing { @@ -118,10 +119,23 @@ internal fun ReportUnhandledException(throwable: Throwable) { @SymbolName("TerminateWithUnhandledException") internal external fun TerminateWithUnhandledException(throwable: Throwable) +// Using object to make sure that `hook` is initialized when it's needed instead of +// in a normal global initialization flow. This is important if some global happens +// to throw an exception during it's initialization before this hook would've been initialized. +internal object UnhandledExceptionHookHolder { + internal val hook: AtomicReference = AtomicReference(null) +} + +@PublishedApi @ExportForCppRuntime -internal fun ExceptionReporterLaunchpad(reporter: (Throwable) -> Unit, throwable: Throwable) { +internal fun OnUnhandledException(throwable: Throwable) { + val handler = UnhandledExceptionHookHolder.hook.swap(null) + if (handler == null) { + ReportUnhandledException(throwable); + return + } try { - reporter(throwable) + handler(throwable) } catch (t: Throwable) { ReportUnhandledException(t) } @@ -210,8 +224,3 @@ internal fun listOfInternal(vararg elements: T): List { result.add(elements[i]) return result } - - -@PublishedApi -@SymbolName("OnUnhandledException") -external internal fun OnUnhandledException(throwable: Throwable) diff --git a/kotlin-native/runtime/src/test_support/cpp/CompilerGenerated.cpp b/kotlin-native/runtime/src/test_support/cpp/CompilerGenerated.cpp index 16d087cf208..05bab08ed91 100644 --- a/kotlin-native/runtime/src/test_support/cpp/CompilerGenerated.cpp +++ b/kotlin-native/runtime/src/test_support/cpp/CompilerGenerated.cpp @@ -170,7 +170,7 @@ RUNTIME_NORETURN OBJ_GETTER(DescribeObjectForDebugging, KConstNativePtr typeInfo throw std::runtime_error("Not implemented for tests"); } -void ExceptionReporterLaunchpad(KRef reporter, KRef throwable) { +void OnUnhandledException(KRef throwable) { throw std::runtime_error("Not implemented for tests"); } From 41a1e462f0f5bfc9671b69698615ac5ea8259b82 Mon Sep 17 00:00:00 2001 From: SvyatoslavScherbina Date: Tue, 16 Feb 2021 14:19:05 +0300 Subject: [PATCH 354/368] Fix samples/androidNativeActivity build Starting from 1.4.0, Kotlin expects Gradle projects with android and kotlin-multiplatform plugins to have an android target. See https://github.com/JetBrains/kotlin/commit/ad9d011ed02bc971a0cf406ff1535c2a67bd3374#diff-685880375690dc3db18f7b39b51c257f7100a11c39791d2b3f9f45cefa485e52R133 --- kotlin-native/samples/androidNativeActivity/build.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kotlin-native/samples/androidNativeActivity/build.gradle.kts b/kotlin-native/samples/androidNativeActivity/build.gradle.kts index 0c86de85e9a..44308ae2d40 100644 --- a/kotlin-native/samples/androidNativeActivity/build.gradle.kts +++ b/kotlin-native/samples/androidNativeActivity/build.gradle.kts @@ -64,6 +64,8 @@ kotlin { } } + android() + sourceSets { val x86Main by getting if (!simulatorOnly) { From c2b1c7df53073d1a02d5593ffc763320f8f53dc4 Mon Sep 17 00:00:00 2001 From: Pavel Semyonov Date: Mon, 15 Feb 2021 15:49:43 +0700 Subject: [PATCH 355/368] update(docs): replace doc content with links to kotlinlang.ord pages --- kotlin-native/COCOAPODS.md | 750 +---------------------------- kotlin-native/CONCURRENCY.md | 221 +-------- kotlin-native/DEBUGGING.md | 262 +--------- kotlin-native/FAQ.md | 207 +------- kotlin-native/GRADLE_PLUGIN.md | 2 +- kotlin-native/IMMUTABILITY.md | 30 +- kotlin-native/INTEROP.md | 721 +-------------------------- kotlin-native/IOS_SYMBOLICATION.md | 73 +-- kotlin-native/LIBRARIES.md | 244 +--------- kotlin-native/OBJC_INTEROP.md | 425 +--------------- kotlin-native/PLATFORM_LIBS.md | 60 +-- 11 files changed, 11 insertions(+), 2984 deletions(-) diff --git a/kotlin-native/COCOAPODS.md b/kotlin-native/COCOAPODS.md index a6356a2081f..761f7ad561a 100644 --- a/kotlin-native/COCOAPODS.md +++ b/kotlin-native/COCOAPODS.md @@ -1,751 +1,3 @@ # CocoaPods integration -Kotlin/Native provides integration with the [CocoaPods dependency manager](https://cocoapods.org/). -You can add dependencies on Pod libraries as well as use a multiplatform project with -native targets as a CocoaPods dependency (Kotlin Pod). - -You can manage Pod dependencies directly in IntelliJ IDEA and enjoy all the additional features such as code highlighting -and completion. You can build the whole Kotlin project with Gradle and not ever have to switch to Xcode. - -Use Xcode only when you need to write Swift/Objective-C code or run your application on a simulator or device. -To work correctly with Xcode, you should [update your Podfile](#update-podfile-for-xcode). - -Depending on your project and purposes, you can add dependencies between [a Kotlin project and a Pod library](#add-dependencies-on-pod-libraries) as well as [a Kotlin Pod and an Xcode project](#use-a-kotlin-gradle-project-as-a-cocoapods-dependency). - ->You can also add dependencies between a Kotlin Pod and multiple Xcode projects. However, in this case you need to add a ->dependency by calling `pod install` manually for each Xcode project. In other cases, it's done automatically. -{:.note} - -## Install the CocoaPods dependency manager and plugin - -1. Install the [CocoaPods dependency manager](https://cocoapods.org/). - -
- - ```ruby - $ sudo gem install cocoapods - ``` - -
- -2. Install the [`cocoapods-generate`](https://github.com/square/cocoapods-generate) plugin. - -
- - ```ruby - $ sudo gem install cocoapods-generate - ``` - -
- -3. In `build.gradle.kts` (or `build.gradle`) of your IDEA project, apply the CocoaPods plugin as well as the Kotlin - Multiplatform plugin. - -
- - ```kotlin - plugins { - kotlin("multiplatform") version "{{ site.data.releases.latest.version }}" - kotlin("native.cocoapods") version "{{ site.data.releases.latest.version }}" - } - ``` - -
- -4. Configure `summary`, `homepage`, and `frameworkName`of the `Podspec` file in the `cocoapods` block. -`version` is a version of the Gradle project. - -
- - ```kotlin - plugins { - kotlin("multiplatform") version "{{ site.data.releases.latest.version }}" - kotlin("native.cocoapods") version "{{ site.data.releases.latest.version }}" - } - - // CocoaPods requires the podspec to have a version. - version = "1.0" - - kotlin { - cocoapods { - // Configure fields required by CocoaPods. - summary = "Some description for a Kotlin/Native module" - homepage = "Link to a Kotlin/Native module homepage" - - // You can change the name of the produced framework. - // By default, it is the name of the Gradle project. - frameworkName = "my_framework" - } - } - ``` - -
- -5. Re-import the project. - -6. Generate the [Gradle wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html) to avoid compatibility issues during an Xcode build. - -When applied, the CocoaPods plugin does the following: - -* Adds both `debug` and `release` frameworks as output binaries for all macOS, iOS, tvOS, and watchOS targets. -* Creates a `podspec` task which generates a [Podspec](https://guides.cocoapods.org/syntax/podspec.html) -file for the project. - -The `Podspec` file includes a path to an output framework and script phases that automate building this framework during -the build process of an Xcode project. - -## Add dependencies on Pod libraries - -To add dependencies between a Kotlin project and a Pod library, you should [complete the initial configuration](#install-the-cocoapods-dependency-manager-and-plugin). -This allows you to add dependencies on the following types of Pod libraries: - * [A Pod library from the CocoaPods repository](#add-a-dependency-on-a-pod-library-from-the-cocoapods-repository) - * [A Pod library stored locally](#add-a-dependency-on-a-pod-library-stored-locally) - * [A Pod library from a Git repository](#add-a-dependency-on-a-pod-library-from-the-git-repository) - * [A Pod library from an archive](#add-a-dependency-on-a-pod-library-from-an-archive) - * [A Pod library from a custom Podspec repository](#add-a-dependency-on-a-pod-library-from-a-custom-podspec-repository) - * [A Pod library with custom cinterop options](#add-a-dependency-on-a-pod-library-with-custom-cinterop-options) - * [A static Pod library](#add-a-dependency-on-a-static-pod-library) - -A Kotlin project requires the `pod()` function call in `build.gradle.kts` (`build.gradle`) for adding a Pod dependency. Each dependency requires its own separate function call. -You can specify the parameters for the dependency in the configuration block of the function. - -When you add a new dependency and re-import the project in IntelliJ IDEA, the new dependency will be added automatically. -No additional steps are required. - -To use your Kotlin project with Xcode, you should [make changes in your project Podfile](#update-podfile-for-xcode). - -### Add a dependency on a Pod library from the CocoaPods repository - -You can add dependencies on a Pod library from the CocoaPods repository with `pod()` to `build.gradle.kts` -(`build.gradle`) of your project: - -1. Specify the name of a Pod library in the `pod()` function. In the configuration block you can specify the version of the library using the `version` parameter. To use the latest version of the library, you can just omit this parameter all-together. - - > You can add dependencies on subspecs. - {:.note} - -2. Specify the minimum deployment target version for the Pod library. - - > If you don't specify the minimum deployment target version and a dependency Pod requires a higher deployment target, you will get an error. - {:.note} - -
- - ```kotlin - kotlin { - ios() - - cocoapods { - - ios.deploymentTarget = "13.5" - - summary = "CocoaPods test library" - homepage = "https://github.com/JetBrains/kotlin" - - pod("AFNetworking") { - version = "~> 4.0.1" - } - } - } - ``` - -
- -3. Re-import the project. - -To use these dependencies from the Kotlin code, import the packages `cocoapods.`. - -
- -```kotlin -import cocoapods.AFNetworking.* -``` - -
- -You can find a sample project [here](https://github.com/Kotlin/kotlin-with-cocoapods-sample). - -### Add a dependency on a Pod library stored locally - -You can add a dependency on a Pod library stored locally with `pod()` to `build.gradle.kts` (`build.gradle`) of your project: - -1. Specify the name of a Pod library in the `pod()` function. In the configuration block specify the path to the local Pod library: use the `path()` function in the `source` parameter value. - - > You can add local dependencies on subspecs as well. - > The `cocoapods` block can include dependencies to Pods stored locally and Pods from the CocoaPods repository at - > the same time. - {:.note} - -2. Specify the minimum deployment target version for the Pod library. - - > If you don't specify the minimum deployment target version and a dependency Pod requires a higher deployment target, you will get an error. - {:.note} - -
- - ```kotlin - kotlin { - ios() - - cocoapods { - summary = "CocoaPods test library" - homepage = "https://github.com/JetBrains/kotlin" - - ios.deploymentTarget = "13.5" - - pod("pod_dependency") { - version = "1.0" - source = path(project.file("../pod_dependency/pod_dependency.podspec")) - } - pod("subspec_dependency/Core") { - version = "1.0" - source = path(project.file("../subspec_dependency/subspec_dependency.podspec")) - } - pod("AFNetworking") { - version = "~> 4.0.1" - } - } - } - ``` - -
- - > You can also specify the version of the library using `version` parameter in the configuration block. - > To use the latest version of the library, omit the parameter. - {:.note} - -3. Re-import the project. - -To use these dependencies from the Kotlin code, import the packages `cocoapods.`. - -
- -```kotlin -import cocoapods.pod_dependency.* -import cocoapods.subspec_dependency.* -import cocoapods.AFNetworking.* -``` - -
- -You can find a sample project [here](https://github.com/Kotlin/kotlin-with-cocoapods-sample). - -### Add a dependency on a Pod library from the Git repository - -You can add dependencies on a Pod library from a custom Git repository with `pod()` to `build.gradle.kts` -(`build.gradle`) of your project: - -1. Specify the name of a Pod library in the `pod()` function. -In the configuration block specify the path to the git repository: use the `git()` function in the `source` parameter value. - - Additionally, you can specify the following parameters in the block after `git()`: - * `commit` – to use a specific commit from the repository - * `tag` – to use a specific tag from the repository - * `branch` – to use a specific branch from the repository - - The `git()` function prioritizes passed parameters in the following order: `commit`, `tag`, `branch`. - If you don't specify a parameter, the Kotlin plugin uses `HEAD` from the `master` branch. - - > You can combine `branch`, `commit`, and `tag` parameters to get the specific version of a Pod. - {:.note} - -2. Specify the minimum deployment target version for the Pod library. - - > If you don't specify the minimum deployment target version and a dependency Pod requires a higher deployment target, you will get an error. - {:.note} - -
- - ```kotlin - kotlin { - ios() - - cocoapods { - summary = "CocoaPods test library" - homepage = "https://github.com/JetBrains/kotlin" - - ios.deploymentTarget = "13.5" - - pod("AFNetworking") { - source = git("https://github.com/AFNetworking/AFNetworking") { - tag = "4.0.0" - } - } - - pod("JSONModel") { - source = git("https://github.com/jsonmodel/jsonmodel.git") { - branch = "key-mapper-class" - } - } - - pod("CocoaLumberjack") { - source = git("https://github.com/CocoaLumberjack/CocoaLumberjack.git") { - commit = "3e7f595e3a459c39b917aacf9856cd2a48c4dbf3" - } - } - } - } - ``` - -
- - -3. Re-import the project. - -> To work correctly with Xcode, you should specify the path to the Podspec in your Podfile. -> For example: -> ->
-> -> ```ruby -> target 'ios-app' do -> # ... other pod depedencies ... -> pod 'JSONModel', :path => '../cocoapods/kotlin-with-cocoapods-sample/kotlin-library/build/cocoapods/externalSources/git/JSONModel' -> end -> ``` -> ->
-> -{:.note} - -To use these dependencies from the Kotlin code, import the packages `cocoapods.`. - -
- -```kotlin -import cocoapods.AFNetworking.* -import cocoapods.JSONModel.* -import cocoapods.CocoaLumberjack.* -``` - -
- -You can find a sample project [here](https://github.com/Kotlin/kotlin-with-cocoapods-sample). - -### Add a dependency on a Pod library from an archive - -You can add dependencies on a Pod library from `zip`, `tar`, or `jar` archive with `pod()` to `build.gradle.kts` -(`build.gradle`) of your project: - -1. Specify the name of a Pod library in the `pod()` function. -In the configuration block specify the path to the archive: use the `url()` function with an arbitrary HTTP address in the `source` parameter value. - - Additionally, you can specify the boolean `flatten` parameter as a second argument for the `url()` function. - This parameter indicates that all the Pod files are located in the root directory of the archive. - -2. Specify the minimum deployment target version for the Pod library. - - > If you don't specify the minimum deployment target version and a dependency Pod requires a higher deployment target, you will get an error. - {:.note} - -
- - ```kotlin - kotlin { - ios() - - cocoapods { - summary = "CocoaPods test library" - homepage = "https://github.com/JetBrains/kotlin" - - ios.deploymentTarget = "13.5" - - pod("pod_dependency") { - source = url("https://github.com/Kotlin/kotlin-with-cocoapods-sample/raw/cocoapods-zip/cocoapodSourcesZip.zip", flatten = true) - } - - } - } - ``` - -
- -3. Re-import the project. - -> To work correctly with Xcode, you should specify the path to the Podspec in your Podfile. -> For example: -> ->
-> -> ```ruby -> target 'ios-app' do -> # ... other pod depedencies ... -> pod 'podspecWithFilesExample', :path => '../cocoapods/kotlin-with-cocoapods-sample/pod_dependency' -> end -> ``` -> ->
-> -{:.note} - -To use these dependencies from the Kotlin code, import the packages `cocoapods.`. - -
- -```kotlin -import cocoapods.pod_dependency.* -``` - -
- -You can find a sample project [here](https://github.com/Kotlin/kotlin-with-cocoapods-sample). - -### Add a dependency on a Pod library from a custom Podspec repository - -You can add dependencies on a Pod library from a custom Podspec repository with `pod()` and `specRepos` to `build.gradle.kts` -(`build.gradle`) of your project: - -1. Specify the HTTP address to the custom Podspec repository using the `url()` inside the `specRepos` block. - -2. Specify the name of a Pod library in the `pod()` function. - -3. Specify the minimum deployment target version for the Pod library. - - > If you don't specify the minimum deployment target version and a dependency Pod requires a higher deployment target, you will get an error. - {:.note} - -
- - ```kotlin - kotlin { - ios() - - cocoapods { - summary = "CocoaPods test library" - homepage = "https://github.com/JetBrains/kotlin" - - ios.deploymentTarget = "13.5" - - specRepos { - url("https://github.com/Kotlin/kotlin-cocoapods-spec.git") - } - pod("example") - - } - } - ``` - -
- -4. Re-import the project. - -> To work correctly with Xcode, you should specify the location of specs at the beginning of your Podfile. -> For example: -> ->
-> -> ```ruby -> source 'https://github.com/Kotlin/kotlin-cocoapods-spec.git' -> ``` -> ->
-> -> You should also specify the path to the Podspec in your Podfile. -> For example: -> ->
-> -> ```ruby -> target 'ios-app' do -> # ... other pod depedencies ... -> pod 'podspecWithFilesExample', :path => '../cocoapods/kotlin-with-cocoapods-sample/pod_dependency' -> end -> ``` -> ->
-> -{:.note} - -To use these dependencies from the Kotlin code, import the packages `cocoapods.`. - -
- -```kotlin -import cocoapods.example.* -``` - -
- -You can find a sample project [here](https://github.com/Kotlin/kotlin-with-cocoapods-sample). - -### Add a dependency on a Pod library with custom cinterop options - -You can add dependencies on a Pod library with custom cinterop options with `pod()` to `build.gradle.kts` -(`build.gradle`) of your project: - -1. Specify the name of a Pod library in the `pod()` function. -In the configuration block specify the cinterop options: - - * `extraOpts` – to specify the list of options for a Pod library. For example, specific flags: `extraOpts = listOf("-compiler-option")` - * `packageName` – to specify the package name. If you specify this, you can import the library using the package name: `import `. - -2. Specify the minimum deployment target version for the Pod library. - - > If you don't specify the minimum deployment target version and a dependency Pod requires a higher deployment target, you will get an error. - {:.note} - -
- - ```kotlin - kotlin { - ios() - - cocoapods { - summary = "CocoaPods test library" - homepage = "https://github.com/JetBrains/kotlin" - - ios.deploymentTarget = "13.5" - - useLibraries() - - pod("YandexMapKit") { - packageName = "YandexMK" - } - - } - } - ``` - -
- -3. Re-import the project. - -To use these dependencies from the Kotlin code, import the packages `cocoapods.`. - -
- -```kotlin -import cocoapods.YandexMapKit.* -``` - -
- -If you use the `packageName` parameter, you can import the library using the package name: `import `: - -
- -```kotlin -import YandexMK.YMKPoint -import YandexMK.YMKDistance -``` - -
- -### Add a dependency on a static Pod library - -You can add dependencies on a static Pod library with `pod()` and `useLibraries()` to `build.gradle.kts` -(`build.gradle`) of your project: - -1. Specify the name of the library using the `pod()` function. - -2. Call the `useLibraries()` function: it enables a special flag for static libraries. - -3. Specify the minimum deployment target version for the Pod library. - - > If you don't specify the minimum deployment target version and a dependency Pod requires a higher deployment target, you will get an error. - {:.note} - -
- - ```kotlin - kotlin { - ios() - - cocoapods { - summary = "CocoaPods test library" - homepage = "https://github.com/JetBrains/kotlin" - - ios.deploymentTarget = "13.5" - - pod("YandexMapKit") { - version = "~> 3.2" - } - useLibraries() - - } - } - ``` - -
- - -4. Re-import the project. - -To use these dependencies from the Kotlin code, import the packages `cocoapods.`. - -
- -```kotlin -import cocoapods.YandexMapKit.* -``` - -
- -### Update Podfile for Xcode - -If you want to import your Kotlin project in an Xcode project, you’ll need to make some changes to your Podfile for it to work correctly: - -* If your project has any Git, HTTP, or custom Podspec repository dependencies, you should also specify the path to the Podspec in the Podfile. - - For example, if you add a dependency on `podspecWithFilesExample`, declare the path to the Podspec in the Podfile: - -
- - ```ruby - target 'ios-app' do - # ... other depedencies ... - pod 'podspecWithFilesExample', :path => 'cocoapods/externalSources/url/podspecWithFilesExample' - end - ``` - -
- - The `:path` should contain the filepath to the Pod. - -* When you add a library from the custom Podspec repository, you should also specify the [location](https://guides.cocoapods.org/syntax/podfile.html#source) of specs at the beginning of your Podfile: - -
- - ```ruby - source 'https://github.com/Kotlin/kotlin-cocoapods-spec.git' - - target 'kotlin-cocoapods-xcproj' do - # ... other depedencies ... - pod 'example' - end - ``` - -
- -> Re-import the project after making changes in Podfile. -{:.note} - -If you don't make these changes to the Podfile, the `podInstall` task will fail and the CocoaPods plugin will show an error message in the log. - -Check out the `withXcproject` branch of the [sample project](https://github.com/Kotlin/kotlin-with-cocoapods-sample), which contains an example of Xcode integration with an existing Xcode project named `kotlin-cocoapods-xcproj`. - -## Use a Kotlin Gradle project as a CocoaPods dependency - -You can use a Kotlin Multiplatform project with native targets as a CocoaPods dependency (Kotlin Pod). You can include such a dependency -in the Podfile of the Xcode project by its name and path to the project directory containing the generated Podspec. -This dependency will be automatically built (and rebuilt) along with this project. -Such an approach simplifies importing to Xcode by removing a need to write the corresponding Gradle tasks and Xcode build steps manually. - -You can add dependencies between: -* [A Kotlin Pod and an Xcode project with one target](#add-a-dependency-between-a-kotlin-pod-and-xcode-project-with-one-target) -* [A Kotlin Pod and an Xcode project with several targets](#add-a-dependency-between-a-kotlin-pod-with-an-xcode-project-with-several-targets) - -> To correctly import the dependencies into the Kotlin/Native module, the -`Podfile` must contain either [`use_modular_headers!`](https://guides.cocoapods.org/syntax/podfile.html#use_modular_headers_bang) -or [`use_frameworks!`](https://guides.cocoapods.org/syntax/podfile.html#use_frameworks_bang) -directive. -{:.note} - -### Add a dependency between a Kotlin Pod and Xcode project with one target - -1. Create an Xcode project with a `Podfile` if you haven’t done so yet. -2. Add the path to your Xcode project `Podfile` with `podfile = project.file(..)` to `build.gradle.kts` (`build.gradle`) -of your Kotlin project. - This step helps synchronize your Xcode project with Kotlin Pod dependencies by calling `pod install` for your `Podfile`. -3. Specify the minimum deployment target version for the Pod library. - > If you don't specify the minimum deployment target version and a dependency Pod requires a higher deployment target, you will get an error. - {:.note} - -
- - ```kotlin - kotlin { - ios() - - cocoapods { - summary = "CocoaPods test library" - homepage = "https://github.com/JetBrains/kotlin" - ios.deploymentTarget = "13.5" - pod("AFNetworking") { - version = "~> 4.0.0" - } - podfile = project.file("../ios-app/Podfile") - } - } - ``` - -
- -4. Add the name and path of the Kotlin Pod you want to include in the Xcode project to `Podfile`. - -
- - ```ruby - use_frameworks! - - platform :ios, '13.5' - - target 'ios-app' do - pod 'kotlin_library', :path => '../kotlin-library' - end - ``` - -
- -5. Re-import the project. - -### Add a dependency between a Kotlin Pod with an Xcode project with several targets - -1. Create an Xcode project with a `Podfile` if you haven’t done so yet. -2. Add the path to your Xcode project `Podfile` with `podfile = project.file(..)` to `build.gradle.kts` (`build.gradle`) of - your Kotlin project. - This step helps synchronize your Xcode project with Kotlin Pod dependencies by calling `pod install` for your `Podfile`. -3. Add dependencies to the Pod libraries that you want to use in your project with `pod()`. -4. For each target, specify the minimum deployment target version for the Pod library. - > If you don't specify the minimum deployment target version and a dependency Pod requires a higher deployment target, you will get an error. - {:.note} - -
- - ```kotlin - kotlin { - ios() - tvos() - - cocoapods { - summary = "CocoaPods test library" - homepage = "https://github.com/JetBrains/kotlin" - ios.deploymentTarget = "13.5" - tvos.deploymentTarget = "13.4" - - pod("AFNetworking") { - version = "~> 4.0.0" - } - podfile = project.file("../severalTargetsXcodeProject/Podfile") // specify the path to Podfile - } - } - ``` - -
- -5. Add the name and path of the Kotlin Pod you want to include in the Xcode project to the `Podfile`. - -
- - ```ruby - target 'iosApp' do - use_frameworks! - platform :ios, '13.5' - # Pods for iosApp - pod 'kotlin_library', :path => '../kotlin-library' - end - - target 'TVosApp' do - use_frameworks! - platform :tvos, '13.4' - - # Pods for TVosApp - pod 'kotlin_library', :path => '../kotlin-library' - end - ``` - -
- -6. Re-import the project. - -You can find a sample project [here](https://github.com/Kotlin/multitarget-xcode-with-kotlin-cocoapods-sample). +The content of this page is moved to https://kotlinlang.org/docs/native-cocoapods.html \ No newline at end of file diff --git a/kotlin-native/CONCURRENCY.md b/kotlin-native/CONCURRENCY.md index 21b340cb9fb..565f2160999 100644 --- a/kotlin-native/CONCURRENCY.md +++ b/kotlin-native/CONCURRENCY.md @@ -1,222 +1,3 @@ ## Concurrency in Kotlin/Native - Kotlin/Native runtime doesn't encourage a classical thread-oriented concurrency - model with mutually exclusive code blocks and conditional variables, as this model is - known to be error-prone and unreliable. Instead, we suggest a collection of - alternative approaches, allowing you to use hardware concurrency and implement blocking IO. - Those approaches are as follows, and they will be elaborated on in further sections: - * Workers with message passing - * Object subgraph ownership transfer - * Object subgraph freezing - * Object subgraph detachment - * Raw shared memory using C globals - * Atomic primitives and references - * Coroutines for blocking operations (not covered in this document) - -### Workers - - Instead of threads Kotlin/Native runtime offers the concept of workers: concurrently executed - control flow streams with an associated request queue. Workers are very similar to the actors - in the Actor Model. A worker can exchange Kotlin objects with another worker, so that at any moment - each mutable object is owned by a single worker, but ownership can be transferred. - See section [Object transfer and freezing](#transfer). - - Once a worker is started with the `Worker.start` function call, it can be addressed with its own unique integer - worker id. Other workers, or non-worker concurrency primitives, such as OS threads, can send a message - to the worker with the `execute` call. - -
- - ```kotlin -val future = execute(TransferMode.SAFE, { SomeDataForWorker() }) { - // data returned by the second function argument comes to the - // worker routine as 'input' parameter. - input -> - // Here we create an instance to be returned when someone consumes result future. - WorkerResult(input.stringParam + " result") -} - -future.consume { - // Here we see result returned from routine above. Note that future object or - // id could be transferred to another worker, so we don't have to consume future - // in same execution context it was obtained. - result -> println("result is $result") -} -``` - -
- - The call to `execute` uses a function passed as its second parameter to produce an object subgraph - (i.e. set of mutually referring objects) which is then passed as a whole to that worker, it is then no longer - available to the thread that initiated the request. This property is checked if the first parameter - is `TransferMode.SAFE` by graph traversal and is just assumed to be true, if it is `TransferMode.UNSAFE`. - The last parameter to `execute` is a special Kotlin lambda, which is not allowed to capture any state, - and is actually invoked in the target worker's context. Once processed, the result is transferred to whatever consumes - it in the future, and it is attached to the object graph of that worker/thread. - - If an object is transferred in `UNSAFE` mode and is still accessible from multiple concurrent executors, - program will likely crash unexpectedly, so consider that last resort in optimizing, not a general purpose - mechanism. - - For a more complete example please refer to the [workers example](https://github.com/JetBrains/kotlin-native/tree/master/samples/workers) - in the Kotlin/Native repository. - -
-### Object transfer and freezing - - An important invariant that Kotlin/Native runtime maintains is that the object is either owned by a single - thread/worker, or it is immutable (_shared XOR mutable_). This ensures that the same data has a single mutator, - and so there is no need for locking to exist. To achieve such an invariant, we use the concept of not externally - referred object subgraphs. - This is a subgraph which has no external references from outside of the subgraph, which could be checked - algorithmically with O(N) complexity (in ARC systems), where N is the number of elements in such a subgraph. - Such subgraphs are usually produced as a result of a lambda expression, for example some builder, and may not - contain objects, referred to externally. - - Freezing is a runtime operation making a given object subgraph immutable, by modifying the object header - so that future mutation attempts throw an `InvalidMutabilityException`. It is deep, so - if an object has a pointer to other objects - transitive closure of such objects will be frozen. - Freezing is a one way transformation, frozen objects cannot be unfrozen. Frozen objects have a nice - property that due to their immutability, they can be freely shared between multiple workers/threads - without breaking the "mutable XOR shared" invariant. - - If an object is frozen it can be checked with an extension property `isFrozen`, and if it is, object sharing - is allowed. Currently, Kotlin/Native runtime only freezes the enum objects after creation, although additional - autofreezing of certain provably immutable objects could be implemented in the future. - - -### Object subgraph detachment - - An object subgraph without external references can be disconnected using `DetachedObjectGraph` to - a `COpaquePointer` value, which could be stored in `void*` data, so the disconnected object subgraphs - can be stored in a C data structure, and later attached back with `DetachedObjectGraph.attach()` in an arbitrary thread - or a worker. Combining it with [raw memory sharing](#shared) it allows side channel object transfer between - concurrent threads, if the worker mechanisms are insufficient for a particular task. Note, that object detachment - may require explicit leaving function holding object references and then performing cyclic garbage collection. - For example, code like: - -
- -```kotlin -val graph = DetachedObjectGraph { - val map = mutableMapOf() - for (entry in map.entries) { - // ... - } - map -} -``` - -
- - will not work as expected and will throw runtime exception, as there are uncollected cycles in the detached graph, while: - -
- -```kotlin -val graph = DetachedObjectGraph { - { - val map = mutableMapOf() - for (entry in map.entries) { - // ... - } - map - }().also { - kotlin.native.internal.GC.collect() - } - } -``` - -
- - will work properly, as holding references will be released, and then cyclic garbage affecting reference counter is - collected. - - -### Raw shared memory - - Considering the strong ties between Kotlin/Native and C via interoperability, in conjunction with the other mechanisms - mentioned above it is possible to build popular data structures, like concurrent hashmap or shared cache with - Kotlin/Native. It is possible to rely upon shared C data, and store in it references to detached object subgraphs. - Consider the following .def file: - -
- -```c -package = global - ---- -typedef struct { - int version; - void* kotlinObject; -} SharedData; - -SharedData sharedData; -``` - -
- -After running the cinterop tool it can share Kotlin data in a versionized global structure, -and interact with it from Kotlin transparently via autogenerated Kotlin like this: - -
- -```kotlin -class SharedData(rawPtr: NativePtr) : CStructVar(rawPtr) { - var version: Int - var kotlinObject: COpaquePointer? -} -``` - -
- -So in combination with the top level variable declared above, it can allow looking at the same memory from different -threads and building traditional concurrent structures with platform-specific synchronization primitives. - - -### Global variables and singletons - - Frequently, global variables are a source of unintended concurrency issues, so _Kotlin/Native_ implements -the following mechanisms to prevent the unintended sharing of state via global objects: - - * global variables, unless specially marked, can be only accessed from the main thread (that is, the thread - _Kotlin/Native_ runtime was first initialized), if other thread access such a global, `IncorrectDereferenceException` is thrown - * for global variables marked with the `@kotlin.native.ThreadLocal` annotation each threads keeps thread-local copy, - so changes are not visible between threads - * for global variables marked with the `@kotlin.native.SharedImmutable` annotation value is shared, but frozen - before publishing, so each threads sees the same value - * singleton objects unless marked with `@kotlin.native.ThreadLocal` are frozen and shared, lazy values allowed, - unless cyclic frozen structures were attempted to be created - * enums are always frozen - - Combined, these mechanisms allow natural race-free programming with code reuse across platforms in MPP projects. - - -### Atomic primitives and references - - Kotlin/Native standard library provides primitives for safe working with concurrently mutable data, namely -`AtomicInt`, `AtomicLong`, `AtomicNativePtr`, `AtomicReference` and `FreezableAtomicReference` in the package -`kotlin.native.concurrent`. -Atomic primitives allows concurrency-safe update operations, such as increment, decrement and compare-and-swap, -along with value setters and getters. Atomic primitives are considered always frozen by the runtime, and -while their fields can be updated with the regular `field.value += 1`, it is not concurrency safe. -Value must be be changed using dedicated operations, so it is possible to perform concurrent-safe -global counters and similar data structures. - - Some algorithms require shared mutable references across the multiple workers, for example global mutable -configuration could be implemented as an immutable instance of properties list atomically replaced with the -new version on configuration update as the whole in a single transaction. This way no inconsistent configuration -could be seen, and at the same time configuration could be updated as needed. -To achieve such functionality Kotlin/Native runtime provides two related classes: -`kotlin.native.concurrent.AtomicReference` and `kotlin.native.concurrent.FreezableAtomicReference`. -Atomic reference holds reference to a frozen or immutable object, and its value could be updated by set -or compare-and-swap operation. Thus, dedicated set of objects could be used to create mutable shared object graphs -(of immutable objects). Cycles in the shared memory could be created using atomic references. -Kotlin/Native runtime doesn't support garbage collecting cyclic data when reference cycle goes through -`AtomicReference` or frozen `FreezableAtomicReference`. So to avoid memory leaks atomic references -that are potentially parts of shared cyclic data should be zeroed out once no longer needed. - - If atomic reference value is attempted to be set to non-frozen value runtime exception is thrown. - - Freezable atomic reference is similar to the regular atomic reference, but until frozen behaves like regular box -for a reference. After freezing it behaves like an atomic reference, and can only hold a reference to a frozen object. \ No newline at end of file +The content of this page is moved to https://kotlinlang.org/docs/native-concurrency.html \ No newline at end of file diff --git a/kotlin-native/DEBUGGING.md b/kotlin-native/DEBUGGING.md index 6f66bc8db96..e05c00d7bfe 100644 --- a/kotlin-native/DEBUGGING.md +++ b/kotlin-native/DEBUGGING.md @@ -1,263 +1,3 @@ ## Debugging -Currently the Kotlin/Native compiler produces debug info compatible with the DWARF 2 specification, so modern debugger tools can -perform the following operations: -- breakpoints -- stepping -- inspection of type information -- variable inspection - -### Producing binaries with debug info with Kotlin/Native compiler - -To produce binaries with the Kotlin/Native compiler it's sufficient to use the ``-g`` option on the command line.
-_Example:_ - -
- -```bash -0:b-debugger-fixes:minamoto@unit-703(0)# cat - > hello.kt -fun main(args: Array) { - println("Hello world") - println("I need your clothes, your boots and your motocycle") -} -0:b-debugger-fixes:minamoto@unit-703(0)# dist/bin/konanc -g hello.kt -o terminator -KtFile: hello.kt -0:b-debugger-fixes:minamoto@unit-703(0)# lldb terminator.kexe -(lldb) target create "terminator.kexe" -Current executable set to 'terminator.kexe' (x86_64). -(lldb) b kfun:main(kotlin.Array) -Breakpoint 1: where = terminator.kexe`kfun:main(kotlin.Array) + 4 at hello.kt:2, address = 0x00000001000012e4 -(lldb) r -Process 28473 launched: '/Users/minamoto/ws/.git-trees/debugger-fixes/terminator.kexe' (x86_64) -Process 28473 stopped -* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 - frame #0: 0x00000001000012e4 terminator.kexe`kfun:main(kotlin.Array) at hello.kt:2 - 1 fun main(args: Array) { --> 2 println("Hello world") - 3 println("I need your clothes, your boots and your motocycle") - 4 } -(lldb) n -Hello world -Process 28473 stopped -* thread #1, queue = 'com.apple.main-thread', stop reason = step over - frame #0: 0x00000001000012f0 terminator.kexe`kfun:main(kotlin.Array) at hello.kt:3 - 1 fun main(args: Array) { - 2 println("Hello world") --> 3 println("I need your clothes, your boots and your motocycle") - 4 } -(lldb) -``` - -
- -### Breakpoints -Modern debuggers provide several ways to set a breakpoint, see below for a tool-by-tool breakdown: - -#### lldb -- by name - -
- -```bash -(lldb) b -n kfun:main(kotlin.Array) -Breakpoint 4: where = terminator.kexe`kfun:main(kotlin.Array) + 4 at hello.kt:2, address = 0x00000001000012e4 -``` - -
- - _``-n`` is optional, this flag is applied by default_ -- by location (filename, line number) - -
- -```bash -(lldb) b -f hello.kt -l 1 -Breakpoint 1: where = terminator.kexe`kfun:main(kotlin.Array) + 4 at hello.kt:2, address = 0x00000001000012e4 -``` - -
- -- by address - -
- -```bash -(lldb) b -a 0x00000001000012e4 -Breakpoint 2: address = 0x00000001000012e4 -``` - -
- -- by regex, you might find it useful for debugging generated artifacts, like lambda etc. (where used ``#`` symbol in name). - -
- -```bash -3: regex = 'main\(', locations = 1 - 3.1: where = terminator.kexe`kfun:main(kotlin.Array) + 4 at hello.kt:2, address = terminator.kexe[0x00000001000012e4], unresolved, hit count = 0 -``` - -
- -#### gdb -- by regex - -
- -```bash -(gdb) rbreak main( -Breakpoint 1 at 0x1000109b4 -struct ktype:kotlin.Unit &kfun:main(kotlin.Array); -``` - -
- -- by name __unusable__, because ``:`` is a separator for the breakpoint by location - -
- -```bash -(gdb) b kfun:main(kotlin.Array) -No source file named kfun. -Make breakpoint pending on future shared library load? (y or [n]) y -Breakpoint 1 (kfun:main(kotlin.Array)) pending -``` - -
- -- by location - -
- -```bash -(gdb) b hello.kt:1 -Breakpoint 2 at 0x100001704: file /Users/minamoto/ws/.git-trees/hello.kt, line 1. -``` - -
- -- by address - -
- -```bash -(gdb) b *0x100001704 -Note: breakpoint 2 also set at pc 0x100001704. -Breakpoint 3 at 0x100001704: file /Users/minamoto/ws/.git-trees/hello.kt, line 2. -``` - -
- - -### Stepping -Stepping functions works mostly the same way as for C/C++ programs - -### Variable inspection - -Variable inspections for var variables works out of the box for primitive types. -For non-primitive types there are custom pretty printers for lldb in -`konan_lldb.py`: - -
- -```bash -λ cat main.kt | nl - 1 fun main(args: Array) { - 2 var x = 1 - 3 var y = 2 - 4 var p = Point(x, y) - 5 println("p = $p") - 6 } - - 7 data class Point(val x: Int, val y: Int) - -λ lldb ./program.kexe -o 'b main.kt:5' -o -(lldb) target create "./program.kexe" -Current executable set to './program.kexe' (x86_64). -(lldb) b main.kt:5 -Breakpoint 1: where = program.kexe`kfun:main(kotlin.Array) + 289 at main.kt:5, address = 0x000000000040af11 -(lldb) r -Process 4985 stopped -* thread #1, name = 'program.kexe', stop reason = breakpoint 1.1 - frame #0: program.kexe`kfun:main(kotlin.Array) at main.kt:5 - 2 var x = 1 - 3 var y = 2 - 4 var p = Point(x, y) --> 5 println("p = $p") - 6 } - 7 - 8 data class Point(val x: Int, val y: Int) - -Process 4985 launched: './program.kexe' (x86_64) -(lldb) fr var -(int) x = 1 -(int) y = 2 -(ObjHeader *) p = 0x00000000007643d8 -(lldb) command script import dist/tools/konan_lldb.py -(lldb) fr var -(int) x = 1 -(int) y = 2 -(ObjHeader *) p = [x: ..., y: ...] -(lldb) p p -(ObjHeader *) $2 = [x: ..., y: ...] -(lldb) script lldb.frame.FindVariable("p").GetChildMemberWithName("x").Dereference().GetValue() -'1' -(lldb) -``` - -
- - -Getting representation of the object variable (var) could also be done using the -built-in runtime function `Konan_DebugPrint` (this approach also works for gdb, -using a module of command syntax): - -
- -```bash -0:b-debugger-fixes:minamoto@unit-703(0)# cat ../debugger-plugin/1.kt | nl -p - 1 fun foo(a:String, b:Int) = a + b - 2 fun one() = 1 - 3 fun main(arg:Array) { - 4 var a_variable = foo("(a_variable) one is ", 1) - 5 var b_variable = foo("(b_variable) two is ", 2) - 6 var c_variable = foo("(c_variable) two is ", 3) - 7 var d_variable = foo("(d_variable) two is ", 4) - 8 println(a_variable) - 9 println(b_variable) - 10 println(c_variable) - 11 println(d_variable) - 12 } -0:b-debugger-fixes:minamoto@unit-703(0)# lldb ./program.kexe -o 'b -f 1.kt -l 9' -o r -(lldb) target create "./program.kexe" -Current executable set to './program.kexe' (x86_64). -(lldb) b -f 1.kt -l 9 -Breakpoint 1: where = program.kexe`kfun:main(kotlin.Array) + 463 at 1.kt:9, address = 0x0000000100000dbf -(lldb) r -(a_variable) one is 1 -Process 80496 stopped -* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 - frame #0: 0x0000000100000dbf program.kexe`kfun:main(kotlin.Array) at 1.kt:9 - 6 var c_variable = foo("(c_variable) two is ", 3) - 7 var d_variable = foo("(d_variable) two is ", 4) - 8 println(a_variable) --> 9 println(b_variable) - 10 println(c_variable) - 11 println(d_variable) - 12 } - -Process 80496 launched: './program.kexe' (x86_64) -(lldb) expression -- (int32_t)Konan_DebugPrint(a_variable) -(a_variable) one is 1(int32_t) $0 = 0 -(lldb) - -``` - -
- - -### Known issues -- performance of Python bindings. - -_Note:_ Supporting the DWARF 2 specification means that the debugger tool recognizes Kotlin as C89, because before the DWARF 5 specification, there is no identifier for the Kotlin language type in specification. - +The content of this page is moved to https://kotlinlang.org/docs/native-debugging.html \ No newline at end of file diff --git a/kotlin-native/FAQ.md b/kotlin-native/FAQ.md index 37a45224f8a..5993c85b615 100644 --- a/kotlin-native/FAQ.md +++ b/kotlin-native/FAQ.md @@ -1,206 +1 @@ -### Q: How do I run my program? - -A: Define a top level function `fun main(args: Array)` or just `fun main()` if you are not interested -in passed arguments, please ensure it's not in a package. -Also compiler switch `-entry` could be used to make any function taking `Array` or no arguments -and return `Unit` as an entry point. - - -### Q: What is Kotlin/Native memory management model? - -A: Kotlin/Native provides an automated memory management scheme, similar to what Java or Swift provides. -The current implementation includes an automated reference counter with a cycle collector to collect cyclical -garbage. - - -### Q: How do I create a shared library? - -A: Use the `-produce dynamic` compiler switch, or `binaries.sharedLib()` in Gradle, i.e. - -
- -```kotlin -kotlin { - iosArm64("mylib") { - binaries.sharedLib() - } -} -``` - -
- -It will produce a platform-specific shared object (.so on Linux, .dylib on macOS, and .dll on Windows targets) and a -C language header, allowing the use of all public APIs available in your Kotlin/Native program from C/C++ code. -See `samples/python_extension` for an example of using such a shared object to provide a bridge between Python and -Kotlin/Native. - - -### Q: How do I create a static library or an object file? - -A: Use the `-produce static` compiler switch, or `binaries.staticLib()` in Gradle, i.e. - -
- -```kotlin -kotlin { - iosArm64("mylib") { - binaries.staticLib() - } -} -``` - -
- -It will produce a platform-specific static object (.a library format) and a C language header, allowing you to -use all the public APIs available in your Kotlin/Native program from C/C++ code. - - -### Q: How do I run Kotlin/Native behind a corporate proxy? - -A: As Kotlin/Native needs to download a platform specific toolchain, you need to specify -`-Dhttp.proxyHost=xxx -Dhttp.proxyPort=xxx` as the compiler's or `gradlew` arguments, -or set it via the `JAVA_OPTS` environment variable. - - -### Q: How do I specify a custom Objective-C prefix/name for my Kotlin framework? - -A: Use the `-module-name` compiler option or matching Gradle DSL statement, i.e. - -
-
- -```kotlin -kotlin { - iosArm64("myapp") { - binaries.framework { - freeCompilerArgs += listOf("-module-name", "TheName") - } - } -} -``` - -
-
- -
-
- -```groovy -kotlin { - iosArm64("myapp") { - binaries.framework { - freeCompilerArgs += ["-module-name", "TheName"] - } - } -} -``` - -
-
- -### Q: How do I rename the iOS framework? (default name is _\_.framework) - -A: Use the `baseName` option. This will also set the module name. - -
- -```kotlin -kotlin { - iosArm64("myapp") { - binaries { - framework { - baseName = "TheName" - } - } - } -} -``` - -
- -### Q: How do I enable bitcode for my Kotlin framework? - -A: By default gradle plugin adds it on iOS target. - * For debug build it embeds placeholder LLVM IR data as a marker. - * For release build it embeds bitcode as data. - -Or commandline arguments: `-Xembed-bitcode` (for release) and `-Xembed-bitcode-marker` (debug) - -Setting this in a Gradle DSL: -
- -```kotlin -kotlin { - iosArm64("myapp") { - binaries { - framework { - // Use "marker" to embed the bitcode marker (for debug builds). - // Use "disable" to disable embedding. - embedBitcode("bitcode") // for release binaries. - } - } - } -} -``` - -
- -These options have nearly the same effect as clang's `-fembed-bitcode`/`-fembed-bitcode-marker` -and swiftc's `-embed-bitcode`/`-embed-bitcode-marker`. - -### Q: Why do I see `InvalidMutabilityException`? - -A: It likely happens, because you are trying to mutate a frozen object. An object can transfer to the -frozen state either explicitly, as objects reachable from objects on which the `kotlin.native.concurrent.freeze` is called, -or implicitly (i.e. reachable from `enum` or global singleton object - see the next question). - - -### Q: How do I make a singleton object mutable? - -A: Currently, singleton objects are immutable (i.e. frozen after creation), and it's generally considered -good practise to have the global state immutable. If for some reason you need a mutable state inside such an -object, use the `@konan.ThreadLocal` annotation on the object. Also the `kotlin.native.concurrent.AtomicReference` class could be -used to store different pointers to frozen objects in a frozen object and automatically update them. - -### Q: How can I compile my project against the Kotlin/Native master? - -A: One of the following should be done: - -
- -For the CLI, you can compile using gradle as stated in the README (and if you get errors, you can try to do a ./gradlew clean): - -
- -```bash -./gradlew dependencies:update -./gradlew dist distPlatformLibs -``` - -
- - -You can then set the `KONAN_HOME` env variable to the generated `dist` folder in the git repository. - -
- -
-For Gradle, you can use Gradle composite builds like this: - -
- - -```bash -# Set with the path of your kotlin-native clone -export KONAN_REPO=$PWD/../kotlin-native - -# Run this once since it is costly, you can remove the `clean` task if not big changes were made from the last time you did this -pushd $KONAN_REPO && git pull && ./gradlew clean dependencies:update dist distPlatformLibs && popd - -# In your project, you set have to the org.jetbrains.kotlin.native.home property, and include as composite the shared and gradle-plugin builds -./gradlew check -Porg.jetbrains.kotlin.native.home=$KONAN_REPO/dist --include-build $KONAN_REPO/shared --include-build $KONAN_REPO/tools/kotlin-native-gradle-plugin -``` - -
- -
+The content of this page is moved to https://kotlinlang.org/docs/native-faq.html \ No newline at end of file diff --git a/kotlin-native/GRADLE_PLUGIN.md b/kotlin-native/GRADLE_PLUGIN.md index 38deb1bb44f..72c09a2ecbb 100644 --- a/kotlin-native/GRADLE_PLUGIN.md +++ b/kotlin-native/GRADLE_PLUGIN.md @@ -3,7 +3,7 @@ Since 1.3.40, a separate Gradle plugin for Kotlin/Native is deprecated in favor of the `kotlin-multiplatform` plugin. This plugin provides an IDE support along with support of the new multiplatform project model introduced in Kotlin 1.3.0. Below you can find a short list of differences between `kotlin-platform-native` and `kotlin-muliplatform` plugins. -For more information see the `kotlin-muliplatform` [documentation page](https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html). +For more information see the `kotlin-muliplatform` [documentation page](https://kotlinlang.org/docs/mpp-discover-project.html). For `kotlin-platform-native` reference see the [corresponding section](#kotlin-platform-native-reference). ### Applying the multiplatform plugin diff --git a/kotlin-native/IMMUTABILITY.md b/kotlin-native/IMMUTABILITY.md index 746610d084a..b20185485cb 100644 --- a/kotlin-native/IMMUTABILITY.md +++ b/kotlin-native/IMMUTABILITY.md @@ -1,31 +1,3 @@ # Immutability in Kotlin/Native - Kotlin/Native implements strict mutability checks, ensuring -the important invariant that the object is either immutable or -accessible from the single thread at that moment in time (`mutable XOR global`). - - Immutability is a runtime property in Kotlin/Native, and can be applied -to an arbitrary object subgraph using the `kotlin.native.concurrent.freeze` function. -It makes all the objects reachable from the given one immutable, -such a transition is a one-way operation (i.e., objects cannot be unfrozen later). -Some naturally immutable objects such as `kotlin.String`, `kotlin.Int`, and -other primitive types, along with `AtomicInt` and `AtomicReference` are frozen -by default. If a mutating operation is applied to a frozen object, -an `InvalidMutabilityException` is thrown. - - To achieve `mutable XOR global` invariant, all globally visible state (currently, -`object` singletons and enums) are automatically frozen. If object freezing -is not desired, a `kotlin.native.ThreadLocal` annotation can be used, which will make -the object state thread local, and so, mutable (but the changed state is not visible to -other threads). - - Top level/global variables of non-primitive types are by default accessible in the -main thread (i.e., the thread which initialized _Kotlin/Native_ runtime first) only. -Access from another thread will lead to an `IncorrectDereferenceException` being thrown. -To make such variables accessible in other threads, you can use either the `@ThreadLocal` annotation, -and mark the value thread local or `@SharedImmutable`, which will make the value frozen and accessible -from other threads. - - Class `AtomicReference` can be used to publish the changed frozen state to -other threads, and so build patterns like shared caches. - +The content of this page is moved to https://kotlinlang.org/docs/native-immutability.html \ No newline at end of file diff --git a/kotlin-native/INTEROP.md b/kotlin-native/INTEROP.md index bbcfbb84083..83c9b604420 100644 --- a/kotlin-native/INTEROP.md +++ b/kotlin-native/INTEROP.md @@ -1,722 +1,3 @@ # _Kotlin/Native_ interoperability # -## Introduction ## - - _Kotlin/Native_ follows the general tradition of Kotlin to provide excellent -existing platform software interoperability. In the case of a native platform, -the most important interoperability target is a C library. So _Kotlin/Native_ -comes with a `cinterop` tool, which can be used to quickly generate -everything needed to interact with an external library. - - The following workflow is expected when interacting with the native library. - * create a `.def` file describing what to include into bindings - * use the `cinterop` tool to produce Kotlin bindings - * run _Kotlin/Native_ compiler on an application to produce the final executable - - The interoperability tool analyses C headers and produces a "natural" mapping of -the types, functions, and constants into the Kotlin world. The generated stubs can be -imported into an IDE for the purpose of code completion and navigation. - - Interoperability with Swift/Objective-C is provided too and covered in a -separate document [OBJC_INTEROP.md](OBJC_INTEROP.md). - -## Platform libraries ## - - Note that in many cases there's no need to use custom interoperability library creation mechanisms described below, -as for APIs available on the platform standardized bindings called [platform libraries](PLATFORM_LIBS.md) -could be used. For example, POSIX on Linux/macOS platforms, Win32 on Windows platform, or Apple frameworks -on macOS/iOS are available this way. - -## Simple example ## - -Install libgit2 and prepare stubs for the git library: - -
- -```bash - -cd samples/gitchurn -../../dist/bin/cinterop -def src/nativeInterop/cinterop/libgit2.def \ - -compiler-option -I/usr/local/include -o libgit2 -``` - -
- -Compile the client: - -
- -```bash -../../dist/bin/kotlinc src/gitChurnMain/kotlin \ - -library libgit2 -o GitChurn -``` - -
- -Run the client: - -
- -```bash -./GitChurn.kexe ../.. -``` - -
- - -## Creating bindings for a new library ## - - To create bindings for a new library, start by creating a `.def` file. -Structurally it's a simple property file, which looks like this: - -
- -```c -headers = png.h -headerFilter = png.h -package = png -``` - -
- - -Then run the `cinterop` tool with something like this (note that for host libraries that are not included -in the sysroot search paths, headers may be needed): - -
- -```bash -cinterop -def png.def -compiler-option -I/usr/local/include -o png -``` - -
- - -This command will produce a `png.klib` compiled library and -`png-build/kotlin` directory containing Kotlin source code for the library. - -If the behavior for a certain platform needs to be modified, you can use a format like -`compilerOpts.osx` or `compilerOpts.linux` to provide platform-specific values -to the options. - -Note, that the generated bindings are generally platform-specific, so if you are developing for -multiple targets, the bindings need to be regenerated. - -After the generation of bindings, they can be used by the IDE as a proxy view of the -native library. - -For a typical Unix library with a config script, the `compilerOpts` will likely contain -the output of a config script with the `--cflags` flag (maybe without exact paths). - -The output of a config script with `--libs` will be passed as a `-linkedArgs` `kotlinc` -flag value (quoted) when compiling. - -### Selecting library headers - -When library headers are imported to a C program with the `#include` directive, -all of the headers included by these headers are also included in the program. -So all header dependencies are included in generated stubs as well. - -This behavior is correct but it can be very inconvenient for some libraries. So -it is possible to specify in the `.def` file which of the included headers are to -be imported. The separate declarations from other headers can also be imported -in case of direct dependencies. - -#### Filtering headers by globs - -It is possible to filter headers by globs. The `headerFilter` property value -from the `.def` file is treated as a space-separated list of globs. If the -included header matches any of the globs, then the declarations from this header -are included into the bindings. - -The globs are applied to the header paths relative to the appropriate include -path elements, e.g. `time.h` or `curl/curl.h`. So if the library is usually -included with `#include `, then it would probably be -correct to filter headers with - -
- -```c -headerFilter = SomeLibrary/** -``` - -
- -If a `headerFilter` is not specified, then all headers are included. - -#### Filtering by module maps - -Some libraries have proper `module.modulemap` or `module.map` files in its -headers. For example, macOS and iOS system libraries and frameworks do. -The [module map file](https://clang.llvm.org/docs/Modules.html#module-map-language) -describes the correspondence between header files and modules. When the module -maps are available, the headers from the modules that are not included directly -can be filtered out using the experimental `excludeDependentModules` option of the -`.def` file: - -
- -```c -headers = OpenGL/gl.h OpenGL/glu.h GLUT/glut.h -compilerOpts = -framework OpenGL -framework GLUT -excludeDependentModules = true -``` - -
- - -When both `excludeDependentModules` and `headerFilter` are used, they are -applied as an intersection. - -### C compiler and linker options ### - - Options passed to the C compiler (used to analyze headers, such as preprocessor definitions) and the linker -(used to link final executables) can be passed in the definition file as `compilerOpts` and `linkerOpts` -respectively. For example - -
- -```c -compilerOpts = -DFOO=bar -linkerOpts = -lpng -``` - -
- -Target-specific options, only applicable to the certain target can be specified as well, such as - -
- - ```c - compilerOpts = -DBAR=bar - compilerOpts.linux_x64 = -DFOO=foo1 - compilerOpts.mac_x64 = -DFOO=foo2 - ``` - -
- -and so, C headers on Linux will be analyzed with `-DBAR=bar -DFOO=foo1` and on macOS with `-DBAR=bar -DFOO=foo2`. -Note that any definition file option can have both common and the platform-specific part. - -### Adding custom declarations ### - - Sometimes it is required to add custom C declarations to the library before -generating bindings (e.g., for [macros](#macros)). Instead of creating an -additional header file with these declarations, you can include them directly -to the end of the `.def` file, after a separating line, containing only the -separator sequence `---`: - -
- -```c -headers = errno.h - ---- - -static inline int getErrno() { - return errno; -} -``` - -
- -Note that this part of the `.def` file is treated as part of the header file, so -functions with the body should be declared as `static`. -The declarations are parsed after including the files from the `headers` list. - -### Including static library in your klib - -Sometimes it is more convenient to ship a static library with your product, -rather than assume it is available within the user's environment. -To include a static library into `.klib` use `staticLibrary` and `libraryPaths` -clauses. For example: - -
- -```c -headers = foo.h -staticLibraries = libfoo.a -libraryPaths = /opt/local/lib /usr/local/opt/curl/lib -``` - -
- -When given the above snippet the `cinterop` tool will search `libfoo.a` in -`/opt/local/lib` and `/usr/local/opt/curl/lib`, and if it is found include the -library binary into `klib`. - -When using such `klib` in your program, the library is linked automatically. - -## Using bindings ## - -### Basic interop types ### - -All the supported C types have corresponding representations in Kotlin: - -* Signed, unsigned integral, and floating point types are mapped to their - Kotlin counterpart with the same width. -* Pointers and arrays are mapped to `CPointer?`. -* Enums can be mapped to either Kotlin enum or integral values, depending on - heuristics and the [definition file hints](#definition-file-hints). -* Structs / unions are mapped to types having fields available via the dot notation, - i.e. `someStructInstance.field1`. -* `typedef` are represented as `typealias`. - -Also, any C type has the Kotlin type representing the lvalue of this type, -i.e., the value located in memory rather than a simple immutable self-contained -value. Think C++ references, as a similar concept. -For structs (and `typedef`s to structs) this representation is the main one -and has the same name as the struct itself, for Kotlin enums it is named -`${type}Var`, for `CPointer` it is `CPointerVar`, and for most other -types it is `${type}Var`. - -For types that have both representations, the one with a "lvalue" has a mutable -`.value` property for accessing the value. - -#### Pointer types #### - -The type argument `T` of `CPointer` must be one of the "lvalue" types -described above, e.g., the C type `struct S*` is mapped to `CPointer`, -`int8_t*` is mapped to `CPointer`, and `char**` is mapped to -`CPointer>`. - -C null pointer is represented as Kotlin's `null`, and the pointer type -`CPointer` is not nullable, but the `CPointer?` is. The values of this -type support all the Kotlin operations related to handling `null`, e.g. `?:`, `?.`, -`!!` etc.: - -
- -```kotlin -val path = getenv("PATH")?.toKString() ?: "" -``` - -
- -Since the arrays are also mapped to `CPointer`, it supports the `[]` operator -for accessing values by index: - -
- -```kotlin -fun shift(ptr: CPointer, length: Int) { - for (index in 0 .. length - 2) { - ptr[index] = ptr[index + 1] - } -} -``` - -
- -The `.pointed` property for `CPointer` returns the lvalue of type `T`, -pointed by this pointer. The reverse operation is `.ptr`: it takes the lvalue -and returns the pointer to it. - -`void*` is mapped to `COpaquePointer` – the special pointer type which is the -supertype for any other pointer type. So if the C function takes `void*`, then -the Kotlin binding accepts any `CPointer`. - -Casting a pointer (including `COpaquePointer`) can be done with -`.reinterpret`, e.g.: - -
- -```kotlin -val intPtr = bytePtr.reinterpret() -``` - -
- -or - -
- -```kotlin -val intPtr: CPointer = bytePtr.reinterpret() -``` - -
- -As is with C, these reinterpret casts are unsafe and can potentially lead to -subtle memory problems in the application. - -Also there are unsafe casts between `CPointer?` and `Long` available, -provided by the `.toLong()` and `.toCPointer()` extension methods: - -
- -```kotlin -val longValue = ptr.toLong() -val originalPtr = longValue.toCPointer() -``` - -
- -Note that if the type of the result is known from the context, the type argument -can be omitted as usual due to the type inference. - -### Memory allocation ### - -The native memory can be allocated using the `NativePlacement` interface, e.g. - -
- -```kotlin -val byteVar = placement.alloc() -``` - -
- -or - -
- -```kotlin -val bytePtr = placement.allocArray(5) -``` - -
- -The most "natural" placement is in the object `nativeHeap`. -It corresponds to allocating native memory with `malloc` and provides an additional -`.free()` operation to free allocated memory: - -
- -```kotlin -val buffer = nativeHeap.allocArray(size) - -nativeHeap.free(buffer) -``` - -
- -However, the lifetime of allocated memory is often bound to the lexical scope. -It is possible to define such scope with `memScoped { ... }`. -Inside the braces, the temporary placement is available as an implicit receiver, -so it is possible to allocate native memory with `alloc` and `allocArray`, -and the allocated memory will be automatically freed after leaving the scope. - -For example, the C function returning values through pointer parameters can be -used like - -
- -```kotlin -val fileSize = memScoped { - val statBuf = alloc() - val error = stat("/", statBuf.ptr) - statBuf.st_size -} -``` - -
- -### Passing pointers to bindings ### - -Although C pointers are mapped to the `CPointer` type, the C function -pointer-typed parameters are mapped to `CValuesRef`. When passing -`CPointer` as the value of such a parameter, it is passed to the C function as is. -However, the sequence of values can be passed instead of a pointer. In this case -the sequence is passed "by value", i.e., the C function receives the pointer to -the temporary copy of that sequence, which is valid only until the function returns. - -The `CValuesRef` representation of pointer parameters is designed to support -C array literals without explicit native memory allocation. -To construct the immutable self-contained sequence of C values, the following -methods are provided: - -* `${type}Array.toCValues()`, where `type` is the Kotlin primitive type -* `Array?>.toCValues()`, `List?>.toCValues()` -* `cValuesOf(vararg elements: ${type})`, where `type` is a primitive or pointer - -For example: - -C: - -
- -```c -void foo(int* elements, int count); -... -int elements[] = {1, 2, 3}; -foo(elements, 3); -``` - -
- -Kotlin: - -
- -```kotlin -foo(cValuesOf(1, 2, 3), 3) -``` - -
- -### Working with the strings ### - -Unlike other pointers, the parameters of type `const char*` are represented as -a Kotlin `String`. So it is possible to pass any Kotlin string to a binding -expecting a C string. - -There are also some tools available to convert between Kotlin and C strings -manually: - -* `fun CPointer.toKString(): String` -* `val String.cstr: CValuesRef`. - - To get the pointer, `.cstr` should be allocated in native memory, e.g. - -
- - ``` - val cString = kotlinString.cstr.getPointer(nativeHeap) - ``` - -
- -In all cases, the C string is supposed to be encoded as UTF-8. - -To skip automatic conversion and ensure raw pointers are used in the bindings, a `noStringConversion` -statement in the `.def` file could be used, i.e. - -
- -```c -noStringConversion = LoadCursorA LoadCursorW -``` - -
- -This way any value of type `CPointer` can be passed as an argument of `const char*` type. -If a Kotlin string should be passed, code like this could be used: - -
- -```kotlin -memScoped { - LoadCursorA(null, "cursor.bmp".cstr.ptr) // for ASCII version - LoadCursorW(null, "cursor.bmp".wcstr.ptr) // for Unicode version -} -``` - -
- -### Scope-local pointers ### - -It is possible to create a scope-stable pointer of C representation of `CValues` -instance using the `CValues.ptr` extension property, available under `memScoped { ... }`. -It allows using the APIs which require C pointers with a lifetime bound to a certain `MemScope`. For example: - -
- -```kotlin -memScoped { - items = arrayOfNulls?>(6) - arrayOf("one", "two").forEachIndexed { index, value -> items[index] = value.cstr.ptr } - menu = new_menu("Menu".cstr.ptr, items.toCValues().ptr) - ... -} -``` - -
- -In this example, all values passed to the C API `new_menu()` have a lifetime of the innermost `memScope` -it belongs to. Once the control flow leaves the `memScoped` scope the C pointers become invalid. - -### Passing and receiving structs by value ### - -When a C function takes or returns a struct / union `T` by value, the corresponding -argument type or return type is represented as `CValue`. - -`CValue` is an opaque type, so the structure fields cannot be accessed with -the appropriate Kotlin properties. It should be possible, if an API uses structures -as handles, but if field access is required, there are the following conversion -methods available: - -* `fun T.readValue(): CValue`. Converts (the lvalue) `T` to a `CValue`. - So to construct the `CValue`, `T` can be allocated, filled, and then - converted to `CValue`. - -* `CValue.useContents(block: T.() -> R): R`. Temporarily places the - `CValue` to memory, and then runs the passed lambda with this placed - value `T` as receiver. So to read a single field, the following code can be - used: - -
- - ```kotlin - val fieldValue = structValue.useContents { field } - ``` - -
- - -### Callbacks ### - -To convert a Kotlin function to a pointer to a C function, -`staticCFunction(::kotlinFunction)` can be used. It is also able to provide -the lambda instead of a function reference. The function or lambda must not -capture any values. - -If the callback doesn't run in the main thread, it is mandatory to init the _Kotlin/Native_ -runtime by calling `kotlin.native.initRuntimeIfNeeded()`. - -#### Passing user data to callbacks #### - -Often C APIs allow passing some user data to callbacks. Such data is usually -provided by the user when configuring the callback. It is passed to some C function -(or written to the struct) as e.g. `void*`. -However, references to Kotlin objects can't be directly passed to C. -So they require wrapping before configuring the callback and then unwrapping in -the callback itself, to safely swim from Kotlin to Kotlin through the C world. -Such wrapping is possible with `StableRef` class. - -To wrap the reference: - -
- -```kotlin -val stableRef = StableRef.create(kotlinReference) -val voidPtr = stableRef.asCPointer() -``` - -
- -where the `voidPtr` is a `COpaquePointer` and can be passed to the C function. - -To unwrap the reference: - -
- -```kotlin -val stableRef = voidPtr.asStableRef() -val kotlinReference = stableRef.get() -``` - -
- -where `kotlinReference` is the original wrapped reference. - -The created `StableRef` should eventually be manually disposed using -the `.dispose()` method to prevent memory leaks: - -
- -```kotlin -stableRef.dispose() -``` - -
- -After that it becomes invalid, so `voidPtr` can't be unwrapped anymore. - -See the `samples/libcurl` for more details. - -### Macros ### - -Every C macro that expands to a constant is represented as a Kotlin property. -Other macros are not supported. However, they can be exposed manually by -wrapping them with supported declarations. E.g. function-like macro `FOO` can be -exposed as function `foo` by -[adding the custom declaration](#adding-custom-declarations) to the library: - -
- -```c -headers = library/base.h - ---- - -static inline int foo(int arg) { - return FOO(arg); -} -``` - -
- -### Definition file hints ### - -The `.def` file supports several options for adjusting the generated bindings. - -* `excludedFunctions` property value specifies a space-separated list of the names - of functions that should be ignored. This may be required because a function - declared in the C header is not generally guaranteed to be really callable, and - it is often hard or impossible to figure this out automatically. This option - can also be used to workaround a bug in the interop itself. - -* `strictEnums` and `nonStrictEnums` properties values are space-separated - lists of the enums that should be generated as a Kotlin enum or as integral - values correspondingly. If the enum is not included into any of these lists, - then it is generated according to the heuristics. - -* `noStringConversion` property value is space-separated lists of the functions whose - `const char*` parameters shall not be autoconverted as Kotlin string - -### Portability ### - - Sometimes the C libraries have function parameters or struct fields of a -platform-dependent type, e.g. `long` or `size_t`. Kotlin itself doesn't provide -neither implicit integer casts nor C-style integer casts (e.g. -`(size_t) intValue`), so to make writing portable code in such cases easier, -the `convert` method is provided: - -
- -```kotlin -fun ${type1}.convert<${type2}>(): ${type2} -``` -
- -where each of `type1` and `type2` must be an integral type, either signed or unsigned. - -`.convert<${type}>` has the same semantics as one of the -`.toByte`, `.toShort`, `.toInt`, `.toLong`, -`.toUByte`, `.toUShort`, `.toUInt` or `.toULong` -methods, depending on `type`. - -The example of using `convert`: - -
- -```kotlin -fun zeroMemory(buffer: COpaquePointer, size: Int) { - memset(buffer, 0, size.convert()) -} -``` - -
- -Also, the type parameter can be inferred automatically and so may be omitted -in some cases. - - -### Object pinning ### - - Kotlin objects could be pinned, i.e. their position in memory is guaranteed to be stable -until unpinned, and pointers to such objects inner data could be passed to the C functions. For example - -
- -```kotlin -fun readData(fd: Int): String { - val buffer = ByteArray(1024) - buffer.usePinned { pinned -> - while (true) { - val length = recv(fd, pinned.addressOf(0), buffer.size.convert(), 0).toInt() - - if (length <= 0) { - break - } - // Now `buffer` has raw data obtained from the `recv()` call. - } - } -} -``` - -
- -Here we use service function `usePinned`, which pins an object, executes block and unpins it on normal and -exception paths. +The content of this page is moved to https://kotlinlang.org/docs/native-c-interop.html \ No newline at end of file diff --git a/kotlin-native/IOS_SYMBOLICATION.md b/kotlin-native/IOS_SYMBOLICATION.md index c7d58ec0cc1..cb0153fa577 100644 --- a/kotlin-native/IOS_SYMBOLICATION.md +++ b/kotlin-native/IOS_SYMBOLICATION.md @@ -1,74 +1,3 @@ # Symbolicating iOS crash reports -Debugging an iOS application crash sometimes involves analyzing crash reports. -More info about crash reports can be found -[in the official documentation](https://developer.apple.com/library/archive/technotes/tn2151/_index.html). - -Crash reports generally require symbolication to become properly readable: -symbolication turns machine code addresses into human-readable source locations. -The document below describes some specific details of symbolicating crash reports -from iOS applications using Kotlin. - -## Producing .dSYM for release Kotlin binaries - -To symbolicate addresses in Kotlin code (e.g. for stack trace elements -corresponding to Kotlin code) `.dSYM` bundle for Kotlin code is required. - -By default Kotlin/Native compiler produces `.dSYM` for release -(i.e. optimized) binaries on Darwin platforms. This can be disabled with `-Xadd-light-debug=disable` -compiler flag. At the same time this option is disabled by default for other platforms, to enable it use `-Xadd-light-debug=enable`. -To control option in Gradle, use - -```kotlin -kotlin { - targets.withType { - binaries.all { - freeCompilerArgs += "-Xadd-light-debug={enable|disable}" - } - } -} -``` - -(in Kotlin DSL). - -In projects created from IntelliJ IDEA or AppCode templates these `.dSYM` bundles -are then discovered by Xcode automatically. - -## Make frameworks static when using rebuild from bitcode - -Rebuilding Kotlin-produced framework from bitcode invalidates the original `.dSYM`. -If it is performed locally, make sure the updated `.dSYM` is used when symbolicating -crash reports. - -If rebuilding is performed on App Store side, then `.dSYM` of rebuilt *dynamic* framework -seems discarded and not downloadable from App Store Connect. -So in this case it may be required to make the framework static, e.g. with - -```kotlin -kotlin { - targets.withType { - binaries.withType { - isStatic = true - } - } -} -``` - -(in Kotlin DSL). - -## Decode inlined stack frames - -Xcode doesn't seem to properly decode stack trace elements of inlined function -calls (these aren't only Kotlin `inline` functions but also functions that are -inlined when optimizing machine code). So some stack trace elements may be -missing. If this is the case, consider using `lldb` to process crash report -that is already symbolicated by Xcode, for example: - -```bash -$ lldb -b -o "script import lldb.macosx" -o "crashlog file.crash" -``` - -This command should output crash report that is additionally processed and -includes inlined stack trace elements. - -More details can be found in [LLDB documentation](https://lldb.llvm.org/use/symbolication.html). +The content of this page is moved to https://kotlinlang.org/docs/native-ios-symbolication.html \ No newline at end of file diff --git a/kotlin-native/LIBRARIES.md b/kotlin-native/LIBRARIES.md index 4539e6c3e0d..6438ec64616 100644 --- a/kotlin-native/LIBRARIES.md +++ b/kotlin-native/LIBRARIES.md @@ -1,245 +1,3 @@ # Kotlin/Native libraries -## Kotlin compiler specifics - -To produce a library with the Kotlin/Native compiler use the `-produce library` or `-p library` flag. For example: - -
- -```bash -$ kotlinc foo.kt -p library -o bar -``` - -
- -the above command will produce a `bar.klib` with the compiled contents of `foo.kt`. - -To link to a library use the `-library ` or `-l ` flag. For example: - -
- -```bash -$ kotlinc qux.kt -l bar -``` - -
- - -the above command will produce a `program.kexe` out of `qux.kt` and `bar.klib` - - -## cinterop tool specifics - -The **cinterop** tool produces `.klib` wrappers for native libraries as its main output. -For example, using the simple `libgit2.def` native library definition file provided in your Kotlin/Native distribution - -
- -```bash -$ cinterop -def samples/gitchurn/src/nativeInterop/cinterop/libgit2.def -compiler-option -I/usr/local/include -o libgit2 -``` - -
- -we will obtain `libgit2.klib`. - -See more details in [INTEROP.md](INTEROP.md) - - -## klib utility - -The **klib** library management utility allows you to inspect and install the libraries. - -The following commands are available. - -To list library contents: - -
- -```bash -$ klib contents -``` - -
- -To inspect the bookkeeping details of the library - -
- -```bash -$ klib info -``` - -
- -To install the library to the default location use - -
- -```bash -$ klib install -``` - -
- -To remove the library from the default repository use - -
- -```bash -$ klib remove -``` - -
- -All of the above commands accept an additional `-repository ` argument for specifying a repository different to the default one. - -
- -```bash -$ klib -repository -``` - -
- - -## Several examples - -First let's create a library. -Place the tiny library source code into `kotlinizer.kt`: - -
- -```kotlin -package kotlinizer -val String.kotlinized - get() = "Kotlin $this" -``` - -```bash -$ kotlinc kotlinizer.kt -p library -o kotlinizer -``` - -
- -The library has been created in the current directory: - -
- -```bash -$ ls kotlinizer.klib -kotlinizer.klib -``` - -
- -Now let's check out the contents of the library: - -
- -```bash -$ klib contents kotlinizer -``` - -
- -We can install `kotlinizer` to the default repository: - -
- -```bash -$ klib install kotlinizer -``` - -
- -Remove any traces of it from the current directory: - -
- -```bash -$ rm kotlinizer.klib -``` - -
- -Create a very short program and place it into a `use.kt` : - -
- -```kotlin -import kotlinizer.* - -fun main(args: Array) { - println("Hello, ${"world".kotlinized}!") -} -``` - -
- -Now compile the program linking with the library we have just created: - -
- -```bash -$ kotlinc use.kt -l kotlinizer -o kohello -``` - -
- -And run the program: - -
- -```bash -$ ./kohello.kexe -Hello, Kotlin world! -``` - -
- -Have fun! - -# Advanced topics - -## Library search sequence - -When given a `-library foo` flag, the compiler searches the `foo` library in the following order: - - * Current compilation directory or an absolute path. - - * All repositories specified with `-repo` flag. - - * Libraries installed in the default repository (For now the default is `~/.konan`, however it could be changed by setting **KONAN_DATA_DIR** environment variable). - - * Libraries installed in `$installation/klib` directory. - -## The library format - -Kotlin/Native libraries are zip files containing a predefined -directory structure, with the following layout: - -**foo.klib** when unpacked as **foo/** gives us: - -```yaml - - foo/ - - $component_name/ - - ir/ - - Serialized Kotlin IR. - - targets/ - - $platform/ - - kotlin/ - - Kotlin compiled to LLVM bitcode. - - native/ - - Bitcode files of additional native objects. - - $another_platform/ - - There can be several platform specific kotlin and native pairs. - - linkdata/ - - A set of ProtoBuf files with serialized linkage metadata. - - resources/ - - General resources such as images. (Not used yet). - - manifest - A file in *java property* format describing the library. -``` - -An example layout can be found in `klib/stdlib` directory of your installation. - +The content of this page is moved to https://kotlinlang.org/docs/native-libraries.html \ No newline at end of file diff --git a/kotlin-native/OBJC_INTEROP.md b/kotlin-native/OBJC_INTEROP.md index 6c49cd061a2..b2a071746e0 100644 --- a/kotlin-native/OBJC_INTEROP.md +++ b/kotlin-native/OBJC_INTEROP.md @@ -1,426 +1,3 @@ # _Kotlin/Native_ interoperability with Swift/Objective-C -This document covers some details of Kotlin/Native interoperability with -Swift/Objective-C. - -## Usage - -Kotlin/Native provides bidirectional interoperability with Objective-C. -Objective-C frameworks and libraries can be used in Kotlin code if -properly imported to the build (system frameworks are imported by default). -See e.g. "Using cinterop" in -[Gradle plugin documentation](GRADLE_PLUGIN.md#using-cinterop). -A Swift library can be used in Kotlin code if its API is exported to Objective-C -with `@objc`. Pure Swift modules are not yet supported. - -Kotlin modules can be used in Swift/Objective-C code if compiled into a -framework (see "Targets and output kinds" section in [Gradle plugin documentation](GRADLE_PLUGIN.md#targets-and-output-kinds)). -See [calculator sample](https://github.com/JetBrains/kotlin-native/tree/master/samples/calculator) for an example. - -## Mappings - -The table below shows how Kotlin concepts are mapped to Swift/Objective-C and vice versa. - -"->" and "<-" indicate that mapping only goes one way. - -| Kotlin | Swift | Objective-C | Notes | -| ------ | ----- |------------ | ----- | -| `class` | `class` | `@interface` | [note](#name-translation) | -| `interface` | `protocol` | `@protocol` | | -| `constructor`/`create` | Initializer | Initializer | [note](#initializers) | -| Property | Property | Property | [note](#top-level-functions-and-properties) [note](#setters)| -| Method | Method | Method | [note](#top-level-functions-and-properties) [note](#method-names-translation) | -| `suspend` -> | `completionHandler:` | | [note](#errors-and-exceptions) | -| `@Throws fun` | `throws` | `error:(NSError**)error` | [note](#errors-and-exceptions) | -| Extension | Extension | Category member | [note](#extensions-and-category-members) | -| `companion` member <- | Class method or property | Class method or property | | -| `null` | `nil` | `nil` | | -| `Singleton` | `Singleton()` | `[Singleton singleton]` | [note](#kotlin-singletons) | -| Primitive type | Primitive type / `NSNumber` | | [note](#nsnumber) | -| `Unit` return type | `Void` | `void` | | -| `String` | `String` | `NSString` | | -| `String` | `NSMutableString` | `NSMutableString` | [note](#nsmutablestring) | -| `List` | `Array` | `NSArray` | | -| `MutableList` | `NSMutableArray` | `NSMutableArray` | | -| `Set` | `Set` | `NSSet` | | -| `MutableSet` | `NSMutableSet` | `NSMutableSet` | [note](#collections) | -| `Map` | `Dictionary` | `NSDictionary` | | -| `MutableMap` | `NSMutableDictionary` | `NSMutableDictionary` | [note](#collections) | -| Function type | Function type | Block pointer type | [note](#function-types) | -| Inline classes | Unsupported| Unsupported| [note](#unsupported) | - - -### Name translation - -Objective-C classes are imported into Kotlin with their original names. -Protocols are imported as interfaces with `Protocol` name suffix, -i.e. `@protocol Foo` -> `interface FooProtocol`. -These classes and interfaces are placed into a package [specified in build configuration](#usage) -(`platform.*` packages for preconfigured system frameworks). - -The names of Kotlin classes and interfaces are prefixed when imported to Objective-C. -The prefix is derived from the framework name. - -### Initializers - -Swift/Objective-C initializers are imported to Kotlin as constructors and factory methods -named `create`. The latter happens with initializers declared in the Objective-C category or -as a Swift extension, because Kotlin has no concept of extension constructors. - -Kotlin constructors are imported as initializers to Swift/Objective-C. - -### Setters - -Writeable Objective-C properties overriding read-only properties of the superclass are represented as `setFoo()` method for the property `foo`. Same goes for a protocol's read-only properties that are implemented as mutable. - -### Top-level functions and properties - -Top-level Kotlin functions and properties are accessible as members of special classes. -Each Kotlin file is translated into such a class. E.g. - -
- -```kotlin -// MyLibraryUtils.kt -package my.library - -fun foo() {} -``` - -
- -can be called from Swift like - -
- -```swift -MyLibraryUtilsKt.foo() -``` - -
- -### Method names translation - -Generally Swift argument labels and Objective-C selector pieces are mapped to Kotlin -parameter names. Anyway these two concepts have different semantics, so sometimes -Swift/Objective-C methods can be imported with a clashing Kotlin signature. In this case -the clashing methods can be called from Kotlin using named arguments, e.g.: - -
- -```swift -[player moveTo:LEFT byMeters:17] -[player moveTo:UP byInches:42] -``` - -
- -in Kotlin it would be: - -
- -```kotlin -player.moveTo(LEFT, byMeters = 17) -player.moveTo(UP, byInches = 42) -``` - -
- -### Errors and exceptions - -Kotlin has no concept of checked exceptions, all Kotlin exceptions are unchecked. -Swift has only checked errors. So if Swift or Objective-C code calls a Kotlin method -which throws an exception to be handled, then the Kotlin method should be marked -with a `@Throws` annotation specifying a list of "expected" exception classes. - -When compiling to Objective-C/Swift framework, non-`suspend` functions having or inheriting -`@Throws` annotation are represented as `NSError*`-producing methods in Objective-C -and as `throws` methods in Swift. Representations for `suspend` functions always have -`NSError*`/`Error` parameter in completion handler. - -When Kotlin function called from Swift/Objective-C code throws an exception -which is an instance of one of the `@Throws`-specified classes or their subclasses, -it is propagated as `NSError`. Other Kotlin exceptions reaching Swift/Objective-C -are considered unhandled and cause program termination. - -`suspend` functions without `@Throws` propagate only -`CancellationException` as `NSError`. Non-`suspend` functions without `@Throws` -don't propagate Kotlin exceptions at all. - -Note that the opposite reversed translation is not implemented yet: -Swift/Objective-C error-throwing methods aren't imported to Kotlin as -exception-throwing. - -### Extensions and category members - -Members of Objective-C categories and Swift extensions are imported to Kotlin -as extensions. That's why these declarations can't be overridden in Kotlin. -And the extension initializers aren't available as Kotlin constructors. - -Kotlin extensions to "regular" Kotlin classes are imported to Swift and Objective-C as extensions and category members respectively. -Kotlin extensions to other types are treated as [top-level declarations](#top-level-functions-and-properties) -with an additional receiver parameter. These types include: - -* Kotlin `String` type -* Kotlin collection types and subtypes -* Kotlin `interface` types -* Kotlin primitive types -* Kotlin `inline` classes -* Kotlin `Any` type -* Kotlin function types and subtypes -* Objective-C classes and protocols - -### Kotlin singletons - -Kotlin singleton (made with an `object` declaration, including `companion object`) -is imported to Swift/Objective-C as a class with a single instance. -The instance is available through the factory method, i.e. as -`[MySingleton mySingleton]` in Objective-C and `MySingleton()` in Swift. - -### NSNumber - -Kotlin primitive type boxes are mapped to special Swift/Objective-C classes. -For example, `kotlin.Int` box is represented as `KotlinInt` class instance in Swift -(or `${prefix}Int` instance in Objective-C, where `prefix` is the framework names prefix). -These classes are derived from `NSNumber`, so the instances are proper `NSNumber`s -supporting all corresponding operations. - -`NSNumber` type is not automatically translated to Kotlin primitive types -when used as a Swift/Objective-C parameter type or return value. -The reason is that `NSNumber` type doesn't provide enough information -about a wrapped primitive value type, i.e. `NSNumber` is statically not known -to be a e.g. `Byte`, `Boolean`, or `Double`. So Kotlin primitive values -should be cast to/from `NSNumber` manually (see [below](#casting-between-mapped-types)). - -### NSMutableString - -`NSMutableString` Objective-C class is not available from Kotlin. -All instances of `NSMutableString` are copied when passed to Kotlin. - -### Collections - -Kotlin collections are converted to Swift/Objective-C collections as described -in the table above. Swift/Objective-C collections are mapped to Kotlin in the same way, -except for `NSMutableSet` and `NSMutableDictionary`. `NSMutableSet` isn't converted to -a Kotlin `MutableSet`. To pass an object for Kotlin `MutableSet`, -you can create this kind of Kotlin collection explicitly by either creating it -in Kotlin with e.g. `mutableSetOf()`, or using the `KotlinMutableSet` class in Swift -(or `${prefix}MutableSet` in Objective-C, where `prefix` is the framework names prefix). -The same holds for `MutableMap`. - -### Function types - -Kotlin function-typed objects (e.g. lambdas) are converted to -Swift functions / Objective-C blocks. However there is a difference in how -types of parameters and return values are mapped when translating a function -and a function type. In the latter case primitive types are mapped to their -boxed representation. Kotlin `Unit` return value is represented -as a corresponding `Unit` singleton in Swift/Objective-C. The value of this singleton -can be retrieved in the same way as it is for any other Kotlin `object` -(see singletons in the table above). -To sum the things up: - -
- -```kotlin -fun foo(block: (Int) -> Unit) { ... } -``` - -
- -would be represented in Swift as - -
- -```swift -func foo(block: (KotlinInt) -> KotlinUnit) -``` - -
- -and can be called like - -
- -```kotlin -foo { - bar($0 as! Int32) - return KotlinUnit() -} -``` - -
- -### Generics - -Objective-C supports "lightweight generics" defined on classes, with a relatively limited feature set. Swift can import -generics defined on classes to help provide additional type information to the compiler. - -Generic feature support for Objective-C and Swift differ from Kotlin, so the translation will inevitably lose some information, -but the features supported retain meaningful information. - -#### Limitations - -Objective-C generics do not support all features of either Kotlin or Swift, so there will be some information lost -in the translation. - -Generics can only be defined on classes, not on interfaces (protocols in Objective-C and Swift) or functions. - -#### Nullability - -Kotlin and Swift both define nullability as part of the type specification, while Objective-C defines nullability on methods -and properties of a type. As such, the following: - -
- -```kotlin -class Sample() { - fun myVal(): T -} -``` - -
- -will (logically) look like this: - -
- -```swift -class Sample() { - fun myVal(): T? -} -``` - -
- -In order to support a potentially nullable type, the Objective-C header needs to define `myVal` with a nullable return value. - -To mitigate this, when defining your generic classes, if the generic type should *never* be null, provide a non-null -type constraint: - -
- -```kotlin -class Sample() { - fun myVal(): T -} -``` - -
- -That will force the Objective-C header to mark `myVal` as non-null. - -#### Variance - -Objective-C allows generics to be declared covariant or contravariant. Swift has no support for variance. Generic classes coming -from Objective-C can be force-cast as needed. - -
- -```kotlin -data class SomeData(val num: Int = 42) : BaseData() -class GenVarOut(val arg: T) -``` - -
- -
- -```swift -let variOut = GenVarOut(arg: sd) -let variOutAny : GenVarOut = variOut as! GenVarOut -``` - -
- -#### Constraints - -In Kotlin you can provide upper bounds for a generic type. Objective-C also supports this, but that support is unavailable -in more complex cases, and is currently not supported in the Kotlin - Objective-C interop. The exception here being a non-null -upper bound will make Objective-C methods/properties non-null. - -### To disable - -To have the framework header written without generics, add the flag to the compiler config: - -
- -```kotlin -binaries.framework { - freeCompilerArgs += "-Xno-objc-generics" -} -``` - -
- -## Casting between mapped types - -When writing Kotlin code, an object may need to be converted from a Kotlin type -to the equivalent Swift/Objective-C type (or vice versa). In this case a plain old -Kotlin cast can be used, e.g. - -
- -```kotlin -val nsArray = listOf(1, 2, 3) as NSArray -val string = nsString as String -val nsNumber = 42 as NSNumber -``` - -
- -## Subclassing - -### Subclassing Kotlin classes and interfaces from Swift/Objective-C - -Kotlin classes and interfaces can be subclassed by Swift/Objective-C classes -and protocols. - -### Subclassing Swift/Objective-C classes and protocols from Kotlin - -Swift/Objective-C classes and protocols can be subclassed with a Kotlin `final` class. -Non-`final` Kotlin classes inheriting Swift/Objective-C types aren't supported yet, so it is -not possible to declare a complex class hierarchy inheriting Swift/Objective-C types. - -Normal methods can be overridden using the `override` Kotlin keyword. In this case -the overriding method must have the same parameter names as the overridden one. - -Sometimes it is required to override initializers, e.g. when subclassing `UIViewController`. -Initializers imported as Kotlin constructors can be overridden by Kotlin constructors -marked with the `@OverrideInit` annotation: - -
- -```swift -class ViewController : UIViewController { - @OverrideInit constructor(coder: NSCoder) : super(coder) - - ... -} -``` - -
- -The overriding constructor must have the same parameter names and types as the overridden one. - -To override different methods with clashing Kotlin signatures, you can add a -`@Suppress("CONFLICTING_OVERLOADS")` annotation to the class. - -By default the Kotlin/Native compiler doesn't allow calling a non-designated -Objective-C initializer as a `super(...)` constructor. This behaviour can be -inconvenient if the designated initializers aren't marked properly in the Objective-C -library. Adding a `disableDesignatedInitializerChecks = true` to the `.def` file for -this library would disable these compiler checks. - -## C features - -See [INTEROP.md](INTEROP.md) for an example case where the library uses some plain C features -(e.g. unsafe pointers, structs etc.). - -## Unsupported - -Some features of Kotlin programming language are not yet mapped into respective features of Objective-C or Swift. -Currently, following features are not properly exposed in generated framework headers: - * inline classes (arguments are mapped as either underlying primitive type or `id`) - * custom classes implementing standard Kotlin collection interfaces (`List`, `Map`, `Set`) and other special classes - * Kotlin subclasses of Objective-C classes +The content of this page is moved to https://kotlinlang.org/docs/native-objc-interop.html \ No newline at end of file diff --git a/kotlin-native/PLATFORM_LIBS.md b/kotlin-native/PLATFORM_LIBS.md index b62f59f2205..aef7fc223c9 100644 --- a/kotlin-native/PLATFORM_LIBS.md +++ b/kotlin-native/PLATFORM_LIBS.md @@ -1,61 +1,3 @@ # Platform libraries -## Overview - -To provide access to user's native operating system services, -`Kotlin/Native` distribution includes a set of prebuilt libraries specific to -each target. We call them **Platform Libraries**. - -### POSIX bindings - -For all `Unix` or `Windows` based targets (including `Android` and -`iOS`) we provide the `posix` platform lib. It contains bindings -to platform's implementation of `POSIX` standard. - -To use the library just - -
- -```kotlin -import platform.posix.* -``` - -
- -The only target for which it is not available is [WebAssembly](https://en.wikipedia.org/wiki/WebAssembly). - -Note that the content of `platform.posix` is NOT identical on -different platforms, in the same way as different `POSIX` implementations -are a little different. - - -### Popular native libraries - -There are many more platform libraries available for host and -cross-compilation targets. `Kotlin/Native` distribution provides access to -`OpenGL`, `zlib` and other popular native libraries on -applicable platforms. - -On Apple platforms `objc` library is provided for interoperability with [Objective-C](https://en.wikipedia.org/wiki/Objective-C). - -Inspect the contents of `dist/klib/platform/$target` of the distribution for the details. - -## Availability by default - -The packages from platform libraries are available by default. No -special link flags need to be specified to use them. `Kotlin/Native` -compiler automatically detects which of the platform libraries have -been accessed and automatically links the needed libraries. - -On the other hand, the platform libs in the distribution are merely -just wrappers and bindings to the native libraries. That means the -native libraries themselves (`.so`, `.a`, `.dylib`, `.dll` etc) -should be installed on the machine. - -## Examples - -`Kotlin/Native` installation provides a wide spectrum of examples -demonstrating the use of platform libraries. -See [samples](https://github.com/JetBrains/kotlin-native/tree/master/samples) for details. - - +The content of this page is moved to https://kotlinlang.org/docs/native-platform-libs.html \ No newline at end of file From ca953d3186c7dafd41d8c51529aac38041ac3a82 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Wed, 17 Feb 2021 12:30:41 +0500 Subject: [PATCH 356/368] [tests] Remove explicit NI switching on in tests It is on by default anyway, but specifying it explicitly turns on specific 'compatibility' mode in FE which is not needed in K/N --- .../src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kotlin-native/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy b/kotlin-native/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy index b8ccd2bd27e..d696fe700c4 100644 --- a/kotlin-native/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy +++ b/kotlin-native/build-tools/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy @@ -215,7 +215,10 @@ class RunExternalTestGroup extends JavaExec implements CompilerRunner { def languageSettings = findLinesWithPrefixesRemoved(text, "// !LANGUAGE: ") if (languageSettings.size() != 0) { languageSettings.forEach { line -> - line.split(" ").toList().forEach { flags.add("-XXLanguage:$it") } + line.split(" ").toList().forEach { + if (it != "+NewInference") // It is on already by default, but passing it explicitly turns on a special "compatibility mode" in FE which is not desirable. + flags.add("-XXLanguage:$it") + } } } From 764f7f31d251041dcaee3cee340fc16132377aff Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Wed, 17 Feb 2021 14:06:11 +0500 Subject: [PATCH 357/368] [IR] Erase non-trivial type projections off of super types This fixes https://youtrack.jetbrains.com/issue/KT-44826 --- .../konan/lower/FunctionReferenceLowering.kt | 20 ++++++++++++++++++- .../backend.native/tests/build.gradle | 4 ++++ .../nonTrivialProjectionInSuperType.kt | 17 ++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 kotlin-native/backend.native/tests/codegen/funInterface/nonTrivialProjectionInSuperType.kt diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionReferenceLowering.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionReferenceLowering.kt index bf9893cc4c5..43397307ce8 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionReferenceLowering.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/FunctionReferenceLowering.kt @@ -32,10 +32,13 @@ import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl import org.jetbrains.kotlin.ir.types.* +import org.jetbrains.kotlin.ir.types.impl.buildSimpleType +import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.types.Variance internal class FunctionReferenceLowering(val context: Context): FileLoweringPass { @@ -89,6 +92,21 @@ internal class FunctionReferenceLowering(val context: Context): FileLoweringPass return result } + // TODO: Move to common IR utils. + fun IrType.eraseProjections(): IrType { + if (this !is IrSimpleType) return this + return buildSimpleType { + this.classifier = this@eraseProjections.classifier + this.hasQuestionMark = this@eraseProjections.hasQuestionMark + this.annotations = this@eraseProjections.annotations + this.arguments = this@eraseProjections.arguments.map { + if (it !is IrTypeProjection) + it + else makeTypeProjection(it.type.eraseProjections(), Variance.INVARIANT) + } + } + } + // Handle SAM conversions which wrap a function reference: // class sam$n(private val receiver: R) : Interface { override fun method(...) = receiver.target(...) } // @@ -111,7 +129,7 @@ internal class FunctionReferenceLowering(val context: Context): FileLoweringPass return super.visitTypeOperator(expression) } reference.transformChildrenVoid() - return transformFunctionReference(reference, expression.typeOperand) + return transformFunctionReference(reference, expression.typeOperand.eraseProjections()) } return super.visitTypeOperator(expression) } diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index fb5363322d1..651e75282ce 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -2881,6 +2881,10 @@ task funInterface_implIsNotFunction(type: KonanLocalTest) { source = "codegen/funInterface/implIsNotFunction.kt" } +task funInterface_nonTrivialProjectionInSuperType(type: KonanLocalTest) { + source = "codegen/funInterface/nonTrivialProjectionInSuperType.kt" +} + task objectExpression1(type: KonanLocalTest) { goldValue = "aabb\n" source = "codegen/objectExpression/expr1.kt" diff --git a/kotlin-native/backend.native/tests/codegen/funInterface/nonTrivialProjectionInSuperType.kt b/kotlin-native/backend.native/tests/codegen/funInterface/nonTrivialProjectionInSuperType.kt new file mode 100644 index 00000000000..29b97a9874f --- /dev/null +++ b/kotlin-native/backend.native/tests/codegen/funInterface/nonTrivialProjectionInSuperType.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +package codegen.funInterface.nonTrivialProjectionInSuperType + +import kotlin.test.* + +fun foo(comparator: kotlin.Comparator, a: T, b: T) = comparator.compare(a, b) + +fun bar(x: Int, y: Int) = foo ({ a, b -> a - b}, x, y) + +@Test +fun test() { + assertTrue(bar(42, 117) < 0) +} \ No newline at end of file From 3f15774cb24c0877bd95a29c22808b3e122e6b2e Mon Sep 17 00:00:00 2001 From: Paul Idstein Date: Thu, 18 Feb 2021 07:25:28 +0100 Subject: [PATCH 358/368] Fix -Xoverride-konan-properties for Apple strip When building an optimised release dynamic framework we see a lot of local symbols in Mach-O. When calling `strip -x` this can be dramatically reduced whilst still having a usable artefact. Current logic seems to keep symbols for DSYM extraction in debug light mode. But only strips hardcoded debug symbols (`strip -S`) afterwards. Introduce new stripFlags for Apple compilation to allow optimization for release with DSYM builds --- kotlin-native/konan/konan.properties | 11 +++++++++++ .../jetbrains/kotlin/konan/target/Configurables.kt | 1 + .../org/jetbrains/kotlin/konan/target/Linker.kt | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/kotlin-native/konan/konan.properties b/kotlin-native/konan/konan.properties index 2404950378e..df30acde6fa 100644 --- a/kotlin-native/konan/konan.properties +++ b/kotlin-native/konan/konan.properties @@ -91,6 +91,7 @@ clangDebugFlags.macos_x64 = -O0 linkerKonanFlags.macos_x64 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 10.15.6 linkerOptimizationFlags.macos_x64 = -dead_strip linkerNoDebugFlags.macos_x64 = -S +stripFlags.macos_x64 = -S linkerDynamicFlags.macos_x64 = -dylib osVersionMinFlagLd.macos_x64 = -macosx_version_min @@ -127,6 +128,7 @@ clangDebugFlags.macos_arm64 = -O0 -mllvm -fast-isel=false -mllvm -global-isel=fa linkerKonanFlags.macos_arm64 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 11.0.1 linkerOptimizationFlags.macos_arm64 = -dead_strip linkerNoDebugFlags.macos_arm64 = -S +stripFlags.macos_arm64 = -S linkerDynamicFlags.macos_arm64 = -dylib osVersionMinFlagLd.macos_arm64 = -macosx_version_min @@ -157,6 +159,7 @@ clangNooptFlags.ios_arm32 = -O1 clangOptFlags.ios_arm32 = -O3 clangDebugFlags.ios_arm32 = -O0 linkerNoDebugFlags.ios_arm32 = -S +stripFlags.ios_arm32 = -S linkerDynamicFlags.ios_arm32 = -dylib linkerKonanFlags.ios_arm32 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 14.0 linkerOptimizationFlags.ios_arm32 = -dead_strip @@ -192,6 +195,7 @@ clangOptFlags.ios_arm64 = -O3 clangDebugFlags.ios_arm64 = -O0 -mllvm -fast-isel=false -mllvm -global-isel=false linkerNoDebugFlags.ios_arm64 = -S +stripFlags.ios_arm64 = -S linkerDynamicFlags.ios_arm64 = -dylib linkerKonanFlags.ios_arm64 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 14.0 linkerOptimizationFlags.ios_arm64 = -dead_strip @@ -221,6 +225,7 @@ clangDebugFlags.ios_x64 = -O0 linkerKonanFlags.ios_x64 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 14.0 linkerOptimizationFlags.ios_x64 = -dead_strip linkerNoDebugFlags.ios_x64 = -S +stripFlags.ios_x64 = -S linkerDynamicFlags.ios_x64 = -dylib osVersionMinFlagLd.ios_x64 = -ios_simulator_version_min osVersionMinFlagClang.ios_x64 = -mios-simulator-version-min @@ -247,6 +252,7 @@ clangDebugFlags.tvos_x64 = -O0 linkerKonanFlags.tvos_x64 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 14.0 linkerOptimizationFlags.tvos_x64 = -dead_strip linkerNoDebugFlags.tvos_x64 = -S +stripFlags.tvos_x64 = -S linkerDynamicFlags.tvos_x64 = -dylib osVersionMinFlagLd.tvos_x64 = -tvos_simulator_version_min osVersionMinFlagClang.tvos_x64 = -mtvos-simulator-version-min @@ -271,6 +277,7 @@ clangOptFlags.tvos_arm64 = -O3 clangDebugFlags.tvos_arm64 = -O0 -mllvm -fast-isel=false -mllvm -global-isel=false linkerNoDebugFlags.tvos_arm64 = -S +stripFlags.tvos_arm64 = -S linkerDynamicFlags.tvos_arm64 = -dylib linkerKonanFlags.tvos_arm64 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 14.0 linkerOptimizationFlags.tvos_arm64 = -dead_strip @@ -299,6 +306,7 @@ clangDebugFlags.watchos_arm32 = -O0 linkerKonanFlags.watchos_arm32 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 7.0 linkerOptimizationFlags.watchos_arm32 = -dead_strip linkerNoDebugFlags.watchos_arm32 = -S +stripFlags.watchos_arm32 = -S linkerDynamicFlags.watchos_arm32 = -dylib osVersionMinFlagLd.watchos_arm32 = -watchos_version_min osVersionMinFlagClang.watchos_arm32 = -mwatchos-version-min @@ -328,6 +336,7 @@ clangDebugFlags.watchos_arm64 = -O0 linkerKonanFlags.watchos_arm64 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 7.0 linkerOptimizationFlags.watchos_arm64 = -dead_strip linkerNoDebugFlags.watchos_arm64 = -S +stripFlags.watchos_arm64 = -S linkerDynamicFlags.watchos_arm64 = -dylib osVersionMinFlagLd.watchos_arm64 = -watchos_version_min osVersionMinFlagClang.watchos_arm64 = -mwatchos-version-min @@ -360,6 +369,7 @@ clangDebugFlags.watchos_x86 = -O0 linkerKonanFlags.watchos_x86 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 7.0 linkerOptimizationFlags.watchos_x86 = -dead_strip linkerNoDebugFlags.watchos_x86 = -S +stripFlags.watchos_x86 = -S linkerDynamicFlags.watchos_x86 = -dylib osVersionMinFlagLd.watchos_x86 = -watchos_simulator_version_min osVersionMinFlagClang.watchos_x86 = -mwatchos-simulator-version-min @@ -386,6 +396,7 @@ clangDebugFlags.watchos_x64 = -O0 linkerKonanFlags.watchos_x64 = -lSystem -lc++ -lobjc -framework Foundation -sdk_version 7.0 linkerOptimizationFlags.watchos_x64 = -dead_strip linkerNoDebugFlags.watchos_x64 = -S +stripFlags.watchos_x64 = -S linkerDynamicFlags.watchos_x64 = -dylib osVersionMinFlagLd.watchos_x64 = -watchos_simulator_version_min osVersionMinFlagClang.watchos_x64 = -mwatchos-simulator-version-min diff --git a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Configurables.kt b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Configurables.kt index e09b05d8c2f..e4e30d7e151 100644 --- a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Configurables.kt +++ b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Configurables.kt @@ -98,6 +98,7 @@ interface AppleConfigurables : Configurables, ClangFlags { val arch get() = targetString("arch")!! val osVersionMin get() = targetString("osVersionMin")!! val osVersionMinFlagLd get() = targetString("osVersionMinFlagLd")!! + val stripFlags get() = targetList("stripFlags") val additionalToolsDir get() = hostString("additionalToolsDir") val absoluteAdditionalToolsDir get() = absolute(additionalToolsDir) } diff --git a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt index 81c0fc403c8..c72f97787f5 100644 --- a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt +++ b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt @@ -265,7 +265,7 @@ class MacOSBasedLinker(targetProperties: AppleConfigurables) if (debug) { result += dsymUtilCommand(executable, outputDsymBundle) if (optimize) { - result += Command(strip, "-S", executable) + result += Command(strip, *stripFlags.toTypedArray(), executable) } } From bea8edb10c7dfcca156b0fe69c08eb8dba2b202e Mon Sep 17 00:00:00 2001 From: SvyatoslavScherbina Date: Thu, 18 Feb 2021 21:24:45 +0300 Subject: [PATCH 359/368] Return old behaviour for cinterop -output argument suffix handling (accidentally changed in 976a9fc1) #KT-44824 Fixed. --- .../jetbrains/kotlin/native/interop/gen/jvm/main.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt b/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt index 8f4987ee357..50cb0a40af2 100644 --- a/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt +++ b/kotlin-native/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt @@ -40,6 +40,7 @@ import org.jetbrains.kotlin.library.resolver.impl.KotlinLibraryResolverImpl import org.jetbrains.kotlin.library.resolver.impl.libraryResolver import org.jetbrains.kotlin.library.toUnresolvedLibraries import org.jetbrains.kotlin.util.removeSuffixIfPresent +import org.jetbrains.kotlin.util.suffixIfNot import java.io.File import java.lang.IllegalArgumentException import java.nio.file.* @@ -376,15 +377,22 @@ private fun processCLib(flavor: KotlinPlatform, cinteropArguments: CInteropArgum noDefaultLibs = true, noEndorsedLibs = true ).getFullList() + + val nopack = cinteropArguments.nopack + val outputPath = cinteropArguments.output.let { + val suffix = CompilerOutputKind.LIBRARY.suffix(tool.target) + if (nopack) it.removeSuffixIfPresent(suffix) else it.suffixIfNot(suffix) + } + createInteropLibrary( metadata = stubIrOutput.metadata, nativeBitcodeFiles = compiledFiles + nativeOutputPath, target = tool.target, moduleName = moduleName, - outputPath = cinteropArguments.output, + outputPath = outputPath, manifest = def.manifestAddendProperties, dependencies = stdlibDependency + imports.requiredLibraries.toList(), - nopack = cinteropArguments.nopack, + nopack = nopack, shortName = cinteropArguments.shortModuleName, staticLibraries = resolveLibraries(staticLibraries, libraryPaths) ) From dc2d01450443126a746fbb845aaa5e96f09ed314 Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Wed, 17 Feb 2021 17:35:30 +0300 Subject: [PATCH 360/368] Add some tests for CPointer.toKStringFromUtf8 --- kotlin-native/backend.native/tests/build.gradle | 10 ++++++++++ .../tests/interop/basics/ctoKString.def | 6 ++++++ .../backend.native/tests/interop/basics/toKString.kt | 12 ++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 kotlin-native/backend.native/tests/interop/basics/ctoKString.def create mode 100644 kotlin-native/backend.native/tests/interop/basics/toKString.kt diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 651e75282ce..42d5c0c2ba2 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -3805,6 +3805,10 @@ createInterop("cunsupported") { it.defFile 'interop/basics/cunsupported.def' } +createInterop("ctoKString") { + it.defFile 'interop/basics/ctoKString.def' +} + createInterop("ctypes") { it.defFile 'interop/basics/ctypes.def' } @@ -4119,6 +4123,12 @@ interopTest("interop_unsupported") { interop = 'cunsupported' } +interopTest("interop_toKString") { + disabled = (project.testTarget == 'wasm32') // No interop for wasm yet. + source = "interop/basics/toKString.kt" + interop = 'ctoKString' +} + interopTest("interop_types") { disabled = (project.testTarget == 'wasm32') // No interop for wasm yet. source = "interop/basics/types.kt" diff --git a/kotlin-native/backend.native/tests/interop/basics/ctoKString.def b/kotlin-native/backend.native/tests/interop/basics/ctoKString.def new file mode 100644 index 00000000000..b644795ed8e --- /dev/null +++ b/kotlin-native/backend.native/tests/interop/basics/ctoKString.def @@ -0,0 +1,6 @@ +--- +const char* empty() { return ""; } +const char* foo() { return "foo"; } +const char* kuku() { return "куку"; } +const char* invalid_utf8() { return "\x85\xAF"; } +const char* zero_in_the_middle() { return "before zero\0after zero"; } diff --git a/kotlin-native/backend.native/tests/interop/basics/toKString.kt b/kotlin-native/backend.native/tests/interop/basics/toKString.kt new file mode 100644 index 00000000000..69a49b763e6 --- /dev/null +++ b/kotlin-native/backend.native/tests/interop/basics/toKString.kt @@ -0,0 +1,12 @@ +import ctoKString.* +import kotlinx.cinterop.* +import kotlin.native.* +import kotlin.test.* + +fun main() { + assertEquals("", empty()!!.toKStringFromUtf8()) + assertEquals("foo", foo()!!.toKStringFromUtf8()) + assertEquals("куку", kuku()!!.toKStringFromUtf8()) + assertEquals("\uFFFD\uFFFD", invalid_utf8()!!.toKStringFromUtf8()) + assertEquals("before zero", zero_in_the_middle()!!.toKStringFromUtf8()) +} From f766a3eae44edc78026141228783b6b07cb73fa6 Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Tue, 16 Feb 2021 19:03:18 +0300 Subject: [PATCH 361/368] Optimize CPointer.toKStringFromUtf8 on Native Use strlen and stop allocating intermediate ByteArray to make the performance comparable to ByteArray.decodeToString(). Partially fix KT-44357. --- .../src/jvm/kotlin/kotlinx/cinterop/JvmUtils.kt | 15 ++++++++++++++- .../src/main/kotlin/kotlinx/cinterop/Utils.kt | 13 +------------ .../native/kotlin/kotlinx/cinterop/NativeUtils.kt | 4 +++- kotlin-native/runtime/src/main/cpp/Interop.cpp | 6 ++++++ kotlin-native/runtime/src/main/cpp/KString.cpp | 7 +++++++ kotlin-native/runtime/src/main/cpp/KString.h | 2 ++ 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/kotlin-native/Interop/Runtime/src/jvm/kotlin/kotlinx/cinterop/JvmUtils.kt b/kotlin-native/Interop/Runtime/src/jvm/kotlin/kotlinx/cinterop/JvmUtils.kt index f99ac1fb915..e9bc4b35316 100644 --- a/kotlin-native/Interop/Runtime/src/jvm/kotlin/kotlinx/cinterop/JvmUtils.kt +++ b/kotlin-native/Interop/Runtime/src/jvm/kotlin/kotlinx/cinterop/JvmUtils.kt @@ -21,9 +21,22 @@ import java.io.File import java.nio.file.Files import java.nio.file.Paths -internal fun decodeFromUtf8(bytes: ByteArray) = String(bytes) +private fun decodeFromUtf8(bytes: ByteArray) = String(bytes) internal fun encodeToUtf8(str: String) = str.toByteArray() +internal fun CPointer.toKStringFromUtf8Impl(): String { + val nativeBytes = this + + var length = 0 + while (nativeBytes[length] != 0.toByte()) { + ++length + } + + val bytes = ByteArray(length) + nativeMemUtils.getByteArray(nativeBytes.pointed, bytes, length) + return decodeFromUtf8(bytes) +} + fun bitsToFloat(bits: Int): Float = java.lang.Float.intBitsToFloat(bits) fun bitsToDouble(bits: Long): Double = java.lang.Double.longBitsToDouble(bits) diff --git a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt index a4e83f74b40..0f74241fe7e 100644 --- a/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt +++ b/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt @@ -507,18 +507,7 @@ public val String.utf32: CValues /** * @return the [kotlin.String] decoded from given zero-terminated UTF-8-encoded C string. */ -public fun CPointer.toKStringFromUtf8(): String { - val nativeBytes = this - - var length = 0 - while (nativeBytes[length] != 0.toByte()) { - ++length - } - - val bytes = ByteArray(length) - nativeMemUtils.getByteArray(nativeBytes.pointed, bytes, length) - return decodeFromUtf8(bytes) -} +public fun CPointer.toKStringFromUtf8(): String = this.toKStringFromUtf8Impl() /** * @return the [kotlin.String] decoded from given zero-terminated UTF-8-encoded C string. diff --git a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeUtils.kt b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeUtils.kt index 846bd3650f4..ccf17aca9e6 100644 --- a/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeUtils.kt +++ b/kotlin-native/Interop/Runtime/src/native/kotlin/kotlinx/cinterop/NativeUtils.kt @@ -20,9 +20,11 @@ import kotlin.native.internal.Intrinsic import kotlin.native.internal.TypedIntrinsic import kotlin.native.internal.IntrinsicType -internal fun decodeFromUtf8(bytes: ByteArray): String = bytes.decodeToString() internal fun encodeToUtf8(str: String): ByteArray = str.encodeToByteArray() +@SymbolName("Kotlin_CString_toKStringFromUtf8Impl") +internal external fun CPointer.toKStringFromUtf8Impl(): String + @TypedIntrinsic(IntrinsicType.INTEROP_BITS_TO_FLOAT) external fun bitsToFloat(bits: Int): Float diff --git a/kotlin-native/runtime/src/main/cpp/Interop.cpp b/kotlin-native/runtime/src/main/cpp/Interop.cpp index 4b6c2909110..e37f1931f1d 100644 --- a/kotlin-native/runtime/src/main/cpp/Interop.cpp +++ b/kotlin-native/runtime/src/main/cpp/Interop.cpp @@ -17,8 +17,10 @@ #include #include #include +#include #include "Alloc.h" +#include "KString.h" #include "Memory.h" #include "MemorySharedRefs.hpp" #include "Types.h" @@ -42,4 +44,8 @@ OBJ_GETTER(Kotlin_Interop_derefStablePointer, KNativePtr pointer) { RETURN_OBJ(holder->ref()); } +OBJ_GETTER(Kotlin_CString_toKStringFromUtf8Impl, const char* cstring) { + RETURN_RESULT_OF(StringFromUtf8Buffer, cstring, strlen(cstring)); +} + } diff --git a/kotlin-native/runtime/src/main/cpp/KString.cpp b/kotlin-native/runtime/src/main/cpp/KString.cpp index 63b37549675..f9579a50720 100644 --- a/kotlin-native/runtime/src/main/cpp/KString.cpp +++ b/kotlin-native/runtime/src/main/cpp/KString.cpp @@ -511,6 +511,13 @@ OBJ_GETTER(Kotlin_ByteArray_unsafeStringFromUtf8, KConstRef thiz, KInt start, KI RETURN_RESULT_OF(utf8ToUtf16, rawString, size); } +OBJ_GETTER(StringFromUtf8Buffer, const char* start, size_t size) { + if (size == 0) { + RETURN_RESULT_OF0(TheEmptyString); + } + RETURN_RESULT_OF(utf8ToUtf16, start, size); +} + OBJ_GETTER(Kotlin_String_unsafeStringToUtf8, KString thiz, KInt start, KInt size) { RETURN_RESULT_OF(unsafeUtf16ToUtf8Impl, thiz, start, size); } diff --git a/kotlin-native/runtime/src/main/cpp/KString.h b/kotlin-native/runtime/src/main/cpp/KString.h index eaf8139ae6f..e970d449af1 100644 --- a/kotlin-native/runtime/src/main/cpp/KString.h +++ b/kotlin-native/runtime/src/main/cpp/KString.h @@ -31,6 +31,8 @@ OBJ_GETTER(CreateStringFromUtf8, const char* utf8, uint32_t lengthBytes); char* CreateCStringFromString(KConstRef kstring); void DisposeCString(char* cstring); +OBJ_GETTER(StringFromUtf8Buffer, const char* start, size_t size); + #ifdef __cplusplus } #endif From 276b4f19fa19d6d4c75e210b7943e7027dbb1d7e Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Fri, 19 Feb 2021 17:34:06 +0300 Subject: [PATCH 362/368] Split generateFunction into different categories (#4712) --- .../backend/konan/llvm/CodeGenerator.kt | 35 +++++++++++++++++++ .../kotlin/backend/konan/llvm/IrToBitcode.kt | 28 ++++----------- .../llvm/KotlinObjCClassInfoGenerator.kt | 2 +- .../objcexport/ObjCExportCodeGenerator.kt | 6 ++-- 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt index 48ca2a89b60..097d7731e33 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt @@ -150,6 +150,41 @@ internal inline fun generateFunction( return function } +// TODO: Consider using different abstraction than `FunctionGenerationContext` for `generateFunctionNoRuntime`. +internal inline fun generateFunctionNoRuntime( + codegen: CodeGenerator, + function: LLVMValueRef, + code: FunctionGenerationContext.(FunctionGenerationContext) -> R, +) { + val functionGenerationContext = FunctionGenerationContext(function, codegen, null, null) + try { + functionGenerationContext.forbidRuntime = true + require(!functionGenerationContext.isObjectType(functionGenerationContext.returnType!!)) { + "Cannot return object from function without Kotlin runtime" + } + + generateFunctionBody(functionGenerationContext, code) + } finally { + functionGenerationContext.dispose() + } +} + +internal inline fun generateFunctionNoRuntime( + codegen: CodeGenerator, + functionType: LLVMTypeRef, + name: String, + code: FunctionGenerationContext.(FunctionGenerationContext) -> Unit, +): LLVMValueRef { + val function = addLlvmFunctionWithDefaultAttributes( + codegen.context, + codegen.context.llvmModule!!, + name, + functionType + ) + generateFunctionNoRuntime(codegen, function, code) + return function +} + private inline fun generateFunctionBody( functionGenerationContext: FunctionGenerationContext, code: FunctionGenerationContext.(FunctionGenerationContext) -> R) { diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index d2796f57542..d69ad7e3310 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -505,18 +505,11 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map) { - generateFunction(codegen, ctorFunction) { - forbidRuntime = true + generateFunctionNoRuntime(codegen, ctorFunction) { val initGuardName = ctorFunction.name.orEmpty() + "_guard" val initGuard = LLVMAddGlobal(context.llvmModule, int32Type, initGuardName) LLVMSetInitializer(initGuard, kImmZero) @@ -2553,21 +2544,14 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map) { if (context.config.produce.isFinalBinary) { // Generate function calling all [ctorFunctions]. - val globalCtorFunction = addLlvmFunctionWithDefaultAttributes( - context, - context.llvmModule!!, - "_Konan_constructors", - kVoidFuncType - ) - LLVMSetLinkage(globalCtorFunction, LLVMLinkage.LLVMPrivateLinkage) - generateFunction(codegen, globalCtorFunction) { - forbidRuntime = true + val globalCtorFunction = generateFunctionNoRuntime(codegen, kVoidFuncType, "_Konan_constructors") { ctorFunctions.forEach { call(it, emptyList(), Lifetime.IRRELEVANT, exceptionHandler = ExceptionHandler.Caller, verbatim = true) } ret(null) } + LLVMSetLinkage(globalCtorFunction, LLVMLinkage.LLVMPrivateLinkage) // Append initializers of global variables in "llvm.global_ctors" array. val globalCtors = context.llvm.staticData.placeGlobalArray("llvm.global_ctors", kCtorType, diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/KotlinObjCClassInfoGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/KotlinObjCClassInfoGenerator.kt index 12d417dfb94..51c3662eae4 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/KotlinObjCClassInfoGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/KotlinObjCClassInfoGenerator.kt @@ -142,7 +142,7 @@ internal class KotlinObjCClassInfoGenerator(override val context: Context) : Con val functionType = functionType(classDataPointer.llvmType, false, int8TypePtr, int8TypePtr) val functionName = "kobjcclassdataimp:${irClass.fqNameForIrSerialization}#internal" - val function = generateFunction(codegen, functionType, functionName) { + val function = generateFunctionNoRuntime(codegen, functionType, functionName) { ret(classDataPointer.llvm) }.also { LLVMSetLinkage(it, LLVMLinkage.LLVMPrivateLinkage) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt index 88434f9e2c4..2d8a8caba37 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt @@ -29,7 +29,6 @@ import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.* -import org.jetbrains.kotlin.konan.target.Family import org.jetbrains.kotlin.konan.target.KonanTarget import org.jetbrains.kotlin.konan.target.LinkerOutputKind import org.jetbrains.kotlin.name.Name @@ -353,8 +352,7 @@ internal class ObjCExportCodeGenerator( private fun emitStaticInitializers() { if (externalGlobalInitializers.isEmpty()) return - val initializer = generateFunction(codegen, functionType(voidType, false), "initObjCExportGlobals") { - forbidRuntime = true + val initializer = generateFunctionNoRuntime(codegen, functionType(voidType, false), "initObjCExportGlobals") { externalGlobalInitializers.forEach { (global, value) -> store(value.llvm, global) } @@ -405,7 +403,7 @@ internal class ObjCExportCodeGenerator( private fun emitSelectorsHolder() { val impType = functionType(voidType, false, int8TypePtr, int8TypePtr) - val imp = generateFunction(codegen, impType, "") { + val imp = generateFunctionNoRuntime(codegen, impType, "") { unreachable() } From 114f5ae8907fe5c60bddadca254225769adac4d7 Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Fri, 19 Feb 2021 20:53:34 +0700 Subject: [PATCH 363/368] Remove .git directory when downloading googletest sources Keeping the .git folder in the googletest directory may cause changing .idea/vcs.xml during IDEA import. .idea/vcs.xml is under source control, thus changing it litters a current diff. --- kotlin-native/.idea/vcs.xml | 20 +++++++++++++++++++ .../kotlin/testing/native/GitDownloadTask.kt | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 kotlin-native/.idea/vcs.xml diff --git a/kotlin-native/.idea/vcs.xml b/kotlin-native/.idea/vcs.xml new file mode 100644 index 00000000000..abcc2585c24 --- /dev/null +++ b/kotlin-native/.idea/vcs.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/GitDownloadTask.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/GitDownloadTask.kt index b576a08e5d4..2fd3507a361 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/GitDownloadTask.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/GitDownloadTask.kt @@ -103,6 +103,9 @@ open class GitDownloadTask @Inject constructor( // Store info about used revision for the manual up-to-date check. upToDateChecker.storeRevisionInfo() + + // Delete the .git directory of the cloned repo to avoid adding it to IDEA's VCS roots. + outputDirectory.resolve(".git").deleteRecursively() } From a38e64a7c85180fe456e73447d071efe603a1242 Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Sat, 20 Feb 2021 16:33:08 +0300 Subject: [PATCH 364/368] Update runtimeDefinitions after toolchain upgrade (#4714) --- kotlin-native/konan/konan.properties | 36 +++++++++---------- .../runtime/src/main/cpp/Exceptions.cpp | 8 ++--- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/kotlin-native/konan/konan.properties b/kotlin-native/konan/konan.properties index df30acde6fa..b7954475309 100644 --- a/kotlin-native/konan/konan.properties +++ b/kotlin-native/konan/konan.properties @@ -98,7 +98,7 @@ osVersionMinFlagLd.macos_x64 = -macosx_version_min osVersionMinFlagClang.macos_x64 = -mmacosx-version-min osVersionMin.macos_x64 = 10.11 runtimeDefinitions.macos_x64 = KONAN_OSX=1 KONAN_MACOSX=1 KONAN_X64=1 KONAN_OBJC_INTEROP=1 \ - KONAN_CORE_SYMBOLICATION=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + KONAN_CORE_SYMBOLICATION=1 dependencies.macos_x64 = \ libffi-3.2.1-3-darwin-macos \ lldb-3-macos @@ -135,7 +135,7 @@ osVersionMinFlagLd.macos_arm64 = -macosx_version_min osVersionMinFlagClang.macos_arm64 = -mmacosx-version-min osVersionMin.macos_arm64 = 11.0 runtimeDefinitions.macos_arm64 = KONAN_OSX=1 KONAN_MACOSX=1 KONAN_ARM64=1 KONAN_OBJC_INTEROP=1 \ - KONAN_CORE_SYMBOLICATION=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + KONAN_CORE_SYMBOLICATION=1 dependencies.macos_x64-macos_arm64 = \ libffi-3.2.1-3-darwin-macos @@ -172,7 +172,7 @@ osVersionMin.ios_arm32 = 9.0 # https://developer.apple.com/library/archive/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARMv6FunctionCallingConventions.html#//apple_ref/doc/uid/TP40009021-SW1 # See https://github.com/ktorio/ktor/issues/941 for the context. runtimeDefinitions.ios_arm32 = KONAN_OBJC_INTEROP=1 KONAN_IOS KONAN_ARM32=1 \ - KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 KONAN_REPORT_BACKTRACE_TO_IOS_CRASH_LOG=1 MACHSIZE=32 \ + KONAN_REPORT_BACKTRACE_TO_IOS_CRASH_LOG=1 MACHSIZE=32 \ KONAN_NO_64BIT_ATOMIC=1 KONAN_NO_UNALIGNED_ACCESS=1 # Apple's 64-bit iOS. @@ -203,7 +203,7 @@ osVersionMinFlagLd.ios_arm64 = -iphoneos_version_min osVersionMinFlagClang.ios_arm64 = -miphoneos-version-min osVersionMin.ios_arm64 = 9.0 runtimeDefinitions.ios_arm64 = KONAN_OBJC_INTEROP=1 KONAN_IOS=1 KONAN_ARM64=1 \ - KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 KONAN_REPORT_BACKTRACE_TO_IOS_CRASH_LOG=1 MACHSIZE=64 + KONAN_REPORT_BACKTRACE_TO_IOS_CRASH_LOG=1 MACHSIZE=64 additionalCacheFlags.ios_arm64 = -Xembed-bitcode-marker # Apple's iOS simulator. @@ -231,7 +231,7 @@ osVersionMinFlagLd.ios_x64 = -ios_simulator_version_min osVersionMinFlagClang.ios_x64 = -mios-simulator-version-min osVersionMin.ios_x64 = 9.0 runtimeDefinitions.ios_x64 = KONAN_OBJC_INTEROP=1 KONAN_IOS=1 KONAN_X64=1 \ - KONAN_CORE_SYMBOLICATION=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + KONAN_CORE_SYMBOLICATION=1 # Apple's tvOS simulator. targetToolchain.macos_x64-tvos_x64 = target-toolchain-xcode_12_2-macos_x64 @@ -258,7 +258,7 @@ osVersionMinFlagLd.tvos_x64 = -tvos_simulator_version_min osVersionMinFlagClang.tvos_x64 = -mtvos-simulator-version-min osVersionMin.tvos_x64 = 9.0 runtimeDefinitions.tvos_x64 = KONAN_OBJC_INTEROP=1 KONAN_TVOS=1 KONAN_X64=1 \ - KONAN_CORE_SYMBOLICATION=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + KONAN_CORE_SYMBOLICATION=1 # Apple's 64-bit tvOS. targetToolchain.macos_x64-tvos_arm64 = target-toolchain-xcode_12_2-macos_x64 @@ -285,7 +285,7 @@ osVersionMinFlagLd.tvos_arm64 = -tvos_version_min osVersionMinFlagClang.tvos_arm64 = -mtvos-version-min osVersionMin.tvos_arm64 = 9.0 runtimeDefinitions.tvos_arm64 = KONAN_OBJC_INTEROP=1 KONAN_TVOS=1 KONAN_ARM64=1 \ - KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 KONAN_REPORT_BACKTRACE_TO_IOS_CRASH_LOG=1 MACHSIZE=64 + KONAN_REPORT_BACKTRACE_TO_IOS_CRASH_LOG=1 MACHSIZE=64 # watchOS armv7k targetToolchain.macos_x64-watchos_arm32 = target-toolchain-xcode_12_2-macos_x64 @@ -313,7 +313,7 @@ osVersionMinFlagClang.watchos_arm32 = -mwatchos-version-min osVersionMin.watchos_arm32 = 5.0 # Regarding KONAN_NO_64BIT_ATOMIC=1: see explanation for ios_arm32 above. runtimeDefinitions.watchos_arm32 = KONAN_OBJC_INTEROP=1 KONAN_WATCHOS KONAN_ARM32=1 \ - KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 KONAN_REPORT_BACKTRACE_TO_IOS_CRASH_LOG=1 \ + KONAN_REPORT_BACKTRACE_TO_IOS_CRASH_LOG=1 \ MACHSIZE=32 KONAN_NO_64BIT_ATOMIC=1 KONAN_NO_UNALIGNED_ACCESS=1 # watchOS arm64_32 @@ -343,7 +343,7 @@ osVersionMinFlagClang.watchos_arm64 = -mwatchos-version-min osVersionMin.watchos_arm64 = 5.0 # Regarding KONAN_NO_64BIT_ATOMIC=1: see explanation for ios_arm32 above. runtimeDefinitions.watchos_arm64 = KONAN_OBJC_INTEROP=1 KONAN_WATCHOS KONAN_ARM32=1 \ - KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 KONAN_REPORT_BACKTRACE_TO_IOS_CRASH_LOG=1 \ + KONAN_REPORT_BACKTRACE_TO_IOS_CRASH_LOG=1 \ MACHSIZE=32 KONAN_NO_64BIT_ATOMIC=1 KONAN_NO_UNALIGNED_ACCESS=1 # Apple's watchOS i386 simulator. @@ -375,7 +375,7 @@ osVersionMinFlagLd.watchos_x86 = -watchos_simulator_version_min osVersionMinFlagClang.watchos_x86 = -mwatchos-simulator-version-min osVersionMin.watchos_x86 = 5.0 runtimeDefinitions.watchos_x86 = KONAN_OBJC_INTEROP=1 KONAN_WATCHOS=1 KONAN_NO_64BIT_ATOMIC=1 \ - KONAN_X86=1 KONAN_CORE_SYMBOLICATION=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + KONAN_X86=1 KONAN_CORE_SYMBOLICATION=1 # watchOS x86_64 simulator. targetToolchain.macos_x64-watchos_x64 = target-toolchain-xcode_12_2-macos_x64 @@ -402,7 +402,7 @@ osVersionMinFlagLd.watchos_x64 = -watchos_simulator_version_min osVersionMinFlagClang.watchos_x64 = -mwatchos-simulator-version-min osVersionMin.watchos_x64 = 7.0 runtimeDefinitions.watchos_x64 = KONAN_OBJC_INTEROP=1 KONAN_WATCHOS=1 \ - KONAN_X64=1 KONAN_CORE_SYMBOLICATION=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + KONAN_X64=1 KONAN_CORE_SYMBOLICATION=1 # Linux x86-64. llvmHome.linux_x64 = $llvm.linux_x64.dev @@ -456,7 +456,7 @@ abiSpecificLibraries.linux_x64 = lib usr/lib ../lib64 lib64 usr/lib64 # targetSysRoot relative crtFilesLocation.linux_x64 = usr/lib runtimeDefinitions.linux_x64 = USE_GCC_UNWIND=1 KONAN_LINUX=1 KONAN_X64=1 \ - USE_ELF_SYMBOLS=1 ELFSIZE=64 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + USE_ELF_SYMBOLS=1 ELFSIZE=64 # Raspberry Pi gccToolchain.linux_arm32_hfp = arm-unknown-linux-gnueabihf-gcc-8.3.0-glibc-2.19-kernel-4.9 @@ -700,7 +700,7 @@ targetSysRoot.android_arm64 = target-sysroot-1-android_ndk linkerKonanFlags.android_arm64 = -lm -lc++_static -lc++abi -landroid -llog -latomic linkerNoDebugFlags.android_arm64 = -Wl,-S runtimeDefinitions.android_arm64 = __ANDROID__ USE_GCC_UNWIND=1 USE_ELF_SYMBOLS=1 \ - ELFSIZE=64 KONAN_ANDROID=1 KONAN_ARM64=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + ELFSIZE=64 KONAN_ANDROID=1 KONAN_ARM64=1 # Android X86, based on NDK. targetToolchain.macos_x64-android_x86 = target-toolchain-2-osx-android_ndk @@ -732,7 +732,7 @@ targetSysRoot.android_x86 = target-sysroot-1-android_ndk linkerKonanFlags.android_x86 = -lm -lc++_static -lc++abi -landroid -llog -latomic linkerNoDebugFlags.android_x86 = -Wl,-S runtimeDefinitions.android_x86 = __ANDROID__ USE_GCC_UNWIND=1 USE_ELF_SYMBOLS=1 \ - ELFSIZE=32 KONAN_ANDROID=1 KONAN_X86=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + ELFSIZE=32 KONAN_ANDROID=1 KONAN_X86=1 # Android X64, based on NDK. targetToolchain.macos_x64-android_x64 = target-toolchain-2-osx-android_ndk @@ -760,7 +760,7 @@ targetSysRoot.android_x64 = target-sysroot-1-android_ndk linkerKonanFlags.android_x64 = -lm -lc++_static -lc++abi -landroid -llog -latomic linkerNoDebugFlags.android_x64 = -Wl,-S runtimeDefinitions.android_x64 = __ANDROID__ USE_GCC_UNWIND=1 USE_ELF_SYMBOLS=1 \ - ELFSIZE=64 KONAN_ANDROID=1 KONAN_X64=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + ELFSIZE=64 KONAN_ANDROID=1 KONAN_X64=1 # Windows x86-64, based on mingw-w64. llvmHome.mingw_x64 = $llvm.mingw_x64.dev @@ -796,7 +796,7 @@ linkerKonanFlags.mingw_x64 =-static-libgcc -static-libstdc++ \ linkerOptimizationFlags.mingw_x64 = -Wl,--gc-sections mimallocLinkerDependencies.mingw_x64 = -lbcrypt runtimeDefinitions.mingw_x64 = USE_GCC_UNWIND=1 USE_PE_COFF_SYMBOLS=1 KONAN_WINDOWS=1 \ - UNICODE KONAN_X64=1 KONAN_NO_MEMMEM=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + UNICODE KONAN_X64=1 KONAN_NO_MEMMEM=1 # Windows i686, based on mingw-w64. targetToolchain.mingw_x64-mingw_x86 = msys2-mingw-w64-i686-clang-llvm-lld-compiler_rt-8.0.1 @@ -834,7 +834,7 @@ linkerKonanFlags.mingw_x86 = -static-libgcc -static-libstdc++ \ mimallocLinkerDependencies.mingw_x86 = -lbcrypt linkerOptimizationFlags.mingw_x86 = -Wl,--gc-sections runtimeDefinitions.mingw_x86 = USE_GCC_UNWIND=1 USE_PE_COFF_SYMBOLS=1 KONAN_WINDOWS=1 \ - UNICODE KONAN_X86=1 KONAN_NO_MEMMEM=1 KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS=1 + UNICODE KONAN_X86=1 KONAN_NO_MEMMEM=1 # WebAssembly 32-bit. targetToolchain.macos_x64-wasm32 = target-toolchain-3-macos-wasm @@ -869,4 +869,4 @@ runtimeDefinitions.wasm32 = KONAN_WASM=1 KONAN_NO_FFI=1 KONAN_NO_THREADS=1 \ KONAN_INTERNAL_NOW=1 KONAN_NO_MEMMEM KONAN_NO_CTORS_SECTION=1 # The version of Kotlin/Native compiler -compilerVersion=1.5-dev \ No newline at end of file +compilerVersion=1.5-dev diff --git a/kotlin-native/runtime/src/main/cpp/Exceptions.cpp b/kotlin-native/runtime/src/main/cpp/Exceptions.cpp index a4cf68769d5..596018f1b3c 100644 --- a/kotlin-native/runtime/src/main/cpp/Exceptions.cpp +++ b/kotlin-native/runtime/src/main/cpp/Exceptions.cpp @@ -252,9 +252,7 @@ RUNTIME_NORETURN void TerminateWithUnhandledException(KRef throwable) { }); } -// Some libstdc++-based targets has limited support for std::current_exception and other C++11 functions. -// This restriction can be lifted later when toolchains will be updated. -#if KONAN_HAS_CXX11_EXCEPTION_FUNCTIONS +#if !KONAN_NO_EXCEPTIONS namespace { // Copy, move and assign would be safe, but not much useful, so let's delete all (rule of 5) @@ -308,13 +306,13 @@ void SetKonanTerminateHandler() { TerminateHandler::install(); } -#else // KONAN_OBJC_INTEROP +#else // !KONAN_NO_EXCEPTIONS void SetKonanTerminateHandler() { // Nothing to do. } -#endif // KONAN_OBJC_INTEROP +#endif // !KONAN_NO_EXCEPTIONS void DisallowSourceInfo() { disallowSourceInfo = true; From 3a5c6480a30005d3259ac222a18169f6c1a0b06c Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Sun, 21 Feb 2021 11:35:03 +0300 Subject: [PATCH 365/368] Track current exception (#4701) --- .../kotlin/backend/konan/CAdapterGenerator.kt | 17 +-- .../backend/konan/llvm/CodeGenerator.kt | 8 +- .../kotlin/backend/konan/llvm/ContextUtils.kt | 1 + .../backend.native/tests/build.gradle | 10 ++ .../tests/runtime/exceptions/rethrow.kt | 19 +++ .../runtime/exceptions/throw_from_catch.kt | 19 +++ .../runtime/src/legacymm/cpp/Memory.cpp | 25 ++++ .../runtime/src/main/cpp/Exceptions.cpp | 12 +- .../runtime/src/main/cpp/Exceptions.h | 2 + kotlin-native/runtime/src/main/cpp/Memory.h | 22 ++-- .../runtime/src/main/cpp/MultiSourceQueue.hpp | 5 + kotlin-native/runtime/src/main/cpp/Worker.cpp | 4 +- .../runtime/src/mm/cpp/ExceptionObjHolder.cpp | 47 ++++++++ .../src/mm/cpp/ExceptionObjHolderTest.cpp | 109 ++++++++++++++++++ .../runtime/src/mm/cpp/StableRefRegistry.hpp | 2 + .../runtime/src/mm/cpp/TestSupport.hpp | 36 ++++++ .../runtime/src/mm/cpp/ThreadStateTest.cpp | 45 +++----- 17 files changed, 319 insertions(+), 64 deletions(-) create mode 100644 kotlin-native/backend.native/tests/runtime/exceptions/rethrow.kt create mode 100644 kotlin-native/backend.native/tests/runtime/exceptions/throw_from_catch.kt create mode 100644 kotlin-native/runtime/src/mm/cpp/ExceptionObjHolder.cpp create mode 100644 kotlin-native/runtime/src/mm/cpp/ExceptionObjHolderTest.cpp create mode 100644 kotlin-native/runtime/src/mm/cpp/TestSupport.hpp diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt index 5becbc2f988..e9c1941960d 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt @@ -461,7 +461,7 @@ private class ExportedElement(val kind: ElementKind, "result", cfunction[0], Direction.KOTLIN_TO_C, builder) builder.append(" return $result;\n") } - builder.append(" } catch (ExceptionObjHolder& e) { TerminateWithUnhandledException(e.obj()); } \n") + builder.append(" } catch (ExceptionObjHolder& e) { TerminateWithUnhandledException(e.GetExceptionObject()); } \n") builder.append("}\n") @@ -905,7 +905,6 @@ internal class CAdapterGenerator(val context: Context) : DeclarationDescriptorVi |#define RUNTIME_NORETURN __attribute__((noreturn)) | |extern "C" { - |void UpdateHeapRef(KObjHeader**, const KObjHeader*) RUNTIME_NOTHROW; |void UpdateStackRef(KObjHeader**, const KObjHeader*) RUNTIME_NOTHROW; |KObjHeader* AllocInstance(const KTypeInfo*, KObjHeader**) RUNTIME_NOTHROW; |KObjHeader* DerefStablePointer(void*, KObjHeader**) RUNTIME_NOTHROW; @@ -951,16 +950,10 @@ internal class CAdapterGenerator(val context: Context) : DeclarationDescriptorVi |}; | |class ExceptionObjHolder { - | public: - | explicit ExceptionObjHolder(const KObjHeader* obj): obj_(nullptr) { - | ::UpdateHeapRef(&obj_, obj); - | } - | ~ExceptionObjHolder() { - | UpdateHeapRef(&obj_, nullptr); - | } - | KObjHeader* obj() { return obj_; } - | private: - | KObjHeader* obj_; + |public: + | virtual ~ExceptionObjHolder() = default; + | + | KObjHeader* GetExceptionObject() noexcept; |}; | |static void DisposeStablePointerImpl(${prefix}_KNativePtr ptr) { diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt index 097d7731e33..8388d41b9d9 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt @@ -862,14 +862,10 @@ internal class FunctionGenerationContext(val function: LLVMValueRef, val beginCatch = context.llvm.cxaBeginCatchFunction val exceptionRawPtr = call(beginCatch, listOf(exceptionRecord)) - // Pointer to KotlinException instance: - val exceptionPtrPtr = bitcast(codegen.kObjHeaderPtrPtr, exceptionRawPtr, "") - // Pointer to Kotlin exception object: - // We do need a slot here, as otherwise exception instance could be freed by _cxa_end_catch. - val exceptionPtr = loadSlot(exceptionPtrPtr, true, "exception") + val exceptionPtr = call(context.llvm.Kotlin_getExceptionObject, listOf(exceptionRawPtr), Lifetime.GLOBAL) - // __cxa_end_catch performs some C++ cleanup, including calling `KotlinException` class destructor. + // __cxa_end_catch performs some C++ cleanup, including calling `ExceptionObjHolder` class destructor. val endCatch = context.llvm.cxaEndCatchFunction call(endCatch, listOf()) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/ContextUtils.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/ContextUtils.kt index b6c840a2133..150a1dfc98f 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/ContextUtils.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/ContextUtils.kt @@ -516,6 +516,7 @@ internal class Llvm(val context: Context, val llvmModule: LLVMModuleRef) { val checkLifetimesConstraint = importRtFunction("CheckLifetimesConstraint") val freezeSubgraph = importRtFunction("FreezeSubgraph") val checkGlobalsAccessible = importRtFunction("CheckGlobalsAccessible") + val Kotlin_getExceptionObject = importRtFunction("Kotlin_getExceptionObject") val kRefSharedHolderInitLocal = importRtFunction("KRefSharedHolder_initLocal") val kRefSharedHolderInit = importRtFunction("KRefSharedHolder_init") diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 42d5c0c2ba2..2129fcbc625 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -2545,6 +2545,16 @@ standaloneTest("exception_in_global_init") { outputChecker = { s -> s.contains("Uncaught Kotlin exception: kotlin.IllegalStateException: FAIL") && !s.contains("in kotlin main") } } +task rethrow_exception(type: KonanLocalTest) { + enabled = (project.testTarget != 'wasm32') // Uses exceptions. + source = "runtime/exceptions/rethrow.kt" +} + +task throw_from_catch(type: KonanLocalTest) { + enabled = (project.testTarget != 'wasm32') // Uses exceptions. + source = "runtime/exceptions/throw_from_catch.kt" +} + standaloneTest("runtime_math_exceptions") { enabled = (project.testTarget != 'wasm32') source = "stdlib_external/numbers/MathExceptionTest.kt" diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/rethrow.kt b/kotlin-native/backend.native/tests/runtime/exceptions/rethrow.kt new file mode 100644 index 00000000000..5de33887ae6 --- /dev/null +++ b/kotlin-native/backend.native/tests/runtime/exceptions/rethrow.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +package runtime.exceptions.rethtow + +import kotlin.test.* + +@Test +fun runTest() { + assertFailsWith("My error") { + try { + error("My error") + } catch (e: Throwable) { + throw e + } + } +} diff --git a/kotlin-native/backend.native/tests/runtime/exceptions/throw_from_catch.kt b/kotlin-native/backend.native/tests/runtime/exceptions/throw_from_catch.kt new file mode 100644 index 00000000000..1522b735d21 --- /dev/null +++ b/kotlin-native/backend.native/tests/runtime/exceptions/throw_from_catch.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +package runtime.exceptions.throw_from_catch + +import kotlin.test.* + +@Test +fun runTest() { + assertFailsWith("My another error") { + try { + error("My error") + } catch (e: Throwable) { + error("My another error") + } + } +} diff --git a/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp b/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp index 8d5b166f42f..bc5e6ceebd6 100644 --- a/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp +++ b/kotlin-native/runtime/src/legacymm/cpp/Memory.cpp @@ -440,6 +440,20 @@ void setContainerFor(ObjHeader* obj, ContainerHeader* container) { obj->typeInfoOrMeta_ = setPointerBits(obj->typeInfoOrMeta_, OBJECT_TAG_NONTRIVIAL_CONTAINER); } +#if !KONAN_NO_EXCEPTIONS +class ExceptionObjHolderImpl : public ExceptionObjHolder { +public: + explicit ExceptionObjHolderImpl(ObjHeader* obj) noexcept { ::SetHeapRef(&obj_, obj); } + + ~ExceptionObjHolderImpl() override { ZeroHeapRef(&obj_); } + + ObjHeader* obj() noexcept { return obj_; } + +private: + ObjHeader* obj_; +}; +#endif + } // namespace ContainerHeader* containerFor(const ObjHeader* obj) { @@ -3691,3 +3705,14 @@ ALWAYS_INLINE RUNTIME_NOTHROW void Kotlin_mm_safePointExceptionUnwind() { } } // extern "C" + +#if !KONAN_NO_EXCEPTIONS +// static +ALWAYS_INLINE RUNTIME_NORETURN void ExceptionObjHolder::Throw(ObjHeader* exception) { + throw ExceptionObjHolderImpl(exception); +} + +ALWAYS_INLINE ObjHeader* ExceptionObjHolder::GetExceptionObject() noexcept { + return static_cast(this)->obj(); +} +#endif diff --git a/kotlin-native/runtime/src/main/cpp/Exceptions.cpp b/kotlin-native/runtime/src/main/cpp/Exceptions.cpp index 596018f1b3c..5c604905658 100644 --- a/kotlin-native/runtime/src/main/cpp/Exceptions.cpp +++ b/kotlin-native/runtime/src/main/cpp/Exceptions.cpp @@ -208,7 +208,7 @@ void ThrowException(KRef exception) { PrintThrowable(exception); RuntimeCheck(false, "Exceptions unsupported"); #else - throw ExceptionObjHolder(exception); + ExceptionObjHolder::Throw(exception); #endif } @@ -252,6 +252,14 @@ RUNTIME_NORETURN void TerminateWithUnhandledException(KRef throwable) { }); } +ALWAYS_INLINE RUNTIME_NOTHROW OBJ_GETTER(Kotlin_getExceptionObject, void* holder) { +#if !KONAN_NO_EXCEPTIONS + RETURN_OBJ(static_cast(holder)->GetExceptionObject()); +#else + RETURN_OBJ(nullptr); +#endif +} + #if !KONAN_NO_EXCEPTIONS namespace { @@ -266,7 +274,7 @@ class TerminateHandler : private kotlin::Pinned { try { std::rethrow_exception(currentException); } catch (ExceptionObjHolder& e) { - processUnhandledKotlinException(e.obj()); + processUnhandledKotlinException(e.GetExceptionObject()); konan::abort(); } catch (...) { // Not a Kotlin exception - call default handler diff --git a/kotlin-native/runtime/src/main/cpp/Exceptions.h b/kotlin-native/runtime/src/main/cpp/Exceptions.h index f115c5f9d42..c5cb866dc56 100644 --- a/kotlin-native/runtime/src/main/cpp/Exceptions.h +++ b/kotlin-native/runtime/src/main/cpp/Exceptions.h @@ -38,6 +38,8 @@ RUNTIME_NORETURN void TerminateWithUnhandledException(KRef exception); void SetKonanTerminateHandler(); +RUNTIME_NOTHROW OBJ_GETTER(Kotlin_getExceptionObject, void* holder); + // The functions below are implemented in Kotlin (at package kotlin.native.internal). // Throws null pointer exception. Context is evaluated from caller's address. diff --git a/kotlin-native/runtime/src/main/cpp/Memory.h b/kotlin-native/runtime/src/main/cpp/Memory.h index fe767630995..6bf213010ca 100644 --- a/kotlin-native/runtime/src/main/cpp/Memory.h +++ b/kotlin-native/runtime/src/main/cpp/Memory.h @@ -22,6 +22,7 @@ #include "TypeInfo.h" #include "Atomic.h" #include "PointerBits.h" +#include "Utils.hpp" typedef enum { // Must match to permTag() in Kotlin. @@ -356,23 +357,16 @@ class ObjHolder { ObjHeader* obj_; }; -//! TODO Follow the Rule of Zero to prevent dangling on unintented copy ctor class ExceptionObjHolder { - public: - explicit ExceptionObjHolder(const ObjHeader* obj) { - ::SetHeapRef(&obj_, obj); - } +public: +#if !KONAN_NO_EXCEPTIONS + static void Throw(ObjHeader* exception) RUNTIME_NORETURN; - ~ExceptionObjHolder() { - ZeroHeapRef(&obj_); - } + ObjHeader* GetExceptionObject() noexcept; +#endif - ObjHeader* obj() { return obj_; } - - const ObjHeader* obj() const { return obj_; } - - private: - ObjHeader* obj_; + // Exceptions are not on a hot path, so having virtual dispatch is fine. + virtual ~ExceptionObjHolder() = default; }; #endif // RUNTIME_MEMORY_H diff --git a/kotlin-native/runtime/src/main/cpp/MultiSourceQueue.hpp b/kotlin-native/runtime/src/main/cpp/MultiSourceQueue.hpp index 30166c31b0d..fae3649807b 100644 --- a/kotlin-native/runtime/src/main/cpp/MultiSourceQueue.hpp +++ b/kotlin-native/runtime/src/main/cpp/MultiSourceQueue.hpp @@ -144,6 +144,11 @@ public: deletionQueue_ = std::move(remainingDeletions); } + void ClearForTests() noexcept { + queue_.clear(); + deletionQueue_.clear(); + } + private: // Using `KStdList` as it allows to implement `Collect` without memory allocations, // which is important for GC mark phase. diff --git a/kotlin-native/runtime/src/main/cpp/Worker.cpp b/kotlin-native/runtime/src/main/cpp/Worker.cpp index 50888740b17..004a4b20d65 100644 --- a/kotlin-native/runtime/src/main/cpp/Worker.cpp +++ b/kotlin-native/runtime/src/main/cpp/Worker.cpp @@ -959,7 +959,7 @@ JobKind Worker::processQueueElement(bool blocking) { WorkerLaunchpad(obj, dummyHolder.slot()); } catch (ExceptionObjHolder& e) { if (errorReporting()) - ReportUnhandledException(e.obj()); + ReportUnhandledException(e.GetExceptionObject()); } DisposeStablePointer(job.executeAfter.operation); break; @@ -979,7 +979,7 @@ JobKind Worker::processQueueElement(bool blocking) { } catch (ExceptionObjHolder& e) { ok = false; if (errorReporting()) - ReportUnhandledException(e.obj()); + ReportUnhandledException(e.GetExceptionObject()); } // Notify the future. job.regularJob.future->storeResultUnlocked(result, ok); diff --git a/kotlin-native/runtime/src/mm/cpp/ExceptionObjHolder.cpp b/kotlin-native/runtime/src/mm/cpp/ExceptionObjHolder.cpp new file mode 100644 index 00000000000..a984bbd078a --- /dev/null +++ b/kotlin-native/runtime/src/mm/cpp/ExceptionObjHolder.cpp @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +#include "Memory.h" + +#include "StableRefRegistry.hpp" +#include "ThreadData.hpp" +#include "ThreadRegistry.hpp" + +using namespace kotlin; + +namespace { + +#if !KONAN_NO_EXCEPTIONS +class ExceptionObjHolderImpl : public ExceptionObjHolder { +public: + explicit ExceptionObjHolderImpl(ObjHeader* obj) noexcept { + auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData(); + stableRef_ = threadData->stableRefThreadQueue().Insert(obj); + } + + ~ExceptionObjHolderImpl() override { + auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData(); + threadData->stableRefThreadQueue().Erase(stableRef_); + } + + ObjHeader* obj() noexcept { return **stableRef_; } + +private: + mm::StableRefRegistry::Node* stableRef_; +}; +#endif + +} // namespace + +#if !KONAN_NO_EXCEPTIONS +// static +RUNTIME_NORETURN void ExceptionObjHolder::Throw(ObjHeader* exception) { + throw ExceptionObjHolderImpl(exception); +} + +ObjHeader* ExceptionObjHolder::GetExceptionObject() noexcept { + return static_cast(this)->obj(); +} +#endif diff --git a/kotlin-native/runtime/src/mm/cpp/ExceptionObjHolderTest.cpp b/kotlin-native/runtime/src/mm/cpp/ExceptionObjHolderTest.cpp new file mode 100644 index 00000000000..30e5a919c23 --- /dev/null +++ b/kotlin-native/runtime/src/mm/cpp/ExceptionObjHolderTest.cpp @@ -0,0 +1,109 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +#include + +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "Memory.h" +#include "TestSupport.hpp" +#include "ThreadData.hpp" +#include "Types.h" + +using namespace kotlin; + +namespace { + +class ExceptionObjHolderTest : public ::testing::Test { +public: + ~ExceptionObjHolderTest() { + auto& stableRefs = mm::StableRefRegistry::Instance(); + stableRefs.ClearForTests(); + } + + static KStdVector Collect(mm::ThreadData& threadData) { + auto& stableRefs = mm::StableRefRegistry::Instance(); + stableRefs.ProcessThread(&threadData); + stableRefs.ProcessDeletions(); + KStdVector result; + for (const auto& obj : stableRefs.Iter()) { + result.push_back(obj); + } + return result; + } + +private: +}; + +} // namespace + +TEST_F(ExceptionObjHolderTest, NothingByDefault) { + mm::RunInNewThread([](mm::ThreadData& threadData) { EXPECT_THAT(Collect(threadData), testing::IsEmpty()); }); +} + +TEST_F(ExceptionObjHolderTest, Throw) { + mm::RunInNewThread([](mm::ThreadData& threadData) { + ASSERT_THAT(Collect(threadData), testing::IsEmpty()); + + ObjHeader exception; + try { + ExceptionObjHolder::Throw(&exception); + } catch (...) { + EXPECT_THAT(Collect(threadData), testing::ElementsAre(&exception)); + } + EXPECT_THAT(Collect(threadData), testing::IsEmpty()); + }); +} + +TEST_F(ExceptionObjHolderTest, ThrowInsideCatch) { + mm::RunInNewThread([](mm::ThreadData& threadData) { + ASSERT_THAT(Collect(threadData), testing::IsEmpty()); + + ObjHeader exception1; + try { + ExceptionObjHolder::Throw(&exception1); + } catch (...) { + ObjHeader exception2; + try { + ExceptionObjHolder::Throw(&exception2); + } catch (...) { + EXPECT_THAT(Collect(threadData), testing::ElementsAre(&exception1, &exception2)); + } + EXPECT_THAT(Collect(threadData), testing::ElementsAre(&exception1)); + } + EXPECT_THAT(Collect(threadData), testing::IsEmpty()); + }); +} + +TEST_F(ExceptionObjHolderTest, StoreException) { + mm::RunInNewThread([](mm::ThreadData& threadData) { + ASSERT_THAT(Collect(threadData), testing::IsEmpty()); + + ObjHeader exception1; + std::exception_ptr storedException1; + try { + ExceptionObjHolder::Throw(&exception1); + } catch (...) { + storedException1 = std::current_exception(); + } + EXPECT_THAT(Collect(threadData), testing::ElementsAre(&exception1)); + + ObjHeader exception2; + std::exception_ptr storedException2; + try { + ExceptionObjHolder::Throw(&exception2); + } catch (...) { + storedException2 = std::current_exception(); + } + EXPECT_THAT(Collect(threadData), testing::ElementsAre(&exception1, &exception2)); + + storedException1 = std::exception_ptr(); + EXPECT_THAT(Collect(threadData), testing::ElementsAre(&exception2)); + + storedException2 = std::exception_ptr(); + EXPECT_THAT(Collect(threadData), testing::IsEmpty()); + }); +} diff --git a/kotlin-native/runtime/src/mm/cpp/StableRefRegistry.hpp b/kotlin-native/runtime/src/mm/cpp/StableRefRegistry.hpp index 6ed972c15e6..ec272554d4e 100644 --- a/kotlin-native/runtime/src/mm/cpp/StableRefRegistry.hpp +++ b/kotlin-native/runtime/src/mm/cpp/StableRefRegistry.hpp @@ -48,6 +48,8 @@ public: // much of a problem is it. Iterable Iter() noexcept { return stableRefs_.Iter(); } + void ClearForTests() noexcept { stableRefs_.ClearForTests(); } + private: // Current approach optimizes for creating and disposing of stable refs: // * creation just enqueues ref, disposing either queues or deletes the ref immediately (if it still resides in the current queue). diff --git a/kotlin-native/runtime/src/mm/cpp/TestSupport.hpp b/kotlin-native/runtime/src/mm/cpp/TestSupport.hpp new file mode 100644 index 00000000000..62800541de8 --- /dev/null +++ b/kotlin-native/runtime/src/mm/cpp/TestSupport.hpp @@ -0,0 +1,36 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +#include "../../main/cpp/TestSupport.hpp" + +#include + +#include "ThreadData.hpp" +#include "ThreadRegistry.hpp" + +namespace kotlin { +namespace mm { + +template +void RunInNewThread(F f) { + std::thread([&f]() { + class ScopedRegistration : private kotlin::Pinned { + public: + ScopedRegistration() : node_(mm::ThreadRegistry::Instance().RegisterCurrentThread()) {} + + ~ScopedRegistration() { mm::ThreadRegistry::Instance().Unregister(node_); } + + mm::ThreadData& threadData() { return *node_->Get(); } + + private: + mm::ThreadRegistry::Node* node_; + } registration; + + f(registration.threadData()); + }).join(); +} + +} // namespace mm +} // namespace kotlin diff --git a/kotlin-native/runtime/src/mm/cpp/ThreadStateTest.cpp b/kotlin-native/runtime/src/mm/cpp/ThreadStateTest.cpp index 75f0ef5ed69..92218c1cafb 100644 --- a/kotlin-native/runtime/src/mm/cpp/ThreadStateTest.cpp +++ b/kotlin-native/runtime/src/mm/cpp/ThreadStateTest.cpp @@ -7,69 +7,58 @@ #include "gtest/gtest.h" +#include "TestSupport.hpp" #include "ThreadData.hpp" -#include "ThreadRegistry.hpp" #include "ThreadState.hpp" using namespace kotlin; TEST(ThreadStateTest, StateSwitch) { - std::thread t([]() { - mm::ThreadRegistry::Instance().RegisterCurrentThread(); - - auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData(); - auto initialState = threadData->state(); + mm::RunInNewThread([](mm::ThreadData& threadData) { + auto initialState = threadData.state(); EXPECT_EQ(mm::ThreadState::kRunnable, initialState); - mm::ThreadState oldState = mm::SwitchThreadState(threadData, mm::ThreadState::kNative); + mm::ThreadState oldState = mm::SwitchThreadState(&threadData, mm::ThreadState::kNative); EXPECT_EQ(initialState, oldState); - EXPECT_EQ(mm::ThreadState::kNative, threadData->state()); + EXPECT_EQ(mm::ThreadState::kNative, threadData.state()); // Check functions exported for the compiler too. Kotlin_mm_switchThreadStateRunnable(); - EXPECT_EQ(mm::ThreadState::kRunnable, threadData->state()); + EXPECT_EQ(mm::ThreadState::kRunnable, threadData.state()); Kotlin_mm_switchThreadStateNative(); - EXPECT_EQ(mm::ThreadState::kNative, threadData->state()); + EXPECT_EQ(mm::ThreadState::kNative, threadData.state()); }); - t.join(); } TEST(ThreadStateTest, StateGuard) { - std::thread t([]() { - mm::ThreadRegistry::Instance().RegisterCurrentThread(); - auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData(); - auto initialState = threadData->state(); + mm::RunInNewThread([](mm::ThreadData& threadData) { + auto initialState = threadData.state(); EXPECT_EQ(mm::ThreadState::kRunnable, initialState); { - mm::ThreadStateGuard guard(threadData, mm::ThreadState::kNative); - EXPECT_EQ(mm::ThreadState::kNative, threadData->state()); + mm::ThreadStateGuard guard(&threadData, mm::ThreadState::kNative); + EXPECT_EQ(mm::ThreadState::kNative, threadData.state()); } - EXPECT_EQ(initialState, threadData->state()); + EXPECT_EQ(initialState, threadData.state()); }); - t.join(); } TEST(ThreadStateDeathTest, StateAsserts) { - std::thread t([]() { - auto* threadData = mm::ThreadRegistry::Instance().RegisterCurrentThread()->Get(); - EXPECT_DEATH(mm::AssertThreadState(threadData, mm::ThreadState::kNative), + mm::RunInNewThread([](mm::ThreadData& threadData) { + EXPECT_DEATH(mm::AssertThreadState(&threadData, mm::ThreadState::kNative), "runtime assert: Unexpected thread state. Expected: NATIVE. Actual: RUNNABLE"); }); - t.join(); } TEST(ThreadStateDeathTest, IncorrectStateSwitch) { - std::thread t([]() { - auto* threadData = mm::ThreadRegistry::Instance().RegisterCurrentThread()->Get(); - EXPECT_DEATH(mm::SwitchThreadState(threadData, kotlin::mm::ThreadState::kRunnable), + mm::RunInNewThread([](mm::ThreadData& threadData) { + EXPECT_DEATH(mm::SwitchThreadState(&threadData, kotlin::mm::ThreadState::kRunnable), "runtime assert: Illegal thread state switch. Old state: RUNNABLE. New state: RUNNABLE"); EXPECT_DEATH(Kotlin_mm_switchThreadStateRunnable(), "runtime assert: Illegal thread state switch. Old state: RUNNABLE. New state: RUNNABLE"); - mm::SwitchThreadState(threadData, kotlin::mm::ThreadState::kNative); + mm::SwitchThreadState(&threadData, kotlin::mm::ThreadState::kNative); EXPECT_DEATH(Kotlin_mm_switchThreadStateNative(), "runtime assert: Illegal thread state switch. Old state: NATIVE. New state: NATIVE"); }); - t.join(); } From e1a75f82031448628eec42213380bea1a7f170a3 Mon Sep 17 00:00:00 2001 From: Vasily Levchenko Date: Mon, 22 Feb 2021 07:16:23 +0100 Subject: [PATCH 366/368] [kotlin compiler][update] 1.5.20-dev-1166 * 073a5003704 - (HEAD -> master, tag: build-1.5.20-dev-1166, origin/master, origin/HEAD) Change order of WITH_RUNTIME and FILE. Wrong order brakes module pattern. (22 hours ago) * 95a8c60a9ce - Ignore test in Native backend. Test overrides kotlin.Result (22 hours ago) * 4643f12a5f1 - Ignore JVM test in Native backend (22 hours ago) * d9be59ea97c - (tag: build-1.5.20-dev-1156) [JS IR] JS code in init block only for js ir backend test (2 days ago) * 13dfa5a8867 - (tag: build-1.5.20-dev-1153) [FIR2IR] Add handling exceptions from Fir2Ir and reporting declaration where converter failed (2 days ago) * ea2783eace4 - [FIR] Fix generating `this` reference in delegated accessors (2 days ago) * 4e5647090e1 - (tag: build-1.5.20-dev-1143) Approximate captured types in contravariant positions properly (2 days ago) * 387d84f8260 - (tag: build-1.5.20-dev-1136) JVM_IR indy-SAM: KT-45069 box lambda 'Unit' return type if needed (2 days ago) * 187d4998fa8 - (tag: build-1.5.20-dev-1132) [JS IR] Not cast to declaration parent in JsCodeOutlineLowering, use parent otherwise (2 days ago) * bd2601f289d - (tag: build-1.5.20-dev-1128) [JS IR] Extract adding of function call to another function (2 days ago) * 5568ceef689 - (tag: build-1.5.20-dev-1125) Add test for KT-37056 (already fixed) (2 days ago) * 6e46b0a1c4b - Add test for KT-41917 (already fixed) (2 days ago) * 1fe0a1f1609 - FIR: Fix interface delegation case via type alias (2 days ago) * e4c851e3ceb - FIR2IR: Fix case of @JvmOverloads with subclass (2 days ago) * 377a0aa237b - FIR2IR: Adjust test data for updated overridden structure (2 days ago) * a750d9466ec - FIR2IR: Rework resulted overridden-relation structure (2 days ago) * fd146e3eed9 - FIR2IR: Copy annotations from original declarations to fake overrides (2 days ago) * a883833941a - FIR2IR: Use IrDeclarationOrigin.FAKE_OVERRIDE for non-source classes (2 days ago) * d339096ac33 - FIR2IR: Introduce and use declarationStorage.getOrCreateIrConstructor (2 days ago) * fb8314f6e76 - FIR: Fix enhancement of property overrides accessors in Java (2 days ago) * 45018ea4685 - FIR: Rework loading overrides of special built-in methods from Java (2 days ago) * 4b0aeb71057 - FIR2IR: Support initialSignatureDescriptor (2 days ago) * 23705a269ff - FIR: Fix supertype scopes for local classes (2 days ago) * 3e420ca4e32 - FIR: Introduce FirDeclarationOrigin.BuiltIns (2 days ago) * 893b1045ba4 - Move some common parts from BuiltinMethodsWithDifferentJvmName to SpecialGenericSignatures (2 days ago) * 5d5228cfc59 - FIR: Require FirJavaClass in JavaScopeProvider (2 days ago) * 04f53d6a23f - FIR: Simplify JavaScopeProvider (2 days ago) * 6766c8fe47f - FIR: Simplify supertypes scopes computation (2 days ago) * 31b9be2d01b - FIR: Extract ConeKotlinType::scopeForSupertype (2 days ago) * 1a0be3ee405 - (tag: build-1.5.20-dev-1124) Fix FirAnnotationArgumentChecker (String + ... case) #KT-44995 Fixed (2 days ago) * cd8f597e2f6 - (tag: build-1.5.20-dev-1123) [FIR] Fix building callable reference adaptation against flexible types (2 days ago) * 469252f6b40 - [FIR] Don't create smartcast node if smartcasted type is equal to original type (2 days ago) * 1c0d862e406 - [FIR] Don't smartcast variables to invisible types (2 days ago) * 026efca49fa - [Test] Add helpers file with functions for inference testing (2 days ago) * d0eeb0535de - (tag: build-1.5.20-dev-1110) Add synchronization to MultiClassFiles maps (2 days ago) * aa683d3b2ac - JPS: Fix JvmMultifileClass processing for IR backend (2 days ago) * ca4ec997ee8 - (tag: build-1.5.20-dev-1106) FIR IDE: split KtAnalysisSession into mixins (3 days ago) * 141b6b0e550 - (tag: build-1.5.20-dev-1098) FIR IDE: use different .after testdata for AbstractHLIntentionTest.kt (3 days ago) * 42103b7363b - FIR IDE: use correct denotable type approximator (3 days ago) * af4d3006868 - Use nullability from approximated local type in AbstractTypeApproximator (3 days ago) * 3571074da40 - (tag: build-1.5.20-dev-1096) Update FIR-IDE diagnostic components (3 days ago) * 7c080395f2e - FIR: minor test data fixes (3 days ago) * 7fdc1c7b217 - Fix RawFirBuilderTotalKotlinTestCase.testPsiConsistency (3 days ago) * 54139b83cee - FIR: fix EXPRESSION_REQUIRED positioning (3 days ago) * 588b1354f60 - FIR IDE: fix reference shortening regarding new qualified sources (3 days ago) * 5066a90f6f3 - FIR2IR: fix offsets for qualified expressions (3 days ago) * 239a44b30c7 - FIR: forbid reporting inapplicable-likes on implicit constructors (3 days ago) * 34c90aab3b8 - FIR: introduce & use REFERENCE_BY_QUALIFIER positioning strategy (3 days ago) * 0accaf0f301 - FIR: report resolve-time errors on qualified access instead of reference (3 days ago) * 5ffa72f1fac - FIR: change DOT_BY_SELECTOR to DOT_BY_QUALIFIED strategy (3 days ago) * 04caa5c6127 - Fix DEBUG_INFO_CALL positioning in FIR (3 days ago) * 5ca3ce9e371 - FIR: introduce & use SELECTOR_BY_QUALIFIED positioning strategy (3 days ago) * 5892646a275 - Change FirQualifiedAccess source to KtQualifiedExpression (if any) (3 days ago) * 742f1e00693 - FIR: add replaceSource to all FIR tree nodes (3 days ago) * b8d1bbdd0d7 - (tag: build-1.5.20-dev-1095) Do not swallow PCE (3 days ago) * d40777c28f1 - (tag: build-1.5.20-dev-1085) [FIR] Fix calculating arguments of bare type with intersection type as base (3 days ago) * 56f9e3360ff - JVM IR: do not generate invokeinterface hashCode if smart cast is present (3 days ago) * 56854a8b1a5 - (tag: build-1.5.20-dev-1078) FIR IDE: register quickfix for the following (3 days ago) * 88c43e7f7bb - (tag: build-1.5.20-dev-1072) [FE] Assume that effective visibility of sealed class constructor is internal (3 days ago) * b08eb6cf4c7 - (tag: build-1.5.20-dev-1069) FIR IDE: specify behaviour of HL API getOverriddenSymbols (3 days ago) * 804df1aec2c - FIR IDE: introduce base class for multifile tests (3 days ago) * 3626008ed26 - (tag: build-1.5.20-dev-1065) [Inference] Add ability to approximate local types in AbstractTypeApproximator (3 days ago) * 73616107b47 - (tag: build-1.5.20-dev-1060) Unmute passing FIR BB test (3 days ago) * c629ba5a3cb - (tag: build-1.5.20-dev-1058) JVM_IR indy-SAM: function reference to Java interface (3 days ago) * 357a7907a34 - (tag: build-1.5.20-dev-1051) FIR: fix type approximation by visibility (3 days ago) * 74bdb2398ef - (tag: build-1.5.20-dev-1048) FIR: Get rid of PSI dependency in the `:fir:resolve` module (3 days ago) * 6b453d9b233 - FIR: implement checker for open members (3 days ago) * 3e9ff3ecda8 - FIR: report SUPERTYPE_NOT_A_CLASS_OR_INTERFACE on type parameters (3 days ago) * e67eb0c1237 - FIR checker: typed declaration's return type should be resolved (3 days ago) * 5f9357eb41c - FIR: transform implicit type ref in anonymous function arguments & body (3 days ago) * a841a0bbca0 - FIR: transform other parts of function call even though callee is an error (3 days ago) * 27c942a0fff - FIR: enforce the return type of function literals without body (3 days ago) * 9aaa952b39b - FIR: regard implicit type for value parameter after body resolve as an error type (3 days ago) * fbb19e3b50d - FIR: ensure type ref transformed by type resolve transformer is resolved (3 days ago) * 52ea7fdb72b - FIR: ensure type ref after supertype resolve transformer is resolved (3 days ago) * 8783ebc3524 - (tag: build-1.5.20-dev-1042) Report highlight errors to WolfTheProblemSolver (3 days ago) * afe71f5d59b - (tag: build-1.5.20-dev-1036) FIR: Add runConfig to generate FIR boilerplate (#4130) (3 days ago) * 51da54ce669 - (tag: build-1.5.20-dev-1030) FIR IDE: Simplify registerPsiQuickFixes (4 days ago) * cacd84390e5 - (tag: build-1.5.20-dev-1027) Use erased upper bound instead of checking for inline type (4 days ago) * 741c1a864f2 - JVM_IR: IC: Unbox inline class argument of callable reference (4 days ago) * 744a0fcd250 - PSI2IR KT-45022 object in LHS of compound assignment (4 days ago) * 05447ce0c8b - (tag: build-1.5.20-dev-1023) [Commonizer] Print true time for resolving of libraries to be commonized (4 days ago) * 0b26a281dee - [Commonizer] Print pretty target name in console output (4 days ago) * fb51105a5d2 - [Commonizer] Log time in commonizer result consumers (4 days ago) * 496aad3c4ac - [Commonizer] Log commonization only for really present targets (4 days ago) * 3ad7b607478 - [Commonizer] Prefer using CommonizerTarget instead of KonanTarget (4 days ago) * 1895c230efb - [Commonizer] K/N dist: Process targets in alphabetical order (4 days ago) * f473b88e478 - [Commonizer] Nicer API for CirProvidedClassifiers (4 days ago) * 84ce9c612c9 - [Commonizer] Keep only "common" dependencies in CirKnownClassifiers (4 days ago) * 2581b67cdaa - [Commonizer] Rename: CirCommonizedClassifiers -> CirCommonizedClassifierNodes (4 days ago) * 43ad0ed9071 - [Commonizer] Optimized implementation of CirProvidedClassifiers (4 days ago) * 79e3ce022f0 - [Commonizer] Fix: Keep fwd declarations under real names in CirForwardDeclarations cache (4 days ago) * bc9a7918090 - (tag: build-1.5.20-dev-1021) Refactor klib serializer/deserializer (4 days ago) * ad9fd7ecf3c - (tag: build-1.5.20-dev-1015) KotlinBinaryClassCache: clean-up request caches for all threads (4 days ago) * 5cbbbc3b832 - (tag: build-1.5.20-dev-1013) Fix artifacts needed for the kotlin-gradle-plugin (4 days ago) * 33313ae4b40 - Fix artifacts needed for the kotlin-gradle-plugin (4 days ago) * 8c20c655feb - (tag: build-1.5.20-dev-1003) Updated bytecode of serialization for IR (4 days ago) * 7b7b8fbea74 - (tag: build-1.5.20-dev-998) [Test] Filter dependent modules by source kind in creating FirModuleInfo (4 days ago) * 8c95b783463 - Update JVM metadata version to 1.5.0 (4 days ago) * dbadd5846a4 - Add test for script flag in kotlin.Metadata (4 days ago) * 1d6b1989151 - Build: suppress version and JVM target warnings (4 days ago) * 49fc1b9e3e6 - Build: enable -Werror for several modules (4 days ago) * 82ac4821433 - (tag: build-1.5.20-dev-989, origin/jupiter/master) Fix typo (#4051) (4 days ago) * a3fa6c6d136 - (tag: build-1.5.20-dev-985) Publish artifacts needed for the kotlin-gradle-plugin in kotlin-ide repository (4 days ago) * 9b4949a3c58 - (tag: build-1.5.20-dev-978) [FIR] Fix taking symbol of expression with smartcast inside DFA (4 days ago) * adb05ab076d - (tag: build-1.5.20-dev-972) JVM IR: write inherited multifile parts flag to kotlin.Metadata (4 days ago) * 35008df9697 - (tag: build-1.5.20-dev-969) [Commonizer] Rename NativeDistributionCommonizer to LibraryCommonizer (4 days ago) * 4500b6ce74c - [Commonizer] Implement :native:kotlin-klib-commonizer:api with support for library commonization (4 days ago) * 6d019d9544b - (tag: build-1.5.20-dev-968) JVM_IR indy-SAM on functional expression (4 days ago) * 134fda8bad8 - (tag: build-1.5.20-dev-967) Support Unit/V types in string-concat indy calls (5 days ago) * e3e7e6b740d - Make `indy-with-constants` default for -jvm-target 9+ (5 days ago) * 3d8e8dd3ba9 - Fail on compilation errors in AbstractBytecodeTextTest (5 days ago) * 61fce74b76b - Support new targets in KotlinBytecodeToolWindow (5 days ago) * 91f1cb88c16 - (tag: build-1.5.20-dev-966) Support serialization of java enum classes in IR (5 days ago) * 652207dcac2 - (tag: build-1.5.20-dev-965) FIR IDE: add AddModifierFix (5 days ago) * 5793f77ece2 - FIR IDE: AddModifierFix -> AddModifierFixMpp (5 days ago) * de06a69b128 - (tag: build-1.5.20-dev-964) Added external serializers in serialization plugin for IR backend (5 days ago) * 66f00a2eb5d - FIR IDE: move AddFunctionBodyFix to fe-independent (5 days ago) * 67e91b7ebdc - (tag: build-1.5.20-dev-959) Minor, add workaround for KT-45008 (5 days ago) * 4d9cffccf23 - (tag: build-1.5.20-dev-946) Support structural equals/hashCode for type constructors of type parameters (5 days ago) * aaecb87d1ba - Tests: compute runtime classpath for JVM box tests manually (5 days ago) * df428688741 - [Inference] Fix subtyping on classes with same FQN but with different number of arguments (5 days ago) * 0b22c30ab1a - [FIR] Fix dispatch receiver type for members of builtin functional types (5 days ago) * e5ab6841272 - [FIR] Support methods of cone type contexts with annotation markers (5 days ago) * 57d29009eef - [FIR] Fix TODOs and cleanup ConeTypeContext and ConeInferenceContext (5 days ago) * 373bc578fb3 - [FIR] Implement capturing of cone types same as for kotlin types (5 days ago) * 5ce36a528ec - [FE] Prohibit sealed fun interfaces (5 days ago) * cdf7de5524a - [FE] Change message for sealed interfaces with language target < 1.5 (5 days ago) * 8521d844e24 - (tag: build-1.5.20-dev-935, tag: build-1.5.20-dev-913) Advance bootstrap to 1.5.20-dev-814 (5 days ago) * 83343f3a7a2 - (tag: build-1.5.20-dev-907, tag: build-1.5.20-dev-901) IR: get rid of some type checks in JvmBackendContext (5 days ago) * 68cabba6987 - IR: preserve signatures when copying IrFiles in performByIrFile (5 days ago) * db18ffc7640 - IR: only worry about threads in JvmIrSignatureDescriptor (5 days ago) * cacfe530650 - IR: move performByIrFile to a separate .kt (5 days ago) * 4c701cf44c1 - IR: make extractedLocalClasses a JS-only field (5 days ago) * 445f6eac3dc - IR: IrBasedDescriptor fix (5 days ago) * c081bc8d7e2 - Fir concurrent maps (5 days ago) * 9cdad272de0 - Fir threadLocal (5 days ago) * ec2dc9c0fa7 - IR: synchronize on SymbolTable operations (5 days ago) * c9d0448fd15 - IR: use threadLocal (5 days ago) * 56a26113cdd - IR: threadLocal (5 days ago) * 57167922e22 - IR: make lazyVar synchronized (5 days ago) * 4e9bedc2fc8 - JVM_IR: use ConcurrentHashMap (5 days ago) * 23da2bde679 - IR: fixes for IR by-file copying (5 days ago) * 54a76977dbe - IR: fix fake override computation (5 days ago) * d154c8d8e67 - IR: copy each file before lowering. (5 days ago) * 103f82c95c3 - IR: an option to automatically select the number of lowering threads (5 days ago) * 52b3cb362bb - IR: thread pool in PerformByIrFilePhase (5 days ago) * eae416d7394 - IR: Handle exceptions from by-file lowering thread (5 days ago) * bea5d955d4d - JVM_IR: perform file lowerings in parallel (5 days ago) * c06b345f3c2 - (tag: build-1.5.20-dev-898) Hide `stageController` into the IrFactory (5 days ago) * 97080c49fcb - Persistent IR generator (5 days ago) * 8a0ce20d439 - PIR: minor restructuring (5 days ago) * 1310a65f0cc - (tag: build-1.5.20-dev-894) JVM: rename this$0 when regenerating nested objects too (5 days ago) * ec89cb23135 - (tag: build-1.5.20-dev-883, origin/push/nk/all) Ignore hanging KotlinAndroid36GradleIT.testAndroidMppSourceSets() (5 days ago) * ec569a4c893 - (tag: build-1.5.20-dev-875) Minor. Suppress errors in tests (5 days ago) * bad197e0759 - Raise RESERVED_VAR_PROPERTY_OF_VALUE_CLASS to error (5 days ago) * 56a104dda91 - (tag: build-1.5.20-dev-867) JVM_IR KT-44974 fix SAM-converted capturing extension lambda (6 days ago) * 83ed67546b6 - (tag: build-1.5.20-dev-857) [Test] Support WITH_STDLIB directive in js box tests (6 days ago) * dfcff132fde - [FIR] Fix false-positive smartcast on receiver in rhs of elvis (6 days ago) * 2b392826822 - [FIR] Render original type before smartcasted type in DEBUG_INFO_EXPRESSION_TYPE (6 days ago) * d4c26cca52a - [FIR] Use type without smartcast for local variable with smartcasted initializer (6 days ago) * 40e286b3546 - [FIR] Increase level of sequential when branches (6 days ago) * 92271527cb8 - [Test] Add CFG and IR dump handlers to FirBlackBoxTests (6 days ago) * b5619dbf370 - [FIR] Add ability to render node levels in CFG graph dumper (6 days ago) * 3e220116266 - Fix compilation of HLRedundantVisibilityModifierInspection (6 days ago) * e8f3ebdd199 - (tag: build-1.5.20-dev-855) FIR IDE: introduce HLRedundantVisibilityModifierInspection by extended checker (6 days ago) * 6d97841f388 - FIR IDE: introduce HLLocalInspectionTest (6 days ago) * 7fb6c228895 - FIR IDE: allow creating inspections by extended checkers (6 days ago) * b9a4613e44e - FIR IDE: remove getMessage from HLPresentation as it duplicates HLApplicator.getActionName (6 days ago) * c13889c2ea2 - FIR: add ability to specify checkers list for checker components (6 days ago) * ca4a07f73f3 - Unify message bundles used in IDEA FIR into KotlinBundle (6 days ago) * 6352814d452 - Fix NPE (6 days ago) * 98ba379e075 - Fixed NPE on StandaloneScriptRootsCache instantiation (6 days ago) * 45b17120ad4 - [Commonizer] Minor. Rename: 'dependee' -> 'dependency' (6 days ago) * ec7e411d806 - [Commonizer] Remove classifierId from CIR class/TA nodes (6 days ago) * ef931d55611 - [Commonizer] Don't keep kotlin/Any as the single supertype in CirClass (6 days ago) * baeee8988ea - [all-open] Don't affect private declarations to change their modality to open (6 days ago) * ec41775d7e4 - [all-open] Fix formatting (6 days ago) * 05ff2b12923 - (tag: build-1.5.20-dev-842) [JVM_IR] Extend when to switch translation to deal with nested ors. (6 days ago) * 91581d6c1ad - Move KotlinBundle to frontend-independent module (6 days ago) * a8c23e1c3a0 - (tag: build-1.5.20-dev-830) FirDefaultStarImportingScope: filter INVISIBLE_CLASSES properly (6 days ago) * 940588a9bba - FE: commonize throw-related annotation FQ names (6 days ago) * 2dc0404751c - FIR: prioritize visible imported classes during type resolution (6 days ago) * 291ed4a38a5 - FIR: handle typealiases during conflict resolution (6 days ago) * 592c285198b - (tag: build-1.5.20-dev-826) Kapt: Don't create KDocCommentKeeper when not needed (6 days ago) * 0a72e164510 - (tag: build-1.5.20-dev-814) FIR: transform DiagnosticBuilder DSL to an object (6 days ago) * 15aaf3a0789 - (tag: build-1.5.20-dev-813) Copy typeParameters from original declaration to the exportedDefaultStubFun before substitution of type parameters (6 days ago) * 706d3e5aa87 - (tag: build-1.5.20-dev-812) FIR IDE: Add quickfix for VAR_ANNOTATION_PARAMETER. (6 days ago) * 2f450549ab4 - (tag: build-1.5.20-dev-806) FIR IDE: Update FIR diagnostic test data for INAPPLICABLE_LATEINIT_MODIFIER. (7 days ago) * 4e44804c775 - FIR IDE: Add quickfix for INAPPLICABLE_LATEINIT_MODIFIER. (7 days ago) * b1ab64e854e - (tag: build-1.5.20-dev-804) JVM_IR KT-44483 argument adaptation is already done in PSI2IR (7 days ago) * f1b0e893ae8 - (tag: build-1.5.20-dev-797) Remove kotlin-annotations-android (7 days ago) * 899f75466d4 - Remove tests on kotlin-annotations-android (7 days ago) * 3432f581cb2 - Remove compiler support for kotlin-annotations-android (7 days ago) * a8845551712 - FIR: bail out early for override check if base candidate is private (7 days ago) * 09640d9d63a - FIR checker: apply override checker to anonymous objects (7 days ago) * 9370f918e9d - FIR: use override checker when populating directOverriddenProperties (7 days ago) * fa1507fb91a - (tag: build-1.5.20-dev-795) Fix FIR test `lambdaParameterTypeInElvis` (7 days ago) * 83836037f8e - (tag: build-1.5.20-dev-793) Add documentation on type checker context / type system context (7 days ago) * 3909e3c54ca - Decouple TypeCheckerContext and TypeSystemContext (7 days ago) * 53a7dc1126a - KT-44839 [Sealed interfaces]: restore move-tests for lang-version < 15 (7 days ago) * eb0c73fd5e9 - KT-44839 [Sealed interfaces]: ability to specify compiler options in tests (7 days ago) * c63a9afa56f - KT-44839 [Sealed interfaces]: move refactoring for language level < 1.5 (7 days ago) * 5c7aadece92 - (tag: build-1.5.20-dev-790) Fix test founds more lines then expected. (7 days ago) * 224aea09530 - Ignore test due to the bug in AGP on Gradle 6.8+. (7 days ago) * 9d9df0c4ffc - Expect new attributes compatibility error. (7 days ago) * 6c0ee2f9eaa - Update test to use new test xml output format. (7 days ago) * 6d2465d00cd - Update Gradle version for tests to 6.8.1. (7 days ago) * b262d09a81b - (tag: build-1.5.20-dev-787) JVM_IR KT-44627 fix bridge signature for parameter with primitive bound (7 days ago) * fa0f967c833 - (tag: build-1.5.20-dev-785) FIR2IR: support adapted references for constructors (7 days ago) * 8bab2083227 - FIR2IR: use information about callable reference adaptation from resolve (7 days ago) * dcad9c84fc6 - (tag: build-1.5.20-dev-771) Don't fix type variables into Nothing in priority way (7 days ago) * 440fc8c4e40 - (tag: build-1.5.20-dev-764) Deprecated 'kotlin.useCompilerFallbackSearch' property. (7 days ago) * 069941cdaf6 - Provide compiler classpath as task input. (7 days ago) * 0eaea655d0d - (tag: build-1.5.20-dev-754) [Commonization] Improvements in approx. keys (7 days ago) * 3c6eb8f8f4f - Minor. Formatted (7 days ago) * 0af31abb048 - [Commonizer] Add tests for overloading purely by different upper bounds (7 days ago) * 90cdb9203fb - [Commonizer] Fix integration tests: wrong mismatches filter (7 days ago) * 8a17de38d0e - [Commonizer] Fix integration tests: serialize only own module contents (7 days ago) * 7f8f1dc4f82 - [Commonizer] Calculate hash code by pure name in approximation keys (7 days ago) * 6ff5704ef96 - Delete obsolete test (7 days ago) * f4937665630 - Add IR tests to Android codegen test (7 days ago) * c0759f96e93 - (tag: build-1.5.20-dev-751) Fix FIR test `lambdaParameterTypeInElvis` (7 days ago) * 8acf3b1d765 - (tag: build-1.5.20-dev-747) [Cocoapods] Fail import if project's version wasn't specified (7 days ago) * c158c64ee00 - (tag: build-1.5.20-dev-744) Reformat TypeWithEnhancement.kt (7 days ago) * 0d40022d6de - Add reporting of the warnings based on Java annotations for expanded type aliases (7 days ago) * d783d99443e - Use upper bound checker for typealias expansion (7 days ago) * edb8007d52b - Add test for errors reporting of UPPER_BOUND_VIOLATED (7 days ago) * befe8599c42 - Report warnings or errors for violated type parameter's upper bounds from Java annotated with nullability annotations (7 days ago) * cf4e61bebb2 - (tag: build-1.5.20-dev-741) [FIR] Add spec diagnostic tests to `[JPS] Fast FIR tests` run configuration (7 days ago) * 5711a8d6100 - [FIR] Support PreliminaryLoopVisitor in FIR DFA (7 days ago) * 0e46a961a3e - [FIR] Implement util Multimap classes (7 days ago) * 67ad4249c8b - [Test] Add FirDumpHandler to AbstractFirBlackBoxCodegenTest (7 days ago) * a94086224d5 - (tag: build-1.5.20-dev-739) Clear request cache properly during disposing component (7 days ago) * 6f64fd2fecf - Propagate inference session into declaration analyzers (7 days ago) * dae1f4c05d2 - Remove redundant extension receiver substitution during lambda's completion (7 days ago) * b463a0fa588 - (tag: build-1.5.20-dev-736) [Gradle] Use property provider for configuration time only if available (7 days ago) * 683bd0ed384 - (tag: build-1.5.20-dev-735) [Gradle, JVM] Don't create deprecated compile/runtime configurations (7 days ago) * ef458b20e13 - (tag: build-1.5.20-dev-734) [Gradle] Replace deprecated dependencies configurations in buildscript (7 days ago) * c7427a751a9 - [Gradle, K/N] Add integration tests for framework artifacts (7 days ago) * 383b9834a16 - [Gradle, K/N] Make BitcodeEmbeddingMode move backward compatible (7 days ago) * cbeb0310994 - [Gradle, K/N] Move NativeBinaryTypes from kotlin-gradle-plugin to kotlin-gradle-plugin-api (7 days ago) * a6cdfeafede - [Gradle, K/N] Consumable frameworks review fixes (7 days ago) * 604dda839a8 - [Gradle, K/N] Generate fat framework tasks and consumable configurations (7 days ago) * d844296629a - [Gradle, K/N] Add user-defined variant attributes to framework artifact (7 days ago) * cbdcd8f2bcc - [Gradle, K/N] Add consumable configuration with K/N frameworks (7 days ago) * ba969410c24 - [Gradle, JS] Make MultiplePluginDeclarationDetector compatible w/ conf cache (7 days ago) * 1cceec36427 - [Gradle, JS] Postpone TeamCity project property read using 'by lazy' (7 days ago) * 240fdfa7a85 - [Gradle] Support multiple failures in KotlinTestReport back again (7 days ago) * 2b0ad702421 - [Gradle, JS] Add integration test for js plugin configuration cache (7 days ago) * a6bf9bf51b5 - [Gradle, JS] Remove workaround for configuration cache enabled builds (7 days ago) * 432c6486d55 - [Gradle] Make KotlinTest, KotlinTestReport partially cc-compatible (7 days ago) * c7421e2bea2 - [Gradle, JS] Use FileSystemOperations only when it's available (7 days ago) * 0e29a9df6c7 - [Gradle, JS] Use target disambiguation classifier for compilation name (7 days ago) * 6eac5e1907f - [Gradle, JS] Tasks that uses ArchiveOperations compatible w/ Gradle < 6.6 (7 days ago) * 15f6bb9506c - [Gradle, JS] Make NodeJsSetup cc-compatible (7 days ago) * daa9c81bcb1 - [Gradle, JS] Make KotlinJsDce, Dukat, KotlinPackageJson cc-compatible (7 days ago) * da80d53796b - [Gradle, JS] Make KotlinWebpack cc-compatible (7 days ago) * 65faf204722 - [Gradle, JS] Make PublicPackageJsonTask cc-compatible (7 days ago) * 521b722c098 - [Gradle, JS] Compilation to compilationName (7 days ago) * 4566b7c6e5c - [Gradle, JS] rootPackageJson and kotlinNpmInstall cache-friendly (7 days ago) * 8c79baa9985 - [Gradle, JS] Partially rootPackageJson and kotlinNpmInstall with conf cache (7 days ago) * a41d3e5b043 - [Gradle, JS] Webpack task with conf cache (w/o install of dependencies) (7 days ago) * e6bfe9a7024 - [Gradle, JS] Npm dependencies as transient, and store only declarations (7 days ago) * b9aa577f84f - [Gradle, JS] KotlinPackageJson configuration cache works (7 days ago) * cd0dfd6fa9c - [Gradle, JS] Use transient for compilation npm resolver (7 days ago) * 60da9281a2c - [Gradle, JS] Next step of configurstion cache (7 days ago) * 19e59fe7707 - [Gradle, JS] Experimenting with making everything transient in npm (7 days ago) * cc51869a2ab - (tag: build-1.5.20-dev-728) [KAPT] Take function argument names from original descriptor (8 days ago) * 4a0437a5071 - (tag: build-1.5.20-dev-727) [KAPT] Fix field type correction for delegates (#4107) (8 days ago) * bf9fa4c9da5 - (tag: build-1.5.20-dev-721) Lightweight hashCode calc for LibraryInfo (8 days ago) * 6882cf820ec - (tag: build-1.5.20-dev-708) FIR IDE: move RemoveModifierFix to ... (10 days ago) * 75f6780b908 - (tag: build-1.5.20-dev-701) AndroidDependencyResolver: Don't load android-related classes on class load (10 days ago) * d42cc219bfd - (tag: build-1.5.20-dev-700) FIR IDE: fix collecting diagnostics for raanalysable non-toplevel declarations (10 days ago) * 6ba57abb8f4 - JVM don't use indy by default for SAM conversions (wait for KT-44844) (10 days ago) * 5013344bc4e - JVM_IR nullability assertions test for indy lambdas (10 days ago) * 4ab242ed51a - JVM_IR indy: minor: use toLowerCaseAsciiOnly for options (10 days ago) * afeb7e18cd5 - JVM_IR indy: fix non-null assertions on indy lambda parameters (10 days ago) * 43b1711010d - JVM_IR indy: extract LambdaMetafactoryArguments code to separate file (10 days ago) * 3438d19c223 - JVM_IR indy: use 'CLASS' mode in SAM bytecode listing tests (10 days ago) * 7564c9bb8c3 - JVM SamWrapperClassesAreSynthetic language feature (10 days ago) * 052f6929c9f - JVM_IR indy SAM conversions: update tests (10 days ago) * 3ebeca58522 - JVM_IR: use indy SAM conversions in jvmTarget 1.8+, fix bridges (10 days ago) * 6c6d43c29ae - JS: add missing reachable nodes data (10 days ago) * a719656118d - Fix extracted metadata for IDE erased when scopes conflict, KT-44845 (10 days ago) * 54636f1af72 - (tag: build-1.5.20-dev-693) Enable -Werror in `:compiler:frontend` module (10 days ago) * 0c4bca4bde2 - [FIR] Fix warnings in FIR modules and enable -Werror in them (10 days ago) * 0e31551797c - [FIR] Generate `_` instead of `value` for unused setters in FIR builders (10 days ago) * d696a488b51 - [FIR] Report list of conflicting symbols in REDECLARATION and CONFLICTING_OVERLOADS (10 days ago) * 7a4625b70b2 - (tag: build-1.5.20-dev-689) FIR IDE: Enable passing completion test (10 days ago) * d615b6b6827 - (tag: build-1.5.20-dev-683) FIR IDE: `firSymbolProvider` -> `symbolProvider` fix (10 days ago) * bc262303923 - FIR IDE: Visit only the smallest acceptable declaration if possible (10 days ago) * c3831baba2c - FIR IDE: Refactor `ElementsToShortenCollector` to be more value-oriented (10 days ago) * dee4f4345b2 - FIR IDE: Add `ElementToShorten` sealed classes (10 days ago) * d202b0feb2c - FIR IDE: Refactor `addElementToShorten` functions (10 days ago) * 09ba927680b - FIR IDE: Decouple `ElementsToShortenCollector` from `KtFirReferenceShortener` (10 days ago) * c89380fc369 - FIR IDE: Refactor `ElementsToShortenCollector` (10 days ago) * 9a464ae9c40 - FIR IDE: Merge all collectors visitors to a single visitor (10 days ago) * 7478b8d1896 - FIR IDE: Use single `TextRange` as selection instead of two ints (10 days ago) * 798c4d24850 - FIR IDE: Create `FirResolvedImport`s without fake PSI (10 days ago) * c0a4301179b - FIR IDE: Enhance check messages in `KtFirReferenceShortener` (10 days ago) * 8020424b932 - FIR IDE: Remove fake root prefix even when the element is not shortened (10 days ago) * ee98a76600a - FIR IDE: Implement simple importing of the functions (10 days ago) * 88e7d1e5eed - FIR: Attach candidate symbol to the `ErrorNamedReference` (10 days ago) * 51c59e56343 - FIR IDE: Check function call before trying to drop the receiver (10 days ago) * d88fd5bd73a - FIR IDE: More strictly navigate to parent `KtDotQualifiedExpression` (10 days ago) * e265a78a33d - FIR IDE: Implement shortening and import for type qualifiers (10 days ago) * 0e271b72c78 - FIR IDE: Do not try to shorten type without qualifier (10 days ago) * 534f4a66ad6 - FIR IDE: Add simple shortening for qualified calls and properties (10 days ago) * f03ca5ea57e - FIR IDE: Add import in case when conflicting class comes from `*` import (10 days ago) * 0b48416a1ee - FIR IDE: Unwrap nullable types (10 days ago) * 08e271411f0 - FIR IDE: Create fake scopes to avoid import duplicates (10 days ago) * e34370554d2 - FIR IDE: Add simple types importing (10 days ago) * 0609aa1e2e0 - FIR IDE: Refactor `KtFirReferenceShortener` (10 days ago) * 8575ce32d4d - FIR IDE: Add more tests for type conflicts (10 days ago) * e744084c15b - FIR IDE: Enable types shortening for nested classes and nested types (10 days ago) * b9d074051fa - FIR IDE: Add separate tests for FIR reference shortening (10 days ago) * c1130f20106 - FIR IDE: Add reference shortening service which works over FIR (10 days ago) * 108395fcfee - FIR: Fix bug with incorrect source element for qualifiers (10 days ago) * 1479388bd59 - FIR IDE: Refactor `AbstractFirShortenRefsTest` (10 days ago) * 68b5f2736e9 - FIR: Add fake root prefix for IDE resolution (10 days ago) * 0de251e50d8 - Add `runTestInWriteCommand` flag to `AbstractImportTest` (10 days ago) * 2d5b6855358 - (tag: build-1.5.20-dev-680) [FIR] Fix processing constructors of sealed classes (10 days ago) * 7c61ddc72b7 - [FE] Allow declaring protected constructors in sealed classes (10 days ago) * f3a8fcaea6e - [FE] Make constructors of sealed classes `protected` instead of `internal` (10 days ago) * e795c2c4079 - (tag: build-1.5.20-dev-676) Generate proper hashCode for fun interface wrappers (10 days ago) * f33cad54c5f - (tag: build-1.5.20-dev-653) AndroidDependencyResolver: fixed AAR import on modern AGP plugins (10 days ago) * 7eb5fc77785 - AndroidDependencyResolver: fixed NPE (10 days ago) * abc44fa6588 - (tag: build-1.5.20-dev-651, origin/rr/abannykh/fix-ant-tests) Increase -Xmx for Ant tests (11 days ago) * 20f9787c700 - (tag: build-1.5.20-dev-642) FIR checker: report errors in contract description (11 days ago) * 3d635b6a941 - FIR: unwrap smartcast expression when extracting effects of contract (11 days ago) * 70f462781a9 - FIR-IDE: add mappings for backing field diagnostics (11 days ago) * 510b9e6f2ad - (tag: build-1.5.20-dev-639) Move around some codegen box tests (11 days ago) * 2d60fa787dc - Remove codegen tests on old language and API versions (11 days ago) * 401f0ac583e - Use TARGET_BACKEND instead of DONT_TARGET_EXACT_BACKEND in box against Java tests (11 days ago) * f797ee78035 - (tag: build-1.5.20-dev-631) Substitute captured types with inner intersection one (NewTypeSubstitutor) (11 days ago) * 80daf120e6a - (tag: build-1.5.20-dev-630) Apply illegal-access=permit workaround for JDK 16+ (11 days ago) * 4b62b2de0c0 - (tag: build-1.5.20-dev-628) Use IDEA ASM in `kotlin-gradle-plugin-integration-tests` module (11 days ago) * c3c8991ab63 - (tag: build-1.5.20-dev-622) FIR IDE: Re-organize MainKtQuickFixRegistrar. (11 days ago) * a9f19c4a454 - FIR IDE: Move ChangeVariableMutabilityFix to idea-frontend-independent. (11 days ago) * 79622248045 - FIR IDE: Add quickfix for VAR_OVERRIDDEN_BY_VAL. (11 days ago) * 57e06992c91 - (tag: build-1.5.20-dev-621) Skip JDK 6 in failing BB test (java.util.function in use) (11 days ago) * cd483ad2318 - (tag: build-1.5.20-dev-617) FIR2IR: fix raw SAM conversion (avoid * in type arguments) (11 days ago) * 5f3102bf2fa - FIR2IR: expand type before getting nullability #KT-44803 Fixed (11 days ago) * 791f5891274 - SymbolTable: Rewrite nasty code with if without else in elvis RHS (11 days ago) * 4bc630d82cb - FIR2IR: enhance approximation of captured types (11 days ago) * 346ffb3acf9 - FIR2IR: support substitution for SAM types (11 days ago) * 7050af9b790 - FIR2IR: use invariant projections for SAM_CONVERSION types (11 days ago) * 67671afab4d - (tag: build-1.5.20-dev-616) [Plugin API] Fix missed call in `resolveBySignatureInModule` (11 days ago) * 2c4a6fdb982 - (tag: build-1.5.20-dev-599) Revert "Use IDEA ASM in kapt module" (11 days ago) * 73aa465ee97 - (tag: build-1.5.20-dev-592) Add tests for issues fixed in JVM IR (11 days ago) * 17fc10a8afe - (tag: build-1.5.20-dev-585) Mark obsolete Gradle JVM options as Deprecated with Error (12 days ago) --- kotlin-native/gradle.properties | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kotlin-native/gradle.properties b/kotlin-native/gradle.properties index ece40d18861..47f2a6ea5de 100644 --- a/kotlin-native/gradle.properties +++ b/kotlin-native/gradle.properties @@ -18,12 +18,12 @@ buildKotlinVersion=1.5.20-dev-372 buildKotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.20-dev-372,branch:default:any,pinned:true/artifacts/content/maven remoteRoot=konan_tests -kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.20-dev-576,branch:default:any,pinned:true/artifacts/content/maven -kotlinVersion=1.5.20-dev-576 -kotlinStdlibRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.20-dev-576,branch:default:any,pinned:true/artifacts/content/maven -kotlinStdlibVersion=1.5.20-dev-576 -kotlinStdlibTestsVersion=1.5.20-dev-576 -testKotlinCompilerVersion=1.5.20-dev-576 +kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.20-dev-1166,branch:default:any,pinned:true/artifacts/content/maven +kotlinVersion=1.5.20-dev-1166 +kotlinStdlibRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.20-dev-1166,branch:default:any,pinned:true/artifacts/content/maven +kotlinStdlibVersion=1.5.20-dev-1166 +kotlinStdlibTestsVersion=1.5.20-dev-1166 +testKotlinCompilerVersion=1.5.20-dev-1166 konanVersion=1.5.20 # A version of Xcode required to build the Kotlin/Native compiler. From 80e7e7010d41fa35ad0f11313c97ec099e74d70f Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Wed, 17 Feb 2021 15:05:16 +0300 Subject: [PATCH 367/368] Fix compilation with Kotlin master (cherry picked from commit b5ed03a7ef72fa41af8742b766f9f01680c426f5) --- .../org/jetbrains/kotlin/backend/konan/KonanBackendContext.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanBackendContext.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanBackendContext.kt index d0fcbde4df6..617265cffb7 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanBackendContext.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanBackendContext.kt @@ -65,8 +65,6 @@ internal abstract class KonanBackendContext(val config: KonanConfig) : CommonBac override val mapping: Mapping = DefaultMapping() - override val extractedLocalClasses: MutableSet = mutableSetOf() - override val irFactory: IrFactory = IrFactoryImpl } From ae5655f9b31aa2de56092ba8081b2124f11088ac Mon Sep 17 00:00:00 2001 From: Anton Bannykh Date: Wed, 10 Feb 2021 19:27:03 +0300 Subject: [PATCH 368/368] BasicIrModuleDeserializer is not inner class anymore (cherry picked from commit 7a32327afb8beaf769b23e342348707874afbfb3) --- .../kotlin/backend/konan/serialization/KonanIrlinker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt index 0f9cd5330bb..4fe7952bfd6 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt @@ -113,7 +113,7 @@ internal class KonanIrLinker( moduleDescriptor: ModuleDescriptor, klib: IrLibrary, strategy: DeserializationStrategy - ): KotlinIrLinker.BasicIrModuleDeserializer(moduleDescriptor, klib, strategy) { + ): BasicIrModuleDeserializer(this@KonanIrLinker, moduleDescriptor, klib, strategy){ override val moduleFragment: IrModuleFragment = KonanIrModuleFragmentImpl(moduleDescriptor, builtIns, emptyList()) }

Find usages for data class components and destructuring declarations
could be
disabled once or disabled for a project.