flowchart TD
    classDef nowrapClass text-align:center,white-space:nowrap;
    classDef callStyle fill:#f2debb,stroke:#333,stroke-width:4px;
    classDef candidateStyle fill:#f2e5ce,stroke:#333,stroke-width:4px;
    classDef stageStyle fill:#c8f0f7,stroke:#333,stroke-width:4px;
    classDef readinessStyle fill:#fff4d6,stroke:#777,stroke-width:1px;

    session0["<tt>Source session for module &lt;main></tt>"]
    class session0 nowrapClass;

    session0 --> call1

    call1["Call 1<br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>TODO#()</tt></pre>"]
    class call1 nowrapClass;
    class call1 callStyle;

    call1 --> candidate2

    candidate2["Candidate 1: <tt>FirNamedFunctionSymbol kotlin/TODO</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>@InlineOnly() fun TODO(): Nothing
</tt></pre>"]
    class candidate2 nowrapClass;
    class candidate2 candidateStyle;

    candidate2 --> stage3

    stage3["Continue Resolution Stages > CheckLambdaAgainstTypeVariableContradiction"]
    class stage3 nowrapClass;
    class stage3 stageStyle;
    constraint4["<tt>Nothing &lt;: P</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>ExpectedType for some call</tt></pre></i>"]
    class constraint4 nowrapClass;
    stage3 ~~~ constraint4

    constraint4 ~~~ call5

    call5["Call 2<br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>ifTrue#(R|&lt;local>/flag|, &lt;L> = ifTrue@fun &lt;implicit>.&lt;anonymous>(): &lt;implicit> &lt;inline=Unknown>  {
    try {
        parse#(decode#(token#))
    }
    catch (e: Exception) {
        Null(null)
    }

}
)</tt></pre>"]
    class call5 nowrapClass;
    class call5 callStyle;

    call5 --> candidate6

    candidate6["Candidate 1: <tt>FirNamedFunctionSymbol /ifTrue</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>fun &lt;T : Any> ifTrue(condition: Boolean, exec: () -> T?): T?</tt></pre>"]
    class candidate6 nowrapClass;
    class candidate6 candidateStyle;

    candidate6 --> stage7

    stage7["Resolution Stages > CreateFreshTypeVariableSubstitutorStage"]
    class stage7 nowrapClass;
    class stage7 stageStyle;

    stage7 ~~~ newVariable8

    newVariable8["New <tt>TypeVariable(T)</tt> for <tt>FirNamedFunctionSymbol /ifTrue</tt>s parameter 0"]
    class newVariable8 nowrapClass;
    constraint9["<tt>TypeVariable(T) &lt;: Any</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>DeclaredUpperBound</tt></pre></i>"]
    class constraint9 nowrapClass;
    newVariable8 ~~~ constraint9

    constraint9 ~~~ stage10

    stage10["Resolution Stages > CheckArguments"]
    class stage10 nowrapClass;
    class stage10 stageStyle;
    constraint11["<tt>Boolean &lt;: Boolean</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Argument R|&lt;local>/flag|</tt></pre></i>"]
    class constraint11 nowrapClass;
    stage10 ~~~ constraint11
    constraint12["<tt>() -> TypeVariable(T)? &lt;: () -> TypeVariable(T)?</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Argument &lt;L> = ifTrue &lt;implicit>.&lt;anonymous>(): &lt;implicit> &lt;inline=Unknown>  {
    try {
        parse#(decode#(token#))
    }
    catch (e: Exception) {
        Null(null)
    }

}
</tt></pre></i>"]
    class constraint12 nowrapClass;
    stage10 ~~~ constraint12

    constraint11 ~~~ stage13
    constraint12 ~~~ stage13

    stage13["Resolution Stages > CheckLambdaAgainstTypeVariableContradiction"]
    class stage13 nowrapClass;
    class stage13 stageStyle;
    constraint14["<tt>TypeVariable(T)? &lt;: Result?</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>ExpectedType for some call</tt></pre></i>"]
    class constraint14 nowrapClass;
    stage13 ~~~ constraint14

    constraint14 ~~~ call15

    call15["Call 3<br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>decode#(R|&lt;local>/token|)</tt></pre>"]
    class call15 nowrapClass;
    class call15 callStyle;

    call15 --> candidate16

    candidate16["Candidate 1: <tt>FirNamedFunctionSymbol /decode</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>fun decode(src: String): String</tt></pre>"]
    class candidate16 nowrapClass;
    class candidate16 candidateStyle;

    candidate16 --> stage17

    stage17["Resolution Stages > CheckArguments"]
    class stage17 nowrapClass;
    class stage17 stageStyle;
    constraint18["<tt>String &lt;: String</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Argument R|&lt;local>/token|</tt></pre></i>"]
    class constraint18 nowrapClass;
    stage17 ~~~ constraint18

    constraint18 ~~~ call19

    call19["Call 4<br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>parse#(R|/decode|(R|&lt;local>/token|))</tt></pre>"]
    class call19 nowrapClass;
    class call19 callStyle;

    call19 --> candidate20

    candidate20["Candidate 1: <tt>FirNamedFunctionSymbol /parse</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>fun &lt;reified P : Any> parse(text: String): P</tt></pre>"]
    class candidate20 nowrapClass;
    class candidate20 candidateStyle;

    candidate20 --> stage21

    stage21["Resolution Stages > CreateFreshTypeVariableSubstitutorStage"]
    class stage21 nowrapClass;
    class stage21 stageStyle;

    stage21 ~~~ newVariable22

    newVariable22["New <tt>TypeVariable(P)</tt> for <tt>FirNamedFunctionSymbol /parse</tt>s parameter 0"]
    class newVariable22 nowrapClass;
    constraint23["<tt>TypeVariable(P) &lt;: Any</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>DeclaredUpperBound</tt></pre></i>"]
    class constraint23 nowrapClass;
    newVariable22 ~~~ constraint23

    constraint23 ~~~ stage24

    stage24["Resolution Stages > CheckArguments"]
    class stage24 nowrapClass;
    class stage24 stageStyle;
    constraint25["<tt>String &lt;: String</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Argument R|/decode|(R|&lt;local>/token|)</tt></pre></i>"]
    class constraint25 nowrapClass;
    stage24 ~~~ constraint25

    constraint25 ~~~ stage26

    stage26["Call Completion"]
    class stage26 nowrapClass;
    class stage26 stageStyle;

    stage26 ~~~ variableReadiness27

    variableReadiness27["Choose <tt>TypeVariable(P)</tt> with <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Readiness(
	false ALLOWED
	false HAS_PROPER_CONSTRAINTS
	false HAS_NO_OUTER_TYPE_VARIABLE_DEPENDENCY
	false HAS_CAPTURED_UPPER_BOUND_WITH_SELF_TYPES
	false HAS_PROPER_NON_SELF_TYPE_BASED_CONSTRAINT
	false HAS_NO_DEPENDENCIES_TO_OTHER_VARIABLES
	false HAS_PROPER_NON_TRIVIAL_CONSTRAINTS
	false HAS_NO_RELATION_TO_ANY_OUTPUT_TYPE
	false HAS_PROPER_NON_TRIVIAL_CONSTRAINTS_OTHER_THAN_INCORPORATED_FROM_DECLARED_UPPER_BOUND
	false REIFIED
	false HAS_PROPER_NON_ILT_CONSTRAINT
)</tt></pre>"]
    class variableReadiness27 nowrapClass;
    class variableReadiness27 readinessStyle;

    variableReadiness27 ~~~ call28

    call28["Call 5<br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>try {
    R?C|/parse|(R|/decode|(R|&lt;local>/token|))
}
catch (e: R|{kotlin/Exception=} java/lang/Exception|) {
    Null(null)
}
</tt></pre>"]
    class call28 nowrapClass;
    class call28 callStyle;

    call28 --> candidate29

    candidate29["Candidate 1: <tt>FirSyntheticFunctionSymbol _synthetic/TRY_CALL</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>fun &lt;K> TRY_CALL(vararg branches: K): K
</tt></pre>"]
    class candidate29 nowrapClass;
    class candidate29 candidateStyle;

    candidate29 --> stage30

    stage30["Resolution Stages > CreateFreshTypeVariableSubstitutorStage"]
    class stage30 nowrapClass;
    class stage30 stageStyle;

    stage30 ~~~ newVariable31

    newVariable31["New <tt>TypeVariable(K)</tt> for <tt>FirSyntheticFunctionSymbol _synthetic/TRY_CALL</tt>s parameter 0"]
    class newVariable31 nowrapClass;

    newVariable31 ~~~ stage32

    stage32["Resolution Stages > CheckArguments"]
    class stage32 nowrapClass;
    class stage32 stageStyle;
    constraint33["<tt>TypeVariable(P) &lt;: TypeVariable(K)</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Argument R?C|/parse|(R|/decode|(R|&lt;local>/token|))</tt></pre></i>"]
    class constraint33 nowrapClass;
    stage32 ~~~ constraint33
    constraint34["<tt>Nothing? &lt;: TypeVariable(K)</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Argument Null(null)</tt></pre></i>"]
    class constraint34 nowrapClass;
    stage32 ~~~ constraint34

    constraint33 ~~~ stage35
    constraint34 ~~~ stage35

    stage35["Call Completion"]
    class stage35 nowrapClass;
    class stage35 stageStyle;

    stage35 ~~~ variableReadiness36

    variableReadiness36["Choose <tt>TypeVariable(K)</tt> with <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Readiness(
	false ALLOWED
	false HAS_PROPER_CONSTRAINTS
	false HAS_NO_OUTER_TYPE_VARIABLE_DEPENDENCY
	false HAS_CAPTURED_UPPER_BOUND_WITH_SELF_TYPES
	false HAS_PROPER_NON_SELF_TYPE_BASED_CONSTRAINT
	false HAS_NO_DEPENDENCIES_TO_OTHER_VARIABLES
	false HAS_PROPER_NON_TRIVIAL_CONSTRAINTS
	false HAS_NO_RELATION_TO_ANY_OUTPUT_TYPE
	false HAS_PROPER_NON_TRIVIAL_CONSTRAINTS_OTHER_THAN_INCORPORATED_FROM_DECLARED_UPPER_BOUND
	false REIFIED
	false HAS_PROPER_NON_ILT_CONSTRAINT
)</tt></pre>"]
    class variableReadiness36 nowrapClass;
    class variableReadiness36 readinessStyle;

    variableReadiness36 ~~~ call37

    call37["Call 2<br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>ifTrue#(R|&lt;local>/flag|, &lt;L> = ifTrue@fun &lt;implicit>.&lt;anonymous>(): &lt;implicit> &lt;inline=Unknown>  {
    try {
        parse#(decode#(token#))
    }
    catch (e: Exception) {
        Null(null)
    }

}
)</tt></pre>"]
    class call37 nowrapClass;
    class call37 callStyle;

    call37 --> candidate38

    candidate38["Candidate 1: <tt>FirNamedFunctionSymbol /ifTrue</tt><br><br><pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>fun &lt;T : Any> ifTrue(condition: Boolean, exec: () -> T?): T?</tt></pre>"]
    class candidate38 nowrapClass;
    class candidate38 candidateStyle;

    candidate38 --> stage39

    stage39["Continue Call Completion"]
    class stage39 nowrapClass;
    class stage39 stageStyle;
    constraint43["<tt>TypeVariable(K) &lt;: TypeVariable(T)?</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>LambdaArgument</tt></pre></i>"]
    class constraint43 nowrapClass;
    stage39 ~~~ constraint43
    constraint44["<tt>TypeVariable(K) &lt;: Any?</tt>"]
    class constraint44 nowrapClass;
    constraint43 --> constraint44
    constraint9 --> constraint44
    constraint45["<tt>TypeVariable(K) &lt;: Result?</tt>"]
    class constraint45 nowrapClass;
    constraint43 --> constraint45
    constraint14 --> constraint45
    constraint46["<tt>TypeVariable(P) &amp; Any &lt;: TypeVariable(T)</tt>"]
    class constraint46 nowrapClass;
    constraint33 --> constraint46
    constraint43 --> constraint46
    constraint47["<tt>TypeVariable(P) &lt;: TypeVariable(T)?</tt>"]
    class constraint47 nowrapClass;
    constraint33 --> constraint47
    constraint43 ---> constraint47
    constraint48["<tt>Nothing &lt;: TypeVariable(T)</tt>"]
    class constraint48 nowrapClass;
    constraint34 --> constraint48
    constraint43 ---> constraint48
    constraint49["<tt>TypeVariable(P) &lt;: Any?</tt>"]
    class constraint49 nowrapClass;
    constraint33 --> constraint49
    constraint44 --> constraint49
    constraint50["<tt>TypeVariable(P) &lt;: Result?</tt>"]
    class constraint50 nowrapClass;
    constraint33 --> constraint50
    constraint45 ---> constraint50

    constraint46 ~~~~~ variableReadiness40
    constraint47 ~~~~ variableReadiness40
    constraint48 ~~~~ variableReadiness40
    constraint49 ~~~~ variableReadiness40
    constraint50 ~~~ variableReadiness40

    variableReadiness40["Choose <tt>TypeVariable(P)</tt> with <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Readiness(
	 true ALLOWED
	 true HAS_PROPER_CONSTRAINTS
	 true HAS_NO_OUTER_TYPE_VARIABLE_DEPENDENCY
	false HAS_CAPTURED_UPPER_BOUND_WITH_SELF_TYPES
	 true HAS_PROPER_NON_SELF_TYPE_BASED_CONSTRAINT
	 true HAS_NO_DEPENDENCIES_TO_OTHER_VARIABLES
	 true HAS_PROPER_NON_TRIVIAL_CONSTRAINTS
	 true HAS_NO_RELATION_TO_ANY_OUTPUT_TYPE
	 true HAS_PROPER_NON_TRIVIAL_CONSTRAINTS_OTHER_THAN_INCORPORATED_FROM_DECLARED_UPPER_BOUND
	 true REIFIED
	 true HAS_PROPER_NON_ILT_CONSTRAINT
)</tt></pre>"]
    class variableReadiness40 nowrapClass;
    class variableReadiness40 readinessStyle;
    constraint51["<tt>TypeVariable(P) == Result</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Fix variable P</tt></pre></i>"]
    class constraint51 nowrapClass;
    variableReadiness40 ~~~ constraint51
    constraint52["<tt>Result &lt;: TypeVariable(K)</tt>"]
    class constraint52 nowrapClass;
    constraint51 --> constraint52
    constraint33 --> constraint52
    constraint53["<tt>Result &lt;: TypeVariable(T)</tt>"]
    class constraint53 nowrapClass;
    constraint51 --> constraint53
    constraint47 --> constraint53

    constraint52 ~~~ variableReadiness41
    constraint53 ~~~ variableReadiness41

    variableReadiness41["Choose <tt>TypeVariable(T)</tt> with <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Readiness(
	 true ALLOWED
	 true HAS_PROPER_CONSTRAINTS
	 true HAS_NO_OUTER_TYPE_VARIABLE_DEPENDENCY
	false HAS_CAPTURED_UPPER_BOUND_WITH_SELF_TYPES
	 true HAS_PROPER_NON_SELF_TYPE_BASED_CONSTRAINT
	 true HAS_NO_DEPENDENCIES_TO_OTHER_VARIABLES
	 true HAS_PROPER_NON_TRIVIAL_CONSTRAINTS
	 true HAS_NO_RELATION_TO_ANY_OUTPUT_TYPE
	 true HAS_PROPER_NON_TRIVIAL_CONSTRAINTS_OTHER_THAN_INCORPORATED_FROM_DECLARED_UPPER_BOUND
	false REIFIED
	 true HAS_PROPER_NON_ILT_CONSTRAINT
)</tt></pre>"]
    class variableReadiness41 nowrapClass;
    class variableReadiness41 readinessStyle;
    constraint54["<tt>TypeVariable(T) == Result</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Fix variable T</tt></pre></i>"]
    class constraint54 nowrapClass;
    variableReadiness41 ~~~ constraint54
    constraint55["<tt>TypeVariable(K) &lt;: Result?</tt>"]
    class constraint55 nowrapClass;
    constraint43 --> constraint55
    constraint54 --> constraint55

    constraint55 ~~~ variableReadiness42

    variableReadiness42["Choose <tt>TypeVariable(K)</tt> with <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Readiness(
	 true ALLOWED
	 true HAS_PROPER_CONSTRAINTS
	 true HAS_NO_OUTER_TYPE_VARIABLE_DEPENDENCY
	false HAS_CAPTURED_UPPER_BOUND_WITH_SELF_TYPES
	 true HAS_PROPER_NON_SELF_TYPE_BASED_CONSTRAINT
	 true HAS_NO_DEPENDENCIES_TO_OTHER_VARIABLES
	 true HAS_PROPER_NON_TRIVIAL_CONSTRAINTS
	 true HAS_NO_RELATION_TO_ANY_OUTPUT_TYPE
	 true HAS_PROPER_NON_TRIVIAL_CONSTRAINTS_OTHER_THAN_INCORPORATED_FROM_DECLARED_UPPER_BOUND
	false REIFIED
	 true HAS_PROPER_NON_ILT_CONSTRAINT
)</tt></pre>"]
    class variableReadiness42 nowrapClass;
    class variableReadiness42 readinessStyle;
    constraint56["<tt>TypeVariable(K) == Result?</tt><br><br><i><div style="display: inline-block;vertical-align: middle;">from</div> <pre style="display: inline-block;vertical-align: middle;text-align: left;margin: 0;"><tt>Fix variable K</tt></pre></i>"]
    class constraint56 nowrapClass;
    variableReadiness42 ~~~ constraint56

    linkStyle 4 stroke:#990000
    linkStyle 9 stroke:#009999
    linkStyle 12 stroke:#4c9900
    linkStyle 13 stroke:#4c0099
    linkStyle 15 stroke:#994900
    linkStyle 19 stroke:#004f99
    linkStyle 24 stroke:#039900
    linkStyle 26 stroke:#950099
    linkStyle 35 stroke:#992400
    linkStyle 36 stroke:#007499
    linkStyle 42 stroke:#279900
    linkStyle 43 stroke:#009999
    linkStyle 44 stroke:#279900
    linkStyle 45 stroke:#994900
    linkStyle 46 stroke:#992400
    linkStyle 47 stroke:#279900
    linkStyle 48 stroke:#992400
    linkStyle 49 stroke:#279900
    linkStyle 50 stroke:#007499
    linkStyle 51 stroke:#279900
    linkStyle 52 stroke:#992400
    linkStyle 53 stroke:#710099
    linkStyle 54 stroke:#992400
    linkStyle 55 stroke:#996d00
    linkStyle 56 stroke:#002b99
    linkStyle 57 stroke:#009921
    linkStyle 58 stroke:#990077
    linkStyle 59 stroke:#991200
    linkStyle 60 stroke:#008699
    linkStyle 62 stroke:#3a9900
    linkStyle 63 stroke:#992400
    linkStyle 64 stroke:#3a9900
    linkStyle 65 stroke:#009921
    linkStyle 66 stroke:#5e0099
    linkStyle 67 stroke:#993600
    linkStyle 69 stroke:#279900
    linkStyle 70 stroke:#006299
    linkStyle 71 stroke:#159900
    style constraint4 stroke:#990000;
    style constraint9 stroke:#009999;
    style constraint11 stroke:#4c9900;
    style constraint12 stroke:#4c0099;
    style constraint14 stroke:#994900;
    style constraint18 stroke:#004f99;
    style constraint23 stroke:#039900;
    style constraint25 stroke:#950099;
    style constraint33 stroke:#992400;
    style constraint34 stroke:#007499;
    style constraint43 stroke:#279900;
    style constraint44 stroke:#710099;
    style constraint45 stroke:#996d00;
    style constraint46 stroke:#002b99;
    style constraint47 stroke:#009921;
    style constraint48 stroke:#990077;
    style constraint49 stroke:#991200;
    style constraint50 stroke:#008699;
    style constraint51 stroke:#3a9900;
    style constraint52 stroke:#5e0099;
    style constraint53 stroke:#993600;
    style constraint54 stroke:#006299;
    style constraint55 stroke:#159900;