[FIR] Add invocation kind to anonymous functions
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.fir
|
package org.jetbrains.kotlin.fir
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.contracts.description.InvocationKind
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||||
@@ -56,7 +57,8 @@ fun FirAnonymousFunction.copy(
|
|||||||
annotations: List<FirAnnotationCall> = this.annotations,
|
annotations: List<FirAnnotationCall> = this.annotations,
|
||||||
typeRef: FirTypeRef = this.typeRef,
|
typeRef: FirTypeRef = this.typeRef,
|
||||||
label: FirLabel? = this.label,
|
label: FirLabel? = this.label,
|
||||||
controlFlowGraphReference: FirControlFlowGraphReference = this.controlFlowGraphReference
|
controlFlowGraphReference: FirControlFlowGraphReference = this.controlFlowGraphReference,
|
||||||
|
invocationKind: InvocationKind? = this.invocationKind
|
||||||
): FirAnonymousFunction {
|
): FirAnonymousFunction {
|
||||||
return FirAnonymousFunctionImpl(session, psi, returnTypeRef, receiverTypeRef, symbol).apply {
|
return FirAnonymousFunctionImpl(session, psi, returnTypeRef, receiverTypeRef, symbol).apply {
|
||||||
this.valueParameters.addAll(valueParameters)
|
this.valueParameters.addAll(valueParameters)
|
||||||
@@ -65,6 +67,7 @@ fun FirAnonymousFunction.copy(
|
|||||||
this.typeRef = typeRef
|
this.typeRef = typeRef
|
||||||
this.label = label
|
this.label = label
|
||||||
this.controlFlowGraphReference = controlFlowGraphReference
|
this.controlFlowGraphReference = controlFlowGraphReference
|
||||||
|
this.invocationKind = invocationKind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.resolve.transformers
|
package org.jetbrains.kotlin.fir.resolve.transformers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.contracts.description.InvocationKind
|
||||||
import org.jetbrains.kotlin.fir.*
|
import org.jetbrains.kotlin.fir.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
||||||
@@ -444,6 +445,7 @@ open class FirBodyResolveTransformer(
|
|||||||
storeTypeFromCallee(functionCall)
|
storeTypeFromCallee(functionCall)
|
||||||
}
|
}
|
||||||
if (functionCall.calleeReference !is FirSimpleNamedReference) return functionCall.compose()
|
if (functionCall.calleeReference !is FirSimpleNamedReference) return functionCall.compose()
|
||||||
|
functionCall.transform<FirFunctionCall, InvocationKind?>(InvocationKindTransformer, null)
|
||||||
val expectedTypeRef = data as FirTypeRef?
|
val expectedTypeRef = data as FirTypeRef?
|
||||||
val completeInference =
|
val completeInference =
|
||||||
try {
|
try {
|
||||||
|
|||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* 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.fir.resolve.transformers
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.contracts.description.InvocationKind
|
||||||
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirLambdaArgumentExpression
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.compose
|
||||||
|
|
||||||
|
object InvocationKindTransformer : FirTransformer<InvocationKind?>() {
|
||||||
|
override fun <E : FirElement> transformElement(element: E, data: InvocationKind?): CompositeTransformResult<E> {
|
||||||
|
return element.compose()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun transformAnonymousFunction(
|
||||||
|
anonymousFunction: FirAnonymousFunction,
|
||||||
|
data: InvocationKind?
|
||||||
|
): CompositeTransformResult<FirDeclaration> {
|
||||||
|
if (data != null) {
|
||||||
|
anonymousFunction.replaceInvocationKind(data)
|
||||||
|
}
|
||||||
|
return anonymousFunction.compose()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun transformLambdaArgumentExpression(
|
||||||
|
lambdaArgumentExpression: FirLambdaArgumentExpression,
|
||||||
|
data: InvocationKind?
|
||||||
|
): CompositeTransformResult<FirStatement> {
|
||||||
|
lambdaArgumentExpression.transformChildren(this, data)
|
||||||
|
return lambdaArgumentExpression.compose()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun transformFunctionCall(functionCall: FirFunctionCall, data: InvocationKind?): CompositeTransformResult<FirStatement> {
|
||||||
|
// TODO: add contracts handling
|
||||||
|
return (functionCall.transformChildren(this, InvocationKind.EXACTLY_ONCE) as FirFunctionCall).compose()
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
-14
@@ -6,38 +6,38 @@ FILE: lambda.kt
|
|||||||
public final fun baz(f: R|kotlin/Function0<kotlin/Unit>|, other: R|kotlin/Boolean| = Boolean(true)): R|kotlin/Unit| {
|
public final fun baz(f: R|kotlin/Function0<kotlin/Unit>|, other: R|kotlin/Boolean| = Boolean(true)): R|kotlin/Unit| {
|
||||||
}
|
}
|
||||||
public final fun test(): R|kotlin/Unit| {
|
public final fun test(): R|kotlin/Unit| {
|
||||||
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| {
|
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| {
|
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|/foo|(foo@fun <anonymous>(): R|kotlin/Unit| {
|
R|/foo|(foo@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(Int(1), <L> = foo@fun <implicit>.<anonymous>(): <implicit> {
|
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(Int(1), <L> = foo@fun <implicit>.<anonymous>(): <implicit> <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(f = foo@fun <implicit>.<anonymous>(): <implicit> {
|
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(f = foo@fun <implicit>.<anonymous>(): <implicit> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
, <L> = foo@fun <implicit>.<anonymous>(): <implicit> {
|
, <L> = foo@fun <implicit>.<anonymous>(): <implicit> <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|/bar|(Int(1), <L> = bar@fun <anonymous>(): R|kotlin/Unit| {
|
R|/bar|(Int(1), <L> = bar@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|/bar|(x = Int(1), <L> = bar@fun <anonymous>(): R|kotlin/Unit| {
|
R|/bar|(x = Int(1), <L> = bar@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|/bar|(Int(1), bar@fun <anonymous>(): R|kotlin/Unit| {
|
R|/bar|(Int(1), bar@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -45,11 +45,11 @@ FILE: lambda.kt
|
|||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(<L> = bar@fun <implicit>.<anonymous>(): <implicit> {
|
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(<L> = bar@fun <implicit>.<anonymous>(): <implicit> <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(bar@fun <implicit>.<anonymous>(): <implicit> {
|
<Inapplicable(PARAMETER_MAPPING_ERROR): [/bar]>#(bar@fun <implicit>.<anonymous>(): <implicit> <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -57,19 +57,19 @@ FILE: lambda.kt
|
|||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|/baz|(baz@fun <anonymous>(): R|kotlin/Unit| {
|
R|/baz|(baz@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
, Boolean(false))
|
, Boolean(false))
|
||||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(<L> = baz@fun <implicit>.<anonymous>(): <implicit> {
|
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(<L> = baz@fun <implicit>.<anonymous>(): <implicit> <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(<L> = baz@fun <implicit>.<anonymous>(): <implicit> {
|
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(<L> = baz@fun <implicit>.<anonymous>(): <implicit> <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(other = Boolean(false), <L> = baz@fun <implicit>.<anonymous>(): <implicit> {
|
<Inapplicable(PARAMETER_MAPPING_ERROR): [/baz]>#(other = Boolean(false), <L> = baz@fun <implicit>.<anonymous>(): <implicit> <kind=EXACTLY_ONCE> {
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,19 +8,19 @@ FILE: lambda.kt
|
|||||||
public final fun multipleArgs(block: R|kotlin/Function2<kotlin/String, kotlin/String, kotlin/String>|): R|kotlin/Unit| {
|
public final fun multipleArgs(block: R|kotlin/Function2<kotlin/String, kotlin/String, kotlin/String>|): R|kotlin/Unit| {
|
||||||
}
|
}
|
||||||
public final fun main(): R|kotlin/Unit| {
|
public final fun main(): R|kotlin/Unit| {
|
||||||
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| {
|
R|/foo|(<L> = foo@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
String(This is test)
|
String(This is test)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|/bar|(<L> = bar@fun <anonymous>(): R|kotlin/String| {
|
R|/bar|(<L> = bar@fun <anonymous>(): R|kotlin/String| <kind=EXACTLY_ONCE> {
|
||||||
String(This is also test)
|
String(This is also test)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|/itIs|(<L> = itIs@fun <anonymous>(it: R|kotlin/String|): R|kotlin/String| {
|
R|/itIs|(<L> = itIs@fun <anonymous>(it: R|kotlin/String|): R|kotlin/String| <kind=EXACTLY_ONCE> {
|
||||||
<strcat>(String(this is ), R|<local>/it|, String( test))
|
<strcat>(String(this is ), R|<local>/it|, String( test))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|/multipleArgs|(<L> = multipleArgs@fun <anonymous>(a: R|kotlin/String|, b: R|kotlin/String|): R|kotlin/String| {
|
R|/multipleArgs|(<L> = multipleArgs@fun <anonymous>(a: R|kotlin/String|, b: R|kotlin/String|): R|kotlin/String| <kind=EXACTLY_ONCE> {
|
||||||
<strcat>(String(This is test of ), R|<local>/a|, String(, ), R|<local>/b|)
|
<strcat>(String(This is test of ), R|<local>/a|, String(, ), R|<local>/b|)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
+2
-2
@@ -7,7 +7,7 @@ FILE: localObject.kt
|
|||||||
|
|
||||||
}
|
}
|
||||||
public final fun tesLambda(x: R|kotlin/Int|): R|kotlin/Int| {
|
public final fun tesLambda(x: R|kotlin/Int|): R|kotlin/Int| {
|
||||||
^tesLambda R|/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| {
|
^tesLambda R|/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
|
||||||
lval obj: R|Foo| = object : R|Foo| {
|
lval obj: R|Foo| = object : R|Foo| {
|
||||||
private constructor(): R|kotlin/Any| {
|
private constructor(): R|kotlin/Any| {
|
||||||
super<R|kotlin/Any|>()
|
super<R|kotlin/Any|>()
|
||||||
@@ -64,7 +64,7 @@ FILE: localObject.kt
|
|||||||
Int(1)
|
Int(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
public final val z: R|kotlin/Int| = R|/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| {
|
public final val z: R|kotlin/Int| = R|/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
|
||||||
lval obj: R|Foo| = object : R|Foo| {
|
lval obj: R|Foo| = object : R|Foo| {
|
||||||
private constructor(): R|kotlin/Any| {
|
private constructor(): R|kotlin/Any| {
|
||||||
super<R|kotlin/Any|>()
|
super<R|kotlin/Any|>()
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ FILE: components.kt
|
|||||||
lval <destruct>: R|D| = R|<local>/list|.R|kotlin/collections/first|<R|D|>()
|
lval <destruct>: R|D| = R|<local>/list|.R|kotlin/collections/first|<R|D|>()
|
||||||
lval x: R|kotlin/Int| = R|<local>/<destruct>|.R|/D.component1|()
|
lval x: R|kotlin/Int| = R|<local>/<destruct>|.R|/D.component1|()
|
||||||
lval y: R|kotlin/String| = R|<local>/<destruct>|.R|/D.component2|()
|
lval y: R|kotlin/String| = R|<local>/<destruct>|.R|/D.component2|()
|
||||||
R|<local>/list|.R|kotlin/collections/forEach|<R|D|>(<L> = forEach@fun <anonymous>(<destruct>: R|D|): R|kotlin/Unit| {
|
R|<local>/list|.R|kotlin/collections/forEach|<R|D|>(<L> = forEach@fun <anonymous>(<destruct>: R|D|): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
lval x: R|kotlin/Int| = R|<local>/<destruct>|.R|/D.component1|()
|
lval x: R|kotlin/Int| = R|<local>/<destruct>|.R|/D.component1|()
|
||||||
lval y: R|kotlin/String| = R|<local>/<destruct>|.R|/D.component2|()
|
lval y: R|kotlin/String| = R|<local>/<destruct>|.R|/D.component2|()
|
||||||
R|kotlin/io/println|(R|<local>/x|)
|
R|kotlin/io/println|(R|<local>/x|)
|
||||||
|
|||||||
@@ -28,16 +28,16 @@ FILE: implicitReceiverOrder.kt
|
|||||||
|
|
||||||
}
|
}
|
||||||
public final fun test(a: R|A|, b: R|B|): R|kotlin/Unit| {
|
public final fun test(a: R|A|, b: R|B|): R|kotlin/Unit| {
|
||||||
R|kotlin/with|<R|B|, R|kotlin/Int|>(R|<local>/b|, <L> = with@fun R|B|.<anonymous>(it: R|B|): R|kotlin/Unit| {
|
R|kotlin/with|<R|B|, R|kotlin/Int|>(R|<local>/b|, <L> = with@fun R|B|.<anonymous>(it: R|B|): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
R|kotlin/with|<R|A|, R|kotlin/Int|>(R|<local>/a|, <L> = with@fun R|A|.<anonymous>(it: R|A|): R|kotlin/Unit| {
|
R|kotlin/with|<R|A|, R|kotlin/Int|>(R|<local>/a|, <L> = with@fun R|A|.<anonymous>(it: R|A|): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
this@R|/A|.R|/A.foo|()
|
this@R|/A|.R|/A.foo|()
|
||||||
(this@R|/B|, this@R|special/anonymous|).R|/B.bar|()
|
(this@R|/B|, this@R|special/anonymous|).R|/B.bar|()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|kotlin/with|<R|A|, R|kotlin/Int|>(R|<local>/a|, <L> = with@fun R|A|.<anonymous>(it: R|A|): R|kotlin/Unit| {
|
R|kotlin/with|<R|A|, R|kotlin/Int|>(R|<local>/a|, <L> = with@fun R|A|.<anonymous>(it: R|A|): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
R|kotlin/with|<R|B|, R|kotlin/Int|>(R|<local>/b|, <L> = with@fun R|B|.<anonymous>(it: R|B|): R|kotlin/Unit| {
|
R|kotlin/with|<R|B|, R|kotlin/Int|>(R|<local>/b|, <L> = with@fun R|B|.<anonymous>(it: R|B|): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
this@R|/B|.R|/B.foo|()
|
this@R|/B|.R|/B.foo|()
|
||||||
(this@R|/A|, this@R|special/anonymous|).R|/A.bar|()
|
(this@R|/A|, this@R|special/anonymous|).R|/A.bar|()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
FILE: mapList.kt
|
FILE: mapList.kt
|
||||||
public final fun main(): R|kotlin/Unit| {
|
public final fun main(): R|kotlin/Unit| {
|
||||||
lval x: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/emptyList|<R|kotlin/Int|>()
|
lval x: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/emptyList|<R|kotlin/Int|>()
|
||||||
lval u: R|kotlin/collections/List<kotlin/Int>| = R|<local>/x|.R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| {
|
lval u: R|kotlin/collections/List<kotlin/Int>| = R|<local>/x|.R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <kind=EXACTLY_ONCE> {
|
||||||
R|<local>/it|.R|kotlin/Int.plus|(R|<local>/it|)
|
R|<local>/it|.R|kotlin/Int.plus|(R|<local>/it|)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|<local>/u|.R|/applyX|<R|kotlin/collections/List<kotlin/Int>|>(<L> = applyX@fun R|kotlin/collections/List<kotlin/Int>|.<anonymous>(it: R|kotlin/collections/List<kotlin/Int>|): R|kotlin/Unit| {
|
R|<local>/u|.R|/applyX|<R|kotlin/collections/List<kotlin/Int>|>(<L> = applyX@fun R|kotlin/collections/List<kotlin/Int>|.<anonymous>(it: R|kotlin/collections/List<kotlin/Int>|): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
this@R|special/anonymous|.R|FakeOverride<kotlin/collections/List.contains: R|kotlin/Boolean|>|(Int(1))
|
this@R|special/anonymous|.R|FakeOverride<kotlin/collections/List.contains: R|kotlin/Boolean|>|(Int(1))
|
||||||
this@R|kotlin/collections/List|.R|FakeOverride<kotlin/collections/List.contains: R|kotlin/Boolean|>|(Int(1))
|
this@R|kotlin/collections/List|.R|FakeOverride<kotlin/collections/List.contains: R|kotlin/Boolean|>|(Int(1))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ FILE: multipleImplicitReceivers.kt
|
|||||||
|
|
||||||
}
|
}
|
||||||
public final fun test(fooImpl: R|IFoo|, invokeImpl: R|IInvoke|): R|kotlin/Unit| {
|
public final fun test(fooImpl: R|IFoo|, invokeImpl: R|IInvoke|): R|kotlin/Unit| {
|
||||||
R|kotlin/with|<R|A|, R|kotlin/Int|>(Q|A|, <L> = with@fun R|A|.<anonymous>(it: R|A|): R|kotlin/Unit| {
|
R|kotlin/with|<R|A|, R|kotlin/Int|>(Q|A|, <L> = with@fun R|A|.<anonymous>(it: R|A|): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
R|kotlin/with|<R|IFoo|, R|kotlin/Int|>(R|<local>/fooImpl|, <L> = with@fun R|IFoo|.<anonymous>(it: R|IFoo|): R|kotlin/Unit| {
|
R|kotlin/with|<R|IFoo|, R|kotlin/Int|>(R|<local>/fooImpl|, <L> = with@fun R|IFoo|.<anonymous>(it: R|IFoo|): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
(this@R|/IFoo|, this@R|special/anonymous|).R|/IFoo.foo|
|
(this@R|/IFoo|, this@R|special/anonymous|).R|/IFoo.foo|
|
||||||
R|kotlin/with|<R|IInvoke|, R|kotlin/Int|>(R|<local>/invokeImpl|, <L> = with@fun R|IInvoke|.<anonymous>(it: R|IInvoke|): R|kotlin/Unit| {
|
R|kotlin/with|<R|IInvoke|, R|kotlin/Int|>(R|<local>/invokeImpl|, <L> = with@fun R|IInvoke|.<anonymous>(it: R|IInvoke|): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||||
(this@R|/IInvoke|, (this@R|/IFoo|, this@R|special/anonymous|).R|/IFoo.foo|).R|/IInvoke.invoke|()
|
(this@R|/IInvoke|, (this@R|/IFoo|, this@R|special/anonymous|).R|/IFoo.foo|).R|/IInvoke.invoke|()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ FILE: recursiveBug.kt
|
|||||||
super<R|kotlin/Any|>()
|
super<R|kotlin/Any|>()
|
||||||
}
|
}
|
||||||
|
|
||||||
public final val result: R|kotlin/String| = this@R|/Foo|.R|kotlin/run|<R|Foo|, R|kotlin/String|>(<L> = run@fun R|Foo|.<anonymous>(it: R|Foo|): R|kotlin/String| {
|
public final val result: R|kotlin/String| = this@R|/Foo|.R|kotlin/run|<R|Foo|, R|kotlin/String|>(<L> = run@fun R|Foo|.<anonymous>(it: R|Foo|): R|kotlin/String| <kind=EXACTLY_ONCE> {
|
||||||
R|<local>/name|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
R|<local>/name|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -15,7 +15,7 @@ FILE: recursiveBug.kt
|
|||||||
|
|
||||||
}
|
}
|
||||||
public final fun bar(name: R|kotlin/Function0<kotlin/String>|): R|kotlin/Unit| {
|
public final fun bar(name: R|kotlin/Function0<kotlin/String>|): R|kotlin/Unit| {
|
||||||
lval result: R|kotlin/String| = R|kotlin/run|<R|kotlin/String|>(<L> = run@fun <anonymous>(): R|kotlin/String| {
|
lval result: R|kotlin/String| = R|kotlin/run|<R|kotlin/String|>(<L> = run@fun <anonymous>(): R|kotlin/String| <kind=EXACTLY_ONCE> {
|
||||||
R|<local>/name|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
R|<local>/name|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
FILE: simpleLazy.kt
|
FILE: simpleLazy.kt
|
||||||
public final val x: R|kotlin/String|by R|kotlin/lazy|<R|kotlin/String|>(<L> = lazy@fun <anonymous>(): R|kotlin/String| {
|
public final val x: R|kotlin/String|by R|kotlin/lazy|<R|kotlin/String|>(<L> = lazy@fun <anonymous>(): R|kotlin/String| <kind=EXACTLY_ONCE> {
|
||||||
String(Hello)
|
String(Hello)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -8,7 +8,7 @@ FILE: simpleLazy.kt
|
|||||||
}
|
}
|
||||||
public final fun foo(): R|kotlin/Unit| {
|
public final fun foo(): R|kotlin/Unit| {
|
||||||
R|/x|.R|kotlin/String.length|
|
R|/x|.R|kotlin/String.length|
|
||||||
lval y: R|kotlin/String|by R|kotlin/lazy|<R|kotlin/String|>(<L> = lazy@fun <anonymous>(): R|kotlin/String| {
|
lval y: R|kotlin/String|by R|kotlin/lazy|<R|kotlin/String|>(<L> = lazy@fun <anonymous>(): R|kotlin/String| <kind=EXACTLY_ONCE> {
|
||||||
String(Bye)
|
String(Bye)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,24 +19,24 @@ FILE: topLevelResolve.kt
|
|||||||
^id R|<local>/arg|
|
^id R|<local>/arg|
|
||||||
}
|
}
|
||||||
public final fun testMap(): R|kotlin/Unit| {
|
public final fun testMap(): R|kotlin/Unit| {
|
||||||
lval first: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(1), Int(2), Int(3)).R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| {
|
lval first: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(1), Int(2), Int(3)).R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <kind=EXACTLY_ONCE> {
|
||||||
R|<local>/it|.R|kotlin/Int.times|(Int(2))
|
R|<local>/it|.R|kotlin/Int.times|(Int(2))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
lval second: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/intArrayOf|(Int(4), Int(5), Int(6)).R|kotlin/collections/map|<R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| {
|
lval second: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/intArrayOf|(Int(4), Int(5), Int(6)).R|kotlin/collections/map|<R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <kind=EXACTLY_ONCE> {
|
||||||
R|<local>/it|.R|kotlin/Int.times|(Int(2))
|
R|<local>/it|.R|kotlin/Int.times|(Int(2))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
lval withId: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(1), Int(2), Int(3)).R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| {
|
lval withId: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(1), Int(2), Int(3)).R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <kind=EXACTLY_ONCE> {
|
||||||
R|/id|<R|kotlin/Int|>(R|<local>/it|)
|
R|/id|<R|kotlin/Int|>(R|<local>/it|)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
lval stringToInt: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/String|>(String(alpha), String(omega)).R|kotlin/collections/map|<R|kotlin/String|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/String|): R|kotlin/Int| {
|
lval stringToInt: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/collections/listOf|<R|kotlin/String|>(String(alpha), String(omega)).R|kotlin/collections/map|<R|kotlin/String|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/String|): R|kotlin/Int| <kind=EXACTLY_ONCE> {
|
||||||
R|<local>/it|.R|kotlin/String.length|
|
R|<local>/it|.R|kotlin/String.length|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
lval viaWith: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/with|<R|kotlin/collections/List<kotlin/Int>|, R|kotlin/collections/List<kotlin/Int>|>(R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(42)), <L> = with@fun R|kotlin/collections/List<kotlin/Int>|.<anonymous>(it: R|kotlin/collections/List<kotlin/Int>|): R|kotlin/collections/List<kotlin/Int>| {
|
lval viaWith: R|kotlin/collections/List<kotlin/Int>| = R|kotlin/with|<R|kotlin/collections/List<kotlin/Int>|, R|kotlin/collections/List<kotlin/Int>|>(R|kotlin/collections/listOf|<R|kotlin/Int|>(Int(42)), <L> = with@fun R|kotlin/collections/List<kotlin/Int>|.<anonymous>(it: R|kotlin/collections/List<kotlin/Int>|): R|kotlin/collections/List<kotlin/Int>| <kind=EXACTLY_ONCE> {
|
||||||
this@R|special/anonymous|.R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| {
|
this@R|special/anonymous|.R|kotlin/collections/map|<R|kotlin/Int|, R|kotlin/Int|>(<L> = map@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| <kind=EXACTLY_ONCE> {
|
||||||
R|<local>/it|.R|kotlin/Int.times|(R|<local>/it|)
|
R|<local>/it|.R|kotlin/Int.times|(R|<local>/it|)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -44,11 +44,11 @@ FILE: topLevelResolve.kt
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
public final fun testWith(): R|kotlin/Unit| {
|
public final fun testWith(): R|kotlin/Unit| {
|
||||||
lval length: R|kotlin/Int| = R|kotlin/with|<R|kotlin/String|, R|kotlin/Int|>(String(), <L> = with@fun R|kotlin/String|.<anonymous>(it: R|kotlin/String|): R|kotlin/Int| {
|
lval length: R|kotlin/Int| = R|kotlin/with|<R|kotlin/String|, R|kotlin/Int|>(String(), <L> = with@fun R|kotlin/String|.<anonymous>(it: R|kotlin/String|): R|kotlin/Int| <kind=EXACTLY_ONCE> {
|
||||||
this@R|kotlin/String|.R|kotlin/String.length|
|
this@R|kotlin/String|.R|kotlin/String.length|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
lval indices: R|kotlin/ranges/IntRange| = R|kotlin/with|<R|kotlin/String|, R|kotlin/ranges/IntRange|>(String(), <L> = with@fun R|kotlin/String|.<anonymous>(it: R|kotlin/String|): R|kotlin/ranges/IntRange| {
|
lval indices: R|kotlin/ranges/IntRange| = R|kotlin/with|<R|kotlin/String|, R|kotlin/ranges/IntRange|>(String(), <L> = with@fun R|kotlin/String|.<anonymous>(it: R|kotlin/String|): R|kotlin/ranges/IntRange| <kind=EXACTLY_ONCE> {
|
||||||
this@R|special/anonymous|.R|kotlin/text/indices|
|
this@R|special/anonymous|.R|kotlin/text/indices|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ FILE: whenAsReceiver.kt
|
|||||||
Null(null)
|
Null(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?.<Inapplicable(WRONG_RECEIVER): [/also]>#(<L> = also@fun <implicit>.<anonymous>(): <implicit> {
|
?.<Inapplicable(WRONG_RECEIVER): [/also]>#(<L> = also@fun <implicit>.<anonymous>(): <implicit> <kind=EXACTLY_ONCE> {
|
||||||
Int(1)
|
Int(1)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -373,6 +373,9 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
|||||||
anonymousFunction.valueParameters.renderParameters()
|
anonymousFunction.valueParameters.renderParameters()
|
||||||
print(": ")
|
print(": ")
|
||||||
anonymousFunction.returnTypeRef.accept(this)
|
anonymousFunction.returnTypeRef.accept(this)
|
||||||
|
if (anonymousFunction.invocationKind != null) {
|
||||||
|
print(" <kind=${anonymousFunction.invocationKind}> ")
|
||||||
|
}
|
||||||
anonymousFunction.body?.renderBody()
|
anonymousFunction.body?.renderBody()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.fir.declarations
|
package org.jetbrains.kotlin.fir.declarations
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.contracts.description.InvocationKind
|
||||||
import org.jetbrains.kotlin.fir.FirLabeledElement
|
import org.jetbrains.kotlin.fir.FirLabeledElement
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.VisitedSupertype
|
import org.jetbrains.kotlin.fir.VisitedSupertype
|
||||||
@@ -26,6 +27,8 @@ abstract class FirAnonymousFunction(
|
|||||||
|
|
||||||
abstract override val controlFlowGraphReference: FirControlFlowGraphReference
|
abstract override val controlFlowGraphReference: FirControlFlowGraphReference
|
||||||
|
|
||||||
|
abstract val invocationKind: InvocationKind?
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R =
|
||||||
visitor.visitAnonymousFunction(this, data)
|
visitor.visitAnonymousFunction(this, data)
|
||||||
|
|
||||||
@@ -38,5 +41,7 @@ abstract class FirAnonymousFunction(
|
|||||||
|
|
||||||
abstract fun replaceReceiverTypeRef(receiverTypeRef: FirTypeRef)
|
abstract fun replaceReceiverTypeRef(receiverTypeRef: FirTypeRef)
|
||||||
|
|
||||||
|
abstract fun replaceInvocationKind(invocationKind: InvocationKind)
|
||||||
|
|
||||||
abstract override fun <D> transformControlFlowGraphReference(transformer: FirTransformer<D>, data: D): FirAnonymousFunction
|
abstract override fun <D> transformControlFlowGraphReference(transformer: FirTransformer<D>, data: D): FirAnonymousFunction
|
||||||
}
|
}
|
||||||
+7
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.fir.declarations.impl
|
package org.jetbrains.kotlin.fir.declarations.impl
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.contracts.description.InvocationKind
|
||||||
import org.jetbrains.kotlin.fir.*
|
import org.jetbrains.kotlin.fir.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||||
@@ -38,6 +39,8 @@ class FirAnonymousFunctionImpl(
|
|||||||
|
|
||||||
override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference()
|
override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference()
|
||||||
|
|
||||||
|
override var invocationKind: InvocationKind? = null
|
||||||
|
|
||||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
||||||
returnTypeRef = returnTypeRef.transformSingle(transformer, data)
|
returnTypeRef = returnTypeRef.transformSingle(transformer, data)
|
||||||
receiverTypeRef = receiverTypeRef?.transformSingle(transformer, data)
|
receiverTypeRef = receiverTypeRef?.transformSingle(transformer, data)
|
||||||
@@ -66,4 +69,8 @@ class FirAnonymousFunctionImpl(
|
|||||||
controlFlowGraphReference = controlFlowGraphReference.transformSingle(transformer, data)
|
controlFlowGraphReference = controlFlowGraphReference.transformSingle(transformer, data)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun replaceInvocationKind(invocationKind: InvocationKind) {
|
||||||
|
this.invocationKind = invocationKind
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user