FIR tree. Make intersection type part-types non-null

This commit is contained in:
Simon Ogorodnik
2022-02-11 21:37:45 +03:00
committed by Space
parent 9c727e6d5d
commit 857fe985b2
5 changed files with 14 additions and 14 deletions
@@ -1753,8 +1753,8 @@ open class RawFirBuilder(
is KtIntersectionType -> FirIntersectionTypeRefBuilder().apply { is KtIntersectionType -> FirIntersectionTypeRefBuilder().apply {
this.source = source this.source = source
isMarkedNullable = isNullable isMarkedNullable = isNullable
leftType = unwrappedElement.getLeftTypeRef()?.toFirOrErrorType() leftType = unwrappedElement.getLeftTypeRef().toFirOrErrorType()
rightType = unwrappedElement.getRightTypeRef()?.toFirOrErrorType() rightType = unwrappedElement.getRightTypeRef().toFirOrErrorType()
} }
null -> FirErrorTypeRefBuilder().apply { null -> FirErrorTypeRefBuilder().apply {
this.source = source this.source = source
@@ -19,8 +19,8 @@ abstract class FirIntersectionTypeRef : FirTypeRefWithNullability() {
abstract override val source: KtSourceElement? abstract override val source: KtSourceElement?
abstract override val annotations: List<FirAnnotation> abstract override val annotations: List<FirAnnotation>
abstract override val isMarkedNullable: Boolean abstract override val isMarkedNullable: Boolean
abstract val leftType: FirTypeRef? abstract val leftType: FirTypeRef
abstract val rightType: FirTypeRef? abstract val rightType: FirTypeRef
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitIntersectionTypeRef(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitIntersectionTypeRef(this, data)
@@ -25,8 +25,8 @@ class FirIntersectionTypeRefBuilder : FirAnnotationContainerBuilder {
override var source: KtSourceElement? = null override var source: KtSourceElement? = null
override val annotations: MutableList<FirAnnotation> = mutableListOf() override val annotations: MutableList<FirAnnotation> = mutableListOf()
var isMarkedNullable: Boolean by kotlin.properties.Delegates.notNull<Boolean>() var isMarkedNullable: Boolean by kotlin.properties.Delegates.notNull<Boolean>()
var leftType: FirTypeRef? = null lateinit var leftType: FirTypeRef
var rightType: FirTypeRef? = null lateinit var rightType: FirTypeRef
override fun build(): FirIntersectionTypeRef { override fun build(): FirIntersectionTypeRef {
return FirIntersectionTypeRefImpl( return FirIntersectionTypeRefImpl(
@@ -20,19 +20,19 @@ internal class FirIntersectionTypeRefImpl(
override val source: KtSourceElement?, override val source: KtSourceElement?,
override val annotations: MutableList<FirAnnotation>, override val annotations: MutableList<FirAnnotation>,
override val isMarkedNullable: Boolean, override val isMarkedNullable: Boolean,
override var leftType: FirTypeRef?, override var leftType: FirTypeRef,
override var rightType: FirTypeRef?, override var rightType: FirTypeRef,
) : FirIntersectionTypeRef() { ) : FirIntersectionTypeRef() {
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) } annotations.forEach { it.accept(visitor, data) }
leftType?.accept(visitor, data) leftType.accept(visitor, data)
rightType?.accept(visitor, data) rightType.accept(visitor, data)
} }
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirIntersectionTypeRefImpl { override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirIntersectionTypeRefImpl {
transformAnnotations(transformer, data) transformAnnotations(transformer, data)
leftType = leftType?.transform(transformer, data) leftType = leftType.transform(transformer, data)
rightType = rightType?.transform(transformer, data) rightType = rightType.transform(transformer, data)
return this return this
} }
@@ -644,8 +644,8 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
} }
intersectionTypeRef.configure { intersectionTypeRef.configure {
+field("leftType", typeRef, nullable = true) +field("leftType", typeRef)
+field("rightType", typeRef, nullable = true) +field("rightType", typeRef)
} }
thisReceiverExpression.configure { thisReceiverExpression.configure {