[LL FIR] rework transformers, so transformers resolve only a specific set of declarations

The change is needed for the parallel resolution (^KT-55750), so we can resolve the declaration
under a lock that is specific to this declaration.
Previously, if LL FIR was resolving some FirClass, LL FIR  resolved all its children too, and it had no control over what parts of the FIR tree were modified.
The same applied to the designation path, sometimes the classes on the designation path
might be unexpectedly (and without lock) modified.

This commit introduces LLFirResolveTarget, which specifies which exact declarations should be resolved during the lazy resolution of the declaration.
All elements outside the declarations specified for resolve in LLFirResolveTarget, should not be modified.

The logic of lazy transformers is the following:
- Go to target declaration collecting all scopes from the file and containing classes
- Resolve only declarations that are specified by the LLFirResolveTarget, performing the resolve under a separate lock for each declaration

^KT-56543
^KT-57619 Fixed
This commit is contained in:
Dmitrii Gridin
2023-03-30 17:19:30 +02:00
committed by Space Team
parent 18a8cfb090
commit 72def186a3
545 changed files with 4297 additions and 2378 deletions
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
fun foo(): Boolean
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
fun foo()
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
fun foo()
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
fun foo()
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
class A {
val s: String = ""
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
open class Base
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
fun foo()
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
fun test_0(x: Any) {
if (x is String) {
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
fun foo()
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
fun foo()
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
fun foo()
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
fun foo()
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// ISSUE: KT-39080
// !DUMP_CFG
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
fun foo(): Boolean
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface A {
fun foo()
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
// There would be ambiguities if some expression was smartcasted to (A & B) and foo() was called.
// There was a bug where 2 variables were "bound" together if they are assigned from the same function call or property.
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
// CONTAINS ERRORS
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
class A {
fun foo() {}
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
// ----------------- Stable -----------------
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
fun String.foo(b: Boolean): String = ""
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
interface I
interface S : I {
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// ISSUE: KT-49747
// DUMP_CFG
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
fun getNothing(): Nothing = throw Exception()
fun getNullableNothing(): Nothing? = null
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
open class A(open val x: Any)
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DUMP_CFG
class A {
fun foo() {}