org.jetbrains.kotlin.contracts.description.KtValues.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-compiler-embeddable Show documentation
Show all versions of kotlin-compiler-embeddable Show documentation
the Kotlin compiler embeddable
/*
* Copyright 2010-2023 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.contracts.description
interface KtContractDescriptionValue : KtContractDescriptionElement {
override fun accept(contractDescriptionVisitor: KtContractDescriptionVisitor, data: D): R =
contractDescriptionVisitor.visitValue(this, data)
}
open class KtConstantReference(val name: String) : KtContractDescriptionValue {
override val erroneous: Boolean
get() = false
override fun accept(contractDescriptionVisitor: KtContractDescriptionVisitor, data: D): R =
contractDescriptionVisitor.visitConstantDescriptor(this, data)
}
class KtBooleanConstantReference(name: String) : KtConstantReference(name),
KtBooleanExpression {
override fun accept(contractDescriptionVisitor: KtContractDescriptionVisitor, data: D): R =
contractDescriptionVisitor.visitBooleanConstantDescriptor(this, data)
}
class KtErroneousConstantReference(val diagnostic: Diagnostic) : KtConstantReference("ERROR") {
override val erroneous: Boolean
get() = true
override fun accept(contractDescriptionVisitor: KtContractDescriptionVisitor, data: D): R =
contractDescriptionVisitor.visitErroneousConstantReference(this, data)
}
/*
* Index of value parameter of function
* -1 means that it is reference to extension receiver
*/
open class KtValueParameterReference(val parameterIndex: Int, val name: String) :
KtContractDescriptionValue {
init {
assert(parameterIndex >= -1)
}
override val erroneous: Boolean
get() = false
override fun accept(contractDescriptionVisitor: KtContractDescriptionVisitor, data: D): R =
contractDescriptionVisitor.visitValueParameterReference(this, data)
}
class KtBooleanValueParameterReference(parameterIndex: Int, name: String) : KtValueParameterReference(parameterIndex, name),
KtBooleanExpression {
override fun accept(contractDescriptionVisitor: KtContractDescriptionVisitor, data: D): R =
contractDescriptionVisitor.visitBooleanValueParameterReference(this, data)
}
class KtErroneousValueParameterReference(val diagnostic: Diagnostic) : KtValueParameterReference(Int.MAX_VALUE, "ERROR") {
override val erroneous: Boolean
get() = true
override fun accept(contractDescriptionVisitor: KtContractDescriptionVisitor, data: D): R =
contractDescriptionVisitor.visitErroneousValueParameterReference(this, data)
}