From 8f0e290deccf6990ceaca13ad70ab387554877ec Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 15 Apr 2015 21:38:44 +0300 Subject: [PATCH] Create additional constructor for java annotation with Class-parameter One of them with KClass<*> parameters and other with java.lang.Class<*>. It's needed just for backward compatibility, and second one is deprecared. --- .../annotationParameters/orderWithValue.txt | 3 +- .../orderWithoutValue.txt | 3 +- .../annotationParameters/valueArray.txt | 3 +- .../valueArrayAndOtherDefault.kt | 4 +- .../valueArrayAndOtherDefault.txt | 3 +- .../annotationAsArgument.kt | 23 ++++++ .../annotationAsArgument.txt | 57 +++++++++++++ .../arg.kt | 7 ++ .../arg.txt | 17 ++++ .../argAndOtherDefault.kt | 10 +++ .../argAndOtherDefault.txt | 25 ++++++ .../argArray.kt | 11 +++ .../argArray.txt | 31 +++++++ .../argWithDefault.kt | 8 ++ .../argWithDefault.txt | 24 ++++++ .../argWithDefaultAndOther.kt | 9 +++ .../argWithDefaultAndOther.txt | 25 ++++++ .../twoArgs.kt | 11 +++ .../twoArgs.txt | 32 ++++++++ .../value.kt | 8 ++ .../value.txt | 24 ++++++ .../valueAndOtherDefault.kt | 13 +++ .../valueAndOtherDefault.txt | 39 +++++++++ .../valueArray.kt | 14 ++++ .../valueArray.txt | 45 +++++++++++ .../valueWithDefault.kt | 11 +++ .../valueWithDefault.txt | 31 +++++++ .../valueWithDefaultAndOther.kt | 10 +++ .../valueWithDefaultAndOther.txt | 32 ++++++++ .../annotationAsArgument.txt | 2 + .../arg.txt | 1 + .../argAndOtherDefault.txt | 1 + .../argArray.txt | 1 + .../argWithDefault.txt | 1 + .../argWithDefaultAndOther.txt | 1 + .../twoArgs.txt | 1 + .../value.txt | 1 + .../valueAndOtherDefault.txt | 1 + .../valueArray.txt | 1 + .../valueWithDefault.txt | 1 + .../valueWithDefaultAndOther.txt | 1 + .../annotations/ClassObjectArrayInParam.txt | 1 + .../annotations/ClassObjectInParam.txt | 1 + .../annotations/ClassObjectInParamRaw.txt | 1 + .../ClassObjectInParamVariance.txt | 1 + ...JetDiagnosticsTestWithStdLibGenerated.java | 81 +++++++++++++++++++ .../components/DescriptorResolverUtils.java | 1 - .../JavaConstructorDescriptor.java | 10 +-- .../descriptors/LazyJavaClassMemberScope.kt | 47 ++++++++--- 49 files changed, 666 insertions(+), 23 deletions(-) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/annotationAsArgument.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/annotationAsArgument.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/arg.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/arg.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argAndOtherDefault.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argAndOtherDefault.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefault.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefault.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefaultAndOther.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefaultAndOther.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/twoArgs.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/twoArgs.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/value.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/value.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueAndOtherDefault.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueAndOtherDefault.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefault.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefault.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefaultAndOther.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefaultAndOther.txt diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithValue.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithValue.txt index 16c9ef11d0b..4a4e8af7019 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithValue.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithValue.txt @@ -1,7 +1,8 @@ package public final annotation class A : kotlin.Annotation { - public constructor A(/*0*/ value: kotlin.String, /*1*/ b: kotlin.Double, /*2*/ x1: java.lang.Class<*>, /*3*/ a: kotlin.Int, /*4*/ x: java.lang.Class<*>, /*5*/ x2: java.lang.Class<*>) + public /*synthesized*/ constructor A(/*0*/ value: kotlin.String, /*1*/ b: kotlin.Double, /*2*/ x1: java.lang.Class<*>, /*3*/ a: kotlin.Int, /*4*/ x: java.lang.Class<*>, /*5*/ x2: java.lang.Class<*>) + public constructor A(/*0*/ value: kotlin.String, /*1*/ b: kotlin.Double, /*2*/ x1: kotlin.reflect.KClass<*>, /*3*/ a: kotlin.Int, /*4*/ x: kotlin.reflect.KClass<*>, /*5*/ x2: kotlin.reflect.KClass<*>) public abstract fun a(): kotlin.Int public abstract fun b(): kotlin.Double public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithoutValue.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithoutValue.txt index d14c18669fa..0a4caa9c727 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithoutValue.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithoutValue.txt @@ -1,7 +1,8 @@ package public final annotation class A : kotlin.Annotation { - public constructor A(/*0*/ b: kotlin.Double, /*1*/ x1: java.lang.Class<*>, /*2*/ a: kotlin.Int, /*3*/ x: java.lang.Class<*>, /*4*/ x2: java.lang.Class<*>) + public /*synthesized*/ constructor A(/*0*/ b: kotlin.Double, /*1*/ x1: java.lang.Class<*>, /*2*/ a: kotlin.Int, /*3*/ x: java.lang.Class<*>, /*4*/ x2: java.lang.Class<*>) + public constructor A(/*0*/ b: kotlin.Double, /*1*/ x1: kotlin.reflect.KClass<*>, /*2*/ a: kotlin.Int, /*3*/ x: kotlin.reflect.KClass<*>, /*4*/ x2: kotlin.reflect.KClass<*>) public abstract fun a(): kotlin.Int public abstract fun b(): kotlin.Double public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt index a3441777675..b9e9fb360fa 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt @@ -10,7 +10,8 @@ A(value = {}: kotlin.Array, y = IntegerValueType(7): IntegerV A(value = {"8", "9", "10"}: kotlin.Array) internal fun test8(): kotlin.Unit public final annotation class A : kotlin.Annotation { - public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/, /*1*/ x: java.lang.Class<*> = ..., /*2*/ y: kotlin.Int) + public /*synthesized*/ constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/, /*1*/ x: java.lang.Class<*> = ..., /*2*/ y: kotlin.Int) + public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/, /*1*/ x: kotlin.reflect.KClass<*> = ..., /*2*/ y: 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 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.kt index 3b43f857b55..0973f947905 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.kt @@ -22,6 +22,6 @@ public @interface A { [A] fun test8() {} -[A(x = javaClass(), *array("5", "6"), "7", y = 3)] fun test9() {} -[A(x = javaClass(), value = *array("5", "6"), "7", y = 3)] fun test10() {} +[A(x = ; java.lang.Class)!>javaClass(), *array("5", "6"), "7", y = 3)] fun test9() {} +[A(x = ; java.lang.Class)!>javaClass(), value = *array("5", "6"), "7", y = 3)] fun test10() {} [A(x = javaClass(), value = *array("5", "6", "7"), y = 3)] fun test11() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt index 6bede1ffedc..4d1f00c75a0 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt @@ -13,7 +13,8 @@ A(value = {}: kotlin.Array) internal fun test8(): kotlin.Unit A(value = {}: kotlin.Array, x = kotlin.Any.class: java.lang.Class, y = IntegerValueType(3): IntegerValueType(3)) internal fun test9(): kotlin.Unit public final annotation class A : kotlin.Annotation { - public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/, /*1*/ x: java.lang.Class<*> = ..., /*2*/ y: kotlin.Int = ...) + public /*synthesized*/ constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/, /*1*/ x: java.lang.Class<*> = ..., /*2*/ y: kotlin.Int = ...) + public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/, /*1*/ x: kotlin.reflect.KClass<*> = ..., /*2*/ y: 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 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/annotationAsArgument.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/annotationAsArgument.kt new file mode 100644 index 00000000000..4096031efa3 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/annotationAsArgument.kt @@ -0,0 +1,23 @@ +// 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 = javaClass(), b = B()) class MyClass1 + +A(b = B(y = 3)) class MyClass3 + +A(b = B(arg = javaClass())) class MyClass4 + +A(arg = javaClass(), b = B(arg = Char::class)) class MyClass5 + +A(arg = String::class, b = B(arg = javaClass())) class MyClass6 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/annotationAsArgument.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/annotationAsArgument.txt new file mode 100644 index 00000000000..d908943fbbd --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/annotationAsArgument.txt @@ -0,0 +1,57 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: java.lang.Class<*> = ..., /*1*/ x: kotlin.Int = ..., /*2*/ b: B) + 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 /*synthesized*/ constructor B(/*0*/ arg: java.lang.Class<*> = ..., /*1*/ y: kotlin.Int = ...) + 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: java.lang.Class, b = B(): 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 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(b = B(arg = kotlin.Double.class: java.lang.Class): B) 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 +} + +A(arg = kotlin.Boolean.class: java.lang.Class, b = B(arg = kotlin.Char::class: kotlin.reflect.KClass): B) internal final class MyClass5 { + public constructor MyClass5() + 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, b = B(arg = kotlin.Boolean.class: java.lang.Class): B) internal final class MyClass6 { + public constructor MyClass6() + 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/arg.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/arg.kt new file mode 100644 index 00000000000..3bbbc9cb6b1 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/arg.kt @@ -0,0 +1,7 @@ +// FILE: A.java +public @interface A { + Class arg(); +} + +// FILE: b.kt +A(arg = javaClass()) class MyClass diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/arg.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/arg.txt new file mode 100644 index 00000000000..0307898e112 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/arg.txt @@ -0,0 +1,17 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: java.lang.Class<*>) + 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: java.lang.Class) 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argAndOtherDefault.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argAndOtherDefault.kt new file mode 100644 index 00000000000..2f450e0945a --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argAndOtherDefault.kt @@ -0,0 +1,10 @@ +// FILE: A.java +public @interface A { + Class arg(); + int x() default 1; +} + +// FILE: b.kt +A(arg = javaClass()) class MyClass1 + +A(arg = javaClass(), x = 1) class MyClass2 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argAndOtherDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argAndOtherDefault.txt new file mode 100644 index 00000000000..aaf67b2cc02 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argAndOtherDefault.txt @@ -0,0 +1,25 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: java.lang.Class<*>, /*1*/ x: kotlin.Int = ...) + 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: java.lang.Class) 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: java.lang.Class, x = IntegerValueType(1): IntegerValueType(1)) 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.kt new file mode 100644 index 00000000000..cabdc79b711 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.kt @@ -0,0 +1,11 @@ +// FILE: A.java +public @interface A { + Class[] arg(); +} + +// FILE: b.kt + +A(arg = array(javaClass(), javaClass())) class MyClass1 + +A(arg = array(javaClass(), Int::class)) class MyClass2 +A(arg = array(String::class, javaClass())) class MyClass3 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.txt new file mode 100644 index 00000000000..efcf135c747 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.txt @@ -0,0 +1,31 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: kotlin.Array>) + public constructor A(/*0*/ arg: kotlin.Array>) + public abstract fun arg(): kotlin.Array> + 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>) 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.Int::class}: kotlin.Array) 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.Int.class}: kotlin.Array) 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefault.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefault.kt new file mode 100644 index 00000000000..5af21fffe86 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefault.kt @@ -0,0 +1,8 @@ +// FILE: A.java +public @interface A { + Class arg() default Integer.class; +} + +// FILE: b.kt +A(arg = javaClass()) class MyClass1 +A class MyClass3 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefault.txt new file mode 100644 index 00000000000..b7b923fbb57 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefault.txt @@ -0,0 +1,24 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: java.lang.Class<*> = ...) + 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: java.lang.Class) 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 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefaultAndOther.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefaultAndOther.kt new file mode 100644 index 00000000000..da3bc83bfea --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefaultAndOther.kt @@ -0,0 +1,9 @@ +// FILE: A.java +public @interface A { + Class arg() default Integer.class; + int x(); +} + +// FILE: b.kt +A(arg = javaClass(), x = 3) class MyClass1 +A(x = 5) class MyClass2 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefaultAndOther.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefaultAndOther.txt new file mode 100644 index 00000000000..53d55a97b74 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefaultAndOther.txt @@ -0,0 +1,25 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: java.lang.Class<*> = ..., /*1*/ x: kotlin.Int) + 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: java.lang.Class, x = IntegerValueType(3): IntegerValueType(3)) 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(x = IntegerValueType(5): IntegerValueType(5)) 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/twoArgs.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/twoArgs.kt new file mode 100644 index 00000000000..576a464450b --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/twoArgs.kt @@ -0,0 +1,11 @@ +// FILE: A.java +public @interface A { + Class arg1(); + Class arg2(); +} + +// FILE: b.kt +A(arg1 = javaClass(), arg2 = javaClass()) class MyClass1 + +A(arg1 = javaClass(), arg2 = Int::class) class MyClass3 +A(arg1 = String::class, arg2 = javaClass()) class MyClass4 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/twoArgs.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/twoArgs.txt new file mode 100644 index 00000000000..1bc02e5cc77 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/twoArgs.txt @@ -0,0 +1,32 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg1: java.lang.Class<*>, /*1*/ arg2: java.lang.Class<*>) + 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: java.lang.Class, arg2 = kotlin.Int.class: java.lang.Class) 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(arg1 = kotlin.String.class: java.lang.Class, arg2 = kotlin.Int::class: kotlin.reflect.KClass) 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(arg1 = kotlin.String::class: kotlin.reflect.KClass, arg2 = kotlin.Int.class: java.lang.Class) 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/value.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/value.kt new file mode 100644 index 00000000000..66ee24a9c96 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/value.kt @@ -0,0 +1,8 @@ +// FILE: A.java +public @interface A { + Class value(); +} + +// FILE: b.kt +A(javaClass()) class MyClass1 +A(value = javaClass()) class MyClass2 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/value.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/value.txt new file mode 100644 index 00000000000..0e43d78cace --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/value.txt @@ -0,0 +1,24 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ value: java.lang.Class<*>) + 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: java.lang.Class) 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: java.lang.Class) 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueAndOtherDefault.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueAndOtherDefault.kt new file mode 100644 index 00000000000..f9dc38bf1c9 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueAndOtherDefault.kt @@ -0,0 +1,13 @@ +// !DIAGNOSTICS: -JAVA_LANG_CLASS_ARGUMENT_IN_ANNOTATION +// FILE: A.java +public @interface A { + Class value(); + int x() default 1; +} + +// FILE: b.kt +A(javaClass()) class MyClass1 +A(value = javaClass()) class MyClass2 + +A(javaClass(), x = 1) class MyClass3 +A(value = javaClass(), x = 3) class MyClass4 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueAndOtherDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueAndOtherDefault.txt new file mode 100644 index 00000000000..0a0f4a15ba2 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueAndOtherDefault.txt @@ -0,0 +1,39 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ value: java.lang.Class<*>, /*1*/ x: kotlin.Int = ...) + 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: java.lang.Class) 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: java.lang.Class) 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: java.lang.Class, x = IntegerValueType(1): IntegerValueType(1)) 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: java.lang.Class, x = IntegerValueType(3): IntegerValueType(3)) 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.kt new file mode 100644 index 00000000000..e2cb1e9c2bf --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.kt @@ -0,0 +1,14 @@ +// FILE: A.java +public @interface A { + Class[] value(); +} + +// FILE: b.kt +A(javaClass(), javaClass()) class MyClass1 + +A(*array(javaClass(), javaClass())) class MyClass2 + +A(value = *array(javaClass(), javaClass())) class MyClass3 + +A(javaClass(), Int::class) class MyClass4 +A(String::class, javaClass()) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.txt new file mode 100644 index 00000000000..6bedd924aa1 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.txt @@ -0,0 +1,45 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ vararg value: java.lang.Class<*> /*kotlin.Array>*/) + public constructor A(/*0*/ vararg value: kotlin.reflect.KClass<*> /*kotlin.Array>*/) + 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> +} + +A(value = {kotlin.String.class, kotlin.Int.class}: kotlin.Array>) 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>>) 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>>) 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.Int::class}: kotlin.Array>) 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 +} + +A(value = {kotlin.String::class, kotlin.Int.class}: kotlin.Array>) internal final class MyClass5 { + public constructor MyClass5() + 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefault.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefault.kt new file mode 100644 index 00000000000..5379316b828 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefault.kt @@ -0,0 +1,11 @@ +// FILE: A.java +public @interface A { + Class value() default Integer.class; +} + +// FILE: b.kt +A(javaClass()) class MyClass1 + +A(value = javaClass()) class MyClass2 + +A class MyClass3 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefault.txt new file mode 100644 index 00000000000..2acfcfd2012 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefault.txt @@ -0,0 +1,31 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ value: java.lang.Class<*> = ...) + 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: java.lang.Class) 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: java.lang.Class) 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefaultAndOther.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefaultAndOther.kt new file mode 100644 index 00000000000..0c6e8687405 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefaultAndOther.kt @@ -0,0 +1,10 @@ +// FILE: A.java +public @interface A { +Class value() default Integer.class; +int x(); +} + +// FILE: b.kt +A(javaClass(), x = 1) class MyClass1 +A(value = javaClass(), x = 3) class MyClass2 +A(x = 5) class MyClass3 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefaultAndOther.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefaultAndOther.txt new file mode 100644 index 00000000000..97b5ee1e16f --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefaultAndOther.txt @@ -0,0 +1,32 @@ +package + +public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ value: java.lang.Class<*> = ..., /*1*/ x: kotlin.Int) + 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: java.lang.Class, x = IntegerValueType(1): IntegerValueType(1)) 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: java.lang.Class, x = IntegerValueType(3): IntegerValueType(3)) 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt index 588cf460b0b..34c4c67589d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: java.lang.Class<*> = ..., /*1*/ x: kotlin.Int = ..., /*2*/ b: B) 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 @@ -11,6 +12,7 @@ public final annotation class A : kotlin.Annotation { } public final annotation class B : kotlin.Annotation { + public /*synthesized*/ constructor B(/*0*/ arg: java.lang.Class<*> = ..., /*1*/ y: kotlin.Int = ...) 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 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/arg.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/arg.txt index 0c4c47f4a71..f66cc9e7bad 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/arg.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/arg.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: java.lang.Class<*>) 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 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt index 2b96bfe15bd..323b8ab9fd0 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: java.lang.Class<*>, /*1*/ x: kotlin.Int = ...) 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 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt index c09e133d3be..092c1fc2277 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: kotlin.Array>) public constructor A(/*0*/ arg: kotlin.Array>) public abstract fun arg(): kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefault.txt index 19a0e779624..4a681ba16da 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefault.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: java.lang.Class<*> = ...) 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 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt index c729ab764bc..0ff593c333e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg: java.lang.Class<*> = ..., /*1*/ x: kotlin.Int) 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 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/twoArgs.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/twoArgs.txt index f8679f9b717..75a11292dc2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/twoArgs.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/twoArgs.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ arg1: java.lang.Class<*>, /*1*/ arg2: java.lang.Class<*>) 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<*> diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/value.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/value.txt index f31821897cd..2fda874e311 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/value.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/value.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ value: java.lang.Class<*>) 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 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt index 50df2e9a0d8..21fde795054 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ value: java.lang.Class<*>, /*1*/ x: kotlin.Int = ...) 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 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.txt index d4c377b12f1..54e7a5a501b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ vararg value: java.lang.Class<*> /*kotlin.Array>*/) public constructor A(/*0*/ vararg value: kotlin.reflect.KClass<*> /*kotlin.Array>*/) public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefault.txt index 8368c972861..5e32d275cd1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefault.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ value: java.lang.Class<*> = ...) 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 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt index 1718b115441..5f7e722e999 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt @@ -1,6 +1,7 @@ package public final annotation class A : kotlin.Annotation { + public /*synthesized*/ constructor A(/*0*/ value: java.lang.Class<*> = ..., /*1*/ x: kotlin.Int) 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 diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt index 67b645f4baf..26d36ac184a 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt @@ -4,6 +4,7 @@ public open class ClassObjectArrayInParam { public constructor ClassObjectArrayInParam() public final annotation class Anno : kotlin.Annotation { + public /*synthesized*/ constructor Anno(/*0*/ vararg value: java.lang.Class<*> /*kotlin.Array>*/) public constructor Anno(/*0*/ vararg value: kotlin.reflect.KClass<*> /*kotlin.Array>*/) public abstract fun value(): kotlin.Array> } diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParam.txt index 02e15614f31..eadc5c00746 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParam.txt @@ -4,6 +4,7 @@ public open class ClassObjectInParam { public constructor ClassObjectInParam() public final annotation class Anno : kotlin.Annotation { + public /*synthesized*/ constructor Anno(/*0*/ value: java.lang.Class<*>) public constructor Anno(/*0*/ value: kotlin.reflect.KClass<*>) public abstract fun value(): kotlin.reflect.KClass<*> } diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt index c1f3277e54b..1513f4e0e34 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt @@ -4,6 +4,7 @@ public open class ClassObjectInParamRaw { public constructor ClassObjectInParamRaw() public final annotation class Anno : kotlin.Annotation { + public /*synthesized*/ constructor Anno(/*0*/ value: java.lang.Class<*>, /*1*/ arg: kotlin.Array>) public constructor Anno(/*0*/ value: kotlin.reflect.KClass<*>, /*1*/ arg: kotlin.Array>) public abstract fun arg(): kotlin.Array> public abstract fun value(): kotlin.reflect.KClass<*> diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt index d0e7cc2870d..c019d14a8ea 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt @@ -4,6 +4,7 @@ public open class ClassObjectInParamVariance { public constructor ClassObjectInParamVariance() public final annotation class Anno : kotlin.Annotation { + public /*synthesized*/ constructor Anno(/*0*/ arg1: java.lang.Class, /*1*/ arg2: java.lang.Class, /*2*/ arg3: kotlin.Array>, /*3*/ arg4: kotlin.Array>, /*4*/ arg5: kotlin.Array!>>, /*5*/ arg6: kotlin.Array!>>, /*6*/ arg7: kotlin.Array!>>, /*7*/ arg8: kotlin.Array!>>) public constructor Anno(/*0*/ arg1: kotlin.reflect.KClass, /*1*/ arg2: kotlin.reflect.KClass, /*2*/ arg3: kotlin.Array>, /*3*/ arg4: kotlin.Array>, /*4*/ arg5: kotlin.Array!>>, /*5*/ arg6: kotlin.Array!>>, /*6*/ arg7: kotlin.Array!>>, /*7*/ arg8: kotlin.Array!>>) public abstract fun arg1(): kotlin.reflect.KClass public abstract fun arg2(): kotlin.reflect.KClass diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java index 33a03194f79..909247fed02 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -175,6 +175,87 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic } } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AnnotationsWithJavaLangClassParameterOverload extends AbstractJetDiagnosticsTestWithStdLib { + public void testAllFilesPresentInAnnotationsWithJavaLangClassParameterOverload() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("annotationAsArgument.kt") + public void testAnnotationAsArgument() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/annotationAsArgument.kt"); + doTest(fileName); + } + + @TestMetadata("arg.kt") + public void testArg() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/arg.kt"); + doTest(fileName); + } + + @TestMetadata("argAndOtherDefault.kt") + public void testArgAndOtherDefault() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argAndOtherDefault.kt"); + doTest(fileName); + } + + @TestMetadata("argArray.kt") + public void testArgArray() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argArray.kt"); + doTest(fileName); + } + + @TestMetadata("argWithDefault.kt") + public void testArgWithDefault() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefault.kt"); + doTest(fileName); + } + + @TestMetadata("argWithDefaultAndOther.kt") + public void testArgWithDefaultAndOther() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/argWithDefaultAndOther.kt"); + doTest(fileName); + } + + @TestMetadata("twoArgs.kt") + public void testTwoArgs() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/twoArgs.kt"); + doTest(fileName); + } + + @TestMetadata("value.kt") + public void testValue() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/value.kt"); + doTest(fileName); + } + + @TestMetadata("valueAndOtherDefault.kt") + public void testValueAndOtherDefault() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueAndOtherDefault.kt"); + doTest(fileName); + } + + @TestMetadata("valueArray.kt") + public void testValueArray() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueArray.kt"); + doTest(fileName); + } + + @TestMetadata("valueWithDefault.kt") + public void testValueWithDefault() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefault.kt"); + doTest(fileName); + } + + @TestMetadata("valueWithDefaultAndOther.kt") + public void testValueWithDefaultAndOther() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationsWithJavaLangClassParameterOverload/valueWithDefaultAndOther.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/DescriptorResolverUtils.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/DescriptorResolverUtils.java index 6ccdb43e4b8..f253d550d28 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/DescriptorResolverUtils.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/DescriptorResolverUtils.java @@ -78,7 +78,6 @@ public final class DescriptorResolverUtils { @Nullable public static ValueParameterDescriptor getAnnotationParameterByName(@NotNull Name name, @NotNull ClassDescriptor annotationClass) { Collection constructors = annotationClass.getConstructors(); - assert constructors.size() == 1 : "Annotation class descriptor must have only one constructor"; for (ValueParameterDescriptor parameter : constructors.iterator().next().getValueParameters()) { if (parameter.getName().equals(name)) { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java index 562e767dff2..c01054e521a 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java @@ -18,10 +18,7 @@ package org.jetbrains.kotlin.load.java.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.descriptors.ClassDescriptor; -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; -import org.jetbrains.kotlin.descriptors.FunctionDescriptor; -import org.jetbrains.kotlin.descriptors.SourceElement; +import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl; @@ -45,9 +42,10 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme @NotNull ClassDescriptor containingDeclaration, @NotNull Annotations annotations, boolean isPrimary, - @NotNull SourceElement source + @NotNull SourceElement source, + Kind kind ) { - return new JavaConstructorDescriptor(containingDeclaration, null, annotations, isPrimary, Kind.DECLARATION, source); + return new JavaConstructorDescriptor(containingDeclaration, null, annotations, isPrimary, kind, source); } @Override diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index 8c83f0632d0..f36da856e4e 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors +import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.load.java.structure.* @@ -62,7 +63,7 @@ public class LazyJavaClassMemberScope( result.add(descriptor) result.addIfNotNull(c.samConversionResolver.resolveSamAdapter(descriptor)) } - result ifEmpty { emptyOrSingletonList(createDefaultConstructor()) } + result ifEmpty { createDefaultConstructors() } } override fun computeNonDeclaredFunctions(result: MutableCollection, name: Name) { @@ -108,7 +109,8 @@ public class LazyJavaClassMemberScope( val classDescriptor = getContainingDeclaration() val constructorDescriptor = JavaConstructorDescriptor.createJavaConstructor( - classDescriptor, c.resolveAnnotations(constructor), /* isPrimary = */ false, c.sourceElementFactory.source(constructor) + classDescriptor, c.resolveAnnotations(constructor), false, c.sourceElementFactory.source(constructor), + CallableMemberDescriptor.Kind.DECLARATION ) val valueParameters = resolveValueParameters(c, constructorDescriptor, constructor.getValueParameters()) @@ -135,24 +137,45 @@ public class LazyJavaClassMemberScope( return constructorDescriptor } - private fun createDefaultConstructor(): ConstructorDescriptor? { - val isAnnotation: Boolean = jClass.isAnnotationType() + private fun createDefaultConstructors(): List { + val isAnnotation = jClass.isAnnotationType() if (jClass.isInterface() && !isAnnotation) - return null + return emptyList() + + val defaultConstructor = createDefaultConstructor(true) + + val additionalConstructor = + if (isAnnotation && defaultConstructor.getValueParameters().any { it.getType().isKClassOrArray() }) + createDefaultConstructor(false) + else null + + return listOf(defaultConstructor) + additionalConstructor.singletonOrEmptyList() + } + + private fun JetType.isKClassOrArray() = isKClass() || (KotlinBuiltIns.isArray(this) && getArguments().first().getType().isKClass()) + private fun JetType.isKClass() = + (getConstructor().getDeclarationDescriptor() as? ClassDescriptor)?.let { KotlinBuiltIns.isKClass(it) } ?: false + + private fun createDefaultConstructor(isPrimary: Boolean): JavaConstructorDescriptor { + val isAnnotation = jClass.isAnnotationType() val classDescriptor = getContainingDeclaration() val constructorDescriptor = JavaConstructorDescriptor.createJavaConstructor( - classDescriptor, Annotations.EMPTY, /* isPrimary = */ true, c.sourceElementFactory.source(jClass) + classDescriptor, Annotations.EMPTY, isPrimary, c.sourceElementFactory.source(jClass), + if (isPrimary) CallableMemberDescriptor.Kind.DECLARATION else CallableMemberDescriptor.Kind.SYNTHESIZED ) val typeParameters = classDescriptor.getTypeConstructor().getParameters() - val valueParameters = if (isAnnotation) createAnnotationConstructorParameters(constructorDescriptor) + val valueParameters = if (isAnnotation) createAnnotationConstructorParameters(constructorDescriptor, isPrimary) else Collections.emptyList() + constructorDescriptor.setHasSynthesizedParameterNames(false) constructorDescriptor.initialize(typeParameters, valueParameters, getConstructorVisibility(classDescriptor)) constructorDescriptor.setHasStableParameterNames(true) constructorDescriptor.setReturnType(classDescriptor.getDefaultType()) - c.javaResolverCache.recordConstructor(jClass, constructorDescriptor); + if (isPrimary) { + c.javaResolverCache.recordConstructor(jClass, constructorDescriptor) + } return constructorDescriptor } @@ -164,11 +187,15 @@ public class LazyJavaClassMemberScope( return visibility } - private fun createAnnotationConstructorParameters(constructor: ConstructorDescriptorImpl): List { + private fun createAnnotationConstructorParameters( + constructor: ConstructorDescriptorImpl, + loadJavaClassAsKClass: Boolean + ): List { val methods = jClass.getMethods() val result = ArrayList(methods.size()) - val attr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes(allowFlexible = false, isForAnnotationParameter = true) + val attr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes( + allowFlexible = false, isForAnnotationParameter = loadJavaClassAsKClass) val (methodsNamedValue, otherMethods) = methods. partition { it.getName() == JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME }