[FIR] Get rid of copying function call in process of completion

This commit is contained in:
Dmitriy Novozhilov
2020-02-26 10:54:12 +03:00
parent cda8177502
commit 4454a0681b
26 changed files with 10 additions and 30 deletions
@@ -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 =
@@ -47,7 +47,7 @@ digraph tryWithLambdaInside_kt {
15 [label="Exit function anonymousFunction"];
}
16 [label="Postponed exit from lambda"];
17 [label="Function call: R|<local>/list|.R|kotlin/collections/filter|(<L> = filter@fun <anonymous>(it: R|kotlin/Boolean|): R|kotlin/Boolean| <kind=UNKNOWN> )"];
17 [label="Function call: R|<local>/list|.R|kotlin/collections/filter|<R|kotlin/Boolean|>(<L> = filter@fun <anonymous>(it: R|kotlin/Boolean|): R|kotlin/Boolean| <kind=UNKNOWN> )"];
18 [label="Exit block"];
}
19 [label="Try main block exit"];
@@ -116,7 +116,7 @@ finally {
32 [label="Access variable R|<local>/list|"];
33 [label="Postponed enter to lambda"];
34 [label="Postponed exit from lambda"];
35 [label="Function call: R|<local>/list|.R|/notInPlaceFilter|(<L> = notInPlaceFilter@fun <anonymous>(it: R|kotlin/Boolean|): R|kotlin/Boolean|)"];
35 [label="Function call: R|<local>/list|.R|/notInPlaceFilter|<R|kotlin/Boolean|>(<L> = notInPlaceFilter@fun <anonymous>(it: R|kotlin/Boolean|): R|kotlin/Boolean|)"];
36 [label="Exit block"];
}
37 [label="Try main block exit"];
@@ -12,7 +12,7 @@ FILE: topLevelResolve.kt
lval mutableList: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/mutableListOf|<R|kotlin/Int|>(vararg(Int(9), Int(10))).R|kotlin/collections/plus|<R|kotlin/Int|>(R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(11), Int(12), Int(13))))
lval setAndList: R|kotlin/collections/Set<kotlin/Int>| = R|kotlin/collections/setOf|<R|kotlin/Int|>(Int(0)).R|kotlin/collections/plus|<R|kotlin/Int|>(R|kotlin/collections/listOf|<R|kotlin/Int|>(vararg(Int(1), Int(2))))
lval stringAndList: R|kotlin/String| = String().R|kotlin/String.plus|(R|kotlin/collections/emptyList|<R|kotlin/Boolean|>())
lval map: R|kotlin/collections/Map<kotlin/String, kotlin/Int>| = R|kotlin/collections/mapOf|<R|kotlin/String|, R|kotlin/Int|>(String().R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(1)), String(.).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(2)), vararg()).R|kotlin/collections/plus|<R|kotlin/String|, R|kotlin/Int|>(String(..).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(3)))
lval map: R|kotlin/collections/Map<kotlin/String, kotlin/Int>| = R|kotlin/collections/mapOf|<R|kotlin/String|, R|kotlin/Int|>(vararg(String().R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(1)), String(.).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(2)))).R|kotlin/collections/plus|<R|kotlin/String|, R|kotlin/Int|>(String(..).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(3)))
lval mapAndMap: R|kotlin/collections/Map<kotlin/String, kotlin/Int>| = R|kotlin/collections/mapOf|<R|kotlin/String|, R|kotlin/Int|>(String(-).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(4))).R|kotlin/collections/plus|<R|kotlin/String|, R|kotlin/Int|>(R|kotlin/collections/mapOf|<R|kotlin/String|, R|kotlin/Int|>(String(_).R|kotlin/to|<R|kotlin/String|, R|kotlin/Int|>(Int(5))))
}
public final fun <T> id(arg: R|T|): R|T| {
@@ -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(),
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun test(y: Array<in Array<String>>) {
y[0] = kotlin.arrayOf("OK")
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun box(): String {
val x : Array<Array<*>> = arrayOf(arrayOf(1))
val y : Array<in Array<String>> = x
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Box<T>(val value: T)
fun <T> run(vararg z: T): Box<T> {
@@ -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)
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KT-2739 Error type inferred for hashSet(Pair, Pair, Pair)
fun <T> foo(vararg ts: T): T? = null
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FILE: box.kt
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FILE: box.kt
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// JVM_TARGET: 1.8
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FILE: box.kt
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FILE: box.kt
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// JVM_TARGET: 1.8
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// JVM_TARGET: 1.8
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FILE: box.kt
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FILE: box.kt
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// JVM_TARGET: 1.8
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FILE: box.kt
@@ -1,6 +1,5 @@
// !LANGUAGE: +StrictJavaNullabilityAssertions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// JVM_TARGET: 1.8
-1
View File
@@ -1,7 +1,6 @@
// !LANGUAGE: +NewInference
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
// IGNORE_BACKEND_FIR: JVM_IR
class Inv<T>
fun <T> bar(x: Inv<T>.() -> Unit) = x
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
fun foo(useScriptArgs: Array<out Any?>?) {
val constructorArgs: Array<out Any?> = arrayOf(useScriptArgs.orEmpty())
}
@@ -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<ft<kotlin/String, kotlin/String?>!>, kotlin/Array<out ft<kotlin/String, kotlin/String?>!>?>!| = 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<ft<kotlin/String, kotlin/String?>!>, kotlin/Array<out ft<kotlin/String, kotlin/String?>!>?>!| = this@R|/A|.R|/Some.bar|(R|kotlin/intArrayOf|(vararg(Int(0), Int(2), Int(2).R|kotlin/Int.unaryMinus|())))
}
}