ek9_seal_type

Adds 'allow only A, B, C' to a class or trait declaration (plus 'as open' on a class that has no extensibility modifier); answers status, edits[] and conflicts[] naming any entry that does not extend the target or any existing subtype left off the list.

Category: Editor · Compare: Kotlin "Make sealed" (loose analogue)

When to use it

'Seal Shape to Circle and Square' is one call with symbol:'Shape', allowOnly:['Circle','Square'] - no file or line needed. Use it to INITIALLY seal a class or trait to a known, fixed subtype list for exhaustive dispatch or API lock-down.

When not to use it

Details

Class/trait targets only — records/components/functions error. Every allowOnly entry must ALREADY extend/implement the target (conflicts: entry-does-not-extend-target), and the language requires concrete entries — an abstract entry fails the dry-run compile per E05250. Sealed CLASSES need 'as open' or 'as abstract' per E05270 (existing modifier kept, else 'as open' auto-emitted; traits need none); an already-sealed target returns conflicts (target-already-sealed).

Arguments

ArgumentTypeRequiredWhat it is
allowOnlyarray of stringyesThe 'allow only' list: every concrete class that may extend/implement the target, at any depth.
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).
symbolstringA construct NAME alone ('Shape', 'sample.deps.core::Validator') - no file needed, the tool finds it workspace-wide; or, with file (+ line), the identifier you mean there.

It also takes the arguments every tool takes.

See also