diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLazyExpressionBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLazyExpressionBuilder.kt new file mode 100644 index 00000000000..8e69a73cfd0 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirLazyExpressionBuilder.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.builder + +import kotlin.contracts.* +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder +import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirLazyExpression +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +@FirBuilderDsl +class FirLazyExpressionBuilder : FirAnnotationContainerBuilder { + override var source: FirSourceElement? = null + + @OptIn(FirImplementationDetail::class) + override fun build(): FirExpression { + return FirLazyExpression( + source, + ) + } + + + @Deprecated("Modification of 'annotations' has no impact for FirLazyExpressionBuilder", level = DeprecationLevel.HIDDEN) + override val annotations: MutableList = mutableListOf() +} + +@OptIn(ExperimentalContracts::class) +inline fun buildLazyExpression(init: FirLazyExpressionBuilder.() -> Unit = {}): FirExpression { + contract { + callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE) + } + return FirLazyExpressionBuilder().apply(init).build() +} diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLazyExpression.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLazyExpression.kt new file mode 100644 index 00000000000..4679bfd7957 --- /dev/null +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirLazyExpression.kt @@ -0,0 +1,38 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.expressions.impl + +import org.jetbrains.kotlin.fir.FirImplementationDetail +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.visitors.* + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +class FirLazyExpression @FirImplementationDetail constructor( + override val source: FirSourceElement?, +) : FirExpression() { + override val typeRef: FirTypeRef get() = error("FirLazyExpression should be calculated before accessing") + override val annotations: List get() = error("FirLazyExpression should be calculated before accessing") + + override fun acceptChildren(visitor: FirVisitor, data: D) { + } + + override fun transformChildren(transformer: FirTransformer, data: D): FirLazyExpression { + return this + } + + override fun transformAnnotations(transformer: FirTransformer, data: D): FirLazyExpression { + return this + } + + override fun replaceTypeRef(newTypeRef: FirTypeRef) {} +} diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index 102d96eb2a6..76595390c80 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -726,10 +726,13 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM } override fun visitExpression(expression: FirExpression) { - expression.annotations.renderAnnotations() + if (expression !is FirLazyExpression) { + expression.annotations.renderAnnotations() + } print( when (expression) { is FirExpressionStub -> "STUB" + is FirLazyExpression -> "LAZY_EXPRESSION" is FirUnitExpression -> "Unit" is FirElseIfTrueCondition -> "else" is FirNoReceiverExpression -> "" diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt index e74effc6930..c2187c2fbd3 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt @@ -140,6 +140,19 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() publicImplementation() } + impl(expression, "FirLazyExpression") { + val error = """error("FirLazyExpression should be calculated before accessing")""" + default("typeRef") { + value = error + withGetter = true + } + default("annotations") { + value = error + withGetter = true + } + publicImplementation() + } + impl(functionCall) { kind = OpenClass }