JS: fix inlining of array constructor expressed via typealias
See KT-20978
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
typealias ArrayS = Array<String>
|
||||||
|
|
||||||
fun testArray() {
|
fun testArray() {
|
||||||
Array<String>(5) { i ->
|
Array<String>(5) { i ->
|
||||||
if (i == 3) return
|
if (i == 3) return
|
||||||
@@ -6,6 +8,14 @@ fun testArray() {
|
|||||||
throw AssertionError()
|
throw AssertionError()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testArrayAlias() {
|
||||||
|
ArrayS(5) { i ->
|
||||||
|
if (i == 3) return
|
||||||
|
i.toString()
|
||||||
|
}
|
||||||
|
throw AssertionError()
|
||||||
|
}
|
||||||
|
|
||||||
fun testIntArray() {
|
fun testIntArray() {
|
||||||
IntArray(5) { i ->
|
IntArray(5) { i ->
|
||||||
if (i == 3) return
|
if (i == 3) return
|
||||||
@@ -56,6 +66,7 @@ fun testDoubleArray() {
|
|||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
testArray()
|
testArray()
|
||||||
|
testArrayAlias()
|
||||||
testIntArray()
|
testIntArray()
|
||||||
testLongArray()
|
testLongArray()
|
||||||
testBooleanArray()
|
testBooleanArray()
|
||||||
|
|||||||
+7
-2
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.builtins.getValueParameterTypesFromFunctionType
|
|||||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
|
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
|
||||||
import org.jetbrains.kotlin.js.backend.ast.*
|
import org.jetbrains.kotlin.js.backend.ast.*
|
||||||
import org.jetbrains.kotlin.js.backend.ast.metadata.descriptor
|
import org.jetbrains.kotlin.js.backend.ast.metadata.descriptor
|
||||||
import org.jetbrains.kotlin.js.backend.ast.metadata.inlineStrategy
|
import org.jetbrains.kotlin.js.backend.ast.metadata.inlineStrategy
|
||||||
@@ -192,8 +193,12 @@ object ArrayFIF : CompositeFIF() {
|
|||||||
}
|
}
|
||||||
invocation.inlineStrategy = InlineStrategy.IN_PLACE
|
invocation.inlineStrategy = InlineStrategy.IN_PLACE
|
||||||
val descriptor = callInfo.resolvedCall.resultingDescriptor.original
|
val descriptor = callInfo.resolvedCall.resultingDescriptor.original
|
||||||
invocation.descriptor = descriptor
|
val resolvedDescriptor = when (descriptor) {
|
||||||
context.addInlineCall(descriptor)
|
is TypeAliasConstructorDescriptor -> descriptor.underlyingConstructorDescriptor
|
||||||
|
else -> descriptor
|
||||||
|
}
|
||||||
|
invocation.descriptor = resolvedDescriptor
|
||||||
|
context.addInlineCall(resolvedDescriptor)
|
||||||
invocation
|
invocation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user