Commit 39006a6
authored
Fix Kotlin parser handling of unresolved callable references (#7469)
`visitCallableReferenceExpression` looked up the FIR for the callable
reference's right-hand side (`expression.getCallableReference()`) to
decide whether to accept the reference. When the type is unresolved
(e.g. `JavaLanguageVersion::of` in a `.gradle.kts` parsed without the
full Gradle classpath), the RHS maps to `FirErrorNamedReferenceImpl`
even though the whole expression still maps cleanly to
`FirCallableReferenceAccess`. The visitor then threw, the declaration
bubbled up into `J.Unknown`, and its PSI text range (which includes the
trailing newline) got duplicated against the file's EOF space, causing
a print idempotency failure.
Check the FIR mapping of the whole expression for validity instead, and
use the reference-level FIR only for optional type resolution. Types
simply remain `null` when the reference cannot be resolved, which
matches how other unresolved-type scenarios are handled.
Re-enables the previously `@Disabled` `firCallableReferenceAccess`
regression test.1 parent 305085c commit 39006a6
4 files changed
Lines changed: 29 additions & 6 deletions
File tree
- rewrite-gradle/src/test/java/org/openrewrite/gradle
- rewrite-kotlin/src
- main/java/org/openrewrite/kotlin/internal
- test/java/org/openrewrite/kotlin/tree
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
278 | 289 | | |
279 | 290 | | |
280 | 291 | | |
| |||
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
273 | | - | |
| 272 | + | |
| 273 | + | |
274 | 274 | | |
275 | | - | |
276 | | - | |
| 275 | + | |
| 276 | + | |
277 | 277 | | |
278 | 278 | | |
| 279 | + | |
279 | 280 | | |
280 | 281 | | |
281 | 282 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
72 | 85 | | |
73 | 86 | | |
74 | 87 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| |||
142 | 141 | | |
143 | 142 | | |
144 | 143 | | |
145 | | - | |
146 | 144 | | |
147 | 145 | | |
148 | 146 | | |
| |||
0 commit comments