diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java index 1f07dfb8019..222ef60b491 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java @@ -257,13 +257,7 @@ public class AnnotationResolver { } }); - JetType arrayType = KotlinBuiltIns.getInstance().getPrimitiveArrayJetTypeByPrimitiveJetType(varargElementType); - if (arrayType == null) { - arrayType = KotlinBuiltIns.getInstance().getArrayType(OUT_VARIANCE, varargElementType); - } - - //todo use parameterDescriptor.getType() instead of arrayType - return new ArrayValue(constants, arrayType, true, usesVariableAsConstant); + return new ArrayValue(constants, parameterDescriptor.getType(), true, usesVariableAsConstant); } else { // we should actually get only one element, but just in case of getting many, we take the last one diff --git a/compiler/testData/diagnostics/tests/MergePackagesWithJava.txt b/compiler/testData/diagnostics/tests/MergePackagesWithJava.txt index 926bb2fb3bb..ef2b964e734 100644 --- a/compiler/testData/diagnostics/tests/MergePackagesWithJava.txt +++ b/compiler/testData/diagnostics/tests/MergePackagesWithJava.txt @@ -7381,7 +7381,7 @@ package java { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE, ElementType.PARAMETER, ElementType.TYPE}: kotlin.Array) public final annotation class Deprecated : kotlin.Annotation { + java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE, ElementType.PARAMETER, ElementType.TYPE}: kotlin.Array) public final annotation class Deprecated : kotlin.Annotation { public constructor Deprecated() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -7870,7 +7870,7 @@ package java { private open fun registerNatives(): kotlin.Unit } - java.lang.annotation.Target(value = {ElementType.METHOD}: kotlin.Array) java.lang.annotation.Retention(value = RetentionPolicy.SOURCE: java.lang.annotation.RetentionPolicy) public final annotation class Override : kotlin.Annotation { + java.lang.annotation.Target(value = {ElementType.METHOD}: kotlin.Array) java.lang.annotation.Retention(value = RetentionPolicy.SOURCE: java.lang.annotation.RetentionPolicy) public final annotation class Override : kotlin.Annotation { public constructor Override() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -8202,8 +8202,8 @@ package java { public/*package*/ final val serialVersionUID: kotlin.Long = 4383685877147921099.toLong() } - java.lang.annotation.Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE}: kotlin.Array) java.lang.annotation.Retention(value = RetentionPolicy.SOURCE: java.lang.annotation.RetentionPolicy) public final annotation class SuppressWarnings : kotlin.Annotation { - public constructor SuppressWarnings(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) + java.lang.annotation.Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE}: kotlin.Array) java.lang.annotation.Retention(value = RetentionPolicy.SOURCE: java.lang.annotation.RetentionPolicy) public final annotation class SuppressWarnings : kotlin.Annotation { + public constructor SuppressWarnings(/*0*/ vararg value: kotlin.String /*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 @@ -8747,7 +8747,7 @@ package java { private final val serialVersionUID: kotlin.Long = 8125925355765570191.toLong() } - java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Documented : kotlin.Annotation { + java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Documented : kotlin.Annotation { public constructor Documented() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -8945,14 +8945,14 @@ package java { private final val serialVersionUID: kotlin.Long = 8445097402741811912.toLong() } - java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Inherited : kotlin.Annotation { + java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Inherited : kotlin.Annotation { public constructor Inherited() 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 } - java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Retention : kotlin.Annotation { + java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Retention : kotlin.Annotation { public constructor Retention(/*0*/ value: java.lang.annotation.RetentionPolicy) public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -9034,8 +9034,8 @@ package java { public final /*synthesized*/ fun values(): kotlin.Array } - java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Target : kotlin.Annotation { - public constructor Target(/*0*/ vararg value: java.lang.annotation.ElementType /*kotlin.Array*/) + java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Target : kotlin.Annotation { + public constructor Target(/*0*/ vararg value: java.lang.annotation.ElementType /*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 diff --git a/compiler/testData/diagnostics/tests/scopes/kt955.txt b/compiler/testData/diagnostics/tests/scopes/kt955.txt index 8a760c2ef3a..fa1c044a498 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt955.txt +++ b/compiler/testData/diagnostics/tests/scopes/kt955.txt @@ -7386,7 +7386,7 @@ package java { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE, ElementType.PARAMETER, ElementType.TYPE}: kotlin.Array) public final annotation class Deprecated : kotlin.Annotation { + java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.METHOD, ElementType.PACKAGE, ElementType.PARAMETER, ElementType.TYPE}: kotlin.Array) public final annotation class Deprecated : kotlin.Annotation { public constructor Deprecated() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -7875,7 +7875,7 @@ package java { private open fun registerNatives(): kotlin.Unit } - java.lang.annotation.Target(value = {ElementType.METHOD}: kotlin.Array) java.lang.annotation.Retention(value = RetentionPolicy.SOURCE: java.lang.annotation.RetentionPolicy) public final annotation class Override : kotlin.Annotation { + java.lang.annotation.Target(value = {ElementType.METHOD}: kotlin.Array) java.lang.annotation.Retention(value = RetentionPolicy.SOURCE: java.lang.annotation.RetentionPolicy) public final annotation class Override : kotlin.Annotation { public constructor Override() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -8207,8 +8207,8 @@ package java { public/*package*/ final val serialVersionUID: kotlin.Long = 4383685877147921099.toLong() } - java.lang.annotation.Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE}: kotlin.Array) java.lang.annotation.Retention(value = RetentionPolicy.SOURCE: java.lang.annotation.RetentionPolicy) public final annotation class SuppressWarnings : kotlin.Annotation { - public constructor SuppressWarnings(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) + java.lang.annotation.Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE}: kotlin.Array) java.lang.annotation.Retention(value = RetentionPolicy.SOURCE: java.lang.annotation.RetentionPolicy) public final annotation class SuppressWarnings : kotlin.Annotation { + public constructor SuppressWarnings(/*0*/ vararg value: kotlin.String /*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 @@ -8752,7 +8752,7 @@ package java { private final val serialVersionUID: kotlin.Long = 8125925355765570191.toLong() } - java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Documented : kotlin.Annotation { + java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Documented : kotlin.Annotation { public constructor Documented() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -8950,14 +8950,14 @@ package java { private final val serialVersionUID: kotlin.Long = 8445097402741811912.toLong() } - java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Inherited : kotlin.Annotation { + java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Inherited : kotlin.Annotation { public constructor Inherited() 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 } - java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Retention : kotlin.Annotation { + java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Retention : kotlin.Annotation { public constructor Retention(/*0*/ value: java.lang.annotation.RetentionPolicy) public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -9039,8 +9039,8 @@ package java { public final /*synthesized*/ fun values(): kotlin.Array } - java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Target : kotlin.Annotation { - public constructor Target(/*0*/ vararg value: java.lang.annotation.ElementType /*kotlin.Array*/) + java.lang.annotation.Documented() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME: java.lang.annotation.RetentionPolicy) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}: kotlin.Array) public final annotation class Target : kotlin.Annotation { + public constructor Target(/*0*/ vararg value: java.lang.annotation.ElementType /*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 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt new file mode 100644 index 00000000000..3aaf83cbcde --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt @@ -0,0 +1,9 @@ +// FILE: A.java +public @interface A { + String[] arg(); +} + +// FILE: b.kt +[A(*; IGNORE)!>array(1, "b"))] +fun test() { +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.txt new file mode 100644 index 00000000000..81688ec81d9 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.txt @@ -0,0 +1,11 @@ +package + +A(arg = {IntegerValueType(1), "b"}: kotlin.Array) internal fun test(): kotlin.Unit + +public final annotation class A : kotlin.Annotation { + public constructor A(/*0*/ vararg arg: kotlin.String /*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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt new file mode 100644 index 00000000000..a72671f5871 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt @@ -0,0 +1,5 @@ +annotation class B(vararg val args: String) + +[B(*; IGNORE)!>array(1, "b"))] +fun test() { +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt new file mode 100644 index 00000000000..b722ae02e81 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt @@ -0,0 +1,11 @@ +package + +B(args = {IntegerValueType(1), "b"}: kotlin.Array) internal fun test(): kotlin.Unit + +internal final annotation class B : kotlin.Annotation { + public constructor B(/*0*/ vararg args: kotlin.String /*kotlin.Array*/) + internal final val args: 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 +} diff --git a/compiler/testData/loadJava/compiledJava/annotations/AnnotationInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/AnnotationInParam.txt index 0253de3ed0a..675d1c89a4f 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/AnnotationInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotationInParam.txt @@ -6,7 +6,7 @@ public trait AnnotationInParam { public constructor A() } - test.AnnotationInParam.MyAnnotationWithParam2(value = test.AnnotationInParam.MyAnnotation2(value = {"test", "test2"}: kotlin.Array): test.AnnotationInParam.MyAnnotation2) public open class B { + test.AnnotationInParam.MyAnnotationWithParam2(value = test.AnnotationInParam.MyAnnotation2(value = {"test", "test2"}: kotlin.Array): test.AnnotationInParam.MyAnnotation2) public open class B { public constructor B() } @@ -20,7 +20,7 @@ public trait AnnotationInParam { } public final annotation class MyAnnotation2 : kotlin.Annotation { - public constructor MyAnnotation2(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) + public constructor MyAnnotation2(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) public abstract fun value(): kotlin.Array } diff --git a/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt index ec04c206e72..5b9b8c48b1b 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt @@ -2,7 +2,7 @@ package test public trait ArrayOfEnumInParam { - java.lang.annotation.Target(value = {ElementType.FIELD, ElementType.CONSTRUCTOR}: kotlin.Array) public final annotation class targetAnnotation : kotlin.Annotation { + java.lang.annotation.Target(value = {ElementType.FIELD, ElementType.CONSTRUCTOR}: kotlin.Array) public final annotation class targetAnnotation : kotlin.Annotation { public constructor targetAnnotation(/*0*/ value: kotlin.String) public abstract fun value(): kotlin.String } diff --git a/compiler/testData/loadJava/compiledJava/annotations/ArrayOfStringInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/ArrayOfStringInParam.txt index ad7b5fdd9a2..6bf5cc4d3bc 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ArrayOfStringInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ArrayOfStringInParam.txt @@ -2,12 +2,12 @@ package test public trait ArrayOfStringInParam { - test.ArrayOfStringInParam.MyAnnotation(value = {"a", "b", "c"}: kotlin.Array) public open class A { + test.ArrayOfStringInParam.MyAnnotation(value = {"a", "b", "c"}: kotlin.Array) public open class A { public constructor A() } public final annotation class MyAnnotation : kotlin.Annotation { - public constructor MyAnnotation(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) + public constructor MyAnnotation(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) public abstract fun value(): kotlin.Array } } diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt index 9a0413b006e..36c0ff70063 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt @@ -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>*/) + public constructor Anno(/*0*/ vararg value: java.lang.Class /*kotlin.Array>*/) public abstract fun value(): kotlin.Array> } - test.ClassObjectArrayInParam.Anno(value = {test.ClassObjectArrayInParam.class, test.ClassObjectArrayInParam.Nested.class, kotlin.String.class}: kotlin.Array>) public open class Nested { + test.ClassObjectArrayInParam.Anno(value = {test.ClassObjectArrayInParam.class, test.ClassObjectArrayInParam.Nested.class, kotlin.String.class}: kotlin.Array>) public open class Nested { public constructor Nested() } } diff --git a/compiler/testData/loadJava/compiledJava/annotations/EmptyArrayInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/EmptyArrayInParam.txt index 8bd2efdce70..1091f4fc281 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/EmptyArrayInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/EmptyArrayInParam.txt @@ -2,12 +2,12 @@ package test public trait EmptyArrayInParam { - test.EmptyArrayInParam.MyAnnotation(value = {}: kotlin.Array) public open class A { + test.EmptyArrayInParam.MyAnnotation(value = {}: kotlin.Array) public open class A { public constructor A() } public final annotation class MyAnnotation : kotlin.Annotation { - public constructor MyAnnotation(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) + public constructor MyAnnotation(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) public abstract fun value(): kotlin.Array } } diff --git a/compiler/testData/loadJava/sourceJava/NullInAnnotation.txt b/compiler/testData/loadJava/sourceJava/NullInAnnotation.txt index 9d177b01e3c..1edda0d3929 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 trait 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*/ vararg b: kotlin.String /*kotlin.Array*/) + public constructor Ann(/*0*/ a: kotlin.String, /*1*/ vararg b: kotlin.String /*kotlin.Array*/) public abstract fun a(): kotlin.String public abstract fun b(): kotlin.Array } diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java index 9019ce00c2a..f6474de63c5 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -39,7 +39,7 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations") @TestDataPath("$PROJECT_ROOT") - @InnerTestClasses({Annotations.AnnotationApplicability.class, Annotations.AnnotationParameterMustBeConstant.class, Annotations.PlatformStatic.class}) + @InnerTestClasses({Annotations.AnnotationApplicability.class, Annotations.AnnotationParameterMustBeConstant.class, Annotations.AnnotationWithVarargParameter.class, Annotations.PlatformStatic.class}) @RunWith(JUnit3RunnerWithInners.class) public static class Annotations extends AbstractJetDiagnosticsTestWithStdLib { public void testAllFilesPresentInAnnotations() throws Exception { @@ -112,6 +112,27 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic } } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class AnnotationWithVarargParameter extends AbstractJetDiagnosticsTestWithStdLib { + public void testAllFilesPresentInAnnotationWithVarargParameter() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("javaAnnotationWithVarargArgument.kt") + public void testJavaAnnotationWithVarargArgument() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt"); + doTest(fileName); + } + + @TestMetadata("kotlinAnnotationWithVarargArgument.kt") + public void testKotlinAnnotationWithVarargArgument() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/platformStatic") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassMemberScope.kt index 10384c7a573..cc7266c3508 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -171,16 +171,13 @@ public class LazyJavaClassMemberScope( val jReturnType = method.getReturnType() ?: throw AssertionError("Annotation method has no return type: " + method) val attr = TypeUsage.MEMBER_SIGNATURE_INVARIANT.toAttributes(allowFlexible = false) - val varargElementType = - if (index == methods.size() - 1 && jReturnType is JavaArrayType) { - c.typeResolver.transformJavaType( - jReturnType.getComponentType(), - attr - ) - } - else null - val returnType = c.typeResolver.transformJavaType(jReturnType, attr) + val (returnType, varargElementType) = + if (index == methods.size() - 1 && jReturnType is JavaArrayType) + Pair(c.typeResolver.transformArrayType(jReturnType, attr, isVararg = true), + c.typeResolver.transformJavaType(jReturnType.getComponentType(), attr)) + else + Pair(c.typeResolver.transformJavaType(jReturnType, attr), null) result.add(ValueParameterDescriptorImpl( constructor,