[FIR] Support constructor call of unsigned in checker

This commit is contained in:
Andrey Zinovyev
2021-05-21 15:56:43 +03:00
committed by TeamCityServer
parent 7f2eaab02b
commit dce8bd4e62
4 changed files with 14 additions and 13 deletions
@@ -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,
@@ -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() {
@@ -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: <!INVALID_TYPE_OF_ANNOTATION_MEMBER!>UInt<!>)
fun array(<!FORBIDDEN_VARARG_PARAMETER_TYPE!>vararg<!> a: UIntArray) {}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun ubyte(vararg a: UByte) {}