Repository navigation
#175: Kotlin bench scopes cut at every type, trace selection walks once per root, and an unbalanced annotation costs only its line - #197
Merged
Conversation
The JVM bench selection carried three residuals in the harness. Kotlin call-graph owners were cut at `class` only, with a short modifier list, so an `object`, an `interface`, an `enum`/`value`/`private` class and every file-level function after a class were read as that class's calls. Kotlin scopes now come from blanked text: every named type owns its lines up to where its brackets close, a nested type's lines return to the enclosing type after it ends, and a companion object belongs to its class, as the store reads it. The graph also reports `shared`, the names more than one scope declares, and the JVM trace selection drops a path whose end or via hop is one of them, counted under `trace_name_two_scopes_share`. Trace selection ran one breadth-first walk per pair. `shortest_paths` answers every destination from one walk per root; a test checks it against `shortest_path` for every pair of 42 graphs, and the selector's outputs on ten fixtures are byte-identical to the per-pair version. An annotation argument list that never closed blanked the rest of a Java file, and in Kotlin its open `(` stopped every later declaration from being read. Both blankers now cut such a list back to the end of its own line; balanced annotations and Kotlin labels are untouched.
A default lambda in the constructor (`onClick: () -> Unit = {}`) counted
as the body opening, so a header whose supertype list carried on to the
next line ended on its first line and its body had no owner.
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.
Summary
di_call_graphused to cut Kotlin files at eachclassline, and only after a short list of modifiers. That missedobject,interface, andenum,valueandprivateclasses, and it charged every file-level function after a class to that class. Kotlin scopes now come from blanked text (kotlin_scopes). Each named type owns its lines up to the point where its brackets close. After a nested type ends, the lines that follow belong to the enclosing type again. A companion object belongs to its class, which is how the store reads it. A type named only in a comment or a string opens no scope. Other languages keep the existing cut throughDiReader.cls.shared: every name that more than one scope declares, nested types included.select_jvm_casesdrops a trace whose end or via hop is one of those names and counts it undertrace_name_two_scopes_share. The reason: the graph merges both classes' calls under one name, andmember_chainonly checks the file thatdeclaredkept.shortest_paths(graph, src)gives every destination the exact path thatshortest_path(graph, src, dst)returns, and trace selection now runs one walk per root instead of one per pair.(stopped every later declaration from being read.blank_javaandblank_kotlinnow cut such a list back to the end of its own line, sodeclarationsanddeclaration_endboth recover. A closing bracket of the wrong kind no longer closes the list. Balanced annotations and Kotlin labels (return@forEach,this@A) are unchanged.Test plan
KotlinCallScopes(3 tests)ShortestPaths: every pair across 42 graphs (a diamond, a chain longer than the hop limit, and 40 seeded random graphs) againstshortest_pathUnbalancedAnnotations(4 tests)SharedNamesintest_select_jvm_cases.py(2 tests)python3 -m unittest discover -s bench/compare: 242 tests OKpython3 -m unittest discover -s bench/probe: 148 tests OKpython3 -m unittest discover -s bench/history: 56 tests OKselect()fromorigin/mainand from this branch gave byte-identicalblast.jsonl,truth.jsonand summaries on ten fixtures (SHOP, the split-method fixture, and eight seeded 24-class Java/Kotlin corpora with up to 173 trace candidates)..ktfiles): the truth for all 10 graded trace cases inbench/blast.jsonlandbench/corpora/beauty-crm-mobile/blast.jsonlis unchanged. The annotation bound changes the blanked text of no file. The Kotlin edges that moved are corrections: library calls (List.*,Map.*,JsonObject.*) that the old cut charged to the wrong class, plusprivateandvalueclasses that the old cut missed.