[FIR IDE] Fix lazy resolve for local declarations

This commit is contained in:
Igor Yakovlev
2021-06-15 19:05:25 +02:00
parent c17a67ba61
commit ec80c21fd1
29 changed files with 133 additions and 133 deletions
@@ -151,7 +151,7 @@ digraph localClassesWithImplicit_kt {
60 [label="Enter block"];
61 [label="Access variable R|<local>/b|"];
62 [label="Access variable R|kotlin/String.length|"];
63 [label="Function call: this@R|/A|.R|/A.bar|()"];
63 [label="Function call: this@R|/A|.R|<local>/bar|()"];
64 [label="Exit block"];
}
65 [label="Exit when branch result"];
@@ -168,7 +168,7 @@ digraph localClassesWithImplicit_kt {
^ when () {
(R|<local>/b| is R|kotlin/String|) -> {
R|<local>/b|.R|kotlin/String.length|
this@R|/A|.R|/A.bar|()
this@R|/A|.R|<local>/bar|()
}
else -> {
Int(1)
@@ -238,7 +238,7 @@ digraph localClassesWithImplicit_kt {
81 [label="Access variable <Unresolved name: length>#"];
82 [label="Access variable R|<local>/a|"];
83 [label="Access variable R|kotlin/String.length|"];
84 [label="Function call: this@R|/A|.R|/A.baz|()"];
84 [label="Function call: this@R|/A|.R|<local>/baz|()"];
85 [label="Exit block"];
}
86 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
@@ -248,7 +248,7 @@ digraph localClassesWithImplicit_kt {
74 [label="Jump: ^bar R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
R|<local>/b|.<Unresolved name: length>#
R|<local>/a|.R|kotlin/String.length|
^ this@R|/A|.R|/A.baz|()
^ this@R|/A|.R|<local>/baz|()
}
)"];
75 [label="Stub" style="filled" fillcolor=gray];
@@ -352,7 +352,7 @@ digraph localClassesWithImplicit_kt {
123 [label="Enter block"];
124 [label="Access variable R|<local>/b|"];
125 [label="Access variable R|kotlin/String.length|"];
126 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.bar|()"];
126 [label="Function call: this@R|/<anonymous>|.R|<local>/bar|()"];
127 [label="Exit block"];
}
128 [label="Exit when branch result"];
@@ -369,7 +369,7 @@ digraph localClassesWithImplicit_kt {
^ when () {
(R|<local>/b| is R|kotlin/String|) -> {
R|<local>/b|.R|kotlin/String.length|
this@R|/<anonymous>|.R|/<anonymous>.bar|()
this@R|/<anonymous>|.R|<local>/bar|()
}
else -> {
Int(1)
@@ -439,7 +439,7 @@ digraph localClassesWithImplicit_kt {
144 [label="Access variable R|kotlin/String.length|"];
145 [label="Access variable R|<local>/b|"];
146 [label="Access variable <Unresolved name: length>#"];
147 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.baz|()"];
147 [label="Function call: this@R|/<anonymous>|.R|<local>/baz|()"];
148 [label="Exit block"];
}
149 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
@@ -449,7 +449,7 @@ digraph localClassesWithImplicit_kt {
137 [label="Jump: ^bar R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
R|<local>/a|.R|kotlin/String.length|
R|<local>/b|.<Unresolved name: length>#
^ this@R|/<anonymous>|.R|/<anonymous>.baz|()
^ this@R|/<anonymous>|.R|<local>/baz|()
}
)"];
138 [label="Stub" style="filled" fillcolor=gray];
@@ -20,7 +20,7 @@ FILE: localClassesWithImplicit.kt
^ when () {
(R|<local>/b| is R|kotlin/String|) -> {
R|<local>/b|.R|kotlin/String.length|
this@R|/A|.R|/A.bar|()
this@R|/A|.R|<local>/bar|()
}
else -> {
Int(1)
@@ -35,7 +35,7 @@ FILE: localClassesWithImplicit.kt
^bar R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
R|<local>/b|.<Unresolved name: length>#
R|<local>/a|.R|kotlin/String.length|
^ this@R|/A|.R|/A.baz|()
^ this@R|/A|.R|<local>/baz|()
}
)
}
@@ -57,7 +57,7 @@ FILE: localClassesWithImplicit.kt
^ when () {
(R|<local>/b| is R|kotlin/String|) -> {
R|<local>/b|.R|kotlin/String.length|
this@R|/<anonymous>|.R|/<anonymous>.bar|()
this@R|/<anonymous>|.R|<local>/bar|()
}
else -> {
Int(1)
@@ -72,7 +72,7 @@ FILE: localClassesWithImplicit.kt
^bar R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
R|<local>/a|.R|kotlin/String.length|
R|<local>/b|.<Unresolved name: length>#
^ this@R|/<anonymous>|.R|/<anonymous>.baz|()
^ this@R|/<anonymous>|.R|<local>/baz|()
}
)
}
@@ -57,12 +57,12 @@ FILE: CallBasedInExpressionGenerator.kt
}
public final override fun putSelector(type: R|org/jetbrains/kotlin/codegen/range/inExpression/Type|, kotlinType: R|org/jetbrains/kotlin/codegen/range/inExpression/KotlinType?|, v: R|org/jetbrains/kotlin/codegen/range/inExpression/InstructionAdapter|): R|kotlin/Unit| {
this@R|/<anonymous>|.R|/<anonymous>.invokeFunction|(R|<local>/v|)
this@R|/<anonymous>|.R|<local>/invokeFunction|(R|<local>/v|)
<Unresolved name: coerceTo>#(R|<local>/type|, R|<local>/kotlinType|, R|<local>/v|)
}
public final override fun condJump(jumpLabel: R|org/jetbrains/kotlin/codegen/range/inExpression/Label|, v: R|org/jetbrains/kotlin/codegen/range/inExpression/InstructionAdapter|, jumpIfFalse: R|kotlin/Boolean|): R|kotlin/Unit| {
this@R|/<anonymous>|.R|/<anonymous>.invokeFunction|(R|<local>/v|)
this@R|/<anonymous>|.R|<local>/invokeFunction|(R|<local>/v|)
R|<local>/v|.<Unresolved name: visitJumpInsn>#(when () {
R|<local>/jumpIfFalse| -> {
<Unresolved name: Opcodes>#.<Unresolved name: IFEQ>#
@@ -6,7 +6,7 @@ FILE: localImplicitBodies.kt
}
public final fun sss(): R|kotlin/Int| {
^sss this@R|/<anonymous>|.R|/<anonymous>.abc|()
^sss this@R|/<anonymous>|.R|<local>/abc|()
}
public final fun abc(): R|kotlin/Int| {
@@ -15,5 +15,5 @@ FILE: localImplicitBodies.kt
}
lval g: R|kotlin/Int| = R|<local>/x|.R|/<anonymous>.sss|()
lval g: R|kotlin/Int| = R|<local>/x|.R|<local>/sss|()
}
@@ -38,7 +38,7 @@ FILE: localObjects.kt
}
Q|B|.R|/B.foo|()
Q|B|.R|<local>/foo|()
}
public final val bb: <ERROR TYPE REF: Unresolved name: foo> = <Unresolved name: B>#.<Unresolved name: foo>#()
public get(): <ERROR TYPE REF: Unresolved name: foo>
@@ -20,7 +20,7 @@ FILE: localScopes.kt
}
lval base: R|BaseLocal| = R|/BaseLocal.BaseLocal|()
R|<local>/base|.R|/BaseLocal.baz|()
R|<local>/base|.R|<local>/baz|()
R|<local>/base|.R|/Bar.foo|()
lval anonymous: R|<anonymous>| = object : R|Bar| {
private constructor(): R|<anonymous>| {
@@ -32,7 +32,7 @@ FILE: localScopes.kt
}
R|<local>/anonymous|.R|/<anonymous>.baz|()
R|<local>/anonymous|.R|<local>/baz|()
R|<local>/anonymous|.R|/Bar.foo|()
local final class DerivedLocal : R|BaseLocal| {
public constructor(): R|DerivedLocal| {
@@ -45,7 +45,7 @@ FILE: localScopes.kt
}
lval derived: R|DerivedLocal| = R|/DerivedLocal.DerivedLocal|()
R|<local>/derived|.R|/DerivedLocal.gau|()
R|<local>/derived|.R|/BaseLocal.baz|()
R|<local>/derived|.R|<local>/gau|()
R|<local>/derived|.R|<local>/baz|()
R|<local>/derived|.R|/Bar.foo|()
}
@@ -10,11 +10,11 @@ FILE: foo.kt
private set(value: R|kotlin/Boolean|): R|kotlin/Unit|
public final fun bar(): R|kotlin/Boolean| {
^bar this@R|/<anonymous>|.R|/<anonymous>.result|.R|kotlin/Boolean.not|()
^bar this@R|/<anonymous>|.R|<local>/result|.R|kotlin/Boolean.not|()
}
public final override fun result(): R|kotlin/Boolean| {
^result this@R|/<anonymous>|.R|/<anonymous>.result|
^result this@R|/<anonymous>|.R|<local>/result|
}
}
@@ -71,7 +71,7 @@ FILE: first.kt
private final fun bar(): R|kotlin/Unit|
public final fun baz(): R|kotlin/Unit| {
this@R|/Local|.R|/Local.bar|()
this@R|/Local|.R|<local>/bar|()
this@R|/Local|.R|/Local.Inner.Inner|()
}
@@ -81,15 +81,15 @@ FILE: first.kt
}
public final fun foo(): R|kotlin/Unit| {
this@R|/Local|.R|/Local.bar|()
this@R|/Local|.R|<local>/bar|()
}
}
}
R|/Local.Local|().R|/Local.baz|()
R|/Local.Local|().<HIDDEN: /Local.bar is invisible>#()
R|/Local.Local|().R|<local>/baz|()
R|/Local.Local|().<HIDDEN: <local>/bar is invisible>#()
}
public final fun test(): R|kotlin/Unit| {
R|/foo|()
@@ -12,7 +12,7 @@ FILE: RedundantVisibilityModifierChecker.kt
}
R|/LocalClass.LocalClass|().R|/LocalClass.foo| = Int(1)
R|/LocalClass.LocalClass|().R|<local>/foo| = Int(1)
}
internal final inline fun internal(): R|kotlin/Unit| {
R|/f|()
@@ -14,5 +14,5 @@ FILE: callableReferenceToLocalClass.kt
}
lval datas: R|kotlin/collections/List<Data>| = Null(null)!!
lval xs: R|kotlin/collections/List<kotlin/Int>| = R|<local>/datas|.R|/myMap|<R|Data|, R|kotlin/Int|>(Q|Data|::R|/Data.x|)
lval xs: R|kotlin/collections/List<kotlin/Int>| = R|<local>/datas|.R|/myMap|<R|Data|, R|kotlin/Int|>(Q|Data|::R|<local>/x|)
}
@@ -8,7 +8,7 @@ FILE: implicitInLocalClasses.kt
}
public final fun foo(x: R|kotlin/Int|): R|kotlin/Boolean| {
^foo this@R|/A|.R|/A.bar|(R|<local>/x|)
^foo this@R|/A|.R|<local>/bar|(R|<local>/x|)
}
public final fun bar(y: R|kotlin/Int|): R|kotlin/Boolean| {
@@ -17,7 +17,7 @@ FILE: implicitInLocalClasses.kt
public final val w: R|kotlin/Boolean|
public get(): R|kotlin/Boolean| {
^ this@R|/A|.R|/A.z|
^ this@R|/A|.R|<local>/z|
}
public final val z: R|kotlin/Boolean|
@@ -28,17 +28,17 @@ FILE: implicitInLocalClasses.kt
}
lval a: R|A| = R|/A.A|()
R|/useBoolean|(R|<local>/a|.R|/A.foo|(Int(1)))
R|/useBoolean|(R|<local>/a|.R|/A.bar|(Int(1)))
R|/useBoolean|(R|<local>/a|.R|/A.w|)
R|/useBoolean|(R|<local>/a|.R|/A.z|)
R|/useBoolean|(R|<local>/a|.R|<local>/foo|(Int(1)))
R|/useBoolean|(R|<local>/a|.R|<local>/bar|(Int(1)))
R|/useBoolean|(R|<local>/a|.R|<local>/w|)
R|/useBoolean|(R|<local>/a|.R|<local>/z|)
local final class B : R|kotlin/Any| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
public final fun foo(x: R|kotlin/Int|): R|kotlin/Boolean| {
^foo this@R|/B|.R|/B.inner|.R|/B.Inner.w|
^foo this@R|/B|.R|<local>/inner|.R|<local>/w|
}
public final fun bar(y: R|kotlin/Int|): R|kotlin/Boolean| {
@@ -55,12 +55,12 @@ FILE: implicitInLocalClasses.kt
public final val w: R|kotlin/Boolean|
public get(): R|kotlin/Boolean| {
^ this@R|/B.Inner|.R|/B.Inner.z|
^ this@R|/B.Inner|.R|<local>/z|
}
public final val z: R|kotlin/Boolean|
public get(): R|kotlin/Boolean| {
^ this@R|/B|.R|/B.bar|(Int(1))
^ this@R|/B|.R|<local>/bar|(Int(1))
}
}
@@ -68,8 +68,8 @@ FILE: implicitInLocalClasses.kt
}
lval b: R|B| = R|/B.B|()
R|/useBoolean|(R|<local>/b|.R|/B.foo|(Int(1)))
R|/useBoolean|(R|<local>/b|.R|/B.bar|(Int(1)))
R|/useBoolean|(R|<local>/b|.R|/B.inner|.R|/B.Inner.w|)
R|/useBoolean|(R|<local>/b|.R|/B.inner|.R|/B.Inner.z|)
R|/useBoolean|(R|<local>/b|.R|<local>/foo|(Int(1)))
R|/useBoolean|(R|<local>/b|.R|<local>/bar|(Int(1)))
R|/useBoolean|(R|<local>/b|.R|<local>/inner|.R|<local>/w|)
R|/useBoolean|(R|<local>/b|.R|<local>/inner|.R|<local>/z|)
}
@@ -10,24 +10,24 @@ FILE: objectInnerClass.kt
}
public final fun R|<anonymous>.Base|.zoo(): R|kotlin/Unit| {
lval x: R|B| = this@R|/<anonymous>.Child.zoo|.R|/<anonymous>.Base.property|
lval x: R|B| = this@R|<local>/zoo|.R|<local>/property|
}
public final fun foo(): R|kotlin/Unit| {
this@R|/<anonymous>.Child|.R|/<anonymous>.Base.baseFun|()
lval x: R|B| = this@R|/<anonymous>.Child|.R|/<anonymous>.Base.property|
(this@R|/<anonymous>.Child|, this@R|/<anonymous>.Child|).R|/<anonymous>.Child.zoo|()
this@R|/<anonymous>.Child|.R|<local>/baseFun|()
lval x: R|B| = this@R|/<anonymous>.Child|.R|<local>/property|
(this@R|/<anonymous>.Child|, this@R|/<anonymous>.Child|).R|<local>/zoo|()
(this@R|/<anonymous>|, this@R|/<anonymous>.Child|).R|/<anonymous>.hoo|()
}
}
public final fun R|<anonymous>.Child|.voo(): R|kotlin/Unit| {
lval x: R|B| = this@R|/<anonymous>.voo|.R|/<anonymous>.Base.property|
lval x: R|B| = this@R|/<anonymous>.voo|.R|<local>/property|
}
public final fun R|<anonymous>.Base|.hoo(): R|kotlin/Unit| {
lval x: R|B| = this@R|/<anonymous>.hoo|.R|/<anonymous>.Base.property|
lval x: R|B| = this@R|/<anonymous>.hoo|.R|<local>/property|
}
local open inner class Base : R|kotlin/Any| {
@@ -45,16 +45,16 @@ FILE: objectInnerClass.kt
public final fun caseForBase(): R|kotlin/Unit| {
lval base: R|<anonymous>.Base| = this@R|/<anonymous>|.R|/<anonymous>.Base.Base|(R|/B.B|())
R|<local>/base|.R|/<anonymous>.Base.baseFun|()
R|<local>/base|.R|/<anonymous>.Base.property|
R|<local>/base|.R|<local>/baseFun|()
R|<local>/base|.R|<local>/property|
(this@R|/<anonymous>|, R|<local>/base|).R|/<anonymous>.hoo|()
}
public final fun caseForChild(): R|kotlin/Unit| {
lval child: R|<anonymous>.Child| = this@R|/<anonymous>|.R|/<anonymous>.Child.Child|(R|/B.B|())
R|<local>/child|.R|/<anonymous>.Base.baseFun|()
R|<local>/child|.R|/<anonymous>.Base.property|
R|<local>/child|.R|/<anonymous>.Child.foo|()
R|<local>/child|.R|<local>/baseFun|()
R|<local>/child|.R|<local>/property|
R|<local>/child|.R|<local>/foo|()
(this@R|/<anonymous>|, R|<local>/child|).R|/<anonymous>.hoo|()
(this@R|/<anonymous>|, R|<local>/child|).R|/<anonymous>.voo|()
}
@@ -135,24 +135,24 @@ FILE: objectInnerClass.kt
}
public final fun R|Case3.<anonymous>.Base|.zoo(): R|kotlin/Unit| {
lval x: R|B| = this@R|/Case3.<anonymous>.Child.zoo|.R|/Case3.<anonymous>.Base.property|
lval x: R|B| = this@R|<local>/zoo|.R|<local>/property|
}
public final fun foo(): R|kotlin/Unit| {
this@R|/Case3.<anonymous>.Child|.R|/Case3.<anonymous>.Base.baseFun|()
lval x: R|B| = this@R|/Case3.<anonymous>.Child|.R|/Case3.<anonymous>.Base.property|
(this@R|/Case3.<anonymous>.Child|, this@R|/Case3.<anonymous>.Child|).R|/Case3.<anonymous>.Child.zoo|()
this@R|/Case3.<anonymous>.Child|.R|<local>/baseFun|()
lval x: R|B| = this@R|/Case3.<anonymous>.Child|.R|<local>/property|
(this@R|/Case3.<anonymous>.Child|, this@R|/Case3.<anonymous>.Child|).R|<local>/zoo|()
(this@R|/<anonymous>|, this@R|/Case3.<anonymous>.Child|).R|/<anonymous>.hoo|()
}
}
public final fun R|Case3.<anonymous>.Child|.voo(): R|kotlin/Unit| {
lval x: R|B| = this@R|/<anonymous>.voo|.R|/Case3.<anonymous>.Base.property|
lval x: R|B| = this@R|/<anonymous>.voo|.R|<local>/property|
}
public final fun R|Case3.<anonymous>.Base|.hoo(): R|kotlin/Unit| {
lval x: R|B| = this@R|/<anonymous>.hoo|.R|/Case3.<anonymous>.Base.property|
lval x: R|B| = this@R|/<anonymous>.hoo|.R|<local>/property|
}
local open inner class Base : R|kotlin/Any| {
@@ -170,16 +170,16 @@ FILE: objectInnerClass.kt
public final fun caseForBase(): R|kotlin/Unit| {
lval base: R|Case3.<anonymous>.Base| = this@R|/<anonymous>|.R|/Case3.<anonymous>.Base.Base|(R|/B.B|())
R|<local>/base|.R|/Case3.<anonymous>.Base.baseFun|()
R|<local>/base|.R|/Case3.<anonymous>.Base.property|
R|<local>/base|.R|<local>/baseFun|()
R|<local>/base|.R|<local>/property|
(this@R|/<anonymous>|, R|<local>/base|).R|/<anonymous>.hoo|()
}
public final fun caseForChild(): R|kotlin/Unit| {
lval child: R|Case3.<anonymous>.Child| = this@R|/<anonymous>|.R|/Case3.<anonymous>.Child.Child|(R|/B.B|())
R|<local>/child|.R|/Case3.<anonymous>.Base.baseFun|()
R|<local>/child|.R|/Case3.<anonymous>.Base.property|
R|<local>/child|.R|/Case3.<anonymous>.Child.foo|()
R|<local>/child|.R|<local>/baseFun|()
R|<local>/child|.R|<local>/property|
R|<local>/child|.R|<local>/foo|()
(this@R|/<anonymous>|, R|<local>/child|).R|/<anonymous>.hoo|()
(this@R|/<anonymous>|, R|<local>/child|).R|/<anonymous>.voo|()
}
@@ -12,7 +12,7 @@ digraph inAnonymousObject_kt {
2 [label="Exit anonymous object"];
3 [label="Variable declaration: lval obj: R|<anonymous>|"];
4 [label="Access variable R|<local>/obj|"];
5 [label="Function call: R|<local>/obj|.R|/<anonymous>.run|()"];
5 [label="Function call: R|<local>/obj|.R|<local>/run|()"];
6 [label="Function call: R|<local>/d|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
7 [label="Exit block"];
}
@@ -70,7 +70,7 @@ digraph inAnonymousObject_kt {
color=blue
20 [label="Enter block"];
21 [label="Access variable R|<local>/b|"];
22 [label="Assignment: R|/<anonymous>.leaked|"];
22 [label="Assignment: R|<local>/leaked|"];
23 [label="Exit block"];
}
24 [label="Exit init block" style="filled" fillcolor=red];
@@ -21,7 +21,7 @@ FILE: inAnonymousObject.kt
public get(): R|kotlin/Any|
init {
this@R|/<anonymous>|.R|/<anonymous>.leaked| = R|<local>/b|
this@R|/<anonymous>|.R|<local>/leaked| = R|<local>/b|
}
public final override fun run(): R|kotlin/Unit| {
@@ -30,6 +30,6 @@ FILE: inAnonymousObject.kt
}
R|<local>/obj|.R|/<anonymous>.run|()
R|<local>/obj|.R|<local>/run|()
R|<local>/d|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
@@ -11,7 +11,7 @@ digraph inLocalClass_kt {
1 [label="Enter block"];
2 [label="Exit local class foo"];
3 [label="Function call: R|/LocalClass.LocalClass|()"];
4 [label="Function call: R|/LocalClass.LocalClass|().R|/LocalClass.run|()"];
4 [label="Function call: R|/LocalClass.LocalClass|().R|<local>/run|()"];
5 [label="Function call: R|<local>/e|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
6 [label="Exit block"];
}
@@ -77,7 +77,7 @@ digraph inLocalClass_kt {
color=blue
22 [label="Enter block"];
23 [label="Access variable R|<local>/c|"];
24 [label="Assignment: R|/LocalClass.leaked|"];
24 [label="Assignment: R|<local>/leaked|"];
25 [label="Exit block"];
}
26 [label="Exit init block" style="filled" fillcolor=red];
@@ -23,7 +23,7 @@ FILE: inLocalClass.kt
}
init {
this@R|/LocalClass|.R|/LocalClass.leaked| = R|<local>/c|
this@R|/LocalClass|.R|<local>/leaked| = R|<local>/c|
}
public final fun run(): R|kotlin/Unit| {
@@ -32,6 +32,6 @@ FILE: inLocalClass.kt
}
R|/LocalClass.LocalClass|().R|/LocalClass.run|()
R|/LocalClass.LocalClass|().R|<local>/run|()
R|<local>/e|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
@@ -15,7 +15,7 @@ FILE: anonymousInDelegate.kt
}
^ R|<local>/foo|.R|/<anonymous>.bar|()
^ R|<local>/foo|.R|<local>/bar|()
}
)
public get(): R|kotlin/Int| {
@@ -57,12 +57,12 @@ FILE: selfReferenceToCompanionObject.kt
public get(): R|kotlin/String|
public final val closure2: R|() -> kotlin/String| = fun <anonymous>(): R|kotlin/String| <inline=Unknown> {
^ this@R|/<anonymous>|.R|/<anonymous>.y|
^ this@R|/<anonymous>|.R|<local>/y|
}
public get(): R|() -> kotlin/String|
public final override val z: R|kotlin/String| = this@R|/<anonymous>|.R|/<anonymous>.closure2|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
public final override val z: R|kotlin/String| = this@R|/<anonymous>|.R|<local>/closure2|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
public get(): R|kotlin/String|
}
@@ -692,7 +692,7 @@ class DeclarationsConverter(
)?.let { declarations += it.firConstructor }
classBodyNode?.also {
// Use ANONYMOUS_OBJECT_NAME for the owner class id of enum entry declarations
withChildClassName(ANONYMOUS_OBJECT_NAME, isLocal = true) {
withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true) {
declarations += convertClassBody(it, enumClassWrapper)
}
}
@@ -1407,7 +1407,7 @@ class DeclarationsConverter(
isSuspend = modifiers.hasSuspend()
}
symbol = FirNamedFunctionSymbol(callableIdForName(functionName, isLocal))
symbol = FirNamedFunctionSymbol(callableIdForName(functionName))
dispatchReceiverType = currentDispatchReceiverType()
}
}
@@ -787,7 +787,7 @@ open class RawFirBuilder(
typeParameters
)
// Use ANONYMOUS_OBJECT_NAME for the owner class id for enum entry declarations (see KT-42351)
withChildClassName(ANONYMOUS_OBJECT_NAME, isLocal = true) {
withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true) {
for (declaration in ktEnumEntry.declarations) {
declarations += declaration.toFirDeclaration(
correctedEnumSelfTypeRef,
@@ -816,7 +816,7 @@ open class RawFirBuilder(
val isLocal = classOrObject.isLocal || classOrObject.getStrictParentOfType<KtEnumEntry>() != null
return withChildClassName(
classOrObject.nameAsSafeName,
isLocal = isLocal
forceLocalContext = isLocal
) {
val classKind = when (classOrObject) {
is KtObjectDeclaration -> ClassKind.OBJECT
@@ -1022,7 +1022,7 @@ open class RawFirBuilder(
receiverTypeRef = receiverType
name = function.nameAsSafeName
labelName = runIf(!name.isSpecial) { name.identifier }
symbol = FirNamedFunctionSymbol(callableIdForName(function.nameAsSafeName, function.isLocal))
symbol = FirNamedFunctionSymbol(callableIdForName(function.nameAsSafeName))
dispatchReceiverType = currentDispatchReceiverType()
status = FirDeclarationStatusImpl(
if (function.isLocal) Visibilities.Local else function.visibility,
@@ -64,11 +64,12 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
/**** Class name utils ****/
inline fun <T> withChildClassName(
name: Name,
isLocal: Boolean = context.firFunctionTargets.isNotEmpty(),
forceLocalContext: Boolean = false,
l: () -> T
): T {
context.className = context.className.child(name)
context.localBits.add(isLocal)
val oldForcedLocalContext = context.forcedLocalContext
context.forcedLocalContext = forceLocalContext || context.forcedLocalContext
val dispatchReceiversNumber = context.dispatchReceiverTypesStack.size
return try {
l()
@@ -82,7 +83,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
}
context.className = context.className.parent()
context.localBits.removeLast()
context.forcedLocalContext = oldForcedLocalContext
}
}
@@ -99,9 +100,9 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
}
}
fun callableIdForName(name: Name, local: Boolean = false) =
fun callableIdForName(name: Name) =
when {
local -> {
context.inLocalContext -> {
val pathFqName =
context.firFunctionTargets.fold(
if (context.className == FqName.ROOT) context.packageFqName else context.currentClassId.asSingleFqName()
@@ -20,8 +20,9 @@ import org.jetbrains.kotlin.name.Name
class Context<T> {
lateinit var packageFqName: FqName
var className: FqName = FqName.ROOT
val localBits: MutableList<Boolean> = mutableListOf()
val currentClassId get() = ClassId(packageFqName, className, localBits.lastOrNull() ?: false)
var forcedLocalContext: Boolean = false
val inLocalContext get() = forcedLocalContext || firFunctionTargets.isNotEmpty()
val currentClassId get() = ClassId(packageFqName, className, inLocalContext)
val firFunctionTargets = mutableListOf<FirFunctionTarget>()
val calleeNamesForLambda = mutableListOf<Name>()
@@ -11,11 +11,9 @@ import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.resolve.ScopeSession
import org.jetbrains.kotlin.fir.resolve.transformers.FirPhaseManager
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
import org.jetbrains.kotlin.idea.fir.low.level.api.api.tryCollectDesignation
import org.jetbrains.kotlin.idea.fir.low.level.api.file.builder.ModuleFileCache
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyDeclarationResolver
import org.jetbrains.kotlin.idea.fir.low.level.api.sessions.FirSessionInvalidator
import org.jetbrains.kotlin.idea.fir.low.level.api.util.isLocalDeclaration
@ThreadSafeMutableState
internal class IdeFirPhaseManager(
@@ -28,7 +26,6 @@ internal class IdeFirPhaseManager(
requiredPhase: FirResolvePhase
) {
val fir = symbol.fir as FirDeclaration
if (fir.isLocalDeclaration) return
try {
if (fir.resolvePhase < requiredPhase) { //TODO Make thread safe
lazyDeclarationResolver.lazyResolveDeclaration(
@@ -36,7 +33,8 @@ internal class IdeFirPhaseManager(
moduleFileCache = cache,
scopeSession = ScopeSession(),
toPhase = requiredPhase,
checkPCE = true
checkPCE = true,
skipLocalDeclaration = true,
)
}
} catch (e: Throwable) {
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.fir.renderWithType
import org.jetbrains.kotlin.fir.resolve.firProvider
import org.jetbrains.kotlin.fir.resolve.toFirRegularClass
import org.jetbrains.kotlin.idea.fir.low.level.api.util.getContainingFile
import org.jetbrains.kotlin.idea.fir.low.level.api.util.isLocalDeclaration
import org.jetbrains.kotlin.idea.util.ifFalse
class FirDeclarationDesignationWithFile(
@@ -55,14 +54,16 @@ private fun FirRegularClass.collectForNonLocal(): List<FirDeclaration> {
}
private fun collectDesignationPath(declaration: FirDeclaration): List<FirDeclaration>? {
if (declaration.isLocalDeclaration) return null
val containingClass = when (declaration) {
is FirCallableDeclaration<*> -> {
val isLocalMember = (declaration as? FirCallableMemberDeclaration<*>)?.status?.visibility == Visibilities.Local
if (isLocalMember) return null
if (declaration.symbol.callableId.isLocal) return null
if ((declaration as? FirCallableMemberDeclaration<*>)?.status?.visibility == Visibilities.Local) return null
when (declaration) {
is FirSimpleFunction, is FirProperty, is FirField, is FirConstructor ->
declaration.containingClass()?.toFirRegularClass(declaration.moduleData.session)
is FirSimpleFunction, is FirProperty, is FirField, is FirConstructor -> {
val klass = declaration.containingClass() ?: return emptyList()
if (klass.classId.isLocal) return null
klass.toFirRegularClass(declaration.moduleData.session)
}
else -> return null
}
}
@@ -12,6 +12,9 @@ import org.jetbrains.kotlin.fir.resolve.ScopeSession
import org.jetbrains.kotlin.fir.resolve.transformers.FirImportResolveTransformer
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirTowerDataContextCollector
import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirDeclarationDesignationWithFile
import org.jetbrains.kotlin.idea.fir.low.level.api.api.collectDesignationWithFile
import org.jetbrains.kotlin.idea.fir.low.level.api.api.tryCollectDesignationWithFile
import org.jetbrains.kotlin.idea.fir.low.level.api.element.builder.getNonLocalContainingOrThisDeclaration
import org.jetbrains.kotlin.idea.fir.low.level.api.file.builder.FirFileBuilder
import org.jetbrains.kotlin.idea.fir.low.level.api.file.builder.ModuleFileCache
import org.jetbrains.kotlin.idea.fir.low.level.api.file.builder.runCustomResolveUnderLock
@@ -22,6 +25,7 @@ import org.jetbrains.kotlin.idea.fir.low.level.api.transformers.FirProviderInter
import org.jetbrains.kotlin.idea.fir.low.level.api.transformers.LazyTransformerFactory
import org.jetbrains.kotlin.idea.fir.low.level.api.util.checkCanceled
import org.jetbrains.kotlin.idea.fir.low.level.api.util.ensurePhase
import org.jetbrains.kotlin.idea.fir.low.level.api.util.findSourceNonLocalFirDeclaration
import org.jetbrains.kotlin.idea.util.ifTrue
internal class FirLazyDeclarationResolver(private val firFileBuilder: FirFileBuilder) {
@@ -189,6 +193,7 @@ internal class FirLazyDeclarationResolver(private val firFileBuilder: FirFileBui
toPhase: FirResolvePhase,
checkPCE: Boolean,
declarationPhaseDowngraded: Boolean = false,
skipLocalDeclaration: Boolean = false,
) {
if (toPhase == FirResolvePhase.RAW_FIR) return
//TODO Should be synchronised
@@ -205,10 +210,29 @@ internal class FirLazyDeclarationResolver(private val firFileBuilder: FirFileBui
return
}
val provider = firDeclarationToResolve.moduleData.session.firIdeProvider
val (designation, forceToBody) =
firDeclarationToResolve.getNonLocalDeclarationToResolveAndForceUpgradeToBodyPhase(provider, moduleFileCache, firFileBuilder)
val neededPhase = if (forceToBody) FirResolvePhase.BODY_RESOLVE else toPhase
val requestedDeclarationDesignation = firDeclarationToResolve.tryCollectDesignationWithFile()
val designation: FirDeclarationDesignationWithFile
val neededPhase: FirResolvePhase
if (requestedDeclarationDesignation != null) {
designation = requestedDeclarationDesignation
neededPhase = toPhase
} else {
val possiblyLocalDeclaration = firDeclarationToResolve.getKtDeclarationForFirElement()
val nonLocalDeclaration = possiblyLocalDeclaration.getNonLocalContainingOrThisDeclaration()
?: error("Container for local declaration cannot be null")
val isLocalDeclarationResolveRequested = possiblyLocalDeclaration != nonLocalDeclaration
if (isLocalDeclarationResolveRequested && skipLocalDeclaration) return
val nonLocalFirDeclaration = nonLocalDeclaration.findSourceNonLocalFirDeclaration(
firFileBuilder,
firDeclarationToResolve.moduleData.session.firIdeProvider.symbolProvider,
moduleFileCache
)
designation = nonLocalFirDeclaration.collectDesignationWithFile()
neededPhase = if (isLocalDeclarationResolveRequested) FirResolvePhase.BODY_RESOLVE else toPhase
}
//TODO Should be synchronised
if (!designation.declaration.isValidForResolve()) return
@@ -21,18 +21,9 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
internal fun FirDeclaration.getNonLocalDeclarationToResolveAndForceUpgradeToBodyPhase(
provider: FirProvider,
moduleFileCache: ModuleFileCache,
firFileBuilder: FirFileBuilder
): Pair<FirDeclarationDesignationWithFile, Boolean> {
internal fun FirDeclaration.getKtDeclarationForFirElement(): KtDeclaration {
require(this !is FirFile)
val nonLocalDesignation = tryCollectDesignationWithFile()
if (nonLocalDesignation != null) {
return nonLocalDesignation to false
}
val ktDeclaration = (psi as? KtDeclaration) ?: run {
(source as? FirFakeSourceElement<*>).psi?.parentOfType()
}
@@ -61,13 +52,7 @@ internal fun FirDeclaration.getNonLocalDeclarationToResolveAndForceUpgradeToBody
check(declaration is KtDeclaration) {
"FirDeclaration should have a PSI of type KtDeclaration"
}
val nonLocalDeclaration = declaration.getNonLocalContainingOrThisDeclaration()
?: error("Container for local declaration cannot be null")
val firDeclaration = nonLocalDeclaration.findSourceNonLocalFirDeclaration(firFileBuilder, provider.symbolProvider, moduleFileCache)
val needUpgrade = nonLocalDeclaration !== declaration
return firDeclaration.collectDesignationWithFile() to needUpgrade
return declaration
}
internal fun declarationCanBeLazilyResolved(declaration: KtDeclaration): Boolean {
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.idea.fir.low.level.api.util
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.psi
import org.jetbrains.kotlin.fir.realPsi
@@ -125,13 +124,4 @@ private fun KtClassLikeDeclaration.findFir(firSymbolProvider: FirSymbolProvider)
val FirDeclaration.isGeneratedDeclaration
get() = realPsi == null
internal val FirDeclaration.isLocalDeclaration: Boolean
get() = when (this) {
is FirCallableDeclaration<*> ->
((this as? FirCallableMemberDeclaration<*>)?.status?.visibility == Visibilities.Local)
is FirClassLikeDeclaration<*> -> isLocal
else -> true
}
get() = realPsi == null
@@ -1,9 +1,9 @@
public? final? [BODY_RESOLVE] class E : R|kotlin/Any| {
public? [BODY_RESOLVE] constructor(): R|E| {
public final [BODY_RESOLVE] class E : R|kotlin/Any| {
public [BODY_RESOLVE] constructor(): R|E| {
super<R|kotlin/Any|>()
}
public? final? [BODY_RESOLVE] fun e(): R|kotlin/Int| {
public final [BODY_RESOLVE] fun e(): R|kotlin/Int| {
^e R|<local>/x|
}
@@ -1,3 +1,3 @@
local final? fun <local>/bar(): R|kotlin/Unit| {
local final? fun test/locals/Owner.bar(): R|kotlin/Unit| {
baz#(i#, x#)
}