fix(kotlin): a property carries its visibility, and a private class hides its members - #1761
Open
danusha2345 wants to merge 5 commits into
Open
fix(kotlin): a property carries its visibility, and a private class hides its members#1761danusha2345 wants to merge 5 commits into
danusha2345 wants to merge 5 commits into
Conversation
`private val` / `private var` at class or object scope were indexed with no visibility, so colbymchenry#1745's Kotlin rule — which declines a `private fun` in another file — read every property as public. On a Kotlin + JS + Go app 24 cross-file calls landed on private properties: a validator's `token(...)` onto another class's `@Volatile private var token`, and JS, Go and Python callers onto Kotlin test fixtures' private fields. Both extractors read the `modifiers` child the way functions already do; the parity fixture gains a `private val` and an `internal var`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`private class Clock(var value: Long) { fun now() = value }` in a test:
the method is public, the class is not, so nothing outside the file
can name `now` — three `now()` calls in the app's gimbal control still
resolved onto it after the property fix. A candidate whose enclosing
class/object in its file is `private` is declined for the languages
where `private` is file-local; found by line range, memoised per node.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…isibility # Conflicts: # CHANGELOG.md
Contributor
Author
|
Merged current |
…isibility # Conflicts: # codegraph-kernel/src/kotlin.rs # src/extraction/languages/kotlin.ts
Contributor
Author
|
Merged current |
…isibility # Conflicts: # CHANGELOG.md
Contributor
Author
|
Merged current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1745 (the Kotlin / Go / Rust file-local rule, #1731). Two commits, off
mainatcd4e65b.What
A Kotlin property records its visibility modifier.
private val/private var/internalat class or object scope were indexed with novisibility, so the Kotlin rule inisVisibleAcrossFiles— which declines aprivate funin another file — read every property as public. Both the WebAssembly extractor and the native kernel now read themodifierschild the way they already do for functions; the parity fixture gains aprivate valand aninternal var.A member of a
privateclass or object is file-local too.private class Clock(var value: Long) { fun now() = value }in a test: the method is public, the class is not, so nothing outside the file can namenow. For the languages whereprivateis file-local (Kotlin, Java, C#, Swift, Scala, Dart, PHP) a candidate whose enclosing class/object/interface/enum in its file isprivateis declined — by line range among the file's nodes, memoised per node.Applied where #1745 applies, after the whole pipeline settles, so a rejection leaves the reference unresolved.
Measured
A Kotlin + JS + Go Electron/Android app (114 Kotlin files),
mainatcd4e65bvs this branch, wasm arm, edge rows keyed withresolvedBy: LOST 57 / GAINED 0.token(...)onto another class's@Volatile private var token; JSnow()/bytes()/gate()callers (renderer, a Python tool, the Go signaling server) onto Kotlin test fixtures'private vals;changed,handler,resources,onStatus,listener,moving.now()calls in the gimbal control onto the test'sprivate class Clock, and 30send/cancel/close/requestcalls fromTelemetryUplink.kt/WebRtcTransport.kt(instance-method resolution) ontoTelemetryUplinkTest.kt'sprivate class FakeWebSocket/ServerSocketListener.A second Kotlin app (FreeFCC, 1,726 nodes): 0 / 0.
pulpRust, Python and C corpora: untouched (the rule is gated to theprivate-is-file-local languages).Tests
cross-file-visibility+2 (aprivate varand aninternal valcarry their modifier and the private one is declined; a public fun of a private class is declined),kernel-kotlin-parity/kernel-grammar-parityon the rebuilt kernel,resolution198/198,frameworks-integration;tscclean. Full suite on Linux: the viewer-lesscodegraph uifiles, plus the three store-action tests that fail onmainsince #1759 and that #1760 fixes.🤖 Generated with Claude Code