agra
2b717d9b38
ffi: resolve foreign-class member types through Self substitution (issue-0043)
...
`inferExprType` for a chained call `Cls.static().instance(...)` never
looked the inner call's foreign-class declaration up, so the outer
dispatch saw a `.s64` receiver, the `foreign_class_map.get(...)` lookup
missed, and lowering emitted `error: unresolved 'method'`. The macOS
target appeared to work because `inline if OS == .ios { ... }` strips
the gated body before lowering — eliding every call that would have
exercised the broken path.
The "lazy-lower" framing in the original issue file was a red herring.
Fix in `src/ir/lower.zig`:
1. `inferExprType` for `.call` with `.field_access` callee now checks
`foreign_class_map` for both shapes — `Cls.static_method(args)` (object
identifier matches a foreign-class alias, look up static members) and
`inst.instance_method(args)` (receiver is a pointer to a foreign-class
struct, look up non-static members).
2. New helpers `resolveForeignMethodReturnType` and
`resolveForeignClassMemberType` substitute `*Self` / `Self` to the
foreign-class struct so a `*Self` return doesn't synthesize a phantom
`Self`-named struct that future dispatches can't resolve.
3. The Obj-C lowering paths (`lowerObjcMethodCall`, `lowerObjcStaticCall`)
route through the same helper for `ret_ty` so the IR Ref's type matches
what `inferExprType` reports.
Regression test at `examples/138-foreign-class-chained-dispatch.sx`
exercises NSObject's `+alloc` / `-init` chain in both shapes —
`*NSObject` return then `*Self` return, and `*Self` then `*Self`. Runs
on the host (macOS) for live exercise; non-macOS hosts fall through to
a stub matching the expected output.
This unblocks Phase 3.2 C4/C5 — the `UIWindow.alloc().initWithWindowScene(scene)`
pattern that surfaced the bug is the cluster's bread-and-butter shape.
167/167 example tests; chess builds clean on macOS, iOS-sim, Android.
2026-05-25 17:52:53 +03:00
..
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 19:44:20 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-05-17 13:19:08 +03:00
2026-05-25 09:10:04 +03:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-05-24 22:59:20 +03:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-20 18:22:42 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 19:44:20 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-15 12:02:36 +02:00
2026-02-22 22:16:30 +02:00
2026-02-22 22:16:30 +02:00
2026-02-22 17:24:04 +02:00
2026-02-22 17:24:04 +02:00
2026-02-22 17:24:04 +02:00
2026-02-22 17:24:04 +02:00
2026-02-22 17:24:04 +02:00
2026-02-28 18:03:38 +02:00
2026-02-23 13:45:44 +02:00
2026-02-23 13:45:44 +02:00
2026-02-25 15:51:22 +02:00
2026-02-25 15:51:22 +02:00
2026-03-02 21:00:55 +02:00
2026-03-02 21:00:55 +02:00
2026-02-15 19:44:20 +02:00
2026-05-25 15:33:28 +03:00
2026-03-05 16:20:36 +02:00
2026-03-05 16:20:36 +02:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 13:19:08 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-17 19:36:37 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 00:11:23 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-19 12:06:08 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 18:32:55 +03:00
2026-05-18 18:32:55 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-19 00:22:35 +03:00
2026-05-19 00:22:35 +03:00
2026-05-19 11:31:04 +03:00
2026-05-19 11:31:04 +03:00
2026-05-19 19:18:31 +03:00
2026-05-19 19:18:31 +03:00
2026-05-19 21:14:31 +03:00
2026-05-19 21:14:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-22 19:03:31 +03:00
2026-05-23 01:28:32 +03:00
2026-05-23 01:28:32 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-24 22:59:20 +03:00
2026-05-25 09:50:37 +03:00
2026-05-25 09:50:37 +03:00
2026-05-25 11:41:59 +03:00
2026-05-25 11:41:59 +03:00
2026-05-25 12:18:27 +03:00
2026-05-25 12:18:27 +03:00
2026-05-25 15:01:58 +03:00
2026-05-25 15:01:58 +03:00
2026-05-25 15:23:13 +03:00
2026-05-25 15:23:13 +03:00
2026-05-25 15:45:33 +03:00
2026-05-25 15:45:33 +03:00
2026-05-25 15:59:32 +03:00
2026-05-25 15:59:32 +03:00
2026-05-25 17:52:53 +03:00
2026-05-25 17:52:53 +03:00
2026-05-19 11:15:13 +03:00
2026-05-19 11:15:13 +03:00
2026-05-19 11:21:16 +03:00
2026-05-19 11:32:36 +03:00
2026-05-19 11:41:06 +03:00
2026-05-19 11:41:06 +03:00
2026-05-19 11:44:43 +03:00
2026-05-19 11:44:43 +03:00
2026-05-19 11:46:47 +03:00
2026-05-19 11:46:47 +03:00
2026-05-19 11:48:34 +03:00
2026-05-19 11:48:34 +03:00
2026-05-19 11:51:34 +03:00
2026-05-19 11:51:34 +03:00
2026-05-19 11:57:44 +03:00
2026-05-19 11:57:44 +03:00
2026-05-19 11:59:18 +03:00
2026-05-19 11:59:18 +03:00
2026-05-22 13:13:43 +03:00
2026-05-22 13:13:43 +03:00
2026-05-19 12:46:53 +03:00
2026-05-19 12:46:53 +03:00
2026-05-19 21:25:42 +03:00
2026-05-19 21:25:42 +03:00
2026-05-19 21:41:26 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 21:41:26 +03:00
2026-05-19 22:26:03 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:26:03 +03:00
2026-05-19 22:30:05 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:30:05 +03:00
2026-05-19 22:31:58 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:31:58 +03:00
2026-05-19 22:33:58 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:33:58 +03:00
2026-05-19 22:36:36 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:36:36 +03:00
2026-05-19 22:40:47 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 22:40:47 +03:00
2026-05-23 01:28:32 +03:00
2026-05-23 01:28:32 +03:00
2026-05-23 01:28:32 +03:00
2026-05-23 01:28:32 +03:00
2026-05-20 09:24:14 +03:00
2026-05-20 09:24:14 +03:00
2026-05-20 09:30:02 +03:00
2026-05-20 09:30:02 +03:00
2026-05-20 09:35:09 +03:00
2026-05-20 09:35:09 +03:00
2026-05-20 10:02:56 +03:00
2026-05-20 10:02:56 +03:00
2026-05-20 10:05:30 +03:00
2026-05-20 10:05:30 +03:00
2026-05-20 10:10:23 +03:00
2026-05-20 10:10:23 +03:00
2026-05-20 10:15:10 +03:00
2026-05-20 10:15:10 +03:00
2026-05-20 11:07:41 +03:00
2026-05-25 15:33:28 +03:00
2026-05-20 11:07:41 +03:00
2026-05-23 01:28:32 +03:00
2026-05-23 01:28:32 +03:00
2026-05-20 10:41:24 +03:00
2026-05-20 10:41:24 +03:00
2026-05-20 10:54:37 +03:00
2026-05-25 15:33:28 +03:00
2026-05-20 10:54:37 +03:00
2026-05-20 13:53:25 +03:00
2026-05-20 13:53:25 +03:00
2026-05-20 14:42:03 +03:00
2026-05-20 14:42:03 +03:00
2026-05-20 16:57:30 +03:00
2026-05-20 16:57:30 +03:00
2026-05-20 17:14:51 +03:00
2026-05-20 17:14:51 +03:00
2026-05-19 12:45:49 +03:00
2026-05-19 12:45:49 +03:00
2026-05-19 12:56:53 +03:00
2026-05-19 12:56:53 +03:00
2026-05-19 12:59:13 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 12:59:13 +03:00
2026-05-19 18:39:10 +03:00
2026-05-19 18:39:10 +03:00
2026-05-19 18:44:14 +03:00
2026-05-19 18:44:14 +03:00
2026-05-19 18:45:57 +03:00
2026-05-25 15:33:28 +03:00
2026-05-19 18:50:26 +03:00
2026-05-19 18:51:56 +03:00
2026-05-19 18:51:56 +03:00
2026-05-19 18:53:19 +03:00
2026-05-19 18:53:19 +03:00
2026-05-19 18:57:41 +03:00
2026-05-19 18:57:41 +03:00
2026-05-19 19:00:47 +03:00
2026-05-19 19:00:47 +03:00
2026-05-19 20:12:09 +03:00
2026-05-19 20:12:09 +03:00
2026-05-19 21:19:09 +03:00
2026-05-19 21:19:09 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:10:22 +03:00
2026-05-25 16:07:19 +03:00
2026-05-25 17:00:23 +03:00
2026-05-25 16:23:24 +03:00
2026-05-25 16:23:24 +03:00
2026-05-25 17:00:23 +03:00
2026-05-25 17:00:23 +03:00
2026-05-25 17:03:16 +03:00
2026-05-25 17:03:16 +03:00
2026-05-25 17:03:16 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00
2026-05-18 17:40:10 +03:00