fix(native): add RES-3 reflection resolution to Rust resolver for Groovy/Java/Scala#1685
Merged
Merged
Conversation
…r Groovy/Java/Scala JVM getMethod/invokeMethod calls with literal method names were emitted by the Rust extractors with dynamicKind='reflection' and keyExpr set, but resolve_call_targets in build_edges.rs had no path to resolve them. Methods in Groovy/Java/Scala are stored as class-qualified names (e.g. DynamicDispatch.greet), so the plain name lookup of 'greet' finds nothing. The TypeScript resolver has a RES-3 fallback in resolveFallbackTargets that handles this via two qualified lookups: 1. typeMap[receiver] -> resolvedType.keyExpr (type-annotated locals) 2. callerName class prefix -> CallerClass.keyExpr (same-class siblings) Add the equivalent block to resolve_call_targets in Rust, scoped to non-JS/TS files to avoid interfering with the existing JS reflection path. Fixes the wasm=1 native=0 divergence for: dynamic-groovy: DynamicDispatch.runInvokeMethod -> DynamicDispatch.greet dynamic-java: Reflection.runGetMethod -> Reflection.greet dynamic-scala: Reflection.runGetMethod -> Reflection.greet Closes #1681
Contributor
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
invokeMethod("lit", args)(Groovy) and.getMethod("lit")(Java/Scala), causingwasm=1 native=0divergence indynamic-groovy,dynamic-java, anddynamic-scalaparity fixturesdynamicKind='reflection'andkeyExpr=<literal>, butresolve_call_targetsinbuild_edges.rshad no code path to resolve themresolve_call_targetsthat mirrors the TypeScriptresolveFallbackTargetsRES-3 logic — whendynamicKind='reflection'andkeyExpris set, try two qualified lookups: (1)typeMap[receiver] → resolvedType.keyExpr, and (2)callerNameclass prefix →CallerClass.keyExprfor same-class sibling methods (e.g.DynamicDispatch.greet)is_module_scoped_languageto avoid interfering with the existing JS reflection pathTest plan
node scripts/parity-compare.mjs --langs dynamic-groovy,dynamic-java,dynamic-scala→ all 3 fixtures now reportPARITY OKnode scripts/parity-compare.mjs→ 39/42 fixtures pass (dynamic-kotlin, dynamic-typescript, pts-javascript were pre-existing divergences unrelated to this fix — no regressions)npx napi build --platform --releasecompiles cleanly (1 pre-existing unused-variable warning in javascript.rs, unrelated to this change)Closes #1681