On this page

0069. Visibility is decided per file

Context

Modules merge before checking, but merging must not grant access to opaque representations or make every loaded interface available everywhere. Generic definitions must retain ADR-0024's definition-time checking.

Decision

Compare declaration and use spans through SourceFile.file_index for newtype constructor and .value access. Only the declaring file has access; a foreign impl has no privilege. Qualified names supply provider text, never authority. Public function, struct, enum and interface signatures cannot expose a private type of their module, including nested arguments and bounds. A newtype's representation is exempt. Import-free single files retain existing behavior.

Record declared/imported interfaces by source file in Types. Method lookup uses that file's interfaces plus the current generic bounds; a generic call uses its definition's source scope, not its instantiator's. Builtin methods retain precedence. Coherence remains global with no orphan rule, and duplicate impls in different files name both file/line/column locations.

This completes ADR-0026's opacity commitment and supersedes only the unrestricted method-lookup rule in ADR-0027. It extends ADR-0064 and ADR-0068.

Alternatives considered

Consequences

Opaque IDs enforce their module API without runtime cost or new syntax. Types from imported modules remain qualified in diagnostics, while root names and existing single-file goldens stay bare. M9.1 Step 5 closes tooling support.