Load Class<?> as KClass<*> for Java annotations parameters
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] args();
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class O
|
||||
class K
|
||||
|
||||
JavaAnn(args = array(O::class, K::class)) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val args = javaClass<MyClass>().getAnnotation(javaClass<JavaAnn>()).args()
|
||||
val argName1 = args[0].simpleName ?: "fail 1"
|
||||
val argName2 = args[1].simpleName ?: "fail 2"
|
||||
return argName1 + argName2
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] args();
|
||||
}
|
||||
|
||||
class O {}
|
||||
class K {}
|
||||
|
||||
@JavaAnn(args = {O.class, K.class})
|
||||
class MyJavaClass {}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
val args = javaClass<MyJavaClass>().getAnnotation(javaClass<JavaAnn>()).args()
|
||||
val argName1 = args[0].simpleName ?: "fail 1"
|
||||
val argName2 = args[1].simpleName ?: "fail 2"
|
||||
return argName1 + argName2
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?> value();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
class OK
|
||||
|
||||
JavaAnn(OK::class) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val ann = javaClass<MyClass>().getAnnotation(javaClass<JavaAnn>())
|
||||
if (ann == null) return "fail: cannot find JavaAnn on MyClass"
|
||||
return ann.value().simpleName!!
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?> value();
|
||||
}
|
||||
|
||||
class OK {}
|
||||
|
||||
@JavaAnn(OK.class)
|
||||
class MyJavaClass {}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
|
||||
fun box(): String {
|
||||
val ann = javaClass<MyJavaClass>().getAnnotation(javaClass<JavaAnn>())
|
||||
if (ann == null) return "fail: cannot find JavaAnn on MyClass"
|
||||
return ann.value().simpleName!!
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] value();
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class O
|
||||
class K
|
||||
|
||||
JavaAnn(O::class, K::class) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val args = javaClass<MyClass>().getAnnotation(javaClass<JavaAnn>()).value()
|
||||
val argName1 = args[0].simpleName ?: "fail 1"
|
||||
val argName2 = args[1].simpleName ?: "fail 2"
|
||||
return argName1 + argName2
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface JavaAnn {
|
||||
Class<?>[] value();
|
||||
}
|
||||
|
||||
class O {}
|
||||
class K {}
|
||||
|
||||
@JavaAnn({O.class, K.class})
|
||||
class MyJavaClass {}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class O
|
||||
class K
|
||||
|
||||
fun box(): String {
|
||||
val args = javaClass<MyJavaClass>().getAnnotation(javaClass<JavaAnn>()).value()
|
||||
val argName1 = args[0].simpleName ?: "fail 1"
|
||||
val argName2 = args[1].simpleName ?: "fail 2"
|
||||
return argName1 + argName2
|
||||
}
|
||||
+3
-3
@@ -8,7 +8,7 @@ public final annotation class A : kotlin.Annotation {
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun value(): kotlin.String
|
||||
public abstract fun x(): java.lang.Class<*>
|
||||
public abstract fun x1(): java.lang.Class<*>
|
||||
public abstract fun x2(): java.lang.Class<*>
|
||||
public abstract fun x(): kotlin.reflect.KClass<*>
|
||||
public abstract fun x1(): kotlin.reflect.KClass<*>
|
||||
public abstract fun x2(): kotlin.reflect.KClass<*>
|
||||
}
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ public final annotation class A : kotlin.Annotation {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun x(): java.lang.Class<*>
|
||||
public abstract fun x1(): java.lang.Class<*>
|
||||
public abstract fun x2(): java.lang.Class<*>
|
||||
public abstract fun x(): kotlin.reflect.KClass<*>
|
||||
public abstract fun x1(): kotlin.reflect.KClass<*>
|
||||
public abstract fun x2(): kotlin.reflect.KClass<*>
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,6 +15,6 @@ public final annotation class A : kotlin.Annotation {
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun value(): kotlin.Array<kotlin.String>
|
||||
public abstract fun x(): java.lang.Class<*>
|
||||
public abstract fun x(): kotlin.reflect.KClass<*>
|
||||
public abstract fun y(): kotlin.Int
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,6 +18,6 @@ public final annotation class A : kotlin.Annotation {
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun value(): kotlin.Array<kotlin.String>
|
||||
public abstract fun x(): java.lang.Class<*>
|
||||
public abstract fun x(): kotlin.reflect.KClass<*>
|
||||
public abstract fun y(): kotlin.Int
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg() default Integer.class;
|
||||
int x() default 1;
|
||||
B b();
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public @interface B {
|
||||
Class<?> arg() default String.class;
|
||||
int y() default 2;
|
||||
}
|
||||
|
||||
// FILE: c.kt
|
||||
A(arg = String::class, b = B(y = 1)) class MyClass1
|
||||
|
||||
A(b = B(y = 3)) class MyClass2
|
||||
|
||||
A(arg = String::class, b = B(arg = Boolean::class)) class MyClass3
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ arg: kotlin.reflect.KClass<*> = ..., /*1*/ x: kotlin.Int = ..., /*2*/ b: B)
|
||||
public abstract fun arg(): kotlin.reflect.KClass<*>
|
||||
public abstract fun b(): B
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun x(): kotlin.Int
|
||||
}
|
||||
|
||||
public final annotation class B : kotlin.Annotation {
|
||||
public constructor B(/*0*/ arg: kotlin.reflect.KClass<*> = ..., /*1*/ y: kotlin.Int = ...)
|
||||
public abstract fun arg(): kotlin.reflect.KClass<*>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun y(): kotlin.Int
|
||||
}
|
||||
|
||||
A(arg = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>, b = B(y = IntegerValueType(1): IntegerValueType(1)): B) internal final class MyClass1 {
|
||||
public constructor MyClass1()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(b = B(y = IntegerValueType(3): IntegerValueType(3)): B) internal final class MyClass2 {
|
||||
public constructor MyClass2()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(arg = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>, b = B(arg = kotlin.Boolean::class: kotlin.reflect.KClass<kotlin.Boolean>): B) internal final class MyClass3 {
|
||||
public constructor MyClass3()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
A(arg = String::class) class MyClass3
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ arg: kotlin.reflect.KClass<*>)
|
||||
public abstract fun arg(): kotlin.reflect.KClass<*>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(arg = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>) internal final class MyClass3 {
|
||||
public constructor MyClass3()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg();
|
||||
int x() default 1;
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
A(arg = String::class) class MyClass1
|
||||
A(arg = String::class, x = 2) class MyClass2
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ arg: kotlin.reflect.KClass<*>, /*1*/ x: kotlin.Int = ...)
|
||||
public abstract fun arg(): kotlin.reflect.KClass<*>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun x(): kotlin.Int
|
||||
}
|
||||
|
||||
A(arg = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>) internal final class MyClass1 {
|
||||
public constructor MyClass1()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(arg = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>, x = IntegerValueType(2): IntegerValueType(2)) internal final class MyClass2 {
|
||||
public constructor MyClass2()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?>[] arg();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
A(arg = array(String::class, Int::class)) class MyClass
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ arg: kotlin.Array<kotlin.reflect.KClass<*>>)
|
||||
public abstract fun arg(): kotlin.Array<kotlin.reflect.KClass<*>>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(arg = {kotlin.String::class, kotlin.Int::class}: kotlin.Array<kotlin.reflect.KClass<*>>) internal final class MyClass {
|
||||
public constructor MyClass()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg() default Integer.class;
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
A(arg = String::class) class MyClass1
|
||||
A class MyClass2
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ arg: kotlin.reflect.KClass<*> = ...)
|
||||
public abstract fun arg(): kotlin.reflect.KClass<*>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(arg = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>) internal final class MyClass1 {
|
||||
public constructor MyClass1()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A() internal final class MyClass2 {
|
||||
public constructor MyClass2()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg() default Integer.class;
|
||||
int x();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
A(arg = String::class, x = 4) class MyClass2
|
||||
A(x = 5) class MyClass3
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ arg: kotlin.reflect.KClass<*> = ..., /*1*/ x: kotlin.Int)
|
||||
public abstract fun arg(): kotlin.reflect.KClass<*>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun x(): kotlin.Int
|
||||
}
|
||||
|
||||
A(arg = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>, x = IntegerValueType(4): IntegerValueType(4)) internal final class MyClass2 {
|
||||
public constructor MyClass2()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(x = IntegerValueType(5): IntegerValueType(5)) internal final class MyClass3 {
|
||||
public constructor MyClass3()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> arg1();
|
||||
Class<?> arg2();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
A(arg1 = String::class, arg2 = Int::class) class MyClass
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ arg1: kotlin.reflect.KClass<*>, /*1*/ arg2: kotlin.reflect.KClass<*>)
|
||||
public abstract fun arg1(): kotlin.reflect.KClass<*>
|
||||
public abstract fun arg2(): kotlin.reflect.KClass<*>
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(arg1 = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>, arg2 = kotlin.Int::class: kotlin.reflect.KClass<kotlin.Int>) internal final class MyClass {
|
||||
public constructor MyClass()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
A(String::class) class MyClass1
|
||||
A(value = String::class) class MyClass2
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ value: kotlin.reflect.KClass<*>)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun value(): kotlin.reflect.KClass<*>
|
||||
}
|
||||
|
||||
A(value = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>) internal final class MyClass1 {
|
||||
public constructor MyClass1()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(value = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>) internal final class MyClass2 {
|
||||
public constructor MyClass2()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value();
|
||||
int x() default 1;
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
A(String::class) class MyClass1
|
||||
A(value = String::class) class MyClass2
|
||||
|
||||
A(String::class, x = 2) class MyClass3
|
||||
A(value = String::class, x = 4) class MyClass4
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ value: kotlin.reflect.KClass<*>, /*1*/ x: kotlin.Int = ...)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun value(): kotlin.reflect.KClass<*>
|
||||
public abstract fun x(): kotlin.Int
|
||||
}
|
||||
|
||||
A(value = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>) internal final class MyClass1 {
|
||||
public constructor MyClass1()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(value = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>) internal final class MyClass2 {
|
||||
public constructor MyClass2()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(value = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>, x = IntegerValueType(2): IntegerValueType(2)) internal final class MyClass3 {
|
||||
public constructor MyClass3()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(value = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>, x = IntegerValueType(4): IntegerValueType(4)) internal final class MyClass4 {
|
||||
public constructor MyClass4()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?>[] value();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
A(String::class, Int::class) class MyClass1
|
||||
A(*array(String::class, Int::class)) class MyClass2
|
||||
A(value = *array(String::class, Int::class)) class MyClass3
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ vararg value: kotlin.reflect.KClass<*> /*kotlin.Array<out kotlin.reflect.KClass<*>>*/)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun value(): kotlin.Array<kotlin.reflect.KClass<*>>
|
||||
}
|
||||
|
||||
A(value = {kotlin.String::class, kotlin.Int::class}: kotlin.Array<out kotlin.reflect.KClass<*>>) internal final class MyClass1 {
|
||||
public constructor MyClass1()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(value = {kotlin.String::class, kotlin.Int::class}: kotlin.Array<kotlin.reflect.KClass<out kotlin.Comparable<out kotlin.Any?>>>) internal final class MyClass2 {
|
||||
public constructor MyClass2()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(value = {kotlin.String::class, kotlin.Int::class}: kotlin.Array<kotlin.reflect.KClass<out kotlin.Comparable<out kotlin.Any?>>>) internal final class MyClass3 {
|
||||
public constructor MyClass3()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value() default Integer.class;
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
A(String::class) class MyClass1
|
||||
A(value = String::class) class MyClass2
|
||||
A class MyClass3
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ value: kotlin.reflect.KClass<*> = ...)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun value(): kotlin.reflect.KClass<*>
|
||||
}
|
||||
|
||||
A(value = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>) internal final class MyClass1 {
|
||||
public constructor MyClass1()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(value = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>) internal final class MyClass2 {
|
||||
public constructor MyClass2()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A() internal final class MyClass3 {
|
||||
public constructor MyClass3()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// FILE: A.java
|
||||
public @interface A {
|
||||
Class<?> value() default Integer.class;
|
||||
int x();
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
A(String::class, x = 2) class MyClass1
|
||||
A(value = String::class, x = 4) class MyClass2
|
||||
A(x = 5) class MyClass3
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package
|
||||
|
||||
public final annotation class A : kotlin.Annotation {
|
||||
public constructor A(/*0*/ value: kotlin.reflect.KClass<*> = ..., /*1*/ x: kotlin.Int)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public abstract fun value(): kotlin.reflect.KClass<*>
|
||||
public abstract fun x(): kotlin.Int
|
||||
}
|
||||
|
||||
A(value = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>, x = IntegerValueType(2): IntegerValueType(2)) internal final class MyClass1 {
|
||||
public constructor MyClass1()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(value = kotlin.String::class: kotlin.reflect.KClass<kotlin.String>, x = IntegerValueType(4): IntegerValueType(4)) internal final class MyClass2 {
|
||||
public constructor MyClass2()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
A(x = IntegerValueType(5): IntegerValueType(5)) internal final class MyClass3 {
|
||||
public constructor MyClass3()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -4,11 +4,11 @@ public open class ClassObjectArrayInParam {
|
||||
public constructor ClassObjectArrayInParam()
|
||||
|
||||
public final annotation class Anno : kotlin.Annotation {
|
||||
public constructor Anno(/*0*/ vararg value: java.lang.Class<*> /*kotlin.Array<out java.lang.Class<*>>*/)
|
||||
public abstract fun value(): kotlin.Array<java.lang.Class<*>>
|
||||
public constructor Anno(/*0*/ vararg value: kotlin.reflect.KClass<*> /*kotlin.Array<out kotlin.reflect.KClass<*>>*/)
|
||||
public abstract fun value(): kotlin.Array<kotlin.reflect.KClass<*>>
|
||||
}
|
||||
|
||||
test.ClassObjectArrayInParam.Anno(value = {test.ClassObjectArrayInParam.class, test.ClassObjectArrayInParam.Nested.class, kotlin.String.class}: kotlin.Array<out java.lang.Class<*>>) public open class Nested {
|
||||
test.ClassObjectArrayInParam.Anno(value = {test.ClassObjectArrayInParam.class, test.ClassObjectArrayInParam.Nested.class, kotlin.String.class}: kotlin.Array<out kotlin.reflect.KClass<*>>) public open class Nested {
|
||||
public constructor Nested()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ public open class ClassObjectInParam {
|
||||
public constructor ClassObjectInParam()
|
||||
|
||||
public final annotation class Anno : kotlin.Annotation {
|
||||
public constructor Anno(/*0*/ value: java.lang.Class<*>)
|
||||
public abstract fun value(): java.lang.Class<*>
|
||||
public constructor Anno(/*0*/ value: kotlin.reflect.KClass<*>)
|
||||
public abstract fun value(): kotlin.reflect.KClass<*>
|
||||
}
|
||||
|
||||
test.ClassObjectInParam.Anno(value = test.ClassObjectInParam.class: java.lang.Class<test.ClassObjectInParam>) public open class Nested {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package test;
|
||||
|
||||
public class ClassObjectInParamRaw {
|
||||
public @interface Anno {
|
||||
Class value();
|
||||
Class[] arg();
|
||||
}
|
||||
|
||||
@Anno(value = ClassObjectInParamRaw.class, arg = {})
|
||||
public static class Nested {}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package test
|
||||
|
||||
public open class ClassObjectInParamRaw {
|
||||
public constructor ClassObjectInParamRaw()
|
||||
|
||||
public final annotation class Anno : kotlin.Annotation {
|
||||
public constructor Anno(/*0*/ value: kotlin.reflect.KClass<*>, /*1*/ arg: kotlin.Array<kotlin.reflect.KClass<*>>)
|
||||
public abstract fun arg(): kotlin.Array<kotlin.reflect.KClass<*>>
|
||||
public abstract fun value(): kotlin.reflect.KClass<*>
|
||||
}
|
||||
|
||||
test.ClassObjectInParamRaw.Anno(arg = {}: kotlin.Array<kotlin.reflect.KClass<*>>, value = test.ClassObjectInParamRaw.class: java.lang.Class<test.ClassObjectInParamRaw>) public open class Nested {
|
||||
public constructor Nested()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package test;
|
||||
|
||||
public class ClassObjectInParamVariance {
|
||||
public @interface Anno {
|
||||
Class<? extends Integer> arg1();
|
||||
Class<? super Integer> arg2();
|
||||
|
||||
Class<? extends Integer>[] arg3();
|
||||
Class<? super Integer>[] arg4();
|
||||
|
||||
Class<? extends Class<?>>[] arg5();
|
||||
Class<? super Class<?>>[] arg6();
|
||||
|
||||
Class<? extends Class<Integer>>[] arg7();
|
||||
Class<? super Class<Integer>>[] arg8();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package test
|
||||
|
||||
public open class ClassObjectInParamVariance {
|
||||
public constructor ClassObjectInParamVariance()
|
||||
|
||||
public final annotation class Anno : kotlin.Annotation {
|
||||
public constructor Anno(/*0*/ arg1: kotlin.reflect.KClass<out kotlin.Int!>, /*1*/ arg2: kotlin.reflect.KClass<in kotlin.Int!>, /*2*/ arg3: kotlin.Array<kotlin.reflect.KClass<out kotlin.Int!>>, /*3*/ arg4: kotlin.Array<kotlin.reflect.KClass<in kotlin.Int!>>, /*4*/ arg5: kotlin.Array<kotlin.reflect.KClass<out java.lang.Class<*>!>>, /*5*/ arg6: kotlin.Array<kotlin.reflect.KClass<in java.lang.Class<*>!>>, /*6*/ arg7: kotlin.Array<kotlin.reflect.KClass<out java.lang.Class<kotlin.Int!>!>>, /*7*/ arg8: kotlin.Array<kotlin.reflect.KClass<in java.lang.Class<kotlin.Int!>!>>)
|
||||
public abstract fun arg1(): kotlin.reflect.KClass<out kotlin.Int!>
|
||||
public abstract fun arg2(): kotlin.reflect.KClass<in kotlin.Int!>
|
||||
public abstract fun arg3(): kotlin.Array<kotlin.reflect.KClass<out kotlin.Int!>>
|
||||
public abstract fun arg4(): kotlin.Array<kotlin.reflect.KClass<in kotlin.Int!>>
|
||||
public abstract fun arg5(): kotlin.Array<kotlin.reflect.KClass<out java.lang.Class<*>!>>
|
||||
public abstract fun arg6(): kotlin.Array<kotlin.reflect.KClass<in java.lang.Class<*>!>>
|
||||
public abstract fun arg7(): kotlin.Array<kotlin.reflect.KClass<out java.lang.Class<kotlin.Int!>!>>
|
||||
public abstract fun arg8(): kotlin.Array<kotlin.reflect.KClass<in java.lang.Class<kotlin.Int!>!>>
|
||||
}
|
||||
}
|
||||
+81
@@ -175,6 +175,87 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JavaAnnotationsWithKClassParameter extends AbstractJetDiagnosticsTestWithStdLib {
|
||||
public void testAllFilesPresentInJavaAnnotationsWithKClassParameter() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationAsArgument.kt")
|
||||
public void testAnnotationAsArgument() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("arg.kt")
|
||||
public void testArg() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/arg.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("argAndOtherDefault.kt")
|
||||
public void testArgAndOtherDefault() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("argArray.kt")
|
||||
public void testArgArray() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("argWithDefault.kt")
|
||||
public void testArgWithDefault() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefault.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("argWithDefaultAndOther.kt")
|
||||
public void testArgWithDefaultAndOther() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("twoArgs.kt")
|
||||
public void testTwoArgs() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/twoArgs.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("value.kt")
|
||||
public void testValue() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/value.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("valueAndOtherDefault.kt")
|
||||
public void testValueAndOtherDefault() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("valueArray.kt")
|
||||
public void testValueArray() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("valueWithDefault.kt")
|
||||
public void testValueWithDefault() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefault.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("valueWithDefaultAndOther.kt")
|
||||
public void testValueWithDefaultAndOther() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmOverloads")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+45
@@ -90,6 +90,51 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCod
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/annotations/retentionInJava.kt");
|
||||
doTestAgainstJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxAgainstJava/annotations/kClassMapping")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class KClassMapping extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInKClassMapping() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxAgainstJava/annotations/kClassMapping"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayClassParameter.kt")
|
||||
public void testArrayClassParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/annotations/kClassMapping/arrayClassParameter.kt");
|
||||
doTestAgainstJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayClassParameterOnJavaClass.kt")
|
||||
public void testArrayClassParameterOnJavaClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/annotations/kClassMapping/arrayClassParameterOnJavaClass.kt");
|
||||
doTestAgainstJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("classParameter.kt")
|
||||
public void testClassParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/annotations/kClassMapping/classParameter.kt");
|
||||
doTestAgainstJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("classParameterOnJavaClass.kt")
|
||||
public void testClassParameterOnJavaClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/annotations/kClassMapping/classParameterOnJavaClass.kt");
|
||||
doTestAgainstJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("varargClassParameter.kt")
|
||||
public void testVarargClassParameter() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/annotations/kClassMapping/varargClassParameter.kt");
|
||||
doTestAgainstJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("varargClassParameterOnJavaClass.kt")
|
||||
public void testVarargClassParameterOnJavaClass() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/annotations/kClassMapping/varargClassParameterOnJavaClass.kt");
|
||||
doTestAgainstJava(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxAgainstJava/callableReference")
|
||||
|
||||
@@ -351,6 +351,18 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
doTestCompiledJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ClassObjectInParamRaw.java")
|
||||
public void testClassObjectInParamRaw() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.java");
|
||||
doTestCompiledJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ClassObjectInParamVariance.java")
|
||||
public void testClassObjectInParamVariance() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.java");
|
||||
doTestCompiledJava(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("CustomAnnotation.java")
|
||||
public void testCustomAnnotation() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/annotations/CustomAnnotation.java");
|
||||
|
||||
+12
@@ -3357,6 +3357,18 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ClassObjectInParamRaw.java")
|
||||
public void testClassObjectInParamRaw() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("ClassObjectInParamVariance.java")
|
||||
public void testClassObjectInParamVariance() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("CustomAnnotation.java")
|
||||
public void testCustomAnnotation() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/annotations/CustomAnnotation.java");
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ public class LazyJavaClassMemberScope(
|
||||
val methods = jClass.getMethods()
|
||||
val result = ArrayList<ValueParameterDescriptor>(methods.size())
|
||||
|
||||
val attr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes(allowFlexible = false)
|
||||
val attr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes(allowFlexible = false, isForAnnotationParameter = true)
|
||||
|
||||
val (methodsNamedValue, otherMethods) = methods.
|
||||
partition { it.getName() == JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME }
|
||||
|
||||
+5
-1
@@ -120,7 +120,11 @@ public abstract class LazyJavaMemberScope(
|
||||
val valueParameters = resolveValueParameters(c, functionDescriptorImpl, method.getValueParameters())
|
||||
|
||||
val annotationMethod = method.getContainingClass().isAnnotationType()
|
||||
val returnTypeAttrs = LazyJavaTypeAttributes(c, method, TypeUsage.MEMBER_SIGNATURE_COVARIANT, annotations, allowFlexible = !annotationMethod)
|
||||
val returnTypeAttrs = LazyJavaTypeAttributes(
|
||||
c, method, TypeUsage.MEMBER_SIGNATURE_COVARIANT, annotations,
|
||||
allowFlexible = !annotationMethod,
|
||||
isForAnnotationParameter = annotationMethod
|
||||
)
|
||||
val returnJavaType = method.getReturnType() ?: throw IllegalStateException("Constructor passed as method: $method")
|
||||
// Annotation arguments are never null in Java
|
||||
val returnType = c.typeResolver.transformJavaType(returnJavaType, returnTypeAttrs).let {
|
||||
|
||||
+35
-18
@@ -35,10 +35,13 @@ import org.jetbrains.kotlin.resolve.jvm.PLATFORM_TYPES
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeFlexibility.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import kotlin.platform.platformStatic
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceAnnotations
|
||||
import kotlin.properties.*
|
||||
|
||||
private val JAVA_LANG_CLASS_FQ_NAME: FqName = FqName("java.lang.Class")
|
||||
|
||||
class LazyJavaTypeResolver(
|
||||
private val c: LazyJavaResolverContext,
|
||||
private val typeParameterResolver: TypeParameterResolver
|
||||
@@ -76,7 +79,8 @@ class LazyJavaTypeResolver(
|
||||
}
|
||||
}
|
||||
|
||||
val componentType = transformJavaType(javaComponentType, TYPE_ARGUMENT.toAttributes(attr.allowFlexible))
|
||||
val componentType = transformJavaType(javaComponentType,
|
||||
TYPE_ARGUMENT.toAttributes(attr.allowFlexible, attr.isForAnnotationParameter))
|
||||
|
||||
if (PLATFORM_TYPES && attr.allowFlexible) {
|
||||
return@run FlexibleJavaClassifierTypeCapabilities.create(
|
||||
@@ -117,21 +121,7 @@ class LazyJavaTypeResolver(
|
||||
val fqName = classifier.getFqName()
|
||||
.sure("Class type should have a FQ name: " + classifier)
|
||||
|
||||
val javaToKotlinClassMap = JavaToKotlinClassMap.INSTANCE
|
||||
val howThisTypeIsUsedEffectively = when {
|
||||
attr.flexibility == FLEXIBLE_LOWER_BOUND -> MEMBER_SIGNATURE_COVARIANT
|
||||
attr.flexibility == FLEXIBLE_UPPER_BOUND -> MEMBER_SIGNATURE_CONTRAVARIANT
|
||||
|
||||
// This case has to be checked before isMarkedReadOnly/isMarkedMutable, because those two are slow
|
||||
// not mapped, we don't care about being marked mutable/read-only
|
||||
javaToKotlinClassMap.mapPlatformClass(fqName).isEmpty() -> attr.howThisTypeIsUsed
|
||||
|
||||
// Read (possibly external) annotations
|
||||
else -> attr.howThisTypeIsUsedAccordingToAnnotations
|
||||
}
|
||||
|
||||
val classData = javaToKotlinClassMap.mapKotlinClass(fqName, howThisTypeIsUsedEffectively)
|
||||
?: c.moduleClassResolver.resolveClass(classifier)
|
||||
val classData = mapKotlinClass(fqName) ?: c.moduleClassResolver.resolveClass(classifier)
|
||||
|
||||
classData?.getTypeConstructor()
|
||||
?: ErrorUtils.createErrorTypeConstructor("Unresolved java classifier: " + javaType.getPresentableText())
|
||||
@@ -149,6 +139,28 @@ class LazyJavaTypeResolver(
|
||||
}
|
||||
}
|
||||
|
||||
private fun mapKotlinClass(fqName: FqName): ClassDescriptor? {
|
||||
if (attr.isForAnnotationParameter && fqName == JAVA_LANG_CLASS_FQ_NAME) {
|
||||
return c.reflectionTypes.kClass
|
||||
}
|
||||
|
||||
val javaToKotlinClassMap = JavaToKotlinClassMap.INSTANCE
|
||||
|
||||
val howThisTypeIsUsedEffectively = when {
|
||||
attr.flexibility == FLEXIBLE_LOWER_BOUND -> MEMBER_SIGNATURE_COVARIANT
|
||||
attr.flexibility == FLEXIBLE_UPPER_BOUND -> MEMBER_SIGNATURE_CONTRAVARIANT
|
||||
|
||||
// This case has to be checked before isMarkedReadOnly/isMarkedMutable, because those two are slow
|
||||
// not mapped, we don't care about being marked mutable/read-only
|
||||
javaToKotlinClassMap.mapPlatformClass(fqName).isEmpty() -> attr.howThisTypeIsUsed
|
||||
|
||||
// Read (possibly external) annotations
|
||||
else -> attr.howThisTypeIsUsedAccordingToAnnotations
|
||||
}
|
||||
|
||||
return javaToKotlinClassMap.mapKotlinClass(fqName, howThisTypeIsUsedEffectively)
|
||||
}
|
||||
|
||||
private fun isConstructorTypeParameter(): Boolean {
|
||||
val classifier = classifier()
|
||||
return classifier is JavaTypeParameter && classifier.getOwner() is JavaConstructor
|
||||
@@ -331,6 +343,8 @@ trait JavaTypeAttributes {
|
||||
val allowFlexible: Boolean
|
||||
get() = true
|
||||
val annotations: Annotations
|
||||
val isForAnnotationParameter: Boolean
|
||||
get() = false
|
||||
}
|
||||
|
||||
enum class JavaTypeFlexibility {
|
||||
@@ -344,7 +358,8 @@ class LazyJavaTypeAttributes(
|
||||
val annotationOwner: JavaAnnotationOwner,
|
||||
override val howThisTypeIsUsed: TypeUsage,
|
||||
override val annotations: Annotations,
|
||||
override val allowFlexible: Boolean = true
|
||||
override val allowFlexible: Boolean = true,
|
||||
override val isForAnnotationParameter: Boolean = false
|
||||
): JavaTypeAttributes {
|
||||
|
||||
override val howThisTypeIsUsedAccordingToAnnotations: TypeUsage by c.storageManager.createLazyValue {
|
||||
@@ -362,7 +377,7 @@ private fun Annotations.isMarkedMutable() = findAnnotation(JvmAnnotationNames.JE
|
||||
internal fun Annotations.isMarkedNotNull() = findAnnotation(JvmAnnotationNames.JETBRAINS_NOT_NULL_ANNOTATION) != null
|
||||
internal fun Annotations.isMarkedNullable() = findAnnotation(JvmAnnotationNames.JETBRAINS_NULLABLE_ANNOTATION) != null
|
||||
|
||||
fun TypeUsage.toAttributes(allowFlexible: Boolean = true) = object : JavaTypeAttributes {
|
||||
fun TypeUsage.toAttributes(allowFlexible: Boolean = true, isForAnnotationParameter: Boolean = false) = object : JavaTypeAttributes {
|
||||
override val howThisTypeIsUsed: TypeUsage = this@toAttributes
|
||||
override val howThisTypeIsUsedAccordingToAnnotations: TypeUsage
|
||||
get() = howThisTypeIsUsed
|
||||
@@ -370,6 +385,8 @@ fun TypeUsage.toAttributes(allowFlexible: Boolean = true) = object : JavaTypeAtt
|
||||
override val allowFlexible: Boolean = allowFlexible
|
||||
|
||||
override val annotations: Annotations = Annotations.EMPTY
|
||||
|
||||
override val isForAnnotationParameter: Boolean = isForAnnotationParameter
|
||||
}
|
||||
|
||||
fun JavaTypeAttributes.toFlexible(flexibility: JavaTypeFlexibility) =
|
||||
|
||||
Reference in New Issue
Block a user