mirror of
https://github.com/github/codeql.git
synced 2026-07-14 15:58:16 +02:00
A data class's generated `copy(...)` has one value parameter per
primary-constructor property. The K1 frontend records each such
parameter (and its type accesses) at the source location of the
corresponding property; the K2 frontend leaves them with undefined
offsets, which the extractor emits as a `0:0:0:0` location.
This divergence is purely a K2 information regression: the richer K1
location is unambiguously better (it points at the real property in
source, enabling location-based queries), so we converge K2 onto K1
rather than the other way around.
Because K2 exposes no PSI back-mapping, the location cannot be
recomputed from source; instead we recover it from the IR. For a value
parameter of a `GENERATED_DATA_CLASS_MEMBER` function whose own offsets
are undefined, we look up the primary-constructor parameter at the same
index and reuse its location.
Guards keep the change surgical:
- `vp.startOffset >= 0` bails out, so K1 (which already has real
offsets) is untouched.
- the origin must be `GENERATED_DATA_CLASS_MEMBER`.
- the primary-ctor parameter name must match and carry real offsets,
which restricts the remap to `copy`-style parameters and excludes
members such as `equals(other)`.
Relearned both suites: only data-class `copy` parameter rows change
(K2 now matches K1). data-classes/PrintAst.expected becomes byte
-identical across suites; the residual diffs in methods/{exprs,
parameters}.expected are pre-existing, unrelated divergences.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
197 lines
8.3 KiB
Plaintext
197 lines
8.3 KiB
Plaintext
dc.kt:
|
|
# 0| [CompilationUnit] dc
|
|
# 1| 1: [Class] ProtoMapValue
|
|
# 0| 1: [Method] component1
|
|
# 0| 3: [TypeAccess] byte[]
|
|
# 0| 5: [BlockStmt] { ... }
|
|
# 0| 0: [ReturnStmt] return ...
|
|
# 0| 0: [VarAccess] this.bytes
|
|
# 0| -1: [ThisAccess] this
|
|
# 0| 2: [Method] component2
|
|
# 0| 3: [TypeAccess] String[]
|
|
# 0| 0: [TypeAccess] String
|
|
# 0| 5: [BlockStmt] { ... }
|
|
# 0| 0: [ReturnStmt] return ...
|
|
# 0| 0: [VarAccess] this.strs
|
|
# 0| -1: [ThisAccess] this
|
|
# 0| 3: [Method] copy
|
|
# 0| 3: [TypeAccess] ProtoMapValue
|
|
#-----| 4: (Parameters)
|
|
# 1| 0: [Parameter] bytes
|
|
# 1| 0: [TypeAccess] byte[]
|
|
# 1| 1: [Parameter] strs
|
|
# 1| 0: [TypeAccess] String[]
|
|
# 1| 0: [TypeAccess] String
|
|
# 0| 5: [BlockStmt] { ... }
|
|
# 0| 0: [ReturnStmt] return ...
|
|
# 0| 0: [ClassInstanceExpr] new ProtoMapValue(...)
|
|
# 0| -3: [TypeAccess] ProtoMapValue
|
|
# 0| 0: [VarAccess] bytes
|
|
# 0| 1: [VarAccess] strs
|
|
# 0| 4: [Method] copy$default
|
|
# 0| 3: [TypeAccess] ProtoMapValue
|
|
#-----| 4: (Parameters)
|
|
# 0| 0: [Parameter] p0
|
|
# 0| 0: [TypeAccess] ProtoMapValue
|
|
# 0| 1: [Parameter] p1
|
|
# 0| 0: [TypeAccess] byte[]
|
|
# 0| 2: [Parameter] p2
|
|
# 0| 0: [TypeAccess] String[]
|
|
# 0| 3: [Parameter] p3
|
|
# 0| 0: [TypeAccess] int
|
|
# 0| 4: [Parameter] p4
|
|
# 0| 0: [TypeAccess] Object
|
|
# 0| 5: [BlockStmt] { ... }
|
|
# 0| 0: [IfStmt] if (...)
|
|
# 0| 0: [EQExpr] ... == ...
|
|
# 0| 0: [AndBitwiseExpr] ... & ...
|
|
# 0| 0: [IntegerLiteral] 1
|
|
# 0| 1: [VarAccess] p3
|
|
# 0| 1: [IntegerLiteral] 0
|
|
# 0| 1: [ExprStmt] <Expr>;
|
|
# 0| 0: [AssignExpr] ...=...
|
|
# 0| 0: [VarAccess] p1
|
|
# 0| 1: [VarAccess] p0.bytes
|
|
# 0| -1: [VarAccess] p0
|
|
# 0| 1: [IfStmt] if (...)
|
|
# 0| 0: [EQExpr] ... == ...
|
|
# 0| 0: [AndBitwiseExpr] ... & ...
|
|
# 0| 0: [IntegerLiteral] 2
|
|
# 0| 1: [VarAccess] p3
|
|
# 0| 1: [IntegerLiteral] 0
|
|
# 0| 1: [ExprStmt] <Expr>;
|
|
# 0| 0: [AssignExpr] ...=...
|
|
# 0| 0: [VarAccess] p2
|
|
# 0| 1: [VarAccess] p0.strs
|
|
# 0| -1: [VarAccess] p0
|
|
# 0| 2: [ReturnStmt] return ...
|
|
# 0| 0: [MethodCall] copy(...)
|
|
# 0| -1: [VarAccess] p0
|
|
# 0| 0: [VarAccess] p1
|
|
# 0| 1: [VarAccess] p2
|
|
# 0| 5: [Method] equals
|
|
# 0| 3: [TypeAccess] boolean
|
|
#-----| 4: (Parameters)
|
|
# 0| 0: [Parameter] other
|
|
# 0| 0: [TypeAccess] Object
|
|
# 0| 5: [BlockStmt] { ... }
|
|
# 0| 0: [ExprStmt] <Expr>;
|
|
# 0| 0: [WhenExpr] when ...
|
|
# 0| 0: [WhenBranch] ... -> ...
|
|
# 0| 0: [EQExpr] ... == ...
|
|
# 0| 0: [ThisAccess] this
|
|
# 0| 1: [VarAccess] other
|
|
# 0| 1: [ReturnStmt] return ...
|
|
# 0| 0: [BooleanLiteral] true
|
|
# 0| 1: [ExprStmt] <Expr>;
|
|
# 0| 0: [WhenExpr] when ...
|
|
# 0| 0: [WhenBranch] ... -> ...
|
|
# 0| 0: [NotInstanceOfExpr] ... !is ...
|
|
# 0| 0: [VarAccess] other
|
|
# 0| 1: [TypeAccess] ProtoMapValue
|
|
# 0| 1: [ReturnStmt] return ...
|
|
# 0| 0: [BooleanLiteral] false
|
|
# 0| 2: [LocalVariableDeclStmt] var ...;
|
|
# 0| 1: [LocalVariableDeclExpr] tmp0_other_with_cast
|
|
# 0| 0: [ImplicitCastExpr] <implicit cast>
|
|
# 0| 0: [TypeAccess] ProtoMapValue
|
|
# 0| 1: [VarAccess] other
|
|
# 0| 3: [ExprStmt] <Expr>;
|
|
# 0| 0: [WhenExpr] when ...
|
|
# 0| 0: [WhenBranch] ... -> ...
|
|
# 0| 0: [ValueNEExpr] ... (value not-equals) ...
|
|
# 0| 0: [VarAccess] this.bytes
|
|
# 0| -1: [ThisAccess] this
|
|
# 0| 1: [VarAccess] tmp0_other_with_cast.bytes
|
|
# 0| -1: [VarAccess] tmp0_other_with_cast
|
|
# 0| 1: [ReturnStmt] return ...
|
|
# 0| 0: [BooleanLiteral] false
|
|
# 0| 4: [ExprStmt] <Expr>;
|
|
# 0| 0: [WhenExpr] when ...
|
|
# 0| 0: [WhenBranch] ... -> ...
|
|
# 0| 0: [ValueNEExpr] ... (value not-equals) ...
|
|
# 0| 0: [VarAccess] this.strs
|
|
# 0| -1: [ThisAccess] this
|
|
# 0| 1: [VarAccess] tmp0_other_with_cast.strs
|
|
# 0| -1: [VarAccess] tmp0_other_with_cast
|
|
# 0| 1: [ReturnStmt] return ...
|
|
# 0| 0: [BooleanLiteral] false
|
|
# 0| 5: [ReturnStmt] return ...
|
|
# 0| 0: [BooleanLiteral] true
|
|
# 0| 6: [Method] hashCode
|
|
# 0| 3: [TypeAccess] int
|
|
# 0| 5: [BlockStmt] { ... }
|
|
# 0| 0: [LocalVariableDeclStmt] var ...;
|
|
# 0| 1: [LocalVariableDeclExpr] result
|
|
# 0| 0: [MethodCall] hashCode(...)
|
|
# 0| -1: [TypeAccess] Arrays
|
|
# 0| 0: [VarAccess] this.bytes
|
|
# 0| -1: [ThisAccess] this
|
|
# 0| 1: [ExprStmt] <Expr>;
|
|
# 0| 0: [AssignExpr] ...=...
|
|
# 0| 0: [VarAccess] result
|
|
# 0| 1: [AddExpr] ... + ...
|
|
# 0| 0: [MulExpr] ... * ...
|
|
# 0| 0: [VarAccess] result
|
|
# 0| 1: [IntegerLiteral] 31
|
|
# 0| 1: [MethodCall] hashCode(...)
|
|
# 0| -1: [TypeAccess] Arrays
|
|
# 0| 0: [VarAccess] this.strs
|
|
# 0| -1: [ThisAccess] this
|
|
# 0| 2: [ReturnStmt] return ...
|
|
# 0| 0: [VarAccess] result
|
|
# 0| 7: [Method] toString
|
|
# 0| 3: [TypeAccess] String
|
|
# 0| 5: [BlockStmt] { ... }
|
|
# 0| 0: [ReturnStmt] return ...
|
|
# 0| 0: [StringTemplateExpr] "..."
|
|
# 0| 0: [StringLiteral] "ProtoMapValue("
|
|
# 0| 1: [StringLiteral] "bytes="
|
|
# 0| 2: [MethodCall] toString(...)
|
|
# 0| -1: [TypeAccess] Arrays
|
|
# 0| 0: [VarAccess] this.bytes
|
|
# 0| -1: [ThisAccess] this
|
|
# 0| 3: [StringLiteral] ", "
|
|
# 0| 4: [StringLiteral] "strs="
|
|
# 0| 5: [MethodCall] toString(...)
|
|
# 0| -1: [TypeAccess] Arrays
|
|
# 0| 0: [VarAccess] this.strs
|
|
# 0| -1: [ThisAccess] this
|
|
# 0| 6: [StringLiteral] ")"
|
|
# 1| 8: [Constructor] ProtoMapValue
|
|
#-----| 4: (Parameters)
|
|
# 1| 0: [Parameter] bytes
|
|
# 1| 0: [TypeAccess] byte[]
|
|
# 1| 1: [Parameter] strs
|
|
# 1| 0: [TypeAccess] String[]
|
|
# 1| 0: [TypeAccess] String
|
|
# 1| 5: [BlockStmt] { ... }
|
|
# 1| 0: [SuperConstructorInvocationStmt] super(...)
|
|
# 1| 1: [BlockStmt] { ... }
|
|
# 1| 0: [ExprStmt] <Expr>;
|
|
# 1| 0: [KtInitializerAssignExpr] ...=...
|
|
# 1| 0: [VarAccess] bytes
|
|
# 1| 1: [ExprStmt] <Expr>;
|
|
# 1| 0: [KtInitializerAssignExpr] ...=...
|
|
# 1| 0: [VarAccess] strs
|
|
# 1| 9: [FieldDeclaration] byte[] bytes;
|
|
# 1| -1: [TypeAccess] byte[]
|
|
# 1| 0: [VarAccess] bytes
|
|
# 1| 10: [Method] getBytes
|
|
# 1| 3: [TypeAccess] byte[]
|
|
# 1| 5: [BlockStmt] { ... }
|
|
# 1| 0: [ReturnStmt] return ...
|
|
# 1| 0: [VarAccess] this.bytes
|
|
# 1| -1: [ThisAccess] this
|
|
# 1| 11: [FieldDeclaration] String[] strs;
|
|
# 1| -1: [TypeAccess] String[]
|
|
# 1| 0: [TypeAccess] String
|
|
# 1| 0: [VarAccess] strs
|
|
# 1| 12: [Method] getStrs
|
|
# 1| 3: [TypeAccess] String[]
|
|
# 1| 0: [TypeAccess] String
|
|
# 1| 5: [BlockStmt] { ... }
|
|
# 1| 0: [ReturnStmt] return ...
|
|
# 1| 0: [VarAccess] this.strs
|
|
# 1| -1: [ThisAccess] this
|