JS: chained reified function calls (KT-12527) fixed
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
inline fun <reified T> Any?.check(): Boolean {
|
||||||
|
return this is T
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <reified T> Any?.check2(): Boolean {
|
||||||
|
return check<T>()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var log = ""
|
||||||
|
fun log(a: Any?) {
|
||||||
|
log += a.toString() + ";"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(a: Any?) {
|
||||||
|
log(a.check<String>())
|
||||||
|
log(a.check<String?>())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test2(a: Any?) {
|
||||||
|
log(a.check2<String>())
|
||||||
|
log(a.check2<String?>())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
test("")
|
||||||
|
test(null)
|
||||||
|
test2("")
|
||||||
|
test2(null)
|
||||||
|
|
||||||
|
if (log != "true;true;false;true;true;true;false;true;") {
|
||||||
|
return "fail"
|
||||||
|
}
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+6
@@ -14540,6 +14540,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reifiedChain.kt")
|
||||||
|
public void testReifiedChain() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reified/reifiedChain.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("reifiedInlineFunOfObject.kt")
|
@TestMetadata("reifiedInlineFunOfObject.kt")
|
||||||
public void testReifiedInlineFunOfObject() throws Exception {
|
public void testReifiedInlineFunOfObject() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reified/reifiedInlineFunOfObject.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reified/reifiedInlineFunOfObject.kt");
|
||||||
|
|||||||
@@ -14540,6 +14540,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reifiedChain.kt")
|
||||||
|
public void testReifiedChain() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reified/reifiedChain.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("reifiedInlineFunOfObject.kt")
|
@TestMetadata("reifiedInlineFunOfObject.kt")
|
||||||
public void testReifiedInlineFunOfObject() throws Exception {
|
public void testReifiedInlineFunOfObject() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reified/reifiedInlineFunOfObject.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reified/reifiedInlineFunOfObject.kt");
|
||||||
|
|||||||
@@ -19112,6 +19112,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reifiedChain.kt")
|
||||||
|
public void testReifiedChain() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reified/reifiedChain.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("reifiedInlineFunOfObject.kt")
|
@TestMetadata("reifiedInlineFunOfObject.kt")
|
||||||
public void testReifiedInlineFunOfObject() throws Exception {
|
public void testReifiedInlineFunOfObject() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reified/reifiedInlineFunOfObject.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reified/reifiedInlineFunOfObject.kt");
|
||||||
|
|||||||
+3
-1
@@ -138,7 +138,9 @@ public final class PatternTranslator extends AbstractTranslator {
|
|||||||
public JsExpression getIsTypeCheckCallable(@NotNull KotlinType type) {
|
public JsExpression getIsTypeCheckCallable(@NotNull KotlinType type) {
|
||||||
JsExpression callable = doGetIsTypeCheckCallable(type);
|
JsExpression callable = doGetIsTypeCheckCallable(type);
|
||||||
|
|
||||||
if (isNullableType(type)) {
|
// If the type is reified, rely on the corresponding is type callable.
|
||||||
|
// Otherwise make sure that passing null yields true
|
||||||
|
if (!isReifiedTypeParameter(type) && isNullableType(type)) {
|
||||||
return namer().orNull(callable);
|
return namer().orNull(callable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user