[FIR] Fix invalid CallableId for methods in anonymous objects
This commit is contained in:
committed by
teamcityserver
parent
47aa04d55d
commit
30c381f16d
+4
-4
@@ -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|<local>/bar|()"];
|
||||
126 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.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|<local>/bar|()
|
||||
this@R|/<anonymous>|.R|/<anonymous>.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|<local>/baz|()"];
|
||||
147 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.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|<local>/baz|()
|
||||
^ this@R|/<anonymous>|.R|/<anonymous>.baz|()
|
||||
}
|
||||
)"];
|
||||
138 [label="Stub" style="filled" fillcolor=gray];
|
||||
|
||||
+2
-2
@@ -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|<local>/bar|()
|
||||
this@R|/<anonymous>|.R|/<anonymous>.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|<local>/baz|()
|
||||
^ this@R|/<anonymous>|.R|/<anonymous>.baz|()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -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|<local>/invokeFunction|(R|<local>/v|)
|
||||
this@R|/<anonymous>|.R|/<anonymous>.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|<local>/invokeFunction|(R|<local>/v|)
|
||||
this@R|/<anonymous>|.R|/<anonymous>.invokeFunction|(R|<local>/v|)
|
||||
R|<local>/v|.<Unresolved name: visitJumpInsn>#(when () {
|
||||
R|<local>/jumpIfFalse| -> {
|
||||
<Unresolved name: Opcodes>#.<Unresolved name: IFEQ>#
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ FILE: localImplicitBodies.kt
|
||||
}
|
||||
|
||||
public final fun sss(): R|kotlin/Int| {
|
||||
^sss this@R|/<anonymous>|.R|<local>/abc|()
|
||||
^sss this@R|/<anonymous>|.R|/<anonymous>.abc|()
|
||||
}
|
||||
|
||||
public final fun abc(): R|kotlin/Int| {
|
||||
@@ -15,5 +15,5 @@ FILE: localImplicitBodies.kt
|
||||
|
||||
}
|
||||
|
||||
lval g: R|kotlin/Int| = R|<local>/x|.R|<local>/sss|()
|
||||
lval g: R|kotlin/Int| = R|<local>/x|.R|/<anonymous>.sss|()
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ FILE: localScopes.kt
|
||||
|
||||
}
|
||||
|
||||
R|<local>/anonymous|.R|<local>/baz|()
|
||||
R|<local>/anonymous|.R|/<anonymous>.baz|()
|
||||
R|<local>/anonymous|.R|/Bar.foo|()
|
||||
local final class DerivedLocal : R|BaseLocal| {
|
||||
public constructor(): R|DerivedLocal| {
|
||||
|
||||
+2
-2
@@ -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|<local>/result|.R|kotlin/Boolean.not|()
|
||||
^bar this@R|/<anonymous>|.R|/<anonymous>.result|.R|kotlin/Boolean.not|()
|
||||
}
|
||||
|
||||
public final override fun result(): R|kotlin/Boolean| {
|
||||
^result this@R|/<anonymous>|.R|<local>/result|
|
||||
^result this@R|/<anonymous>|.R|/<anonymous>.result|
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -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|<local>/run|()"];
|
||||
5 [label="Function call: R|<local>/obj|.R|/<anonymous>.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|<local>/leaked|"];
|
||||
22 [label="Assignment: R|/<anonymous>.leaked|"];
|
||||
23 [label="Exit block"];
|
||||
}
|
||||
24 [label="Exit init block" style="filled" fillcolor=red];
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ FILE: inAnonymousObject.kt
|
||||
public get(): R|kotlin/Any|
|
||||
|
||||
init {
|
||||
this@R|/<anonymous>|.R|<local>/leaked| = R|<local>/b|
|
||||
this@R|/<anonymous>|.R|/<anonymous>.leaked| = R|<local>/b|
|
||||
}
|
||||
|
||||
public final override fun run(): R|kotlin/Unit| {
|
||||
@@ -30,6 +30,6 @@ FILE: inAnonymousObject.kt
|
||||
|
||||
}
|
||||
|
||||
R|<local>/obj|.R|<local>/run|()
|
||||
R|<local>/obj|.R|/<anonymous>.run|()
|
||||
R|<local>/d|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -15,7 +15,7 @@ FILE: anonymousInDelegate.kt
|
||||
|
||||
}
|
||||
|
||||
^ R|<local>/foo|.R|<local>/bar|()
|
||||
^ R|<local>/foo|.R|/<anonymous>.bar|()
|
||||
}
|
||||
)
|
||||
public get(): R|kotlin/Int| {
|
||||
|
||||
+2
-2
@@ -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|<local>/y|
|
||||
^ this@R|/<anonymous>|.R|/<anonymous>.y|
|
||||
}
|
||||
|
||||
public get(): 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 final override val z: R|kotlin/String| = this@R|/<anonymous>|.R|/<anonymous>.closure2|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
|
||||
@@ -942,7 +942,7 @@ open class RawFirBuilder(
|
||||
|
||||
override fun visitObjectLiteralExpression(expression: KtObjectLiteralExpression, data: Unit): FirElement {
|
||||
val objectDeclaration = expression.objectDeclaration
|
||||
return withChildClassName(ANONYMOUS_OBJECT_NAME) {
|
||||
return withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true) {
|
||||
buildAnonymousObject {
|
||||
source = objectDeclaration.toFirSourceElement()
|
||||
moduleData = baseModuleData
|
||||
|
||||
+3
-3
@@ -102,10 +102,12 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
|
||||
fun callableIdForName(name: Name) =
|
||||
when {
|
||||
context.className.shortNameOrSpecial() == ANONYMOUS_OBJECT_NAME -> CallableId(ANONYMOUS_CLASS_ID, name)
|
||||
context.className.isRoot && !context.inLocalContext -> CallableId(context.packageFqName, name)
|
||||
context.inLocalContext -> {
|
||||
val pathFqName =
|
||||
context.firFunctionTargets.fold(
|
||||
if (context.className == FqName.ROOT) context.packageFqName else context.currentClassId.asSingleFqName()
|
||||
if (context.className.isRoot) context.packageFqName else context.currentClassId.asSingleFqName()
|
||||
) { result, firFunctionTarget ->
|
||||
if (firFunctionTarget.isLambda || firFunctionTarget.labelName == null)
|
||||
result
|
||||
@@ -114,8 +116,6 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
}
|
||||
CallableId(name, pathFqName)
|
||||
}
|
||||
context.className == FqName.ROOT -> CallableId(context.packageFqName, name)
|
||||
context.className.shortName() == ANONYMOUS_OBJECT_NAME -> CallableId(ANONYMOUS_CLASS_ID, name)
|
||||
else -> CallableId(context.packageFqName, context.className, name)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user