[FIR] fix contract violation from meta annotations
^KT-60448 Fixed
This commit is contained in:
committed by
Space Team
parent
480c794444
commit
7620289f6f
+4
-3
@@ -215,12 +215,13 @@ fun FirRegularClassSymbol?.markedWithMetaAnnotationImpl(
|
|||||||
session: FirSession,
|
session: FirSession,
|
||||||
metaAnnotations: Set<AnnotationFqn>,
|
metaAnnotations: Set<AnnotationFqn>,
|
||||||
includeItself: Boolean,
|
includeItself: Boolean,
|
||||||
visited: MutableSet<FirRegularClassSymbol>
|
visited: MutableSet<FirRegularClassSymbol>,
|
||||||
|
resolvedCompilerAnnotations: (FirRegularClassSymbol) -> List<FirAnnotation> = FirBasedSymbol<*>::resolvedCompilerAnnotationsWithClassIds,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (this == null) return false
|
if (this == null) return false
|
||||||
if (!visited.add(this)) return false
|
if (!visited.add(this)) return false
|
||||||
if (this.classId.asSingleFqName() in metaAnnotations) return includeItself
|
if (this.classId.asSingleFqName() in metaAnnotations) return includeItself
|
||||||
return this.resolvedCompilerAnnotationsWithClassIds
|
return resolvedCompilerAnnotations(this)
|
||||||
.mapNotNull { it.annotationTypeRef.coneTypeSafe<ConeKotlinType>()?.toRegularClassSymbol(session) }
|
.mapNotNull { it.annotationTypeRef.coneTypeSafe<ConeKotlinType>()?.toRegularClassSymbol(session) }
|
||||||
.any { it.markedWithMetaAnnotationImpl(session, metaAnnotations, includeItself = true, visited) }
|
.any { it.markedWithMetaAnnotationImpl(session, metaAnnotations, includeItself = true, visited, resolvedCompilerAnnotations) }
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -276,7 +276,10 @@ abstract class AbstractFirSpecificAnnotationResolveTransformer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun ConeKotlinType.markedWithMetaAnnotation(session: FirSession, metaAnnotations: Set<AnnotationFqn>): Boolean {
|
private fun ConeKotlinType.markedWithMetaAnnotation(session: FirSession, metaAnnotations: Set<AnnotationFqn>): Boolean {
|
||||||
return toRegularClassSymbol(session).markedWithMetaAnnotationImpl(session, metaAnnotations, includeItself = true, mutableSetOf())
|
return toRegularClassSymbol(session).markedWithMetaAnnotationImpl(session, metaAnnotations, includeItself = true, mutableSetOf()) {
|
||||||
|
computationSession.resolveAnnotationsOnAnnotationIfNeeded(it, scopeSession)
|
||||||
|
it.annotations
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// WITH_STDLIB
|
||||||
|
annotation class AllOpen
|
||||||
|
|
||||||
|
@AllOpen
|
||||||
|
class Test {
|
||||||
|
@JvmName("g")
|
||||||
|
private fun f() {}
|
||||||
|
}
|
||||||
Generated
+6
@@ -30,6 +30,12 @@ public class DiagnosticTestForAllOpenBaseGenerated extends AbstractDiagnosticTes
|
|||||||
runTest("plugins/allopen/testData/diagnostics/kt54260.kt");
|
runTest("plugins/allopen/testData/diagnostics/kt54260.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt60448.kt")
|
||||||
|
public void testKt60448() throws Exception {
|
||||||
|
runTest("plugins/allopen/testData/diagnostics/kt60448.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("smartcast.kt")
|
@TestMetadata("smartcast.kt")
|
||||||
public void testSmartcast() throws Exception {
|
public void testSmartcast() throws Exception {
|
||||||
|
|||||||
+6
@@ -30,6 +30,12 @@ public class FirLightTreeDiagnosticTestForAllOpenGenerated extends AbstractFirLi
|
|||||||
runTest("plugins/allopen/testData/diagnostics/kt54260.kt");
|
runTest("plugins/allopen/testData/diagnostics/kt54260.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt60448.kt")
|
||||||
|
public void testKt60448() throws Exception {
|
||||||
|
runTest("plugins/allopen/testData/diagnostics/kt60448.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("smartcast.kt")
|
@TestMetadata("smartcast.kt")
|
||||||
public void testSmartcast() throws Exception {
|
public void testSmartcast() throws Exception {
|
||||||
|
|||||||
Generated
+6
@@ -30,6 +30,12 @@ public class FirPsiDiagnosticTestForAllOpenGenerated extends AbstractFirPsiDiagn
|
|||||||
runTest("plugins/allopen/testData/diagnostics/kt54260.kt");
|
runTest("plugins/allopen/testData/diagnostics/kt54260.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt60448.kt")
|
||||||
|
public void testKt60448() throws Exception {
|
||||||
|
runTest("plugins/allopen/testData/diagnostics/kt60448.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("smartcast.kt")
|
@TestMetadata("smartcast.kt")
|
||||||
public void testSmartcast() throws Exception {
|
public void testSmartcast() throws Exception {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// FIR_DISABLE_LAZY_RESOLVE_CHECKS
|
|
||||||
// LANGUAGE: +MultiPlatformProjects
|
// LANGUAGE: +MultiPlatformProjects
|
||||||
// ISSUE: KT-58539
|
// ISSUE: KT-58539
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// FIR_DISABLE_LAZY_RESOLVE_CHECKS
|
|
||||||
// MODULE: lib
|
// MODULE: lib
|
||||||
import org.jetbrains.kotlin.fir.plugin.AllOpen
|
import org.jetbrains.kotlin.fir.plugin.AllOpen
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// FIR_DISABLE_LAZY_RESOLVE_CHECKS
|
|
||||||
// FILE: first.kt
|
// FILE: first.kt
|
||||||
|
|
||||||
@Open
|
@Open
|
||||||
|
|||||||
Vendored
-1
@@ -1,4 +1,3 @@
|
|||||||
// FIR_DISABLE_LAZY_RESOLVE_CHECKS
|
|
||||||
import org.jetbrains.kotlin.fir.plugin.AllOpen
|
import org.jetbrains.kotlin.fir.plugin.AllOpen
|
||||||
|
|
||||||
@AllOpen
|
@AllOpen
|
||||||
|
|||||||
-1
@@ -1,4 +1,3 @@
|
|||||||
// FIR_DISABLE_LAZY_RESOLVE_CHECKS
|
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
package foo
|
package foo
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// FIR_DISABLE_LAZY_RESOLVE_CHECKS
|
|
||||||
// FIR_IDENTICAL
|
// FIR_IDENTICAL
|
||||||
// SKIP_TXT
|
// SKIP_TXT
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user