Skip to content

[ffigen] Fix #1268 #2247

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

Merged
merged 1 commit into from
Apr 28, 2025
Merged

[ffigen] Fix #1268 #2247

merged 1 commit into from
Apr 28, 2025

Conversation

liamappelbe
Copy link
Contributor

There's a rareish bug where a specific interface type can be codegenned as a generic ObjCObjectBase. It can happen in methods or properties, in arguments or returns.

I'm not 100% sure what causes it, but it seems to happen when the interface has type params, and is forward declared. Eg, I was able to repro it in the test by writing a method that returns an NSArray<NSString*>*, and forward declaring NSArray and NSString instead of #importing their headers.

The bug is that in the AST these types show up as a CXType_ObjCObject instead of a CXType_ObjCInterface. Their structure is exactly the same as any other interface, but the different kind enum value means that they fall through our parsing switch and default to the generic object type. So the fix is just to add this enum value to the switch.

Fixes #1268

Copy link

PR Health

Breaking changes ⚠️
Package Change Current Version New Version Needed Version Looking good?
objective_c Breaking 7.1.0 7.2.0-wip 8.0.0
Got "7.2.0-wip" expected >= "8.0.0" (breaking changes)
⚠️

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

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
objective_c _Version

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

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 Apr 28, 2025

Coverage Status

coverage: 86.357% (+0.07%) from 86.29%
when pulling 82ff296 on bug1268
into deda4d1 on main.

@liamappelbe liamappelbe merged commit f768349 into main Apr 28, 2025
22 of 23 checks passed
@liamappelbe liamappelbe deleted the bug1268 branch April 28, 2025 21:34
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.

NSArray is not recognized in the generated file
3 participants