[Analysis API] Keep the collected 'FirTowerDataContext' mutable

'ContextCollector' is used for computing context of 'FirCodeFragment's.
Code fragments themselves might contain additional smart cast operations
that modify the context receiver stack.

^KT-63056 Fixed
This commit is contained in:
Yan Zhulanow
2023-11-01 19:04:59 +09:00
committed by Space Team
parent 4a7f12a8eb
commit 0944e8fc36
14 changed files with 87 additions and 27 deletions
@@ -0,0 +1,3 @@
ExtensionReceiver[name: apply; isMutated: false; displayText: this@apply]
apply@fun R|Foo|.<anonymous>(): R|kotlin/Unit| <inline=Inline, kind=EXACTLY_ONCE>
R|Foo|
@@ -0,0 +1,16 @@
MODULE_FRAGMENT
FILE fqName:<root> fileName:fragment.kt
CLASS CLASS name:CodeFragment modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.CodeFragment
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
FUN name:run visibility:public modality:FINAL <> (p0:<root>.Foo) returnType:kotlin.Int
VALUE_PARAMETER name:p0 index:0 type:<root>.Foo
EXPRESSION_BODY
BLOCK type=kotlin.Int origin=null
TYPE_OP type=<root>.FooImpl origin=CAST typeOperand=<root>.FooImpl
GET_VAR 'p0: <root>.Foo declared in <root>.CodeFragment.run' type=<root>.Foo origin=null
CALL 'public final fun <get-n> (): kotlin.Int declared in <root>.FooImpl' type=kotlin.Int origin=GET_PROPERTY
$this: TYPE_OP type=<root>.FooImpl origin=IMPLICIT_CAST typeOperand=<root>.FooImpl
GET_VAR 'p0: <root>.Foo declared in <root>.CodeFragment.run' type=<root>.Foo origin=null
@@ -0,0 +1,13 @@
interface Foo
class FooImpl : Foo {
val n: Int = 5
}
fun makeFoo(): Foo = FooImpl()
fun main() {
makeFoo().apply {
<caret>Unit
}
}
@@ -0,0 +1,5 @@
public final class CodeFragment {
// source: 'fragment.kt'
public method <init>(): void
public final static method run(p0: Foo): int
}