From 6b378cab29e196030a573e04e12a276aa770fe3c Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 13 Feb 2020 14:34:43 +0300 Subject: [PATCH] [FIR] Don't render lambda bodies in arguments of calls in cfg dump --- .../dfa/cfg/ControlFlowGraphRenderer.kt | 19 +++++--- .../resolve/testData/resolve/cfg/jumps.dot | 5 +- .../resolve/testData/resolve/cfg/lambdas.dot | 15 ++---- .../testData/resolve/cfg/postponedLambdas.dot | 5 +- .../resolve/cfg/propertiesAndInitBlocks.dot | 22 +-------- .../resolve/cfg/returnValuesFromLambda.dot | 21 ++------ .../smartcasts/controlStructures/returns.dot | 5 +- .../smartcasts/lambdas/inPlaceLambdas.dot | 16 ++----- .../receivers/implicitReceivers.dot | 34 ++----------- .../smartcasts/safeCalls/safeCalls.dot | 15 ++---- .../resolve/smartcasts/smartcastToNothing.dot | 5 +- .../contracts/callsInPlace.dot | 48 ++++--------------- .../smartcasts/tryWithLambdaInside.dot | 10 +--- .../org/jetbrains/kotlin/fir/FirRenderer.kt | 18 +++++-- 14 files changed, 55 insertions(+), 183 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt index dbbb315d617..8118f5634c0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphRenderer.kt @@ -157,20 +157,25 @@ private fun CFGNode<*>.render(): String = is LoopConditionExitNode -> "Exit loop condition" is LoopExitNode -> "Exit ${fir.type()}loop" - is QualifiedAccessNode -> "Access variable ${fir.calleeReference.render()}" + is QualifiedAccessNode -> "Access variable ${fir.calleeReference.render(FirRenderer.RenderMode.DontRenderLambdaBodies)}" is OperatorCallNode -> "Operator ${fir.operation.operator}" - is TypeOperatorCallNode -> "Type operator: \"${fir.render()}\"" + is TypeOperatorCallNode -> "Type operator: \"${fir.render(FirRenderer.RenderMode.DontRenderLambdaBodies)}\"" is JumpNode -> "Jump: ${fir.render()}" is StubNode -> "Stub" - is CheckNotNullCallNode -> "Check not null: ${fir.render()}" + is CheckNotNullCallNode -> "Check not null: ${fir.render(FirRenderer.RenderMode.DontRenderLambdaBodies)}" is ConstExpressionNode -> "Const: ${fir.render()}" is VariableDeclarationNode -> - "Variable declaration: ${buildString { FirRenderer(this).visitCallableDeclaration(fir) }}" + "Variable declaration: ${buildString { + FirRenderer( + this, + FirRenderer.RenderMode.DontRenderLambdaBodies + ).visitCallableDeclaration(fir) + }}" - is VariableAssignmentNode -> "Assignmenet: ${fir.lValue.render()}" - is FunctionCallNode -> "Function call: ${fir.render()}" - is ThrowExceptionNode -> "Throw: ${fir.render()}" + is VariableAssignmentNode -> "Assignmenet: ${fir.lValue.render(FirRenderer.RenderMode.DontRenderLambdaBodies)}" + is FunctionCallNode -> "Function call: ${fir.render(FirRenderer.RenderMode.DontRenderLambdaBodies)}" + is ThrowExceptionNode -> "Throw: ${fir.render(FirRenderer.RenderMode.DontRenderLambdaBodies)}" is TryExpressionEnterNode -> "Try expression enter" is TryMainBlockEnterNode -> "Try main block enter" diff --git a/compiler/fir/resolve/testData/resolve/cfg/jumps.dot b/compiler/fir/resolve/testData/resolve/cfg/jumps.dot index 11949857d31..314c20949a4 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/jumps.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/jumps.dot @@ -343,10 +343,7 @@ digraph jumps_kt { 117 [label="Exit function anonymousFunction"]; } 118 [label="Postponed exit from lambda"]; - 119 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { - ^@run Unit -} -)"]; + 119 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| )"]; 120 [label="Exit function test_6" style="filled" fillcolor=red]; } diff --git a/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot b/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot index 10af49c7089..13fee34480a 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/lambdas.dot @@ -40,10 +40,7 @@ digraph lambdas_kt { 16 [label="Exit function anonymousFunction"]; } 17 [label="Postponed exit from lambda"]; - 18 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { - ^ R|/x|.R|kotlin/Int.inc|() -} -)"]; + 18 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| )"]; 19 [label="Exit block"]; } 20 [label="Exit when branch result"]; @@ -157,10 +154,7 @@ digraph lambdas_kt { 53 [label="Exit function anonymousFunction"]; } 54 [label="Postponed exit from lambda"]; - 55 [label="Function call: R|/getInt|( = getInt@fun (): R|kotlin/Unit| { - ^test_3 Int(1) -} -)"]; + 55 [label="Function call: R|/getInt|( = getInt@fun (): R|kotlin/Unit| )"]; 56 [label="Jump: ^test_3 R|/getInt|( = getInt@fun (): R|kotlin/Unit| { ^test_3 Int(1) } @@ -198,10 +192,7 @@ digraph lambdas_kt { 65 [label="Exit function anonymousFunction"]; } 66 [label="Postponed exit from lambda"]; - 67 [label="Function call: R|/getInt|(block = getInt@fun (): R|kotlin/Unit| { - ^test_4 Int(1) -} -)"]; + 67 [label="Function call: R|/getInt|(block = getInt@fun (): R|kotlin/Unit| )"]; 68 [label="Jump: ^test_4 R|/getInt|(block = getInt@fun (): R|kotlin/Unit| { ^test_4 Int(1) } diff --git a/compiler/fir/resolve/testData/resolve/cfg/postponedLambdas.dot b/compiler/fir/resolve/testData/resolve/cfg/postponedLambdas.dot index 148a19a8eb9..034e2c5853c 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/postponedLambdas.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/postponedLambdas.dot @@ -24,10 +24,7 @@ digraph postponedLambdas_kt { } 8 [label="Postponed exit from lambda"]; 9 [label="Access variable R|/b|"]; - 10 [label="Function call: R|/foo|(vararg(R|/a|, foo@fun (): R|kotlin/String| { - ^ String() -} -, R|/b|))"]; + 10 [label="Function call: R|/foo|(vararg(R|/a|, foo@fun (): R|kotlin/String| , R|/b|))"]; 11 [label="Exit function test" style="filled" fillcolor=red]; } diff --git a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.dot b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.dot index fab2014ddc3..f95d2c345ce 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/propertiesAndInitBlocks.dot @@ -128,27 +128,7 @@ digraph propertiesAndInitBlocks_kt { 41 [label="Exit function anonymousFunction"]; } 42 [label="Postponed exit from lambda"]; - 43 [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|() - } - - local final class LocalClass : R|kotlin/Any| { - public constructor(): R|LocalClass| { - super() - } - - init { - throw R|java/lang/Exception.Exception|() - Int(1) - } - - } - - throw R|java/lang/Exception.Exception|() -} -)"]; + 43 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| )"]; 44 [label="Exit property" style="filled" fillcolor=red]; } diff --git a/compiler/fir/resolve/testData/resolve/cfg/returnValuesFromLambda.dot b/compiler/fir/resolve/testData/resolve/cfg/returnValuesFromLambda.dot index bf3128a99f6..0402cdd9ca5 100644 --- a/compiler/fir/resolve/testData/resolve/cfg/returnValuesFromLambda.dot +++ b/compiler/fir/resolve/testData/resolve/cfg/returnValuesFromLambda.dot @@ -52,16 +52,7 @@ digraph returnValuesFromLambda_kt { 21 [label="Exit function anonymousFunction"]; } 22 [label="Postponed exit from lambda"]; - 23 [label="Function call: R|kotlin/run|( = run@fun (): R|A| { - when () { - R|/b| -> { - ^@run R|/B.B|() - } - } - - ^ R|/C.C|() -} -)"]; + 23 [label="Function call: R|kotlin/run|( = run@fun (): R|A| )"]; 24 [label="Variable declaration: lval x: R|A|"]; 25 [label="Exit function test_1" style="filled" fillcolor=red]; } @@ -103,10 +94,7 @@ digraph returnValuesFromLambda_kt { 32 [label="Exit function anonymousFunction"]; } 33 [label="Postponed exit from lambda"]; - 34 [label="Function call: R|kotlin/run|( = run@fun (): R|C| { - ^@run R|/C.C|() -} -)"]; + 34 [label="Function call: R|kotlin/run|( = run@fun (): R|C| )"]; 35 [label="Variable declaration: lval x: R|C|"]; 36 [label="Exit function test_2" style="filled" fillcolor=red]; } @@ -136,10 +124,7 @@ digraph returnValuesFromLambda_kt { 42 [label="Exit function anonymousFunction" style="filled" fillcolor=gray]; } 43 [label="Postponed exit from lambda"]; - 44 [label="Function call: R|kotlin/run|( = run@fun (): R|kotlin/Nothing| { - ^test_3 Unit -} -)"]; + 44 [label="Function call: R|kotlin/run|( = run@fun (): R|kotlin/Nothing| )"]; 45 [label="Stub" style="filled" fillcolor=gray]; 46 [label="Variable declaration: lval x: R|kotlin/Nothing|" style="filled" fillcolor=gray]; 47 [label="Exit function test_3" style="filled" fillcolor=red]; diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.dot b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.dot index 1a12979d9f3..5df5c156d97 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/controlStructures/returns.dot @@ -427,10 +427,7 @@ digraph returns_kt { 161 [label="Variable declaration: lval length: R|kotlin/Int|"]; 162 [label="Postponed enter to lambda"]; 163 [label="Postponed exit from lambda"]; - 164 [label="Function call: R|/runHigherOrder|( = runHigherOrder@fun (): R|kotlin/Int| { - ^ R|/s|.R|kotlin/String.length| -} -)"]; + 164 [label="Function call: R|/runHigherOrder|( = runHigherOrder@fun (): R|kotlin/Int|)"]; 165 [label="Exit function test_4" style="filled" fillcolor=red]; } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/inPlaceLambdas.dot b/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/inPlaceLambdas.dot index 09e9c4754e5..e633b9ad171 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/inPlaceLambdas.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/lambdas/inPlaceLambdas.dot @@ -56,10 +56,7 @@ digraph inPlaceLambdas_kt { 20 [label="Exit function anonymousFunction"]; } 21 [label="Postponed exit from lambda"]; - 22 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { - R|/x|.R|/A.foo|() -} -)"]; + 22 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| )"]; 23 [label="Exit block"]; } 24 [label="Exit when branch result"]; @@ -102,10 +99,7 @@ digraph inPlaceLambdas_kt { 32 [label="Exit function anonymousFunction"]; } 33 [label="Postponed exit from lambda"]; - 34 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { - ^ (R|/x| as R|B|) -} -)"]; + 34 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| )"]; 35 [label="Access variable R|/x|"]; 36 [label="Function call: R|/x|.R|/B.bar|()"]; 37 [label="Exit function test_2" style="filled" fillcolor=red]; @@ -153,11 +147,7 @@ digraph inPlaceLambdas_kt { 53 [label="Exit function anonymousFunction"]; } 54 [label="Postponed exit from lambda"]; - 55 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| { - R|/x|.R|/A.foo|() - ^ (R|/x| as R|B|) -} -)"]; + 55 [label="Function call: R|/run|( = run@fun (): R|kotlin/Unit| )"]; 56 [label="Access variable R|/x|"]; 57 [label="Function call: R|/x|.R|/B.bar|()"]; 58 [label="Exit block"]; diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.dot b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.dot index 7d413f4d1a1..347705c39f8 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/receivers/implicitReceivers.dot @@ -215,46 +215,18 @@ digraph implicitReceivers_kt { 79 [label="Exit function anonymousFunction"]; } 80 [label="Postponed exit from lambda"]; - 81 [label="Function call: R|kotlin/with|(R|/c|, = wc@fun R|kotlin/Any|.(): R|kotlin/Unit| { - (this@R|special/anonymous| as R|A|) - this@R|special/anonymous|.R|/A.foo|() - this@R|special/anonymous|.R|/A.foo|() -} -)"]; + 81 [label="Function call: R|kotlin/with|(R|/c|, = wc@fun R|kotlin/Any|.(): R|kotlin/Unit| )"]; 82 [label="Access variable this@R|special/anonymous|"]; 83 [label="Function call: this@R|special/anonymous|.R|/A.foo|()"]; 84 [label="Function call: this@R|special/anonymous|.R|/A.foo|()"]; 85 [label="Exit function anonymousFunction"]; } 86 [label="Postponed exit from lambda"]; - 87 [label="Function call: R|kotlin/with|(R|/b|, = wb@fun R|kotlin/Any|.(): R|kotlin/Unit| { - R|kotlin/with|(R|/c|, = wc@fun R|kotlin/Any|.(): R|kotlin/Unit| { - (this@R|special/anonymous| as R|A|) - this@R|special/anonymous|.R|/A.foo|() - this@R|special/anonymous|.R|/A.foo|() - } - ) - this@R|special/anonymous|.R|/A.foo|() - this@R|special/anonymous|.R|/A.foo|() -} -)"]; + 87 [label="Function call: R|kotlin/with|(R|/b|, = wb@fun R|kotlin/Any|.(): R|kotlin/Unit| )"]; 88 [label="Exit function anonymousFunction"]; } 89 [label="Postponed exit from lambda"]; - 90 [label="Function call: R|kotlin/with|(R|/a|, = wa@fun R|kotlin/Any|.(): R|kotlin/Unit| { - R|kotlin/with|(R|/b|, = wb@fun R|kotlin/Any|.(): R|kotlin/Unit| { - R|kotlin/with|(R|/c|, = wc@fun R|kotlin/Any|.(): R|kotlin/Unit| { - (this@R|special/anonymous| as R|A|) - this@R|special/anonymous|.R|/A.foo|() - this@R|special/anonymous|.R|/A.foo|() - } - ) - this@R|special/anonymous|.R|/A.foo|() - this@R|special/anonymous|.R|/A.foo|() - } - ) -} -)"]; + 90 [label="Function call: R|kotlin/with|(R|/a|, = wa@fun R|kotlin/Any|.(): R|kotlin/Unit| )"]; 91 [label="Exit function test_3" style="filled" fillcolor=red]; } diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCalls.dot b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCalls.dot index 899cbb8409f..62e2b62227c 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCalls.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/safeCalls/safeCalls.dot @@ -115,10 +115,7 @@ digraph safeCalls_kt { 45 [label="Enter safe call"]; 46 [label="Postponed enter to lambda"]; 47 [label="Postponed exit from lambda"]; - 48 [label="Function call: (R|/x| as? R|A|)?.R|/A.bar|(R|/x|)?.R|/foo|(R|/x|.R|/A.bool|())?.R|/let|( = let@fun (): R|kotlin/Unit| { - ^ R|/x|.R|/A.bool|() -} -)"]; + 48 [label="Function call: (R|/x| as? R|A|)?.R|/A.bar|(R|/x|)?.R|/foo|(R|/x|.R|/A.bool|())?.R|/let|( = let@fun (): R|kotlin/Unit|)"]; 49 [label="Exit safe call"]; 50 [label="Access variable R|/x|"]; 51 [label="Function call: R|/x|.#()"]; @@ -205,18 +202,12 @@ digraph safeCalls_kt { 77 [label="Exit function anonymousFunction" style="filled" fillcolor=gray]; } 78 [label="Postponed exit from lambda"]; - 79 [label="Function call: R|/x|?.R|kotlin/let|( = let@fun (it: R|A|): R|kotlin/Nothing| { - ^test_5 Unit -} -)"]; + 79 [label="Function call: R|/x|?.R|kotlin/let|( = let@fun (it: R|A|): R|kotlin/Nothing| )"]; 80 [label="Exit safe call"]; 81 [label="Enter safe call"]; 82 [label="Access variable R|/x|"]; 83 [label="Function call: R|/x|.R|/A.bool|()"]; - 84 [label="Function call: R|/x|?.R|kotlin/let|( = let@fun (it: R|A|): R|kotlin/Nothing| { - ^test_5 Unit -} -)?.R|/boo|(R|/x|.R|/A.bool|())"]; + 84 [label="Function call: R|/x|?.R|kotlin/let|( = let@fun (it: R|A|): R|kotlin/Nothing| )?.R|/boo|(R|/x|.R|/A.bool|())"]; 85 [label="Exit safe call"]; 86 [label="Access variable R|/x|"]; 87 [label="Function call: R|/x|.#()"]; diff --git a/compiler/fir/resolve/testData/resolve/smartcasts/smartcastToNothing.dot b/compiler/fir/resolve/testData/resolve/smartcasts/smartcastToNothing.dot index f6389130fce..bc4de38bc15 100644 --- a/compiler/fir/resolve/testData/resolve/smartcasts/smartcastToNothing.dot +++ b/compiler/fir/resolve/testData/resolve/smartcasts/smartcastToNothing.dot @@ -217,10 +217,7 @@ digraph smartcastToNothing_kt { 89 [label="Exit function anonymousFunction"]; } 90 [label="Postponed exit from lambda"]; - 91 [label="Function call: R|/s|?.R|kotlin/let|( = let@fun (it: R|A|): R|kotlin/Int| { - ^ R|/it|.R|/A.a| -} -)"]; + 91 [label="Function call: R|/s|?.R|kotlin/let|( = let@fun (it: R|A|): R|kotlin/Int| )"]; 92 [label="Exit safe call"]; 93 [label="Exit function test_0" style="filled" fillcolor=red]; } diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/contracts/callsInPlace.dot b/compiler/fir/resolve/testData/resolveWithStdlib/contracts/callsInPlace.dot index 799f9c93eb6..767bcfc5bd2 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/contracts/callsInPlace.dot +++ b/compiler/fir/resolve/testData/resolveWithStdlib/contracts/callsInPlace.dot @@ -16,10 +16,7 @@ digraph callsInPlace_kt { 6 [label="Exit function anonymousFunction"]; } 7 [label="Postponed exit from lambda"]; - 8 [label="Function call: R|kotlin/run|( = run@fun (): R|kotlin/Unit| { - R|/x| = Int(1) -} -)"]; + 8 [label="Function call: R|kotlin/run|( = run@fun (): R|kotlin/Unit| )"]; 9 [label="Access variable R|/x|"]; 10 [label="Function call: R|/x|.R|kotlin/Int.inc|()"]; 11 [label="Exit function test" style="filled" fillcolor=red]; @@ -50,10 +47,7 @@ digraph callsInPlace_kt { 17 [label="Exit function anonymousFunction"]; } 18 [label="Postponed exit from lambda"]; - 19 [label="Function call: R|kotlin/repeat|(Int(10), = repeat@fun (it: R|kotlin/Int|): R|kotlin/Unit| { - ^ String(test_2) -} -)"]; + 19 [label="Function call: R|kotlin/repeat|(Int(10), = repeat@fun (it: R|kotlin/Int|): R|kotlin/Unit| )"]; 20 [label="Exit function test_2" style="filled" fillcolor=red]; } @@ -80,10 +74,7 @@ digraph callsInPlace_kt { } 26 [label="Postponed exit from lambda"]; 27 [label="Const: Int(10)"]; - 28 [label="Function call: R|kotlin/repeat|(action = repeat@fun (it: R|kotlin/Int|): R|kotlin/Unit| { - ^ String(test_3) -} -, times = Int(10))"]; + 28 [label="Function call: R|kotlin/repeat|(action = repeat@fun (it: R|kotlin/Int|): R|kotlin/Unit| , times = Int(10))"]; 29 [label="Exit function test_3" style="filled" fillcolor=red]; } @@ -113,11 +104,7 @@ digraph callsInPlace_kt { 38 [label="Exit function anonymousFunction"]; } 39 [label="Postponed exit from lambda"]; - 40 [label="Function call: Int(1).R|kotlin/takeUnless|( = takeUnless@fun (it: R|kotlin/Int|): R|kotlin/Boolean| { - String(test_4) - ^ >(R|/it|, Int(0)) -} -)"]; + 40 [label="Function call: Int(1).R|kotlin/takeUnless|( = takeUnless@fun (it: R|kotlin/Int|): R|kotlin/Boolean| )"]; 41 [label="Exit function test_4" style="filled" fillcolor=red]; } @@ -149,11 +136,7 @@ digraph callsInPlace_kt { 50 [label="Exit function anonymousFunction"]; } 51 [label="Postponed exit from lambda"]; - 52 [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)) -} -)"]; + 52 [label="Function call: Int(1).R|kotlin/takeUnless|(predicate = takeUnless@fun (it: R|kotlin/Int|): R|kotlin/Boolean| )"]; 53 [label="Exit function test_5" style="filled" fillcolor=red]; } @@ -201,13 +184,7 @@ digraph callsInPlace_kt { 67 [label="Exit function anonymousFunction"]; } 68 [label="Postponed exit from lambda"]; - 69 [label="Function call: R|/myRun|(myRun@fun (): R|kotlin/Unit| { - ^ String(test_6_1) -} -, = myRun@fun (): R|kotlin/Unit| { - ^ String(test_6_2) -} -)"]; + 69 [label="Function call: R|/myRun|(myRun@fun (): R|kotlin/Unit| , = myRun@fun (): R|kotlin/Unit| )"]; 70 [label="Exit function test_6" style="filled" fillcolor=red]; } @@ -247,13 +224,7 @@ digraph callsInPlace_kt { 80 [label="Exit function anonymousFunction"]; } 81 [label="Postponed exit from lambda"]; - 82 [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) -} -)"]; + 82 [label="Function call: R|/myRun|(block2 = myRun@fun (): R|kotlin/Unit| , block1 = myRun@fun (): R|kotlin/Unit| )"]; 83 [label="Exit function test_7" style="filled" fillcolor=red]; } @@ -289,10 +260,7 @@ digraph callsInPlace_kt { 87 [label="Enter function test_8" style="filled" fillcolor=red]; 88 [label="Postponed enter to lambda"]; 89 [label="Postponed exit from lambda"]; - 90 [label="Function call: R|/myDummyRun|( = myDummyRun@fun (): R|kotlin/Unit| { - ^ String(test_8) -} -)"]; + 90 [label="Function call: R|/myDummyRun|( = myDummyRun@fun (): R|kotlin/Unit|)"]; 91 [label="Exit function test_8" style="filled" fillcolor=red]; } diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot b/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot index a440a846d76..74c717dc364 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot +++ b/compiler/fir/resolve/testData/resolveWithStdlib/smartcasts/tryWithLambdaInside.dot @@ -47,10 +47,7 @@ digraph tryWithLambdaInside_kt { 15 [label="Exit function anonymousFunction"]; } 16 [label="Postponed exit from lambda"]; - 17 [label="Function call: R|/list|.R|kotlin/collections/filter|( = filter@fun (it: R|kotlin/Boolean|): R|kotlin/Boolean| { - ^ R|/it| -} -)"]; + 17 [label="Function call: R|/list|.R|kotlin/collections/filter|( = filter@fun (it: R|kotlin/Boolean|): R|kotlin/Boolean| )"]; 18 [label="Exit block"]; } 19 [label="Try main block exit"]; @@ -119,10 +116,7 @@ finally { 32 [label="Access variable R|/list|"]; 33 [label="Postponed enter to lambda"]; 34 [label="Postponed exit from lambda"]; - 35 [label="Function call: R|/list|.R|/notInPlaceFilter|( = notInPlaceFilter@fun (it: R|kotlin/Boolean|): R|kotlin/Boolean| { - ^ R|/it| -} -)"]; + 35 [label="Function call: R|/list|.R|/notInPlaceFilter|( = notInPlaceFilter@fun (it: R|kotlin/Boolean|): R|kotlin/Boolean|)"]; 36 [label="Exit block"]; } 37 [label="Try main block exit"]; diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index bb472c76085..d2d3fc44642 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -25,21 +25,27 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.visitors.FirVisitor import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid import org.jetbrains.kotlin.name.SpecialNames import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.addToStdlib.safeAs -fun FirElement.renderWithType(): String = buildString { +fun FirElement.renderWithType(mode: FirRenderer.RenderMode = FirRenderer.RenderMode.Normal): String = buildString { append(this@renderWithType) append(": ") - this@renderWithType.accept(FirRenderer(this)) + this@renderWithType.accept(FirRenderer(this, mode)) } -fun FirElement.render(): String = buildString { this@render.accept(FirRenderer(this)) } +fun FirElement.render(mode: FirRenderer.RenderMode = FirRenderer.RenderMode.Normal): String = + buildString { this@render.accept(FirRenderer(this, mode)) } + +class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderMode.Normal) : FirVisitorVoid() { + enum class RenderMode { + Normal, DontRenderLambdaBodies + } -class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { private val printer = Printer(builder) private var lineBeginning = true @@ -421,7 +427,9 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { if (anonymousFunction.invocationKind != null) { print(" ") } - anonymousFunction.body?.renderBody() + if (mode != RenderMode.DontRenderLambdaBodies) { + anonymousFunction.body?.renderBody() + } } override fun > visitFunction(function: FirFunction) {