Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jnigen] Respect top-type nullability of type arguments #1909

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

HosseinYousefi
Copy link
Member

Closes #1906.

Keep the original nullability of a type argument T extends Foo, so that even if the type provided is not explicitly identified as nullable or non-nullable (due to a missing annotation or being a kotlin wildcard), it's still generated with regards to the constraints of the top-type Foo.

Copy link

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

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 symbols
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/jni/lib/src/third_party/generated_bindings.dart
pkgs/objective_c/lib/src/ns_input_stream.dart

@coveralls
Copy link

coveralls commented Jan 16, 2025

Coverage Status

coverage: 80.948%. first build
when pulling 63966a3 on kotlin-top-type-nullability
into 817c76e on main.

final definedTypeParams = <String>[];
for (var i = 0; i < node.params.length; ++i) {
final param = node.params[i];
final index = allTypeParams.length - node.params.length + i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allTypeParams stuff feels like it should be factored out into a little helper class or something. You have little bits of logic for dealing with allTypeParams indexes spread throughout this function. Better to consolidate that logic if possible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, rewriting the logic made the code much better!

pkgs/jnigen/lib/src/bindings/dart_generator.dart Outdated Show resolved Hide resolved
@HosseinYousefi HosseinYousefi merged commit 2d3fc60 into main Jan 17, 2025
27 checks passed
@HosseinYousefi HosseinYousefi deleted the kotlin-top-type-nullability branch January 17, 2025 16:22
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.

Kotlin wildcards should be generated as the class top-type
3 participants