Class ClonedMemberRetyping

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

public final class ClonedMemberRetyping extends Object
THE re-typing of members that were cloned from a template onto their new owner - use this, never a variant.

A member cloned from a template still carries the template's types: a T, or a dependent parameterisation such as List of T. Each one is replaced through replacement: a constructor is renamed to its new owner (EK9, like Java, names a constructor after its type) and returns that owner; a method's parameters and returning symbol are re-typed; and every member's own type is re-typed.

Two callers, which differ ONLY in the replacement: phase 6 TypeSubstitution (a parameterised type's members, where the replacement may DEFINE dependent parameterised types) and phase 7 IR generation's monomorphisation of a dynamic class declared inside a generic body (phase7.support.DynamicConstructMonomorphisation, which may only resolve them).

  • Method Details

    • retype

      public static void retype(IScopedSymbol newOwner, List<ISymbol> clonedMembers, UnaryOperator<ISymbol> replacement)
      Re-type the members, in place.
      Parameters:
      newOwner - The symbol the members were cloned onto
      clonedMembers - The cloned members
      replacement - The concrete type for each (possibly template) type
    • retypeOne

      public static void retypeOne(ISymbol value, UnaryOperator<ISymbol> replacement)
      Re-type a single symbol, in place, when it has a type.