From 0ed4799f5fa635af7af436f566809ed86a1866b6 Mon Sep 17 00:00:00 2001 From: agra Date: Wed, 20 May 2026 10:06:22 +0300 Subject: [PATCH] ffi 2.6 xfail: `#desc("(Sig)Ret")` per-method JNI descriptor override `weirdMethod :: (self: *Self) -> s32 #desc("()I");` should parse, today's 2.5 parser expects `;` immediately after the return type and errors at the `#desc` token. The make-green follow-up adds a `hash_desc` lexer token and threads an optional `desc_override` field through `JniMethodDecl`. --- examples/ffi-jni-class-06-desc.sx | 20 ++++++++++++++++++++ tests/expected/ffi-jni-class-06-desc.exit | 1 + tests/expected/ffi-jni-class-06-desc.txt | 1 + 3 files changed, 22 insertions(+) create mode 100644 examples/ffi-jni-class-06-desc.sx create mode 100644 tests/expected/ffi-jni-class-06-desc.exit create mode 100644 tests/expected/ffi-jni-class-06-desc.txt diff --git a/examples/ffi-jni-class-06-desc.sx b/examples/ffi-jni-class-06-desc.sx new file mode 100644 index 0000000..6ea385d --- /dev/null +++ b/examples/ffi-jni-class-06-desc.sx @@ -0,0 +1,20 @@ +// Phase 2 step 2.6 (PLAN-FFI.md): xfail then green for the +// `#desc("(Sig)Ret")` per-method JNI-descriptor override. +// +// The default descriptor is derived from sx types (Phase 2.8); `#desc` +// is the escape hatch when the auto-derived signature doesn't match +// (e.g., synthetic methods, ambiguous overloads, accessing JNI +// internals). It appears trailing the method's return type, before +// the terminating `;`. Today the parser expects `;` immediately after +// the return type and errors at the `#desc` token. + +#import "modules/std.sx"; + +Foo :: #jni_class("com/example/Foo") { + weirdMethod :: (self: *Self) -> s32 #desc("()I"); +} + +main :: () -> s32 { + print("parse-only ok\n"); + 0; +} diff --git a/tests/expected/ffi-jni-class-06-desc.exit b/tests/expected/ffi-jni-class-06-desc.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/expected/ffi-jni-class-06-desc.exit @@ -0,0 +1 @@ +1 diff --git a/tests/expected/ffi-jni-class-06-desc.txt b/tests/expected/ffi-jni-class-06-desc.txt new file mode 100644 index 0000000..2ac0d36 --- /dev/null +++ b/tests/expected/ffi-jni-class-06-desc.txt @@ -0,0 +1 @@ +/Users/agra/projects/sx/examples/ffi-jni-class-06-desc.sx:14:41: error: expected ';'