-
Notifications
You must be signed in to change notification settings - Fork 80
[ffigen] Separate Symbol
s into distinct kinds
#2675
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
base: main
Are you sure you want to change the base?
Conversation
PR HealthBreaking changes ✔️
This check can be disabled by tagging the PR with
API leaks
|
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
.
Symbol
s into distinct kindsSymbol
s into distinct kinds
The main change is to give each
Symbol
aSymbolKind
, indicating what sort of entity it's naming. Keywords are either disallowed for allSymbolKind
s, 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 (egNSData.dataWithBytes
has alength
param that was being renamed tolength$1
to avoid colliding withNSData.length
). This was technically correct1, but annoying. The fix is to put the method name symbols in a special scope on the class, calledmethodNameScope
.Fixes #2054
Footnotes
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. ↩