refactor(ffi-linkage): Phase 9.3-src — purge 'foreign' from src/ comments + a user-facing diagnostic

Reword every 'foreign' comment to the extern/runtime-class vocabulary matching the
renamed identifiers (foreign call→extern call, foreign class→runtime class, foreign
path→runtime path, the #foreign-literal comment mentions → extern, etc.). Also fixes
two USER-FACING issues: the 'expected … #foreign … after type annotation' parse error
no longer advertises the removed keyword, and the Android 'no #jni_main' help
diagnostic now shows '#jni_class(…) extern' instead of the rejected '#foreign
#jni_class'. Removed the now-dead prefix-#foreign-vs-postfix conflict branch in
parseRuntimeClassDecl (the caller rejects #foreign before it runs).

src/ now contains 'foreign' ONLY in the hash_foreign token machinery + its 4
rejection messages — the deprecation mechanism (kept per the 9.0 recommendation; the
message MUST name #foreign to guide migration). Snapshot-neutral; suite green
(646 corpus / 444 unit, 0 failed).
This commit is contained in:
agra
2026-06-15 09:35:00 +03:00
parent e99383fcb4
commit dc51c4b5bf
35 changed files with 172 additions and 180 deletions

View File

@@ -63,7 +63,7 @@ pub const VisibilityMode = enum {
/// own scope `flat_import_graph`. The PERMANENT core for bare-name lookup
/// under flat imports (Agra constraint) — never a transitional path.
user_bare_flat,
/// `user_bare_flat` plus the foreign-C gate (today's `isCImportVisible`):
/// `user_bare_flat` plus the extern-C gate (today's `isCImportVisible`):
/// only C-import `fn_decl`s without a `library_ref` are policed; everything
/// else is unconditionally visible.
c_import_bare,
@@ -172,13 +172,13 @@ pub fn fnDeclOf(raw: RawDeclRef) ?*const ast.FnDecl {
};
}
/// A PLAIN free function — no type params, an ordinary (non-`#foreign`/
/// A PLAIN free function — no type params, an ordinary (non-`extern`/
/// `#builtin`/`#compiler`/`extern`) body — the only callable kind the bare-call
/// verdict counts.
pub fn isPlainFreeFnDecl(fd: *const ast.FnDecl) bool {
if (fd.type_params.len > 0) return false;
// An `extern` import is an external C symbol with no sx-lowerable body —
// dispatched name-keyed first-wins, exactly like a `#foreign` body, so it
// dispatched name-keyed first-wins, exactly like a `extern` body, so it
// is NOT a plain free fn (excluded from the bare-call ambiguity verdict and
// the out-of-line-slot / shadow-author pass). `export` DEFINES a real sx
// body, so it stays plain-free.
@@ -227,8 +227,8 @@ pub fn classifyHeadKind(raw: RawDeclRef, gs: *bool, tf: *bool, pr: *bool) void {
}
}
/// True when the bare-type verdict selected a foreign-class author
/// unambiguously. Used by lowering to route to the foreign-class path.
/// True when the bare-type verdict selected a runtime-class author
/// unambiguously. Used by lowering to route to the runtime-class path.
pub fn runtimeClassWinsType(set: AuthorSet, verdict: Verdict) bool {
return switch (verdict) {
.own_wins => if (set.own) |a| std.meta.activeTag(a.raw) == .runtime_class_decl else false,