Package org.codehaus.groovy.ast

# Class IntersectionTypeClassNode

java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.ClassNode
org.codehaus.groovy.ast.IntersectionTypeClassNode

All Implemented Interfaces:
  `GroovydocHolder<AnnotatedNode>`, `NodeMetaDataHandler`

public final class IntersectionTypeClassNode extends ClassNode
Represents a user-written intersection type used as the target of a cast expression or `as` coercion, e.g.

         (Runnable & Serializable) () -> ...
         value as (A & B)

Distinct from the implicit lowest-upper-bound nodes that `StaticTypeCheckingVisitor` synthesizes during inference: an instance of this class records the ordered list of components exactly as written by the user. That ordering is needed for cast-conversion checks, error messages and (in later phases) bytecode generation via `LambdaMetafactory.altMetafactory` markers.

Lifecycle: at parse time the components have not yet been resolved to bound `ClassNode`s, so the constructor places all components in the inherited `interfaces` array with `Object` as the placeholder superclass. After `ResolveVisitor` resolves each component it should call `reclassifyComponents()` so that the interfaces array contains only interface components and the superclass is the (at most one) class component.

Since:
  6.0.0

- ## Field Summary

  ### Fields inherited from class org.codehaus.groovy.ast.ClassNode

  `clazz, EMPTY_ARRAY, isPrimaryNode, lazyInitLock, SUPER, THIS`

  ### Fields inherited from interface groovy.lang.groovydoc.GroovydocHolder

  `DOC_COMMENT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `IntersectionTypeClassNode(ClassNode[] components)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ClassNode[]`
  `getComponents()`
  Returns the components of this intersection type in user-written order.
  `String`
  `getText()`
  Returns a human-readable text representation of this AST node.
  `void`
  `reclassifyComponents()`
  Reclassifies the components after resolution: separates the (at most one) class component from the interface components and updates the inherited superclass and interfaces accordingly.
  `String`
  `toString(boolean showRedirect)`
  Returns a string representation of this ClassNode with optional redirect information.

  ### Methods inherited from class org.codehaus.groovy.ast.ClassNode

  `addConstructor, addConstructor, addField, addField, addFieldFirst, addFieldFirst, addInterface, addMethod, addMethod, addMixin, addObjectInitializerStatements, addProperty, addProperty, addStaticInitializerStatements, addSyntheticMethod, addTransform, addTypeAnnotation, addTypeAnnotations, asGenericsType, declaresAnyInterfaces, declaresInterface, equals, getAbstractMethods, getAllDeclaredMethods, getAllInterfaces, getAnnotations, getAnnotations, getCompileUnit, getComponentType, getDeclaredConstructor, getDeclaredConstructors, getDeclaredField, getDeclaredMethod, getDeclaredMethods, getDeclaredMethodsMap, getEnclosingMethod, getField, getFieldIndex, getFields, getGenericsTypes, getGetterMethod, getGetterMethod, getInnerClasses, getInterfaces, getMethod, getMethods, getMethods, getMixins, getModifiers, getModule, getName, getNameWithoutPackage, getObjectInitializerStatements, getOuterClass, getOuterClasses, getOuterField, getPackage, getPackageName, getPermittedSubclasses, getPlainNodeReference, getPlainNodeReference, getProperties, getProperty, getRecordComponents, getSetterMethod, getSetterMethod, getSuperClass, getTransforms, getTypeAnnotations, getTypeAnnotations, getTypeClass, getUnresolvedInterfaces, getUnresolvedInterfaces, getUnresolvedName, getUnresolvedSuperClass, getUnresolvedSuperClass, hasDeclaredMethod, hashCode, hasMethod, hasPackageName, hasPossibleMethod, hasPossibleStaticMethod, hasProperty, implementsAnyInterfaces, implementsInterface, isAbstract, isAnnotated, isAnnotationDefinition, isArray, isDerivedFrom, isDerivedFromGroovyObject, isEnum, isGenericsPlaceHolder, isInterface, isPrimaryClassNode, isRecord, isRedirectNode, isResolved, isScript, isScriptBody, isSealed, isStaticClass, isSyntheticPublic, isUsingGenerics, makeArray, parametersEqual, positionStmtsAfterEnumInitStmts, redirect, removeConstructor, removeField, removeMethod, renameField, setAnnotated, setCompileUnit, setEnclosingMethod, setGenericsPlaceHolder, setGenericsTypes, setInterfaces, setMixins, setModifiers, setModule, setName, setPermittedSubclasses, setRecordComponents, setRedirect, setScript, setScriptBody, setStaticClass, setSuperClass, setSyntheticPublic, setUnresolvedSuperClass, setUsingGenerics, toString, tryFindPossibleMethod, visitContents`

  ### Methods inherited from class org.codehaus.groovy.ast.AnnotatedNode

  `addAnnotation, addAnnotation, addAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSynthetic`

  ### Methods inherited from class org.codehaus.groovy.ast.ASTNode

  `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler

  `copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData`

- ## Constructor Details

  - ### IntersectionTypeClassNode

    public IntersectionTypeClassNode(ClassNode[] components)

- ## Method Details

  - ### getComponents

    public ClassNode[] getComponents()
    Returns the components of this intersection type in user-written order.

  - ### reclassifyComponents

    public void reclassifyComponents()
    Reclassifies the components after resolution: separates the (at most one) class component from the interface components and updates the inherited superclass and interfaces accordingly. Components are resolved in place — callers do not need to substitute new instances.

  - ### getText

    public String getText()
    Description copied from class: `ASTNode`
    Returns a human-readable text representation of this AST node. Used for debugging and error messages. Default implementation returns a message indicating the representation is not yet implemented for this node type.
    Overrides:
      `getText` in class `ClassNode`
    Returns:
      text representation of this node, or placeholder for unimplemented types

  - ### toString

    public String toString(boolean showRedirect)
    Description copied from class: `ClassNode`
    Returns a string representation of this ClassNode with optional redirect information. For array types, appends "[]" to the component type's string representation. For generic types, includes generic type parameters (e.g., "List"). If `showRedirect` is `true` and this is a redirect node, includes arrow notation showing the redirect target; otherwise the redirect information is omitted.
    Overrides:
      `toString` in class `ClassNode`
    Parameters:
      `showRedirect` - if `true`, includes redirect information in the output; if `false`, omits it
    Returns:
      a string representation of this ClassNode