[FIR IDE] Add base support for FIR incomplete types resolve

This commit is contained in:
Igor Yakovlev
2021-01-14 00:31:50 +03:00
parent 704366e531
commit 243f85a4d6
15 changed files with 30 additions and 22 deletions
@@ -86,6 +86,8 @@ class FirSpecificTypeResolverTransformer(
typeRef.source
}
delegatedTypeRef = typeRef
diagnostic = resolvedType.diagnostic
}
}.compose()
@@ -39,7 +39,7 @@ internal class FirErrorFunctionImpl(
override val symbol: FirErrorFunctionSymbol,
override val typeParameters: MutableList<FirTypeParameter>,
) : FirErrorFunction() {
override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, diagnostic)
override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, null, diagnostic)
override val receiverTypeRef: FirTypeRef? get() = null
override var controlFlowGraphReference: FirControlFlowGraphReference? = null
override val body: FirBlock? get() = null
@@ -40,7 +40,7 @@ internal class FirErrorPropertyImpl(
override val typeParameters: MutableList<FirTypeParameter>,
override val symbol: FirErrorPropertySymbol,
) : FirErrorProperty() {
override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, diagnostic)
override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, null, diagnostic)
override val receiverTypeRef: FirTypeRef? get() = null
override val initializer: FirExpression? get() = null
override val delegate: FirExpression? get() = null
@@ -23,7 +23,7 @@ internal class FirErrorExpressionImpl(
override val source: FirSourceElement?,
override val diagnostic: ConeDiagnostic,
) : FirErrorExpression() {
override var typeRef: FirTypeRef = FirErrorTypeRefImpl(source, ConeStubDiagnostic(diagnostic))
override var typeRef: FirTypeRef = FirErrorTypeRefImpl(source, null, ConeStubDiagnostic(diagnostic))
override val annotations: List<FirAnnotationCall> get() = emptyList()
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
@@ -26,11 +26,13 @@ import org.jetbrains.kotlin.fir.visitors.*
@FirBuilderDsl
class FirErrorTypeRefBuilder : FirAnnotationContainerBuilder {
override var source: FirSourceElement? = null
var delegatedTypeRef: FirTypeRef? = null
lateinit var diagnostic: ConeDiagnostic
override fun build(): FirErrorTypeRef {
return FirErrorTypeRefImpl(
source,
delegatedTypeRef,
diagnostic,
)
}
@@ -55,6 +57,7 @@ inline fun buildErrorTypeRefCopy(original: FirErrorTypeRef, init: FirErrorTypeRe
}
val copyBuilder = FirErrorTypeRefBuilder()
copyBuilder.source = original.source
copyBuilder.delegatedTypeRef = original.delegatedTypeRef
copyBuilder.diagnostic = original.diagnostic
return copyBuilder.apply(init).build()
}
@@ -21,18 +21,20 @@ import org.jetbrains.kotlin.fir.visitors.*
internal class FirErrorTypeRefImpl(
override val source: FirSourceElement?,
override var delegatedTypeRef: FirTypeRef?,
override val diagnostic: ConeDiagnostic,
) : FirErrorTypeRef() {
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override val type: ConeKotlinType = ConeClassErrorType(diagnostic)
override val delegatedTypeRef: FirTypeRef? get() = null
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
annotations.forEach { it.accept(visitor, data) }
delegatedTypeRef?.accept(visitor, data)
}
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirErrorTypeRefImpl {
transformAnnotations(transformer, data)
delegatedTypeRef = delegatedTypeRef?.transformSingle(transformer, data)
return this
}
@@ -170,10 +170,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
val errorTypeRefImpl = impl(errorTypeRef) {
default("type", "ConeClassErrorType(diagnostic)")
default("delegatedTypeRef") {
value = "null"
withGetter = true
}
default("annotations", "mutableListOf()")
useTypes(coneClassErrorTypeType)
}
@@ -201,7 +197,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
"getter", "setter",
withGetter = true
)
default("returnTypeRef", "FirErrorTypeRefImpl(null, diagnostic)")
default("returnTypeRef", "FirErrorTypeRefImpl(null, null, diagnostic)")
useTypes(errorTypeRefImpl)
}
@@ -396,13 +392,13 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
impl(errorExpression) {
defaultEmptyList("annotations")
default("typeRef", "FirErrorTypeRefImpl(source, ConeStubDiagnostic(diagnostic))")
default("typeRef", "FirErrorTypeRefImpl(source, null, ConeStubDiagnostic(diagnostic))")
useTypes(errorTypeRefImpl, coneStubDiagnosticType)
}
impl(errorFunction) {
defaultNull("receiverTypeRef", "body", withGetter = true)
default("returnTypeRef", "FirErrorTypeRefImpl(null, diagnostic)")
default("returnTypeRef", "FirErrorTypeRefImpl(null, null, diagnostic)")
useTypes(errorTypeRefImpl)
}