mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Add extension receiver type to function signature in trap file names
This commit is contained in:
@@ -249,7 +249,14 @@ open class KotlinUsesExtractor(
|
||||
// Note we erase the parameter types before calling useType even though the signature should be the same
|
||||
// in order to prevent an infinite loop through useTypeParameter -> useDeclarationParent -> useFunction
|
||||
// -> extractFunctionLaterIfExternalFileMember, which would result for `fun <T> f(t: T) { ... }` for example.
|
||||
val paramTypes = f.valueParameters.map { useType(erase(it.type)) }
|
||||
val ext = f.extensionReceiverParameter
|
||||
val parameters = if (ext != null) {
|
||||
listOf(ext) + f.valueParameters
|
||||
} else {
|
||||
f.valueParameters
|
||||
}
|
||||
|
||||
val paramTypes = parameters.map { useType(erase(it.type)) }
|
||||
val signature = paramTypes.joinToString(separator = ",", prefix = "(", postfix = ")") { it.javaResult.signature!! }
|
||||
dependencyCollector?.addDependency(f, signature)
|
||||
externalClassExtractor.extractLater(f, signature)
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
| test.kt:2:17:2:31 | startsWith(...) | test.kt:2:13:2:15 | url | test.kt:2:29:2:29 | 1 |
|
||||
| test.kt:3:17:3:33 | removePrefix(...) | test.kt:3:13:3:15 | url | test.kt:3:31:3:31 | 2 |
|
||||
| PropertyReferenceDelegatesKt | getValue(KProperty0<V>, Object, KProperty<?>) |
|
||||
| PropertyReferenceDelegatesKt | getValue(KProperty1<T,V>, T, KProperty<?>) |
|
||||
| StringsKt | removePrefix(String, CharSequence) |
|
||||
| StringsKt | startsWith(String, String, boolean) |
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import java
|
||||
|
||||
from MethodAccess ma, Expr qualifier, Argument arg
|
||||
where ma.getQualifier() = qualifier and
|
||||
ma.getAnArgument() = arg
|
||||
select ma, qualifier, arg
|
||||
from MethodAccess ma
|
||||
select ma.getMethod().getDeclaringType().getName(), ma.getMethod().getStringSignature()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
fun test(url: String) {
|
||||
val s = url.startsWith("1")
|
||||
val r = url.removePrefix("2")
|
||||
|
||||
(null!! as kotlin.reflect.KProperty0<Int>).getValue(null, null!!)
|
||||
(null!! as kotlin.reflect.KProperty1<Int, Int>).getValue(1, null!!)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user