JS: don't optimize when over external enum
See KT-21468
This commit is contained in:
@@ -3388,6 +3388,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("externalEnumSubject.kt")
|
||||||
|
public void testExternalEnumSubject() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/expression/when/externalEnumSubject.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("forWithOneStmWhen.kt")
|
@TestMetadata("forWithOneStmWhen.kt")
|
||||||
public void testForWithOneStmWhen() throws Exception {
|
public void testForWithOneStmWhen() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/expression/when/forWithOneStmWhen.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/expression/when/forWithOneStmWhen.kt");
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ private constructor(private val whenExpression: KtWhenExpression, context: Trans
|
|||||||
private fun KotlinType.getEnumClass(): ClassDescriptor? {
|
private fun KotlinType.getEnumClass(): ClassDescriptor? {
|
||||||
if (isMarkedNullable) return null
|
if (isMarkedNullable) return null
|
||||||
val classDescriptor = (constructor.declarationDescriptor as? ClassDescriptor)
|
val classDescriptor = (constructor.declarationDescriptor as? ClassDescriptor)
|
||||||
return if (classDescriptor?.kind == ClassKind.ENUM_CLASS) classDescriptor else null
|
return if (classDescriptor?.kind == ClassKind.ENUM_CLASS && !classDescriptor.isExternal) classDescriptor else null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun translateEntryExpression(
|
private fun translateEntryExpression(
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
var X = {
|
||||||
|
A: {},
|
||||||
|
B: {}
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// EXPECTED_REACHABLE_NODES: 1133
|
||||||
|
external enum class X {
|
||||||
|
A, B
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
if (foo(X.A) != "!") return "fail1: ${foo(X.A)}"
|
||||||
|
if (foo(X.B) != "@") return "fail2: ${foo(X.B)}"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(x: X) = when (x) {
|
||||||
|
X.A -> "!"
|
||||||
|
X.B -> "@"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user