Class AcceptableInheritanceDepthOrError
java.lang.Object
org.ek9lang.compiler.phase5.AcceptableInheritanceDepthOrError
- All Implemented Interfaces:
Consumer<org.antlr.v4.runtime.tree.ParseTree>
class AcceptableInheritanceDepthOrError
extends Object
implements Consumer<org.antlr.v4.runtime.tree.ParseTree>
Checks inheritance depth (DIT) against thresholds and emits errors if exceeded.
Based on Chidamber & Kemerer (1994) CK Metrics Suite.
Deep inheritance hierarchies cause the "fragile base class problem" where changes to ancestors cascade unpredictably to descendants. EK9 promotes the use of delegation via the 'by' keyword as a superior alternative.
Thresholds are set slightly below industry standard (4 vs 5-6) because EK9 provides the 'by' delegation mechanism as a built-in alternative:
- class: max 4 (allows Base -> Abstract -> Concrete -> Specialization)
- record: max 2 (data-focused, minimal behavior inheritance)
- trait: max 4 (interface hierarchies)
- component: max 4 (entry points)
- function: max 3 (function inheritance is rare)
-
Constructor Summary
ConstructorsConstructorDescriptionAcceptableInheritanceDepthOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
-
Constructor Details
-
AcceptableInheritanceDepthOrError
AcceptableInheritanceDepthOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
-