[FIR] KT-57247: Expand typealiases in annotation vararg arguments
^KT-57247 Fixed
This commit is contained in:
committed by
Space Team
parent
5b0b7c4da4
commit
4b8471d806
+6
@@ -57,6 +57,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationArgumentWithAliasedArrayType.kt")
|
||||||
|
public void testAnnotationArgumentWithAliasedArrayType() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotationArgumentWithAliasedArrayType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("AnonymousInitializerVarAndConstructor.kt")
|
@TestMetadata("AnonymousInitializerVarAndConstructor.kt")
|
||||||
public void testAnonymousInitializerVarAndConstructor() throws Exception {
|
public void testAnonymousInitializerVarAndConstructor() throws Exception {
|
||||||
|
|||||||
+6
@@ -57,6 +57,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationArgumentWithAliasedArrayType.kt")
|
||||||
|
public void testAnnotationArgumentWithAliasedArrayType() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotationArgumentWithAliasedArrayType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("AnonymousInitializerVarAndConstructor.kt")
|
@TestMetadata("AnonymousInitializerVarAndConstructor.kt")
|
||||||
public void testAnonymousInitializerVarAndConstructor() throws Exception {
|
public void testAnonymousInitializerVarAndConstructor() throws Exception {
|
||||||
|
|||||||
+6
@@ -57,6 +57,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationArgumentWithAliasedArrayType.kt")
|
||||||
|
public void testAnnotationArgumentWithAliasedArrayType() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotationArgumentWithAliasedArrayType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("AnonymousInitializerVarAndConstructor.kt")
|
@TestMetadata("AnonymousInitializerVarAndConstructor.kt")
|
||||||
public void testAnonymousInitializerVarAndConstructor() throws Exception {
|
public void testAnonymousInitializerVarAndConstructor() throws Exception {
|
||||||
|
|||||||
+4
-5
@@ -101,7 +101,7 @@ object FirAnnotationClassDeclarationChecker : FirRegularClassChecker() {
|
|||||||
// DO NOTHING: arrays of unsigned types are allowed
|
// DO NOTHING: arrays of unsigned types are allowed
|
||||||
}
|
}
|
||||||
classId == StandardClassIds.Array -> {
|
classId == StandardClassIds.Array -> {
|
||||||
if (!isAllowedArray(typeRef, context.session))
|
if (!isAllowedArray(coneType, context.session))
|
||||||
reporter.reportOn(typeRef.source, FirErrors.INVALID_TYPE_OF_ANNOTATION_MEMBER, context)
|
reporter.reportOn(typeRef.source, FirErrors.INVALID_TYPE_OF_ANNOTATION_MEMBER, context)
|
||||||
}
|
}
|
||||||
isAllowedClassKind(coneType, context.session) -> {
|
isAllowedClassKind(coneType, context.session) -> {
|
||||||
@@ -137,13 +137,12 @@ object FirAnnotationClassDeclarationChecker : FirRegularClassChecker() {
|
|||||||
return typeRefClassKind == ANNOTATION_CLASS || typeRefClassKind == ENUM_CLASS
|
return typeRefClassKind == ANNOTATION_CLASS || typeRefClassKind == ENUM_CLASS
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isAllowedArray(typeRef: FirTypeRef, session: FirSession): Boolean {
|
private fun isAllowedArray(type: ConeKotlinType, session: FirSession): Boolean {
|
||||||
val typeArguments = typeRef.coneType.typeArguments
|
val typeArguments = type.typeArguments
|
||||||
|
|
||||||
if (typeArguments.size != 1) return false
|
if (typeArguments.size != 1) return false
|
||||||
|
|
||||||
val arrayType = (typeArguments[0] as? ConeKotlinTypeProjection)
|
val arrayType = (typeArguments[0] as? ConeKotlinTypeProjection)?.type?.fullyExpandedType(session)
|
||||||
?.type
|
|
||||||
?: return false
|
?: return false
|
||||||
|
|
||||||
if (arrayType.isNullable) return false
|
if (arrayType.isNullable) return false
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// ISSUE: KT-57247
|
||||||
|
|
||||||
|
typealias Aliased = String
|
||||||
|
annotation class Tag(vararg val tags: Aliased) // K1: ok, K2: INVALID_TYPE_OF_ANNOTATION_MEMBER
|
||||||
Generated
+6
@@ -57,6 +57,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(fir|ll)\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("annotationArgumentWithAliasedArrayType.kt")
|
||||||
|
public void testAnnotationArgumentWithAliasedArrayType() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotationArgumentWithAliasedArrayType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("AnonymousInitializerVarAndConstructor.kt")
|
@TestMetadata("AnonymousInitializerVarAndConstructor.kt")
|
||||||
public void testAnonymousInitializerVarAndConstructor() throws Exception {
|
public void testAnonymousInitializerVarAndConstructor() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user