Skip to content

Commit 44b0f19

Browse files
authored
Merge pull request github#11090 from smowton/smowton/fix/value-parameter-label-external-class
Kotlin: drop same-file requirement for overridden parameter labels
2 parents 8502939 + 8e240a2 commit 44b0f19

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,12 +1622,7 @@ open class KotlinUsesExtractor(
16221622
fun getValueParameterLabel(vp: IrValueParameter, parent: Label<out DbCallable>?): String {
16231623
val declarationParent = vp.parent
16241624
val overriddenParentAttributes = (declarationParent as? IrFunction)?.let {
1625-
// Note the check 'vp.fileOrNull?.path == this.filePath' should never actually do anything, since references
1626-
// to a value parameter should always come from within the same .kt file.
1627-
if (this is KotlinFileExtractor && vp.fileOrNull?.path == this.filePath)
1628-
this.declarationStack.findOverriddenAttributes(it)
1629-
else
1630-
null
1625+
(this as? KotlinFileExtractor)?.declarationStack?.findOverriddenAttributes(it)
16311626
}
16321627
val parentId = parent ?: overriddenParentAttributes?.id ?: useDeclarationParent(declarationParent, false)
16331628

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
| test.kt:3:17:3:45 | f | test.kt:3:23:3:32 | x |
2+
| test.kt:3:17:3:45 | f | test.kt:3:35:3:40 | y |
3+
| test.kt:3:17:3:45 | f | test.kt:3:35:3:40 | y |
4+
| test.kt:3:17:3:45 | f$default | test.kt:3:17:3:45 | p0 |
5+
| test.kt:3:17:3:45 | f$default | test.kt:3:17:3:45 | p1 |
6+
| test.kt:3:17:3:45 | f$default | test.kt:3:17:3:45 | p2 |
7+
| test.kt:3:17:3:45 | f$default | test.kt:3:17:3:45 | p3 |
8+
| test.kt:3:17:3:45 | f$default | test.kt:3:17:3:45 | p4 |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class Test {
2+
3+
@JvmOverloads fun f(x: Int = 0, y: Int) { }
4+
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from create_database_utils import *
2+
3+
os.mkdir('bin')
4+
run_codeql_database_create(["kotlinc test.kt -d bin", "kotlinc user.kt -cp bin"], lang="java")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import java
2+
3+
from Method m
4+
where m.fromSource()
5+
select m, m.getAParameter()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
val x = Test().f(1, 2)

0 commit comments

Comments
 (0)