diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/CopyUtils.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/CopyUtils.kt index 8e7e191c5dc..2a48302d688 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/CopyUtils.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/CopyUtils.kt @@ -117,6 +117,7 @@ fun FirTypeRef.resolvedTypeFromPrototype( return if (type is ConeKotlinErrorType) { buildErrorTypeRef { source = this@resolvedTypeFromPrototype.source + this.type = type diagnostic = type.diagnostic } } else { diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt index 4960c8b95b9..ceae859f495 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt @@ -217,6 +217,7 @@ fun ConeKotlinType.toFirResolvedTypeRef( buildErrorTypeRef { this.source = source diagnostic = this@toFirResolvedTypeRef.diagnostic + type = this@toFirResolvedTypeRef this.delegatedTypeRef = delegatedTypeRef } } else { @@ -275,6 +276,7 @@ fun FirTypeRef.withReplacedConeType( return if (newType is ConeKotlinErrorType) { buildErrorTypeRef { source = newSource + type = newType diagnostic = newType.diagnostic } } else { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index eb81fbae56c..b64dbf1e6cd 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -107,6 +107,7 @@ class FirCallCompletionResultsWriterTransformer( } else { buildErrorTypeRef { source = calculated.source?.fakeElement(KtFakeSourceElementKind.ImplicitTypeRef) + type = calculated.type diagnostic = calculated.diagnostic } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt index 2818b1a842b..e6987282a2e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt @@ -116,6 +116,9 @@ class FirSpecificTypeResolverTransformer( } else { buildErrorTypeRef { source = functionTypeRef.source + if (resolvedType != null) { + type = resolvedType + } diagnostic = (resolvedType as? ConeClassErrorType)?.diagnostic ?: ConeSimpleDiagnostic("Unresolved functional type: ${functionTypeRef.render()}") } @@ -146,9 +149,9 @@ class FirSpecificTypeResolverTransformer( typeRef.source } - delegatedTypeRef = typeRef - - diagnostic = resolvedType.diagnostic + delegatedTypeRef = typeRef + type = resolvedType + diagnostic = resolvedType.diagnostic } } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt similarity index 82% rename from compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt rename to compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt index 94a11541688..634e6dc46e0 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt @@ -26,18 +26,28 @@ import org.jetbrains.kotlin.fir.visitors.* @FirBuilderDsl class FirErrorTypeRefBuilder : FirAnnotationContainerBuilder { override var source: KtSourceElement? = null + var type: ConeKotlinType? = null var delegatedTypeRef: FirTypeRef? = null lateinit var diagnostic: ConeDiagnostic override fun build(): FirErrorTypeRef { - return FirErrorTypeRefImpl( - source, - delegatedTypeRef, - diagnostic, - ) + val type = this.type + return if (type != null) { + FirErrorTypeRefImpl( + source, + type, + delegatedTypeRef, + diagnostic, + ) + } else { + FirErrorTypeRefImpl( + source, + delegatedTypeRef, + diagnostic, + ) + } } - @Deprecated("Modification of 'annotations' has no impact for FirErrorTypeRefBuilder", level = DeprecationLevel.HIDDEN) override val annotations: MutableList = mutableListOf() } @@ -57,6 +67,7 @@ inline fun buildErrorTypeRefCopy(original: FirErrorTypeRef, init: FirErrorTypeRe } val copyBuilder = FirErrorTypeRefBuilder() copyBuilder.source = original.source + copyBuilder.type = original.type copyBuilder.delegatedTypeRef = original.delegatedTypeRef copyBuilder.diagnostic = original.diagnostic return copyBuilder.apply(init).build() diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt similarity index 85% rename from compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt rename to compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt index a27ce6d9877..d915066ae86 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt @@ -14,18 +14,19 @@ import org.jetbrains.kotlin.fir.types.FirErrorTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* -/* - * This file was generated automatically - * DO NOT MODIFY IT MANUALLY - */ - internal class FirErrorTypeRefImpl( override val source: KtSourceElement?, + override val type: ConeKotlinType, override var delegatedTypeRef: FirTypeRef?, override val diagnostic: ConeDiagnostic, ) : FirErrorTypeRef() { + constructor(source: KtSourceElement?, delegatedTypeRef: FirTypeRef?, diagnostic: ConeDiagnostic) : this( + source, + ConeClassErrorType(diagnostic), + delegatedTypeRef, diagnostic + ) + override val annotations: MutableList = mutableListOf() - override val type: ConeKotlinType = ConeClassErrorType(diagnostic) override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt index ef4bbcd0f85..ba5512da14f 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/BuilderConfigurator.kt @@ -254,10 +254,6 @@ object BuilderConfigurator : AbstractBuilderConfigurator(FirTree withCopy() } - builder(errorTypeRef) { - withCopy() - } - builder(functionTypeRef) { withCopy() } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt index f399149fc42..b85bcda5f12 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt @@ -200,15 +200,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() } } - val errorTypeRefImpl = impl(errorTypeRef) { - default("type", "ConeClassErrorType(diagnostic)") - default("annotations", "mutableListOf()") - useTypes(coneClassErrorTypeType) - default("delegatedTypeRef") { - needAcceptAndTransform = false - } - } - + noImpl(errorTypeRef) impl(property) { default("isVal") { @@ -231,7 +223,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() withGetter = true ) default("returnTypeRef", "FirErrorTypeRefImpl(null, null, diagnostic)") - useTypes(errorTypeRefImpl) + useTypes(errorTypeRefImplType) } impl(field) { @@ -428,13 +420,13 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(errorExpression) { default("typeRef", "FirErrorTypeRefImpl(source, null, ConeStubDiagnostic(diagnostic))") - useTypes(errorTypeRefImpl, coneStubDiagnosticType) + useTypes(errorTypeRefImplType, coneStubDiagnosticType) } impl(errorFunction) { defaultNull("receiverTypeRef", "body", withGetter = true) default("returnTypeRef", "FirErrorTypeRefImpl(null, null, diagnostic)") - useTypes(errorTypeRefImpl) + useTypes(errorTypeRefImplType) } impl(functionTypeRef) diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt index fe5a6827f07..068a22f706b 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/Types.kt @@ -98,4 +98,5 @@ val deprecationsPerUseSiteType = type("fir.declarations", "DeprecationsPerUseSit val emptyAnnotationArgumentMappingType = type("fir.expressions.impl", "FirEmptyAnnotationArgumentMapping") val firPropertySymbolType = type("fir.symbols.impl", "FirPropertySymbol") +val errorTypeRefImplType = type("fir.types.impl", "FirErrorTypeRefImpl") diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWithBoundExtensionReceiver.fir.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWithBoundExtensionReceiver.fir.kt index 0f30990cb3e..9fcc383dd51 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWithBoundExtensionReceiver.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/ambiguityWithBoundExtensionReceiver.fir.kt @@ -10,6 +10,6 @@ fun A.foo() = "" class A { fun main() { - bar(::foo) checkType { _() } + bar(::foo) checkType { _() } } }