Support qualified this refs in bytecode

This commit is contained in:
sergeych committed 2026-02-09 10:16:04 +03:00
1 parent 7850d5fbde
commit f0dc0d2396
3 files changed
+27

No files matched your search

@@ -397,6 +397,7 @@ class BytecodeCompiler(
is ImplicitThisMethodCallRef -> compileImplicitThisMethodCall(ref)
is QualifiedThisMethodSlotCallRef -> compileQualifiedThisMethodSlotCall(ref)
is IndexRef -> compileIndexRef(ref)
is QualifiedThisRef -> compileThisVariantRef(ref.typeName)
else -> null
}
}
@@ -5422,6 +5423,7 @@ class BytecodeCompiler(
} ?: nameObjClass[ref.name]
?: resolveTypeNameClass(ref.name)
}
is QualifiedThisRef -> resolveTypeNameClass(ref.typeName)
is ListLiteralRef -> ObjList.type
is MapLiteralRef -> ObjMap.type
is RangeRef -> ObjRange.type
@@ -5487,6 +5489,7 @@ class BytecodeCompiler(
return when (ref) {
is LocalSlotRef -> nameObjClass[ref.name] ?: resolveTypeNameClass(ref.name)
is LocalVarRef -> nameObjClass[ref.name] ?: resolveTypeNameClass(ref.name)
is QualifiedThisRef -> resolveTypeNameClass(ref.typeName)
is ListLiteralRef -> ObjList.type
is MapLiteralRef -> ObjMap.type
is RangeRef -> ObjRange.type
@@ -140,4 +140,18 @@ class BytecodeRecentOpsTest {
""".trimIndent()
)
}
@Test
fun qualifiedThisValueRef() = runTest {
eval(
"""
class T(val v) {
fun get() {
this@T.v
}
}
assertEquals(7, T(7).get())
""".trimIndent()
)
}
}