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

.kotlin.kotlin-compiler.1.3.11.source-code.IrLazyTypeParameter.kt Maven / Gradle / Ivy

There is a newer version: 2.0.20
Show newest version
/*
 * Copyright 2010-2018 JetBrains s.r.o. 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.ir.declarations.lazy

import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.DeclarationStubGenerator
import org.jetbrains.kotlin.ir.util.TypeTranslator
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.Variance

class IrLazyTypeParameter(
    startOffset: Int,
    endOffset: Int,
    origin: IrDeclarationOrigin,
    override val symbol: IrTypeParameterSymbol,
    override val name: Name,
    override val index: Int,
    override val isReified: Boolean,
    override val variance: Variance,
    stubGenerator: DeclarationStubGenerator,
    typeTranslator: TypeTranslator
) :
    IrLazyDeclarationBase(startOffset, endOffset, origin, stubGenerator, typeTranslator),
    IrTypeParameter {

    constructor(
        startOffset: Int,
        endOffset: Int,
        origin: IrDeclarationOrigin,
        symbol: IrTypeParameterSymbol,
        stubGenerator: DeclarationStubGenerator,
        TypeTranslator: TypeTranslator
    ) :
            this(
                startOffset, endOffset, origin, symbol,
                symbol.descriptor.name,
                symbol.descriptor.index,
                symbol.descriptor.isReified,
                symbol.descriptor.variance,
                stubGenerator, TypeTranslator
            )

    override val descriptor: TypeParameterDescriptor get() = symbol.descriptor

    init {
        symbol.bind(this)
    }

    override val superTypes: MutableList by lazy {
        typeTranslator.buildWithScope(this.parent as IrTypeParametersContainer) {
            val descriptor = symbol.descriptor
            descriptor.upperBounds.mapTo(arrayListOf()) { it.toIrType() }
        }
    }

    override fun  accept(visitor: IrElementVisitor, data: D): R =
        visitor.visitTypeParameter(this, data)

    override fun  transform(transformer: IrElementTransformer, data: D): IrTypeParameter =
        transformer.visitTypeParameter(this, data) as IrTypeParameter

    override fun  acceptChildren(visitor: IrElementVisitor, data: D) {
        // no children
    }

    override fun  transformChildren(transformer: IrElementTransformer, data: D) {
        // no children
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy