Support instantiation of annotations with type parameters
By ignoring type parameters. Since type parameters in annotations are a very limited feature, their sole use is to be able to specify them as KClass argument: annotation class Foo<T: Any>(val bar: KClass<T>). Since we can encounter type param only as a KClass type argument (and never as a property type), simple approach of ignoring them works fine. In that case, since we simply copy property types to synthetic implementation class, its properties in IR start look like this: annotation class FooImpl(override val bar: KClass<T of Foo>). This IR seems to be not completely correct, since FooImpl.bar type contains T of Foo param, which is out of its scope. However, so far I didn't encounter any problems with this during testing and after MR discussion this approach has been considered possible. #KT-59558 Fixed #KT-59036 Fixed
This commit is contained in:
committed by
Space Team
parent
8c795462e1
commit
648c1f4599
+12
@@ -143,6 +143,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/annotationToString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationWithTypeParameters.kt")
|
||||
public void testAnnotationWithTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/annotationWithTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsUnsignedTypes.kt")
|
||||
public void testAnnotationsUnsignedTypes() throws Exception {
|
||||
@@ -161,6 +167,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/multifileEqHc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multimoduleTypeParams.kt")
|
||||
public void testMultimoduleTypeParams() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/multimoduleTypeParams.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multiplatformInstantiation.kt")
|
||||
public void testMultiplatformInstantiation() throws Exception {
|
||||
|
||||
+12
@@ -153,6 +153,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/annotationToString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationWithTypeParameters.kt")
|
||||
public void testAnnotationWithTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/annotationWithTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsUnsignedTypes.kt")
|
||||
public void testAnnotationsUnsignedTypes() throws Exception {
|
||||
@@ -171,6 +177,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/multifileEqHc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multimoduleTypeParams.kt")
|
||||
public void testMultimoduleTypeParams() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/multimoduleTypeParams.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multiplatformInstantiation.kt")
|
||||
public void testMultiplatformInstantiation() throws Exception {
|
||||
|
||||
+12
@@ -139,6 +139,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/annotationToString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationWithTypeParameters.kt")
|
||||
public void testAnnotationWithTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/annotationWithTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsUnsignedTypes.kt")
|
||||
public void testAnnotationsUnsignedTypes() throws Exception {
|
||||
@@ -157,6 +163,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/multifileEqHc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multimoduleTypeParams.kt")
|
||||
public void testMultimoduleTypeParams() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/multimoduleTypeParams.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multiplatformInstantiation.kt")
|
||||
public void testMultiplatformInstantiation() throws Exception {
|
||||
|
||||
+12
@@ -144,6 +144,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/annotationToString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationWithTypeParameters.kt")
|
||||
public void testAnnotationWithTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/annotationWithTypeParameters.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("annotationsUnsignedTypes.kt")
|
||||
public void testAnnotationsUnsignedTypes() throws Exception {
|
||||
@@ -162,6 +168,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/multifileEqHc.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multimoduleTypeParams.kt")
|
||||
public void testMultimoduleTypeParams() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/instances/multimoduleTypeParams.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multiplatformInstantiation.kt")
|
||||
public void testMultiplatformInstantiation() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user