[FIR] KT-54220: Don't crash on unsigned integers when no stdlib present
^KT-54220 Fixed
This commit is contained in:
+6
@@ -203,6 +203,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.UNSIGNED_LITERAL_WITHOUT_DECLARATIONS_ON_CLASSPATH) { firDiagnostic ->
|
||||
UnsignedLiteralWithoutDeclarationsOnClasspathImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.DIVISION_BY_ZERO) { firDiagnostic ->
|
||||
DivisionByZeroImpl(
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
|
||||
+4
@@ -179,6 +179,10 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = WrongLongSuffix::class
|
||||
}
|
||||
|
||||
abstract class UnsignedLiteralWithoutDeclarationsOnClasspath : KtFirDiagnostic<KtElement>() {
|
||||
override val diagnosticClass get() = UnsignedLiteralWithoutDeclarationsOnClasspath::class
|
||||
}
|
||||
|
||||
abstract class DivisionByZero : KtFirDiagnostic<KtExpression>() {
|
||||
override val diagnosticClass get() = DivisionByZero::class
|
||||
}
|
||||
|
||||
+5
@@ -201,6 +201,11 @@ internal class WrongLongSuffixImpl(
|
||||
override val token: KtLifetimeToken,
|
||||
) : KtFirDiagnostic.WrongLongSuffix(), KtAbstractFirDiagnostic<KtElement>
|
||||
|
||||
internal class UnsignedLiteralWithoutDeclarationsOnClasspathImpl(
|
||||
override val firDiagnostic: KtPsiDiagnostic,
|
||||
override val token: KtLifetimeToken,
|
||||
) : KtFirDiagnostic.UnsignedLiteralWithoutDeclarationsOnClasspath(), KtAbstractFirDiagnostic<KtElement>
|
||||
|
||||
internal class DivisionByZeroImpl(
|
||||
override val firDiagnostic: KtPsiDiagnostic,
|
||||
override val token: KtLifetimeToken,
|
||||
|
||||
+1
@@ -368,6 +368,7 @@ internal object FirCompileTimeConstantEvaluator {
|
||||
ConstantValueKind.UnsignedShort -> value.toLong().toUShort()
|
||||
ConstantValueKind.UnsignedInt -> value.toLong().toUInt()
|
||||
ConstantValueKind.UnsignedLong -> value.toLong().toULong()
|
||||
ConstantValueKind.UnsignedIntegerLiteral -> value.toLong().toULong()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user