All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlin.fir.lazy.AbstractFir2IrLazyDeclaration.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-RC
Show newest version
/*
 * 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.lazy

import org.jetbrains.kotlin.fir.FirAnnotationContainer
import org.jetbrains.kotlin.fir.backend.Fir2IrComponents
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
import org.jetbrains.kotlin.ir.declarations.IrFactory
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyDeclarationBase
import org.jetbrains.kotlin.ir.declarations.lazy.lazyVar
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.util.DeclarationStubGenerator
import org.jetbrains.kotlin.ir.util.TypeTranslator
import org.jetbrains.kotlin.utils.addToStdlib.shouldNotBeCalled
import kotlin.properties.ReadWriteProperty

interface AbstractFir2IrLazyDeclaration :
    IrDeclaration, IrLazyDeclarationBase, Fir2IrComponents where F : FirAnnotationContainer {

    val fir: F

    override val factory: IrFactory
        get() = IrFactoryImpl

    override fun createLazyAnnotations(): ReadWriteProperty> = lazyVar(lock) {
        fir.annotations.mapNotNull {
            callGenerator.convertToIrConstructorCall(it) as? IrConstructorCall
        }
    }

    override val stubGenerator: DeclarationStubGenerator
        get() = shouldNotBeCalled()
    override val typeTranslator: TypeTranslator
        get() = shouldNotBeCalled()
}

internal fun mutationNotSupported(): Nothing =
    error("Mutation of Fir2Ir lazy elements is not possible")




© 2015 - 2024 Weber Informatics LLC | Privacy Policy