FIR IDE: make compile-time constant evaluator an object

because it doesn't have any states.
This commit is contained in:
Jinseong Jeon
2021-09-21 11:32:39 -07:00
committed by Ilya Kirillov
parent 414881403b
commit d3d3aeacb4
2 changed files with 2 additions and 2 deletions
@@ -25,7 +25,7 @@ internal class KtFirCompileTimeConstantProvider(
override fun evaluate(expression: KtExpression): KtConstantValue? = withValidityAssertion {
when (val fir = expression.getOrBuildFir(firResolveState)) {
is FirExpression -> {
FirCompileTimeConstantEvaluator().evaluate(fir)?.let { KtFirConstantValueConverter.toConstantValue(it) }
FirCompileTimeConstantEvaluator.evaluate(fir)?.let { KtFirConstantValueConverter.toConstantValue(it) }
?: KtFirConstantValueConverter.toConstantValue(fir, firResolveState.rootModuleSession)
}
else -> throwUnexpectedFirElementError(fir, expression)
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.types.ConstantValueKind
* An evaluator that transform numeric operation, such as div, into compile-time constant iff involved operands, such as explicit receiver
* and the argument, are compile-time constant as well.
*/
internal class FirCompileTimeConstantEvaluator {
internal object FirCompileTimeConstantEvaluator {
// TODO: Handle boolean operators, const property loading, class reference, array, annotation values, etc.
fun evaluate(expression: FirExpression): FirConstExpression<*>? =