From 57f1eac9a8fb7cc43349ec3b0b95e8718e6f1829 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 24 Oct 2019 18:16:54 +0300 Subject: [PATCH] [FIR] Support CallsInPlace effects --- .../dfa/cfg/ControlFlowGraphBuilder.kt | 24 +- .../fir/resolve/inference/FirCallCompleter.kt | 2 + .../transformers/InvocationKindTransformer.kt | 104 +++-- .../FirExpressionsResolveTransformer.kt | 9 +- ...leReferenceDependingOnInferredReceiver.txt | 4 +- .../diagnostics/j+k/FunctionTypeInJava.txt | 8 +- .../testData/diagnostics/j+k/MyMap.txt | 12 +- .../samConstructors/genericSam.txt | 6 +- .../genericSamInferenceFromExpectType.txt | 10 +- .../diagnostics/samConstructors/kotlinSam.txt | 4 +- .../realConstructorFunction.txt | 4 +- .../diagnostics/samConstructors/runnable.txt | 2 +- .../diagnostics/samConstructors/simple.txt | 4 +- .../diagnostics/samConversions/genericSam.txt | 10 +- .../diagnostics/samConversions/kotlinSam.txt | 8 +- .../notSamBecauseOfSupertype.txt | 4 +- .../diagnostics/samConversions/runnable.txt | 4 +- .../samConversions/samSupertype.txt | 4 +- .../samSupertypeWithOverride.txt | 4 +- .../diagnostics/samConversions/simple.txt | 4 +- .../testData/resolve/arguments/lambda.txt | 34 +- .../resolve/testData/resolve/cfg/complex.dot | 2 +- .../resolve/testData/resolve/cfg/complex.txt | 2 +- .../resolve/testData/resolve/cfg/jumps.dot | 6 +- .../fir/resolve/testData/resolve/cfg/jumps.kt | 2 +- .../resolve/testData/resolve/cfg/jumps.txt | 4 +- .../resolve/testData/resolve/cfg/lambdas.dot | 44 +- .../resolve/testData/resolve/cfg/lambdas.kt | 4 +- .../resolve/testData/resolve/cfg/lambdas.txt | 10 +- .../resolve/cfg/propertiesAndInitBlocks.dot | 12 +- .../resolve/cfg/propertiesAndInitBlocks.kt | 2 +- .../resolve/cfg/propertiesAndInitBlocks.txt | 4 +- .../extensionPropertyInLambda.txt | 2 +- .../testData/resolve/expresssions/lambda.txt | 8 +- .../resolve/testData/resolve/localObject.txt | 4 +- .../resolve/smartcasts/inPlaceLambdas.dot | 18 +- .../resolve/smartcasts/inPlaceLambdas.kt | 2 +- .../resolve/smartcasts/inPlaceLambdas.txt | 8 +- .../testData/resolve/stdlib/components.txt | 2 +- .../resolve/stdlib/contracts/callsInPlace.dot | 399 ++++++++++++++++++ .../resolve/stdlib/contracts/callsInPlace.kt | 52 +++ .../resolve/stdlib/contracts/callsInPlace.txt | 66 +++ .../testData/resolve/stdlib/mapList.txt | 4 +- .../testData/resolve/stdlib/simpleLazy.txt | 4 +- .../resolve/stdlib/topLevelResolve.txt | 10 +- .../testData/resolve/whenAsReceiver.txt | 2 +- .../AbstractFirCfgBuildingWithStdlibTest.kt | 16 + ...FirCfgBuildingWithStdlibTestGenerated.java | 35 ++ ...FirResolveTestCaseWithStdlibGenerated.java | 2 +- .../generators/tests/GenerateCompilerTests.kt | 12 +- 50 files changed, 808 insertions(+), 195 deletions(-) create mode 100644 compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.dot create mode 100644 compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.kt create mode 100644 compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.txt create mode 100644 compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirCfgBuildingWithStdlibTest.kt create mode 100644 compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirCfgBuildingWithStdlibTestGenerated.java 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 c034cebe54f..ff491c11dfb 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 @@ -24,6 +24,7 @@ class ControlFlowGraphBuilder { private val exitNodes: Stack> = stackOf() + private val functionEnterNodes: SymbolBasedNodeStorage, FunctionEnterNode> = SymbolBasedNodeStorage() private val functionExitNodes: SymbolBasedNodeStorage, FunctionExitNode> = SymbolBasedNodeStorage() private val whenExitNodes: NodeStorage = NodeStorage() @@ -86,17 +87,14 @@ class ControlFlowGraphBuilder { @Suppress("NON_EXHAUSTIVE_WHEN") when (invocationKind) { - InvocationKind.AT_LEAST_ONCE -> addEdge(exitNode, enterNode) - InvocationKind.AT_MOST_ONCE -> addEdge(enterNode, exitNode) - InvocationKind.UNKNOWN -> { - addEdge(exitNode, enterNode) - addEdge(enterNode, exitNode) - } + InvocationKind.AT_MOST_ONCE, InvocationKind.UNKNOWN -> addEdge(enterNode, exitNode) } functionExitNodes.push(exitNode) if (!isInplace) { exitNodes.push(exitNode) + } else { + functionEnterNodes.push(enterNode) } levelCounter++ return enterNode to previousNode @@ -105,12 +103,17 @@ class ControlFlowGraphBuilder { fun exitFunction(function: FirFunction<*>): Pair { levelCounter-- val exitNode = functionExitNodes.pop() - val isInplace = function.isInplace() + val invocationKind = function.invocationKind + val isInplace = invocationKind != null if (!isInplace) { exitNodes.pop() } if (isInplace) { addNewSimpleNode(exitNode) + val enterNode = functionEnterNodes.pop() + when (invocationKind) { + InvocationKind.AT_LEAST_ONCE, InvocationKind.UNKNOWN -> addEdge(exitNode, enterNode, propagateDeadness = false) + } } else { addEdge(lastNodes.pop(), exitNode) lexicalScopes.pop() @@ -615,11 +618,6 @@ class ControlFlowGraphBuilder { get() = (this as? FirAnonymousFunction)?.invocationKind private fun InvocationKind?.isInplace(): Boolean { - return this != null && this != InvocationKind.UNKNOWN - } - - private fun FirFunction<*>.isInplace(): Boolean { - val invocationKind = this.invocationKind - return invocationKind != null && invocationKind != InvocationKind.UNKNOWN + return this != null } } \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt index c18d8210c87..d7d91ebb22a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.calls.* import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.transformers.FirCallCompletionResultsWriterTransformer +import org.jetbrains.kotlin.fir.resolve.transformers.InvocationKindTransformer import org.jetbrains.kotlin.fir.resolve.transformers.MapArguments import org.jetbrains.kotlin.fir.resolve.transformers.StoreType import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirAbstractBodyResolveTransformer @@ -76,6 +77,7 @@ class FirCallCompleter( transformer.components.callResolver ) + call.transformSingle(InvocationKindTransformer, null) completer.complete(candidate.system.asConstraintSystemCompleterContext(), completionMode, listOf(call), initialType) { analyzer.analyze(candidate.system.asPostponedArgumentsAnalyzerContext(), it) } 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 index 607c1b52c72..ca305c86f22 100644 --- 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 @@ -7,49 +7,87 @@ 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.contracts.description.ConeCallsEffectDeclaration 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.FirNamedArgumentExpression -import org.jetbrains.kotlin.fir.expressions.FirStatement +import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction +import org.jetbrains.kotlin.fir.declarations.isInline +import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate 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 { +object InvocationKindTransformer : FirTransformer() { + private object ArgumentsTransformer : FirTransformer, InvocationKind?>>() { + override fun transformElement(element: E, data: Pair, InvocationKind?>): CompositeTransformResult { + return element.compose() + } + + override fun transformAnonymousFunction( + anonymousFunction: FirAnonymousFunction, + data: Pair, InvocationKind?> + ): CompositeTransformResult { + val kind = data.second ?: data.first[anonymousFunction] + if (kind != null) { + anonymousFunction.replaceInvocationKind(kind) + } + return anonymousFunction.compose() + } + + override fun transformLambdaArgumentExpression( + lambdaArgumentExpression: FirLambdaArgumentExpression, + data: Pair, InvocationKind?> + ): CompositeTransformResult { + return data.first[lambdaArgumentExpression]?.let { + (lambdaArgumentExpression.transformChildren(this, data.first to it) as FirStatement).compose() + } ?: lambdaArgumentExpression.compose() + } + + override fun transformNamedArgumentExpression( + namedArgumentExpression: FirNamedArgumentExpression, + data: Pair, InvocationKind?> + ): CompositeTransformResult { + return data.first[namedArgumentExpression]?.let { + (namedArgumentExpression.transformChildren(this, data.first to it) as FirStatement).compose() + } ?: namedArgumentExpression.compose() + } + } + + override fun transformElement(element: E, data: Nothing?): CompositeTransformResult { return element.compose() } - override fun transformAnonymousFunction( - anonymousFunction: FirAnonymousFunction, - data: InvocationKind? - ): CompositeTransformResult { - if (data != null) { - anonymousFunction.replaceInvocationKind(data) + override fun transformFunctionCall(functionCall: FirFunctionCall, data: Nothing?): CompositeTransformResult { + val calleeReference = functionCall.calleeReference as? FirNamedReferenceWithCandidate ?: return functionCall.compose() + val argumentMapping = calleeReference.candidate.argumentMapping ?: return functionCall.compose() + val function = calleeReference.candidateSymbol.fir as? FirSimpleFunction ?: return functionCall.compose() + + val callsEffects = function.contractDescription.effects.filterIsInstance() + + val isInline = function.isInline + if (callsEffects.isEmpty() && !isInline) { + return functionCall.compose() } - return anonymousFunction.compose() - } - override fun transformLambdaArgumentExpression( - lambdaArgumentExpression: FirLambdaArgumentExpression, - data: InvocationKind? - ): CompositeTransformResult { - lambdaArgumentExpression.transformChildren(this, data) - return lambdaArgumentExpression.compose() - } + val reversedArgumentMapping = argumentMapping.entries.map { (argument, parameter) -> + parameter to argument + }.toMap() - override fun transformNamedArgumentExpression( - namedArgumentExpression: FirNamedArgumentExpression, - data: InvocationKind? - ): CompositeTransformResult { - namedArgumentExpression.transformChildren(this, data) - return namedArgumentExpression.compose() - } - - override fun transformFunctionCall(functionCall: FirFunctionCall, data: InvocationKind?): CompositeTransformResult { - // TODO: add contracts handling and inline handling - return (functionCall.transformChildren(this, InvocationKind.EXACTLY_ONCE) as FirFunctionCall).compose() + val invocationKindMapping = mutableMapOf() + for (effect in callsEffects) { + // TODO: Support callsInPlace contracts on receivers + val valueParameter = function.valueParameters.getOrNull(effect.valueParameterReference.parameterIndex) ?: continue + val argument = reversedArgumentMapping[valueParameter] ?: continue + invocationKindMapping[argument] = effect.kind + } + if (isInline) { + for (argument in functionCall.arguments) { + invocationKindMapping.putIfAbsent(argument, InvocationKind.UNKNOWN) + } + } + if (invocationKindMapping.isEmpty()) { + return functionCall.compose() + } + return functionCall.transformArguments(ArgumentsTransformer, invocationKindMapping to null).compose() } } \ No newline at end of file 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 303c09159e3..17cbc2ef254 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 @@ -6,8 +6,8 @@ package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve import org.jetbrains.kotlin.contracts.description.InvocationKind -import org.jetbrains.kotlin.fir.BuiltinTypes -import org.jetbrains.kotlin.fir.FirCallResolver +import org.jetbrains.kotlin.fir.* +import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionWithSmartcastImpl import org.jetbrains.kotlin.fir.references.FirDelegateFieldReference @@ -34,6 +34,7 @@ import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl import org.jetbrains.kotlin.fir.types.impl.FirImplicitUnitTypeRef import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult +import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.fir.visitors.compose import org.jetbrains.kotlin.fir.visitors.transformSingle import org.jetbrains.kotlin.ir.expressions.IrConstKind @@ -126,12 +127,12 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : } override fun transformFunctionCall(functionCall: FirFunctionCall, data: Any?): CompositeTransformResult { - dataFlowAnalyzer.enterFunctionCall(functionCall) if (functionCall.calleeReference is FirResolvedNamedReference && functionCall.resultType is FirImplicitTypeRef) { storeTypeFromCallee(functionCall) } + dataFlowAnalyzer.enterFunctionCall(functionCall) if (functionCall.calleeReference !is FirSimpleNamedReference) return functionCall.compose() - functionCall.transform(InvocationKindTransformer, null) + functionCall.transform(InvocationKindTransformer, null) val expectedTypeRef = data as FirTypeRef? val completeInference = try { diff --git a/compiler/fir/resolve/testData/diagnostics/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt b/compiler/fir/resolve/testData/diagnostics/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt index e718a2f51d4..7dca31be72c 100644 --- a/compiler/fir/resolve/testData/diagnostics/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt +++ b/compiler/fir/resolve/testData/diagnostics/callableReferences/fromBasicDiagnosticTests/chooseCallableReferenceDependingOnInferredReceiver.txt @@ -30,10 +30,10 @@ FILE: chooseCallableReferenceDependingOnInferredReceiver.kt ^bar R|kotlin/TODO|() } public final fun test(): R|kotlin/Unit| { - R|/myWith|(R|/A.A|(), = myWith@fun (it: R|A|): R|kotlin/Unit| { + R|/myWith|(R|/A.A|(), = myWith@fun (it: R|A|): R|kotlin/Unit| { lval t1: = #(::foo#) lval t2: = #(::baz#) - R|/myWith|(R|/B.B|(), = myWith@fun (it: R|B|): R|kotlin/Unit| { + R|/myWith|(R|/B.B|(), = myWith@fun (it: R|B|): R|kotlin/Unit| { lval a: R|A| = #(::foo#) lval b: R|B| = #(::foo#) lval t3: = #(::baz#) diff --git a/compiler/fir/resolve/testData/diagnostics/j+k/FunctionTypeInJava.txt b/compiler/fir/resolve/testData/diagnostics/j+k/FunctionTypeInJava.txt index be502954ad8..606141f70ec 100644 --- a/compiler/fir/resolve/testData/diagnostics/j+k/FunctionTypeInJava.txt +++ b/compiler/fir/resolve/testData/diagnostics/j+k/FunctionTypeInJava.txt @@ -1,14 +1,14 @@ FILE: main.kt public final fun main(): R|kotlin/Unit| { - Q|JavaClass|.R|/JavaClass.foo1|( = foo1@fun (): R|ft!| { + Q|JavaClass|.R|/JavaClass.foo1|( = foo1@fun (): R|ft!| { Int(123) } ) - Q|JavaClass|.R|/JavaClass.foo2|( = foo2@fun (it: R|ft!|): R|ft!| { + Q|JavaClass|.R|/JavaClass.foo2|( = foo2@fun (it: R|ft!|): R|ft!| { R|/it|.R|kotlin/Int.plus|(Int(2)).R|kotlin/Any.toString|() } ) - Q|JavaClass|.R|/JavaClass.foo2|(foo2@fun (it: R|ft!|): R|ft!| { + Q|JavaClass|.R|/JavaClass.foo2|(foo2@fun (it: R|ft!|): R|ft!| { R|/it|.R|kotlin/Int.plus|(Int(3)).R|kotlin/Any.toString|() } ) @@ -17,7 +17,7 @@ FILE: main.kt } Q|JavaClass|.R|/JavaClass.foo2|(R|/y|) - Q|JavaClass|.R|/JavaClass.foo3||>(foo3@fun (it: R|ft|): R|ft!| { + Q|JavaClass|.R|/JavaClass.foo3||>(foo3@fun (it: R|ft|): R|ft!| { R|/it|.R|kotlin/Int.plus|(Int(4)).R|kotlin/Any.toString|() } , Int(5)) diff --git a/compiler/fir/resolve/testData/diagnostics/j+k/MyMap.txt b/compiler/fir/resolve/testData/diagnostics/j+k/MyMap.txt index 199ffd120b4..212bffd2edf 100644 --- a/compiler/fir/resolve/testData/diagnostics/j+k/MyMap.txt +++ b/compiler/fir/resolve/testData/diagnostics/j+k/MyMap.txt @@ -1,16 +1,16 @@ FILE: test.kt public final fun test(map: R|MyMap|): R|kotlin/Unit| { - lval result: R|kotlin/String| = R|/map|.R|kotlin/collections/getOrPut|(String(key), = getOrPut@fun (): R|kotlin/String| { + lval result: R|kotlin/String| = R|/map|.R|kotlin/collections/getOrPut|(String(key), = getOrPut@fun (): R|kotlin/String| { String(value) } ) lval otherResult: R|kotlin/String| = R|/map|.R|FakeOverride|(String(key), String(value)) lval anotherResult: = R|/map|.#(String(key), String(value)) - R|/map|.R|kotlin/collections/forEach|( = forEach@fun (key: R|kotlin/collections/Map.Entry|, value: R|kotlin/Any?|): R|kotlin/Unit| { + R|/map|.R|kotlin/collections/forEach|( = forEach@fun (key: R|kotlin/collections/Map.Entry|, value: R|kotlin/Any?|): R|kotlin/Unit| { R|kotlin/io/println|((R|/key|, String(: ), R|/value|)) } ) - R|/map|.R|kotlin/collections/forEach|( = forEach@fun (: R|kotlin/collections/Map.Entry|): R|kotlin/Unit| { + R|/map|.R|kotlin/collections/forEach|( = forEach@fun (: R|kotlin/collections/Map.Entry|): R|kotlin/Unit| { lval key: R|kotlin/String| = R|/|.R|kotlin/collections/component1|() lval value: R|kotlin/String| = R|/|.R|kotlin/collections/component2|() R|kotlin/io/println|((R|/key|, String(: ), R|/value|)) @@ -18,17 +18,17 @@ FILE: test.kt ) } public final fun test(map: R|kotlin/collections/MutableMap|): R|kotlin/Unit| { - lval result: R|kotlin/String| = R|/map|.R|kotlin/collections/getOrPut|(String(key), = getOrPut@fun (): R|kotlin/String| { + lval result: R|kotlin/String| = R|/map|.R|kotlin/collections/getOrPut|(String(key), = getOrPut@fun (): R|kotlin/String| { String(value) } ) lval otherResult: R|kotlin/String| = R|/map|.R|FakeOverride|(String(key), String(value)) lval anotherResult: = R|/map|.#(String(key), String(value)) - R|/map|.R|kotlin/collections/forEach|( = forEach@fun (key: R|kotlin/collections/Map.Entry|, value: R|kotlin/Any?|): R|kotlin/Unit| { + R|/map|.R|kotlin/collections/forEach|( = forEach@fun (key: R|kotlin/collections/Map.Entry|, value: R|kotlin/Any?|): R|kotlin/Unit| { R|kotlin/io/println|((R|/key|, String(: ), R|/value|)) } ) - R|/map|.R|kotlin/collections/forEach|( = forEach@fun (: R|kotlin/collections/Map.Entry|): R|kotlin/Unit| { + R|/map|.R|kotlin/collections/forEach|( = forEach@fun (: R|kotlin/collections/Map.Entry|): R|kotlin/Unit| { lval key: R|kotlin/String| = R|/|.R|kotlin/collections/component1|() lval value: R|kotlin/String| = R|/|.R|kotlin/collections/component2|() R|kotlin/io/println|((R|/key|, String(: ), R|/value|)) diff --git a/compiler/fir/resolve/testData/diagnostics/samConstructors/genericSam.txt b/compiler/fir/resolve/testData/diagnostics/samConstructors/genericSam.txt index c59652481d7..1a4a5cc8e4a 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConstructors/genericSam.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConstructors/genericSam.txt @@ -1,14 +1,14 @@ FILE: main.kt public final fun main(): R|kotlin/Unit| { - R|/MyFunction|( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { + R|/MyFunction|( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { R|/x|.R|kotlin/Int.toInt|().R|kotlin/Any.toString|() } ) - R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { + R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { R|/x|.R|kotlin/Any.toString|() } ) - R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Any?|): R|kotlin/String| { + R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Any?|): R|kotlin/String| { String() } ) diff --git a/compiler/fir/resolve/testData/diagnostics/samConstructors/genericSamInferenceFromExpectType.txt b/compiler/fir/resolve/testData/diagnostics/samConstructors/genericSamInferenceFromExpectType.txt index 1dc463f7c03..06cf1b4937f 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConstructors/genericSamInferenceFromExpectType.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConstructors/genericSamInferenceFromExpectType.txt @@ -6,23 +6,23 @@ FILE: main.kt public final fun foo3(f: R|MyFunction|, x: R|X|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - R|/foo1|(R|/MyFunction|( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { + R|/foo1|(R|/MyFunction|( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { R|/x|.R|kotlin/Int.toInt|().R|kotlin/Any.toString|() } )) - R|/foo2|(R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Number|): R|kotlin/String| { + R|/foo2|(R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Number|): R|kotlin/String| { R|/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|() } )) - R|/foo2|(R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { + R|/foo2|(R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { R|/x|.R|kotlin/Any.toString|() } )) - R|/foo3||>(R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { + R|/foo3||>(R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { R|/x|.R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|() } ), Int(1)) - R|/foo3||>(R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Number|): R|kotlin/String| { + R|/foo3||>(R|/MyFunction||>( = MyFunction@fun (x: R|kotlin/Number|): R|kotlin/String| { R|/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|() } ), Int(2)) diff --git a/compiler/fir/resolve/testData/diagnostics/samConstructors/kotlinSam.txt b/compiler/fir/resolve/testData/diagnostics/samConstructors/kotlinSam.txt index 381c746a761..2cfab1b83ce 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConstructors/kotlinSam.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConstructors/kotlinSam.txt @@ -6,11 +6,11 @@ FILE: kotlinSam.kt public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - R|/foo|(R|/MyRunnable|( = MyRunnable@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + R|/foo|(R|/MyRunnable|( = MyRunnable@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } )) - R|/foo|(R|/MyRunnable|(MyRunnable@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { + R|/foo|(R|/MyRunnable|(MyRunnable@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/it|, Int(1)) } )) diff --git a/compiler/fir/resolve/testData/diagnostics/samConstructors/realConstructorFunction.txt b/compiler/fir/resolve/testData/diagnostics/samConstructors/realConstructorFunction.txt index 875ae75236b..078bb610892 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConstructors/realConstructorFunction.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConstructors/realConstructorFunction.txt @@ -5,11 +5,11 @@ FILE: main.kt ^MyRunnable Int(1) } public final fun main(): R|kotlin/Unit| { - #(R|/MyRunnable|( = MyRunnable@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + #(R|/MyRunnable|( = MyRunnable@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } )) - #(R|/MyRunnable|(MyRunnable@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { + #(R|/MyRunnable|(MyRunnable@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/it|, Int(1)) } )) diff --git a/compiler/fir/resolve/testData/diagnostics/samConstructors/runnable.txt b/compiler/fir/resolve/testData/diagnostics/samConstructors/runnable.txt index ef3b5298228..b67de7af5bb 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConstructors/runnable.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConstructors/runnable.txt @@ -2,7 +2,7 @@ FILE: runnable.kt public final fun foo(runnable: R|java/lang/Runnable|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - R|/foo|(R|java/lang/Runnable|( = Runnable@fun (): R|kotlin/Unit| { + R|/foo|(R|java/lang/Runnable|( = Runnable@fun (): R|kotlin/Unit| { Unit } )) diff --git a/compiler/fir/resolve/testData/diagnostics/samConstructors/simple.txt b/compiler/fir/resolve/testData/diagnostics/samConstructors/simple.txt index b637733d6b6..de422dd674b 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConstructors/simple.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConstructors/simple.txt @@ -2,11 +2,11 @@ FILE: main.kt public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - R|/foo|(R|/MyRunnable|( = MyRunnable@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + R|/foo|(R|/MyRunnable|( = MyRunnable@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } )) - R|/foo|(R|/MyRunnable|(MyRunnable@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { + R|/foo|(R|/MyRunnable|(MyRunnable@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/it|, Int(1)) } )) diff --git a/compiler/fir/resolve/testData/diagnostics/samConversions/genericSam.txt b/compiler/fir/resolve/testData/diagnostics/samConversions/genericSam.txt index ae7a7846557..20000fa9ccc 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConversions/genericSam.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConversions/genericSam.txt @@ -1,22 +1,22 @@ FILE: main.kt public final fun main(): R|kotlin/Unit| { - Q|JavaUsage|.R|/JavaUsage.foo1|( = foo1@fun (x: R|ft!|): R|ft!| { + Q|JavaUsage|.R|/JavaUsage.foo1|( = foo1@fun (x: R|ft!|): R|ft!| { R|/x|.R|kotlin/Int.toInt|().R|kotlin/Any.toString|() } ) - Q|JavaUsage|.R|/JavaUsage.foo2|( = foo2@fun (x: R|ft!|): R|ft!| { + Q|JavaUsage|.R|/JavaUsage.foo2|( = foo2@fun (x: R|ft!|): R|ft!| { R|/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|() } ) - Q|JavaUsage|.R|/JavaUsage.foo2|( = foo2@fun (x: R|kotlin/Int|): R|ft!| { + Q|JavaUsage|.R|/JavaUsage.foo2|( = foo2@fun (x: R|kotlin/Int|): R|ft!| { R|/x|.R|kotlin/Any.toString|() } ) - Q|JavaUsage|.R|/JavaUsage.foo3||, R|ft|>(foo3@fun (x: R|ft|): R|kotlin/Unit| { + Q|JavaUsage|.R|/JavaUsage.foo3||, R|ft|>(foo3@fun (x: R|ft|): R|kotlin/Unit| { R|/x|.R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|() } , Int(1)) - Q|JavaUsage|.R|/JavaUsage.foo3||, R|ft|>(foo3@fun (x: R|kotlin/Number|): R|kotlin/Unit| { + Q|JavaUsage|.R|/JavaUsage.foo3||, R|ft|>(foo3@fun (x: R|kotlin/Number|): R|kotlin/Unit| { R|/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|() } , Int(2)) diff --git a/compiler/fir/resolve/testData/diagnostics/samConversions/kotlinSam.txt b/compiler/fir/resolve/testData/diagnostics/samConversions/kotlinSam.txt index d1da06ff491..d505ed77f91 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConversions/kotlinSam.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConversions/kotlinSam.txt @@ -33,22 +33,22 @@ FILE: kotlinSam.kt >(R|/t|, Int(1)) } - R|/foo1|( = foo1@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + R|/foo1|( = foo1@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } ) R|/foo1|(R|/f|) - R|/foo2|( = foo2@fun (x: R|kotlin/Nothing|): kotlin/Boolean { + R|/foo2|( = foo2@fun (x: R|kotlin/Nothing|): kotlin/Boolean { >(R|/x|, Int(1)) } ) #(R|/f|) - #( = foo3@fun .(x: ): { + #( = foo3@fun .(x: ): { >(x#, Int(1)) } ) R|/foo3|(R|/f|) - #( = foo4@fun .(x: ): { + #( = foo4@fun .(x: ): { >(x#, Int(1)) } ) diff --git a/compiler/fir/resolve/testData/diagnostics/samConversions/notSamBecauseOfSupertype.txt b/compiler/fir/resolve/testData/diagnostics/samConversions/notSamBecauseOfSupertype.txt index 5102818ff0b..bb583f19e12 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConversions/notSamBecauseOfSupertype.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConversions/notSamBecauseOfSupertype.txt @@ -2,11 +2,11 @@ FILE: main.kt public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - Q|JavaUsage|.R|/JavaUsage.foo|( = foo@fun (x: R|kotlin/Nothing|): kotlin/Boolean { + Q|JavaUsage|.R|/JavaUsage.foo|( = foo@fun (x: R|kotlin/Nothing|): kotlin/Boolean { >(R|/x|, Int(1)) } ) - Q|JavaUsage|.R|/JavaUsage.foo|(foo@fun (): kotlin/Boolean { + Q|JavaUsage|.R|/JavaUsage.foo|(foo@fun (): kotlin/Boolean { >(#, Int(1)) } ) diff --git a/compiler/fir/resolve/testData/diagnostics/samConversions/runnable.txt b/compiler/fir/resolve/testData/diagnostics/samConversions/runnable.txt index 1a02c812105..f265cd70f90 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConversions/runnable.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConversions/runnable.txt @@ -1,10 +1,10 @@ FILE: main.kt public final fun main(): R|kotlin/Unit| { - Q|JavaClass|.R|/JavaClass.foo|( = foo@fun (): R|kotlin/Unit| { + Q|JavaClass|.R|/JavaClass.foo|( = foo@fun (): R|kotlin/Unit| { String() } ) - R|/JavaClass.JavaClass|().R|/JavaClass.bar|( = bar@fun (): R|kotlin/Unit| { + R|/JavaClass.JavaClass|().R|/JavaClass.bar|( = bar@fun (): R|kotlin/Unit| { String() } ) diff --git a/compiler/fir/resolve/testData/diagnostics/samConversions/samSupertype.txt b/compiler/fir/resolve/testData/diagnostics/samConversions/samSupertype.txt index 5d1edc0baaa..2be57bd36e1 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConversions/samSupertype.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConversions/samSupertype.txt @@ -2,11 +2,11 @@ FILE: main.kt public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - Q|JavaUsage|.R|/JavaUsage.foo|( = foo@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + Q|JavaUsage|.R|/JavaUsage.foo|( = foo@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } ) - Q|JavaUsage|.R|/JavaUsage.foo|(foo@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { + Q|JavaUsage|.R|/JavaUsage.foo|(foo@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/it|, Int(1)) } ) diff --git a/compiler/fir/resolve/testData/diagnostics/samConversions/samSupertypeWithOverride.txt b/compiler/fir/resolve/testData/diagnostics/samConversions/samSupertypeWithOverride.txt index 90e1b08d47f..10aff34cc41 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConversions/samSupertypeWithOverride.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConversions/samSupertypeWithOverride.txt @@ -2,11 +2,11 @@ FILE: main.kt public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - Q|JavaUsage|.R|/JavaUsage.foo|( = foo@fun (x: R|kotlin/Int|): R|ft!| { + Q|JavaUsage|.R|/JavaUsage.foo|( = foo@fun (x: R|kotlin/Int|): R|ft!| { >(R|/x|, Int(1)) } ) - Q|JavaUsage|.R|/JavaUsage.foo|(foo@fun (it: R|kotlin/Int|): R|ft!| { + Q|JavaUsage|.R|/JavaUsage.foo|(foo@fun (it: R|kotlin/Int|): R|ft!| { >(R|/it|, Int(1)) } ) diff --git a/compiler/fir/resolve/testData/diagnostics/samConversions/simple.txt b/compiler/fir/resolve/testData/diagnostics/samConversions/simple.txt index 5d1edc0baaa..2be57bd36e1 100644 --- a/compiler/fir/resolve/testData/diagnostics/samConversions/simple.txt +++ b/compiler/fir/resolve/testData/diagnostics/samConversions/simple.txt @@ -2,11 +2,11 @@ FILE: main.kt public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - Q|JavaUsage|.R|/JavaUsage.foo|( = foo@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { + Q|JavaUsage|.R|/JavaUsage.foo|( = foo@fun (x: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/x|, Int(1)) } ) - Q|JavaUsage|.R|/JavaUsage.foo|(foo@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { + Q|JavaUsage|.R|/JavaUsage.foo|(foo@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { >(R|/it|, Int(1)) } ) diff --git a/compiler/fir/resolve/testData/resolve/arguments/lambda.txt b/compiler/fir/resolve/testData/resolve/arguments/lambda.txt index d94db3b7dbe..65b9430265d 100644 --- a/compiler/fir/resolve/testData/resolve/arguments/lambda.txt +++ b/compiler/fir/resolve/testData/resolve/arguments/lambda.txt @@ -6,70 +6,70 @@ 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 .(): { + #(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 } ) - R|/bar|(x = Int(1), f = bar@fun (): R|kotlin/Unit| { + R|/bar|(x = Int(1), f = bar@fun (): R|kotlin/Unit| { Unit } ) - #( = bar@fun .(): { + #( = bar@fun .(): { Unit } ) - #(bar@fun .(): { + #(bar@fun .(): { Unit } ) - R|/baz|(other = Boolean(false), f = baz@fun (): R|kotlin/Unit| { + R|/baz|(other = Boolean(false), f = baz@fun (): R|kotlin/Unit| { 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/cfg/complex.dot b/compiler/fir/resolve/testData/resolve/cfg/complex.dot index 4840c6024e4..21b00f8e076 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/complex.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/complex.dot @@ -27,7 +27,7 @@ digraph complex_kt { 11 [label="Access variable #"]; 12 [label="Access variable R|/url|"]; 13 [label="Function call: #.#(R|/url|)"]; - 14 [label="Function call: #.#(R|/url|).#( = connect@fun .(): { + 14 [label="Function call: #.#(R|/url|).#( = connect@fun .(): { GsonBuilder#().create#().fromJson#(it#.inputStream#.reader#(), (Array#()).java#) } )"]; diff --git a/compiler/fir/resolve/testData/resolve/cfg/complex.txt b/compiler/fir/resolve/testData/resolve/cfg/complex.txt index 808681c086b..61ef2be09d2 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/complex.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/complex.txt @@ -2,7 +2,7 @@ FILE: complex.kt @R|kotlin/jvm/Throws|((#), (#)) public final fun fetchPluginReleaseDate(pluginId: R|class error: Symbol not found, for `PluginId`|, version: R|kotlin/String|, channel: R|kotlin/String?|): R|class error: Symbol not found, for `LocalDate?`| { lval url: R|kotlin/String| = (String(https://plugins.jetbrains.com/api/plugins/), R|/pluginId|.#, String(/updates?version=), R|/version|) lval pluginDTOs: R|kotlin/Array| = try { - #.#(R|/url|).#( = connect@fun .(): { + #.#(R|/url|).#( = connect@fun .(): { GsonBuilder#().create#().fromJson#(it#.inputStream#.reader#(), (Array#()).java#) } ) diff --git a/compiler/fir/resolve/testData/resolve/cfg/jumps.dot b/compiler/fir/resolve/testData/resolve/cfg/jumps.dot index 0c110ef4d38..c1c1d38c7a0 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/jumps.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/jumps.dot @@ -391,7 +391,7 @@ digraph jumps_kt { } 131 [label="Exit function anonymousFunction"]; } - 132 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { + 132 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { ^@run Unit } )"]; @@ -402,13 +402,13 @@ digraph jumps_kt { 124 -> {125}; 125 -> {126}; - 126 -> {127}; + 126 -> {131 127}; 127 -> {128}; 128 -> {131}; 128 -> {129} [style=dotted]; 129 -> {130} [style=dotted]; 130 -> {131} [style=dotted]; - 131 -> {132}; + 131 -> {126 132}; 132 -> {133}; 133 -> {134}; diff --git a/compiler/fir/resolve/testData/resolve/cfg/jumps.kt b/compiler/fir/resolve/testData/resolve/cfg/jumps.kt index f2b65e69887..09602f88207 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/jumps.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/jumps.kt @@ -40,7 +40,7 @@ fun test_5(b: Boolean) { } } -fun run(block: () -> Unit) { +inline fun run(block: () -> Unit) { block() } diff --git a/compiler/fir/resolve/testData/resolve/cfg/jumps.txt b/compiler/fir/resolve/testData/resolve/cfg/jumps.txt index 95b10f67d0c..3416d239cee 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/jumps.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/jumps.txt @@ -50,11 +50,11 @@ FILE: jumps.kt } } - public final fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { + public final inline fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { R|/block|.R|FakeOverride|() } public final fun test_6(): R|kotlin/Unit| { - R|/run|( = run@fun (): R|kotlin/Unit| { + R|/run|( = run@fun (): R|kotlin/Unit| { ^@run Unit } ) diff --git a/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot b/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot index 00a2340f70e..e3c84b682ce 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot @@ -53,7 +53,7 @@ digraph lambdas_kt { } 20 [label="Exit function anonymousFunction"]; } - 21 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { + 21 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { R|/x|.R|kotlin/Int.inc|() } )"]; @@ -77,12 +77,12 @@ digraph lambdas_kt { 12 -> {24}; 13 -> {14}; 14 -> {15}; - 15 -> {16}; + 15 -> {20 16}; 16 -> {17}; 17 -> {18}; 18 -> {19}; 19 -> {20}; - 20 -> {21}; + 20 -> {15 21}; 21 -> {22}; 22 -> {23}; 23 -> {24}; @@ -197,16 +197,16 @@ digraph lambdas_kt { 63 [label="Stub" style="filled" fillcolor=gray]; 64 [label="Exit block" style="filled" fillcolor=gray]; } - 65 [label="Exit function anonymousFunction" style="filled" fillcolor=gray]; + 65 [label="Exit function anonymousFunction"]; } - 66 [label="Function call: R|/getInt|( = getInt@fun (): R|kotlin/Unit| { + 66 [label="Function call: R|/getInt|( = getInt@fun (): R|kotlin/Unit| { ^test_3 Int(1) } -)" style="filled" fillcolor=gray]; - 67 [label="Jump: ^test_3 R|/getInt|( = getInt@fun (): R|kotlin/Unit| { +)"]; + 67 [label="Jump: ^test_3 R|/getInt|( = getInt@fun (): R|kotlin/Unit| { ^test_3 Int(1) } -)" style="filled" fillcolor=gray]; +)"]; 68 [label="Stub" style="filled" fillcolor=gray]; 69 [label="Exit block" style="filled" fillcolor=gray]; } @@ -215,16 +215,17 @@ digraph lambdas_kt { 57 -> {58}; 58 -> {59}; - 59 -> {60}; + 59 -> {65 60}; 60 -> {61}; 61 -> {62}; 62 -> {70}; 62 -> {63} [style=dotted]; 63 -> {64} [style=dotted]; 64 -> {65} [style=dotted]; - 65 -> {66} [style=dotted]; - 66 -> {67} [style=dotted]; - 67 -> {70 68} [style=dotted]; + 65 -> {59 66}; + 66 -> {67}; + 67 -> {70}; + 67 -> {68} [style=dotted]; 68 -> {69} [style=dotted]; 69 -> {70} [style=dotted]; @@ -245,16 +246,16 @@ digraph lambdas_kt { 77 [label="Stub" style="filled" fillcolor=gray]; 78 [label="Exit block" style="filled" fillcolor=gray]; } - 79 [label="Exit function anonymousFunction" style="filled" fillcolor=gray]; + 79 [label="Exit function anonymousFunction"]; } - 80 [label="Function call: R|/getInt|(block = getInt@fun (): R|kotlin/Unit| { + 80 [label="Function call: R|/getInt|(block = getInt@fun (): R|kotlin/Unit| { ^test_4 Int(1) } -)" style="filled" fillcolor=gray]; - 81 [label="Jump: ^test_4 R|/getInt|(block = getInt@fun (): R|kotlin/Unit| { +)"]; + 81 [label="Jump: ^test_4 R|/getInt|(block = getInt@fun (): R|kotlin/Unit| { ^test_4 Int(1) } -)" style="filled" fillcolor=gray]; +)"]; 82 [label="Stub" style="filled" fillcolor=gray]; 83 [label="Exit block" style="filled" fillcolor=gray]; } @@ -263,16 +264,17 @@ digraph lambdas_kt { 71 -> {72}; 72 -> {73}; - 73 -> {74}; + 73 -> {79 74}; 74 -> {75}; 75 -> {76}; 76 -> {84}; 76 -> {77} [style=dotted]; 77 -> {78} [style=dotted]; 78 -> {79} [style=dotted]; - 79 -> {80} [style=dotted]; - 80 -> {81} [style=dotted]; - 81 -> {84 82} [style=dotted]; + 79 -> {73 80}; + 80 -> {81}; + 81 -> {84}; + 81 -> {82} [style=dotted]; 82 -> {83} [style=dotted]; 83 -> {84} [style=dotted]; diff --git a/compiler/fir/resolve/testData/resolve/cfg/lambdas.kt b/compiler/fir/resolve/testData/resolve/cfg/lambdas.kt index f520c5b8b74..d3395da52c1 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/lambdas.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/lambdas.kt @@ -1,4 +1,4 @@ -fun run(block: () -> Unit) { +inline fun run(block: () -> Unit) { block() } @@ -19,7 +19,7 @@ fun test_2(x: Any?) { } -fun getInt(block: () -> Unit): Int { +inline fun getInt(block: () -> Unit): Int { block() return 1 } diff --git a/compiler/fir/resolve/testData/resolve/cfg/lambdas.txt b/compiler/fir/resolve/testData/resolve/cfg/lambdas.txt index 65d0c31a73b..69f23b8ee5f 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/lambdas.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/lambdas.txt @@ -1,11 +1,11 @@ FILE: lambdas.kt - public final fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { + public final inline fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { R|/block|.R|FakeOverride|() } public final fun test_1(x: R|kotlin/Any?|): R|kotlin/Unit| { when () { (R|/x| is R|kotlin/Int|) -> { - R|/run|( = run@fun (): R|kotlin/Unit| { + R|/run|( = run@fun (): R|kotlin/Unit| { R|/x|.R|kotlin/Int.inc|() } ) @@ -24,18 +24,18 @@ FILE: lambdas.kt } } - public final fun getInt(block: R|kotlin/Function0|): R|kotlin/Int| { + public final inline fun getInt(block: R|kotlin/Function0|): R|kotlin/Int| { R|/block|.R|FakeOverride|() ^getInt Int(1) } public final fun test_3(): R|kotlin/Int| { - ^test_3 R|/getInt|( = getInt@fun (): R|kotlin/Unit| { + ^test_3 R|/getInt|( = getInt@fun (): R|kotlin/Unit| { ^test_3 Int(1) } ) } public final fun test_4(): R|kotlin/Int| { - ^test_4 R|/getInt|(block = getInt@fun (): R|kotlin/Unit| { + ^test_4 R|/getInt|(block = getInt@fun (): R|kotlin/Unit| { ^test_4 Int(1) } ) diff --git a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.dot b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.dot index 89b7966f1d3..b07e1a860d8 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.dot @@ -164,9 +164,9 @@ digraph propertiesAndInitBlocks_kt { 50 [label="Stub" style="filled" fillcolor=gray]; 51 [label="Exit block" style="filled" fillcolor=gray]; } - 52 [label="Exit function anonymousFunction" style="filled" fillcolor=gray]; + 52 [label="Exit function anonymousFunction"]; } - 53 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { + 53 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { local final fun foo(): R|kotlin/Unit| { lval c: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(1)) throw R|java/lang/Exception.Exception|() @@ -186,20 +186,20 @@ digraph propertiesAndInitBlocks_kt { throw R|java/lang/Exception.Exception|() } -)" style="filled" fillcolor=gray]; +)"]; 54 [label="Exit property" style="filled" fillcolor=red]; } 45 -> {46}; - 46 -> {47}; + 46 -> {52 47}; 47 -> {48}; 48 -> {49}; 49 -> {54}; 49 -> {50} [style=dotted]; 50 -> {51} [style=dotted]; 51 -> {52} [style=dotted]; - 52 -> {53} [style=dotted]; - 53 -> {54} [style=dotted]; + 52 -> {46 53}; + 53 -> {54}; subgraph cluster_18 { color=red diff --git a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.kt b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.kt index 6ae6c3a2029..d446cce0028 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.kt +++ b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.kt @@ -1,4 +1,4 @@ -fun run(block: () -> Unit) { +inline fun run(block: () -> Unit) { block() } diff --git a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.txt b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.txt index 7761f4651f0..a181cc2d8e9 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.txt +++ b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.txt @@ -1,5 +1,5 @@ FILE: propertiesAndInitBlocks.kt - public final fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { + public final inline fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { R|/block|.R|FakeOverride|() } public final val x1: R|kotlin/Int| = Int(1) @@ -11,7 +11,7 @@ FILE: propertiesAndInitBlocks.kt public set(value: R|kotlin/Int|): R|kotlin/Unit| { F|/x2| = Int(1) } - public final val x3: R|kotlin/Unit| = R|/run|( = run@fun (): R|kotlin/Unit| { + public final val x3: R|kotlin/Unit| = R|/run|( = run@fun (): R|kotlin/Unit| { local final fun foo(): R|kotlin/Unit| { lval c: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(1)) throw R|java/lang/Exception.Exception|() diff --git a/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt b/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt index 137364a7c3a..7a3c8cf5cb4 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.txt @@ -19,7 +19,7 @@ FILE: extensionPropertyInLambda.kt public final fun use(f: R|kotlin/Function0|): R|kotlin/Unit| { } public final fun test1(): R|kotlin/Unit| { - R|/use|( = use@fun (): R|kotlin/String| { + R|/use|( = use@fun (): R|kotlin/String| { R|/C.C|(String(abc)).R|/y| } ) diff --git a/compiler/fir/resolve/testData/resolve/expresssions/lambda.txt b/compiler/fir/resolve/testData/resolve/expresssions/lambda.txt index daffd0c978b..1f0e228efc1 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 a6ee9e463b4..8b46686c66b 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/smartcasts/inPlaceLambdas.dot b/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.dot index bcc605d58f0..5969091fb16 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.dot @@ -69,7 +69,7 @@ digraph inPlaceLambdas_kt { } 24 [label="Exit function anonymousFunction"]; } - 25 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { + 25 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { R|/x|.R|/A.foo|() } )"]; @@ -93,12 +93,12 @@ digraph inPlaceLambdas_kt { 16 -> {28}; 17 -> {18}; 18 -> {19}; - 19 -> {20}; + 19 -> {24 20}; 20 -> {21}; 21 -> {22}; 22 -> {23}; 23 -> {24}; - 24 -> {25}; + 24 -> {19 25}; 25 -> {26}; 26 -> {27}; 27 -> {28}; @@ -123,7 +123,7 @@ digraph inPlaceLambdas_kt { } 38 [label="Exit function anonymousFunction"]; } - 39 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { + 39 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { (R|/x| as R|B|) } )"]; @@ -136,12 +136,12 @@ digraph inPlaceLambdas_kt { 31 -> {32}; 32 -> {33}; - 33 -> {34}; + 33 -> {38 34}; 34 -> {35}; 35 -> {36}; 36 -> {37}; 37 -> {38}; - 38 -> {39}; + 38 -> {33 39}; 39 -> {40}; 40 -> {41}; 41 -> {42}; @@ -182,7 +182,7 @@ digraph inPlaceLambdas_kt { } 61 [label="Exit function anonymousFunction"]; } - 62 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { + 62 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { R|/x|.R|/A.foo|() (R|/x| as R|B|) } @@ -209,14 +209,14 @@ digraph inPlaceLambdas_kt { 51 -> {67}; 52 -> {53}; 53 -> {54}; - 54 -> {55}; + 54 -> {61 55}; 55 -> {56}; 56 -> {57}; 57 -> {58}; 58 -> {59}; 59 -> {60}; 60 -> {61}; - 61 -> {62}; + 61 -> {54 62}; 62 -> {63}; 63 -> {64}; 64 -> {65}; diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.kt b/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.kt index f2b1414a395..9cb045b988a 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.kt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.kt @@ -7,7 +7,7 @@ interface B { } -fun run(block: () -> Unit) { +inline fun run(block: () -> Unit) { block() } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.txt b/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.txt index d8bb6ca1ad1..d8746ba4288 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.txt +++ b/compiler/fir/resolve/testData/resolve/smartcasts/inPlaceLambdas.txt @@ -7,13 +7,13 @@ FILE: inPlaceLambdas.kt public abstract fun bar(): R|kotlin/Unit| } - public final fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { + public final inline fun run(block: R|kotlin/Function0|): R|kotlin/Unit| { R|/block|.R|FakeOverride|() } public final fun test_1(x: R|kotlin/Any?|): R|kotlin/Unit| { when () { (R|/x| is R|A|) -> { - R|/run|( = run@fun (): R|kotlin/Unit| { + R|/run|( = run@fun (): R|kotlin/Unit| { R|/x|.R|/A.foo|() } ) @@ -22,7 +22,7 @@ FILE: inPlaceLambdas.kt } public final fun test_2(x: R|kotlin/Any?|): R|kotlin/Unit| { - R|/run|( = run@fun (): R|kotlin/Unit| { + R|/run|( = run@fun (): R|kotlin/Unit| { (R|/x| as R|B|) } ) @@ -31,7 +31,7 @@ FILE: inPlaceLambdas.kt public final fun test_3(x: R|kotlin/Any?|): R|kotlin/Unit| { when () { (R|/x| is R|A|) -> { - R|/run|( = run@fun (): R|kotlin/Unit| { + R|/run|( = run@fun (): R|kotlin/Unit| { R|/x|.R|/A.foo|() (R|/x| as R|B|) } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/components.txt b/compiler/fir/resolve/testData/resolve/stdlib/components.txt index 1229c329e24..95719901e19 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/contracts/callsInPlace.dot b/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.dot new file mode 100644 index 00000000000..fc5b602a685 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.dot @@ -0,0 +1,399 @@ +digraph callsInPlace_kt { + graph [splines=ortho nodesep=3] + node [shape=box penwidth=2] + edge [penwidth=2] + + subgraph cluster_0 { + color=red + 0 [label="Enter function test" style="filled" fillcolor=red]; + subgraph cluster_1 { + color=blue + 1 [label="Enter block"]; + 2 [label="Variable declaration: lval x: R|kotlin/Int|"]; + subgraph cluster_2 { + color=blue + 3 [label="Enter function anonymousFunction"]; + subgraph cluster_3 { + color=blue + 4 [label="Enter block"]; + 5 [label="Const: Int(1)"]; + 6 [label="Assignmenet: R|/x|"]; + 7 [label="Exit block"]; + } + 8 [label="Exit function anonymousFunction"]; + } + 9 [label="Function call: R|kotlin/run|( = run@fun (): R|kotlin/Unit| { + R|/x| = Int(1) +} +)"]; + 10 [label="Access variable R|/x|"]; + 11 [label="Function call: R|/x|.R|kotlin/Int.inc|()"]; + 12 [label="Exit block"]; + } + 13 [label="Exit function test" style="filled" fillcolor=red]; + } + + 0 -> {1}; + 1 -> {2}; + 2 -> {3}; + 3 -> {4}; + 4 -> {5}; + 5 -> {6}; + 6 -> {7}; + 7 -> {8}; + 8 -> {9}; + 9 -> {10}; + 10 -> {11}; + 11 -> {12}; + 12 -> {13}; + + subgraph cluster_4 { + color=red + 14 [label="Enter function test_2" style="filled" fillcolor=red]; + subgraph cluster_5 { + color=blue + 15 [label="Enter block"]; + 16 [label="Const: Int(10)"]; + subgraph cluster_6 { + color=blue + 17 [label="Enter function anonymousFunction"]; + subgraph cluster_7 { + color=blue + 18 [label="Enter block"]; + 19 [label="Const: String(test_2)"]; + 20 [label="Exit block"]; + } + 21 [label="Exit function anonymousFunction"]; + } + 22 [label="Function call: R|kotlin/repeat|(Int(10), = repeat@fun (it: R|kotlin/Int|): R|kotlin/Unit| { + String(test_2) +} +)"]; + 23 [label="Exit block"]; + } + 24 [label="Exit function test_2" style="filled" fillcolor=red]; + } + + 14 -> {15}; + 15 -> {16}; + 16 -> {17}; + 17 -> {21 18}; + 18 -> {19}; + 19 -> {20}; + 20 -> {21}; + 21 -> {17 22}; + 22 -> {23}; + 23 -> {24}; + + subgraph cluster_8 { + color=red + 25 [label="Enter function test_3" style="filled" fillcolor=red]; + subgraph cluster_9 { + color=blue + 26 [label="Enter block"]; + 27 [label="Const: Int(10)"]; + subgraph cluster_10 { + color=blue + 28 [label="Enter function anonymousFunction"]; + subgraph cluster_11 { + color=blue + 29 [label="Enter block"]; + 30 [label="Const: String(test_3)"]; + 31 [label="Exit block"]; + } + 32 [label="Exit function anonymousFunction"]; + } + 33 [label="Function call: R|kotlin/repeat|(action = repeat@fun (it: R|kotlin/Int|): R|kotlin/Unit| { + String(test_3) +} +, times = Int(10))"]; + 34 [label="Exit block"]; + } + 35 [label="Exit function test_3" style="filled" fillcolor=red]; + } + + 25 -> {26}; + 26 -> {27}; + 27 -> {28}; + 28 -> {32 29}; + 29 -> {30}; + 30 -> {31}; + 31 -> {32}; + 32 -> {28 33}; + 33 -> {34}; + 34 -> {35}; + + subgraph cluster_12 { + color=red + 36 [label="Enter function test_4" style="filled" fillcolor=red]; + subgraph cluster_13 { + color=blue + 37 [label="Enter block"]; + 38 [label="Const: Int(1)"]; + subgraph cluster_14 { + color=blue + 39 [label="Enter function anonymousFunction"]; + subgraph cluster_15 { + color=blue + 40 [label="Enter block"]; + 41 [label="Const: String(test_4)"]; + 42 [label="Access variable R|/it|"]; + 43 [label="Const: Int(0)"]; + 44 [label="Operator >"]; + 45 [label="Exit block"]; + } + 46 [label="Exit function anonymousFunction"]; + } + 47 [label="Function call: Int(1).R|kotlin/takeUnless|( = takeUnless@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { + String(test_4) + >(R|/it|, Int(0)) +} +)"]; + 48 [label="Exit block"]; + } + 49 [label="Exit function test_4" style="filled" fillcolor=red]; + } + + 36 -> {37}; + 37 -> {38}; + 38 -> {39}; + 39 -> {40}; + 40 -> {41}; + 41 -> {42}; + 42 -> {43}; + 43 -> {44}; + 44 -> {45}; + 45 -> {46}; + 46 -> {47}; + 47 -> {48}; + 48 -> {49}; + + subgraph cluster_16 { + color=red + 50 [label="Enter function test_5" style="filled" fillcolor=red]; + subgraph cluster_17 { + color=blue + 51 [label="Enter block"]; + 52 [label="Const: Int(1)"]; + subgraph cluster_18 { + color=blue + 53 [label="Enter function anonymousFunction"]; + subgraph cluster_19 { + color=blue + 54 [label="Enter block"]; + 55 [label="Const: String(test_5)"]; + 56 [label="Access variable R|/it|"]; + 57 [label="Const: Int(0)"]; + 58 [label="Operator >"]; + 59 [label="Exit block"]; + } + 60 [label="Exit function anonymousFunction"]; + } + 61 [label="Function call: Int(1).R|kotlin/takeUnless|(predicate = takeUnless@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { + String(test_5) + >(R|/it|, Int(0)) +} +)"]; + 62 [label="Exit block"]; + } + 63 [label="Exit function test_5" style="filled" fillcolor=red]; + } + + 50 -> {51}; + 51 -> {52}; + 52 -> {53}; + 53 -> {54}; + 54 -> {55}; + 55 -> {56}; + 56 -> {57}; + 57 -> {58}; + 58 -> {59}; + 59 -> {60}; + 60 -> {61}; + 61 -> {62}; + 62 -> {63}; + + subgraph cluster_20 { + color=red + 64 [label="Enter function myRun" style="filled" fillcolor=red]; + subgraph cluster_21 { + color=blue + 65 [label="Enter block"]; + 66 [label="Function call: R|/block1|.R|FakeOverride|()"]; + 67 [label="Function call: R|/block2|.R|FakeOverride|()"]; + 68 [label="Exit block"]; + } + 69 [label="Exit function myRun" style="filled" fillcolor=red]; + } + + 64 -> {65}; + 65 -> {66}; + 66 -> {67}; + 67 -> {68}; + 68 -> {69}; + + subgraph cluster_22 { + color=red + 70 [label="Enter function test_6" style="filled" fillcolor=red]; + subgraph cluster_23 { + color=blue + 71 [label="Enter block"]; + subgraph cluster_24 { + color=blue + 72 [label="Enter function anonymousFunction"]; + subgraph cluster_25 { + color=blue + 73 [label="Enter block"]; + 74 [label="Const: String(test_6_1)"]; + 75 [label="Exit block"]; + } + 76 [label="Exit function anonymousFunction"]; + } + subgraph cluster_26 { + color=blue + 77 [label="Enter function anonymousFunction"]; + subgraph cluster_27 { + color=blue + 78 [label="Enter block"]; + 79 [label="Const: String(test_6_2)"]; + 80 [label="Exit block"]; + } + 81 [label="Exit function anonymousFunction"]; + } + 82 [label="Function call: R|/myRun|(myRun@fun (): R|kotlin/Unit| { + String(test_6_1) +} +, = myRun@fun (): R|kotlin/Unit| { + String(test_6_2) +} +)"]; + 83 [label="Exit block"]; + } + 84 [label="Exit function test_6" style="filled" fillcolor=red]; + } + + 70 -> {71}; + 71 -> {72}; + 72 -> {76 73}; + 73 -> {74}; + 74 -> {75}; + 75 -> {76}; + 76 -> {72 77}; + 77 -> {81 78}; + 78 -> {79}; + 79 -> {80}; + 80 -> {81}; + 81 -> {77 82}; + 82 -> {83}; + 83 -> {84}; + + subgraph cluster_28 { + color=red + 85 [label="Enter function test_7" style="filled" fillcolor=red]; + subgraph cluster_29 { + color=blue + 86 [label="Enter block"]; + subgraph cluster_30 { + color=blue + 87 [label="Enter function anonymousFunction"]; + subgraph cluster_31 { + color=blue + 88 [label="Enter block"]; + 89 [label="Const: String(test_7_2)"]; + 90 [label="Exit block"]; + } + 91 [label="Exit function anonymousFunction"]; + } + subgraph cluster_32 { + color=blue + 92 [label="Enter function anonymousFunction"]; + subgraph cluster_33 { + color=blue + 93 [label="Enter block"]; + 94 [label="Const: String(test_7_1)"]; + 95 [label="Exit block"]; + } + 96 [label="Exit function anonymousFunction"]; + } + 97 [label="Function call: R|/myRun|(block2 = myRun@fun (): R|kotlin/Unit| { + String(test_7_2) +} +, block1 = myRun@fun (): R|kotlin/Unit| { + String(test_7_1) +} +)"]; + 98 [label="Exit block"]; + } + 99 [label="Exit function test_7" style="filled" fillcolor=red]; + } + + 85 -> {86}; + 86 -> {87}; + 87 -> {91 88}; + 88 -> {89}; + 89 -> {90}; + 90 -> {91}; + 91 -> {87 92}; + 92 -> {96 93}; + 93 -> {94}; + 94 -> {95}; + 95 -> {96}; + 96 -> {92 97}; + 97 -> {98}; + 98 -> {99}; + + subgraph cluster_34 { + color=red + 100 [label="Enter function myDummyRun" style="filled" fillcolor=red]; + subgraph cluster_35 { + color=blue + 101 [label="Enter block"]; + 102 [label="Function call: R|/block|.R|FakeOverride|()"]; + 103 [label="Exit block"]; + } + 104 [label="Exit function myDummyRun" style="filled" fillcolor=red]; + } + + 100 -> {101}; + 101 -> {102}; + 102 -> {103}; + 103 -> {104}; + + subgraph cluster_36 { + color=red + 105 [label="Enter function test_8" style="filled" fillcolor=red]; + subgraph cluster_37 { + color=blue + 106 [label="Enter block"]; + 107 [label="Function call: R|/myDummyRun|( = myDummyRun@fun (): R|kotlin/Unit| { + String(test_8) +} +)"]; + 108 [label="Exit block"]; + } + 109 [label="Exit function test_8" style="filled" fillcolor=red]; + } + + 105 -> {106}; + 106 -> {107}; + 107 -> {108}; + 108 -> {109}; + + subgraph cluster_38 { + color=red + 110 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; + subgraph cluster_39 { + color=blue + 111 [label="Enter block"]; + 112 [label="Const: String(test_8)"]; + 113 [label="Exit block"]; + } + 114 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; + } + + 110 -> {111}; + 111 -> {112}; + 112 -> {113}; + 113 -> {114}; + +} diff --git a/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.kt b/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.kt new file mode 100644 index 00000000000..03605c55595 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.kt @@ -0,0 +1,52 @@ +fun test() { + val x: Int + run { + x = 1 + } + x.inc() +} + +fun test_2() { + repeat(10) { + "test_2" + } +} + +fun test_3() { + repeat(action = { "test_3" }, times = 10) +} + +fun test_4() { + 1.takeUnless { + "test_4" + it > 0 + } +} + +fun test_5() { + 1.takeUnless(predicate = { + "test_5" + it > 0 + }) +} + +inline fun myRun(block1: () -> Unit, block2: () -> Unit) { + block1() + block2() +} + +fun test_6() { + myRun({ "test_6_1" }) { "test_6_2" } +} + +fun test_7() { + myRun(block2 = { "test_7_2" }, block1 = { "test_7_1" }) +} + +fun myDummyRun(block: () -> Unit) { + block() +} + +fun test_8() { + myDummyRun { "test_8" } +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.txt b/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.txt new file mode 100644 index 00000000000..88bafc01a88 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.txt @@ -0,0 +1,66 @@ +FILE: callsInPlace.kt + public final fun test(): R|kotlin/Unit| { + lval x: R|kotlin/Int| + R|kotlin/run|( = run@fun (): R|kotlin/Unit| { + R|/x| = Int(1) + } + ) + R|/x|.R|kotlin/Int.inc|() + } + public final fun test_2(): R|kotlin/Unit| { + R|kotlin/repeat|(Int(10), = repeat@fun (it: R|kotlin/Int|): R|kotlin/Unit| { + String(test_2) + } + ) + } + public final fun test_3(): R|kotlin/Unit| { + R|kotlin/repeat|(action = repeat@fun (it: R|kotlin/Int|): R|kotlin/Unit| { + String(test_3) + } + , times = Int(10)) + } + public final fun test_4(): R|kotlin/Unit| { + Int(1).R|kotlin/takeUnless|( = takeUnless@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { + String(test_4) + >(R|/it|, Int(0)) + } + ) + } + public final fun test_5(): R|kotlin/Unit| { + Int(1).R|kotlin/takeUnless|(predicate = takeUnless@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { + String(test_5) + >(R|/it|, Int(0)) + } + ) + } + public final inline fun myRun(block1: R|kotlin/Function0|, block2: R|kotlin/Function0|): R|kotlin/Unit| { + R|/block1|.R|FakeOverride|() + R|/block2|.R|FakeOverride|() + } + public final fun test_6(): R|kotlin/Unit| { + R|/myRun|(myRun@fun (): R|kotlin/Unit| { + String(test_6_1) + } + , = myRun@fun (): R|kotlin/Unit| { + String(test_6_2) + } + ) + } + public final fun test_7(): R|kotlin/Unit| { + R|/myRun|(block2 = myRun@fun (): R|kotlin/Unit| { + String(test_7_2) + } + , block1 = myRun@fun (): R|kotlin/Unit| { + String(test_7_1) + } + ) + } + public final fun myDummyRun(block: R|kotlin/Function0|): R|kotlin/Unit| { + R|/block|.R|FakeOverride|() + } + public final fun test_8(): R|kotlin/Unit| { + R|/myDummyRun|( = myDummyRun@fun (): R|kotlin/Unit| { + String(test_8) + } + ) + } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/mapList.txt b/compiler/fir/resolve/testData/resolve/stdlib/mapList.txt index 3e3909584bc..2a52cc6a452 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/simpleLazy.txt b/compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.txt index 6097d568dff..c1d5a15e543 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 35b5fb04f97..8c42d62b4a2 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| { + 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|) } ) diff --git a/compiler/fir/resolve/testData/resolve/whenAsReceiver.txt b/compiler/fir/resolve/testData/resolve/whenAsReceiver.txt index b49c188268f..6bef5a8169a 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/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirCfgBuildingWithStdlibTest.kt b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirCfgBuildingWithStdlibTest.kt new file mode 100644 index 00000000000..cead223a557 --- /dev/null +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirCfgBuildingWithStdlibTest.kt @@ -0,0 +1,16 @@ +/* + * 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 + +import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment +import org.jetbrains.kotlin.test.ConfigurationKind +import org.jetbrains.kotlin.test.TestJdkKind + +abstract class AbstractFirCfgBuildingWithStdlibTest : AbstractFirCfgBuildingTest() { + override fun createEnvironment(): KotlinCoreEnvironment { + return createEnvironmentWithJdk(ConfigurationKind.ALL, TestJdkKind.FULL_JDK) + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirCfgBuildingWithStdlibTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirCfgBuildingWithStdlibTestGenerated.java new file mode 100644 index 00000000000..1dddab2372c --- /dev/null +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirCfgBuildingWithStdlibTestGenerated.java @@ -0,0 +1,35 @@ +/* + * 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; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +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("compiler/fir/resolve/testData/resolve/stdlib/contracts") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class FirCfgBuildingWithStdlibTestGenerated extends AbstractFirCfgBuildingWithStdlibTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInContracts() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib/contracts"), Pattern.compile("^([^.]+)\\.kt$"), true); + } + + @TestMetadata("callsInPlace.kt") + public void testCallsInPlace() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/contracts/callsInPlace.kt"); + } +} diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseWithStdlibGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseWithStdlibGenerated.java index 92d9170fa4f..21564201ced 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseWithStdlibGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseWithStdlibGenerated.java @@ -25,7 +25,7 @@ public class FirResolveTestCaseWithStdlibGenerated extends AbstractFirResolveTes } public void testAllFilesPresentInStdlib() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib"), Pattern.compile("^([^.]+)\\.kt$"), true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib"), Pattern.compile("^([^.]+)\\.kt$"), true, "contracts"); } @TestMetadata("arrayFirstOrNull.kt") diff --git a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt index 385fad27d0f..35ddb85c96c 100644 --- a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt +++ b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt @@ -506,14 +506,18 @@ fun main(args: Array) { model("resolve", pattern = KT_WITHOUT_DOTS_IN_NAME, excludeDirs = listOf("stdlib", "cfg", "smartcasts")) } - testClass { - model("resolve/stdlib", pattern = KT_WITHOUT_DOTS_IN_NAME) - } - testClass { model("resolve/cfg", pattern = KT_WITHOUT_DOTS_IN_NAME) model("resolve/smartcasts", pattern = KT_WITHOUT_DOTS_IN_NAME) } + + testClass { + model("resolve/stdlib", pattern = KT_WITHOUT_DOTS_IN_NAME, excludeDirs = listOf("contracts")) + } + + testClass { + model("resolve/stdlib/contracts", pattern = KT_WITHOUT_DOTS_IN_NAME) + } } testGroup("compiler/fir/resolve/tests", "compiler/testData") {