Support reading from class files of the type use annotations on type parameters and type arguments
^KT-11454 Fixed
This commit is contained in:
+5
@@ -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<JavaAnnotation> = emptyList()
|
||||
override val isDeprecatedInJavaDoc = false
|
||||
}
|
||||
|
||||
+5
@@ -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<JavaAnnotation> = emptyList()
|
||||
override val isDeprecatedInJavaDoc = false
|
||||
}
|
||||
|
||||
+5
@@ -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<JavaAnnotation> = emptyList()
|
||||
override val isDeprecatedInJavaDoc = false
|
||||
}
|
||||
|
||||
+62
-6
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user