Package: org.codehaus.groovy.classgen.asm.sc

## [Java] Class StaticTypesSwitchExpressionWriter

- org.codehaus.groovy.classgen.asm.sc.StaticTypesSwitchExpressionWriter

-     public class StaticTypesSwitchExpressionWriter
      extends SwitchExpressionWriter

  Static-compilation writer for SwitchExpression. Emits `tableswitch` / `lookupswitch` when the selector and labels are constants of a type `javac` would switch on, and otherwise the `isCase` method selected by the type checker as a direct call.

  Since:
    6.0.0

- - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class SwitchExpressionWriter` | `controller`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `StaticTypesSwitchExpressionWriter(StaticTypesWriterController controller)` Creates a switch-expression writer for statically compiled methods.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected ClassNode` | `prepareSelectorType(OperandStack operandStack)` Keeps the selector as visited — boxing is deferred until a path actually needs a reference (isCase or a null check on a wrapper).
    `` | `protected void` | `writeIsCaseComparison(CaseStatement caseStatement, int selectorIndex, ClassNode selectorType)` Emits the `isCase` call selected by the type checker as a direct method call via AsmClassGenerator.visitMethodCallExpression, which reaches `StaticInvocationWriter.writeDirectMethodCall`.
    `` | `protected boolean` | `writeOptimizedSwitch(SwitchExpression expression, int selectorIndex, ClassNode selectorType)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class SwitchExpressionWriter` | `enumConstantCount, enumConstantName, intConstant, isIntegralType, isIntegralWrapper, prepareSelectorType, resolveResultType, stringConstant, throwIncompatibleClassChangeError, throwUnmatchedSelector, unwrapEnumType, writeDefaultOrThrow, writeIsCaseComparison, writeOptimizedSwitch, writeSwitchExpression, writeYield`

- - ### Constructor Detail

    - #### public StaticTypesSwitchExpressionWriter(StaticTypesWriterController controller)

      Creates a switch-expression writer for statically compiled methods.

      Parameters:
        `controller` - the static types writer controller

  - ### Method Detail

    - #### protected ClassNode prepareSelectorType(OperandStack operandStack)

      Keeps the selector as visited — boxing is deferred until a path actually needs a reference (isCase or a null check on a wrapper).

    - #### protected void writeIsCaseComparison(CaseStatement caseStatement, int selectorIndex, ClassNode selectorType)

      Emits the `isCase` call selected by the type checker as a direct method call via AsmClassGenerator.visitMethodCallExpression, which reaches `StaticInvocationWriter.writeDirectMethodCall`. A literal `case null` is identity, not `DGM.isCase(Object,Object)` (which NPEs). Any other arm must already carry StaticTypesMarker.DIRECT_METHOD_CALL_TARGET on the CaseStatement; missing targets are a type-checking error except under `TypeCheckingMode.SKIP`.

    - #### protected boolean writeOptimizedSwitch(SwitchExpression expression, int selectorIndex, ClassNode selectorType)