From 4454a0681b3df20a61b927165b4512702cc86f9b Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 26 Feb 2020 10:54:12 +0300 Subject: [PATCH] [FIR] Get rid of copying function call in process of completion --- .../FirCallCompletionResultsWriterTransformer.kt | 8 ++++---- .../resolveWithStdlib/smartcasts/tryWithLambdaInside.dot | 4 ++-- .../testData/resolveWithStdlib/topLevelResolve.txt | 2 +- .../org/jetbrains/kotlin/fir/tree/generator/FieldSets.kt | 2 +- .../codegen/box/arrays/inProjectionAsParameter.kt | 1 - .../testData/codegen/box/arrays/inProjectionOfArray.kt | 1 - .../testData/codegen/box/arrays/inProjectionOfList.kt | 1 - .../casts/literalExpressionAsGenericArgument/vararg.kt | 1 - .../box/controlStructures/forArrayListMultiDecl.kt | 2 +- .../builderInferenceAndGenericArrayAcessCall.kt | 1 - compiler/testData/codegen/box/functions/kt2739.kt | 1 - .../box/ranges/javaInterop/javaArrayOfInheritedNotNull.kt | 1 - .../javaArrayOfMaybeNullableWithNotNullLoopVariable.kt | 1 - .../ranges/javaInterop/javaCollectionOfExplicitNotNull.kt | 1 - .../javaInterop/javaCollectionOfInheritedNotNull.kt | 1 - ...avaCollectionOfMaybeNullableWithNotNullLoopVariable.kt | 1 - .../javaInterop/javaCollectionOfNotNullToTypedArray.kt | 1 - .../box/ranges/javaInterop/javaIteratorOfNotNull.kt | 1 - .../withIndex/javaArrayOfInheritedNotNullWithIndex.kt | 1 - ...rrayOfMaybeNullableWithIndexWithNotNullLoopVariable.kt | 1 - .../withIndex/javaCollectionOfExplicitNotNullWithIndex.kt | 1 - ...tionOfMaybeNullableWithIndexWithNotNullLoopVariable.kt | 1 - .../withIndex/javaIteratorOfNotNullWithIndex.kt | 1 - compiler/testData/codegen/box/regressions/kt35914.kt | 1 - .../regressions/noCapturingForTypesWithTypeVariables.kt | 1 - .../fir/multiModule/basicWithPrimitiveJava/jvm/jvm.txt | 2 +- 26 files changed, 10 insertions(+), 30 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 13a2e36ebee..a96a1f7c7dd 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 @@ -205,10 +205,10 @@ class FirCallCompletionResultsWriterTransformer( } } - return result.copy( - resultType = resultType, - typeArguments = typeArguments, - ).compose() + result.replaceTypeRef(resultType) + result.replaceTypeArguments(typeArguments) + + return result.compose() } private fun FirTypeRef.substitute(candidate: Candidate): ConeKotlinType = diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot b/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot index 74c717dc364..9fa1c223b3c 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot +++ b/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot @@ -47,7 +47,7 @@ digraph tryWithLambdaInside_kt { 15 [label="Exit function anonymousFunction"]; } 16 [label="Postponed exit from lambda"]; - 17 [label="Function call: R|/list|.R|kotlin/collections/filter|( = filter@fun (it: R|kotlin/Boolean|): R|kotlin/Boolean| )"]; + 17 [label="Function call: R|/list|.R|kotlin/collections/filter|( = filter@fun (it: R|kotlin/Boolean|): R|kotlin/Boolean| )"]; 18 [label="Exit block"]; } 19 [label="Try main block exit"]; @@ -116,7 +116,7 @@ finally { 32 [label="Access variable R|/list|"]; 33 [label="Postponed enter to lambda"]; 34 [label="Postponed exit from lambda"]; - 35 [label="Function call: R|/list|.R|/notInPlaceFilter|( = notInPlaceFilter@fun (it: R|kotlin/Boolean|): R|kotlin/Boolean|)"]; + 35 [label="Function call: R|/list|.R|/notInPlaceFilter|( = notInPlaceFilter@fun (it: R|kotlin/Boolean|): R|kotlin/Boolean|)"]; 36 [label="Exit block"]; } 37 [label="Try main block exit"]; diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/topLevelResolve.txt b/compiler/fir/resolve/testData/resolveWithStdlib/topLevelResolve.txt index e9164fc29d3..86055dc6e48 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/topLevelResolve.txt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/topLevelResolve.txt @@ -12,7 +12,7 @@ FILE: topLevelResolve.kt lval mutableList: R|kotlin/collections/List| = R|kotlin/collections/mutableListOf|(vararg(Int(9), Int(10))).R|kotlin/collections/plus|(R|kotlin/collections/listOf|(vararg(Int(11), Int(12), Int(13)))) lval setAndList: R|kotlin/collections/Set| = R|kotlin/collections/setOf|(Int(0)).R|kotlin/collections/plus|(R|kotlin/collections/listOf|(vararg(Int(1), Int(2)))) lval stringAndList: R|kotlin/String| = String().R|kotlin/String.plus|(R|kotlin/collections/emptyList|()) - lval map: R|kotlin/collections/Map| = R|kotlin/collections/mapOf|(String().R|kotlin/to|(Int(1)), String(.).R|kotlin/to|(Int(2)), vararg()).R|kotlin/collections/plus|(String(..).R|kotlin/to|(Int(3))) + lval map: R|kotlin/collections/Map| = R|kotlin/collections/mapOf|(vararg(String().R|kotlin/to|(Int(1)), String(.).R|kotlin/to|(Int(2)))).R|kotlin/collections/plus|(String(..).R|kotlin/to|(Int(3))) lval mapAndMap: R|kotlin/collections/Map| = R|kotlin/collections/mapOf|(String(-).R|kotlin/to|(Int(4))).R|kotlin/collections/plus|(R|kotlin/collections/mapOf|(String(_).R|kotlin/to|(Int(5)))) } public final fun id(arg: R|T|): R|T| { diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FieldSets.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FieldSets.kt index 0842ba3f6e6..0c73cd355bd 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FieldSets.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/FieldSets.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.fir.tree.generator.context.type import org.jetbrains.kotlin.fir.tree.generator.model.* object FieldSets { - val calleeReference = field("calleeReference", reference) + val calleeReference = field("calleeReference", reference, withReplace = true) val receivers = fieldSet( field("explicitReceiver", expression, nullable = true).withTransform(), diff --git a/compiler/testData/codegen/box/arrays/inProjectionAsParameter.kt b/compiler/testData/codegen/box/arrays/inProjectionAsParameter.kt index f2c12474660..d89fdf1f02b 100644 --- a/compiler/testData/codegen/box/arrays/inProjectionAsParameter.kt +++ b/compiler/testData/codegen/box/arrays/inProjectionAsParameter.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun test(y: Array>) { y[0] = kotlin.arrayOf("OK") } diff --git a/compiler/testData/codegen/box/arrays/inProjectionOfArray.kt b/compiler/testData/codegen/box/arrays/inProjectionOfArray.kt index 35732b57148..87785a47aaf 100644 --- a/compiler/testData/codegen/box/arrays/inProjectionOfArray.kt +++ b/compiler/testData/codegen/box/arrays/inProjectionOfArray.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun box(): String { val x : Array> = arrayOf(arrayOf(1)) val y : Array> = x diff --git a/compiler/testData/codegen/box/arrays/inProjectionOfList.kt b/compiler/testData/codegen/box/arrays/inProjectionOfList.kt index d1bca2bc54a..559ca509e8f 100644 --- a/compiler/testData/codegen/box/arrays/inProjectionOfList.kt +++ b/compiler/testData/codegen/box/arrays/inProjectionOfList.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KJS_WITH_FULL_RUNTIME // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/casts/literalExpressionAsGenericArgument/vararg.kt b/compiler/testData/codegen/box/casts/literalExpressionAsGenericArgument/vararg.kt index 9a058bc0d2f..dab9ff62303 100644 --- a/compiler/testData/codegen/box/casts/literalExpressionAsGenericArgument/vararg.kt +++ b/compiler/testData/codegen/box/casts/literalExpressionAsGenericArgument/vararg.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class Box(val value: T) fun run(vararg z: T): Box { diff --git a/compiler/testData/codegen/box/controlStructures/forArrayListMultiDecl.kt b/compiler/testData/codegen/box/controlStructures/forArrayListMultiDecl.kt index b3e24ffa775..350b71d9a59 100644 --- a/compiler/testData/codegen/box/controlStructures/forArrayListMultiDecl.kt +++ b/compiler/testData/codegen/box/controlStructures/forArrayListMultiDecl.kt @@ -1,4 +1,4 @@ -// IGNORE_BACKEND_FIR: JVM_IR + // KJS_WITH_FULL_RUNTIME // WITH_RUNTIME val alist = arrayListOf(1 to 2, 2 to 3, 3 to 4) diff --git a/compiler/testData/codegen/box/coroutines/builderInferenceAndGenericArrayAcessCall.kt b/compiler/testData/codegen/box/coroutines/builderInferenceAndGenericArrayAcessCall.kt index 0726ae52f75..09f899270b7 100644 --- a/compiler/testData/codegen/box/coroutines/builderInferenceAndGenericArrayAcessCall.kt +++ b/compiler/testData/codegen/box/coroutines/builderInferenceAndGenericArrayAcessCall.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // KJS_WITH_FULL_RUNTIME diff --git a/compiler/testData/codegen/box/functions/kt2739.kt b/compiler/testData/codegen/box/functions/kt2739.kt index c12400cdd4a..296dd3bc8c3 100644 --- a/compiler/testData/codegen/box/functions/kt2739.kt +++ b/compiler/testData/codegen/box/functions/kt2739.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // KT-2739 Error type inferred for hashSet(Pair, Pair, Pair) fun foo(vararg ts: T): T? = null diff --git a/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfInheritedNotNull.kt b/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfInheritedNotNull.kt index 1f34a1b37af..c13b03eca5e 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfInheritedNotNull.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfInheritedNotNull.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // FILE: box.kt diff --git a/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfMaybeNullableWithNotNullLoopVariable.kt b/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfMaybeNullableWithNotNullLoopVariable.kt index 7ead8be35ee..005fd639259 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfMaybeNullableWithNotNullLoopVariable.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/javaArrayOfMaybeNullableWithNotNullLoopVariable.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // FILE: box.kt diff --git a/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfExplicitNotNull.kt b/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfExplicitNotNull.kt index c5f9a53ab3f..5e55f918b41 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfExplicitNotNull.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfExplicitNotNull.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // JVM_TARGET: 1.8 diff --git a/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfInheritedNotNull.kt b/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfInheritedNotNull.kt index 11c24cc495f..80801cad38b 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfInheritedNotNull.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfInheritedNotNull.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // FILE: box.kt diff --git a/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfMaybeNullableWithNotNullLoopVariable.kt b/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfMaybeNullableWithNotNullLoopVariable.kt index f900d19d40c..cdf62e6f179 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfMaybeNullableWithNotNullLoopVariable.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfMaybeNullableWithNotNullLoopVariable.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // FILE: box.kt diff --git a/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfNotNullToTypedArray.kt b/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfNotNullToTypedArray.kt index a1da80b2564..00425402e43 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfNotNullToTypedArray.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/javaCollectionOfNotNullToTypedArray.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // JVM_TARGET: 1.8 diff --git a/compiler/testData/codegen/box/ranges/javaInterop/javaIteratorOfNotNull.kt b/compiler/testData/codegen/box/ranges/javaInterop/javaIteratorOfNotNull.kt index dc935275d1a..6c3908484f3 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/javaIteratorOfNotNull.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/javaIteratorOfNotNull.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // JVM_TARGET: 1.8 diff --git a/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaArrayOfInheritedNotNullWithIndex.kt b/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaArrayOfInheritedNotNullWithIndex.kt index dee9ec44677..7e9bd863cbe 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaArrayOfInheritedNotNullWithIndex.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaArrayOfInheritedNotNullWithIndex.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // FILE: box.kt diff --git a/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaArrayOfMaybeNullableWithIndexWithNotNullLoopVariable.kt b/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaArrayOfMaybeNullableWithIndexWithNotNullLoopVariable.kt index bd9a434fa26..13ebaeb28c1 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaArrayOfMaybeNullableWithIndexWithNotNullLoopVariable.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaArrayOfMaybeNullableWithIndexWithNotNullLoopVariable.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // FILE: box.kt diff --git a/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaCollectionOfExplicitNotNullWithIndex.kt b/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaCollectionOfExplicitNotNullWithIndex.kt index a89d0557864..f374f4b3e84 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaCollectionOfExplicitNotNullWithIndex.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaCollectionOfExplicitNotNullWithIndex.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // JVM_TARGET: 1.8 diff --git a/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaCollectionOfMaybeNullableWithIndexWithNotNullLoopVariable.kt b/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaCollectionOfMaybeNullableWithIndexWithNotNullLoopVariable.kt index ae3d5c18b2b..650e45b2c50 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaCollectionOfMaybeNullableWithIndexWithNotNullLoopVariable.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaCollectionOfMaybeNullableWithIndexWithNotNullLoopVariable.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // FILE: box.kt diff --git a/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaIteratorOfNotNullWithIndex.kt b/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaIteratorOfNotNullWithIndex.kt index 5b36a78c471..ada44a595fe 100644 --- a/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaIteratorOfNotNullWithIndex.kt +++ b/compiler/testData/codegen/box/ranges/javaInterop/withIndex/javaIteratorOfNotNullWithIndex.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +StrictJavaNullabilityAssertions // TARGET_BACKEND: JVM -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME // JVM_TARGET: 1.8 diff --git a/compiler/testData/codegen/box/regressions/kt35914.kt b/compiler/testData/codegen/box/regressions/kt35914.kt index 92483152851..860d50f6891 100644 --- a/compiler/testData/codegen/box/regressions/kt35914.kt +++ b/compiler/testData/codegen/box/regressions/kt35914.kt @@ -1,7 +1,6 @@ // !LANGUAGE: +NewInference // WITH_RUNTIME // KJS_WITH_FULL_RUNTIME -// IGNORE_BACKEND_FIR: JVM_IR class Inv fun bar(x: Inv.() -> Unit) = x diff --git a/compiler/testData/codegen/box/regressions/noCapturingForTypesWithTypeVariables.kt b/compiler/testData/codegen/box/regressions/noCapturingForTypesWithTypeVariables.kt index 2ab91417c3c..993d8ad63cd 100644 --- a/compiler/testData/codegen/box/regressions/noCapturingForTypesWithTypeVariables.kt +++ b/compiler/testData/codegen/box/regressions/noCapturingForTypesWithTypeVariables.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun foo(useScriptArgs: Array?) { val constructorArgs: Array = arrayOf(useScriptArgs.orEmpty()) } diff --git a/idea/testData/fir/multiModule/basicWithPrimitiveJava/jvm/jvm.txt b/idea/testData/fir/multiModule/basicWithPrimitiveJava/jvm/jvm.txt index baafde5aed3..58d4b14e15b 100644 --- a/idea/testData/fir/multiModule/basicWithPrimitiveJava/jvm/jvm.txt +++ b/idea/testData/fir/multiModule/basicWithPrimitiveJava/jvm/jvm.txt @@ -7,7 +7,7 @@ FILE: jvm.kt public final fun test(): R|kotlin/Unit| { lval res1: R|kotlin/Boolean| = this@R|/A|.R|/Some.foo|(Int(1)) lval res2: R|kotlin/Boolean| = this@R|/A|.R|/Some.foo|(Int(1).R|kotlin/Int.unaryMinus|()) - lval res3: R|ft!>, kotlin/Array!>?>!| = this@R|/A|.R|/Some.bar|(R|kotlin/intArrayOf|(vararg(Int(0), Int(2)), Int(2).R|kotlin/Int.unaryMinus|())) + lval res3: R|ft!>, kotlin/Array!>?>!| = this@R|/A|.R|/Some.bar|(R|kotlin/intArrayOf|(vararg(Int(0), Int(2), Int(2).R|kotlin/Int.unaryMinus|()))) } }