Class PolymorphicCopy
:=:) through a super-typed reference (Steve, Q5b, 2026-10-08) - its names here, its
parts in support.copy: SelfCopy, IsCopyOwner, HasGeneratedSelfCopy,
IsGeneratedCopy, CopyNeedsRuntimeCheck, NeedsCopyAccepts and InheritedCopySignatures.
Hold those - never a private reading of "who owns this copy" or "which inherited signatures does it override".
A class that DECLARES :=: is a copy OWNER (IsCopyOwner; E07238 guarantees a class adding fields is
one). The object decides which copy runs (N07), so a GENERATED :=: on an owner:
- also OVERRIDES each inherited
:=:(Super)signature (InheritedCopySignatures), so aBase-typedtarget :=: sourceon aLeafruns the Leaf's copy, not Base's; - comes with a generated virtual
_copyAccepts(target as Any) <- Boolean(COPY_ACCEPTS_METHOD) = "istargetan instance of my owner?"; - copies in full only when the source is an instance of the owner (INSTANCEOF, a SUBTYPE test) AND the
source accepts the target (
source._copyAccepts(this)) - i.e. both have the SAME copy owner; else it THROWS an EK9 Exception. Leaf<-Leaf copies; Leaf<-Middle and Leaf<-SubLeaf (which adds fields) throw; a field-less PlainLeaf<-Leaf copies (its owner IS Leaf).
A copy that cannot fail skips the check (CopyNeedsRuntimeCheck): an owner that is CLOSED has no sub-type,
so its own :=:(Owner) only ever meets an Owner, and its overrides need only the INSTANCEOF.
A HAND-WRITTEN :=: is never touched and gets no overrides: its author decides what a copy means. A
generated :=: BELOW a hand-written one still overrides the hand-written signature; its super part calls
the hand-written copy (Contract 19), which runs unchecked as written. _copyAccepts is given to every owner,
hand-written or generated, where one can be asked (NeedsCopyAccepts), because it is a separate method and
is what a generated copy below or above asks. Back-end contract: Contract 20 in
EK9_BACKEND_IR_CONTRACTS.md.
_copyAccepts is not an EK9 name: a leading _ cannot start an EK9 identifier, so it can never be
called from source nor clash with a user's method (as _fieldSetStatus). Its symbol is DETACHED - created
for the IR construct and never defined into the aggregate's scope (F37).
-
Field Details
-
COPY_OPERATOR
-
COPY_ACCEPTS_METHOD
THE generated virtual "would my owner accept this target?" method - an IR/back-end name only.- See Also:
-
COPY_ACCEPTS_PARAMETER
The name of_copyAccepts's single parameter.- See Also:
-