mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Kotlin: Extract parameter modifiers (noinline, crossinline)
This commit is contained in:
@@ -643,11 +643,11 @@ open class KotlinFileExtractor(
|
||||
extractTypeAccessRecursive(substitutedType, location, id, -1)
|
||||
}
|
||||
val syntheticParameterNames = isUnderscoreParameter(vp) || ((vp.parent as? IrFunction)?.let { hasSynthesizedParameterNames(it) } ?: true)
|
||||
return extractValueParameter(id, substitutedType, vp.name.asString(), location, parent, idx, useValueParameter(vp, parentSourceDeclaration), vp.isVararg, syntheticParameterNames)
|
||||
return extractValueParameter(id, substitutedType, vp.name.asString(), location, parent, idx, useValueParameter(vp, parentSourceDeclaration), syntheticParameterNames, vp.isVararg, vp.isNoinline, vp.isCrossinline)
|
||||
}
|
||||
}
|
||||
|
||||
private fun extractValueParameter(id: Label<out DbParam>, t: IrType, name: String, locId: Label<DbLocation>, parent: Label<out DbCallable>, idx: Int, paramSourceDeclaration: Label<out DbParam>, isVararg: Boolean, syntheticParameterNames: Boolean): TypeResults {
|
||||
private fun extractValueParameter(id: Label<out DbParam>, t: IrType, name: String, locId: Label<DbLocation>, parent: Label<out DbCallable>, idx: Int, paramSourceDeclaration: Label<out DbParam>, syntheticParameterNames: Boolean, isVararg: Boolean, isNoinline: Boolean, isCrossinline: Boolean): TypeResults {
|
||||
val type = useType(t)
|
||||
tw.writeParams(id, type.javaResult.id, idx, parent, paramSourceDeclaration)
|
||||
tw.writeParamsKotlinType(id, type.kotlinResult.id)
|
||||
@@ -658,6 +658,12 @@ open class KotlinFileExtractor(
|
||||
if (isVararg) {
|
||||
tw.writeIsVarargsParam(id)
|
||||
}
|
||||
if (isNoinline) {
|
||||
addModifiers(id, "noinline")
|
||||
}
|
||||
if (isCrossinline) {
|
||||
addModifiers(id, "crossinline")
|
||||
}
|
||||
return type
|
||||
}
|
||||
|
||||
@@ -3412,7 +3418,7 @@ open class KotlinFileExtractor(
|
||||
stmtIdx: Int
|
||||
) {
|
||||
val paramId = tw.getFreshIdLabel<DbParam>()
|
||||
val paramTypeRes = extractValueParameter(paramId, paramType, paramName, locId, ids.constructor, paramIdx, paramId, isVararg = false, syntheticParameterNames = false)
|
||||
val paramTypeRes = extractValueParameter(paramId, paramType, paramName, locId, ids.constructor, paramIdx, paramId, syntheticParameterNames = false, isVararg = false, isNoinline = false, isCrossinline = false)
|
||||
|
||||
val assignmentStmtId = tw.getFreshIdLabel<DbExprstmt>()
|
||||
tw.writeStmts_exprstmt(assignmentStmtId, ids.constructorBlock, stmtIdx, ids.constructor)
|
||||
@@ -4085,7 +4091,7 @@ open class KotlinFileExtractor(
|
||||
|
||||
val parameters = parameterTypes.mapIndexed { idx, p ->
|
||||
val paramId = tw.getFreshIdLabel<DbParam>()
|
||||
val paramType = extractValueParameter(paramId, p, "a$idx", locId, methodId, idx, paramId, isVararg = false, syntheticParameterNames = false)
|
||||
val paramType = extractValueParameter(paramId, p, "a$idx", locId, methodId, idx, paramId, syntheticParameterNames = false, isVararg = false, isNoinline = false, isCrossinline = false)
|
||||
|
||||
Pair(paramId, paramType)
|
||||
}
|
||||
|
||||
@@ -67,6 +67,12 @@ abstract class Modifiable extends Element {
|
||||
/** Holds if this element has an `inline` modifier. */
|
||||
predicate isInline() { this.hasModifier("inline") }
|
||||
|
||||
/** Holds if this element has an `noinline` modifier. */
|
||||
predicate isNoinline() { this.hasModifier("noinline") }
|
||||
|
||||
/** Holds if this element has an `crossinline` modifier. */
|
||||
predicate isCrossinline() { this.hasModifier("crossinline") }
|
||||
|
||||
/** Holds if this element has a `suspend` modifier. */
|
||||
predicate isSuspend() { this.hasModifier("suspend") }
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
| modifiers.kt:1:1:25:1 | X | Class | public |
|
||||
| modifiers.kt:1:6:25:1 | X | Constructor | public |
|
||||
| modifiers.kt:1:1:28:1 | X | Class | public |
|
||||
| modifiers.kt:1:6:28:1 | X | Constructor | public |
|
||||
| modifiers.kt:2:5:2:21 | a | Field | final |
|
||||
| modifiers.kt:2:5:2:21 | a | Field | private |
|
||||
| modifiers.kt:2:5:2:21 | a | Property | private |
|
||||
@@ -39,3 +39,9 @@
|
||||
| modifiers.kt:23:9:23:27 | localClass | Constructor | public |
|
||||
| modifiers.kt:23:9:23:27 | localClass | LocalClass | final |
|
||||
| modifiers.kt:23:9:23:27 | localClass | LocalClass | private |
|
||||
| modifiers.kt:26:12:26:46 | fn4 | Method | inline |
|
||||
| modifiers.kt:26:12:26:46 | fn4 | Method | public |
|
||||
| modifiers.kt:26:20:26:41 | f | Parameter | noinline |
|
||||
| modifiers.kt:27:12:27:49 | fn5 | Method | inline |
|
||||
| modifiers.kt:27:12:27:49 | fn5 | Method | public |
|
||||
| modifiers.kt:27:20:27:44 | f | Parameter | crossinline |
|
||||
|
||||
@@ -22,4 +22,7 @@ open class X {
|
||||
fun fn3() {
|
||||
class localClass {}
|
||||
}
|
||||
|
||||
inline fun fn4(noinline f: () -> Unit) { }
|
||||
inline fun fn5(crossinline f: () -> Unit) { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user