diff --git a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt index 990eff6fdec..d5a1e562f9b 100644 --- a/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt @@ -6277,7 +6277,7 @@ open class KotlinFileExtractor( val condId = tw.getFreshIdLabel() tw.writeStmts_whenbranchcondition(condId, bId, 0, callable) - tw.writeHasLocation(id, bLocId) + tw.writeHasLocation(condId, bLocId) tw.writeWhen_branch_condition_with_expr(condId) extractExpressionExpr(b.condition, callable, condId, 0, condId) extractExpressionStmt(b.result, callable, bId, 1) diff --git a/java/ql/lib/semmle/code/java/Expr.qll b/java/ql/lib/semmle/code/java/Expr.qll index 333b54a351a..22d955c183d 100644 --- a/java/ql/lib/semmle/code/java/Expr.qll +++ b/java/ql/lib/semmle/code/java/Expr.qll @@ -2624,6 +2624,10 @@ class WhenBranchConditionWithExpression extends WhenBranchCondition { /** Gets the expression of this branch condition. */ Expr getExpression() { result.isNthChildOf(this, 0) } + + override string toString() { result = "... ->" } + + override string getAPrimaryQlClass() { result = "WhenBranchConditionWithExpression" } } /** A Kotlin `when` branch condition with a range. */ @@ -2638,6 +2642,10 @@ class WhenBranchConditionWithRange extends WhenBranchCondition { * Ranges are represented by calls to `operator fun > T.rangeTo(that: T): ClosedRange`. */ MethodCall getRange() { result.isNthChildOf(this, 0) } + + override string toString() { result = "in ... ->" } + + override string getAPrimaryQlClass() { result = "WhenBranchConditionWithRange" } } /** A Kotlin `when` branch condition with a pattern. */ @@ -2649,6 +2657,10 @@ class WhenBranchConditionWithPattern extends WhenBranchCondition { /** Gets the type pattern of this branch condition. */ Type getType() { when_branch_condition_with_pattern(this, _, result, _) } + + override string toString() { result = "is ... ->" } + + override string getAPrimaryQlClass() { result = "WhenBranchConditionWithPattern" } } // TODO: This might need more cases. It might be better as a predicate