Skip to content

feat: support async exported resource methods - #77

Merged
andreiltd merged 1 commit into
mainfrom
feat/async-resource-methods
Aug 31, 2026
Merged

andreiltd merged 1 commit into
mainfrom
feat/async-resource-methods

Conversation

@andreiltd

Copy link
Copy Markdown
Owner

Dispatch async instance methods with the resource receiver as this and resolve async static methods on the exported class.

Dispatch async instance methods with the resource receiver as `this` and
resolve async static methods on the exported class.
@andreiltd
andreiltd merged commit 93b5020 into main Aug 31, 2026
5 checks passed
@andreiltd
andreiltd deleted the feat/async-resource-methods branch August 31, 2026 12:41
@github-actions github-actions Bot mentioned this pull request Aug 31, 2026
malformed-c added a commit to apsis-io/dwarf that referenced this pull request Sep 2, 2026
Two things a resource could not do.

An async resource method was unreachable. The async export wrapper looked
up `func.name().to_lower_camel_case()` on the exports object, and a
resource member's WIT name is `[method]counter.bump`, which camel-cases
into nothing that exists there - so the lookup failed outright. It now
classifies the name the same way the synchronous path does, shifting the
receiver off the front of the arguments and binding it as `this`. A
constructor is rejected with a clear message rather than a failed lookup:
the canonical ABI hands back the handle itself, so there is nothing for a
Promise to resolve to.

A static method was called with no `this` at all, so one static calling
another (`this.parse(...)`, an ordinary thing to write) got undefined.
Its class is now bound as the receiver.

Ported rather than cherry-picked - upstream's dispatch is built on a
refactor dwarf does not share - but dwarf already had the `classify`
helper it needed, in wit_imports.rs. The test covers both halves and was
checked against the unported runtime, where it fails.

Upstream: andreiltd/componentize-qjs#77

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant