[FIR] Fix compiler crash with incorrect argument in FirDanglingModifierList

KT-63508 Fixed
This commit is contained in:
Ivan Kochurkin
2023-11-21 23:30:53 +01:00
committed by Space Team
parent fc5239bdfd
commit a04deba7c7
8 changed files with 63 additions and 0 deletions
@@ -12518,6 +12518,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("annotationWithWrongArgInDanglingModifierList.kt")
public void testAnnotationWithWrongArgInDanglingModifierList() throws Exception {
runTest("compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt");
}
@Test
@TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt")
public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception {
@@ -12518,6 +12518,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("annotationWithWrongArgInDanglingModifierList.kt")
public void testAnnotationWithWrongArgInDanglingModifierList() throws Exception {
runTest("compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt");
}
@Test
@TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt")
public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception {
@@ -12512,6 +12512,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform");
}
@Test
@TestMetadata("annotationWithWrongArgInDanglingModifierList.kt")
public void testAnnotationWithWrongArgInDanglingModifierList() throws Exception {
runTest("compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt");
}
@Test
@TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt")
public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception {
@@ -12518,6 +12518,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform");
}
@Test
@TestMetadata("annotationWithWrongArgInDanglingModifierList.kt")
public void testAnnotationWithWrongArgInDanglingModifierList() throws Exception {
runTest("compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt");
}
@Test
@TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt")
public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception {
@@ -138,6 +138,17 @@ open class FirImplicitAwareBodyResolveTransformer(
super.transformDeclarationContent(declaration, data)
}
override fun transformDanglingModifierList(
danglingModifierList: FirDanglingModifierList,
data: ResolutionMode
): FirDanglingModifierList {
return if (implicitTypeOnly) {
danglingModifierList
} else {
transformElement(danglingModifierList, data)
}
}
override fun transformSimpleFunction(
simpleFunction: FirSimpleFunction,
data: ResolutionMode
@@ -0,0 +1,11 @@
// ISSUE: KT-63508
annotation class Ann(val x: String)
fun foo() {
class Local {
@Ann(<!ANONYMOUS_FUNCTION_WITH_NAME!>fun f(): String { return <!RETURN_TYPE_MISMATCH!>42<!> }<!>)<!SYNTAX!><!>
}
}
@Ann(<!ANONYMOUS_FUNCTION_WITH_NAME!>fun g(): String { return <!RETURN_TYPE_MISMATCH!>42<!> }<!>)<!SYNTAX!><!>
@@ -0,0 +1,11 @@
// ISSUE: KT-63508
annotation class Ann(val x: String)
fun foo() {
class Local {
@Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST, TYPE_MISMATCH!>fun <!ANONYMOUS_FUNCTION_WITH_NAME!>f<!>(): String { return <!CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!> }<!>)<!SYNTAX!><!>
}
}
@Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST, TYPE_MISMATCH!>fun <!ANONYMOUS_FUNCTION_WITH_NAME!>g<!>(): String { return <!CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!> }<!>)<!SYNTAX!><!>
@@ -12518,6 +12518,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("annotationWithWrongArgInDanglingModifierList.kt")
public void testAnnotationWithWrongArgInDanglingModifierList() throws Exception {
runTest("compiler/testData/diagnostics/tests/exceptions/annotationWithWrongArgInDanglingModifierList.kt");
}
@Test
@TestMetadata("expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt")
public void testExpectedSomeTypesOnBranchForWhenExpressionOfErroneousType() throws Exception {