diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConstChecks.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConstChecks.kt index 5ad8756c38d..b6199fab329 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConstChecks.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConstChecks.kt @@ -89,6 +89,15 @@ internal fun checkConstantArguments( ) return ConstantArgumentKind.NOT_CONST } + expressionSymbol is FirConstructor -> { + if (expression.typeRef.coneType.isUnsignedType) { + (expression as FirFunctionCall).arguments.forEach { argumentExpression -> + checkConstantArguments(argumentExpression, session)?.let { return it } + } + } else { + return ConstantArgumentKind.NOT_CONST + } + } expression is FirFunctionCall -> { val calleeReference = expression.calleeReference if (calleeReference is FirErrorNamedReference) { @@ -103,6 +112,7 @@ internal fun checkConstantArguments( return null } + when (calleeReference.name) { in OperatorNameConventions.BINARY_OPERATION_NAMES, in OperatorNameConventions.UNARY_OPERATION_NAMES, OperatorNameConventions.SHL, OperatorNameConventions.SHR, OperatorNameConventions.USHR, diff --git a/compiler/testData/codegen/bytecodeText/constants/inlineUnsignedIntConstant.kt b/compiler/testData/codegen/bytecodeText/constants/inlineUnsignedIntConstant.kt index aaeae9efd69..bf888eca433 100644 --- a/compiler/testData/codegen/bytecodeText/constants/inlineUnsignedIntConstant.kt +++ b/compiler/testData/codegen/bytecodeText/constants/inlineUnsignedIntConstant.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND_FIR: JVM_IR // FILE: uint.kt @@ -9,6 +8,9 @@ inline class UInt(val value: Int) // FILE: test.kt +//this import in required in FIR because default imports don't search in local sources atm +import kotlin.UInt + const val u = UInt(14) fun foo() { diff --git a/compiler/testData/diagnostics/tests/unsignedTypes/allowedVarargsOfUnsignedTypes.fir.kt b/compiler/testData/diagnostics/tests/unsignedTypes/allowedVarargsOfUnsignedTypes.fir.kt deleted file mode 100644 index e25d1f0d2b7..00000000000 --- a/compiler/testData/diagnostics/tests/unsignedTypes/allowedVarargsOfUnsignedTypes.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER - -fun ubyte(vararg a: UByte) {} -fun ushort(vararg a: UShort) {} -fun uint(vararg a: UInt) {} -fun ulong(vararg a: ULong) {} - -class ValueParam(vararg val a: ULong) - -annotation class Ann(vararg val a: UInt) - -fun array(vararg a: UIntArray) {} diff --git a/compiler/testData/diagnostics/tests/unsignedTypes/allowedVarargsOfUnsignedTypes.kt b/compiler/testData/diagnostics/tests/unsignedTypes/allowedVarargsOfUnsignedTypes.kt index bd99c3ecfec..fbf95cf3401 100644 --- a/compiler/testData/diagnostics/tests/unsignedTypes/allowedVarargsOfUnsignedTypes.kt +++ b/compiler/testData/diagnostics/tests/unsignedTypes/allowedVarargsOfUnsignedTypes.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER fun ubyte(vararg a: UByte) {}