JS/RTTI: support unsafe casts

#KT-2670 fixed
This commit is contained in:
Alexey Tsvetkov
2015-06-11 15:31:54 +03:00
committed by Alexey Andreev
parent 1d2da9729e
commit 3fd387d4a6
17 changed files with 196 additions and 83 deletions
@@ -41,15 +41,27 @@ public class CastTestGenerated extends AbstractCastTest {
doTest(fileName);
}
@TestMetadata("castToNotNullType.kt")
public void testCastToNotNullType() throws Exception {
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToNotNullType.kt");
@TestMetadata("castToNotNull.kt")
public void testCastToNotNull() throws Exception {
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToNotNull.kt");
doTest(fileName);
}
@TestMetadata("castToNullableType.kt")
public void testCastToNullableType() throws Exception {
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToNullableType.kt");
@TestMetadata("castToNullable.kt")
public void testCastToNullable() throws Exception {
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToNullable.kt");
doTest(fileName);
}
@TestMetadata("reifiedToNotNull.kt")
public void testReifiedToNotNull() throws Exception {
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/reifiedToNotNull.kt");
doTest(fileName);
}
@TestMetadata("reifiedToNullable.kt")
public void testReifiedToNullable() throws Exception {
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/reifiedToNullable.kt");
doTest(fileName);
}
@@ -148,6 +148,22 @@ public class DirectiveTestUtils {
private static final DirectiveHandler COUNT_NULLS = new CountNodesDirective<JsNullLiteral>("CHECK_NULLS_COUNT", JsNullLiteral.class);
private static final DirectiveHandler NOT_REFERENCED = new DirectiveHandler("CHECK_NOT_REFERENCED") {
@Override
void processEntry(@NotNull JsNode ast, @NotNull ArgumentsHelper arguments) throws Exception {
final String reference = arguments.getPositionalArgument(0);
JsVisitor visitor = new RecursiveJsVisitor() {
@Override
public void visitNameRef(@NotNull JsNameRef nameRef) {
assertNotEquals(reference, nameRef.toString());
}
};
visitor.accept(ast);
}
};
private static final DirectiveHandler HAS_INLINE_METADATA = new DirectiveHandler("CHECK_HAS_INLINE_METADATA") {
@Override
void processEntry(@NotNull JsNode ast, @NotNull ArgumentsHelper arguments) throws Exception {
@@ -178,6 +194,7 @@ public class DirectiveTestUtils {
COUNT_VARS,
COUNT_BREAKS,
COUNT_NULLS,
NOT_REFERENCED,
HAS_INLINE_METADATA,
HAS_NO_INLINE_METADATA
);