[FIR] Properly create type ref for error type in various places
This commit is contained in:
committed by
Space Team
parent
ad3ae0ff69
commit
e9204521a9
@@ -358,11 +358,7 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: FirBasedSymbol<*>, make
|
||||
KtFakeSourceElementKind.ImplicitTypeRef
|
||||
)
|
||||
} else {
|
||||
buildResolvedTypeRef {
|
||||
source = returnTypeRef.source?.fakeElement(KtFakeSourceElementKind.ImplicitTypeRef)
|
||||
type = returnTypeRef.type
|
||||
annotations += returnTypeRef.annotations
|
||||
}
|
||||
returnTypeRef.copyWithNewSourceKind(KtFakeSourceElementKind.ImplicitTypeRef)
|
||||
}
|
||||
}
|
||||
is FirClassifierSymbol<*> -> {
|
||||
|
||||
+1
-3
@@ -508,9 +508,7 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
else -> {
|
||||
buildTypeProjectionWithVariance {
|
||||
source = argument?.source
|
||||
typeRef = buildResolvedTypeRef {
|
||||
this.type = type
|
||||
}
|
||||
typeRef = type.toFirResolvedTypeRef()
|
||||
variance = Variance.INVARIANT
|
||||
}
|
||||
}
|
||||
|
||||
+2
-9
@@ -7,8 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers.body.resolve
|
||||
|
||||
import org.jetbrains.kotlin.KtFakeSourceElementKind
|
||||
import org.jetbrains.kotlin.fakeElement
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
|
||||
import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind
|
||||
@@ -16,9 +15,7 @@ import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirNamedArgumentExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildVarargArgumentsExpression
|
||||
import org.jetbrains.kotlin.fir.renderWithType
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef
|
||||
@@ -90,11 +87,7 @@ fun FirBlock.writeResultType(session: FirSession) {
|
||||
} else {
|
||||
val theType = resultExpression.resultType
|
||||
if (theType is FirResolvedTypeRef) {
|
||||
buildResolvedTypeRef {
|
||||
source = theType.source?.fakeElement(KtFakeSourceElementKind.ImplicitTypeRef)
|
||||
type = theType.type
|
||||
annotations += theType.annotations
|
||||
}
|
||||
theType.copyWithNewSourceKind(KtFakeSourceElementKind.ImplicitTypeRef)
|
||||
} else {
|
||||
buildErrorTypeRef {
|
||||
diagnostic = ConeSimpleDiagnostic("No type for block", DiagnosticKind.InferenceError)
|
||||
|
||||
+2
-8
@@ -113,10 +113,7 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
||||
source = qualifiedAccessExpression.source
|
||||
diagnostic = ConeInstanceAccessBeforeSuperCall("<this>")
|
||||
}
|
||||
implicitType != null -> buildResolvedTypeRef {
|
||||
source = callee.source
|
||||
type = implicitType
|
||||
}
|
||||
implicitType != null -> implicitType.toFirResolvedTypeRef(callee.source?.fakeElement(KtFakeSourceElementKind.ImplicitTypeRef))
|
||||
labelName != null -> buildErrorTypeRef {
|
||||
source = qualifiedAccessExpression.source
|
||||
diagnostic = ConeSimpleDiagnostic("Unresolved this@$labelName", DiagnosticKind.UnresolvedLabel)
|
||||
@@ -310,10 +307,7 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
||||
// Report stub error so that it won't surface up. Instead, errors on the callee would be reported.
|
||||
diagnostic = ConeStubDiagnostic(ConeSimpleDiagnostic("Unresolved super method", DiagnosticKind.Other))
|
||||
}
|
||||
1 -> buildResolvedTypeRef {
|
||||
source = superReferenceContainer.source?.fakeElement(KtFakeSourceElementKind.SuperCallImplicitType)
|
||||
type = types.single()
|
||||
}
|
||||
1 -> types.single().toFirResolvedTypeRef(superReferenceContainer.source?.fakeElement(KtFakeSourceElementKind.SuperCallImplicitType))
|
||||
else -> buildErrorTypeRef {
|
||||
source = superReferenceContainer.source
|
||||
diagnostic = ConeAmbiguousSuper(types)
|
||||
|
||||
Reference in New Issue
Block a user