Class PropertyTypeGraph

java.lang.Object
org.ek9lang.compiler.phase5.PropertyTypeGraph

public final class PropertyTypeGraph extends Object
THE property-type graph: which types an object of a given type can reach through its properties. Its cycles are the types whose objects can form a reference cycle, so their GENERATED operators (?, $, $$, ==, <=>, #?) could recurse forever (PropertyCycleMarker).

Nodes - three kinds, so the graph stays LINEAR in types plus properties plus subtype relations:

  • FIELDS(X) - the fields an object of exact type X carries: X's own fields (the same set the generated operators walk, GeneratedOperatorFields) and, through one edge, its super's.
  • HOLDS(T) - what a property DECLARED as T can hold. ONE node per type, however many properties use it: an edge to FIELDS(T) when T can be constructed and one to FIELDS(S) for each concrete subtype S of an open, abstract or trait T (ConcreteSubtypeFinder, whole-program, dynamic classes included). Subtypes are never expanded per property. A built-in generic container (List, Optional, Result, Dict, ...) holds its type arguments, so its node points at theirs.
  • ANY - ONE shared node for Any (and a bare T), with an edge to FIELDS of every concrete aggregate: an Any can hold anything.

A node with ONE successor is never made: a property of a closed type points straight at that type's FIELDS, a List of Node straight at what a Node property would, and a built-in type nothing extends (String, Integer, ...) is not a node at all - it has no properties. So the graph holds the user types plus one node per type that genuinely fans out.

A function-typed property is not followed: a function's generated operators never recurse into what it captured ($$/$ on a function is Any's unset answer, its ? is always true).

Lazy, from the roots. Successors are computed once per node and only for nodes reached (StronglyConnectedComponents asks lazily), so a program with no generated operators builds nothing.