From a89329e07757d85f62f66f45c6141ab1e120d971 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Tue, 1 Dec 2020 18:21:44 +0300 Subject: [PATCH] Support reading from class files of the type use annotations on type parameters and type arguments ^KT-11454 Fixed --- .../structure/impl/classFiles/Annotations.kt | 128 +++++++++++----- .../classFiles/BinaryClassSignatureParser.kt | 15 +- .../impl/classFiles/BinaryJavaClass.kt | 52 ++++++- .../impl/classFiles/BinaryJavaClass.kt.201 | 57 ++++--- .../java/structure/impl/classFiles/Methods.kt | 126 ++++++++-------- .../java/structure/impl/classFiles/Other.kt | 36 +++-- .../java/structure/impl/classFiles/Types.kt | 35 ++--- .../TypeParameterAnnotations.javac.txt | 14 -- .../TypeParameterAnnotations.runtime.txt | 14 -- .../Basic.java} | 12 +- .../typeParameterAnnotations/Basic.javac.txt | 14 ++ .../Basic.runtime.txt | 14 ++ .../typeParameterAnnotations/Basic.txt | 19 +++ .../BaseClassTypeArguments.java | 26 ++++ .../BaseClassTypeArguments.txt | 39 +++++ .../typeUseAnnotations/Basic.java} | 2 +- .../typeUseAnnotations/Basic.txt} | 8 +- .../ClassTypeParameterBounds.java | 33 +++++ .../ClassTypeParameterBounds.txt | 61 ++++++++ .../typeUseAnnotations/MethodReceiver.java | 23 +++ .../typeUseAnnotations/MethodReceiver.txt | 16 ++ .../MethodTypeParameterBounds.java | 33 +++++ .../MethodTypeParameterBounds.txt | 37 +++++ .../typeUseAnnotations/ReturnType.java | 95 ++++++++++++ .../typeUseAnnotations/ReturnType.txt | 88 +++++++++++ .../typeUseAnnotations/ValueArguments.java | 117 +++++++++++++++ .../typeUseAnnotations/ValueArguments.txt | 99 +++++++++++++ .../typeParameterAnnotations/Basic.java | 22 +++ .../typeParameterAnnotations/Basic.javac.txt} | 8 +- .../Basic.runtime.txt | 14 ++ .../typeParameterAnnotations/Basic.txt | 19 +++ .../BaseClassTypeArguments.java | 26 ++++ .../BaseClassTypeArguments.txt | 17 +++ .../typeUseAnnotations/Basic.java} | 4 +- .../typeUseAnnotations/Basic.txt} | 8 +- .../ClassTypeParameterBounds.java | 33 +++++ .../ClassTypeParameterBounds.txt | 56 +++++++ .../typeUseAnnotations/MethodReceiver.java | 23 +++ .../typeUseAnnotations/MethodReceiver.txt | 11 ++ .../MethodTypeParameterBounds.java | 33 +++++ .../MethodTypeParameterBounds.txt | 32 ++++ .../typeUseAnnotations/ReturnType.java | 95 ++++++++++++ .../typeUseAnnotations/ReturnType.txt | 74 ++++++++++ .../typeUseAnnotations/ValueArguments.java | 117 +++++++++++++++ .../typeUseAnnotations/ValueArguments.txt | 85 +++++++++++ .../jvm/compiler/LoadJava8TestGenerated.java | 139 ++++++++++++++++-- ...Java8WithPsiClassReadingTestGenerated.java | 68 ++++++++- .../LoadJava8UsingJavacTestGenerated.java | 139 ++++++++++++++++-- .../load/java/structure/javaElements.kt | 16 +- .../kotlin/load/java/structure/javaTypes.kt | 4 +- .../runtime/structure/ReflectJavaArrayType.kt | 5 + .../structure/ReflectJavaPrimitiveType.kt | 5 + .../structure/ReflectJavaWildcardType.kt | 5 + ...8RuntimeDescriptorLoaderTestGenerated.java | 68 ++++++++- 54 files changed, 2077 insertions(+), 262 deletions(-) delete mode 100644 compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.javac.txt delete mode 100644 compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.runtime.txt rename compiler/testData/loadJava8/compiledJava/{TypeParameterAnnotations.java => typeParameterAnnotations/Basic.java} (52%) create mode 100644 compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.javac.txt create mode 100644 compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.runtime.txt create mode 100644 compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.txt create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.java create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.txt rename compiler/testData/loadJava8/{sourceJava/TypeAnnotations.java => compiledJava/typeUseAnnotations/Basic.java} (91%) rename compiler/testData/loadJava8/{sourceJava/TypeAnnotations.txt => compiledJava/typeUseAnnotations/Basic.txt} (57%) create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.java create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.txt create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.java create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.txt create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.java create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.txt create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.java create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.txt create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.java create mode 100644 compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.txt create mode 100644 compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.java rename compiler/testData/loadJava8/{compiledJava/TypeParameterAnnotations.txt => sourceJava/typeParameterAnnotations/Basic.javac.txt} (54%) create mode 100644 compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.runtime.txt create mode 100644 compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.txt create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/BaseClassTypeArguments.java create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/BaseClassTypeArguments.txt rename compiler/testData/loadJava8/{compiledJava/TypeAnnotations.java => sourceJava/typeUseAnnotations/Basic.java} (59%) rename compiler/testData/loadJava8/{compiledJava/TypeAnnotations.txt => sourceJava/typeUseAnnotations/Basic.txt} (62%) create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ClassTypeParameterBounds.java create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ClassTypeParameterBounds.txt create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodReceiver.java create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodReceiver.txt create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.java create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.txt create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ReturnType.java create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ReturnType.txt create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ValueArguments.java create mode 100644 compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ValueArguments.txt diff --git a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Annotations.kt b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Annotations.kt index b4f33417d63..2cae0ecc160 100644 --- a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Annotations.kt +++ b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Annotations.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.load.java.structure.impl.classFiles import org.jetbrains.kotlin.load.java.structure.* +import org.jetbrains.kotlin.load.java.structure.impl.classFiles.BinaryJavaAnnotation.Companion.computeTargetType import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -56,10 +57,7 @@ internal class AnnotationsAndParameterCollectorMethodVisitor( } override fun visitAnnotation(desc: String, visible: Boolean) = - BinaryJavaAnnotation.addAnnotation( - member.annotations as MutableCollection, - desc, context, signatureParser - ) + BinaryJavaAnnotation.addAnnotation(member, desc, context, signatureParser) @Suppress("NOTHING_TO_OVERRIDE") override fun visitAnnotableParameterCount(parameterCount: Int, visible: Boolean) { @@ -76,33 +74,38 @@ internal class AnnotationsAndParameterCollectorMethodVisitor( val index = absoluteParameterIndex - parametersToSkipNumber if (index < 0) return null - val annotations = - member.valueParameters[index].annotations as MutableCollection? - ?: return null - - return BinaryJavaAnnotation.addAnnotation(annotations, desc, context, signatureParser) + return BinaryJavaAnnotation.addAnnotation(member.valueParameters[index], desc, context, signatureParser) } override fun visitTypeAnnotation(typeRef: Int, typePath: TypePath?, desc: String, visible: Boolean): AnnotationVisitor? { - // TODO: support annotations on type arguments - if (typePath != null) return null - val typeReference = TypeReference(typeRef) - return when (typeReference.sort) { - TypeReference.METHOD_RETURN -> member.safeAs()?.returnType?.let { - BinaryJavaAnnotation.addTypeAnnotation(it, desc, context, signatureParser) - } + if (typePath != null) { + val baseType = when (typeReference.sort) { + TypeReference.METHOD_RETURN -> member.safeAs()?.returnType + TypeReference.METHOD_FORMAL_PARAMETER -> member.valueParameters[typeReference.formalParameterIndex].type + TypeReference.METHOD_TYPE_PARAMETER_BOUND -> + BinaryJavaAnnotation.computeTypeParameterBound(member.typeParameters, typeReference) + else -> null + } ?: return null - TypeReference.METHOD_FORMAL_PARAMETER -> - BinaryJavaAnnotation.addTypeAnnotation( - member.valueParameters[typeReference.formalParameterIndex].type, - desc, context, signatureParser - ) - - else -> null + return BinaryJavaAnnotation.addAnnotation( + computeTargetType(baseType, translatePath(typePath)) as JavaPlainType, desc, context, signatureParser + ) } + + val targetType = when (typeReference.sort) { + TypeReference.METHOD_RETURN -> (member as? BinaryJavaMethod)?.returnType as JavaPlainType + TypeReference.METHOD_TYPE_PARAMETER -> member.typeParameters[typeReference.typeParameterIndex] as BinaryJavaTypeParameter + TypeReference.METHOD_FORMAL_PARAMETER -> member.valueParameters[typeReference.formalParameterIndex].type as JavaPlainType + TypeReference.METHOD_TYPE_PARAMETER_BOUND -> BinaryJavaAnnotation.computeTypeParameterBound(member.typeParameters, typeReference) as JavaPlainType + else -> null + } ?: return null + + return BinaryJavaAnnotation.addAnnotation(targetType, desc, context, signatureParser) } + + enum class PathElementType { ARRAY_ELEMENT, WILDCARD_BOUND, ENCLOSING_CLASS, TYPE_ARGUMENT } } class BinaryJavaAnnotation private constructor( @@ -125,29 +128,76 @@ class BinaryJavaAnnotation private constructor( } fun addAnnotation( - annotations: MutableCollection, - desc: String, - context: ClassifierResolutionContext, - signatureParser: BinaryClassSignatureParser + annotationOwner: MutableJavaAnnotationOwner, + desc: String, + context: ClassifierResolutionContext, + signatureParser: BinaryClassSignatureParser ): AnnotationVisitor { val (javaAnnotation, annotationVisitor) = createAnnotationAndVisitor(desc, context, signatureParser) - annotations.add(javaAnnotation) - + annotationOwner.annotations.add(javaAnnotation) return annotationVisitor } - fun addTypeAnnotation( - type: JavaType, - desc: String, - context: ClassifierResolutionContext, - signatureParser: BinaryClassSignatureParser - ): AnnotationVisitor? { - type as? PlainJavaClassifierType ?: return null + internal fun translatePath(path: TypePath): List> { + val length = path.length + val list = mutableListOf>() + for (i in 0 until length) { + when (path.getStep(i)) { + TypePath.INNER_TYPE -> { + continue + } + TypePath.ARRAY_ELEMENT -> { + list.add(AnnotationsAndParameterCollectorMethodVisitor.PathElementType.ARRAY_ELEMENT to null) + } + TypePath.WILDCARD_BOUND -> { + list.add(AnnotationsAndParameterCollectorMethodVisitor.PathElementType.WILDCARD_BOUND to null) + } + TypePath.TYPE_ARGUMENT -> { + list.add(AnnotationsAndParameterCollectorMethodVisitor.PathElementType.TYPE_ARGUMENT to path.getStepArgument(i)) + } + } + } + return list + } - val (javaAnnotation, annotationVisitor) = createAnnotationAndVisitor(desc, context, signatureParser) - type.addAnnotation(javaAnnotation) + internal fun computeTargetType( + baseType: JavaType, + typePath: List> + ): JavaType { + var targetType = baseType - return annotationVisitor + for (element in typePath) { + when (element.first) { + AnnotationsAndParameterCollectorMethodVisitor.PathElementType.TYPE_ARGUMENT -> { + if (targetType is JavaClassifierType) { + targetType = targetType.typeArguments[element.second!!]!! + } + } + AnnotationsAndParameterCollectorMethodVisitor.PathElementType.WILDCARD_BOUND -> { + if (targetType is JavaWildcardType) { + targetType = targetType.bound!! + } + } + AnnotationsAndParameterCollectorMethodVisitor.PathElementType.ARRAY_ELEMENT -> { + if (targetType is JavaArrayType) { + targetType = targetType.componentType + } + } + } + } + + return targetType + } + + internal fun computeTypeParameterBound( + typeParameters: List, + typeReference: TypeReference + ): JavaClassifierType { + val typeParameter = typeParameters[typeReference.typeParameterIndex] as BinaryJavaTypeParameter + val boundIndex = + if (typeParameter.hasImplicitObjectClassBound) typeReference.typeParameterBoundIndex - 1 else typeReference.typeParameterBoundIndex + + return typeParameters[typeReference.typeParameterIndex].upperBounds.toList()[boundIndex] } } diff --git a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryClassSignatureParser.kt b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryClassSignatureParser.kt index 13448788ce3..7fd5be448e6 100644 --- a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryClassSignatureParser.kt +++ b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryClassSignatureParser.kt @@ -66,13 +66,20 @@ class BinaryClassSignatureParser { // postpone list allocation till a second bound is seen; ignore sole Object bound val bounds: MutableList = SmartList() + var hasImplicitObjectBound = false while (signature.current() == ':') { signature.next() - val bound = parseClassifierRefSignature(signature, context) ?: continue - bounds.add(bound) + + // '::' means that the implicit object bound is between ':' + if (signature.current() == ':') { + hasImplicitObjectBound = true + continue + } + + bounds.add(parseClassifierRefSignature(signature, context) ?: continue) } - return BinaryJavaTypeParameter(Name.identifier(parameterName), bounds) + return BinaryJavaTypeParameter(Name.identifier(parameterName), bounds, hasImplicitObjectBound) } fun parseClassifierRefSignature(signature: CharacterIterator, context: ClassifierResolutionContext): JavaClassifierType? { @@ -83,7 +90,7 @@ class BinaryClassSignatureParser { } } - private fun parseTypeVariableRefSignature(signature: CharacterIterator, context: ClassifierResolutionContext): JavaClassifierType? { + private fun parseTypeVariableRefSignature(signature: CharacterIterator, context: ClassifierResolutionContext): JavaClassifierType { val id = StringBuilder() signature.next() diff --git a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt index 3dbf87805b9..06db541e6c2 100644 --- a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt +++ b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt @@ -22,6 +22,7 @@ import gnu.trove.THashMap import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.load.java.structure.* import org.jetbrains.kotlin.load.java.structure.impl.VirtualFileBoundJavaClass +import org.jetbrains.kotlin.load.java.structure.impl.classFiles.BinaryJavaAnnotation.Companion.computeTypeParameterBound import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.SmartList @@ -38,12 +39,12 @@ class BinaryJavaClass( override var access: Int = 0, override val outerClass: JavaClass?, classContent: ByteArray? = null -) : ClassVisitor(ASM_API_VERSION_FOR_CLASS_READING), VirtualFileBoundJavaClass, BinaryJavaModifierListOwner, MapBasedJavaAnnotationOwner { - private lateinit var myInternalName: String - +) : ClassVisitor(ASM_API_VERSION_FOR_CLASS_READING), VirtualFileBoundJavaClass, BinaryJavaModifierListOwner, MutableJavaAnnotationOwner { override val annotations: MutableCollection = SmartList() + override lateinit var typeParameters: List - override lateinit var supertypes: Collection + override lateinit var supertypes: List + override val methods = arrayListOf() override val fields = arrayListOf() override val constructors = arrayListOf() @@ -51,6 +52,12 @@ class BinaryJavaClass( override fun hasDefaultConstructor() = false // never: all constructors explicit in bytecode + private lateinit var myInternalName: String + + // In accordance with JVMS, super class always comes before the interface list + private val superclass: JavaClassifierType? get() = supertypes.firstOrNull() + private val interfaces: List get() = supertypes.drop(1) + override val annotationsByFqName by buildLazyValueForMap() // Short name of a nested class of this class -> access flags as seen in the InnerClasses attribute value. @@ -75,6 +82,37 @@ class BinaryJavaClass( override fun isFromSourceCodeInScope(scope: SearchScope): Boolean = false + override fun visitTypeAnnotation(typeRef: Int, typePath: TypePath?, descriptor: String?, visible: Boolean): AnnotationVisitor? { + val typeReference = TypeReference(typeRef) + if (descriptor == null) + return null + + if (typePath != null) { + val translatedPath = BinaryJavaAnnotation.translatePath(typePath) + + when (typeReference.sort) { + TypeReference.CLASS_TYPE_PARAMETER_BOUND -> { + val baseType = computeTypeParameterBound(typeParameters, typeReference) + val targetType = BinaryJavaAnnotation.computeTargetType(baseType, translatedPath) + + return BinaryJavaAnnotation.addAnnotation(targetType as JavaPlainType, descriptor, context, signatureParser) + } + } + } + + return when (typeReference.sort) { + TypeReference.CLASS_TYPE_PARAMETER -> + BinaryJavaAnnotation.addAnnotation( + typeParameters[typeReference.typeParameterIndex] as BinaryJavaTypeParameter, descriptor, context, signatureParser + ) + TypeReference.CLASS_TYPE_PARAMETER_BOUND -> + BinaryJavaAnnotation.addAnnotation( + computeTypeParameterBound(typeParameters, typeReference) as JavaPlainType, descriptor, context, signatureParser + ) + else -> null + } + } + override fun visitEnd() { methods.trimToSize() fields.trimToSize() @@ -181,11 +219,11 @@ class BinaryJavaClass( object : FieldVisitor(ASM_API_VERSION_FOR_CLASS_READING) { override fun visitAnnotation(desc: String, visible: Boolean) = - BinaryJavaAnnotation.addAnnotation(this@run.annotations, desc, context, signatureParser) + BinaryJavaAnnotation.addAnnotation(this@run, desc, context, signatureParser) override fun visitTypeAnnotation(typeRef: Int, typePath: TypePath?, desc: String, visible: Boolean) = if (typePath == null) - BinaryJavaAnnotation.addTypeAnnotation(type, desc, context, signatureParser) + BinaryJavaAnnotation.addAnnotation(type as JavaPlainType, desc, context, signatureParser) else null } @@ -222,7 +260,7 @@ class BinaryJavaClass( } override fun visitAnnotation(desc: String, visible: Boolean) = - BinaryJavaAnnotation.addAnnotation(annotations, desc, context, signatureParser) + BinaryJavaAnnotation.addAnnotation(this, desc, context, signatureParser) override fun findInnerClass(name: Name): JavaClass? = findInnerClass(name, classFileContent = null) diff --git a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt.201 b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt.201 index 2c38ac263ee..8de96673afb 100644 --- a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt.201 +++ b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/BinaryJavaClass.kt.201 @@ -22,6 +22,7 @@ import gnu.trove.THashMap import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.load.java.structure.* import org.jetbrains.kotlin.load.java.structure.impl.VirtualFileBoundJavaClass +import org.jetbrains.kotlin.load.java.structure.impl.classFiles.BinaryJavaAnnotation.Companion.computeTypeParameterBound import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.SmartList @@ -38,12 +39,12 @@ class BinaryJavaClass( override var access: Int = 0, override val outerClass: JavaClass?, classContent: ByteArray? = null -) : ClassVisitor(ASM_API_VERSION_FOR_CLASS_READING), VirtualFileBoundJavaClass, BinaryJavaModifierListOwner, MapBasedJavaAnnotationOwner { - private lateinit var myInternalName: String - +) : ClassVisitor(ASM_API_VERSION_FOR_CLASS_READING), VirtualFileBoundJavaClass, BinaryJavaModifierListOwner, MutableJavaAnnotationOwner { override val annotations: MutableCollection = SmartList() + override lateinit var typeParameters: List - override lateinit var supertypes: Collection + override lateinit var supertypes: List + override val methods = arrayListOf() override val fields = arrayListOf() override val constructors = arrayListOf() @@ -51,6 +52,12 @@ class BinaryJavaClass( override fun hasDefaultConstructor() = false // never: all constructors explicit in bytecode + private lateinit var myInternalName: String + + // In accordance with JVMS, super class always comes before the interface list + private val superclass: JavaClassifierType? get() = supertypes.firstOrNull() + private val implementedInterfaces: List get() = supertypes.drop(1) + override val annotationsByFqName by buildLazyValueForMap() // Short name of a nested class of this class -> access flags as seen in the InnerClasses attribute value. @@ -69,11 +76,34 @@ class BinaryJavaClass( override val isRecord get() = false override val lightClassOriginKind: LightClassOriginKind? get() = null + override val isSealed: Boolean get() = permittedTypes.isNotEmpty() override val permittedTypes = arrayListOf() override fun isFromSourceCodeInScope(scope: SearchScope): Boolean = false + override fun visitTypeAnnotation(typeRef: Int, typePath: TypePath?, descriptor: String?, visible: Boolean): AnnotationVisitor? { + if (descriptor == null) + return null + + fun getTargetType(baseType: JavaType) = + if (typePath != null) BinaryJavaAnnotation.computeTargetType(baseType, typePath) else baseType + + val typeReference = TypeReference(typeRef) + + val annotationOwner = when (typeReference.sort) { + TypeReference.CLASS_EXTENDS -> + getTargetType(if (typeReference.superTypeIndex == -1) superclass!! else implementedInterfaces[typeReference.superTypeIndex]) + TypeReference.CLASS_TYPE_PARAMETER -> typeParameters[typeReference.typeParameterIndex] + TypeReference.CLASS_TYPE_PARAMETER_BOUND -> getTargetType(computeTypeParameterBound(typeParameters, typeReference)) + else -> return null + } + + if (annotationOwner !is MutableJavaAnnotationOwner) return null + + return BinaryJavaAnnotation.addAnnotation(annotationOwner, descriptor, context, signatureParser, isFreshlySupportedAnnotation = true) + } + override fun visitEnd() { methods.trimToSize() fields.trimToSize() @@ -172,23 +202,12 @@ class BinaryJavaClass( if (access.isSet(Opcodes.ACC_SYNTHETIC)) return null val type = signatureParser.parseTypeString(StringCharacterIterator(signature ?: desc), context) - val processedValue = processValue(value, type) + val filed = BinaryJavaField(Name.identifier(name), access, this, access.isSet(Opcodes.ACC_ENUM), type, processedValue) - return BinaryJavaField(Name.identifier(name), access, this, access.isSet(Opcodes.ACC_ENUM), type, processedValue).run { - fields.add(this) + fields.add(filed) - object : FieldVisitor(ASM_API_VERSION_FOR_CLASS_READING) { - override fun visitAnnotation(desc: String, visible: Boolean) = - BinaryJavaAnnotation.addAnnotation(this@run.annotations, desc, context, signatureParser) - - override fun visitTypeAnnotation(typeRef: Int, typePath: TypePath?, desc: String, visible: Boolean) = - if (typePath == null) - BinaryJavaAnnotation.addTypeAnnotation(type, desc, context, signatureParser) - else - null - } - } + return AnnotationsCollectorFieldVisitor(filed, context, signatureParser) } /** @@ -211,7 +230,7 @@ class BinaryJavaClass( } override fun visitAnnotation(desc: String, visible: Boolean) = - BinaryJavaAnnotation.addAnnotation(annotations, desc, context, signatureParser) + BinaryJavaAnnotation.addAnnotation(this, desc, context, signatureParser) override fun findInnerClass(name: Name): JavaClass? = findInnerClass(name, classFileContent = null) diff --git a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Methods.kt b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Methods.kt index 77ef489fc6b..40dac89ef99 100644 --- a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Methods.kt +++ b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Methods.kt @@ -29,31 +29,30 @@ import java.text.CharacterIterator import java.text.StringCharacterIterator abstract class BinaryJavaMethodBase( - override val access: Int, - override val containingClass: JavaClass, - val valueParameters: List, - val typeParameters: List, - override val name: Name -) : JavaMember, MapBasedJavaAnnotationOwner, BinaryJavaModifierListOwner { + override val access: Int, + override val containingClass: JavaClass, + val valueParameters: List, + val typeParameters: List, + override val name: Name +) : JavaMember, BinaryJavaModifierListOwner, MutableJavaAnnotationOwner { + override val annotations: MutableCollection = SmartList() override val annotationsByFqName by buildLazyValueForMap() - override val annotations: Collection = SmartList() - companion object { private class MethodInfo( - val returnType: JavaType, - val typeParameters: List, - val valueParameterTypes: List + val returnType: JavaType, + val typeParameters: List, + val valueParameterTypes: List ) fun create( - name: String, - access: Int, - desc: String, - signature: String?, - containingClass: JavaClass, - parentContext: ClassifierResolutionContext, - signatureParser: BinaryClassSignatureParser + name: String, + access: Int, + desc: String, + signature: String?, + containingClass: JavaClass, + parentContext: ClassifierResolutionContext, + signatureParser: BinaryClassSignatureParser ): Pair { val isConstructor = "" == name val isVarargs = access.isSet(Opcodes.ACC_VARARGS) @@ -61,23 +60,23 @@ abstract class BinaryJavaMethodBase( val isInnerClassConstructor = isConstructor && containingClass.outerClass != null && !containingClass.isStatic val isEnumConstructor = containingClass.isEnum && isConstructor val info: MethodInfo = - if (signature != null) { - val contextForMethod = parentContext.copyForMember() - parseMethodSignature(signature, signatureParser, contextForMethod).also { - contextForMethod.addTypeParameters(it.typeParameters) - } - } else - parseMethodDescription(desc, parentContext, signatureParser).let { - when { - isEnumConstructor -> - // skip ordinal/name parameters for enum constructors - MethodInfo(it.returnType, it.typeParameters, it.valueParameterTypes.drop(2)) - isInnerClassConstructor -> - // omit synthetic inner class constructor parameter - MethodInfo(it.returnType, it.typeParameters, it.valueParameterTypes.drop(1)) - else -> it - } + if (signature != null) { + val contextForMethod = parentContext.copyForMember() + parseMethodSignature(signature, signatureParser, contextForMethod).also { + contextForMethod.addTypeParameters(it.typeParameters) + } + } else + parseMethodDescription(desc, parentContext, signatureParser).let { + when { + isEnumConstructor -> + // skip ordinal/name parameters for enum constructors + MethodInfo(it.returnType, it.typeParameters, it.valueParameterTypes.drop(2)) + isInnerClassConstructor -> + // omit synthetic inner class constructor parameter + MethodInfo(it.returnType, it.typeParameters, it.valueParameterTypes.drop(1)) + else -> it } + } val parameterTypes = info.valueParameterTypes val paramCount = parameterTypes.size @@ -87,15 +86,15 @@ abstract class BinaryJavaMethodBase( } val member: BinaryJavaMethodBase = - if (isConstructor) - BinaryJavaConstructor(access, containingClass, parameterList, info.typeParameters) - else - BinaryJavaMethod( - access, containingClass, - parameterList, - info.typeParameters, - Name.identifier(name), info.returnType - ) + if (isConstructor) + BinaryJavaConstructor(access, containingClass, parameterList, info.typeParameters) + else + BinaryJavaMethod( + access, containingClass, + parameterList, + info.typeParameters, + Name.identifier(name), info.returnType + ) val paramIgnoreCount = when { isEnumConstructor -> 2 @@ -114,9 +113,9 @@ abstract class BinaryJavaMethodBase( } private fun parseMethodDescription( - desc: String, - context: ClassifierResolutionContext, - signatureParser: BinaryClassSignatureParser + desc: String, + context: ClassifierResolutionContext, + signatureParser: BinaryClassSignatureParser ): MethodInfo { val returnType = signatureParser.mapAsmType(Type.getReturnType(desc), context) val parameterTypes = Type.getArgumentTypes(desc).map { signatureParser.mapAsmType(it, context) } @@ -125,9 +124,9 @@ abstract class BinaryJavaMethodBase( } private fun parseMethodSignature( - signature: String, - signatureParser: BinaryClassSignatureParser, - context: ClassifierResolutionContext + signature: String, + signatureParser: BinaryClassSignatureParser, + context: ClassifierResolutionContext ): MethodInfo { val iterator = StringCharacterIterator(signature) val typeParameters = signatureParser.parseTypeParametersDeclaration(iterator, context) @@ -137,8 +136,7 @@ abstract class BinaryJavaMethodBase( var paramTypes: List if (iterator.current() == ')') { paramTypes = emptyList() - } - else { + } else { paramTypes = mutableListOf() while (iterator.current() != ')' && iterator.current() != CharacterIterator.DONE) { paramTypes.add(signatureParser.parseTypeString(iterator, context)) @@ -157,14 +155,14 @@ abstract class BinaryJavaMethodBase( } class BinaryJavaMethod( - flags: Int, - containingClass: JavaClass, - valueParameters: List, - typeParameters: List, - name: Name, - override val returnType: JavaType + flags: Int, + containingClass: JavaClass, + valueParameters: List, + typeParameters: List, + name: Name, + override val returnType: JavaType ) : BinaryJavaMethodBase( - flags, containingClass, valueParameters, typeParameters, name + flags, containingClass, valueParameters, typeParameters, name ), JavaMethod { override var annotationParameterDefaultValue: JavaAnnotationArgument? = null internal set(value) { @@ -178,11 +176,11 @@ class BinaryJavaMethod( } class BinaryJavaConstructor( - flags: Int, - containingClass: JavaClass, - valueParameters: List, - typeParameters: List + flags: Int, + containingClass: JavaClass, + valueParameters: List, + typeParameters: List ) : BinaryJavaMethodBase( - flags, containingClass, valueParameters, typeParameters, - SpecialNames.NO_NAME_PROVIDED + flags, containingClass, valueParameters, typeParameters, + SpecialNames.NO_NAME_PROVIDED ), JavaConstructor diff --git a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Other.kt b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Other.kt index 9328dbcc8fa..975245f6c61 100644 --- a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Other.kt +++ b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Other.kt @@ -17,20 +17,19 @@ package org.jetbrains.kotlin.load.java.structure.impl.classFiles import org.jetbrains.kotlin.load.java.structure.* -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.SmartList import org.jetbrains.org.objectweb.asm.ClassReader import org.jetbrains.org.objectweb.asm.ClassVisitor class BinaryJavaField( - override val name: Name, - override val access: Int, - override val containingClass: JavaClass, - override val isEnumEntry: Boolean, - override val type: JavaType, - override val initializerValue: Any? -) : JavaField, MapBasedJavaAnnotationOwner, BinaryJavaModifierListOwner { + override val name: Name, + override val access: Int, + override val containingClass: JavaClass, + override val isEnumEntry: Boolean, + override val type: JavaType, + override val initializerValue: Any? +) : JavaField, BinaryJavaModifierListOwner, MutableJavaAnnotationOwner { override val annotations: MutableCollection = SmartList() override val annotationsByFqName by buildLazyValueForMap() @@ -39,20 +38,19 @@ class BinaryJavaField( } class BinaryJavaTypeParameter( - override val name: Name, - override val upperBounds: Collection -) : JavaTypeParameter { - // TODO: support annotations on type parameters - override val annotations get() = emptyList() - override fun findAnnotation(fqName: FqName) = null - - override val isDeprecatedInJavaDoc get() = false + override val name: Name, + override val upperBounds: Collection, + // If all bounds are interfaces then a type parameter has implicit Object class bound + val hasImplicitObjectClassBound: Boolean +) : JavaTypeParameter, ListBasedJavaAnnotationOwner, MutableJavaAnnotationOwner { + override val annotations: MutableCollection = SmartList() + override val isDeprecatedInJavaDoc = false } class BinaryJavaValueParameter( - override val type: JavaType, - override val isVararg: Boolean -) : JavaValueParameter, MapBasedJavaAnnotationOwner { + override val type: JavaType, + override val isVararg: Boolean +) : JavaValueParameter, MapBasedJavaAnnotationOwner, MutableJavaAnnotationOwner { override val annotations: MutableCollection = SmartList() override val annotationsByFqName by buildLazyValueForMap() diff --git a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Types.kt b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Types.kt index 9c17f038908..9facc4f623c 100644 --- a/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Types.kt +++ b/compiler/resolution.common.jvm/src/org/jetbrains/kotlin/load/java/structure/impl/classFiles/Types.kt @@ -18,21 +18,25 @@ package org.jetbrains.kotlin.load.java.structure.impl.classFiles import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.load.java.structure.* -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.utils.SmartList import org.jetbrains.kotlin.utils.addToStdlib.safeAs +internal abstract class JavaPlainType : ListBasedJavaAnnotationOwner, MutableJavaAnnotationOwner { + override val annotations: MutableCollection = SmartList() + override val isDeprecatedInJavaDoc = false +} + // They are only used for java class files, but potentially may be used in other cases // It would be better to call them like JavaSomeTypeImpl, but these names are already occupied by the PSI based types -internal class PlainJavaArrayType(override val componentType: JavaType) : JavaArrayType -internal class PlainJavaWildcardType(override val bound: JavaType?, override val isExtends: Boolean) : JavaWildcardType -internal class PlainJavaPrimitiveType(override val type: PrimitiveType?) : JavaPrimitiveType +internal class PlainJavaArrayType(override val componentType: JavaType) : JavaPlainType(), JavaArrayType +internal class PlainJavaWildcardType(override val bound: JavaType?, override val isExtends: Boolean) : JavaPlainType(), JavaWildcardType +internal class PlainJavaPrimitiveType(override val type: PrimitiveType?) : JavaPlainType(), JavaPrimitiveType internal class PlainJavaClassifierType( - // calculation of classifier and canonicalText - classifierComputation: () -> ClassifierResolutionContext.Result, - override val typeArguments: List -) : JavaClassifierType { + // calculation of classifier and canonicalText + classifierComputation: () -> ClassifierResolutionContext.Result, + override val typeArguments: List +) : JavaPlainType(), JavaClassifierType { private val classifierResolverResult by lazy(LazyThreadSafetyMode.NONE, classifierComputation) override val classifier get() = classifierResolverResult.classifier @@ -40,21 +44,6 @@ internal class PlainJavaClassifierType( get() = typeArguments.isEmpty() && classifierResolverResult.classifier?.safeAs()?.typeParameters?.isNotEmpty() == true - private var _annotations = emptyList() - override val annotations get() = _annotations - - override fun findAnnotation(fqName: FqName) = annotations.find { it.classId?.asSingleFqName() == fqName } - - internal fun addAnnotation(annotation: JavaAnnotation) { - if (_annotations.isEmpty()) { - _annotations = SmartList() - } - - (_annotations as MutableList).add(annotation) - } - - override val isDeprecatedInJavaDoc get() = false - override val classifierQualifiedName: String get() = classifierResolverResult.qualifiedName diff --git a/compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.javac.txt b/compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.javac.txt deleted file mode 100644 index e78e8750b0b..00000000000 --- a/compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.javac.txt +++ /dev/null @@ -1,14 +0,0 @@ -package test - -public open class TypeParameterAnnotations { - public constructor TypeParameterAnnotations() - - @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) public final annotation class A : kotlin.Annotation { - public constructor A(/*0*/ value: kotlin.String = ...) - public final val value: kotlin.String - } - - public interface G { - public abstract fun foo(/*0*/ p0: R!): kotlin.Unit - } -} diff --git a/compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.runtime.txt b/compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.runtime.txt deleted file mode 100644 index 98273e896e2..00000000000 --- a/compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.runtime.txt +++ /dev/null @@ -1,14 +0,0 @@ -package test - -public open class TypeParameterAnnotations { - public constructor TypeParameterAnnotations() - - @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) @kotlin.annotation.Retention(value = ...) public final annotation class A : kotlin.Annotation { - public final val value: kotlin.String - public final fun (): kotlin.String - } - - public interface G { - public abstract fun foo(/*0*/ R!): kotlin.Unit - } -} diff --git a/compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.java b/compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.java similarity index 52% rename from compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.java rename to compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.java index 55dbc0b0bd1..65420a47763 100644 --- a/compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.java +++ b/compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.java @@ -2,15 +2,21 @@ package test; import java.lang.annotation.*; -public class TypeParameterAnnotations { +public class Basic { @Target(ElementType.TYPE_PARAMETER) public @interface A { String value() default ""; } - // Currently annotations on type parameters and arguments are not loaded from compiled code because of IDEA-153093 - // Once it will be fixed check if KT-11454 is ready to be resolved public interface G<@A T> { <@A("abc") R> void foo(R r); } + + public interface G1 { + void foo(R r); + } + + void foo(R r) { + + } } diff --git a/compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.javac.txt b/compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.javac.txt new file mode 100644 index 00000000000..900f301900d --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.javac.txt @@ -0,0 +1,14 @@ +package test + +public open class Basic { + public constructor Basic() + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) public final annotation class A : kotlin.Annotation { + public constructor A(/*0*/ value: kotlin.String = ...) + public final val value: kotlin.String + } + + public interface G { + public abstract fun foo(/*0*/ p0: R!): kotlin.Unit + } +} diff --git a/compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.runtime.txt b/compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.runtime.txt new file mode 100644 index 00000000000..2a256fb0fdf --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.runtime.txt @@ -0,0 +1,14 @@ +package test + +public open class Basic { + public constructor Basic() + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) @kotlin.annotation.Retention(value = ...) public final annotation class A : kotlin.Annotation { + public final val value: kotlin.String + public final fun (): kotlin.String + } + + public interface G { + public abstract fun foo(/*0*/ R!): kotlin.Unit + } +} diff --git a/compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.txt b/compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.txt new file mode 100644 index 00000000000..5e35b2ed9cb --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.txt @@ -0,0 +1,19 @@ +package test + +public open class Basic { + public constructor Basic() + public/*package*/ open fun foo(/*0*/ p0: R!): kotlin.Unit + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) public final annotation class A : kotlin.Annotation { + public constructor A(/*0*/ value: kotlin.String = ...) + public final val value: kotlin.String + } + + public interface G { + public abstract fun foo(/*0*/ p0: R!): kotlin.Unit + } + + public interface G1 { + public abstract fun foo(/*0*/ p0: R!): kotlin.Unit + } +} diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.java b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.java new file mode 100644 index 00000000000..b99084103bc --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.java @@ -0,0 +1,26 @@ +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +interface I1 {} +interface I2 {} +interface I3 {} + +class A2 {} +class A3 {} + +public class BaseClassTypeArguments extends A3<@A B [][][][][], I1>, A2> implements I1<@A Integer @A [][][]>, I2<@A B, B>, I3<@A B [][][][][], B, @A B> { + class ImplementedInterfacesTypeArguments implements I1, I1<@A int [] @A []>>>, I2<@A B, B>, I3<@A B [][][][][], I1>, I2> { + public class BaseClassTypeArguments1 extends A3<@A B [][][][][], I1>, A2> { + + } + } + static class BaseClassTypeArguments2 extends A3<@A B [][][][][], I1>, A2> { + + } +} \ No newline at end of file diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.txt b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.txt new file mode 100644 index 00000000000..46dd7dac980 --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.txt @@ -0,0 +1,39 @@ +package test + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public/*package*/ final annotation class A : kotlin.Annotation { + public/*package*/ constructor A(/*0*/ value: kotlin.String = ...) + public final val value: kotlin.String +} + +public/*package*/ open class A2 { + public/*package*/ constructor A2() +} + +public/*package*/ open class A3 { + public/*package*/ constructor A3() +} + +public open class BaseClassTypeArguments : test.A3!>!>!>!>!, test.I1..@test.A kotlin.Array?)>!>!, test.A2!>!>!>, test.I1<(@test.A kotlin.Array!>!>..@test.A kotlin.Array!>!>?)>, test.I2<@test.A B!, B!>, test.I3!>!>!>!>!, B!, @test.A B!> { + public constructor BaseClassTypeArguments() + + public/*package*/ open class BaseClassTypeArguments2 : test.A3!>!>!>!>!, test.I1..@test.A kotlin.Array?)>!>!, test.A2!>!>!> { + public/*package*/ constructor BaseClassTypeArguments2() + } + + public/*package*/ open inner class ImplementedInterfacesTypeArguments /*captured type parameters: /*1*/ B : kotlin.Any!*/ : test.I1!>!>..@test.A kotlin.Array!>!>?)>!, test.I1!>!>!>, test.I2<@test.A B!, B!>, test.I3!>!>!>!>!, test.I1..@test.A kotlin.Array?)>!>!, test.I2!>!>!> { + public/*package*/ constructor ImplementedInterfacesTypeArguments() + + public open inner class BaseClassTypeArguments1 /*captured type parameters: /*1*/ B : kotlin.Any!, /*2*/ B : kotlin.Any!*/ : test.A3!>!>!>!>!, test.I1..@test.A kotlin.Array?)>!>!, test.A2!>!>!> { + public constructor BaseClassTypeArguments1() + } + } +} + +public/*package*/ interface I1 { +} + +public/*package*/ interface I2 { +} + +public/*package*/ interface I3 { +} diff --git a/compiler/testData/loadJava8/sourceJava/TypeAnnotations.java b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/Basic.java similarity index 91% rename from compiler/testData/loadJava8/sourceJava/TypeAnnotations.java rename to compiler/testData/loadJava8/compiledJava/typeUseAnnotations/Basic.java index cffa9f44312..e2309dac755 100644 --- a/compiler/testData/loadJava8/sourceJava/TypeAnnotations.java +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/Basic.java @@ -1,7 +1,7 @@ package test; import java.lang.annotation.*; -public class TypeAnnotations { +public class Basic { @Target(ElementType.TYPE_USE) @interface A { String value() default ""; diff --git a/compiler/testData/loadJava8/sourceJava/TypeAnnotations.txt b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/Basic.txt similarity index 57% rename from compiler/testData/loadJava8/sourceJava/TypeAnnotations.txt rename to compiler/testData/loadJava8/compiledJava/typeUseAnnotations/Basic.txt index d5160b844ee..b5181c531f7 100644 --- a/compiler/testData/loadJava8/sourceJava/TypeAnnotations.txt +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/Basic.txt @@ -1,7 +1,7 @@ package test -public open class TypeAnnotations { - public constructor TypeAnnotations() +public open class Basic { + public constructor Basic() @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public/*package*/ final annotation class A : kotlin.Annotation { public/*package*/ constructor A(/*0*/ value: kotlin.String = ...) @@ -15,7 +15,7 @@ public open class TypeAnnotations { } public interface MyClass { - public abstract fun f(/*0*/ p: test.TypeAnnotations.G2<@test.TypeAnnotations.A kotlin.String!, @test.TypeAnnotations.A(value = "abc") kotlin.Int!>!): kotlin.Unit - public abstract fun f(/*0*/ p: test.TypeAnnotations.G<@test.TypeAnnotations.A kotlin.String!>!): kotlin.Unit + public abstract fun f(/*0*/ p0: test.Basic.G2<@test.Basic.A kotlin.String!, @test.Basic.A(value = "abc") kotlin.Int!>!): kotlin.Unit + public abstract fun f(/*0*/ p0: test.Basic.G<@test.Basic.A kotlin.String!>!): kotlin.Unit } } diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.java b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.java new file mode 100644 index 00000000000..e8ed265b044 --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.java @@ -0,0 +1,33 @@ +// JAVAC_EXPECTED_FILE + +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +public class ClassTypeParameterBounds { + interface I1 {} + interface I2 {} + interface I3 {} + interface I4 {} + + interface G1 { } + class G2<_A, B extends @A Integer> { } + interface G3<_A, B extends Object & @A I1> { } + class G4<_A extends @A B, B> { } + interface G5<_A, B extends @A _A> { } + class G6<_A extends @A I1, B, C, D extends @A E, E, F> { } + interface G7<_A extends Object & I2<@A Integer> & @A I3> { } + interface G8<_A extends Object & I2 & @A I3> { } + + interface G9<_A extends I4 & I2 & @A I3> { } + interface G10<_A extends I4 & I2 & @A I3> { } + interface G11<_A extends I4 & I2 & @A I3> { } + interface G12<_A extends I4 & I2 & @A I3> { } + + // class G13<_A extends Object, B extends I3<@A _A> & @A I2<_A>> { } +} diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.txt b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.txt new file mode 100644 index 00000000000..c2664ce9824 --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.txt @@ -0,0 +1,61 @@ +package test + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public/*package*/ final annotation class A : kotlin.Annotation { + public/*package*/ constructor A(/*0*/ value: kotlin.String = ...) + public final val value: kotlin.String +} + +public open class ClassTypeParameterBounds { + public constructor ClassTypeParameterBounds() + + public/*package*/ interface G1 { + } + + public/*package*/ interface G10!> where _A : test.ClassTypeParameterBounds.I2!, _A : @test.A test.ClassTypeParameterBounds.I3! { + } + + public/*package*/ interface G11..@test.A kotlin.Array?)>!>!>!> where _A : test.ClassTypeParameterBounds.I2!>!>!>..@test.A kotlin.Array!>!>!>?)>!, _A : @test.A test.ClassTypeParameterBounds.I3..@test.A kotlin.Array?)>!>! { + } + + public/*package*/ interface G12..@test.A kotlin.Array?)>!> where _A : test.ClassTypeParameterBounds.I2!>!>!, _A : @test.A test.ClassTypeParameterBounds.I3..@test.A kotlin.Array?)>!>! { + } + + public/*package*/ open inner class G2 { + public/*package*/ constructor G2() + } + + public/*package*/ interface G3 where B : @test.A test.ClassTypeParameterBounds.I1! { + } + + public/*package*/ open inner class G4 { + public/*package*/ constructor G4() + } + + public/*package*/ interface G5 { + } + + public/*package*/ open inner class G6 { + public/*package*/ constructor G6() + } + + public/*package*/ interface G7 where _A : test.ClassTypeParameterBounds.I2<@test.A kotlin.Int!>!, _A : @test.A test.ClassTypeParameterBounds.I3! { + } + + public/*package*/ interface G8 where _A : test.ClassTypeParameterBounds.I2!, _A : @test.A test.ClassTypeParameterBounds.I3! { + } + + public/*package*/ interface G9..@test.A kotlin.Array?)>!> where _A : test.ClassTypeParameterBounds.I2..@test.A kotlin.Array?)>!, _A : @test.A test.ClassTypeParameterBounds.I3..@test.A kotlin.Array?)>! { + } + + public/*package*/ interface I1 { + } + + public/*package*/ interface I2 { + } + + public/*package*/ interface I3 { + } + + public/*package*/ interface I4 { + } +} diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.java b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.java new file mode 100644 index 00000000000..c26e08c0b33 --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.java @@ -0,0 +1,23 @@ +// JAVAC_EXPECTED_FILE + +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +/* + * Note that a receiver type doesn't get into signatures used by the Kotlin compiler + * So in this test, annotated types shouldn't be reflected in the signatures dump + */ + +public class MethodReceiver { + public void f1(MethodReceiver<@A T> this) { } + + class MethodReceiver3 { + public void f1(@A MethodReceiver3<@A T, K, @A L> this) { } + } +} \ No newline at end of file diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.txt b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.txt new file mode 100644 index 00000000000..b966213b1d6 --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.txt @@ -0,0 +1,16 @@ +package test + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public/*package*/ final annotation class A : kotlin.Annotation { + public/*package*/ constructor A(/*0*/ value: kotlin.String = ...) + public final val value: kotlin.String +} + +public open class MethodReceiver { + public constructor MethodReceiver() + public open fun f1(): kotlin.Unit + + public/*package*/ open inner class MethodReceiver3 /*captured type parameters: /*3*/ T : kotlin.Any!*/ { + public/*package*/ constructor MethodReceiver3() + public open fun f1(): kotlin.Unit + } +} diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.java b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.java new file mode 100644 index 00000000000..1ddc625116a --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.java @@ -0,0 +1,33 @@ +// JAVAC_EXPECTED_FILE + +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +abstract class MethodTypeParameterBounds { + interface I1 {} + interface I2 {} + interface I3 {} + interface I4 {} + + void f1(T x) { } + <_A, B extends @A Integer> void f2(_A x, B y) { } + <_A, B extends Object & @A I1> void f3(_A x, B y) { } + <_A extends @A B, B> void f4(_A x, B y) { } + <_A, B extends @A _A> void f5(_A x, B y) { } + <_A extends @A I1> void f6() { } + abstract <_A, B extends @A _A> void f7(_A x, B y); + abstract <_A extends @A I1, B, C, D extends @A E, E, F> void f8(_A x1, B x2, C x3, D x4, E x5, F x6); + <_A extends Object & I2<@A Integer> & @A I3> void f9(_A x) { } + <_A extends Object & I2 & @A I3> void f10(_A x) { } + <_A extends I4 & I2 & @A I3> void f11(_A x) { } + <_A extends I4 & I2 & @A I3> void f12(_A x) { } + <_A extends I4 & I2 & @A I3> void f13(_A x) { } + abstract <_A extends I4 & I2 & @A I3> void f14(_A x); + <_A extends Object, B extends I3<@A A> & @A I2> void f15(_A x) { } +} diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.txt b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.txt new file mode 100644 index 00000000000..43b77d4acaa --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.txt @@ -0,0 +1,37 @@ +package test + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public/*package*/ final annotation class A : kotlin.Annotation { + public/*package*/ constructor A(/*0*/ value: kotlin.String = ...) + public final val value: kotlin.String +} + +public/*package*/ abstract class MethodTypeParameterBounds { + public/*package*/ constructor MethodTypeParameterBounds() + public/*package*/ open fun f1(/*0*/ p0: T!): kotlin.Unit + public/*package*/ open fun f10(/*0*/ p0: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!, _A : @test.A test.MethodTypeParameterBounds.I3! + public/*package*/ open fun ..@test.A kotlin.Array?)>!> f11(/*0*/ p0: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2..@test.A kotlin.Array?)>!, _A : @test.A test.MethodTypeParameterBounds.I3..@test.A kotlin.Array?)>! + public/*package*/ open fun !> f12(/*0*/ p0: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!, _A : @test.A test.MethodTypeParameterBounds.I3! + public/*package*/ open fun ..@test.A kotlin.Array?)>!>!>!> f13(/*0*/ p0: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!>!>!>..@test.A kotlin.Array!>!>!>?)>!, _A : @test.A test.MethodTypeParameterBounds.I3..@test.A kotlin.Array?)>!>! + public/*package*/ abstract fun ..@test.A kotlin.Array?)>!> f14(/*0*/ p0: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!>!>!, _A : @test.A test.MethodTypeParameterBounds.I3..@test.A kotlin.Array?)>!>! + public/*package*/ open fun !> f15(/*0*/ p0: _A!): kotlin.Unit where B : @test.A test.MethodTypeParameterBounds.I2! + public/*package*/ open fun f2(/*0*/ p0: _A!, /*1*/ p1: B!): kotlin.Unit + public/*package*/ open fun f3(/*0*/ p0: _A!, /*1*/ p1: B!): kotlin.Unit where B : @test.A test.MethodTypeParameterBounds.I1! + public/*package*/ open fun f4(/*0*/ p0: _A!, /*1*/ p1: B!): kotlin.Unit + public/*package*/ open fun f5(/*0*/ p0: _A!, /*1*/ p1: B!): kotlin.Unit + public/*package*/ open fun f6(): kotlin.Unit + public/*package*/ abstract fun f7(/*0*/ p0: _A!, /*1*/ p1: B!): kotlin.Unit + public/*package*/ abstract fun f8(/*0*/ p0: _A!, /*1*/ p1: B!, /*2*/ p2: C!, /*3*/ p3: D!, /*4*/ p4: E!, /*5*/ p5: F!): kotlin.Unit + public/*package*/ open fun f9(/*0*/ p0: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2<@test.A kotlin.Int!>!, _A : @test.A test.MethodTypeParameterBounds.I3! + + public/*package*/ interface I1 { + } + + public/*package*/ interface I2 { + } + + public/*package*/ interface I3 { + } + + public/*package*/ interface I4 { + } +} diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.java b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.java new file mode 100644 index 00000000000..5c223aef06f --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.java @@ -0,0 +1,95 @@ +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +interface G0 { } +interface G1 { } +interface G2 { } + +interface ReturnType { + // simplpe type arguments + G1<@A G0> f0(); + G1>>> f1(); + G1<@A String> f2(); + G2<@A String, G2<@A("abc") Integer, G2<@A("abc") G2, @A("abc") Integer>>> f3(); + + // wildcards + G1 f4 = null; + G1>>> f5(); + G1 f6(); + G2, ? extends @A("abc") Integer>>> f7(); + + G1 f8(); + G1>>> f9(); + G1 f10 = null; + G2, ? super @A("abc") Integer>>> f11(); + + G2, ? extends @A("abc") Integer>>> f12 = null; + + // arrays + Integer @A [] f13(); + int @A [] f14(); + @A Integer [] f15(); + @A int [] f16(); + @A Integer @A [] f17(); + @A int @A [] f18 = null; + + // multidementional arrays + Integer @A [] [] f19(); + int @A [] @A [] f20(); + @A Integer [] [] [] f21 = null; + @A int @A [] @A [] [] @A [] f22(); + @A Integer @A [] [] @A [] [] f23(); + @A int @A [] @A [] f24 = null; + int [] @A [] f25(); + Object [] @A [] f26(); + @A Object [] [] [] [] @A [] f27(); + + // arrays in type arguments + G1 f28(); + G2 f29(); + G1<@A Integer []> f30(); + G1> f31(); + G1, G1<@A int @A []>>> f32(); + G1<@A int @A []> f33(); + G1 f34(); + G2 f35 = null; + G1<@A Integer @A [] []> f36(); + G1> f37(); + G1, G1<@A int [] [] @A []>>> f38(); + G1<@A int @A [] @A [] []> f39(); + + // arrays in wildcard bounds + G1 f40(); + G2 f41(); + G1 f42(); + G1> f43(); + G1, G1>> f44(); + G1, G1>> f45 = null; + G1 f46(); + G1 f47(); + G2 f48 = null; + G1 f49(); + G1> f50(); + G1, G1>> f51(); + G1, G1>> f52 = null; + G1 f53(); + + class ReturnType2 { + G1 f4 = null; + G1 f10 = null; + G2, ? extends @A("abc") Integer>>> f12 = null; + @A int @A [] f18 = null; + @A Integer [] [] [] f21 = null; + @A int @A [] @A [] f24 = null; + G2 f35 = null; + G1, G1>> f45 = null; + G2 f48 = null; + G1, G1>> f52 = null; + } +} diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.txt b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.txt new file mode 100644 index 00000000000..cb7cc847e10 --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.txt @@ -0,0 +1,88 @@ +package test + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public/*package*/ final annotation class A : kotlin.Annotation { + public/*package*/ constructor A(/*0*/ value: kotlin.String = ...) + public final val value: kotlin.String +} + +public/*package*/ interface G0 { +} + +public/*package*/ interface G1 { +} + +public/*package*/ interface G2 { +} + +public/*package*/ interface ReturnType { + public abstract fun f0(): test.G1<@test.A test.G0!>! + public abstract fun f1(): test.G1!>!>!>! + public abstract fun f11(): test.G2!, in @test.A(value = "abc") kotlin.Int!>!>!>! + public abstract fun f13(): (@test.A kotlin.Array..@test.A kotlin.Array?) + public abstract fun f14(): @test.A kotlin.IntArray! + public abstract fun f15(): kotlin.Array<(out) @test.A kotlin.Int!>! + public abstract fun f16(): kotlin.IntArray! + public abstract fun f17(): (@test.A kotlin.Array<@test.A kotlin.Int!>..@test.A kotlin.Array?) + public abstract fun f19(): (@test.A kotlin.Array!>..@test.A kotlin.Array!>?) + public abstract fun f2(): test.G1<@test.A kotlin.String!>! + public abstract fun f20(): (@test.A kotlin.Array<@test.A kotlin.IntArray!>..@test.A kotlin.Array?) + public abstract fun f22(): (@test.A kotlin.Array<(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>..@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>?) + public abstract fun f23(): (@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>!>..@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>!>?) + public abstract fun f25(): kotlin.Array<(out) @test.A kotlin.IntArray!>! + public abstract fun f26(): kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>! + public abstract fun f27(): kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) (@test.A kotlin.Array<@test.A kotlin.Any!>..@test.A kotlin.Array?)>!>!>!>! + public abstract fun f28(): test.G1<(@test.A kotlin.Array..@test.A kotlin.Array?)>! + public abstract fun f29(): test.G2! + public abstract fun f3(): test.G2<@test.A kotlin.String!, test.G2<@test.A(value = "abc") kotlin.Int!, test.G2<@test.A(value = "abc") test.G2!, @test.A(value = "abc") kotlin.Int!>!>!>! + public abstract fun f30(): test.G1!>! + public abstract fun f31(): test.G1!>! + public abstract fun f32(): test.G1..@test.A kotlin.Array?)>!, test.G1<@test.A kotlin.IntArray!>!>!>! + public abstract fun f33(): test.G1<@test.A kotlin.IntArray!>! + public abstract fun f34(): test.G1..@test.A kotlin.Array?)>!>! + public abstract fun f36(): test.G1<(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>! + public abstract fun f37(): test.G1!>!>!>! + public abstract fun f38(): test.G1..@test.A kotlin.Array?)>!, test.G1!>!>!>!>! + public abstract fun f39(): test.G1<(@test.A kotlin.Array<(@test.A kotlin.Array..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)>! + public abstract fun f40(): test.G1..@test.A kotlin.Array?)>! + public abstract fun f41(): test.G2! + public abstract fun f42(): test.G1!>! + public abstract fun f43(): test.G1!>! + public abstract fun f44(): test.G1..@test.A kotlin.Array?)>!, test.G1!>!>! + public abstract fun f46(): test.G1! + public abstract fun f47(): test.G1..@test.A kotlin.Array?)>!>! + public abstract fun f49(): test.G1!>!>!>!>!>! + public abstract fun f5(): test.G1!>!>!>! + public abstract fun f50(): test.G1..@test.A kotlin.Array?)>!>! + public abstract fun f51(): test.G1..@test.A kotlin.Array?)>!>!>!, test.G1..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)>!>!>! + public abstract fun f53(): test.G1..@test.A kotlin.Array?)>! + public abstract fun f6(): test.G1! + public abstract fun f7(): test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>! + public abstract fun f8(): test.G1! + public abstract fun f9(): test.G1!>!>!>! + + public open class ReturnType2 { + public constructor ReturnType2() + public/*package*/ final var f10: test.G1! + public/*package*/ final var f12: test.G2!, out kotlin.Int!>!>!>! + public/*package*/ final var f18: @test.A kotlin.IntArray! + public/*package*/ final var f21: kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) kotlin.Int!>!>!>! + public/*package*/ final var f24: (@test.A kotlin.Array..@test.A kotlin.Array?) + public/*package*/ final var f35: test.G2!>! + public/*package*/ final var f4: test.G1! + public/*package*/ final var f45: test.G1!>!, test.G1!>!>! + public/*package*/ final var f48: test.G2!>!>! + public/*package*/ final var f52: test.G1!>!>!>!, test.G1!>!>!>! + } + + // Static members + public final val f10: test.G1! + public final val f12: test.G2!, out kotlin.Int!>!>!>! + public final val f18: @test.A kotlin.IntArray! + public final val f21: kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) kotlin.Int!>!>!>! + public final val f24: (@test.A kotlin.Array..@test.A kotlin.Array?) + public final val f35: test.G2!>! + public final val f4: test.G1! + public final val f45: test.G1!>!, test.G1!>!>! + public final val f48: test.G2!>!>! + public final val f52: test.G1!>!>!>!, test.G1!>!>!>! +} diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.java b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.java new file mode 100644 index 00000000000..8d54ff5550d --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.java @@ -0,0 +1,117 @@ +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +interface G0 { } +interface G1 { } +interface G2 { } + +interface ValueArguments { + // simplpe type arguments + void f0(G1<@A G0> p); + void f1(G1>>> p); + void f2(G1<@A String> p); + void f3(G2<@A String, G2<@A("abc") Integer, G2<@A("abc") G2, @A("abc") Integer>>> p); + + // wildcards + void f4(G1 p); + void f5(G1>>> p); + void f6(G1 p1, G1>>> p2); + void f7(G2, ? extends @A("abc") Integer>>> p); + + void f8(G1 p); + void f9(G1>>> p); + void f10(G1 p); + void f11(G2, ? super @A("abc") Integer>>> p); + + void f12(G2, ? extends @A("abc") Integer>>> p); + + // arrays + void f13(Integer @A [] p); + void f14(int @A [] p); + void f15(@A Integer [] p); + void f16(@A int [] p); + void f17(@A Integer @A [] p); + void f18(@A int @A [] p1, Integer @A [] p2, @A int [] p3); + + // multidementional arrays + void f19(Integer @A [] [] p); + void f20(int @A [] @A [] p); + void f21(@A Integer [] [] [] p); + void f22(@A int @A [] @A [] [] @A [] p); + void f23(@A Integer @A [] [] @A [] [] p); + void f24(@A int @A [] @A [] p); + void f25(int [] @A [] p); + void f26(Object [] @A [] p1, int [] @A [] p2, @A int @A [] @A [] [] @A [] p3); + void f27(@A Object [] [] [] [] @A [] p); + + // arrays in type arguments + void f28(G1 p); + void f29(G2 p); + void f30(G1<@A Integer []> p); + void f31(G1> p); + void f32(G1, G1<@A int @A []>>> p); + void f33(G1<@A int @A []> p); + void f34(G1 p); + void f35(G2 p1, G1<@A Integer @A [] []> p2, G1> p3); + void f36(G1<@A Integer @A [] []> p); + void f37(G1> p); + void f38(G1, G1<@A int [] [] @A []>>> p); + void f39(G1<@A int @A [] @A [] []> p); + + // arrays in wildcard bounds + void f40(G1 p); + void f41(G2 p); + void f42(G1 p); + void f43(G1> p); + void f44(G1, G1>> p); + void f45(G1, G1>> p); + void f46(G1 p); + void f47(G1 p); + void f48(G2 p); + void f49(G1 p1, G1> p2, G2 p3); + void f50(G1> p); + void f51(G1, G1>> p); + void f52(G1, G1>> p); + void f53(G1 p); + + void f54(G1, G1>> p1, G1<@A int @A [] @A [] []> p2, @A Object [] [] [] [] @A [] p3, @A int @A [] p4, G2, ? extends @A("abc") Integer>>> p5); + + // varargs + void f55(@A String ... x); + void f56(String @A ... x); + void f57(@A String @A ... x); + void f58(@A int ... x); + void f59(int @A ... x); + void f60(@A int @A ... x); + + // varargs + arrays + void f61(@A String [] ... x); + void f62(String @A [] ... x); + void f63(String [] @A ... x); + void f64(@A String @A [] @A ... x); + void f65(@A int [] ... x); + void f66(int @A [] ... x); + void f67(int [] @A ... x); + void f68(@A int @A [] @A ... x); + + void f69(@A String [] [] ... x); + void f70(String [] @A [] ... x); + void f71(String [] [] [] @A ... x); + void f72(@A String @A [] [] @A [] @A ... x); + void f73(@A int [] @A [] ... x); + void f74(int @A [][][] @A [] ... x); + void f75(int [] [] [] @A ... x); + void f76(@A int @A [] [] @A ... x); + + class Test { + public Test(G2, ? extends @A("abc") Integer>>> p1, Object [] @A [] p2, int [] @A [] p3, @A int @A [] @A [] [] @A [] p4, @A int @A [] [] @A ... p5) { + + } + } +} diff --git a/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.txt b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.txt new file mode 100644 index 00000000000..e4ecaac4799 --- /dev/null +++ b/compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.txt @@ -0,0 +1,99 @@ +package test + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public/*package*/ final annotation class A : kotlin.Annotation { + public/*package*/ constructor A(/*0*/ value: kotlin.String = ...) + public final val value: kotlin.String +} + +public/*package*/ interface G0 { +} + +public/*package*/ interface G1 { +} + +public/*package*/ interface G2 { +} + +public/*package*/ interface ValueArguments { + public abstract fun f0(/*0*/ p0: test.G1<@test.A test.G0!>!): kotlin.Unit + public abstract fun f1(/*0*/ p0: test.G1!>!>!>!): kotlin.Unit + public abstract fun f10(/*0*/ p0: test.G1!): kotlin.Unit + public abstract fun f11(/*0*/ p0: test.G2!, in @test.A(value = "abc") kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f12(/*0*/ p0: test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f13(/*0*/ p0: (@test.A kotlin.Array..@test.A kotlin.Array?)): kotlin.Unit + public abstract fun f14(/*0*/ p0: @test.A kotlin.IntArray!): kotlin.Unit + public abstract fun f15(/*0*/ p0: kotlin.Array<(out) @test.A kotlin.Int!>!): kotlin.Unit + public abstract fun f16(/*0*/ p0: kotlin.IntArray!): kotlin.Unit + public abstract fun f17(/*0*/ p0: (@test.A kotlin.Array<@test.A kotlin.Int!>..@test.A kotlin.Array?)): kotlin.Unit + public abstract fun f18(/*0*/ p0: @test.A kotlin.IntArray!, /*1*/ p1: (@test.A kotlin.Array..@test.A kotlin.Array?), /*2*/ p2: kotlin.IntArray!): kotlin.Unit + public abstract fun f19(/*0*/ p0: (@test.A kotlin.Array!>..@test.A kotlin.Array!>?)): kotlin.Unit + public abstract fun f2(/*0*/ p0: test.G1<@test.A kotlin.String!>!): kotlin.Unit + public abstract fun f20(/*0*/ p0: (@test.A kotlin.Array<@test.A kotlin.IntArray!>..@test.A kotlin.Array?)): kotlin.Unit + public abstract fun f21(/*0*/ p0: kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f22(/*0*/ p0: (@test.A kotlin.Array<(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>..@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>?)): kotlin.Unit + public abstract fun f23(/*0*/ p0: (@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>!>..@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>!>?)): kotlin.Unit + public abstract fun f24(/*0*/ p0: (@test.A kotlin.Array<@test.A kotlin.IntArray!>..@test.A kotlin.Array?)): kotlin.Unit + public abstract fun f25(/*0*/ p0: kotlin.Array<(out) @test.A kotlin.IntArray!>!): kotlin.Unit + public abstract fun f26(/*0*/ p0: kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!, /*1*/ p1: kotlin.Array<(out) @test.A kotlin.IntArray!>!, /*2*/ p2: (@test.A kotlin.Array<(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>..@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>?)): kotlin.Unit + public abstract fun f27(/*0*/ p0: kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) (@test.A kotlin.Array<@test.A kotlin.Any!>..@test.A kotlin.Array?)>!>!>!>!): kotlin.Unit + public abstract fun f28(/*0*/ p0: test.G1<(@test.A kotlin.Array..@test.A kotlin.Array?)>!): kotlin.Unit + public abstract fun f29(/*0*/ p0: test.G2!): kotlin.Unit + public abstract fun f3(/*0*/ p0: test.G2<@test.A kotlin.String!, test.G2<@test.A(value = "abc") kotlin.Int!, test.G2<@test.A(value = "abc") test.G2!, @test.A(value = "abc") kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f30(/*0*/ p0: test.G1!>!): kotlin.Unit + public abstract fun f31(/*0*/ p0: test.G1!>!): kotlin.Unit + public abstract fun f32(/*0*/ p0: test.G1..@test.A kotlin.Array?)>!, test.G1<@test.A kotlin.IntArray!>!>!>!): kotlin.Unit + public abstract fun f33(/*0*/ p0: test.G1<@test.A kotlin.IntArray!>!): kotlin.Unit + public abstract fun f34(/*0*/ p0: test.G1..@test.A kotlin.Array?)>!>!): kotlin.Unit + public abstract fun f35(/*0*/ p0: test.G2..@test.A kotlin.Array?)>!, /*1*/ p1: test.G1<(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>!, /*2*/ p2: test.G1!>!): kotlin.Unit + public abstract fun f36(/*0*/ p0: test.G1<(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>!): kotlin.Unit + public abstract fun f37(/*0*/ p0: test.G1!>!>!>!): kotlin.Unit + public abstract fun f38(/*0*/ p0: test.G1..@test.A kotlin.Array?)>!, test.G1!>!>!>!>!): kotlin.Unit + public abstract fun f39(/*0*/ p0: test.G1<(@test.A kotlin.Array<(@test.A kotlin.Array..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)>!): kotlin.Unit + public abstract fun f4(/*0*/ p0: test.G1!): kotlin.Unit + public abstract fun f40(/*0*/ p0: test.G1..@test.A kotlin.Array?)>!): kotlin.Unit + public abstract fun f41(/*0*/ p0: test.G2!): kotlin.Unit + public abstract fun f42(/*0*/ p0: test.G1!>!): kotlin.Unit + public abstract fun f43(/*0*/ p0: test.G1!>!): kotlin.Unit + public abstract fun f44(/*0*/ p0: test.G1..@test.A kotlin.Array?)>!, test.G1!>!>!): kotlin.Unit + public abstract fun f45(/*0*/ p0: test.G1..@test.A kotlin.Array?)>!, test.G1!>!>!): kotlin.Unit + public abstract fun f46(/*0*/ p0: test.G1!): kotlin.Unit + public abstract fun f47(/*0*/ p0: test.G1..@test.A kotlin.Array?)>!>!): kotlin.Unit + public abstract fun f48(/*0*/ p0: test.G2!>!>!): kotlin.Unit + public abstract fun f49(/*0*/ p0: test.G1!>!>!>!>!>!, /*1*/ p1: test.G1..@test.A kotlin.Array?)>!>!, /*2*/ p2: test.G2!>!>!): kotlin.Unit + public abstract fun f5(/*0*/ p0: test.G1!>!>!>!): kotlin.Unit + public abstract fun f50(/*0*/ p0: test.G1..@test.A kotlin.Array?)>!>!): kotlin.Unit + public abstract fun f51(/*0*/ p0: test.G1..@test.A kotlin.Array?)>!>!>!, test.G1..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)>!>!>!): kotlin.Unit + public abstract fun f52(/*0*/ p0: test.G1!>!>..@test.A kotlin.Array!>!>?)>!, test.G1!>!>!>!): kotlin.Unit + public abstract fun f53(/*0*/ p0: test.G1..@test.A kotlin.Array?)>!): kotlin.Unit + public abstract fun f54(/*0*/ p0: test.G1!>!>..@test.A kotlin.Array!>!>?)>!, test.G1!>!>!>!, /*1*/ p1: test.G1<(@test.A kotlin.Array<(@test.A kotlin.Array..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)>!, /*2*/ p2: kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) (@test.A kotlin.Array<@test.A kotlin.Any!>..@test.A kotlin.Array?)>!>!>!>!, /*3*/ p3: @test.A kotlin.IntArray!, /*4*/ p4: test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f55(/*0*/ vararg p0: @test.A kotlin.String! /*kotlin.Array<(out) @test.A kotlin.String!>!*/): kotlin.Unit + public abstract fun f56(/*0*/ vararg p0: kotlin.String! /*(@test.A kotlin.Array..@test.A kotlin.Array?)*/): kotlin.Unit + public abstract fun f57(/*0*/ vararg p0: @test.A kotlin.String! /*(@test.A kotlin.Array<@test.A kotlin.String!>..@test.A kotlin.Array?)*/): kotlin.Unit + public abstract fun f58(/*0*/ vararg p0: kotlin.Int /*kotlin.IntArray!*/): kotlin.Unit + public abstract fun f59(/*0*/ vararg p0: kotlin.Int /*@test.A kotlin.IntArray!*/): kotlin.Unit + public abstract fun f6(/*0*/ p0: test.G1!, /*1*/ p1: test.G1!>!>!>!): kotlin.Unit + public abstract fun f60(/*0*/ vararg p0: kotlin.Int /*@test.A kotlin.IntArray!*/): kotlin.Unit + public abstract fun f61(/*0*/ vararg p0: kotlin.Array<(out) @test.A kotlin.String!>! /*kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.String!>!>!*/): kotlin.Unit + public abstract fun f62(/*0*/ vararg p0: kotlin.Array<(out) kotlin.String!>! /*(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)*/): kotlin.Unit + public abstract fun f63(/*0*/ vararg p0: (@test.A kotlin.Array..@test.A kotlin.Array?) /*kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!*/): kotlin.Unit + public abstract fun f64(/*0*/ vararg p0: (@test.A kotlin.Array<@test.A kotlin.String!>..@test.A kotlin.Array?) /*(@test.A kotlin.Array<(@test.A kotlin.Array<@test.A kotlin.String!>..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)*/): kotlin.Unit + public abstract fun f65(/*0*/ vararg p0: kotlin.IntArray! /*kotlin.Array<(out) kotlin.IntArray!>!*/): kotlin.Unit + public abstract fun f66(/*0*/ vararg p0: kotlin.IntArray! /*(@test.A kotlin.Array..@test.A kotlin.Array?)*/): kotlin.Unit + public abstract fun f67(/*0*/ vararg p0: @test.A kotlin.IntArray! /*kotlin.Array<(out) @test.A kotlin.IntArray!>!*/): kotlin.Unit + public abstract fun f68(/*0*/ vararg p0: @test.A kotlin.IntArray! /*(@test.A kotlin.Array<@test.A kotlin.IntArray!>..@test.A kotlin.Array?)*/): kotlin.Unit + public abstract fun f69(/*0*/ vararg p0: kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.String!>!>! /*kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.String!>!>!>!*/): kotlin.Unit + public abstract fun f7(/*0*/ p0: test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f70(/*0*/ vararg p0: (@test.A kotlin.Array!>..@test.A kotlin.Array!>?) /*kotlin.Array<(out) (@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>!*/): kotlin.Unit + public abstract fun f71(/*0*/ vararg p0: kotlin.Array<(out) kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!>! /*kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!>!>!*/): kotlin.Unit + public abstract fun f72(/*0*/ vararg p0: kotlin.Array<(out) (@test.A kotlin.Array<(@test.A kotlin.Array<@test.A kotlin.String!>..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)>! /*(@test.A kotlin.Array..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)>!>..@test.A kotlin.Array..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)>!>?)*/): kotlin.Unit + public abstract fun f73(/*0*/ vararg p0: (@test.A kotlin.Array..@test.A kotlin.Array?) /*kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!*/): kotlin.Unit + public abstract fun f74(/*0*/ vararg p0: kotlin.Array<(out) kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!>! /*(@test.A kotlin.Array..@test.A kotlin.Array?)>!>!>..@test.A kotlin.Array..@test.A kotlin.Array?)>!>!>?)*/): kotlin.Unit + public abstract fun f75(/*0*/ vararg p0: kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.IntArray!>!>! /*kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.IntArray!>!>!>!*/): kotlin.Unit + public abstract fun f76(/*0*/ vararg p0: kotlin.Array<(out) @test.A kotlin.IntArray!>! /*(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)*/): kotlin.Unit + public abstract fun f8(/*0*/ p0: test.G1!): kotlin.Unit + public abstract fun f9(/*0*/ p0: test.G1!>!>!>!): kotlin.Unit + + public open class Test { + public constructor Test(/*0*/ p0: test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>!, /*1*/ p1: kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!, /*2*/ p2: kotlin.Array<(out) @test.A kotlin.IntArray!>!, /*3*/ p3: (@test.A kotlin.Array<(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>..@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>?), /*4*/ vararg p4: kotlin.Array<(out) @test.A kotlin.IntArray!>! /*(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)*/) + } +} diff --git a/compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.java b/compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.java new file mode 100644 index 00000000000..65420a47763 --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.java @@ -0,0 +1,22 @@ +// JAVAC_EXPECTED_FILE +package test; + +import java.lang.annotation.*; +public class Basic { + @Target(ElementType.TYPE_PARAMETER) + public @interface A { + String value() default ""; + } + + public interface G<@A T> { + <@A("abc") R> void foo(R r); + } + + public interface G1 { + void foo(R r); + } + + void foo(R r) { + + } +} diff --git a/compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.txt b/compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.javac.txt similarity index 54% rename from compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.txt rename to compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.javac.txt index 1be3aa442f1..a9887657d0a 100644 --- a/compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.txt +++ b/compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.javac.txt @@ -1,14 +1,14 @@ package test -public open class TypeParameterAnnotations { - public constructor TypeParameterAnnotations() +public open class Basic { + public constructor Basic() @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) public final annotation class A : kotlin.Annotation { public constructor A(/*0*/ value: kotlin.String = ...) public final val value: kotlin.String } - public interface G { - public abstract fun foo(/*0*/ p0: R!): kotlin.Unit + public interface G { + public abstract fun foo(/*0*/ r: R!): kotlin.Unit } } diff --git a/compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.runtime.txt b/compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.runtime.txt new file mode 100644 index 00000000000..2a256fb0fdf --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.runtime.txt @@ -0,0 +1,14 @@ +package test + +public open class Basic { + public constructor Basic() + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) @kotlin.annotation.Retention(value = ...) public final annotation class A : kotlin.Annotation { + public final val value: kotlin.String + public final fun (): kotlin.String + } + + public interface G { + public abstract fun foo(/*0*/ R!): kotlin.Unit + } +} diff --git a/compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.txt b/compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.txt new file mode 100644 index 00000000000..462a7a3341e --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.txt @@ -0,0 +1,19 @@ +package test + +public open class Basic { + public constructor Basic() + public/*package*/ open fun foo(/*0*/ r: R!): kotlin.Unit + + @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) public final annotation class A : kotlin.Annotation { + public constructor A(/*0*/ value: kotlin.String = ...) + public final val value: kotlin.String + } + + public interface G { + public abstract fun foo(/*0*/ r: R!): kotlin.Unit + } + + public interface G1 { + public abstract fun foo(/*0*/ r: R!): kotlin.Unit + } +} diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/BaseClassTypeArguments.java b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/BaseClassTypeArguments.java new file mode 100644 index 00000000000..b99084103bc --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/BaseClassTypeArguments.java @@ -0,0 +1,26 @@ +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +interface I1 {} +interface I2 {} +interface I3 {} + +class A2 {} +class A3 {} + +public class BaseClassTypeArguments extends A3<@A B [][][][][], I1>, A2> implements I1<@A Integer @A [][][]>, I2<@A B, B>, I3<@A B [][][][][], B, @A B> { + class ImplementedInterfacesTypeArguments implements I1, I1<@A int [] @A []>>>, I2<@A B, B>, I3<@A B [][][][][], I1>, I2> { + public class BaseClassTypeArguments1 extends A3<@A B [][][][][], I1>, A2> { + + } + } + static class BaseClassTypeArguments2 extends A3<@A B [][][][][], I1>, A2> { + + } +} \ No newline at end of file diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/BaseClassTypeArguments.txt b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/BaseClassTypeArguments.txt new file mode 100644 index 00000000000..09f9e522c1c --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/BaseClassTypeArguments.txt @@ -0,0 +1,17 @@ +package test + +public open class BaseClassTypeArguments : test.A3!>!>!>!>!, test.I1!>!>!, test.A2!>..@test.A kotlin.Array!>?)>!>, test.I1..@test.A kotlin.Array?)>!>!>, test.I2<@test.A B!, B!>, test.I3!>!>!>!>!, B!, @test.A B!> { + public constructor BaseClassTypeArguments() + + public/*package*/ open class BaseClassTypeArguments2 : test.A3!>!>!>!>!, test.I1!>!>!, test.A2!>..@test.A kotlin.Array!>?)>!> { + public/*package*/ constructor BaseClassTypeArguments2() + } + + public/*package*/ open inner class ImplementedInterfacesTypeArguments /*captured type parameters: /*1*/ B : kotlin.Any!*/ : test.I1..@test.A kotlin.Array?)>!>!>!, test.I1<(@test.A kotlin.Array..@test.A kotlin.Array?)>!>!>, test.I2<@test.A B!, B!>, test.I3!>!>!>!>!, test.I1!>!>!, test.I2!>..@test.A kotlin.Array!>?)>!> { + public/*package*/ constructor ImplementedInterfacesTypeArguments() + + public open inner class BaseClassTypeArguments1 /*captured type parameters: /*1*/ B : kotlin.Any!, /*2*/ B : kotlin.Any!*/ : test.A3!>!>!>!>!, test.I1!>!>!, test.A2!>..@test.A kotlin.Array!>?)>!> { + public constructor BaseClassTypeArguments1() + } + } +} diff --git a/compiler/testData/loadJava8/compiledJava/TypeAnnotations.java b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/Basic.java similarity index 59% rename from compiler/testData/loadJava8/compiledJava/TypeAnnotations.java rename to compiler/testData/loadJava8/sourceJava/typeUseAnnotations/Basic.java index c62ead65755..e2309dac755 100644 --- a/compiler/testData/loadJava8/compiledJava/TypeAnnotations.java +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/Basic.java @@ -1,7 +1,7 @@ package test; import java.lang.annotation.*; -public class TypeAnnotations { +public class Basic { @Target(ElementType.TYPE_USE) @interface A { String value() default ""; @@ -13,8 +13,6 @@ public class TypeAnnotations { interface G2 { } - // Currently annotations on type parameters and arguments are not loaded from compiled code because of IDEA-153093 - // Once it will be fixed check if KT-11454 is ready to be resolved public interface MyClass { void f(G<@A String> p); diff --git a/compiler/testData/loadJava8/compiledJava/TypeAnnotations.txt b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/Basic.txt similarity index 62% rename from compiler/testData/loadJava8/compiledJava/TypeAnnotations.txt rename to compiler/testData/loadJava8/sourceJava/typeUseAnnotations/Basic.txt index 9fa9870de7f..ce0f47c771f 100644 --- a/compiler/testData/loadJava8/compiledJava/TypeAnnotations.txt +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/Basic.txt @@ -1,7 +1,7 @@ package test -public open class TypeAnnotations { - public constructor TypeAnnotations() +public open class Basic { + public constructor Basic() @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public/*package*/ final annotation class A : kotlin.Annotation { public/*package*/ constructor A(/*0*/ value: kotlin.String = ...) @@ -15,7 +15,7 @@ public open class TypeAnnotations { } public interface MyClass { - public abstract fun f(/*0*/ p0: test.TypeAnnotations.G2!): kotlin.Unit - public abstract fun f(/*0*/ p0: test.TypeAnnotations.G!): kotlin.Unit + public abstract fun f(/*0*/ p: test.Basic.G2<@test.Basic.A kotlin.String!, @test.Basic.A(value = "abc") kotlin.Int!>!): kotlin.Unit + public abstract fun f(/*0*/ p: test.Basic.G<@test.Basic.A kotlin.String!>!): kotlin.Unit } } diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ClassTypeParameterBounds.java b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ClassTypeParameterBounds.java new file mode 100644 index 00000000000..e8ed265b044 --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ClassTypeParameterBounds.java @@ -0,0 +1,33 @@ +// JAVAC_EXPECTED_FILE + +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +public class ClassTypeParameterBounds { + interface I1 {} + interface I2 {} + interface I3 {} + interface I4 {} + + interface G1 { } + class G2<_A, B extends @A Integer> { } + interface G3<_A, B extends Object & @A I1> { } + class G4<_A extends @A B, B> { } + interface G5<_A, B extends @A _A> { } + class G6<_A extends @A I1, B, C, D extends @A E, E, F> { } + interface G7<_A extends Object & I2<@A Integer> & @A I3> { } + interface G8<_A extends Object & I2 & @A I3> { } + + interface G9<_A extends I4 & I2 & @A I3> { } + interface G10<_A extends I4 & I2 & @A I3> { } + interface G11<_A extends I4 & I2 & @A I3> { } + interface G12<_A extends I4 & I2 & @A I3> { } + + // class G13<_A extends Object, B extends I3<@A _A> & @A I2<_A>> { } +} diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ClassTypeParameterBounds.txt b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ClassTypeParameterBounds.txt new file mode 100644 index 00000000000..7cb5d93800e --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ClassTypeParameterBounds.txt @@ -0,0 +1,56 @@ +package test + +public open class ClassTypeParameterBounds { + public constructor ClassTypeParameterBounds() + + public/*package*/ interface G1 { + } + + public/*package*/ interface G10!> where _A : test.ClassTypeParameterBounds.I2!, _A : @test.A test.ClassTypeParameterBounds.I3! { + } + + public/*package*/ interface G11!>!>..@test.A kotlin.Array!>!>?)>!> where _A : test.ClassTypeParameterBounds.I2..@test.A kotlin.Array?)>!>!>!>!, _A : @test.A test.ClassTypeParameterBounds.I3!>..@test.A kotlin.Array!>?)>! { + } + + public/*package*/ interface G12!>!> where _A : test.ClassTypeParameterBounds.I2!>..@test.A kotlin.Array!>?)>!, _A : @test.A test.ClassTypeParameterBounds.I3..@test.A kotlin.Array?)>!>! { + } + + public/*package*/ open inner class G2 { + public/*package*/ constructor G2() + } + + public/*package*/ interface G3 where B : @test.A test.ClassTypeParameterBounds.I1! { + } + + public/*package*/ open inner class G4 { + public/*package*/ constructor G4() + } + + public/*package*/ interface G5 { + } + + public/*package*/ open inner class G6 { + public/*package*/ constructor G6() + } + + public/*package*/ interface G7 where _A : test.ClassTypeParameterBounds.I2<@test.A kotlin.Int!>!, _A : @test.A test.ClassTypeParameterBounds.I3! { + } + + public/*package*/ interface G8 where _A : test.ClassTypeParameterBounds.I2!, _A : @test.A test.ClassTypeParameterBounds.I3! { + } + + public/*package*/ interface G9..@test.A kotlin.Array?)>!> where _A : test.ClassTypeParameterBounds.I2..@test.A kotlin.Array?)>!, _A : @test.A test.ClassTypeParameterBounds.I3..@test.A kotlin.Array?)>! { + } + + public/*package*/ interface I1 { + } + + public/*package*/ interface I2 { + } + + public/*package*/ interface I3 { + } + + public/*package*/ interface I4 { + } +} diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodReceiver.java b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodReceiver.java new file mode 100644 index 00000000000..c26e08c0b33 --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodReceiver.java @@ -0,0 +1,23 @@ +// JAVAC_EXPECTED_FILE + +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +/* + * Note that a receiver type doesn't get into signatures used by the Kotlin compiler + * So in this test, annotated types shouldn't be reflected in the signatures dump + */ + +public class MethodReceiver { + public void f1(MethodReceiver<@A T> this) { } + + class MethodReceiver3 { + public void f1(@A MethodReceiver3<@A T, K, @A L> this) { } + } +} \ No newline at end of file diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodReceiver.txt b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodReceiver.txt new file mode 100644 index 00000000000..1964dcde5ba --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodReceiver.txt @@ -0,0 +1,11 @@ +package test + +public open class MethodReceiver { + public constructor MethodReceiver() + public open fun f1(): kotlin.Unit + + public/*package*/ open inner class MethodReceiver3 /*captured type parameters: /*3*/ T : kotlin.Any!*/ { + public/*package*/ constructor MethodReceiver3() + public open fun f1(): kotlin.Unit + } +} diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.java b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.java new file mode 100644 index 00000000000..1ddc625116a --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.java @@ -0,0 +1,33 @@ +// JAVAC_EXPECTED_FILE + +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +abstract class MethodTypeParameterBounds { + interface I1 {} + interface I2 {} + interface I3 {} + interface I4 {} + + void f1(T x) { } + <_A, B extends @A Integer> void f2(_A x, B y) { } + <_A, B extends Object & @A I1> void f3(_A x, B y) { } + <_A extends @A B, B> void f4(_A x, B y) { } + <_A, B extends @A _A> void f5(_A x, B y) { } + <_A extends @A I1> void f6() { } + abstract <_A, B extends @A _A> void f7(_A x, B y); + abstract <_A extends @A I1, B, C, D extends @A E, E, F> void f8(_A x1, B x2, C x3, D x4, E x5, F x6); + <_A extends Object & I2<@A Integer> & @A I3> void f9(_A x) { } + <_A extends Object & I2 & @A I3> void f10(_A x) { } + <_A extends I4 & I2 & @A I3> void f11(_A x) { } + <_A extends I4 & I2 & @A I3> void f12(_A x) { } + <_A extends I4 & I2 & @A I3> void f13(_A x) { } + abstract <_A extends I4 & I2 & @A I3> void f14(_A x); + <_A extends Object, B extends I3<@A A> & @A I2> void f15(_A x) { } +} diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.txt b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.txt new file mode 100644 index 00000000000..8189a35c39f --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.txt @@ -0,0 +1,32 @@ +package test + +public/*package*/ abstract class MethodTypeParameterBounds { + public/*package*/ constructor MethodTypeParameterBounds() + public/*package*/ open fun f1(/*0*/ x: T!): kotlin.Unit + public/*package*/ open fun f10(/*0*/ x: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!, _A : @test.A test.MethodTypeParameterBounds.I3! + public/*package*/ open fun ..@test.A kotlin.Array?)>!> f11(/*0*/ x: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2..@test.A kotlin.Array?)>!, _A : @test.A test.MethodTypeParameterBounds.I3..@test.A kotlin.Array?)>! + public/*package*/ open fun !> f12(/*0*/ x: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!, _A : @test.A test.MethodTypeParameterBounds.I3! + public/*package*/ open fun !>!>..@test.A kotlin.Array!>!>?)>!> f13(/*0*/ x: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2..@test.A kotlin.Array?)>!>!>!>!, _A : @test.A test.MethodTypeParameterBounds.I3!>..@test.A kotlin.Array!>?)>! + public/*package*/ abstract fun !>!> f14(/*0*/ x: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2!>..@test.A kotlin.Array!>?)>!, _A : @test.A test.MethodTypeParameterBounds.I3..@test.A kotlin.Array?)>!>! + public/*package*/ open fun !> f15(/*0*/ x: _A!): kotlin.Unit where B : @test.A test.MethodTypeParameterBounds.I2! + public/*package*/ open fun f2(/*0*/ x: _A!, /*1*/ y: B!): kotlin.Unit + public/*package*/ open fun f3(/*0*/ x: _A!, /*1*/ y: B!): kotlin.Unit where B : @test.A test.MethodTypeParameterBounds.I1! + public/*package*/ open fun f4(/*0*/ x: _A!, /*1*/ y: B!): kotlin.Unit + public/*package*/ open fun f5(/*0*/ x: _A!, /*1*/ y: B!): kotlin.Unit + public/*package*/ open fun f6(): kotlin.Unit + public/*package*/ abstract fun f7(/*0*/ x: _A!, /*1*/ y: B!): kotlin.Unit + public/*package*/ abstract fun f8(/*0*/ x1: _A!, /*1*/ x2: B!, /*2*/ x3: C!, /*3*/ x4: D!, /*4*/ x5: E!, /*5*/ x6: F!): kotlin.Unit + public/*package*/ open fun f9(/*0*/ x: _A!): kotlin.Unit where _A : test.MethodTypeParameterBounds.I2<@test.A kotlin.Int!>!, _A : @test.A test.MethodTypeParameterBounds.I3! + + public/*package*/ interface I1 { + } + + public/*package*/ interface I2 { + } + + public/*package*/ interface I3 { + } + + public/*package*/ interface I4 { + } +} diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ReturnType.java b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ReturnType.java new file mode 100644 index 00000000000..5c223aef06f --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ReturnType.java @@ -0,0 +1,95 @@ +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +interface G0 { } +interface G1 { } +interface G2 { } + +interface ReturnType { + // simplpe type arguments + G1<@A G0> f0(); + G1>>> f1(); + G1<@A String> f2(); + G2<@A String, G2<@A("abc") Integer, G2<@A("abc") G2, @A("abc") Integer>>> f3(); + + // wildcards + G1 f4 = null; + G1>>> f5(); + G1 f6(); + G2, ? extends @A("abc") Integer>>> f7(); + + G1 f8(); + G1>>> f9(); + G1 f10 = null; + G2, ? super @A("abc") Integer>>> f11(); + + G2, ? extends @A("abc") Integer>>> f12 = null; + + // arrays + Integer @A [] f13(); + int @A [] f14(); + @A Integer [] f15(); + @A int [] f16(); + @A Integer @A [] f17(); + @A int @A [] f18 = null; + + // multidementional arrays + Integer @A [] [] f19(); + int @A [] @A [] f20(); + @A Integer [] [] [] f21 = null; + @A int @A [] @A [] [] @A [] f22(); + @A Integer @A [] [] @A [] [] f23(); + @A int @A [] @A [] f24 = null; + int [] @A [] f25(); + Object [] @A [] f26(); + @A Object [] [] [] [] @A [] f27(); + + // arrays in type arguments + G1 f28(); + G2 f29(); + G1<@A Integer []> f30(); + G1> f31(); + G1, G1<@A int @A []>>> f32(); + G1<@A int @A []> f33(); + G1 f34(); + G2 f35 = null; + G1<@A Integer @A [] []> f36(); + G1> f37(); + G1, G1<@A int [] [] @A []>>> f38(); + G1<@A int @A [] @A [] []> f39(); + + // arrays in wildcard bounds + G1 f40(); + G2 f41(); + G1 f42(); + G1> f43(); + G1, G1>> f44(); + G1, G1>> f45 = null; + G1 f46(); + G1 f47(); + G2 f48 = null; + G1 f49(); + G1> f50(); + G1, G1>> f51(); + G1, G1>> f52 = null; + G1 f53(); + + class ReturnType2 { + G1 f4 = null; + G1 f10 = null; + G2, ? extends @A("abc") Integer>>> f12 = null; + @A int @A [] f18 = null; + @A Integer [] [] [] f21 = null; + @A int @A [] @A [] f24 = null; + G2 f35 = null; + G1, G1>> f45 = null; + G2 f48 = null; + G1, G1>> f52 = null; + } +} diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ReturnType.txt b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ReturnType.txt new file mode 100644 index 00000000000..923b2caa9a1 --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ReturnType.txt @@ -0,0 +1,74 @@ +package test + +public/*package*/ interface ReturnType { + public abstract fun f0(): test.G1<@test.A test.G0!>! + public abstract fun f1(): test.G1!>!>!>! + public abstract fun f11(): test.G2!, in @test.A(value = "abc") kotlin.Int!>!>!>! + public abstract fun f13(): (@test.A kotlin.Array..@test.A kotlin.Array?) + public abstract fun f14(): @test.A kotlin.IntArray! + @test.A public abstract fun f15(): kotlin.Array<(out) @test.A kotlin.Int!>! + @test.A public abstract fun f16(): kotlin.IntArray! + @test.A public abstract fun f17(): (@test.A kotlin.Array<@test.A kotlin.Int!>..@test.A kotlin.Array?) + public abstract fun f19(): kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>! + public abstract fun f2(): test.G1<@test.A kotlin.String!>! + public abstract fun f20(): (@test.A kotlin.Array<@test.A kotlin.IntArray!>..@test.A kotlin.Array?) + @test.A public abstract fun f22(): (@test.A kotlin.Array..@test.A kotlin.Array?)>!>..@test.A kotlin.Array..@test.A kotlin.Array?)>!>?) + @test.A public abstract fun f23(): kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!>..@test.A kotlin.Array..@test.A kotlin.Array?)>!>?)>! + public abstract fun f25(): (@test.A kotlin.Array..@test.A kotlin.Array?) + public abstract fun f26(): (@test.A kotlin.Array!>..@test.A kotlin.Array!>?) + @test.A public abstract fun f27(): (@test.A kotlin.Array!>!>!>!>..@test.A kotlin.Array!>!>!>!>?) + public abstract fun f28(): test.G1<(@test.A kotlin.Array..@test.A kotlin.Array?)>! + public abstract fun f29(): test.G2! + public abstract fun f3(): test.G2<@test.A kotlin.String!, test.G2<@test.A(value = "abc") kotlin.Int!, test.G2<@test.A(value = "abc") test.G2!, @test.A(value = "abc") kotlin.Int!>!>!>! + public abstract fun f30(): test.G1!>! + public abstract fun f31(): test.G1!>! + public abstract fun f32(): test.G1..@test.A kotlin.Array?)>!, test.G1<@test.A kotlin.IntArray!>!>!>! + public abstract fun f33(): test.G1<@test.A kotlin.IntArray!>! + public abstract fun f34(): test.G1<(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>! + public abstract fun f36(): test.G1..@test.A kotlin.Array?)>!>! + public abstract fun f37(): test.G1!>!>!>! + public abstract fun f38(): test.G1..@test.A kotlin.Array?)>!, test.G1<(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>!>!>! + public abstract fun f39(): test.G1..@test.A kotlin.Array?)>!>! + public abstract fun f40(): test.G1..@test.A kotlin.Array?)>! + public abstract fun f41(): test.G2! + public abstract fun f42(): test.G1!>! + public abstract fun f43(): test.G1!>! + public abstract fun f44(): test.G1..@test.A kotlin.Array?)>!, test.G1!>!>! + public abstract fun f46(): test.G1! + public abstract fun f47(): test.G1!>..@test.A kotlin.Array!>?)>! + public abstract fun f49(): test.G1!>!>!>!>!>! + public abstract fun f5(): test.G1!>!>!>! + public abstract fun f50(): test.G1!>!>! + public abstract fun f51(): test.G1!>!>..@test.A kotlin.Array!>!>?)>!, test.G1..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)>!>!>! + public abstract fun f53(): test.G1!>! + public abstract fun f6(): test.G1! + public abstract fun f7(): test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>! + public abstract fun f8(): test.G1! + public abstract fun f9(): test.G1!>!>!>! + + public open class ReturnType2 { + public constructor ReturnType2() + public/*package*/ final var f10: test.G1! + public/*package*/ final var f12: test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>! + @test.A public/*package*/ final var f18: @test.A kotlin.IntArray! + @test.A public/*package*/ final var f21: kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.Int!>!>!>! + @test.A public/*package*/ final var f24: (@test.A kotlin.Array<@test.A kotlin.IntArray!>..@test.A kotlin.Array?) + public/*package*/ final var f35: test.G2!>! + public/*package*/ final var f4: test.G1! + public/*package*/ final var f45: test.G1..@test.A kotlin.Array?)>!, test.G1!>!>! + public/*package*/ final var f48: test.G2!>..@test.A kotlin.Array!>?)>! + public/*package*/ final var f52: test.G1..@test.A kotlin.Array?)>!>!>!, test.G1..@test.A kotlin.Array?)>!>!>! + } + + // Static members + public final val f10: test.G1! + public final val f12: test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>! + @test.A public final val f18: @test.A kotlin.IntArray! + @test.A public final val f21: kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.Int!>!>!>! + @test.A public final val f24: (@test.A kotlin.Array<@test.A kotlin.IntArray!>..@test.A kotlin.Array?) + public final val f35: test.G2!>! + public final val f4: test.G1! + public final val f45: test.G1..@test.A kotlin.Array?)>!, test.G1!>!>! + public final val f48: test.G2!>..@test.A kotlin.Array!>?)>! + public final val f52: test.G1..@test.A kotlin.Array?)>!>!>!, test.G1..@test.A kotlin.Array?)>!>!>! +} diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ValueArguments.java b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ValueArguments.java new file mode 100644 index 00000000000..8d54ff5550d --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ValueArguments.java @@ -0,0 +1,117 @@ +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +interface G0 { } +interface G1 { } +interface G2 { } + +interface ValueArguments { + // simplpe type arguments + void f0(G1<@A G0> p); + void f1(G1>>> p); + void f2(G1<@A String> p); + void f3(G2<@A String, G2<@A("abc") Integer, G2<@A("abc") G2, @A("abc") Integer>>> p); + + // wildcards + void f4(G1 p); + void f5(G1>>> p); + void f6(G1 p1, G1>>> p2); + void f7(G2, ? extends @A("abc") Integer>>> p); + + void f8(G1 p); + void f9(G1>>> p); + void f10(G1 p); + void f11(G2, ? super @A("abc") Integer>>> p); + + void f12(G2, ? extends @A("abc") Integer>>> p); + + // arrays + void f13(Integer @A [] p); + void f14(int @A [] p); + void f15(@A Integer [] p); + void f16(@A int [] p); + void f17(@A Integer @A [] p); + void f18(@A int @A [] p1, Integer @A [] p2, @A int [] p3); + + // multidementional arrays + void f19(Integer @A [] [] p); + void f20(int @A [] @A [] p); + void f21(@A Integer [] [] [] p); + void f22(@A int @A [] @A [] [] @A [] p); + void f23(@A Integer @A [] [] @A [] [] p); + void f24(@A int @A [] @A [] p); + void f25(int [] @A [] p); + void f26(Object [] @A [] p1, int [] @A [] p2, @A int @A [] @A [] [] @A [] p3); + void f27(@A Object [] [] [] [] @A [] p); + + // arrays in type arguments + void f28(G1 p); + void f29(G2 p); + void f30(G1<@A Integer []> p); + void f31(G1> p); + void f32(G1, G1<@A int @A []>>> p); + void f33(G1<@A int @A []> p); + void f34(G1 p); + void f35(G2 p1, G1<@A Integer @A [] []> p2, G1> p3); + void f36(G1<@A Integer @A [] []> p); + void f37(G1> p); + void f38(G1, G1<@A int [] [] @A []>>> p); + void f39(G1<@A int @A [] @A [] []> p); + + // arrays in wildcard bounds + void f40(G1 p); + void f41(G2 p); + void f42(G1 p); + void f43(G1> p); + void f44(G1, G1>> p); + void f45(G1, G1>> p); + void f46(G1 p); + void f47(G1 p); + void f48(G2 p); + void f49(G1 p1, G1> p2, G2 p3); + void f50(G1> p); + void f51(G1, G1>> p); + void f52(G1, G1>> p); + void f53(G1 p); + + void f54(G1, G1>> p1, G1<@A int @A [] @A [] []> p2, @A Object [] [] [] [] @A [] p3, @A int @A [] p4, G2, ? extends @A("abc") Integer>>> p5); + + // varargs + void f55(@A String ... x); + void f56(String @A ... x); + void f57(@A String @A ... x); + void f58(@A int ... x); + void f59(int @A ... x); + void f60(@A int @A ... x); + + // varargs + arrays + void f61(@A String [] ... x); + void f62(String @A [] ... x); + void f63(String [] @A ... x); + void f64(@A String @A [] @A ... x); + void f65(@A int [] ... x); + void f66(int @A [] ... x); + void f67(int [] @A ... x); + void f68(@A int @A [] @A ... x); + + void f69(@A String [] [] ... x); + void f70(String [] @A [] ... x); + void f71(String [] [] [] @A ... x); + void f72(@A String @A [] [] @A [] @A ... x); + void f73(@A int [] @A [] ... x); + void f74(int @A [][][] @A [] ... x); + void f75(int [] [] [] @A ... x); + void f76(@A int @A [] [] @A ... x); + + class Test { + public Test(G2, ? extends @A("abc") Integer>>> p1, Object [] @A [] p2, int [] @A [] p3, @A int @A [] @A [] [] @A [] p4, @A int @A [] [] @A ... p5) { + + } + } +} diff --git a/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ValueArguments.txt b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ValueArguments.txt new file mode 100644 index 00000000000..96ff61a326e --- /dev/null +++ b/compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ValueArguments.txt @@ -0,0 +1,85 @@ +package test + +public/*package*/ interface ValueArguments { + public abstract fun f0(/*0*/ p: test.G1<@test.A test.G0!>!): kotlin.Unit + public abstract fun f1(/*0*/ p: test.G1!>!>!>!): kotlin.Unit + public abstract fun f10(/*0*/ p: test.G1!): kotlin.Unit + public abstract fun f11(/*0*/ p: test.G2!, in @test.A(value = "abc") kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f12(/*0*/ p: test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f13(/*0*/ p: (@test.A kotlin.Array..@test.A kotlin.Array?)): kotlin.Unit + public abstract fun f14(/*0*/ p: @test.A kotlin.IntArray!): kotlin.Unit + public abstract fun f15(/*0*/ @test.A p: kotlin.Array<(out) @test.A kotlin.Int!>!): kotlin.Unit + public abstract fun f16(/*0*/ @test.A p: kotlin.IntArray!): kotlin.Unit + public abstract fun f17(/*0*/ @test.A p: (@test.A kotlin.Array<@test.A kotlin.Int!>..@test.A kotlin.Array?)): kotlin.Unit + public abstract fun f18(/*0*/ @test.A p1: @test.A kotlin.IntArray!, /*1*/ p2: (@test.A kotlin.Array..@test.A kotlin.Array?), /*2*/ @test.A p3: kotlin.IntArray!): kotlin.Unit + public abstract fun f19(/*0*/ p: kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!): kotlin.Unit + public abstract fun f2(/*0*/ p: test.G1<@test.A kotlin.String!>!): kotlin.Unit + public abstract fun f20(/*0*/ p: (@test.A kotlin.Array<@test.A kotlin.IntArray!>..@test.A kotlin.Array?)): kotlin.Unit + public abstract fun f21(/*0*/ @test.A p: kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f22(/*0*/ @test.A p: (@test.A kotlin.Array..@test.A kotlin.Array?)>!>..@test.A kotlin.Array..@test.A kotlin.Array?)>!>?)): kotlin.Unit + public abstract fun f23(/*0*/ @test.A p: kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!>..@test.A kotlin.Array..@test.A kotlin.Array?)>!>?)>!): kotlin.Unit + public abstract fun f24(/*0*/ @test.A p: (@test.A kotlin.Array<@test.A kotlin.IntArray!>..@test.A kotlin.Array?)): kotlin.Unit + public abstract fun f25(/*0*/ p: (@test.A kotlin.Array..@test.A kotlin.Array?)): kotlin.Unit + public abstract fun f26(/*0*/ p1: (@test.A kotlin.Array!>..@test.A kotlin.Array!>?), /*1*/ p2: (@test.A kotlin.Array..@test.A kotlin.Array?), /*2*/ @test.A p3: (@test.A kotlin.Array..@test.A kotlin.Array?)>!>..@test.A kotlin.Array..@test.A kotlin.Array?)>!>?)): kotlin.Unit + public abstract fun f27(/*0*/ @test.A p: (@test.A kotlin.Array!>!>!>!>..@test.A kotlin.Array!>!>!>!>?)): kotlin.Unit + public abstract fun f28(/*0*/ p: test.G1<(@test.A kotlin.Array..@test.A kotlin.Array?)>!): kotlin.Unit + public abstract fun f29(/*0*/ p: test.G2!): kotlin.Unit + public abstract fun f3(/*0*/ p: test.G2<@test.A kotlin.String!, test.G2<@test.A(value = "abc") kotlin.Int!, test.G2<@test.A(value = "abc") test.G2!, @test.A(value = "abc") kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f30(/*0*/ p: test.G1!>!): kotlin.Unit + public abstract fun f31(/*0*/ p: test.G1!>!): kotlin.Unit + public abstract fun f32(/*0*/ p: test.G1..@test.A kotlin.Array?)>!, test.G1<@test.A kotlin.IntArray!>!>!>!): kotlin.Unit + public abstract fun f33(/*0*/ p: test.G1<@test.A kotlin.IntArray!>!): kotlin.Unit + public abstract fun f34(/*0*/ p: test.G1<(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>!): kotlin.Unit + public abstract fun f35(/*0*/ p1: test.G2!>!, /*1*/ p2: test.G1..@test.A kotlin.Array?)>!>!, /*2*/ p3: test.G1!>!): kotlin.Unit + public abstract fun f36(/*0*/ p: test.G1..@test.A kotlin.Array?)>!>!): kotlin.Unit + public abstract fun f37(/*0*/ p: test.G1!>!>!>!): kotlin.Unit + public abstract fun f38(/*0*/ p: test.G1..@test.A kotlin.Array?)>!, test.G1<(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>!>!>!): kotlin.Unit + public abstract fun f39(/*0*/ p: test.G1..@test.A kotlin.Array?)>!>!): kotlin.Unit + public abstract fun f4(/*0*/ p: test.G1!): kotlin.Unit + public abstract fun f40(/*0*/ p: test.G1..@test.A kotlin.Array?)>!): kotlin.Unit + public abstract fun f41(/*0*/ p: test.G2!): kotlin.Unit + public abstract fun f42(/*0*/ p: test.G1!>!): kotlin.Unit + public abstract fun f43(/*0*/ p: test.G1!>!): kotlin.Unit + public abstract fun f44(/*0*/ p: test.G1..@test.A kotlin.Array?)>!, test.G1!>!>!): kotlin.Unit + public abstract fun f45(/*0*/ p: test.G1..@test.A kotlin.Array?)>!, test.G1!>!>!): kotlin.Unit + public abstract fun f46(/*0*/ p: test.G1!): kotlin.Unit + public abstract fun f47(/*0*/ p: test.G1!>..@test.A kotlin.Array!>?)>!): kotlin.Unit + public abstract fun f48(/*0*/ p: test.G2!>..@test.A kotlin.Array!>?)>!): kotlin.Unit + public abstract fun f49(/*0*/ p1: test.G1!>!>!>!>!>!, /*1*/ p2: test.G1!>!>!, /*2*/ p3: test.G2!>..@test.A kotlin.Array!>?)>!): kotlin.Unit + public abstract fun f5(/*0*/ p: test.G1!>!>!>!): kotlin.Unit + public abstract fun f50(/*0*/ p: test.G1!>!>!): kotlin.Unit + public abstract fun f51(/*0*/ p: test.G1!>!>..@test.A kotlin.Array!>!>?)>!, test.G1..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)>!>!>!): kotlin.Unit + public abstract fun f52(/*0*/ p: test.G1..@test.A kotlin.Array?)>!>!>!, test.G1..@test.A kotlin.Array?)>!>!>!): kotlin.Unit + public abstract fun f53(/*0*/ p: test.G1!>!): kotlin.Unit + public abstract fun f54(/*0*/ p1: test.G1..@test.A kotlin.Array?)>!>!>!, test.G1..@test.A kotlin.Array?)>!>!>!, /*1*/ p2: test.G1..@test.A kotlin.Array?)>!>!, /*2*/ @test.A p3: (@test.A kotlin.Array!>!>!>!>..@test.A kotlin.Array!>!>!>!>?), /*3*/ @test.A p4: @test.A kotlin.IntArray!, /*4*/ p5: test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f55(/*0*/ @test.A vararg x: @test.A kotlin.String! /*kotlin.Array<(out) @test.A kotlin.String!>!*/): kotlin.Unit + public abstract fun f56(/*0*/ vararg x: kotlin.String! /*(@test.A kotlin.Array..@test.A kotlin.Array?)*/): kotlin.Unit + public abstract fun f57(/*0*/ @test.A vararg x: @test.A kotlin.String! /*(@test.A kotlin.Array<@test.A kotlin.String!>..@test.A kotlin.Array?)*/): kotlin.Unit + public abstract fun f58(/*0*/ @test.A vararg x: kotlin.Int /*kotlin.IntArray!*/): kotlin.Unit + public abstract fun f59(/*0*/ vararg x: kotlin.Int /*@test.A kotlin.IntArray!*/): kotlin.Unit + public abstract fun f6(/*0*/ p1: test.G1!, /*1*/ p2: test.G1!>!>!>!): kotlin.Unit + public abstract fun f60(/*0*/ @test.A vararg x: kotlin.Int /*@test.A kotlin.IntArray!*/): kotlin.Unit + public abstract fun f61(/*0*/ @test.A vararg x: kotlin.Array<(out) @test.A kotlin.String!>! /*kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.String!>!>!*/): kotlin.Unit + public abstract fun f62(/*0*/ vararg x: (@test.A kotlin.Array..@test.A kotlin.Array?) /*kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!*/): kotlin.Unit + public abstract fun f63(/*0*/ vararg x: kotlin.Array<(out) kotlin.String!>! /*(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)*/): kotlin.Unit + public abstract fun f64(/*0*/ @test.A vararg x: (@test.A kotlin.Array<@test.A kotlin.String!>..@test.A kotlin.Array?) /*(@test.A kotlin.Array<(@test.A kotlin.Array<@test.A kotlin.String!>..@test.A kotlin.Array?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>?)*/): kotlin.Unit + public abstract fun f65(/*0*/ @test.A vararg x: kotlin.IntArray! /*kotlin.Array<(out) kotlin.IntArray!>!*/): kotlin.Unit + public abstract fun f66(/*0*/ vararg x: @test.A kotlin.IntArray! /*kotlin.Array<(out) @test.A kotlin.IntArray!>!*/): kotlin.Unit + public abstract fun f67(/*0*/ vararg x: kotlin.IntArray! /*(@test.A kotlin.Array..@test.A kotlin.Array?)*/): kotlin.Unit + public abstract fun f68(/*0*/ @test.A vararg x: @test.A kotlin.IntArray! /*(@test.A kotlin.Array<@test.A kotlin.IntArray!>..@test.A kotlin.Array?)*/): kotlin.Unit + public abstract fun f69(/*0*/ @test.A vararg x: kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.String!>!>! /*kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) @test.A kotlin.String!>!>!>!*/): kotlin.Unit + public abstract fun f7(/*0*/ p: test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>!): kotlin.Unit + public abstract fun f70(/*0*/ vararg x: (@test.A kotlin.Array!>..@test.A kotlin.Array!>?) /*kotlin.Array<(out) (@test.A kotlin.Array!>..@test.A kotlin.Array!>?)>!*/): kotlin.Unit + public abstract fun f71(/*0*/ vararg x: kotlin.Array<(out) kotlin.Array<(out) kotlin.Array<(out) kotlin.String!>!>!>! /*(@test.A kotlin.Array!>!>!>..@test.A kotlin.Array!>!>!>?)*/): kotlin.Unit + public abstract fun f72(/*0*/ @test.A vararg x: (@test.A kotlin.Array..@test.A kotlin.Array?)>!>..@test.A kotlin.Array..@test.A kotlin.Array?)>!>?) /*(@test.A kotlin.Array<(@test.A kotlin.Array..@test.A kotlin.Array?)>!>..@test.A kotlin.Array..@test.A kotlin.Array?)>!>?)>..@test.A kotlin.Array..@test.A kotlin.Array?)>!>..@test.A kotlin.Array..@test.A kotlin.Array?)>!>?)>?)*/): kotlin.Unit + public abstract fun f73(/*0*/ @test.A vararg x: (@test.A kotlin.Array..@test.A kotlin.Array?) /*kotlin.Array<(out) (@test.A kotlin.Array..@test.A kotlin.Array?)>!*/): kotlin.Unit + public abstract fun f74(/*0*/ vararg x: (@test.A kotlin.Array!>!>..@test.A kotlin.Array!>!>?) /*kotlin.Array<(out) (@test.A kotlin.Array!>!>..@test.A kotlin.Array!>!>?)>!*/): kotlin.Unit + public abstract fun f75(/*0*/ vararg x: kotlin.Array<(out) kotlin.Array<(out) kotlin.IntArray!>!>! /*(@test.A kotlin.Array!>!>..@test.A kotlin.Array!>!>?)*/): kotlin.Unit + public abstract fun f76(/*0*/ @test.A vararg x: kotlin.Array<(out) @test.A kotlin.IntArray!>! /*(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)*/): kotlin.Unit + public abstract fun f8(/*0*/ p: test.G1!): kotlin.Unit + public abstract fun f9(/*0*/ p: test.G1!>!>!>!): kotlin.Unit + + public open class Test { + public constructor Test(/*0*/ p1: test.G2!, out @test.A(value = "abc") kotlin.Int!>!>!>!, /*1*/ p2: (@test.A kotlin.Array!>..@test.A kotlin.Array!>?), /*2*/ p3: (@test.A kotlin.Array..@test.A kotlin.Array?), /*3*/ @test.A p4: (@test.A kotlin.Array..@test.A kotlin.Array?)>!>..@test.A kotlin.Array..@test.A kotlin.Array?)>!>?), /*4*/ @test.A vararg p5: kotlin.Array<(out) @test.A kotlin.IntArray!>! /*(@test.A kotlin.Array!>..@test.A kotlin.Array!>?)*/) + } +} diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/LoadJava8TestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/LoadJava8TestGenerated.java index 2262382181b..bb0a0cef3f3 100644 --- a/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/LoadJava8TestGenerated.java +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/LoadJava8TestGenerated.java @@ -46,14 +46,70 @@ public class LoadJava8TestGenerated extends AbstractLoadJava8Test { runTest("compiler/testData/loadJava8/compiledJava/ParameterNames.java"); } - @TestMetadata("TypeAnnotations.java") - public void testTypeAnnotations() throws Exception { - runTest("compiler/testData/loadJava8/compiledJava/TypeAnnotations.java"); + @TestMetadata("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeParameterAnnotations extends AbstractLoadJava8Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCompiledJava, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeParameterAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.java"); + } } - @TestMetadata("TypeParameterAnnotations.java") - public void testTypeParameterAnnotations() throws Exception { - runTest("compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.java"); + @TestMetadata("compiler/testData/loadJava8/compiledJava/typeUseAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeUseAnnotations extends AbstractLoadJava8Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCompiledJava, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeUseAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/compiledJava/typeUseAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("BaseClassTypeArguments.java") + public void testBaseClassTypeArguments() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.java"); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/Basic.java"); + } + + @TestMetadata("ClassTypeParameterBounds.java") + public void testClassTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.java"); + } + + @TestMetadata("MethodReceiver.java") + public void testMethodReceiver() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.java"); + } + + @TestMetadata("MethodTypeParameterBounds.java") + public void testMethodTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.java"); + } + + @TestMetadata("ReturnType.java") + public void testReturnType() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.java"); + } + + @TestMetadata("ValueArguments.java") + public void testValueArguments() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.java"); + } } } @@ -74,14 +130,75 @@ public class LoadJava8TestGenerated extends AbstractLoadJava8Test { runTest("compiler/testData/loadJava8/sourceJava/MapRemove.java"); } - @TestMetadata("TypeAnnotations.java") - public void testTypeAnnotations() throws Exception { - runTest("compiler/testData/loadJava8/sourceJava/TypeAnnotations.java"); - } - @TestMetadata("TypeParameterAnnotations.java") public void testTypeParameterAnnotations() throws Exception { runTest("compiler/testData/loadJava8/sourceJava/TypeParameterAnnotations.java"); } + + @TestMetadata("compiler/testData/loadJava8/sourceJava/typeParameterAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeParameterAnnotations extends AbstractLoadJava8Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestSourceJava, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeParameterAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/sourceJava/typeParameterAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.java"); + } + } + + @TestMetadata("compiler/testData/loadJava8/sourceJava/typeUseAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeUseAnnotations extends AbstractLoadJava8Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestSourceJava, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeUseAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/sourceJava/typeUseAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("BaseClassTypeArguments.java") + public void testBaseClassTypeArguments() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/BaseClassTypeArguments.java"); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/Basic.java"); + } + + @TestMetadata("ClassTypeParameterBounds.java") + public void testClassTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ClassTypeParameterBounds.java"); + } + + @TestMetadata("MethodReceiver.java") + public void testMethodReceiver() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodReceiver.java"); + } + + @TestMetadata("MethodTypeParameterBounds.java") + public void testMethodTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.java"); + } + + @TestMetadata("ReturnType.java") + public void testReturnType() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ReturnType.java"); + } + + @TestMetadata("ValueArguments.java") + public void testValueArguments() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ValueArguments.java"); + } + } } } diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/LoadJava8WithPsiClassReadingTestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/LoadJava8WithPsiClassReadingTestGenerated.java index b1d1f14a44e..4cf9cfb4590 100644 --- a/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/LoadJava8WithPsiClassReadingTestGenerated.java +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/LoadJava8WithPsiClassReadingTestGenerated.java @@ -44,13 +44,69 @@ public class LoadJava8WithPsiClassReadingTestGenerated extends AbstractLoadJava8 runTest("compiler/testData/loadJava8/compiledJava/ParameterNames.java"); } - @TestMetadata("TypeAnnotations.java") - public void testTypeAnnotations() throws Exception { - runTest("compiler/testData/loadJava8/compiledJava/TypeAnnotations.java"); + @TestMetadata("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeParameterAnnotations extends AbstractLoadJava8WithPsiClassReadingTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCompiledJava, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeParameterAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.java"); + } } - @TestMetadata("TypeParameterAnnotations.java") - public void testTypeParameterAnnotations() throws Exception { - runTest("compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.java"); + @TestMetadata("compiler/testData/loadJava8/compiledJava/typeUseAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeUseAnnotations extends AbstractLoadJava8WithPsiClassReadingTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCompiledJava, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeUseAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/compiledJava/typeUseAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("BaseClassTypeArguments.java") + public void testBaseClassTypeArguments() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.java"); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/Basic.java"); + } + + @TestMetadata("ClassTypeParameterBounds.java") + public void testClassTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.java"); + } + + @TestMetadata("MethodReceiver.java") + public void testMethodReceiver() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.java"); + } + + @TestMetadata("MethodTypeParameterBounds.java") + public void testMethodTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.java"); + } + + @TestMetadata("ReturnType.java") + public void testReturnType() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.java"); + } + + @TestMetadata("ValueArguments.java") + public void testValueArguments() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.java"); + } } } diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/javac/LoadJava8UsingJavacTestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/javac/LoadJava8UsingJavacTestGenerated.java index 248e50883db..6f3908dc8dc 100644 --- a/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/javac/LoadJava8UsingJavacTestGenerated.java +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/jvm/compiler/javac/LoadJava8UsingJavacTestGenerated.java @@ -46,14 +46,70 @@ public class LoadJava8UsingJavacTestGenerated extends AbstractLoadJava8UsingJava runTest("compiler/testData/loadJava8/compiledJava/ParameterNames.java"); } - @TestMetadata("TypeAnnotations.java") - public void testTypeAnnotations() throws Exception { - runTest("compiler/testData/loadJava8/compiledJava/TypeAnnotations.java"); + @TestMetadata("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeParameterAnnotations extends AbstractLoadJava8UsingJavacTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCompiledJava, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeParameterAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.java"); + } } - @TestMetadata("TypeParameterAnnotations.java") - public void testTypeParameterAnnotations() throws Exception { - runTest("compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.java"); + @TestMetadata("compiler/testData/loadJava8/compiledJava/typeUseAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeUseAnnotations extends AbstractLoadJava8UsingJavacTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestCompiledJava, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeUseAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/compiledJava/typeUseAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("BaseClassTypeArguments.java") + public void testBaseClassTypeArguments() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.java"); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/Basic.java"); + } + + @TestMetadata("ClassTypeParameterBounds.java") + public void testClassTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.java"); + } + + @TestMetadata("MethodReceiver.java") + public void testMethodReceiver() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.java"); + } + + @TestMetadata("MethodTypeParameterBounds.java") + public void testMethodTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.java"); + } + + @TestMetadata("ReturnType.java") + public void testReturnType() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.java"); + } + + @TestMetadata("ValueArguments.java") + public void testValueArguments() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.java"); + } } } @@ -74,14 +130,75 @@ public class LoadJava8UsingJavacTestGenerated extends AbstractLoadJava8UsingJava runTest("compiler/testData/loadJava8/sourceJava/MapRemove.java"); } - @TestMetadata("TypeAnnotations.java") - public void testTypeAnnotations() throws Exception { - runTest("compiler/testData/loadJava8/sourceJava/TypeAnnotations.java"); - } - @TestMetadata("TypeParameterAnnotations.java") public void testTypeParameterAnnotations() throws Exception { runTest("compiler/testData/loadJava8/sourceJava/TypeParameterAnnotations.java"); } + + @TestMetadata("compiler/testData/loadJava8/sourceJava/typeParameterAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeParameterAnnotations extends AbstractLoadJava8UsingJavacTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestSourceJava, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeParameterAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/sourceJava/typeParameterAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeParameterAnnotations/Basic.java"); + } + } + + @TestMetadata("compiler/testData/loadJava8/sourceJava/typeUseAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeUseAnnotations extends AbstractLoadJava8UsingJavacTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTestSourceJava, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeUseAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/sourceJava/typeUseAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("BaseClassTypeArguments.java") + public void testBaseClassTypeArguments() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/BaseClassTypeArguments.java"); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/Basic.java"); + } + + @TestMetadata("ClassTypeParameterBounds.java") + public void testClassTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ClassTypeParameterBounds.java"); + } + + @TestMetadata("MethodReceiver.java") + public void testMethodReceiver() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodReceiver.java"); + } + + @TestMetadata("MethodTypeParameterBounds.java") + public void testMethodTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/MethodTypeParameterBounds.java"); + } + + @TestMetadata("ReturnType.java") + public void testReturnType() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ReturnType.java"); + } + + @TestMetadata("ValueArguments.java") + public void testValueArguments() throws Exception { + runTest("compiler/testData/loadJava8/sourceJava/typeUseAnnotations/ValueArguments.java"); + } + } } } diff --git a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/structure/javaElements.kt b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/structure/javaElements.kt index 15d34def2c8..59ad273fb98 100644 --- a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/structure/javaElements.kt +++ b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/structure/javaElements.kt @@ -29,9 +29,9 @@ interface JavaNamedElement : JavaElement { interface JavaAnnotationOwner : JavaElement { val annotations: Collection - fun findAnnotation(fqName: FqName): JavaAnnotation? - val isDeprecatedInJavaDoc: Boolean + + fun findAnnotation(fqName: FqName): JavaAnnotation? } interface JavaModifierListOwner : JavaElement { @@ -56,9 +56,17 @@ interface JavaAnnotation : JavaElement { interface MapBasedJavaAnnotationOwner : JavaAnnotationOwner { val annotationsByFqName: Map + + override val isDeprecatedInJavaDoc: Boolean get() = false override fun findAnnotation(fqName: FqName) = annotationsByFqName[fqName] - override val isDeprecatedInJavaDoc: Boolean - get() = false +} + +interface ListBasedJavaAnnotationOwner : JavaAnnotationOwner { + override fun findAnnotation(fqName: FqName) = annotations.find { it.classId?.asSingleFqName() == fqName } +} + +interface MutableJavaAnnotationOwner : JavaAnnotationOwner { + override val annotations: MutableCollection } fun JavaAnnotationOwner.buildLazyValueForMap() = lazy { diff --git a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/structure/javaTypes.kt b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/structure/javaTypes.kt index 1e87b4edada..4c48535ba3a 100644 --- a/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/structure/javaTypes.kt +++ b/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/structure/javaTypes.kt @@ -18,13 +18,13 @@ package org.jetbrains.kotlin.load.java.structure import org.jetbrains.kotlin.builtins.PrimitiveType -interface JavaType +interface JavaType : ListBasedJavaAnnotationOwner interface JavaArrayType : JavaType { val componentType: JavaType } -interface JavaClassifierType : JavaType, JavaAnnotationOwner { +interface JavaClassifierType : JavaType { val classifier: JavaClassifier? val typeArguments: List diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaArrayType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaArrayType.kt index e4c3463e2a5..49435fec11f 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaArrayType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaArrayType.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.descriptors.runtime.structure +import org.jetbrains.kotlin.load.java.structure.JavaAnnotation import org.jetbrains.kotlin.load.java.structure.JavaArrayType import java.lang.reflect.GenericArrayType import java.lang.reflect.Type @@ -28,4 +29,8 @@ class ReflectJavaArrayType(override val reflectType: Type) : ReflectJavaType(), else -> throw IllegalArgumentException("Not an array type (${reflectType::class.java}): $reflectType") } } + + // TODO: support type use annotations in reflection + override val annotations: Collection = emptyList() + override val isDeprecatedInJavaDoc = false } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaPrimitiveType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaPrimitiveType.kt index 87cd7139058..774823072c3 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaPrimitiveType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaPrimitiveType.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.descriptors.runtime.structure import org.jetbrains.kotlin.builtins.PrimitiveType +import org.jetbrains.kotlin.load.java.structure.JavaAnnotation import org.jetbrains.kotlin.load.java.structure.JavaPrimitiveType import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType @@ -26,4 +27,8 @@ class ReflectJavaPrimitiveType(override val reflectType: Class<*>) : ReflectJava null else JvmPrimitiveType.get(reflectType.name).primitiveType + + // TODO: support type use annotations in reflection + override val annotations: Collection = emptyList() + override val isDeprecatedInJavaDoc = false } diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaWildcardType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaWildcardType.kt index 54f35496650..9df5f9ec6dc 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaWildcardType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/descriptors/runtime/structure/ReflectJavaWildcardType.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.descriptors.runtime.structure +import org.jetbrains.kotlin.load.java.structure.JavaAnnotation import org.jetbrains.kotlin.load.java.structure.JavaWildcardType import java.lang.reflect.WildcardType @@ -36,4 +37,8 @@ class ReflectJavaWildcardType(override val reflectType: WildcardType) : ReflectJ override val isExtends: Boolean get() = reflectType.upperBounds.firstOrNull() != Any::class.java + + // TODO: support type use annotations in reflection + override val annotations: Collection = emptyList() + override val isDeprecatedInJavaDoc = false } diff --git a/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/Jvm8RuntimeDescriptorLoaderTestGenerated.java b/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/Jvm8RuntimeDescriptorLoaderTestGenerated.java index f28d46f1df2..6d4f6f0646a 100644 --- a/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/Jvm8RuntimeDescriptorLoaderTestGenerated.java +++ b/core/descriptors.runtime/tests/org/jetbrains/kotlin/jvm/runtime/Jvm8RuntimeDescriptorLoaderTestGenerated.java @@ -44,13 +44,69 @@ public class Jvm8RuntimeDescriptorLoaderTestGenerated extends AbstractJvm8Runtim runTest("compiler/testData/loadJava8/compiledJava/ParameterNames.java"); } - @TestMetadata("TypeAnnotations.java") - public void testTypeAnnotations() throws Exception { - runTest("compiler/testData/loadJava8/compiledJava/TypeAnnotations.java"); + @TestMetadata("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeParameterAnnotations extends AbstractJvm8RuntimeDescriptorLoaderTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeParameterAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeParameterAnnotations/Basic.java"); + } } - @TestMetadata("TypeParameterAnnotations.java") - public void testTypeParameterAnnotations() throws Exception { - runTest("compiler/testData/loadJava8/compiledJava/TypeParameterAnnotations.java"); + @TestMetadata("compiler/testData/loadJava8/compiledJava/typeUseAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeUseAnnotations extends AbstractJvm8RuntimeDescriptorLoaderTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInTypeUseAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/compiledJava/typeUseAnnotations"), Pattern.compile("^(.+)\\.java$"), null, true); + } + + @TestMetadata("BaseClassTypeArguments.java") + public void testBaseClassTypeArguments() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/BaseClassTypeArguments.java"); + } + + @TestMetadata("Basic.java") + public void testBasic() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/Basic.java"); + } + + @TestMetadata("ClassTypeParameterBounds.java") + public void testClassTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ClassTypeParameterBounds.java"); + } + + @TestMetadata("MethodReceiver.java") + public void testMethodReceiver() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodReceiver.java"); + } + + @TestMetadata("MethodTypeParameterBounds.java") + public void testMethodTypeParameterBounds() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/MethodTypeParameterBounds.java"); + } + + @TestMetadata("ReturnType.java") + public void testReturnType() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ReturnType.java"); + } + + @TestMetadata("ValueArguments.java") + public void testValueArguments() throws Exception { + runTest("compiler/testData/loadJava8/compiledJava/typeUseAnnotations/ValueArguments.java"); + } } }