ek9_add_to_sealed_allowlist

Rewrites the sealed type's 'allow only' line with the new subtypes appended; answers status, edits[] and summary, each bad entry as conflicts[] (target-not-sealed, entry-does-not-extend-target, entry-already-in-allowlist).

Category: Editor · Compare: Kotlin sealed-hierarchy extension (loose analogue)

When to use it

'Let Pentagon and Hexagon into sealed Shape' is one call with symbol:'Shape' and allowOnly:['Pentagon','Hexagon'] - every unlisted subtype at once, no line.

When not to use it

Details

conflicts kinds (all bad entries reported at once, not just the first): 'target-not-sealed' (mechanical - switch to ek9_seal_type), 'entry-does-not-extend-target' (escalation - add extends / with trait of first), 'entry-already-in-allowlist' (mechanical no-op - drop it from allowOnly). Abstract entry (E05250) and dispatcher-non-exhaustive (E05260) are NOT pre-checked - they surface as would-fail. Entries de-duplicated, appended in the order given; the typical baseline is already E05240-errored, and since apply verifies only NEW diagnostics, clearing it yields 'applied'.

Arguments

ArgumentTypeRequiredWhat it is
allowOnlyarray of stringyesConcrete subtype names to add to the target's 'allow only' list, appended in the order given. Pass every unlisted subtype you intend to permit.
filestringThe EK9 source file - OPTIONAL when symbol is a construct name; required to anchor on a member or a use site.
lineinteger1-based line of the declaration or a reference - OMIT it and pass symbol:'<name>' to let the tool find the line (a model counting lines in a file miscounts); if you do count, use ek9_read_file(lineNumbers:true).
symbolstringyesThe sealed class or trait - a bare name ('Shape') finds its file and declaration workspace-wide; 'mod::Shape' when the name is declared in two modules.

It also takes the arguments every tool takes.

Recorded calls

Real calls, recorded against small projects and checked on every build - a changed answer fails it. 3 of the 7 recorded are shown.

Add to sealed allowlist already in allowlist

Request

{
  "entries" : [ "Circle" ],
  "file" : "shapes.ek9",
  "line" : 6
}

Response

{
  "conflicts" : [ {
    "entry" : "Circle",
    "kind" : "entry-already-in-allowlist",
    "message" : "Circle is already permitted — nothing to add"
  } ],
  "edits" : [ ],
  "meta" : {
    "serverMs" : "<timing>"
  },
  "risk" : {
    "crossesModuleBoundary" : false,
    "estimatedSeverity" : "trivial",
    "fileCount" : 0,
    "lineCount" : 0,
    "touchesPublicApi" : false,
    "touchesTests" : false
  },
  "status" : "conflicts",
  "summary" : "Circle cannot be added to Shape's allow only list",
  "workspaceHash" : "<workspace-hash>",
  "wouldBeDiagnostics" : [ ],
  "written" : false
}

Add to sealed allowlist target not sealed

Request

{
  "entries" : [ "Circle" ],
  "file" : "shapes.ek9",
  "line" : 6
}

Response

{
  "conflicts" : [ {
    "hint" : "seal the type first with ek9_seal_type (which writes the full allow only list)",
    "kind" : "target-not-sealed"
  } ],
  "edits" : [ ],
  "meta" : {
    "serverMs" : "<timing>"
  },
  "risk" : {
    "crossesModuleBoundary" : false,
    "estimatedSeverity" : "trivial",
    "fileCount" : 0,
    "lineCount" : 0,
    "touchesPublicApi" : false,
    "touchesTests" : false
  },
  "status" : "conflicts",
  "summary" : "Shape is not sealed — use ek9_seal_type for initial sealing",
  "workspaceHash" : "<workspace-hash>",
  "wouldBeDiagnostics" : [ ],
  "written" : false
}

Add to sealed allowlist apply

Request

{
  "entries" : [ "Triangle" ],
  "file" : "shapes.ek9",
  "line" : 6
}

Response

{
  "conflicts" : [ ],
  "edits" : [ {
    "after" : "    Shape allow only Circle, Square, Triangle",
    "before" : "    Shape allow only Circle, Square",
    "endLine" : 6,
    "file" : "shapes.ek9",
    "startLine" : 6,
    "type" : "replace"
  } ],
  "meta" : {
    "serverMs" : "<timing>"
  },
  "risk" : {
    "crossesModuleBoundary" : false,
    "estimatedSeverity" : "trivial",
    "fileCount" : 1,
    "lineCount" : 1,
    "touchesPublicApi" : false,
    "touchesTests" : false
  },
  "status" : "applied",
  "summary" : "Changed Added Triangle to Shape allow only list",
  "workspaceHash" : "<workspace-hash>",
...

Cut short here: 3 more lines. The whole recorded call.

See also