Revert "Map Kotlin TYPE target to Java TYPE_USE in bytecode"

This reverts commit d122406dca.

See KT-23857

 #KT-24952 Fixed
This commit is contained in:
Alexander Udalov
2018-06-19 12:08:18 +02:00
parent 863639c9ab
commit e689733f69
5 changed files with 1 additions and 76 deletions
@@ -228,8 +228,6 @@ public abstract class AnnotationCodegen {
annotationTargetMap.put(KotlinTarget.PROPERTY_SETTER, ElementType.METHOD);
annotationTargetMap.put(KotlinTarget.FIELD, ElementType.FIELD);
annotationTargetMap.put(KotlinTarget.VALUE_PARAMETER, ElementType.PARAMETER);
annotationTargetMap.put(KotlinTarget.TYPE_PARAMETER, ElementType.TYPE_PARAMETER);
annotationTargetMap.put(KotlinTarget.TYPE, ElementType.TYPE_USE);
}
private void generateTargetAnnotation(@NotNull ClassDescriptor classDescriptor, @NotNull Set<String> annotationDescriptorsAlreadyPresent) {
@@ -4,7 +4,7 @@
@kotlin.annotation.Repeatable
@java.lang.annotation.Documented
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE)
@java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE_PARAMETER})
@java.lang.annotation.Target({})
public @interface Anno {
int i();
}
@@ -1,21 +0,0 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FULL_JDK
// FILE: A.java
import java.util.List;
public class A<@Anno(1) T> {}
// FILE: Anno.kt
import kotlin.test.assertEquals
@Target(AnnotationTarget.TYPE_PARAMETER)
annotation class Anno(val value: Int = 0)
fun box(): String {
val typeParameter = A::class.java.typeParameters.single()
assertEquals("[@Anno(value=1)]", typeParameter.annotations.toList().toString())
return "OK"
}
@@ -1,29 +0,0 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FULL_JDK
// FILE: A.java
import java.util.List;
public class A {
public static @Anno(1) String test(List<@Anno(2) String> list) {
return list.get(0);
}
}
// FILE: Anno.kt
import java.lang.reflect.AnnotatedParameterizedType
import kotlin.test.assertEquals
@Target(AnnotationTarget.TYPE)
annotation class Anno(val value: Int = 0)
fun box(): String {
val method = A::class.java.declaredMethods.single()
assertEquals("[@Anno(value=1)]", method.annotatedReturnType.annotations.toList().toString())
val parameterType = method.parameters.single().annotatedType as AnnotatedParameterizedType
assertEquals("[@Anno(value=2)]", parameterType.annotatedActualTypeArguments.single().annotations.toList().toString())
return "OK"
}
@@ -133,29 +133,6 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg
runTest("compiler/testData/codegen/java8/box/useStream.kt");
}
@TestMetadata("compiler/testData/codegen/java8/box/annotations")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Annotations extends AbstractBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInAnnotations() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/box/annotations"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("useTypeParameterAnnotationFromJava.kt")
public void testUseTypeParameterAnnotationFromJava() throws Exception {
runTest("compiler/testData/codegen/java8/box/annotations/useTypeParameterAnnotationFromJava.kt");
}
@TestMetadata("useTypeUseAnnotationFromJava.kt")
public void testUseTypeUseAnnotationFromJava() throws Exception {
runTest("compiler/testData/codegen/java8/box/annotations/useTypeUseAnnotationFromJava.kt");
}
}
@TestMetadata("compiler/testData/codegen/java8/box/builtinStubMethods")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)