diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt index 2460151ecdd..253e94cc909 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt @@ -1,8 +1,8 @@ package public final annotation class A : kotlin.Annotation { - public /*synthesized*/ constructor A(/*0*/ arg: kotlin.Array>) - public constructor A(/*0*/ arg: kotlin.Array>) + public /*synthesized*/ constructor A(/*0*/ arg: kotlin.Array>) + public constructor A(/*0*/ arg: kotlin.Array>) public final val arg: kotlin.Array> public abstract fun arg(): kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -10,7 +10,7 @@ public final annotation class A : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -A(arg = {kotlin.String::class, kotlin.Int::class}: kotlin.Array>>) internal final class MyClass { +A(arg = {kotlin.String::class, kotlin.Int::class}: kotlin.Array>) 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 diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt index a11d8e9bd45..c2b5b35bb52 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt @@ -4,15 +4,15 @@ 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 /*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 final val arg: kotlin.Array> public final val value: kotlin.reflect.KClass<*> public abstract fun arg(): kotlin.Array> public abstract fun value(): kotlin.reflect.KClass<*> } - test.ClassObjectInParamRaw.Anno(arg = {}: kotlin.Array>, value = javaClass(): java.lang.Class) public open class Nested { + test.ClassObjectInParamRaw.Anno(arg = {}: kotlin.Array>, value = javaClass(): java.lang.Class) public open class Nested { public constructor Nested() } } diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt index f737c1c142d..4141de66107 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt @@ -4,8 +4,8 @@ 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 /*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 final val arg1: kotlin.reflect.KClass public final val arg2: kotlin.reflect.KClass public final val arg3: kotlin.Array> diff --git a/compiler/testData/loadJava/sourceJava/NullInAnnotation.txt b/compiler/testData/loadJava/sourceJava/NullInAnnotation.txt index 9469d92c46e..f5f7b0b5c58 100644 --- a/compiler/testData/loadJava/sourceJava/NullInAnnotation.txt +++ b/compiler/testData/loadJava/sourceJava/NullInAnnotation.txt @@ -3,10 +3,10 @@ package test public /*synthesized*/ fun NullInAnnotation(/*0*/ function: () -> kotlin.Unit): test.NullInAnnotation public interface NullInAnnotation { - test.NullInAnnotation.Ann(a = null: kotlin.Nothing?, b = {null}: kotlin.Array) public abstract fun foo(): kotlin.Unit + test.NullInAnnotation.Ann(a = null: kotlin.Nothing?, b = {null}: kotlin.Array) public abstract fun foo(): kotlin.Unit public final annotation class Ann : kotlin.Annotation { - public constructor Ann(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Array) + public constructor Ann(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Array) public final val a: kotlin.String public final val b: kotlin.Array public abstract fun a(): kotlin.String 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 9b89af61079..ea21245b373 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 @@ -225,16 +225,7 @@ public class LazyJavaClassMemberScope( val methods = jClass.getMethods() val result = ArrayList(methods.size()) - // Using MEMBER_SIGNATURE_CONTRAVARIANT is just a hack to make overload resolution work in cases like - // Ann(arg = array(javaClass())) class Annotated - // - // If we load constructor parameters' types as invariant: Ann(arg: Array>), Ann(arg: Array>), then - // when resolving `Ann(arg = array(javaClass()))` type of array is inferred as Array> - // which is neither subtype of Array> nor Array> (similar case is KT-7410) - // - // Hack should be removed if support of Class<*> in annotations is dropped or KT-7410 is fixed - // Also see tests `AnnotationsWithClassParameterOverload` - val attr = TypeUsage.MEMBER_SIGNATURE_CONTRAVARIANT.toAttributes( + val attr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes( allowFlexible = false, isForAnnotationParameter = loadJavaClassAsKClass) val (methodsNamedValue, otherMethods) = methods.