Support JvmSuppressWildcards and JvmWildcard annotations
#KT-9898 Fixed
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
public class JavaClass {
|
||||
|
||||
public static class C extends B {
|
||||
public OutPair<String, Integer> foo() {
|
||||
return super.foo();
|
||||
}
|
||||
|
||||
public In<Object> bar() {
|
||||
return super.bar();
|
||||
}
|
||||
}
|
||||
|
||||
public static String test() {
|
||||
A a = new C();
|
||||
|
||||
if (!a.foo().getX().equals("OK")) return "fail 1";
|
||||
if (!a.foo().getY().equals(123)) return "fail 2";
|
||||
|
||||
if (!a.bar().make("123").equals("123")) return "fail 3";
|
||||
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
class OutPair<out X, out Y>(val x: X, val y: Y)
|
||||
class In<in Z> {
|
||||
fun make(x: Z): String = x.toString()
|
||||
}
|
||||
|
||||
@JvmSuppressWildcards(suppress = false)
|
||||
interface A {
|
||||
fun foo(): OutPair<CharSequence, Number>
|
||||
fun bar(): In<String>
|
||||
}
|
||||
|
||||
abstract class B : A {
|
||||
override fun foo(): OutPair<String, Int> = OutPair("OK", 123)
|
||||
override fun bar(): In<Any> = In()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return JavaClass.test();
|
||||
}
|
||||
+2
-1
@@ -7,11 +7,12 @@ public abstract class AImpl {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
@JvmSuppressWildcards(suppress = false)
|
||||
fun addAll(elements: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun addAll(index: Int, elements: Collection<String>): Boolean {
|
||||
fun addAll(index: Int, elements: Collection<@JvmWildcard String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
public class JavaClass {
|
||||
|
||||
public static class C extends B {
|
||||
public OutPair<String, Integer> foo() {
|
||||
return super.foo();
|
||||
}
|
||||
|
||||
public In<Object> bar() {
|
||||
return super.bar();
|
||||
}
|
||||
}
|
||||
|
||||
public static String test() {
|
||||
A a = new C();
|
||||
|
||||
if (!a.foo().getX().equals("OK")) return "fail 1";
|
||||
if (!a.foo().getY().equals(123)) return "fail 2";
|
||||
|
||||
if (!a.bar().make("123").equals("123")) return "fail 3";
|
||||
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
class OutPair<out X, out Y>(val x: X, val y: Y)
|
||||
class In<in Z> {
|
||||
fun make(x: Z): String = x.toString()
|
||||
}
|
||||
|
||||
interface A {
|
||||
fun foo(): OutPair<@JvmWildcard CharSequence, @JvmSuppressWildcards(false) Number>
|
||||
fun bar(): In<@JvmWildcard String>
|
||||
}
|
||||
|
||||
abstract class B : A {
|
||||
override fun foo(): OutPair<String, Int> = OutPair("OK", 123)
|
||||
override fun bar(): In<Any> = In()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return JavaClass.test();
|
||||
}
|
||||
Reference in New Issue
Block a user