mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Merge pull request #11003 from smowton/smowton/fix/reintroduce-pointless-wildcards
Kotlin: reintroduce pointless wildcards when a Java declaration explicitly uses them
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
public class Test {
|
||||
|
||||
// This gets mapped to kotlin.Iterable<out T>, meaning we must reintroduce the use-site extends variance to get a type consistent with Java.
|
||||
public static void needlessExtends(Iterable<? extends String> l) { }
|
||||
|
||||
// This type is defined KotlinConsumer<in T>, meaning we must reintroduce the use-site extends variance to get a type consistent with Java.
|
||||
public static void needlessSuper(KotlinConsumer<? super Object> l) { }
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
public class KotlinConsumer<in T> { }
|
||||
@@ -0,0 +1,2 @@
|
||||
| Test.java:4:22:4:36 | needlessExtends | file:///modules/java.base/java/lang/Iterable.class:0:0:0:0 | Iterable<? extends String> |
|
||||
| Test.java:7:22:7:34 | needlessSuper | build1/KotlinConsumer.class:0:0:0:0 | KotlinConsumer<? super Object> |
|
||||
@@ -0,0 +1,5 @@
|
||||
from create_database_utils import *
|
||||
|
||||
os.mkdir('build1')
|
||||
os.mkdir('build2')
|
||||
run_codeql_database_create(["kotlinc kConsumer.kt -d build1", "javac Test.java -cp build1 -d build2", "kotlinc user.kt -cp build1:build2"], lang="java")
|
||||
@@ -0,0 +1,5 @@
|
||||
import java
|
||||
|
||||
from Method m
|
||||
where m.fromSource()
|
||||
select m, m.getAParamType()
|
||||
@@ -0,0 +1,4 @@
|
||||
fun f() {
|
||||
Test.needlessExtends(null)
|
||||
Test.needlessSuper(null)
|
||||
}
|
||||
Reference in New Issue
Block a user