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

@@ -364,7 +364,7 @@ pub const Lowering = struct {
/// Null / absent for the comptime `..$args` pack (no constraint).
pack_constraint: ?std.StringHashMap([]const u8) = null,
struct_const_map: std.StringHashMap(StructConstInfo), // "Struct.CONST" → value info
extern_name_map: std.StringHashMap([]const u8), // sx name → C name for #foreign renames
extern_name_map: std.StringHashMap([]const u8), // sx name → C name for #extern renames
target_config: ?@import("../target.zig").TargetConfig = null, // compilation target (for inline if)
comptime_constants: std.StringHashMap(ComptimeValue), // compile-time known constants (e.g. OS, ARCH)
diagnostics: ?*errors.DiagnosticList = null, // error reporting with source locations
@@ -836,8 +836,8 @@ pub const Lowering = struct {
}
return .unresolved;
}
// `*Self` substitution inside foreign-class member declarations
// — both foreign and sx-defined — resolves to the class's own
// `*Self` substitution inside runtime-class member declarations
// — both runtime and sx-defined — resolves to the class's own
// 0-field stub struct (i.e. the opaque Obj-C pointer type).
// This matches the Obj-C idiom where `self` IS the object.
// `self.field` access on sx-defined classes is rewritten by