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() {
|
||||
Array<String>(5) { i ->
|
||||
if (i == 3) return
|
||||
@@ -6,6 +8,14 @@ fun testArray() {
|
||||
throw AssertionError()
|
||||
}
|
||||
|
||||
fun testArrayAlias() {
|
||||
ArrayS(5) { i ->
|
||||
if (i == 3) return
|
||||
i.toString()
|
||||
}
|
||||
throw AssertionError()
|
||||
}
|
||||
|
||||
fun testIntArray() {
|
||||
IntArray(5) { i ->
|
||||
if (i == 3) return
|
||||
@@ -56,6 +66,7 @@ fun testDoubleArray() {
|
||||
|
||||
fun box(): String {
|
||||
testArray()
|
||||
testArrayAlias()
|
||||
testIntArray()
|
||||
testLongArray()
|
||||
testBooleanArray()
|
||||
|
||||
+7
-2
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.builtins.getValueParameterTypesFromFunctionType
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
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.metadata.descriptor
|
||||
import org.jetbrains.kotlin.js.backend.ast.metadata.inlineStrategy
|
||||
@@ -192,8 +193,12 @@ object ArrayFIF : CompositeFIF() {
|
||||
}
|
||||
invocation.inlineStrategy = InlineStrategy.IN_PLACE
|
||||
val descriptor = callInfo.resolvedCall.resultingDescriptor.original
|
||||
invocation.descriptor = descriptor
|
||||
context.addInlineCall(descriptor)
|
||||
val resolvedDescriptor = when (descriptor) {
|
||||
is TypeAliasConstructorDescriptor -> descriptor.underlyingConstructorDescriptor
|
||||
else -> descriptor
|
||||
}
|
||||
invocation.descriptor = resolvedDescriptor
|
||||
context.addInlineCall(resolvedDescriptor)
|
||||
invocation
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user