[FIR] Rework predicates system

Now predicates are split into LookupPredicate and DeclarationPredicate
  hierarchies. First one allows to perform global search for declarations
  and second one allows to check if some declaration matches the predicate.
Predicates with meta annotations are excluded from LookupPredicates,
  because it's impossible to create index of annotations with meta-annotations,
  because they can be located inside binary dependencies (so to achieve
  this we need to scan the whole classpath).
Also only one predicate with meta-annotations is left in DeclarationPredicate
  hierarchy (AnnotatedWithMeta)

^KT-53874 Fixed
^KT-53590 Fixed
This commit is contained in:
Dmitriy Novozhilov
2022-11-23 15:16:44 +02:00
committed by Space Team
parent 7a9a71a089
commit 246dc985a6
41 changed files with 934 additions and 605 deletions
@@ -0,0 +1,36 @@
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'anonymousObject.kt'
}
@kotlin.Metadata
public final class Test$a$1 {
// source: 'anonymousObject.kt'
enclosing method Test.<init>()V
inner (anonymous) class Test$a$1
method <init>(): void
public final method run(): void
}
@kotlin.Metadata
public final class Test$b$1 {
// source: 'anonymousObject.kt'
enclosing method Test.b()V
inner (anonymous) class Test$b$1
method <init>(): void
public final method run(): void
}
@AllOpen
@kotlin.Metadata
public class Test {
// source: 'anonymousObject.kt'
private final @org.jetbrains.annotations.NotNull field a: java.lang.Runnable
inner (anonymous) class Test$a$1
inner (anonymous) class Test$b$1
public method <init>(): void
private final static method b$lambda$0(): void
public method b(): void
public @org.jetbrains.annotations.NotNull method getA(): java.lang.Runnable
}
@@ -1,6 +1,6 @@
// IGNORE_BACKEND_K2: JVM_IR
// FIR version does not go inside bodies
// Also it's quiestionable do we even need to transform local classes and anonymous objects
annotation class AllOpen
@AllOpen
@@ -1,5 +1,4 @@
// IGNORE_BACKEND_K2: JVM_IR
// FIR version does not support double-transitive annotations by design
// MODULE: lib
annotation class AllOpen
@AllOpen
@@ -14,6 +13,8 @@ annotation class AnotherComponent
@java.lang.annotation.Documented
annotation class Documented
// MODULE: main(lib)
class TestWithoutAnnotations_ShouldBeFinal
@Documented
@@ -0,0 +1,103 @@
Module: lib
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'module_lib_metaAnnotation_differentModules.kt'
}
@OtherComponent
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AnotherComponent {
// source: 'module_lib_metaAnnotation_differentModules.kt'
}
@java.lang.annotation.Documented
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class Documented {
// source: 'module_lib_metaAnnotation_differentModules.kt'
}
@AllOpen
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class MyComponent {
// source: 'module_lib_metaAnnotation_differentModules.kt'
}
@MyComponent
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class OtherComponent {
// source: 'module_lib_metaAnnotation_differentModules.kt'
}
Module: main
@Documented
@kotlin.Metadata
public final class ClassWithDocumented {
// source: 'module_main_metaAnnotation_differentModules.kt'
public method <init>(): void
}
@MyComponent
@kotlin.Metadata
public abstract class MyComponentBase {
// source: 'module_main_metaAnnotation_differentModules.kt'
public method <init>(): void
}
@kotlin.Metadata
public final class MyComponentImpl2_ShouldBeFinal {
// source: 'module_main_metaAnnotation_differentModules.kt'
public method <init>(): void
public method method(): void
}
@kotlin.Metadata
public class MyComponentImpl3_ShouldBeOpen {
// source: 'module_main_metaAnnotation_differentModules.kt'
public method <init>(): void
public final method method_ShouldBeFinal(): void
}
@kotlin.Metadata
public class MyComponentImpl_ShouldBeOpen {
// source: 'module_main_metaAnnotation_differentModules.kt'
public method <init>(): void
public method method(): void
}
@AllOpen
@kotlin.Metadata
public class TestAllOpen_ShouldBeOpen {
// source: 'module_main_metaAnnotation_differentModules.kt'
public method <init>(): void
}
@AnotherComponent
@kotlin.Metadata
public class TestAnotherComponent_ShouldBeOpen {
// source: 'module_main_metaAnnotation_differentModules.kt'
public method <init>(): void
}
@MyComponent
@kotlin.Metadata
public class TestMyComponent_ShouldBeOpen {
// source: 'module_main_metaAnnotation_differentModules.kt'
public method <init>(): void
}
@OtherComponent
@kotlin.Metadata
public class TestOtherComponent_ShouldBeOpen {
// source: 'module_main_metaAnnotation_differentModules.kt'
public method <init>(): void
}
@kotlin.Metadata
public final class TestWithoutAnnotations_ShouldBeFinal {
// source: 'module_main_metaAnnotation_differentModules.kt'
public method <init>(): void
}
@@ -0,0 +1,45 @@
annotation class AllOpen
@AllOpen
annotation class MyComponent
@MyComponent // Double-transitive annotations is supported
annotation class OtherComponent
@OtherComponent
annotation class AnotherComponent
@java.lang.annotation.Documented
annotation class Documented
class TestWithoutAnnotations_ShouldBeFinal
@Documented
class ClassWithDocumented
@AllOpen
class TestAllOpen_ShouldBeOpen
@MyComponent
class TestMyComponent_ShouldBeOpen
@OtherComponent
class TestOtherComponent_ShouldBeOpen
@AnotherComponent
class TestAnotherComponent_ShouldBeOpen
@MyComponent
abstract class MyComponentBase
class MyComponentImpl_ShouldBeOpen : MyComponentBase() {
fun method() {}
}
final class MyComponentImpl2_ShouldBeFinal : MyComponentBase() {
fun method() {}
}
class MyComponentImpl3_ShouldBeOpen : MyComponentBase() {
final fun method_ShouldBeFinal() {}
}
@@ -1,20 +1,20 @@
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AllOpen {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
}
@OtherComponent
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class AnotherComponent {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
}
@Documented
@kotlin.Metadata
public final class ClassWithDocumented {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
public method <init>(): void
}
@@ -22,40 +22,40 @@ public final class ClassWithDocumented {
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class Documented {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
}
@AllOpen
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class MyComponent {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
}
@MyComponent
@kotlin.Metadata
public abstract class MyComponentBase {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
public method <init>(): void
}
@kotlin.Metadata
public final class MyComponentImpl2_ShouldBeFinal {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
public method <init>(): void
public method method(): void
}
@kotlin.Metadata
public class MyComponentImpl3_ShouldBeOpen {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
public method <init>(): void
public final method method_ShouldBeFinal(): void
}
@kotlin.Metadata
public class MyComponentImpl_ShouldBeOpen {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
public method <init>(): void
public method method(): void
}
@@ -64,39 +64,39 @@ public class MyComponentImpl_ShouldBeOpen {
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class OtherComponent {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
}
@AllOpen
@kotlin.Metadata
public class TestAllOpen_ShouldBeOpen {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
public method <init>(): void
}
@AnotherComponent
@kotlin.Metadata
public class TestAnotherComponent_ShouldBeOpen {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
public method <init>(): void
}
@MyComponent
@kotlin.Metadata
public class TestMyComponent_ShouldBeOpen {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
public method <init>(): void
}
@OtherComponent
@kotlin.Metadata
public class TestOtherComponent_ShouldBeOpen {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
public method <init>(): void
}
@kotlin.Metadata
public final class TestWithoutAnnotations_ShouldBeFinal {
// source: 'metaAnnotation.kt'
// source: 'metaAnnotation_sameModule.kt'
public method <init>(): void
}