fixup! [FIR] KT-54220: Don't crash on unsigned integers when no stdlib present
diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt
index cb0980c..7840bec 100644
--- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt
+++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt
@@ -498,7 +498,7 @@
DiagnosticKind.IntLiteralOutOfRange -> FirErrors.INT_LITERAL_OUT_OF_RANGE
DiagnosticKind.FloatLiteralOutOfRange -> FirErrors.FLOAT_LITERAL_OUT_OF_RANGE
DiagnosticKind.WrongLongSuffix -> FirErrors.WRONG_LONG_SUFFIX
- DiagnosticKind.UnsignedLiteralsNotPresent -> FirErrors.UNSIGNED_LITERAL_WITHOUT_DECLARATIONS_ON_CLASSPATH
+ DiagnosticKind.UnsignedNumbersAreNotPresent -> FirErrors.UNSIGNED_LITERAL_WITHOUT_DECLARATIONS_ON_CLASSPATH
DiagnosticKind.IncorrectCharacterLiteral -> FirErrors.INCORRECT_CHARACTER_LITERAL
DiagnosticKind.EmptyCharacterLiteral -> FirErrors.EMPTY_CHARACTER_LITERAL
DiagnosticKind.TooManyCharactersInCharacterLiteral -> FirErrors.TOO_MANY_CHARACTERS_IN_CHARACTER_LITERAL
diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt
index 2c56cf1..fee2464 100644
--- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt
+++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt
@@ -1010,8 +1010,8 @@
ConstantValueKind.IntegerLiteral, ConstantValueKind.UnsignedIntegerLiteral -> {
val expressionType = ConeIntegerLiteralConstantTypeImpl.create(
constExpression.value as Long,
- isUnsigned = kind == ConstantValueKind.UnsignedIntegerLiteral,
- isTypePresent = { it.lookupTag.toSymbol(session) != null }
+ isTypePresent = { it.lookupTag.toSymbol(session) != null },
+ isUnsigned = kind == ConstantValueKind.UnsignedIntegerLiteral
)
val expectedTypeRef = data.expectedType
@Suppress("UNCHECKED_CAST")
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt
index 3ab471b..c5932e4 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/diagnostics/ConeSimpleDiagnostic.kt
@@ -6,9 +6,7 @@
package org.jetbrains.kotlin.fir.diagnostics
import org.jetbrains.kotlin.KtSourceElement
-import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
-import org.jetbrains.kotlin.fir.symbols.impl.FirValueParameterSymbol
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.name.Name
@@ -84,7 +82,7 @@
IntLiteralOutOfRange,
FloatLiteralOutOfRange,
WrongLongSuffix,
- UnsignedLiteralsNotPresent,
+ UnsignedNumbersAreNotPresent,
IsEnumEntry,
EnumEntryAsType,
diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/ConeIntegerLiteralTypeImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/ConeIntegerLiteralTypeImpl.kt
index cfa489c..62030fd 100644
--- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/ConeIntegerLiteralTypeImpl.kt
+++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/ConeIntegerLiteralTypeImpl.kt
@@ -40,8 +40,8 @@
fun create(
value: Long,
isUnsigned: Boolean,
- nullability: ConeNullability = ConeNullability.NOT_NULL,
- isTypePresent: (ConeClassLikeType) -> Boolean = { true },
+ isTypePresent: (ConeClassLikeType) -> Boolean,
+ nullability: ConeNullability = ConeNullability.NOT_NULL
): ConeSimpleKotlinType {
val possibleTypes = mutableListOf<ConeClassLikeType>()
@@ -67,8 +67,8 @@
if (isUnsigned) {
addUnsignedPossibleType()
- if (!possibleTypes.all { isTypePresent(it) }) {
- return ConeErrorType(ConeSimpleDiagnostic("Unsigned integers need stdlib", DiagnosticKind.UnsignedLiteralsNotPresent))
+ if (possibleTypes.any { !isTypePresent(it) }) {
+ return ConeErrorType(ConeSimpleDiagnostic("Unsigned integers need stdlib", DiagnosticKind.UnsignedNumbersAreNotPresent))
}
} else {
addSignedPossibleTypes()