[FIR] Fix WRONG_ANNOTATION_TARGET for annotation for block, ^KT-52175 Fixed
This commit is contained in:
+6
@@ -996,6 +996,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt");
|
runTest("compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("AnnotatedBlock.kt")
|
||||||
|
public void testAnnotatedBlock() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotatedBlock.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("AnnotatedConstructor.kt")
|
@TestMetadata("AnnotatedConstructor.kt")
|
||||||
public void testAnnotatedConstructor() throws Exception {
|
public void testAnnotatedConstructor() throws Exception {
|
||||||
|
|||||||
+6
@@ -996,6 +996,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt");
|
runTest("compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("AnnotatedBlock.kt")
|
||||||
|
public void testAnnotatedBlock() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotatedBlock.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("AnnotatedConstructor.kt")
|
@TestMetadata("AnnotatedConstructor.kt")
|
||||||
public void testAnnotatedConstructor() throws Exception {
|
public void testAnnotatedConstructor() throws Exception {
|
||||||
|
|||||||
+6
@@ -996,6 +996,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt");
|
runTest("compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("AnnotatedBlock.kt")
|
||||||
|
public void testAnnotatedBlock() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotatedBlock.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("AnnotatedConstructor.kt")
|
@TestMetadata("AnnotatedConstructor.kt")
|
||||||
public void testAnnotatedConstructor() throws Exception {
|
public void testAnnotatedConstructor() throws Exception {
|
||||||
|
|||||||
+3
-1
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.fir.analysis.checkers.expression
|
package org.jetbrains.kotlin.fir.analysis.checkers.expression
|
||||||
|
|
||||||
import org.jetbrains.kotlin.KtFakeSourceElementKind
|
import org.jetbrains.kotlin.KtFakeSourceElementKind
|
||||||
|
import org.jetbrains.kotlin.KtRealSourceElementKind
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.checkRepeatedAnnotation
|
import org.jetbrains.kotlin.fir.analysis.checkers.checkRepeatedAnnotation
|
||||||
@@ -29,7 +30,8 @@ object FirExpressionAnnotationChecker : FirBasicExpressionChecker() {
|
|||||||
// See KT-33658 about annotations on non-expression statements
|
// See KT-33658 about annotations on non-expression statements
|
||||||
if (expression is FirDeclaration ||
|
if (expression is FirDeclaration ||
|
||||||
expression !is FirExpression ||
|
expression !is FirExpression ||
|
||||||
expression is FirBlock && expression.source?.kind == KtFakeSourceElementKind.DesugaredForLoop
|
expression is FirBlock && (expression.source?.kind == KtRealSourceElementKind ||
|
||||||
|
expression.source?.kind == KtFakeSourceElementKind.DesugaredForLoop)
|
||||||
) return
|
) return
|
||||||
|
|
||||||
val annotations = expression.annotations
|
val annotations = expression.annotations
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
FILE: AnnotatedBlock.kt
|
||||||
|
public final annotation class Ann : R|kotlin/Annotation| {
|
||||||
|
public constructor(): R|Ann| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final annotation class Ann2 : R|kotlin/Annotation| {
|
||||||
|
public constructor(): R|Ann2| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final fun test(x: R|kotlin/String?|): R|kotlin/Unit| {
|
||||||
|
when () {
|
||||||
|
!=(R|<local>/x|, Null(null)) -> @R|Ann|() @R|Ann2|() {
|
||||||
|
Q|kotlin/Unit|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
when () {
|
||||||
|
!=(R|<local>/x|, Null(null)) -> {
|
||||||
|
@R|Ann|() @R|Ann2|() Q|kotlin/Unit|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@R|Ann|() @R|Ann2|() R|<local>/x|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// FIR_DUMP
|
||||||
|
// ISSUE: KT-52175
|
||||||
|
|
||||||
|
annotation class Ann
|
||||||
|
|
||||||
|
fun test(x: String?) {
|
||||||
|
if (x != null)
|
||||||
|
@Ann() { Unit }
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun test(/*0*/ x: kotlin.String?): kotlin.Unit
|
||||||
|
|
||||||
|
public final annotation class Ann : kotlin.Annotation {
|
||||||
|
public constructor Ann()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
Generated
+6
@@ -996,6 +996,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt");
|
runTest("compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("AnnotatedBlock.kt")
|
||||||
|
public void testAnnotatedBlock() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotatedBlock.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("AnnotatedConstructor.kt")
|
@TestMetadata("AnnotatedConstructor.kt")
|
||||||
public void testAnnotatedConstructor() throws Exception {
|
public void testAnnotatedConstructor() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user