Step 17: callable property calls
This commit is contained in:
1 parent
0b94b46d40
commit
b2d5897aa8
3 files changed
+24
-7
No files matched your search
@@ -3375,13 +3375,6 @@ class BytecodeCompiler(
|
||||
}
|
||||
}
|
||||
}
|
||||
val fieldTarget = ref.target as? FieldRef
|
||||
if (fieldTarget != null) {
|
||||
throw BytecodeCompileException(
|
||||
"Member call requires compile-time receiver type: ${fieldTarget.name}",
|
||||
Pos.builtIn
|
||||
)
|
||||
}
|
||||
val initClass = when (localTarget?.name) {
|
||||
"List" -> ObjList.type
|
||||
"Map" -> ObjMap.type
|
||||
|
||||
@@ -159,6 +159,18 @@ class BytecodeRecentOpsTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun callablePropertyCall() = runTest {
|
||||
eval(
|
||||
"""
|
||||
class C { var f = { x -> x + 1 } }
|
||||
val c = C()
|
||||
val r = (c.f)(2)
|
||||
assertEquals(3, r)
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun qualifiedThisValueRef() = runTest {
|
||||
eval(
|
||||
|
||||
Reference in new issue
Block a user