JS: add metadata for generated continuation classes to properly implement RTTI

This commit is contained in:
Alexey Andreev
2016-11-10 18:41:30 +03:00
parent 6860b2c057
commit d41d09ffc4
6 changed files with 74 additions and 7 deletions
@@ -0,0 +1,30 @@
// WITH_RUNTIME
// WITH_REFLECT
class Controller {
suspend fun runInstanceOf(x: Continuation<Boolean>) {
val y: Any = x
x.resume(x is Continuation<*>)
}
suspend fun runCast(x: Continuation<Boolean>) {
val y: Any = x
x.resume(Continuation::class.isInstance(y as Continuation<*>))
}
}
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
c(Controller()).resume(Unit)
}
fun box(): String {
var result = ""
builder {
result = runInstanceOf().toString() + "," + runCast().toString()
}
if (result != "true,true") return "fail: $result"
return "OK"
}
@@ -4520,6 +4520,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("instanceOfContinuation.kt")
public void testInstanceOfContinuation() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt");
doTest(fileName);
}
@TestMetadata("iterateOverArray.kt")
public void testIterateOverArray() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/iterateOverArray.kt");
@@ -4520,6 +4520,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("instanceOfContinuation.kt")
public void testInstanceOfContinuation() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/instanceOfContinuation.kt");
doTest(fileName);
}
@TestMetadata("iterateOverArray.kt")
public void testIterateOverArray() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/iterateOverArray.kt");