[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,3 +1,4 @@
// IGNORE_REVERSED_RESOLVE
// FIR_IDENTICAL
@Retention(AnnotationRetention.SOURCE)
@Repeatable
@@ -5,6 +6,8 @@ annotation class Ann(val i: Int)
annotation class AnnIA(val ia: IntArray)
annotation class AnnSA(val sa: Array<String>)
var i = 1
@Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>MyClass().i<!>)
@Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>i<!>)
@Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>i2<!>)
@@ -15,7 +18,6 @@ class Test {
@Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST!>i<!>) val i2 = 1
}
var i = 1
val i2 = foo()
fun foo(): Int = 1
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
val nonConst = 1
const val constConst = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>nonConst * nonConst + 2<!>
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
val nonConst = 1
const val constConst = <!NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION!>nonConst * nonConst + 2<!>
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
import kotlin.annotation.AnnotationTarget.FIELD
object Some {
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
import kotlin.annotation.AnnotationTarget.FIELD
object Some {
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !OPT_IN: kotlin.contracts.ExperimentalContracts
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
// !OPT_IN: kotlin.contracts.ExperimentalContracts
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect +AllowContractsForNonOverridableMembers +AllowReifiedGenericsInContracts
// !OPT_IN: kotlin.contracts.ExperimentalContracts
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER -NOTHING_TO_INLINE -ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS -ABSTRACT_FUNCTION_WITH_BODY -UNUSED_PARAMETER -UNUSED_VARIABLE -EXPERIMENTAL_FEATURE_WARNING
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !LANGUAGE: +AllowContractsForCustomFunctions +UseReturnsEffect +AllowContractsForNonOverridableMembers +AllowReifiedGenericsInContracts
// !OPT_IN: kotlin.contracts.ExperimentalContracts
// !DIAGNOSTICS: -INVISIBLE_REFERENCE -INVISIBLE_MEMBER -NOTHING_TO_INLINE -ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS -ABSTRACT_FUNCTION_WITH_BODY -UNUSED_PARAMETER -UNUSED_VARIABLE -EXPERIMENTAL_FEATURE_WARNING
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// FIR_IDENTICAL
// See KT-28847
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// FIR_IDENTICAL
import Host.bar
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// FIR_IDENTICAL
import java.io.File
import kotlin.system.exitProcess
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// FIR_IDENTICAL
@RequiresOptIn
annotation class Marker
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// FIR_IDENTICAL
// !OPT_IN: kotlin.RequiresOptIn
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DIAGNOSTICS: -UNUSED_VARIABLE
import kotlin.reflect.KProperty
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// !DIAGNOSTICS: -UNUSED_VARIABLE
import kotlin.reflect.KProperty
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// KT-9078 (NPE in control flow analysis); EA-71535
abstract class KFunctionKt9005WorkAround<out R: Any?>(private val _functionInstance: Function<R>) {
private val _reflectedFunction: kotlin.reflect.KFunction<R> = _functionInstance.<!UNRESOLVED_REFERENCE!>reflect<!>() ?: throw IllegalStateException("")
@@ -1,4 +1,3 @@
// IGNORE_REVERSED_RESOLVE
// KT-9078 (NPE in control flow analysis); EA-71535
abstract class KFunctionKt9005WorkAround<out R: Any?>(private val _functionInstance: Function<R>) {
private val _reflectedFunction: kotlin.reflect.KFunction<R> = _functionInstance.<!UNRESOLVED_REFERENCE!>reflect<!>() ?: throw IllegalStateException("")