Kotlin: Add support for varargs

This commit is contained in:
Ian Lynagh
2021-11-09 13:56:50 +00:00
parent 497263e92d
commit be75d30ee0
8 changed files with 85 additions and 0 deletions

View File

@@ -694,6 +694,7 @@ case @expr.kind of
| 78 = @notinstanceofexpr
| 79 = @stmtexpr
| 80 = @stringtemplateexpr
| 81 = @varargexpr
;
/** Holds if this `when` expression was written as an `if` expression. */

View File

@@ -2267,3 +2267,26 @@ class StringTemplateExpr extends Expr, @stringtemplateexpr {
override string getAPrimaryQlClass() { result = "StringTemplateExpr" }
}
/**
* A Kotlin(TODO: Should Java make these too?) vararg expression.
* This is the argument to a function that corresponds to a `vararg`
* parameter.
*/
class VarArgExpr extends Expr, @varargexpr {
/**
* Gets the `i`th component of this vararg. TODO: Is this always Expr?
*
* For example, in the string template `"foo${bar}baz"`, the 0th
* component is the string literal `"foo"`, the 1st component is
* the variable access `bar`, and the 2nd component is the string
* literal `"bar"`.
*/
Expr getComponent(int i) { result.isNthChildOf(this, i) }
override string toString() { result = "..." }
override string getHalsteadID() { result = "VarArgExpr" }
override string getAPrimaryQlClass() { result = "VarArgExpr" }
}