@@ -2613,8 +2613,12 @@ open class KotlinFileExtractor(
2613
2613
|| isBuiltinCallKotlin(c, " byteArrayOf" )
2614
2614
|| isBuiltinCallKotlin(c, " booleanArrayOf" ) -> {
2615
2615
2616
- // TODO: is there any reason not to always use getArrayElementType?
2617
- val elementType = if (isBuiltinCallKotlin(c, " arrayOf" )) {
2616
+
2617
+ val isPrimitiveArrayCreation = ! isBuiltinCallKotlin(c, " arrayOf" )
2618
+ val elementType = if (isPrimitiveArrayCreation) {
2619
+ c.type.getArrayElementType(pluginContext.irBuiltIns)
2620
+ } else {
2621
+ // TODO: is there any reason not to always use getArrayElementType?
2618
2622
if (c.typeArgumentsCount == 1 ) {
2619
2623
c.getTypeArgument(0 ).also {
2620
2624
if (it == null ) {
@@ -2625,8 +2629,6 @@ open class KotlinFileExtractor(
2625
2629
logger.errorElement(" Expected to find one type argument in arrayOf call" , c)
2626
2630
null
2627
2631
}
2628
- } else {
2629
- c.type.getArrayElementType(pluginContext.irBuiltIns)
2630
2632
}
2631
2633
2632
2634
val arg = if (c.valueArgumentsCount == 1 ) c.getValueArgument(0 ) else {
@@ -2639,7 +2641,7 @@ open class KotlinFileExtractor(
2639
2641
}
2640
2642
}
2641
2643
2642
- extractArrayCreation(arg, c.type, elementType, c, parent, idx, callable, enclosingStmt)
2644
+ extractArrayCreation(arg, c.type, elementType, isPrimitiveArrayCreation, c, parent, idx, callable, enclosingStmt)
2643
2645
}
2644
2646
isBuiltinCall(c, " <get-java>" , " kotlin.jvm" ) -> {
2645
2647
// Special case for KClass<*>.java, which is used in the Parcelize plugin. In normal cases, this is already rewritten to the property referenced below:
@@ -2825,7 +2827,7 @@ open class KotlinFileExtractor(
2825
2827
}
2826
2828
}
2827
2829
2828
- private fun extractArrayCreation (elementList : IrVararg ? , resultType : IrType , elementType : IrType ? , locElement : IrElement , parent : Label <out DbExprparent >, idx : Int , enclosingCallable : Label <out DbCallable >, enclosingStmt : Label <out DbStmt >) {
2830
+ private fun extractArrayCreation (elementList : IrVararg ? , resultType : IrType , elementType : IrType ? , allowPrimitiveElementType : Boolean , locElement : IrElement , parent : Label <out DbExprparent >, idx : Int , enclosingCallable : Label <out DbCallable >, enclosingStmt : Label <out DbStmt >) {
2829
2831
// If this is [someType]ArrayOf(*x), x, otherwise null
2830
2832
val clonedArray = elementList?.let {
2831
2833
if (it.elements.size == 1 ) {
@@ -2852,7 +2854,8 @@ open class KotlinFileExtractor(
2852
2854
tw.writeCallableEnclosingExpr(id, enclosingCallable)
2853
2855
2854
2856
if (elementType != null ) {
2855
- extractTypeAccessRecursive(elementType, locId, id, - 1 , enclosingCallable, enclosingStmt, TypeContext .GENERIC_ARGUMENT )
2857
+ val typeContext = if (allowPrimitiveElementType) TypeContext .OTHER else TypeContext .GENERIC_ARGUMENT
2858
+ extractTypeAccessRecursive(elementType, locId, id, - 1 , enclosingCallable, enclosingStmt, typeContext)
2856
2859
}
2857
2860
2858
2861
if (elementList != null ) {
@@ -3657,7 +3660,7 @@ open class KotlinFileExtractor(
3657
3660
// This AST element can also occur as a collection literal in an annotation class, such as
3658
3661
// annotation class Ann(val strings: Array<String> = [])
3659
3662
val exprParent = parent.expr(e, callable)
3660
- extractArrayCreation(e, e.type, e.varargElementType, e, exprParent.parent, exprParent.idx, callable, exprParent.enclosingStmt)
3663
+ extractArrayCreation(e, e.type, e.varargElementType, true , e, exprParent.parent, exprParent.idx, callable, exprParent.enclosingStmt)
3661
3664
}
3662
3665
is IrGetObjectValue -> {
3663
3666
// For `object MyObject { ... }`, the .class has an
0 commit comments