mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
Add QL for ::class expression, and add test
This commit is contained in:
@@ -2143,9 +2143,7 @@ class WhenExpr extends Expr, @whenexpr {
|
||||
override string getAPrimaryQlClass() { result = "WhenExpr" }
|
||||
|
||||
/** Gets the `i`th branch. */
|
||||
WhenBranch getBranch(int i) {
|
||||
when_branch(result, this, i)
|
||||
}
|
||||
WhenBranch getBranch(int i) { when_branch(result, this, i) }
|
||||
}
|
||||
|
||||
/** A Kotlin `when` branch. */
|
||||
@@ -2163,3 +2161,13 @@ class WhenBranch extends Top, @whenbranch {
|
||||
|
||||
override string getAPrimaryQlClass() { result = "WhenBranch" }
|
||||
}
|
||||
|
||||
/** A Kotlin `::class` expression. */
|
||||
class ClassExpr extends Expr, @getclassexpr {
|
||||
/** Gets the expression whose class is being returned. */
|
||||
Expr getExpr() { result.isNthChildOf(this, 0) }
|
||||
|
||||
override string toString() { result = "::class" }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "ClassExpr" }
|
||||
}
|
||||
|
||||
@@ -41,12 +41,15 @@
|
||||
| exprs.kt:46:12:46:14 | 123 | IntegerLiteral |
|
||||
| exprs.kt:46:12:46:20 | ... + ... | AddExpr |
|
||||
| exprs.kt:46:18:46:20 | 456 | IntegerLiteral |
|
||||
| exprs.kt:50:13:50:16 | true | BooleanLiteral |
|
||||
| exprs.kt:50:13:50:23 | ::class | ClassExpr |
|
||||
| file://:0:0:0:0 | b1 | LocalVariableDeclExpr |
|
||||
| file://:0:0:0:0 | b2 | LocalVariableDeclExpr |
|
||||
| file://:0:0:0:0 | b6 | LocalVariableDeclExpr |
|
||||
| file://:0:0:0:0 | b7 | LocalVariableDeclExpr |
|
||||
| file://:0:0:0:0 | b8 | LocalVariableDeclExpr |
|
||||
| file://:0:0:0:0 | c | LocalVariableDeclExpr |
|
||||
| file://:0:0:0:0 | d | LocalVariableDeclExpr |
|
||||
| file://:0:0:0:0 | i1 | LocalVariableDeclExpr |
|
||||
| file://:0:0:0:0 | i2 | LocalVariableDeclExpr |
|
||||
| file://:0:0:0:0 | i3 | LocalVariableDeclExpr |
|
||||
|
||||
@@ -46,3 +46,6 @@ TODO
|
||||
return 123 + 456
|
||||
}
|
||||
|
||||
fun getClass() {
|
||||
val d = true::class
|
||||
}
|
||||
Reference in New Issue
Block a user