@@ -12,7 +12,24 @@ import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
1212import org.jetbrains.kotlin.ir.declarations.*
1313import org.jetbrains.kotlin.ir.expressions.*
1414import org.jetbrains.kotlin.ir.symbols.*
15- import org.jetbrains.kotlin.ir.types.*
15+ import org.jetbrains.kotlin.ir.types.addAnnotations
16+ import org.jetbrains.kotlin.ir.types.classFqName
17+ import org.jetbrains.kotlin.ir.types.classifierOrNull
18+ import org.jetbrains.kotlin.ir.types.classOrNull
19+ import org.jetbrains.kotlin.ir.types.isAny
20+ import org.jetbrains.kotlin.ir.types.isNullableAny
21+ import org.jetbrains.kotlin.ir.types.isPrimitiveType
22+ import org.jetbrains.kotlin.ir.types.makeNullable
23+ import org.jetbrains.kotlin.ir.types.typeOrNull
24+ import org.jetbrains.kotlin.ir.types.typeWith
25+ import org.jetbrains.kotlin.ir.types.typeWithArguments
26+ import org.jetbrains.kotlin.ir.types.IrDynamicType
27+ import org.jetbrains.kotlin.ir.types.IrErrorType
28+ import org.jetbrains.kotlin.ir.types.IrSimpleType
29+ import org.jetbrains.kotlin.ir.types.IrStarProjection
30+ import org.jetbrains.kotlin.ir.types.IrType
31+ import org.jetbrains.kotlin.ir.types.IrTypeArgument
32+ import org.jetbrains.kotlin.ir.types.IrTypeProjection
1633import org.jetbrains.kotlin.ir.types.impl.*
1734import org.jetbrains.kotlin.ir.util.*
1835import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature
@@ -679,7 +696,7 @@ open class KotlinUsesExtractor(
679696 private fun getInvariantNullableArrayType (arrayType : IrSimpleType ): IrSimpleType =
680697 if (arrayType.isPrimitiveArray()) arrayType
681698 else {
682- val componentType = arrayType.getArrayElementType (pluginContext.irBuiltIns)
699+ val componentType = arrayType.getArrayElementTypeCodeQL (pluginContext.irBuiltIns)
683700 val componentTypeBroadened =
684701 when (componentType) {
685702 is IrSimpleType ->
@@ -690,7 +707,7 @@ open class KotlinUsesExtractor(
690707 val unchanged =
691708 componentType == componentTypeBroadened &&
692709 (arrayType.arguments[0 ] as ? IrTypeProjection )?.variance == Variance .INVARIANT &&
693- componentType.isNullable ()
710+ componentType.isNullableCodeQL ()
694711 if (unchanged) arrayType
695712 else
696713 IrSimpleTypeImpl (
@@ -705,7 +722,7 @@ open class KotlinUsesExtractor(
705722 Kotlin arrays can be broken down as:
706723
707724 isArray(t)
708- |- t.isBoxedArray
725+ |- t.isBoxedArrayCodeQL
709726 | |- t.isArray() e.g. Array<Boolean>, Array<Boolean?>
710727 | |- t.isNullableArray() e.g. Array<Boolean>?, Array<Boolean?>?
711728 |- t.isPrimitiveArray() e.g. BooleanArray
@@ -715,7 +732,7 @@ open class KotlinUsesExtractor(
715732 Primitive arrays are represented as e.g. boolean[].
716733 */
717734
718- private fun isArray (t : IrType ) = t.isBoxedArray || t.isPrimitiveArray()
735+ private fun isArray (t : IrType ) = t.isBoxedArrayCodeQL || t.isPrimitiveArray()
719736
720737 data class ArrayInfo (
721738 val elementTypeResults : TypeResults ,
@@ -756,7 +773,7 @@ open class KotlinUsesExtractor(
756773 ) {
757774 pluginContext.irBuiltIns.anyType
758775 } else {
759- t.getArrayElementType (pluginContext.irBuiltIns)
776+ t.getArrayElementTypeCodeQL (pluginContext.irBuiltIns)
760777 }
761778
762779 val recInfo = useArrayType(elementType, t.isPrimitiveArray())
@@ -844,7 +861,7 @@ open class KotlinUsesExtractor(
844861 if (
845862 (context == TypeContext .RETURN ||
846863 (context == TypeContext .OTHER && otherIsPrimitive)) &&
847- ! s.isNullable () &&
864+ ! s.isNullableCodeQL () &&
848865 getKotlinType(s)?.hasEnhancedNullability() != true &&
849866 primitiveName != null
850867 ) {
@@ -860,7 +877,7 @@ open class KotlinUsesExtractor(
860877 val kotlinClassId = useClassInstance(kotlinClass, listOf ()).typeResult.id
861878 val kotlinResult =
862879 if (true ) TypeResult (fakeKotlinType(), " TODO" , " TODO" )
863- else if (s.isNullable ()) {
880+ else if (s.isNullableCodeQL ()) {
864881 val kotlinSignature =
865882 " $kotlinPackageName .$kotlinClassName ?" // TODO: Is this right?
866883 val kotlinLabel = " @\" kt_type;nullable;$kotlinPackageName .$kotlinClassName \" "
@@ -902,21 +919,21 @@ open class KotlinUsesExtractor(
902919 return extractErrorType()
903920 }
904921 }
905- (s.isBoxedArray && s.arguments.isNotEmpty()) || s.isPrimitiveArray() -> {
922+ (s.isBoxedArrayCodeQL && s.arguments.isNotEmpty()) || s.isPrimitiveArray() -> {
906923 val arrayInfo = useArrayType(s, false )
907924 return arrayInfo.componentTypeResults
908925 }
909926 owner is IrClass -> {
910927 val args = if (s.codeQlIsRawType()) null else s.arguments
911928
912- return useSimpleTypeClass(owner, args, s.isNullable ())
929+ return useSimpleTypeClass(owner, args, s.isNullableCodeQL ())
913930 }
914931 owner is IrTypeParameter -> {
915932 val javaResult = useTypeParameter(owner)
916933 val aClassId = makeClass(" kotlin" , " TypeParam" ) // TODO: Wrong
917934 val kotlinResult =
918935 if (true ) TypeResult (fakeKotlinType(), " TODO" , " TODO" )
919- else if (s.isNullable ()) {
936+ else if (s.isNullableCodeQL ()) {
920937 val kotlinSignature = " ${javaResult.signature} ?" // TODO: Wrong
921938 val kotlinLabel = " @\" kt_type;nullable;type_param\" " // TODO: Wrong
922939 val kotlinId: Label <DbKt_nullable_type > =
@@ -1200,7 +1217,7 @@ open class KotlinUsesExtractor(
12001217 }
12011218
12021219 private fun extendsAdditionAllowed (t : IrType ) =
1203- if (t.isBoxedArray ) {
1220+ if (t.isBoxedArrayCodeQL ) {
12041221 if (t is IrSimpleType ) {
12051222 arrayExtendsAdditionAllowed(t)
12061223 } else {
@@ -1493,7 +1510,7 @@ open class KotlinUsesExtractor(
14931510 }
14941511 } else {
14951512 t.classOrNull?.let { tCls ->
1496- if (t.isBoxedArray ) {
1513+ if (t.isBoxedArrayCodeQL ) {
14971514 (t.arguments.singleOrNull() as ? IrTypeProjection )?.let { elementTypeArg
14981515 ->
14991516 val elementType = elementTypeArg.type
@@ -1506,7 +1523,7 @@ open class KotlinUsesExtractor(
15061523 )
15071524 return tCls
15081525 .typeWithArguments(listOf (newArg))
1509- .codeQlWithHasQuestionMark(t.isNullable ())
1526+ .codeQlWithHasQuestionMark(t.isNullableCodeQL ())
15101527 }
15111528 }
15121529 }
@@ -2086,12 +2103,12 @@ open class KotlinUsesExtractor(
20862103 }
20872104
20882105 if (owner is IrClass ) {
2089- if (t.isBoxedArray ) {
2090- val elementType = t.getArrayElementType (pluginContext.irBuiltIns)
2106+ if (t.isBoxedArrayCodeQL ) {
2107+ val elementType = t.getArrayElementTypeCodeQL (pluginContext.irBuiltIns)
20912108 val erasedElementType = erase(elementType)
20922109 return owner
20932110 .typeWith(erasedElementType)
2094- .codeQlWithHasQuestionMark(t.isNullable ())
2111+ .codeQlWithHasQuestionMark(t.isNullableCodeQL ())
20952112 }
20962113
20972114 return if (t.arguments.isNotEmpty())
0 commit comments