Files
codeql/java/ql/integration-tests/posix-only/kotlin/needless-java-wildcards/Test.java
Chris Smowton 28b6e263ec Kotlin: reintroduce pointless wildcards when a Java declaration explicitly uses them
For example, Java code might use `HasOutVariance<? extends String>`, or `HasInVariance<? super Object>`, both of which are needless wildcards and which the Kotlin extractor would previously have refused to reintroduce due to their not specifying a larger type than their bound. However this led to inconsistency with Java extraction, which
extracts the type as it appears in source.

This seems to particularly happen with generated code, e.g. the output of the Kotlin protobuf compiler.
2022-10-26 20:05:27 +01:00

10 lines
454 B
Java

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) { }
}