[FIR] Hide local type for return type of single expression function ^KT-51418 Fixed
This commit is contained in:
+1
-1
@@ -952,7 +952,7 @@ internal class FirDeclarationCompletionResultsWriter(
|
||||
typeRef.resolvedTypeFromPrototype(it)
|
||||
} ?: typeRef
|
||||
if (data is ApproximationData.ApproximateByStatus) {
|
||||
return result.approximatedIfNeededOrSelf(typeApproximator, data.visibility, data.isInline)
|
||||
return result.approximatedIfNeededOrSelf(typeApproximator, data.visibility, this.typeContext.session, data.isInline)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
+21
-20
@@ -344,7 +344,11 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
||||
typeVariableTypeToStubType, session.typeContext, approximateIntegerLiterals = true
|
||||
)
|
||||
|
||||
val stubTypeSubstituted = substitutor.substituteOrSelf(provideDelegateCandidate.substitutor.substituteOrSelf(components.typeFromCallee(provideDelegateCall).type))
|
||||
val stubTypeSubstituted = substitutor.substituteOrSelf(
|
||||
provideDelegateCandidate.substitutor.substituteOrSelf(
|
||||
components.typeFromCallee(provideDelegateCall).type
|
||||
)
|
||||
)
|
||||
|
||||
provideDelegateCall.replaceTypeRef(provideDelegateCall.typeRef.resolvedTypeFromPrototype(stubTypeSubstituted))
|
||||
return provideDelegateCall
|
||||
@@ -624,14 +628,15 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
||||
if (result.returnTypeRef is FirImplicitTypeRef) {
|
||||
val simpleFunction = function as? FirSimpleFunction
|
||||
val returnExpression = (body?.statements?.single() as? FirReturnExpression)?.result
|
||||
if (returnExpression != null && returnExpression.typeRef is FirResolvedTypeRef) {
|
||||
if (returnExpression?.typeRef is FirResolvedTypeRef) {
|
||||
result.transformReturnTypeRef(
|
||||
transformer,
|
||||
withExpectedType(
|
||||
returnExpression.resultType.approximatedIfNeededOrSelf(
|
||||
session.typeApproximator,
|
||||
simpleFunction?.visibilityForApproximation(),
|
||||
simpleFunction?.isInline == true
|
||||
session,
|
||||
isInlineFunction = simpleFunction?.isInline == true
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -1009,6 +1014,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
||||
expectedType.approximatedIfNeededOrSelf(
|
||||
session.typeApproximator,
|
||||
backingField.visibilityForApproximation(),
|
||||
session
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -1025,28 +1031,23 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
||||
variable.getter != null && variable.getter !is FirDefaultPropertyAccessor -> variable.getter?.returnTypeRef
|
||||
else -> null
|
||||
}
|
||||
if (resultType != null) {
|
||||
val expectedType = resultType.toExpectedTypeRef()
|
||||
variable.transformReturnTypeRef(
|
||||
transformer,
|
||||
withExpectedType(
|
||||
|
||||
variable.transformReturnTypeRef(
|
||||
transformer,
|
||||
withExpectedType(
|
||||
resultType?.let {
|
||||
val expectedType = it.toExpectedTypeRef()
|
||||
expectedType.approximatedIfNeededOrSelf(
|
||||
session.typeApproximator,
|
||||
variable.visibilityForApproximation(),
|
||||
session
|
||||
)
|
||||
)
|
||||
} ?: buildErrorTypeRef {
|
||||
diagnostic = ConeLocalVariableNoTypeOrInitializer(variable)
|
||||
source = variable.source
|
||||
}
|
||||
)
|
||||
} else {
|
||||
variable.transformReturnTypeRef(
|
||||
transformer,
|
||||
withExpectedType(
|
||||
buildErrorTypeRef {
|
||||
diagnostic = ConeLocalVariableNoTypeOrInitializer(variable)
|
||||
source = variable.source
|
||||
},
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
if (variable.getter?.returnTypeRef is FirImplicitTypeRef) {
|
||||
variable.getter?.transformReturnTypeRef(transformer, withExpectedType(variable.returnTypeRef))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user