[FIR] Add ability to specify if meta annotation itself should match metaAnnotated predicate
^KT-55843 Fixed
This commit is contained in:
committed by
Space Team
parent
e88a6af7a0
commit
4363b0815c
+1
-1
@@ -57,7 +57,7 @@ class FirAllOpenPredicateMatcher(
|
||||
|
||||
override val predicate = DeclarationPredicate.create {
|
||||
val annotationFqNames = allOpenAnnotationFqNames.map { FqName(it) }
|
||||
annotated(annotationFqNames) or metaAnnotated(annotationFqNames)
|
||||
annotated(annotationFqNames) or metaAnnotated(annotationFqNames, includeItself = true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ class AllOpenStatusTransformer(session: FirSession) : FirStatusTransformerExtens
|
||||
companion object {
|
||||
private val ALL_OPEN = FqName("org.jetbrains.kotlin.fir.plugin.AllOpen")
|
||||
private val PREDICATE = DeclarationPredicate.create {
|
||||
annotatedOrUnder(ALL_OPEN) or metaAnnotated(ALL_OPEN)
|
||||
annotatedOrUnder(ALL_OPEN) or metaAnnotated(ALL_OPEN, includeItself = true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ class SomeAdditionalSupertypeGenerator(session: FirSession) : FirSupertypeGenera
|
||||
companion object {
|
||||
private val myInterfaceClassId = ClassId(FqName("foo"), Name.identifier("MyInterface"))
|
||||
private val PREDICATE = DeclarationPredicate.create {
|
||||
annotated("MyInterfaceSupertype".fqn()) or metaAnnotated("MetaSupertype".fqn())
|
||||
annotated("MyInterfaceSupertype".fqn()) or metaAnnotated("MetaSupertype".fqn(), includeItself = false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -24,14 +24,14 @@ FILE: main.kt
|
||||
}
|
||||
|
||||
}
|
||||
@R|org/jetbrains/kotlin/fir/plugin/MetaSupertype|() public final class Zero : R|kotlin/Any|, R|foo/MyInterface| {
|
||||
@R|org/jetbrains/kotlin/fir/plugin/MetaSupertype|() public final class Zero : R|kotlin/Any| {
|
||||
public constructor(): R|foo/Zero| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test(a: R|foo/Zero|, b: R|foo/First|, c: R|foo/Second|, d: R|foo/Third|): R|kotlin/Unit| {
|
||||
R|<local>/a|.R|foo/MyInterface.foo|()
|
||||
R|<local>/a|.<Unresolved name: foo>#()
|
||||
R|<local>/b|.R|foo/MyInterface.foo|()
|
||||
R|<local>/c|.R|foo/MyInterface.foo|()
|
||||
R|<local>/d|.R|foo/MyInterface.foo|()
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ class First
|
||||
class Zero
|
||||
|
||||
fun test(a: Zero, b: First, c: Second, d: Third) {
|
||||
a.foo()
|
||||
a.<!UNRESOLVED_REFERENCE!>foo<!>() // should be an error, because meta predicate has inludeItself = false
|
||||
b.foo()
|
||||
c.foo()
|
||||
d.foo()
|
||||
|
||||
+3
-2
@@ -13,9 +13,10 @@ object FirSerializationPredicates {
|
||||
annotated(setOf(SerializationAnnotations.serializerAnnotationFqName)) // @Serializer(for=...)
|
||||
}
|
||||
internal val hasMetaAnnotation = DeclarationPredicate.create {
|
||||
metaAnnotated(SerializationAnnotations.metaSerializableAnnotationFqName)
|
||||
metaAnnotated(SerializationAnnotations.metaSerializableAnnotationFqName, includeItself = false)
|
||||
}
|
||||
internal val annotatedWithSerializableOrMeta = DeclarationPredicate.create {
|
||||
annotated(setOf(SerializationAnnotations.serializableAnnotationFqName)) or metaAnnotated(SerializationAnnotations.metaSerializableAnnotationFqName)
|
||||
annotated(setOf(SerializationAnnotations.serializableAnnotationFqName)) or
|
||||
metaAnnotated(SerializationAnnotations.metaSerializableAnnotationFqName, includeItself = false)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ class FirNoArgPredicateMatcher(
|
||||
|
||||
override val predicate = DeclarationPredicate.create {
|
||||
val annotationFqNames = noArgAnnotationFqNames.map { FqName(it) }
|
||||
annotated(annotationFqNames) or metaAnnotated(annotationFqNames)
|
||||
annotated(annotationFqNames) or metaAnnotated(annotationFqNames, includeItself = true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user