Skip to content

Conversation

@liamappelbe
Copy link
Contributor

@liamappelbe liamappelbe commented Dec 10, 2025

  • In dart_generator.dart, I factored out some of the logic for dealing with async methods into a new Method extension
  • Used that extension to add suspend support to _ConcreteImplClosureDef, _AbstractImplFactoryArg, _ConcreteImplClosureCtorArg, and _ConcreteImplMethod
  • _ConcreteImplMethod is where the interesting stuff happens. It constructs a KotlinContinuation, invokes the user's method, then passes the future to KotlinContinuation.resumeWithFuture.
  • KotlinContinuation is a new internal class with some helpers for resuming continuations.
  • Continuations can be resumed with an arbitrary value, an exception wrapped in a kotlin/Result$Failure, or a value wrapped in a kotlin/Result. The existing suspend function invocation logic didn't handle that last case, so I also changed _MethodGenerator to add support for this case. I don't know how common this is in practice though.

Fixes #558

@github-actions
Copy link

github-actions bot commented Dec 10, 2025

PR Health

License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/hooks_runner/test_data/download_assets/hook/build.dart
pkgs/jni/test/debug_release_test.dart
pkgs/objective_c/example/command_line/lib/main.dart
pkgs/objective_c/lib/src/ns_input_stream.dart

This check can be disabled by tagging the PR with skip-license-check.

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources

This check can be disabled by tagging the PR with skip-leaking-check.

Breaking changes ⚠️
Package Change Current Version New Version Needed Version Looking good?
jni Breaking 0.15.2 0.15.3-wip 0.16.0
Got "0.15.3-wip" expected >= "0.16.0" (breaking changes)
⚠️

This check can be disabled by tagging the PR with skip-breaking-check.

@coveralls
Copy link

coveralls commented Dec 17, 2025

Coverage Status

coverage: 87.037% (-5.1%) from 92.127%
when pulling 79cc033 on jnigen_susitf
into 4341e37 on main.

@liamappelbe liamappelbe changed the title WIP: Kotlin interface with suspend method [jnigen] Kotlin interfaces with suspend methods Dec 18, 2025
@liamappelbe liamappelbe marked this pull request as ready for review December 18, 2025 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement a Kotlin interface which includes a suspend fun

2 participants