From f5da453af159e203bc79c346063c87bedd1dc317 Mon Sep 17 00:00:00 2001 From: agra Date: Wed, 20 May 2026 09:28:07 +0300 Subject: [PATCH] ffi 2.2 xfail: instance method body item in `#jni_class` `Foo :: #jni_class("path") { getId :: (self: *Self) -> s32; }` should parse, today's 2.1 parser rejects any non-empty body. The make-green follow-up extends parseJniClassDecl to loop over body items collecting method declarations. --- examples/ffi-jni-class-02-method.sx | 20 ++++++++++++++++++++ tests/expected/ffi-jni-class-02-method.exit | 1 + tests/expected/ffi-jni-class-02-method.txt | 1 + 3 files changed, 22 insertions(+) create mode 100644 examples/ffi-jni-class-02-method.sx create mode 100644 tests/expected/ffi-jni-class-02-method.exit create mode 100644 tests/expected/ffi-jni-class-02-method.txt diff --git a/examples/ffi-jni-class-02-method.sx b/examples/ffi-jni-class-02-method.sx new file mode 100644 index 0000000..ed3d2ea --- /dev/null +++ b/examples/ffi-jni-class-02-method.sx @@ -0,0 +1,20 @@ +// Phase 2 step 2.2 (PLAN-FFI.md): xfail then green for the instance +// method body item inside a `#jni_class` declaration. +// +// `name :: (self: *Self, args...) -> Ret;` is the shape — semicolon +// terminated (foreign declaration, no body). The 2.1 parser only +// accepts an empty body; step 2.2 extends `parseJniClassDecl` to +// loop over body items and collect method declarations. + +#import "modules/std.sx"; + +// `Self` here refers to the enclosing `View` type — resolved at +// 2.x sema, not at parse time. +View :: #jni_class("android/view/View") { + getId :: (self: *Self) -> s32; +} + +main :: () -> s32 { + print("parse-only ok\n"); + 0; +} diff --git a/tests/expected/ffi-jni-class-02-method.exit b/tests/expected/ffi-jni-class-02-method.exit new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/expected/ffi-jni-class-02-method.exit @@ -0,0 +1 @@ +1 diff --git a/tests/expected/ffi-jni-class-02-method.txt b/tests/expected/ffi-jni-class-02-method.txt new file mode 100644 index 0000000..ea7929d --- /dev/null +++ b/tests/expected/ffi-jni-class-02-method.txt @@ -0,0 +1 @@ +/Users/agra/projects/sx/examples/ffi-jni-class-02-method.sx:14:5: error: non-empty `#jni_class` body not yet supported (Phase 2.1 accepts only the empty/opaque form)