mirror of
https://github.com/github/codeql.git
synced 2025-12-21 11:16:30 +01:00
Kotlin: Add support for varargs
This commit is contained in:
@@ -1695,6 +1695,15 @@ open class KotlinFileExtractor(
|
||||
val exprParent = parent.expr(e, callable)
|
||||
extractTypeOperatorCall(e, callable, exprParent.parent, exprParent.idx)
|
||||
}
|
||||
is IrVararg -> {
|
||||
val exprParent = parent.expr(e, callable)
|
||||
val id = tw.getFreshIdLabel<DbVarargexpr>()
|
||||
val locId = tw.getLocation(e)
|
||||
val type = useType(e.type)
|
||||
tw.writeExprs_varargexpr(id, type.javaResult.id, type.kotlinResult.id, exprParent.parent, exprParent.idx)
|
||||
tw.writeHasLocation(id, locId)
|
||||
e.elements.forEachIndexed { i, arg -> extractVarargElement(arg, callable, id, i) }
|
||||
}
|
||||
is IrGetObjectValue -> {
|
||||
// For `object MyObject { ... }`, the .class has an
|
||||
// automatically-generated `public static final MyObject INSTANCE`
|
||||
@@ -1719,6 +1728,17 @@ open class KotlinFileExtractor(
|
||||
}
|
||||
}
|
||||
|
||||
fun extractVarargElement(e: IrVarargElement, callable: Label<out DbCallable>, parent: Label<out DbExprparent>, idx: Int) {
|
||||
when(e) {
|
||||
is IrExpression -> {
|
||||
extractExpressionExpr(e, callable, parent, idx)
|
||||
}
|
||||
else -> {
|
||||
logger.warnElement(Severity.ErrorSevere, "Unrecognised IrVarargElement: " + e.javaClass, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun extractModifier(m: String): Label<DbModifier> {
|
||||
val modifierLabel = "@\"modifier;$m\""
|
||||
val id: Label<DbModifier> = tw.getLabelFor(modifierLabel, {
|
||||
|
||||
Reference in New Issue
Block a user