Class CopyConstructor

java.lang.Object
org.ek9lang.compiler.support.CopyConstructor

public final class CopyConstructor extends Object
THE copy constructor of a type: a PUBLIC constructor taking exactly one argument of EXACTLY that type - Step(Step). Call this, do not re-derive it.

🔑 Exact type, never a promotion or a super. A constructor taking a wider type (Step(Any), a trait, the super) or one reached through #^ does not make an independent value of the SAME type, so it is not a copy constructor. The match is drawn on isExactSameType - symbol identity, never a name.

A generic's conceptual T always has one (CommonFactory gives every type parameter a constructor per type parameter, so T(item as T)); a range over T marks it ACCESSED_BY_RANGE, so the type a generic is parameterised with - constrained T included - must have its own, by THIS predicate (phase 4, E08272; Steve R1/R3, 2026-10-07).

Users: the constrained-type copy mechanism (phase2/PopulateConstrainedTypeOrError, Path A), the for-range rule (phase3/ForRangeOrError, E08272), its parameterisation check (phase4/ParameterisedTypeOrError) and the for-range IR (phase7/generator/ RangeIterationHelper: counter = T(start), loop variable = T(counter); Contract 15). Extracted 2026-10-07 from PopulateConstrainedTypeOrError.takesExactlyTheBase when the range copy became a copy-constructor call (Steve, RANGE COPY decision).

  • Method Details

    • of

      public static Optional<MethodSymbol> of(IAggregateSymbol type)
      The public copy constructor of type, if it has one.
    • takesExactlyOne

      public static boolean takesExactlyOne(MethodSymbol method, ISymbol type)
      True when method takes exactly one parameter whose type is exactly type. Used for a copy OPERATOR too (:=: taking exactly the base).