Do not write "? extends" and "? super" in immediate arguments of supertypes in Java generic signatures
This commit is contained in:
@@ -9,15 +9,15 @@ fun A.baz() {}
|
||||
|
||||
fun box(): String {
|
||||
val f = "${::foo}"
|
||||
if (f != "jet.KFunctionImpl1<? super java.lang.String, ? extends jet.Unit>") return "Fail foo: $f"
|
||||
if (f != "jet.KFunctionImpl1<java.lang.String, jet.Unit>") return "Fail foo: $f"
|
||||
|
||||
val nameOfA = (A() as java.lang.Object).getClass().getName()
|
||||
|
||||
val g = "${A::bar}"
|
||||
if (g != "jet.KMemberFunctionImpl0<? super $nameOfA, ? extends java.lang.String>") return "Fail bar: $g"
|
||||
if (g != "jet.KMemberFunctionImpl0<$nameOfA, java.lang.String>") return "Fail bar: $g"
|
||||
|
||||
val h = "${A::baz}"
|
||||
if (h != "jet.KExtensionFunctionImpl0<? super $nameOfA, ? extends jet.Unit>") return "Fail baz: $h"
|
||||
if (h != "jet.KExtensionFunctionImpl0<$nameOfA, jet.Unit>") return "Fail baz: $h"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -6,22 +6,22 @@ fun check(expected: String, obj: Any?) {
|
||||
|
||||
|
||||
fun box(): String {
|
||||
check("jet.FunctionImpl0<? extends jet.Unit>")
|
||||
check("jet.FunctionImpl0<jet.Unit>")
|
||||
{ () : Unit -> }
|
||||
check("jet.FunctionImpl0<? extends java.lang.Integer>")
|
||||
check("jet.FunctionImpl0<java.lang.Integer>")
|
||||
{ () : Int -> 42 }
|
||||
check("jet.FunctionImpl1<? super java.lang.String, ? extends java.lang.Long>")
|
||||
check("jet.FunctionImpl1<java.lang.String, java.lang.Long>")
|
||||
{ (s: String) : Long -> 42.toLong() }
|
||||
check("jet.FunctionImpl2<? super java.lang.Integer, ? super java.lang.Integer, ? extends jet.Unit>")
|
||||
check("jet.FunctionImpl2<java.lang.Integer, java.lang.Integer, jet.Unit>")
|
||||
{ (x: Int, y: Int) : Unit -> }
|
||||
|
||||
check("jet.ExtensionFunctionImpl0<? super java.lang.Integer, ? extends jet.Unit>")
|
||||
check("jet.ExtensionFunctionImpl0<java.lang.Integer, jet.Unit>")
|
||||
{ Int.() : Unit -> }
|
||||
check("jet.ExtensionFunctionImpl0<? super jet.Unit, ? extends java.lang.Integer>")
|
||||
check("jet.ExtensionFunctionImpl0<jet.Unit, java.lang.Integer>")
|
||||
{ Unit.() : Int -> 42 }
|
||||
check("jet.ExtensionFunctionImpl1<? super java.lang.String, ? super java.lang.String, ? extends java.lang.Long>")
|
||||
check("jet.ExtensionFunctionImpl1<java.lang.String, java.lang.String, java.lang.Long>")
|
||||
{ String.(s: String) : Long -> 42.toLong() }
|
||||
check("jet.ExtensionFunctionImpl2<? super java.lang.Integer, ? super java.lang.Integer, ? super java.lang.Integer, ? extends jet.Unit>")
|
||||
check("jet.ExtensionFunctionImpl2<java.lang.Integer, java.lang.Integer, java.lang.Integer, jet.Unit>")
|
||||
{ Int.(x: Int, y: Int) : Unit -> }
|
||||
|
||||
return "OK"
|
||||
|
||||
@@ -14,18 +14,22 @@ val stringParamFun = { (x: String) : Unit -> }
|
||||
val listFun = { (l: List<String>) : List<String> -> l }
|
||||
val mutableListFun = { (l: MutableList<Double>) : MutableList<Int> -> null!! }
|
||||
|
||||
trait In<in T>
|
||||
val funWithIn = { (x: In<String>) : Unit -> }
|
||||
|
||||
val extensionFun = { Any.() : Unit -> }
|
||||
val extensionWithArgFun = { Long.(x: Any) : Date -> Date() }
|
||||
|
||||
fun box(): String {
|
||||
assertGenericSuper("jet.FunctionImpl0<? extends jet.Unit>", unitFun)
|
||||
assertGenericSuper("jet.FunctionImpl0<? extends java.lang.Integer>", intFun)
|
||||
assertGenericSuper("jet.FunctionImpl1<? super java.lang.String, ? extends jet.Unit>", stringParamFun)
|
||||
assertGenericSuper("jet.FunctionImpl1<? super java.util.List<? extends java.lang.String>, ? extends java.util.List<? extends java.lang.String>>", listFun)
|
||||
assertGenericSuper("jet.FunctionImpl1<? super java.util.List<java.lang.Double>, ? extends java.util.List<java.lang.Integer>>", mutableListFun)
|
||||
|
||||
assertGenericSuper("jet.ExtensionFunctionImpl0<? super java.lang.Object, ? extends jet.Unit>", extensionFun)
|
||||
assertGenericSuper("jet.ExtensionFunctionImpl1<? super java.lang.Long, ? super java.lang.Object, ? extends java.util.Date>", extensionWithArgFun)
|
||||
|
||||
assertGenericSuper("jet.FunctionImpl0<jet.Unit>", unitFun)
|
||||
assertGenericSuper("jet.FunctionImpl0<java.lang.Integer>", intFun)
|
||||
assertGenericSuper("jet.FunctionImpl1<java.lang.String, jet.Unit>", stringParamFun)
|
||||
assertGenericSuper("jet.FunctionImpl1<java.util.List<? extends java.lang.String>, java.util.List<? extends java.lang.String>>", listFun)
|
||||
assertGenericSuper("jet.FunctionImpl1<java.util.List<java.lang.Double>, java.util.List<java.lang.Integer>>", mutableListFun)
|
||||
assertGenericSuper("jet.FunctionImpl1<In<? super java.lang.String>, jet.Unit>", funWithIn)
|
||||
|
||||
assertGenericSuper("jet.ExtensionFunctionImpl0<java.lang.Object, jet.Unit>", extensionFun)
|
||||
assertGenericSuper("jet.ExtensionFunctionImpl1<java.lang.Long, java.lang.Object, java.util.Date>", extensionWithArgFun)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user