[FIR] Ignore anonymous functions during annotation argument phase
Anonymous functions (lambdas) are not allowed as annotation arguments. However, because it is still possible to parse code written this way, it must be handled without exception. So ignore these expressions when processing annotation arguments. #KT-59565 Fixed
This commit is contained in:
+6
@@ -2193,6 +2193,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaParameter.kt")
|
||||
public void testLambdaParameter() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/lambdaParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("standaloneInExpression.kt")
|
||||
public void testStandaloneInExpression() throws Exception {
|
||||
|
||||
+6
@@ -2193,6 +2193,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaParameter.kt")
|
||||
public void testLambdaParameter() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/lambdaParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("standaloneInExpression.kt")
|
||||
public void testStandaloneInExpression() throws Exception {
|
||||
|
||||
+6
@@ -2193,6 +2193,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaParameter.kt")
|
||||
public void testLambdaParameter() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/lambdaParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("standaloneInExpression.kt")
|
||||
public void testStandaloneInExpression() throws Exception {
|
||||
|
||||
+6
@@ -2199,6 +2199,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaParameter.kt")
|
||||
public void testLambdaParameter() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/lambdaParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("standaloneInExpression.kt")
|
||||
public void testStandaloneInExpression() throws Exception {
|
||||
|
||||
+14
@@ -295,6 +295,20 @@ abstract class AbstractFirExpressionsResolveTransformerForAnnotations(transforme
|
||||
return arrayLiteral
|
||||
}
|
||||
|
||||
override fun transformAnonymousObjectExpression(
|
||||
anonymousObjectExpression: FirAnonymousObjectExpression,
|
||||
data: ResolutionMode,
|
||||
): FirStatement {
|
||||
return anonymousObjectExpression
|
||||
}
|
||||
|
||||
override fun transformAnonymousFunctionExpression(
|
||||
anonymousFunctionExpression: FirAnonymousFunctionExpression,
|
||||
data: ResolutionMode,
|
||||
): FirStatement {
|
||||
return anonymousFunctionExpression
|
||||
}
|
||||
|
||||
override fun shouldComputeTypeOfGetClassCallWithNotQualifierInLhs(getClassCall: FirGetClassCall): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// ISSUE: KT-59565
|
||||
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Ann(val x: Int)
|
||||
|
||||
class A<T: @Ann(<!ARGUMENT_TYPE_MISMATCH!>{
|
||||
fun local() = 1
|
||||
var result = local()
|
||||
result += 1
|
||||
result
|
||||
}<!>) Any>
|
||||
|
||||
fun f(x: @Ann(<!ARGUMENT_TYPE_MISMATCH!>{
|
||||
fun local() = 1
|
||||
var result = local()
|
||||
result += 1
|
||||
result
|
||||
}<!>) Int) = x
|
||||
compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/lambdaParameter.kt
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// ISSUE: KT-59565
|
||||
|
||||
@Target(AnnotationTarget.TYPE)
|
||||
annotation class Ann(val x: Int)
|
||||
|
||||
class A<T: @Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST, TYPE_MISMATCH!>{
|
||||
fun local() = 1
|
||||
var result = local()
|
||||
result += 1
|
||||
result
|
||||
}<!>) Any>
|
||||
|
||||
fun f(x: @Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST, TYPE_MISMATCH!>{
|
||||
fun local() = 1
|
||||
var result = local()
|
||||
result += 1
|
||||
result
|
||||
}<!>) Int) = x
|
||||
Generated
+6
@@ -2199,6 +2199,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaParameter.kt")
|
||||
public void testLambdaParameter() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/lambdaParameter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("standaloneInExpression.kt")
|
||||
public void testStandaloneInExpression() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user