diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/CopyUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/CopyUtils.kt index 37816e19331..1d9296a84ae 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/CopyUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/CopyUtils.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir 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.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter @@ -56,7 +57,8 @@ fun FirAnonymousFunction.copy( annotations: List = this.annotations, typeRef: FirTypeRef = this.typeRef, label: FirLabel? = this.label, - controlFlowGraphReference: FirControlFlowGraphReference = this.controlFlowGraphReference + controlFlowGraphReference: FirControlFlowGraphReference = this.controlFlowGraphReference, + invocationKind: InvocationKind? = this.invocationKind ): FirAnonymousFunction { return FirAnonymousFunctionImpl(session, psi, returnTypeRef, receiverTypeRef, symbol).apply { this.valueParameters.addAll(valueParameters) @@ -65,6 +67,7 @@ fun FirAnonymousFunction.copy( this.typeRef = typeRef this.label = label this.controlFlowGraphReference = controlFlowGraphReference + this.invocationKind = invocationKind } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt index a5fae6b74e1..466a592567e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers +import org.jetbrains.kotlin.contracts.description.InvocationKind import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor @@ -444,6 +445,7 @@ open class FirBodyResolveTransformer( storeTypeFromCallee(functionCall) } if (functionCall.calleeReference !is FirSimpleNamedReference) return functionCall.compose() + functionCall.transform(InvocationKindTransformer, null) val expectedTypeRef = data as FirTypeRef? val completeInference = try { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/InvocationKindTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/InvocationKindTransformer.kt new file mode 100644 index 00000000000..538fe971ac3 --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/InvocationKindTransformer.kt @@ -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() { + override fun transformElement(element: E, data: InvocationKind?): CompositeTransformResult { + return element.compose() + } + + override fun transformAnonymousFunction( + anonymousFunction: FirAnonymousFunction, + data: InvocationKind? + ): CompositeTransformResult { + if (data != null) { + anonymousFunction.replaceInvocationKind(data) + } + return anonymousFunction.compose() + } + + override fun transformLambdaArgumentExpression( + lambdaArgumentExpression: FirLambdaArgumentExpression, + data: InvocationKind? + ): CompositeTransformResult { + lambdaArgumentExpression.transformChildren(this, data) + return lambdaArgumentExpression.compose() + } + + override fun transformFunctionCall(functionCall: FirFunctionCall, data: InvocationKind?): CompositeTransformResult { + // TODO: add contracts handling + return (functionCall.transformChildren(this, InvocationKind.EXACTLY_ONCE) as FirFunctionCall).compose() + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/arguments/lambda.txt b/compiler/fir/resolve/testData/resolve/arguments/lambda.txt index 65b9430265d..05024d95752 100644 --- a/compiler/fir/resolve/testData/resolve/arguments/lambda.txt +++ b/compiler/fir/resolve/testData/resolve/arguments/lambda.txt @@ -6,38 +6,38 @@ FILE: lambda.kt public final fun baz(f: R|kotlin/Function0|, other: R|kotlin/Boolean| = Boolean(true)): R|kotlin/Unit| { } public final fun test(): R|kotlin/Unit| { - R|/foo|( = foo@fun (): R|kotlin/Unit| { + R|/foo|( = foo@fun (): R|kotlin/Unit| { Unit } ) - R|/foo|( = foo@fun (): R|kotlin/Unit| { + R|/foo|( = foo@fun (): R|kotlin/Unit| { Unit } ) - R|/foo|(foo@fun (): R|kotlin/Unit| { + R|/foo|(foo@fun (): R|kotlin/Unit| { Unit } ) - #(Int(1), = foo@fun .(): { + #(Int(1), = foo@fun .(): { Unit } ) #(f = foo@fun .(): { Unit } - , = foo@fun .(): { + , = foo@fun .(): { Unit } ) - R|/bar|(Int(1), = bar@fun (): R|kotlin/Unit| { + R|/bar|(Int(1), = bar@fun (): R|kotlin/Unit| { Unit } ) - R|/bar|(x = Int(1), = bar@fun (): R|kotlin/Unit| { + R|/bar|(x = Int(1), = bar@fun (): R|kotlin/Unit| { Unit } ) - R|/bar|(Int(1), bar@fun (): R|kotlin/Unit| { + R|/bar|(Int(1), bar@fun (): R|kotlin/Unit| { Unit } ) @@ -45,11 +45,11 @@ FILE: lambda.kt Unit } ) - #( = bar@fun .(): { + #( = bar@fun .(): { Unit } ) - #(bar@fun .(): { + #(bar@fun .(): { Unit } ) @@ -57,19 +57,19 @@ FILE: lambda.kt Unit } ) - R|/baz|(baz@fun (): R|kotlin/Unit| { + R|/baz|(baz@fun (): R|kotlin/Unit| { Unit } , Boolean(false)) - #( = baz@fun .(): { + #( = baz@fun .(): { Unit } ) - #( = baz@fun .(): { + #( = baz@fun .(): { Unit } ) - #(other = Boolean(false), = baz@fun .(): { + #(other = Boolean(false), = baz@fun .(): { Unit } ) diff --git a/compiler/fir/resolve/testData/resolve/expresssions/lambda.txt b/compiler/fir/resolve/testData/resolve/expresssions/lambda.txt index 1f0e228efc1..daffd0c978b 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/lambda.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/lambda.txt @@ -8,19 +8,19 @@ FILE: lambda.kt public final fun multipleArgs(block: R|kotlin/Function2|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - R|/foo|( = foo@fun (): R|kotlin/Unit| { + R|/foo|( = foo@fun (): R|kotlin/Unit| { String(This is test) } ) - R|/bar|( = bar@fun (): R|kotlin/String| { + R|/bar|( = bar@fun (): R|kotlin/String| { String(This is also test) } ) - R|/itIs|( = itIs@fun (it: R|kotlin/String|): R|kotlin/String| { + R|/itIs|( = itIs@fun (it: R|kotlin/String|): R|kotlin/String| { (String(this is ), R|/it|, String( test)) } ) - R|/multipleArgs|( = multipleArgs@fun (a: R|kotlin/String|, b: R|kotlin/String|): R|kotlin/String| { + R|/multipleArgs|( = multipleArgs@fun (a: R|kotlin/String|, b: R|kotlin/String|): R|kotlin/String| { (String(This is test of ), R|/a|, String(, ), R|/b|) } ) diff --git a/compiler/fir/resolve/testData/resolve/localObject.txt b/compiler/fir/resolve/testData/resolve/localObject.txt index 8b46686c66b..a6ee9e463b4 100644 --- a/compiler/fir/resolve/testData/resolve/localObject.txt +++ b/compiler/fir/resolve/testData/resolve/localObject.txt @@ -7,7 +7,7 @@ FILE: localObject.kt } public final fun tesLambda(x: R|kotlin/Int|): R|kotlin/Int| { - ^tesLambda R|/run|( = run@fun (): R|kotlin/Int| { + ^tesLambda R|/run|( = run@fun (): R|kotlin/Int| { lval obj: R|Foo| = object : R|Foo| { private constructor(): R|kotlin/Any| { super() @@ -64,7 +64,7 @@ FILE: localObject.kt Int(1) } - public final val z: R|kotlin/Int| = R|/run|( = run@fun (): R|kotlin/Int| { + public final val z: R|kotlin/Int| = R|/run|( = run@fun (): R|kotlin/Int| { lval obj: R|Foo| = object : R|Foo| { private constructor(): R|kotlin/Any| { super() diff --git a/compiler/fir/resolve/testData/resolve/stdlib/components.txt b/compiler/fir/resolve/testData/resolve/stdlib/components.txt index 6eb588ea118..e2d0effd69a 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/components.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/components.txt @@ -34,7 +34,7 @@ FILE: components.kt lval : R|D| = R|/list|.R|kotlin/collections/first|() lval x: R|kotlin/Int| = R|/|.R|/D.component1|() lval y: R|kotlin/String| = R|/|.R|/D.component2|() - R|/list|.R|kotlin/collections/forEach|( = forEach@fun (: R|D|): R|kotlin/Unit| { + R|/list|.R|kotlin/collections/forEach|( = forEach@fun (: R|D|): R|kotlin/Unit| { lval x: R|kotlin/Int| = R|/|.R|/D.component1|() lval y: R|kotlin/String| = R|/|.R|/D.component2|() R|kotlin/io/println|(R|/x|) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/implicitReceiverOrder.txt b/compiler/fir/resolve/testData/resolve/stdlib/implicitReceiverOrder.txt index 774e3590818..7c84a2976de 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/implicitReceiverOrder.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/implicitReceiverOrder.txt @@ -28,16 +28,16 @@ FILE: implicitReceiverOrder.kt } public final fun test(a: R|A|, b: R|B|): R|kotlin/Unit| { - R|kotlin/with|(R|/b|, = with@fun R|B|.(it: R|B|): R|kotlin/Unit| { - R|kotlin/with|(R|/a|, = with@fun R|A|.(it: R|A|): R|kotlin/Unit| { + R|kotlin/with|(R|/b|, = with@fun R|B|.(it: R|B|): R|kotlin/Unit| { + R|kotlin/with|(R|/a|, = with@fun R|A|.(it: R|A|): R|kotlin/Unit| { this@R|/A|.R|/A.foo|() (this@R|/B|, this@R|special/anonymous|).R|/B.bar|() } ) } ) - R|kotlin/with|(R|/a|, = with@fun R|A|.(it: R|A|): R|kotlin/Unit| { - R|kotlin/with|(R|/b|, = with@fun R|B|.(it: R|B|): R|kotlin/Unit| { + R|kotlin/with|(R|/a|, = with@fun R|A|.(it: R|A|): R|kotlin/Unit| { + R|kotlin/with|(R|/b|, = with@fun R|B|.(it: R|B|): R|kotlin/Unit| { this@R|/B|.R|/B.foo|() (this@R|/A|, this@R|special/anonymous|).R|/A.bar|() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/mapList.txt b/compiler/fir/resolve/testData/resolve/stdlib/mapList.txt index ad241979be8..3e3909584bc 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/mapList.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/mapList.txt @@ -1,11 +1,11 @@ FILE: mapList.kt public final fun main(): R|kotlin/Unit| { lval x: R|kotlin/collections/List| = R|kotlin/collections/emptyList|() - lval u: R|kotlin/collections/List| = R|/x|.R|kotlin/collections/map|( = map@fun (it: R|kotlin/Int|): R|kotlin/Int| { + lval u: R|kotlin/collections/List| = R|/x|.R|kotlin/collections/map|( = map@fun (it: R|kotlin/Int|): R|kotlin/Int| { R|/it|.R|kotlin/Int.plus|(R|/it|) } ) - R|/u|.R|/applyX||>( = applyX@fun R|kotlin/collections/List|.(it: R|kotlin/collections/List|): R|kotlin/Unit| { + R|/u|.R|/applyX||>( = applyX@fun R|kotlin/collections/List|.(it: R|kotlin/collections/List|): R|kotlin/Unit| { this@R|special/anonymous|.R|FakeOverride|(Int(1)) this@R|kotlin/collections/List|.R|FakeOverride|(Int(1)) } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/multipleImplicitReceivers.txt b/compiler/fir/resolve/testData/resolve/stdlib/multipleImplicitReceivers.txt index 1f14bd9b082..d0dbc2eb2cd 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/multipleImplicitReceivers.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/multipleImplicitReceivers.txt @@ -25,10 +25,10 @@ FILE: multipleImplicitReceivers.kt } public final fun test(fooImpl: R|IFoo|, invokeImpl: R|IInvoke|): R|kotlin/Unit| { - R|kotlin/with|(Q|A|, = with@fun R|A|.(it: R|A|): R|kotlin/Unit| { - R|kotlin/with|(R|/fooImpl|, = with@fun R|IFoo|.(it: R|IFoo|): R|kotlin/Unit| { + R|kotlin/with|(Q|A|, = with@fun R|A|.(it: R|A|): R|kotlin/Unit| { + R|kotlin/with|(R|/fooImpl|, = with@fun R|IFoo|.(it: R|IFoo|): R|kotlin/Unit| { (this@R|/IFoo|, this@R|special/anonymous|).R|/IFoo.foo| - R|kotlin/with|(R|/invokeImpl|, = with@fun R|IInvoke|.(it: R|IInvoke|): R|kotlin/Unit| { + R|kotlin/with|(R|/invokeImpl|, = with@fun R|IInvoke|.(it: R|IInvoke|): R|kotlin/Unit| { (this@R|/IInvoke|, (this@R|/IFoo|, this@R|special/anonymous|).R|/IFoo.foo|).R|/IInvoke.invoke|() } ) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/recursiveBug.txt b/compiler/fir/resolve/testData/resolve/stdlib/recursiveBug.txt index 51428cebd19..8d2452a314d 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/recursiveBug.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/recursiveBug.txt @@ -4,7 +4,7 @@ FILE: recursiveBug.kt super() } - public final val result: R|kotlin/String| = this@R|/Foo|.R|kotlin/run|( = run@fun R|Foo|.(it: R|Foo|): R|kotlin/String| { + public final val result: R|kotlin/String| = this@R|/Foo|.R|kotlin/run|( = run@fun R|Foo|.(it: R|Foo|): R|kotlin/String| { R|/name|.R|FakeOverride|() } ) @@ -15,7 +15,7 @@ FILE: recursiveBug.kt } public final fun bar(name: R|kotlin/Function0|): R|kotlin/Unit| { - lval result: R|kotlin/String| = R|kotlin/run|( = run@fun (): R|kotlin/String| { + lval result: R|kotlin/String| = R|kotlin/run|( = run@fun (): R|kotlin/String| { R|/name|.R|FakeOverride|() } ) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.txt b/compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.txt index c1d5a15e543..6097d568dff 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.txt @@ -1,5 +1,5 @@ FILE: simpleLazy.kt - public final val x: R|kotlin/String|by R|kotlin/lazy|( = lazy@fun (): R|kotlin/String| { + public final val x: R|kotlin/String|by R|kotlin/lazy|( = lazy@fun (): R|kotlin/String| { String(Hello) } ) @@ -8,7 +8,7 @@ FILE: simpleLazy.kt } public final fun foo(): R|kotlin/Unit| { R|/x|.R|kotlin/String.length| - lval y: R|kotlin/String|by R|kotlin/lazy|( = lazy@fun (): R|kotlin/String| { + lval y: R|kotlin/String|by R|kotlin/lazy|( = lazy@fun (): R|kotlin/String| { String(Bye) } ) diff --git a/compiler/fir/resolve/testData/resolve/stdlib/topLevelResolve.txt b/compiler/fir/resolve/testData/resolve/stdlib/topLevelResolve.txt index 0c2c94dd854..35b5fb04f97 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/topLevelResolve.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/topLevelResolve.txt @@ -19,24 +19,24 @@ FILE: topLevelResolve.kt ^id R|/arg| } public final fun testMap(): R|kotlin/Unit| { - lval first: R|kotlin/collections/List| = R|kotlin/collections/listOf|(Int(1), Int(2), Int(3)).R|kotlin/collections/map|( = map@fun (it: R|kotlin/Int|): R|kotlin/Int| { + lval first: R|kotlin/collections/List| = R|kotlin/collections/listOf|(Int(1), Int(2), Int(3)).R|kotlin/collections/map|( = map@fun (it: R|kotlin/Int|): R|kotlin/Int| { R|/it|.R|kotlin/Int.times|(Int(2)) } ) - lval second: R|kotlin/collections/List| = R|kotlin/intArrayOf|(Int(4), Int(5), Int(6)).R|kotlin/collections/map|( = map@fun (it: R|kotlin/Int|): R|kotlin/Int| { + lval second: R|kotlin/collections/List| = R|kotlin/intArrayOf|(Int(4), Int(5), Int(6)).R|kotlin/collections/map|( = map@fun (it: R|kotlin/Int|): R|kotlin/Int| { R|/it|.R|kotlin/Int.times|(Int(2)) } ) - lval withId: R|kotlin/collections/List| = R|kotlin/collections/listOf|(Int(1), Int(2), Int(3)).R|kotlin/collections/map|( = map@fun (it: R|kotlin/Int|): R|kotlin/Int| { + lval withId: R|kotlin/collections/List| = R|kotlin/collections/listOf|(Int(1), Int(2), Int(3)).R|kotlin/collections/map|( = map@fun (it: R|kotlin/Int|): R|kotlin/Int| { R|/id|(R|/it|) } ) - lval stringToInt: R|kotlin/collections/List| = R|kotlin/collections/listOf|(String(alpha), String(omega)).R|kotlin/collections/map|( = map@fun (it: R|kotlin/String|): R|kotlin/Int| { + lval stringToInt: R|kotlin/collections/List| = R|kotlin/collections/listOf|(String(alpha), String(omega)).R|kotlin/collections/map|( = map@fun (it: R|kotlin/String|): R|kotlin/Int| { R|/it|.R|kotlin/String.length| } ) - lval viaWith: R|kotlin/collections/List| = R|kotlin/with||, R|kotlin/collections/List|>(R|kotlin/collections/listOf|(Int(42)), = with@fun R|kotlin/collections/List|.(it: R|kotlin/collections/List|): R|kotlin/collections/List| { - this@R|special/anonymous|.R|kotlin/collections/map|( = map@fun (it: R|kotlin/Int|): R|kotlin/Int| { + lval viaWith: R|kotlin/collections/List| = R|kotlin/with||, R|kotlin/collections/List|>(R|kotlin/collections/listOf|(Int(42)), = with@fun R|kotlin/collections/List|.(it: R|kotlin/collections/List|): R|kotlin/collections/List| { + this@R|special/anonymous|.R|kotlin/collections/map|( = map@fun (it: R|kotlin/Int|): R|kotlin/Int| { R|/it|.R|kotlin/Int.times|(R|/it|) } ) @@ -44,11 +44,11 @@ FILE: topLevelResolve.kt ) } public final fun testWith(): R|kotlin/Unit| { - lval length: R|kotlin/Int| = R|kotlin/with|(String(), = with@fun R|kotlin/String|.(it: R|kotlin/String|): R|kotlin/Int| { + lval length: R|kotlin/Int| = R|kotlin/with|(String(), = with@fun R|kotlin/String|.(it: R|kotlin/String|): R|kotlin/Int| { this@R|kotlin/String|.R|kotlin/String.length| } ) - lval indices: R|kotlin/ranges/IntRange| = R|kotlin/with|(String(), = with@fun R|kotlin/String|.(it: R|kotlin/String|): R|kotlin/ranges/IntRange| { + lval indices: R|kotlin/ranges/IntRange| = R|kotlin/with|(String(), = with@fun R|kotlin/String|.(it: R|kotlin/String|): R|kotlin/ranges/IntRange| { this@R|special/anonymous|.R|kotlin/text/indices| } ) diff --git a/compiler/fir/resolve/testData/resolve/whenAsReceiver.txt b/compiler/fir/resolve/testData/resolve/whenAsReceiver.txt index 44cc5930a8f..f79f2abf9cf 100644 --- a/compiler/fir/resolve/testData/resolve/whenAsReceiver.txt +++ b/compiler/fir/resolve/testData/resolve/whenAsReceiver.txt @@ -19,7 +19,7 @@ FILE: whenAsReceiver.kt Null(null) } } - ?.#( = also@fun .(): { + ?.#( = also@fun .(): { Int(1) } ) 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 57f57078dff..2081492e889 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -373,6 +373,9 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { anonymousFunction.valueParameters.renderParameters() print(": ") anonymousFunction.returnTypeRef.accept(this) + if (anonymousFunction.invocationKind != null) { + print(" ") + } anonymousFunction.body?.renderBody() } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt index a8c5c2d937e..e299a2806c4 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/FirAnonymousFunction.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.declarations import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.contracts.description.InvocationKind import org.jetbrains.kotlin.fir.FirLabeledElement import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.VisitedSupertype @@ -26,6 +27,8 @@ abstract class FirAnonymousFunction( abstract override val controlFlowGraphReference: FirControlFlowGraphReference + abstract val invocationKind: InvocationKind? + override fun accept(visitor: FirVisitor, data: D): R = visitor.visitAnonymousFunction(this, data) @@ -38,5 +41,7 @@ abstract class FirAnonymousFunction( abstract fun replaceReceiverTypeRef(receiverTypeRef: FirTypeRef) + abstract fun replaceInvocationKind(invocationKind: InvocationKind) + abstract override fun transformControlFlowGraphReference(transformer: FirTransformer, data: D): FirAnonymousFunction } \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt index 126e74da282..a1db98c63fb 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/declarations/impl/FirAnonymousFunctionImpl.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.declarations.impl import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.contracts.description.InvocationKind import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.declarations.FirResolvePhase @@ -38,6 +39,8 @@ class FirAnonymousFunctionImpl( override var controlFlowGraphReference: FirControlFlowGraphReference = FirEmptyControlFlowGraphReference() + override var invocationKind: InvocationKind? = null + override fun transformChildren(transformer: FirTransformer, data: D): FirElement { returnTypeRef = returnTypeRef.transformSingle(transformer, data) receiverTypeRef = receiverTypeRef?.transformSingle(transformer, data) @@ -66,4 +69,8 @@ class FirAnonymousFunctionImpl( controlFlowGraphReference = controlFlowGraphReference.transformSingle(transformer, data) return this } + + override fun replaceInvocationKind(invocationKind: InvocationKind) { + this.invocationKind = invocationKind + } } \ No newline at end of file