Skip to content

Commit 826e87f

Browse files
committed
Kotlin: Simplify some array tests
1 parent ad51767 commit 826e87f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ open class KotlinUsesExtractor(
239239
return UseClassInstanceResult(classTypeResult, extractClass)
240240
}
241241

242-
private fun isArray(t: IrSimpleType) = t.isBoxedArray || t.isPrimitiveArray()
243-
244242
private fun extractClassLaterIfExternal(c: IrClass) {
245243
if (isExternalDeclaration(c)) {
246244
extractExternalClassLater(c)
@@ -565,6 +563,8 @@ open class KotlinUsesExtractor(
565563
Primitive arrays are represented as e.g. boolean[].
566564
*/
567565

566+
private fun isArray(t: IrType) = t.isBoxedArray || t.isPrimitiveArray()
567+
568568
data class ArrayInfo(val elementTypeResults: TypeResults,
569569
val componentTypeResults: TypeResults,
570570
val dimensions: Int)
@@ -579,7 +579,7 @@ open class KotlinUsesExtractor(
579579
*/
580580
private fun useArrayType(t: IrType, isPrimitiveArray: Boolean): ArrayInfo {
581581

582-
if (!t.isBoxedArray && !t.isPrimitiveArray()) {
582+
if (!isArray(t)) {
583583
val nullableT = if (t.isPrimitiveType() && !isPrimitiveArray) t.makeNullable() else t
584584
val typeResults = useType(nullableT)
585585
return ArrayInfo(typeResults, typeResults, 0)
@@ -1155,13 +1155,13 @@ open class KotlinUsesExtractor(
11551155
}
11561156
} else {
11571157
t.classOrNull?.let { tCls ->
1158-
if (t.isArray() || t.isNullableArray()) {
1158+
if (t.isBoxedArray) {
11591159
(t.arguments.singleOrNull() as? IrTypeProjection)?.let { elementTypeArg ->
11601160
val elementType = elementTypeArg.type
11611161
val replacedElementType = kClassToJavaClass(elementType)
11621162
if (replacedElementType !== elementType) {
11631163
val newArg = makeTypeProjection(replacedElementType, elementTypeArg.variance)
1164-
return tCls.typeWithArguments(listOf(newArg)).codeQlWithHasQuestionMark(t.isNullableArray())
1164+
return tCls.typeWithArguments(listOf(newArg)).codeQlWithHasQuestionMark(t.isNullable())
11651165
}
11661166
}
11671167
}
@@ -1592,7 +1592,7 @@ open class KotlinUsesExtractor(
15921592
}
15931593

15941594
if (owner is IrClass) {
1595-
if (t.isArray() || t.isNullableArray()) {
1595+
if (t.isBoxedArray) {
15961596
val elementType = t.getArrayElementType(pluginContext.irBuiltIns)
15971597
val erasedElementType = erase(elementType)
15981598
return owner.typeWith(erasedElementType).codeQlWithHasQuestionMark(t.isNullable())

0 commit comments

Comments
 (0)