Deserialize repeated annotations inside implicit container

#KT-49651 Fixed
This commit is contained in:
Alexander Udalov
2021-11-18 01:11:48 +01:00
parent 6cae6dc5e0
commit 1b5e3f5d51
9 changed files with 128 additions and 5 deletions
@@ -0,0 +1,22 @@
// FULL_JDK
package test
@java.lang.annotation.Repeatable(Anno.Container::class)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS)
annotation class Anno(val code: Int) {
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS)
annotation class Container(val value: Array<Anno>)
}
@Anno(1)
@Anno(2)
class Z
@Anno(3)
@Anno(4)
fun f() {}
@Anno(5)
@Anno(6)
typealias S = String
@@ -0,0 +1,20 @@
package test
@test.Anno(code = 3) @test.Anno(code = 4) public fun f(): kotlin.Unit
@java.lang.annotation.Repeatable(value = test.Anno.Container::class) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS}) public final annotation class Anno : kotlin.Annotation {
/*primary*/ public constructor Anno(/*0*/ code: kotlin.Int)
public final val code: kotlin.Int
public final fun <get-code>(): kotlin.Int
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS}) public final annotation class Container : kotlin.Annotation {
/*primary*/ public constructor Container(/*0*/ value: kotlin.Array<test.Anno>)
public final val value: kotlin.Array<test.Anno>
public final fun <get-value>(): kotlin.Array<test.Anno>
}
}
@test.Anno(code = 1) @test.Anno(code = 2) public final class Z {
/*primary*/ public constructor Z()
}
@test.Anno(code = 5) @test.Anno(code = 6) public typealias S = kotlin.String
@@ -0,0 +1,17 @@
package test
@Repeatable
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS)
annotation class Anno(val code: Int)
@Anno(1)
@Anno(2)
class Z
@Anno(3)
@Anno(4)
fun f() {}
@Anno(5)
@Anno(6)
typealias S = String
@@ -0,0 +1,14 @@
package test
@test.Anno(code = 3) @test.Anno(code = 4) public fun f(): kotlin.Unit
@kotlin.annotation.Repeatable @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.TYPEALIAS}) public final annotation class Anno : kotlin.Annotation {
/*primary*/ public constructor Anno(/*0*/ code: kotlin.Int)
public final val code: kotlin.Int
public final fun <get-code>(): kotlin.Int
}
@test.Anno(code = 1) @test.Anno(code = 2) public final class Z {
/*primary*/ public constructor Z()
}
@test.Anno(code = 5) @test.Anno(code = 6) public typealias S = kotlin.String
@@ -132,7 +132,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
File ktFile = new File(ktFileName);
File txtFile = getTxtFileFromKtFile(ktFileName);
CompilerConfiguration configuration = newConfiguration(configurationKind, TestJdkKind.MOCK_JDK, getClasspath(), Collections.emptyList());
CompilerConfiguration configuration = newConfiguration(configurationKind, getJdkKind(), getClasspath(), Collections.emptyList());
updateConfiguration(configuration);
if (useTypeTableInSerializer) {
configuration.put(JVMConfigurationKeys.USE_TYPE_TABLE, true);
@@ -30,6 +30,7 @@ fun main(args: Array<String>) {
testGroup("compiler/tests-java8/tests", "compiler/testData") {
testClass<AbstractLoadJava8Test> {
model("loadJava8/compiledJava", extension = "java", testMethod = "doTestCompiledJava")
model("loadJava8/compiledKotlinWithStdlib", testMethod = "doTestCompiledKotlinWithStdlib")
model("loadJava8/sourceJava", extension = "java", testMethod = "doTestSourceJava")
}
@@ -123,6 +123,42 @@ public class LoadJava8TestGenerated extends AbstractLoadJava8Test {
}
}
@TestMetadata("compiler/testData/loadJava8/compiledKotlinWithStdlib")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class CompiledKotlinWithStdlib extends AbstractLoadJava8Test {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTestCompiledKotlinWithStdlib, this, testDataFilePath);
}
public void testAllFilesPresentInCompiledKotlinWithStdlib() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/compiledKotlinWithStdlib"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("compiler/testData/loadJava8/compiledKotlinWithStdlib/annotations")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Annotations extends AbstractLoadJava8Test {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTestCompiledKotlinWithStdlib, this, testDataFilePath);
}
public void testAllFilesPresentInAnnotations() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/loadJava8/compiledKotlinWithStdlib/annotations"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("RepeatableAnnotationWithExplicitContainer.kt")
public void testRepeatableAnnotationWithExplicitContainer() throws Exception {
runTest("compiler/testData/loadJava8/compiledKotlinWithStdlib/annotations/RepeatableAnnotationWithExplicitContainer.kt");
}
@TestMetadata("RepeatableAnnotationWithImplicitContainer.kt")
public void testRepeatableAnnotationWithImplicitContainer() throws Exception {
runTest("compiler/testData/loadJava8/compiledKotlinWithStdlib/annotations/RepeatableAnnotationWithImplicitContainer.kt");
}
}
}
@TestMetadata("compiler/testData/loadJava8/sourceJava")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)