Repository navigation
java: a var local never names an external type called var (#1401) - #1563
Merged
Merged
Conversation
The parser records `var h = r.lookup(k)` as a LOCAL_VARIABLE type reference written `var`. Nothing resolves that name, so external-types.dl minted `external:var` and typed every var receiver with it: each call on a var local got an `external:var.<m>` boundary, beside its real target when the local was in-source typed, alone when it was not. candidate_ref now skips a reference written `var`, and a var local takes the external type of its initializer (`var f = source()` with an unstaged return type) the way a declared local takes its written one. Case 61-var-local-type pins each var shape against its declared control. 36-generic-two-hop loses three external:var boundaries that sat beside the real library targets.
swapnilpaliwal-sd
requested review from
JaredHLZhang,
Whua689 and
suyashpaliwal26
as code owners
September 28, 2026 02:18
This was referenced Sep 28, 2026
Merged
Merged
qtwang
pushed a commit
to qtwang/axiomcodegraph
that referenced
this pull request
Oct 11, 2026
…I#1563 AxiomCodeAI#1563 added a Java case that both ground-truth oracles agree on, but left graph/test/java/expected/oracle-agreement.txt at 45 cases, so the engine (java) job fails its oracle-agreement check on 0.1.3. CI measured 46 cases compared, 46 agreeing, 0 disagreements; this records that. Refs AxiomCodeAI#1401.
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.
Fixes #1401
What was wrong. The parser records
var h = r.lookup(k)as a LOCAL_VARIABLE type reference writtenvar. No import or declaration resolves that name, sograph/java/engine/resolution/external-types.dlmintedexternal:varfor it and typed the local with it. Every call on a var local then got anexternal:var.<m>boundary:multi_inferred;The change. Both edits are in
external-types.dl.candidate_refskips a reference writtenvar.expr_type("external", …)clause gives avarlocal the external type of its initializer. For example,var f = source()whereFormat source()is not staged typesfasFormat, the same as a declaredFormat f. The clause applies only to locals flagged isVarInferred, and a reassignment does not widen the type, because a var's type is fixed at the declaration (JLS 14.4.1).Without the second clause, removing
external:varturned those receivers into declared unknowns. On the dev project it gives 341 var sites their real external label.Tests.
graph/test/java/cases/61-var-local-typecovers each var shape next to its declared control: a client call's return, a static factory,new,newthen reassigned, a literal, enhanced-for, a try-with-resources resource, an unstaged platform call, a client method with an external return type, and lambdavarparameters.36-generic-two-hoploses threeexternal:varboundaries that sat beside the real library targets.bin/axiomcode test java: 64 passed, 0 failed.Measurement. Engine only, no library staged (the default index), same IR before and after.
No var site lost a real target. The declared unknowns are sites whose initializer type is not known in a client-only build: library calls, generic
Class<T>lookups, and unresolved receivers.The non-var changes come from argument and assignment-target typing, which used to read the fake type:
multi_inferrednarrows toknown_edge, or a spuriousObject.equals/toStringboundary is dropped), 4 are neutral (known_edgeto an anonymous implementation becomesknown_edgeto the interface method it implements) and 4 are worse.Object.toStringboundary is dropped, and 1 boundary that existed only through the fake type becomes a declared unknown.What got worse. On the dev project, 4 sites whose argument is a
varof unknown type lose precision, though the correct target is still present. One goes fromknown_edgetomulti_inferredover 2 overloads, and three fans grow by 2 to 3 candidates. Before the fix,external:varruled out the client-typed overloads by accident.var s = "abc"; s.length()is a declared unknown in a client-only build, the same answer the engine gives for"abc".length()written inline. With the JDK staged, the literal is typedjava.lang.Stringand the var follows it.Solve cost. Dev project, warm, back to back: solve 26 s before, 26 s after.