Class DynamicConstructMonomorphisation

java.lang.Object
org.ek9lang.compiler.phase7.support.DynamicConstructMonomorphisation

public final class DynamicConstructMonomorphisation extends Object
THE monomorphisation of a dynamic function or dynamic class declared inside a generic body - use this at every site that generates or constructs one, never a variant.

A dynamic construct inside Holder of type T is ONE symbol, recorded once against the generic's AST, and typed with the template's T: its super (Transformer of T), its captured variables, its methods. Scenario 3 generates the generic's bodies once per parameterisation by walking that same AST, so each parameterisation needs ITS OWN class for the dynamic construct, typed with the concrete arguments - otherwise the one class names Holder/T and the never-generated Transformer of T, and the program fails with NoClassDefFoundError (found 2026-10-08 by the generic-omissions sweep, R5).

Outside a monomorphisation the construct is returned unchanged, so nothing outside a generic body moves. Inside one the construct is cloned, renamed (its name plus the concrete type arguments, digested - deterministic and unique per parameterisation) and re-typed through IRGenerationContext.resolveType(ISymbol): its super, traits, captured variables and members (members via ClonedMemberRetyping, THE re-typing phase 6 uses too). The copy is recorded on the context first, so every reference to the construct - in its own body, its constructor call, a dynamic construct nested in it - resolves to the copy.