Skip to content

Conversation

liamappelbe
Copy link
Contributor

@liamappelbe liamappelbe commented Oct 8, 2025

The main change is to give each Symbol a SymbolKind, indicating what sort of entity it's naming. Keywords are either disallowed for all SymbolKinds, or allowed only for methods and fields.

There's a related namespacing issue (mentioned here) that I thought would need to be fixed using the SymbolKind, but after some experimentation that turned out to be the wrong solution. I've left that fix in this PR since it's small. The issue was that param names that collided with method names were being renamed (eg NSData.dataWithBytes has a length param that was being renamed to length$1 to avoid colliding with NSData.length). This was technically correct1, but annoying. The fix is to put the method name symbols in a special scope on the class, called methodNameScope.

Fixes #2054

Footnotes

  1. Dart doesn't allow you to declare a variable and a function in the same scope with the same name. It's allowed in this case because the method scope is a separate scope, but since it's nested inside the class scope we're aliasing the method name. If the method implementation needed to call that other method, we'd run into issues. But this is not a problem for us because aside from a few very special cases, generated methods don't call other generated methods. So it's clearly better to allow aliasing in this case. I originally tried to use the SymbolKind to allow aliasing in a more general way, but it caused more problems than it solved.

Copy link

github-actions bot commented Oct 8, 2025

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
objective_c Breaking 8.1.0 9.0.0-dev.0 9.0.0 ✔️

This check can be disabled by tagging the PR with skip-breaking-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
objective_c _FinalizablePointer internal.dart::_ObjCReference::new::_finalizable

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

All source files should start with a license header.

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

@coveralls
Copy link

coveralls commented Oct 8, 2025

Coverage Status

coverage: 81.265%. remained the same
when pulling fa34545 on ffigen_keyword
into 7fea048 on main.

@liamappelbe liamappelbe changed the title WIP: [ffigen] Separate Symbols into distinct kinds [ffigen] Separate Symbols into distinct kinds Oct 14, 2025
@liamappelbe liamappelbe marked this pull request as ready for review October 14, 2025 01: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.

[ffigen] Less strict keyword renaming

2 participants