diff --git a/compiler/fir/evaluate/src/org/jetbrains/kotlin/fir/evaluate/CompileTimeConstantEvaluator.kt b/compiler/fir/evaluate/src/org/jetbrains/kotlin/fir/evaluate/CompileTimeConstantEvaluator.kt index 3a58f5e7269..a65dae565c0 100644 --- a/compiler/fir/evaluate/src/org/jetbrains/kotlin/fir/evaluate/CompileTimeConstantEvaluator.kt +++ b/compiler/fir/evaluate/src/org/jetbrains/kotlin/fir/evaluate/CompileTimeConstantEvaluator.kt @@ -183,22 +183,6 @@ class CompileTimeConstantEvaluator { private fun FirConstKind.toConstExpression(source: FirSourceElement?, value: Number): FirConstExpression = @Suppress("UNCHECKED_CAST") buildConstExpression(source, this, value as T) - - // TODO: extension functions, e.g., Byte.and - // TODO: toChar?, toString? - companion object { - private val unaryOperatorNames: Set = setOf( - "hashCode", - "dec", "inc", "unaryMinus", "unaryPlus", - "toByte", "toDouble", "toFloat", "toInt", "toLong", "toShort" - ) - - // TODO: rangeTo? - private val binaryOperatorNames: Set = setOf( - // TODO: "compareTo", "equals", - "div", "minus", "mod", "plus", "rem", "times" - ) - } } val FirConstExpression.typedValue: T diff --git a/compiler/fir/evaluate/src/org/jetbrains/kotlin/fir/evaluate/FirOperationsMapGenerated.kt b/compiler/fir/evaluate/src/org/jetbrains/kotlin/fir/evaluate/FirOperationsMapGenerated.kt index a7f99c2118d..1a8b489de48 100644 --- a/compiler/fir/evaluate/src/org/jetbrains/kotlin/fir/evaluate/FirOperationsMapGenerated.kt +++ b/compiler/fir/evaluate/src/org/jetbrains/kotlin/fir/evaluate/FirOperationsMapGenerated.kt @@ -291,3 +291,6 @@ internal val binaryOperations: HashMap, Function2 a.times(b) }), binaryOperation(FirConstKind.Short, FirConstKind.Short, "times", { a, b -> a.times(b) }), ) + +internal val unaryOperatorNames = unaryOperations.map { it.key.opName }.toHashSet() +internal val binaryOperatorNames = binaryOperations.map { it.key.opName }.toHashSet() diff --git a/generators/evaluate/GenerateFirOperationsMap.kt b/generators/evaluate/GenerateFirOperationsMap.kt index 9a0077a9270..812ce0ee125 100644 --- a/generators/evaluate/GenerateFirOperationsMap.kt +++ b/generators/evaluate/GenerateFirOperationsMap.kt @@ -73,6 +73,14 @@ fun generateFirMap(): String { p.renderBinaryOperations(binaryOperationsMap) p.popIndent() p.println(")") + p.println() + + p.println( + """ + |internal val unaryOperatorNames = unaryOperations.map { it.key.opName }.toHashSet() + |internal val binaryOperatorNames = binaryOperations.map { it.key.opName }.toHashSet() + """.trimMargin() + ) return sb.toString() }