[FIR] KT-54220: Don't crash on unsigned integers when no stdlib present
^KT-54220 Fixed
This commit is contained in:
@@ -87,6 +87,7 @@ enum class DiagnosticKind {
|
||||
IntLiteralOutOfRange,
|
||||
FloatLiteralOutOfRange,
|
||||
WrongLongSuffix,
|
||||
UnsignedNumbersAreNotPresent,
|
||||
|
||||
IsEnumEntry,
|
||||
EnumEntryAsType,
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.types
|
||||
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||
import org.jetbrains.kotlin.fir.isLong
|
||||
import org.jetbrains.kotlin.fir.isULong
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
@@ -38,6 +40,7 @@ class ConeIntegerLiteralConstantTypeImpl(
|
||||
fun create(
|
||||
value: Long,
|
||||
isUnsigned: Boolean,
|
||||
isTypePresent: (ConeClassLikeType) -> Boolean,
|
||||
nullability: ConeNullability = ConeNullability.NOT_NULL
|
||||
): ConeSimpleKotlinType {
|
||||
val possibleTypes = mutableListOf<ConeClassLikeType>()
|
||||
@@ -64,6 +67,9 @@ class ConeIntegerLiteralConstantTypeImpl(
|
||||
|
||||
if (isUnsigned) {
|
||||
addUnsignedPossibleType()
|
||||
if (possibleTypes.any { !isTypePresent(it) }) {
|
||||
return ConeErrorType(ConeSimpleDiagnostic("Unsigned integers need stdlib", DiagnosticKind.UnsignedNumbersAreNotPresent))
|
||||
}
|
||||
} else {
|
||||
addSignedPossibleTypes()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user