[FIR] Make type of special expressions immutable

This commit is contained in:
Kirill Rakhman
2023-08-07 13:08:37 +02:00
committed by Space Team
parent 8d7c5b375e
commit a5cff6ae36
8 changed files with 18 additions and 29 deletions
@@ -30,7 +30,7 @@ internal class FirBreakExpressionImpl(
override var annotations: MutableOrEmptyList<FirAnnotation>,
override val target: FirTarget<FirLoop>,
) : FirBreakExpression() {
override var coneTypeOrNull: ConeKotlinType? = StandardClassIds.Nothing.constructClassLikeType()
override val coneTypeOrNull: ConeKotlinType? = StandardClassIds.Nothing.constructClassLikeType()
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) }
@@ -46,9 +46,7 @@ internal class FirBreakExpressionImpl(
return this
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {
coneTypeOrNull = newConeTypeOrNull
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {}
override fun replaceAnnotations(newAnnotations: List<FirAnnotation>) {
annotations = newAnnotations.toMutableOrEmpty()
@@ -30,7 +30,7 @@ internal class FirContinueExpressionImpl(
override var annotations: MutableOrEmptyList<FirAnnotation>,
override val target: FirTarget<FirLoop>,
) : FirContinueExpression() {
override var coneTypeOrNull: ConeKotlinType? = StandardClassIds.Nothing.constructClassLikeType()
override val coneTypeOrNull: ConeKotlinType? = StandardClassIds.Nothing.constructClassLikeType()
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) }
@@ -46,9 +46,7 @@ internal class FirContinueExpressionImpl(
return this
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {
coneTypeOrNull = newConeTypeOrNull
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {}
override fun replaceAnnotations(newAnnotations: List<FirAnnotation>) {
annotations = newAnnotations.toMutableOrEmpty()
@@ -28,7 +28,7 @@ class FirElseIfTrueCondition @FirImplementationDetail constructor(
override val source: KtSourceElement?,
override var annotations: MutableOrEmptyList<FirAnnotation>,
) : FirExpression() {
override var coneTypeOrNull: ConeKotlinType? = StandardClassIds.Boolean.constructClassLikeType()
override val coneTypeOrNull: ConeKotlinType? = StandardClassIds.Boolean.constructClassLikeType()
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) }
@@ -44,9 +44,7 @@ class FirElseIfTrueCondition @FirImplementationDetail constructor(
return this
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {
coneTypeOrNull = newConeTypeOrNull
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {}
override fun replaceAnnotations(newAnnotations: List<FirAnnotation>) {
annotations = newAnnotations.toMutableOrEmpty()
@@ -32,7 +32,7 @@ internal class FirReturnExpressionImpl(
override val target: FirTarget<FirFunction>,
override var result: FirExpression,
) : FirReturnExpression() {
override var coneTypeOrNull: ConeKotlinType? = StandardClassIds.Nothing.constructClassLikeType()
override val coneTypeOrNull: ConeKotlinType? = StandardClassIds.Nothing.constructClassLikeType()
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) }
@@ -60,9 +60,7 @@ internal class FirReturnExpressionImpl(
return this
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {
coneTypeOrNull = newConeTypeOrNull
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {}
override fun replaceAnnotations(newAnnotations: List<FirAnnotation>) {
annotations = newAnnotations.toMutableOrEmpty()
@@ -29,7 +29,7 @@ internal class FirStringConcatenationCallImpl(
override var annotations: MutableOrEmptyList<FirAnnotation>,
override var argumentList: FirArgumentList,
) : FirStringConcatenationCall() {
override var coneTypeOrNull: ConeKotlinType? = StandardClassIds.String.constructClassLikeType()
override val coneTypeOrNull: ConeKotlinType? = StandardClassIds.String.constructClassLikeType()
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) }
@@ -55,7 +55,5 @@ internal class FirStringConcatenationCallImpl(
argumentList = newArgumentList
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {
coneTypeOrNull = newConeTypeOrNull
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {}
}
@@ -29,7 +29,7 @@ internal class FirThrowExpressionImpl(
override var annotations: MutableOrEmptyList<FirAnnotation>,
override var exception: FirExpression,
) : FirThrowExpression() {
override var coneTypeOrNull: ConeKotlinType? = StandardClassIds.Nothing.constructClassLikeType()
override val coneTypeOrNull: ConeKotlinType? = StandardClassIds.Nothing.constructClassLikeType()
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) }
@@ -52,9 +52,7 @@ internal class FirThrowExpressionImpl(
return this
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {
coneTypeOrNull = newConeTypeOrNull
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {}
override fun replaceAnnotations(newAnnotations: List<FirAnnotation>) {
annotations = newAnnotations.toMutableOrEmpty()
@@ -28,7 +28,7 @@ class FirUnitExpression @FirImplementationDetail constructor(
override val source: KtSourceElement?,
override var annotations: MutableOrEmptyList<FirAnnotation>,
) : FirExpression() {
override var coneTypeOrNull: ConeKotlinType? = StandardClassIds.Unit.constructClassLikeType()
override val coneTypeOrNull: ConeKotlinType? = StandardClassIds.Unit.constructClassLikeType()
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) }
@@ -44,9 +44,7 @@ class FirUnitExpression @FirImplementationDetail constructor(
return this
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {
coneTypeOrNull = newConeTypeOrNull
}
override fun replaceConeTypeOrNull(newConeTypeOrNull: ConeKotlinType?) {}
override fun replaceAnnotations(newAnnotations: List<FirAnnotation>) {
annotations = newAnnotations.toMutableOrEmpty()
@@ -122,7 +122,10 @@ abstract class AbstractFirTreeImplementationConfigurator {
}
fun defaultBuiltInType(type: String) {
default("coneTypeOrNull", "StandardClassIds.$type.constructClassLikeType()")
default("coneTypeOrNull") {
value = "StandardClassIds.$type.constructClassLikeType()"
isMutable = false
}
useTypes(standardClassIdsType, constructClassLikeTypeImport)
}