Skip to content

fix(dart): a private member is visible across its library's part files - #2468

Closed
maxmilian wants to merge 1 commit into
colbymchenry:mainfrom
maxmilian:fix/dart-part-private-2466
Closed

maxmilian wants to merge 1 commit into
colbymchenry:mainfrom
maxmilian:fix/dart-part-private-2466

Conversation

@maxmilian

Copy link
Copy Markdown
Contributor

Closes #2466.

Changes

  • isVisibleAcrossFiles (src/resolution/name-matcher.ts): a Dart private candidate is now checked with the existing inSameDartLibrary (the library file plus its part files) before the PRIVATE_IS_FILE_LOCAL rule. Dart privacy is per library, so calls between a library and its parts link again. A private member of another library stays unlinked. inSameDartLibrary returns false when the library is unknown, so that case behaves as before.
  • Regression test in __tests__/dart-part-directives.test.ts: the four-file repro from the issue (library file, two parts, one part in a subdirectory) plus a file in another library that calls the greeter's _trace.
  • Changelog entry under [Unreleased].

Verification

  • New test: 1 of 5 calls edges on main (only the same-file control), 5 of 5 with the fix, and the other library's call stays unlinked.
  • npx tsc --noEmit clean.
  • npm test (Node 22): 6442 passed, 1 failed. The failure was ui-server-api.test.ts › "caps the caller list … and stays fast", a timing assertion under full-suite load; it passes on its own (62/62, twice).

🤖 Generated with Claude Code

https://claude.ai/code/session_01WuRWooMLGXysyySZsUMNVH

colbymchenry#2466)

Dart privacy is per library, but isVisibleAcrossFiles treated a Dart
_name as file-local, so calls between a library file and its part files
were dropped. Check private Dart candidates with inSameDartLibrary first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WuRWooMLGXysyySZsUMNVH
@colbymchenry

Copy link
Copy Markdown
Owner

Thanks for this fix, @maxmilian!

The same fix landed on main in #2832, which used your PR as its guide and credits you; it also covers part files when there's no pubspec. Your test passes on current main. Closing as already fixed; it ships in the next release after 1.6.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dart: calls to private members across part files are dropped since 1.6

2 participants