mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Kotlin: drop same-file requirement for overridden parameter labels
This commit is contained in:
@@ -1622,12 +1622,7 @@ open class KotlinUsesExtractor(
|
||||
fun getValueParameterLabel(vp: IrValueParameter, parent: Label<out DbCallable>?): String {
|
||||
val declarationParent = vp.parent
|
||||
val overriddenParentAttributes = (declarationParent as? IrFunction)?.let {
|
||||
// Note the check 'vp.fileOrNull?.path == this.filePath' should never actually do anything, since references
|
||||
// to a value parameter should always come from within the same .kt file.
|
||||
if (this is KotlinFileExtractor && vp.fileOrNull?.path == this.filePath)
|
||||
this.declarationStack.findOverriddenAttributes(it)
|
||||
else
|
||||
null
|
||||
(this as? KotlinFileExtractor)?.declarationStack?.findOverriddenAttributes(it)
|
||||
}
|
||||
val parentId = parent ?: overriddenParentAttributes?.id ?: useDeclarationParent(declarationParent, false)
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
| test.kt:3:17:3:45 | f | test.kt:3:23:3:32 | x |
|
||||
| test.kt:3:17:3:45 | f | test.kt:3:35:3:40 | y |
|
||||
| test.kt:3:17:3:45 | f | test.kt:3:35:3:40 | y |
|
||||
| test.kt:3:17:3:45 | f$default | test.kt:3:17:3:45 | p0 |
|
||||
| test.kt:3:17:3:45 | f$default | test.kt:3:17:3:45 | p1 |
|
||||
| test.kt:3:17:3:45 | f$default | test.kt:3:17:3:45 | p2 |
|
||||
| test.kt:3:17:3:45 | f$default | test.kt:3:17:3:45 | p3 |
|
||||
| test.kt:3:17:3:45 | f$default | test.kt:3:17:3:45 | p4 |
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Test {
|
||||
|
||||
@JvmOverloads fun f(x: Int = 0, y: Int) { }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
from create_database_utils import *
|
||||
|
||||
os.mkdir('bin')
|
||||
run_codeql_database_create(["kotlinc test.kt -d bin", "kotlinc user.kt -cp bin"], lang="java")
|
||||
@@ -0,0 +1,5 @@
|
||||
import java
|
||||
|
||||
from Method m
|
||||
where m.fromSource()
|
||||
select m, m.getAParameter()
|
||||
@@ -0,0 +1 @@
|
||||
val x = Test().f(1, 2)
|
||||
Reference in New Issue
Block a user