mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Extract static method qualifier type accesses
This commit is contained in:
committed by
Ian Lynagh
parent
ef9a213ae1
commit
2730d07b4c
@@ -864,6 +864,8 @@ open class KotlinFileExtractor(
|
||||
|
||||
if (dr != null) {
|
||||
extractExpressionExpr(dr, callable, id, -1, enclosingStmt)
|
||||
} else if(callTarget.isStaticMethodOfClass) {
|
||||
extractTypeAccess(callTarget.parentAsClass.toRawType(), callable, id, -1, c, enclosingStmt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,4 +172,12 @@ fun IrType.toRawType(): IrType =
|
||||
else -> this
|
||||
}
|
||||
|
||||
fun IrClass.toRawType(): IrType {
|
||||
val result = this.typeWith(listOf())
|
||||
return if (this.typeParameters.isNotEmpty())
|
||||
result.addAnnotations(listOf(RawTypeAnnotation.annotationConstructor))
|
||||
else
|
||||
result
|
||||
}
|
||||
|
||||
typealias TypeSubstitution = (IrType, KotlinUsesExtractor.TypeContext, IrPluginContext) -> IrType
|
||||
@@ -0,0 +1,2 @@
|
||||
| test.kt:4:17:4:30 | Class<> | TypeAccess | forName |
|
||||
| test.kt:7:18:7:44 | StringsKt | TypeAccess | format |
|
||||
@@ -0,0 +1,9 @@
|
||||
fun test() {
|
||||
|
||||
// Static method of a class with type parameters:
|
||||
val c = Class.forName("xyz")
|
||||
|
||||
// Static method of a class without one:
|
||||
val s = String.format("Hello %s", "world")
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import java
|
||||
|
||||
from MethodAccess ma
|
||||
select ma.getQualifier(), ma.getQualifier().getAPrimaryQlClass(), ma.getCallee().toString()
|
||||
Reference in New Issue
Block a user