[FIR] Unwrap vararg array types for diagnostic rendering
#KT-65770 Fixed
This commit is contained in:
committed by
Space Team
parent
eae72eac54
commit
33648e1f44
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.fir.types
|
||||
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
|
||||
val ConeKotlinType.isArrayOrPrimitiveArray: Boolean
|
||||
get() = arrayElementTypeArgument() != null
|
||||
@@ -35,30 +34,6 @@ fun ConeTypeProjection.createArrayType(nullable: Boolean = false, createPrimitiv
|
||||
return StandardClassIds.Array.constructClassLikeType(arrayOf(this), nullable)
|
||||
}
|
||||
|
||||
fun ConeKotlinType.arrayElementType(checkUnsignedArrays: Boolean = true): ConeKotlinType? {
|
||||
return when (val argument = arrayElementTypeArgument(checkUnsignedArrays)) {
|
||||
is ConeKotlinTypeProjection -> argument.type
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
private fun ConeKotlinType.arrayElementTypeArgument(checkUnsignedArrays: Boolean = true): ConeTypeProjection? {
|
||||
val type = this.lowerBoundIfFlexible()
|
||||
if (type !is ConeClassLikeType) return null
|
||||
val classId = type.lookupTag.classId
|
||||
if (classId == StandardClassIds.Array) {
|
||||
return type.typeArguments.first()
|
||||
}
|
||||
val elementType = StandardClassIds.elementTypeByPrimitiveArrayType[classId] ?: runIf(checkUnsignedArrays) {
|
||||
StandardClassIds.elementTypeByUnsignedArrayType[classId]
|
||||
}
|
||||
if (elementType != null) {
|
||||
return elementType.constructClassLikeType(emptyArray(), isNullable = false)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
fun ConeKotlinType.varargElementType(): ConeKotlinType {
|
||||
return this.arrayElementType() ?: this
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user