72def186a3
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
153 lines
3.1 KiB
Kotlin
Vendored
153 lines
3.1 KiB
Kotlin
Vendored
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect
|
|
// !OPT_IN: kotlin.internal.ContractsDsl
|
|
|
|
import kotlin.contracts.*
|
|
|
|
@kotlin.contracts.ExperimentalContracts
|
|
inline fun inlineMe(block: () -> Unit) {
|
|
contract {
|
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
}
|
|
block()
|
|
}
|
|
|
|
@kotlin.contracts.ExperimentalContracts
|
|
inline fun crossinlineMe(crossinline block: () -> Unit) {
|
|
contract {
|
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
}
|
|
block()
|
|
}
|
|
|
|
@Suppress("NOTHING_TO_INLINE")
|
|
@kotlin.contracts.ExperimentalContracts
|
|
inline fun noinlineMe(noinline block: () -> Unit) {
|
|
contract {
|
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
}
|
|
block()
|
|
}
|
|
|
|
@kotlin.contracts.ExperimentalContracts
|
|
fun notinline(block: () -> Unit) {
|
|
contract {
|
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
}
|
|
block()
|
|
}
|
|
|
|
@kotlin.contracts.ExperimentalContracts
|
|
class Test {
|
|
val a: String
|
|
val b: String
|
|
val c: String
|
|
val d: String
|
|
|
|
init {
|
|
inlineMe {
|
|
a = "allowed"
|
|
}
|
|
crossinlineMe {
|
|
<!CAPTURED_VAL_INITIALIZATION!>b<!> = "not allowed"
|
|
}
|
|
noinlineMe {
|
|
<!CAPTURED_VAL_INITIALIZATION!>c<!> = "not allowed"
|
|
}
|
|
notinline {
|
|
<!CAPTURED_VAL_INITIALIZATION!>d<!> = "not allowed"
|
|
}
|
|
}
|
|
}
|
|
|
|
@kotlin.contracts.ExperimentalContracts
|
|
class Test1 {
|
|
val a: String = ""
|
|
val b: String = ""
|
|
val c: String = ""
|
|
val d: String = ""
|
|
|
|
init {
|
|
inlineMe {
|
|
<!VAL_REASSIGNMENT!>a<!> += "allowed"
|
|
}
|
|
crossinlineMe {
|
|
<!VAL_REASSIGNMENT!>b<!> += "not allowed"
|
|
}
|
|
noinlineMe {
|
|
<!VAL_REASSIGNMENT!>c<!> += "not allowed"
|
|
}
|
|
notinline {
|
|
<!VAL_REASSIGNMENT!>d<!> += "not allowed"
|
|
}
|
|
}
|
|
}
|
|
|
|
@kotlin.contracts.ExperimentalContracts
|
|
class Test2 {
|
|
val a: String = ""
|
|
val b: String = ""
|
|
val c: String = ""
|
|
val d: String = ""
|
|
|
|
init {
|
|
var blackhole = ""
|
|
inlineMe {
|
|
blackhole += a
|
|
}
|
|
crossinlineMe {
|
|
blackhole += b
|
|
}
|
|
noinlineMe {
|
|
blackhole += c
|
|
}
|
|
notinline {
|
|
blackhole += d
|
|
}
|
|
}
|
|
}
|
|
|
|
@kotlin.contracts.ExperimentalContracts
|
|
class Test4 {
|
|
val a: String = ""
|
|
val b: String = ""
|
|
val c: String = ""
|
|
val d: String = ""
|
|
|
|
init {
|
|
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>blackhole<!>: String
|
|
inlineMe {
|
|
blackhole = a
|
|
}
|
|
crossinlineMe {
|
|
blackhole = b
|
|
}
|
|
noinlineMe {
|
|
blackhole = c
|
|
}
|
|
notinline {
|
|
blackhole = d
|
|
}
|
|
}
|
|
}
|
|
|
|
@kotlin.contracts.ExperimentalContracts
|
|
class Test5 {
|
|
val a: String
|
|
val b: String
|
|
val c: String
|
|
val d: String
|
|
|
|
val aInit = inlineMe {
|
|
a = "OK"
|
|
}
|
|
val bInit = crossinlineMe {
|
|
<!CAPTURED_VAL_INITIALIZATION!>b<!> = "OK"
|
|
}
|
|
val cInit = noinlineMe {
|
|
<!CAPTURED_VAL_INITIALIZATION!>c<!> = "OK"
|
|
}
|
|
val dInit = notinline {
|
|
<!CAPTURED_VAL_INITIALIZATION!>d<!> = "OK"
|
|
}
|
|
}
|