[FIR] introduce FirErrorTypeRef.partiallyResolvedTypeRef
^KT-58125
This commit is contained in:
committed by
Space Team
parent
da35f436b3
commit
2cd4ff11f0
+5
@@ -181,6 +181,11 @@ class FirSpecificTypeResolverTransformer(
|
|||||||
return resolvedTypeRef
|
return resolvedTypeRef
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun transformErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: ScopeClassDeclaration): FirTypeRef {
|
||||||
|
errorTypeRef.transformPartiallyResolvedTypeRef(this, data)
|
||||||
|
return errorTypeRef
|
||||||
|
}
|
||||||
|
|
||||||
override fun transformImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef, data: ScopeClassDeclaration): FirTypeRef {
|
override fun transformImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef, data: ScopeClassDeclaration): FirTypeRef {
|
||||||
return implicitTypeRef
|
return implicitTypeRef
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ abstract class FirErrorTypeRef : FirResolvedTypeRef(), FirDiagnosticHolder {
|
|||||||
abstract override val delegatedTypeRef: FirTypeRef?
|
abstract override val delegatedTypeRef: FirTypeRef?
|
||||||
abstract override val isFromStubType: Boolean
|
abstract override val isFromStubType: Boolean
|
||||||
abstract override val diagnostic: ConeDiagnostic
|
abstract override val diagnostic: ConeDiagnostic
|
||||||
|
abstract val partiallyResolvedTypeRef: FirTypeRef?
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitErrorTypeRef(this, data)
|
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitErrorTypeRef(this, data)
|
||||||
|
|
||||||
@@ -34,4 +35,6 @@ abstract class FirErrorTypeRef : FirResolvedTypeRef(), FirDiagnosticHolder {
|
|||||||
abstract override fun replaceAnnotations(newAnnotations: List<FirAnnotation>)
|
abstract override fun replaceAnnotations(newAnnotations: List<FirAnnotation>)
|
||||||
|
|
||||||
abstract override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirErrorTypeRef
|
abstract override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirErrorTypeRef
|
||||||
|
|
||||||
|
abstract fun <D> transformPartiallyResolvedTypeRef(transformer: FirTransformer<D>, data: D): FirErrorTypeRef
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-4
@@ -5,18 +5,17 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.types.builder
|
package org.jetbrains.kotlin.fir.types.builder
|
||||||
|
|
||||||
import kotlin.contracts.*
|
|
||||||
import org.jetbrains.kotlin.KtSourceElement
|
import org.jetbrains.kotlin.KtSourceElement
|
||||||
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
|
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
|
||||||
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
|
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
|
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||||
import org.jetbrains.kotlin.fir.types.ConeErrorType
|
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||||
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
|
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl
|
import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl
|
||||||
import org.jetbrains.kotlin.fir.visitors.*
|
import kotlin.contracts.ExperimentalContracts
|
||||||
|
import kotlin.contracts.contract
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file was generated automatically
|
* This file was generated automatically
|
||||||
@@ -28,6 +27,8 @@ class FirErrorTypeRefBuilder : FirAnnotationContainerBuilder {
|
|||||||
override var source: KtSourceElement? = null
|
override var source: KtSourceElement? = null
|
||||||
var type: ConeKotlinType? = null
|
var type: ConeKotlinType? = null
|
||||||
var delegatedTypeRef: FirTypeRef? = null
|
var delegatedTypeRef: FirTypeRef? = null
|
||||||
|
var partiallyResolvedTypeRef: FirTypeRef? = null
|
||||||
|
|
||||||
lateinit var diagnostic: ConeDiagnostic
|
lateinit var diagnostic: ConeDiagnostic
|
||||||
|
|
||||||
override fun build(): FirErrorTypeRef {
|
override fun build(): FirErrorTypeRef {
|
||||||
@@ -37,13 +38,15 @@ class FirErrorTypeRefBuilder : FirAnnotationContainerBuilder {
|
|||||||
source,
|
source,
|
||||||
type,
|
type,
|
||||||
delegatedTypeRef,
|
delegatedTypeRef,
|
||||||
diagnostic
|
diagnostic,
|
||||||
|
partiallyResolvedTypeRef = partiallyResolvedTypeRef,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
FirErrorTypeRefImpl(
|
FirErrorTypeRefImpl(
|
||||||
source,
|
source,
|
||||||
delegatedTypeRef,
|
delegatedTypeRef,
|
||||||
diagnostic,
|
diagnostic,
|
||||||
|
partiallyResolvedTypeRef = partiallyResolvedTypeRef,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,29 +13,35 @@ import org.jetbrains.kotlin.fir.types.ConeErrorType
|
|||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||||
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
|
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
import org.jetbrains.kotlin.fir.visitors.*
|
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.transformInplace
|
||||||
|
|
||||||
internal class FirErrorTypeRefImpl(
|
internal class FirErrorTypeRefImpl(
|
||||||
override val source: KtSourceElement?,
|
override val source: KtSourceElement?,
|
||||||
override val type: ConeKotlinType,
|
override val type: ConeKotlinType,
|
||||||
override var delegatedTypeRef: FirTypeRef?,
|
override var delegatedTypeRef: FirTypeRef?,
|
||||||
override val diagnostic: ConeDiagnostic,
|
override val diagnostic: ConeDiagnostic,
|
||||||
override val isFromStubType: Boolean = false
|
override val isFromStubType: Boolean = false,
|
||||||
|
override var partiallyResolvedTypeRef: FirTypeRef? = null,
|
||||||
) : FirErrorTypeRef() {
|
) : FirErrorTypeRef() {
|
||||||
constructor(source: KtSourceElement?, delegatedTypeRef: FirTypeRef?, diagnostic: ConeDiagnostic,
|
constructor(
|
||||||
isFromStubType: Boolean = false
|
source: KtSourceElement?, delegatedTypeRef: FirTypeRef?, diagnostic: ConeDiagnostic,
|
||||||
|
isFromStubType: Boolean = false, partiallyResolvedTypeRef: FirTypeRef? = null,
|
||||||
) : this(
|
) : this(
|
||||||
source,
|
source,
|
||||||
ConeErrorType(diagnostic),
|
ConeErrorType(diagnostic),
|
||||||
delegatedTypeRef,
|
delegatedTypeRef,
|
||||||
diagnostic,
|
diagnostic,
|
||||||
isFromStubType
|
isFromStubType,
|
||||||
|
partiallyResolvedTypeRef,
|
||||||
)
|
)
|
||||||
|
|
||||||
override val annotations: MutableOrEmptyList<FirAnnotation> = MutableOrEmptyList.empty()
|
override val annotations: MutableOrEmptyList<FirAnnotation> = MutableOrEmptyList.empty()
|
||||||
|
|
||||||
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) }
|
||||||
|
partiallyResolvedTypeRef?.accept(visitor, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirErrorTypeRefImpl {
|
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirErrorTypeRefImpl {
|
||||||
@@ -51,4 +57,9 @@ internal class FirErrorTypeRefImpl(
|
|||||||
annotations.transformInplace(transformer, data)
|
annotations.transformInplace(transformer, data)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun <D> transformPartiallyResolvedTypeRef(transformer: FirTransformer<D>, data: D): FirErrorTypeRef {
|
||||||
|
partiallyResolvedTypeRef = partiallyResolvedTypeRef?.transform(transformer, data)
|
||||||
|
return this
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -717,6 +717,10 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
|||||||
+fieldList("contextReceiverTypeRefs", typeRef)
|
+fieldList("contextReceiverTypeRefs", typeRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errorTypeRef.configure {
|
||||||
|
+field("partiallyResolvedTypeRef", typeRef, nullable = true).withTransform()
|
||||||
|
}
|
||||||
|
|
||||||
intersectionTypeRef.configure {
|
intersectionTypeRef.configure {
|
||||||
+field("leftType", typeRef)
|
+field("leftType", typeRef)
|
||||||
+field("rightType", typeRef)
|
+field("rightType", typeRef)
|
||||||
|
|||||||
Reference in New Issue
Block a user