Class CaptureEvaluationScope

java.lang.Object
org.ek9lang.compiler.phase3.CaptureEvaluationScope

final class CaptureEvaluationScope extends Object
THE phase-3 answer to "whose code is running here?" for a property field (a private property or a capture) - shared by the access check (E06180 in IdentifierReferenceOrError) and the "read it through a capture" wording of an unresolved name inside a dynamic body (IdentifierReferenceOrError, IdentifierOrError).

The running code is the nearest dynamic function or class on the scope stack, else the nearest method or function. A capture list is the one place that differs (Steve, 2026-10-08, CAPTURES a/b): it is visited with its dynamic construct already on the stack, yet each capture expression is evaluated where the construct is CREATED, so it is judged outside that construct - '(limit: pivot)' in a method of the type that holds 'pivot', and an inner dynamic class capturing its enclosing dynamic function's capture. A capture SHARES the object, as a method returning the property would.

Whether the running code HOLDS a field is identity, never a name: one of its captures (CapturedVariables) or one of its own properties (OwnProperty; a method's are its aggregate's). Only outerFieldNamed(ParseTree, String) matches by name - it words the error for a name that did not resolve, and an unresolved name has nothing else.

deniesAccessTo(ParseTree, ISymbol) is the BARE-NAME half of the private rule (a name resolved up the scope stack, with no receiver). A member reached THROUGH a receiver (peer.count, this.count, a method call) is judged by AccessToSymbolOrError.isAccessible(SymbolAccessData), which is given the receiver's type. The two answer different questions and must agree on the rule: a property is private to the type that declares it, so a sub-type holds none of its super's (D81).

  • Constructor Details

    • CaptureEvaluationScope

      CaptureEvaluationScope(SymbolsAndScopes symbolsAndScopes)
  • Method Details

    • deniesAccessTo

      boolean deniesAccessTo(org.antlr.v4.runtime.tree.ParseTree node, ISymbol symbol)
      THE "may this code reach that property?" check for a BARE name, shared by every site that resolves one against the scope stack: a read (IdentifierReferenceOrError), an assignment, an object-access start, a pre-flow or a for-range (IdentifierOrError), and a stream pipeline part (ResolveFunctionOrDelegateByNameOrError: a sink, head, map with, tee in). True when symbol is a private property field that the code evaluating node does not hold. A sub-type does not hold its super's properties, so naming one in any of those places is denied exactly as reading it is (D81). Where there is no running code to judge against, it is not denied (as it always was).
    • deniedReferenceText

      static String deniedReferenceText(ISymbol symbol)
      The text of a denial, the same at every site: what was named and where it is declared.
    • outerFieldNamed

      Optional<CaptureEvaluationScope.OuterField> outerFieldNamed(org.antlr.v4.runtime.tree.ParseTree node, String name)
      Inside a dynamic function or class body (not its capture list): the property or capture called name of the code AROUND it - the nearest construct outward that has one. A dynamic construct is pulled out to module level, so those fields are never in its scope; reading one directly stays an error (CAPTURES c), and this is what lets the error name the fix.