[FIR] Properly set sources of intersection overrides

Otherwise, they may point to one of
the base intersected functions, and
if we start reporting diagnostics on
them, they'll appear on base
functions.
This commit is contained in:
Nikolay Lunyak
2023-11-29 12:00:02 +02:00
committed by Space Team
parent 3b5fff5473
commit 686abb112d
2 changed files with 7 additions and 4 deletions
@@ -121,9 +121,9 @@ object FirFakeOverrideGenerator {
newModality: Modality? = null,
newVisibility: Visibility? = null,
deferredReturnTypeCalculation: CallableCopyDeferredReturnTypeCalculation? = null,
newSource: KtSourceElement? = null,
newSource: KtSourceElement? = derivedClassLookupTag?.toSymbol(session)?.source ?: baseFunction.source,
): FirSimpleFunction = buildSimpleFunction {
source = newSource ?: derivedClassLookupTag?.toSymbol(session)?.source ?: baseFunction.source
source = newSource
moduleData = session.nullableModuleData ?: baseFunction.moduleData
this.origin = origin
name = baseFunction.name
@@ -401,8 +401,9 @@ object FirFakeOverrideGenerator {
newModality: Modality? = null,
newVisibility: Visibility? = null,
deferredReturnTypeCalculation: CallableCopyDeferredReturnTypeCalculation? = null,
newSource: KtSourceElement? = derivedClassLookupTag?.toSymbol(session)?.source ?: baseProperty.source,
): FirProperty = buildProperty {
source = derivedClassLookupTag?.toSymbol(session)?.source ?: baseProperty.source
source = newSource
moduleData = session.nullableModuleData ?: baseProperty.moduleData
this.origin = origin
name = baseProperty.name
@@ -358,6 +358,7 @@ class FirTypeIntersectionScopeContext(
newDispatchReceiverType = dispatchReceiverType,
deferredReturnTypeCalculation = deferredReturnTypeCalculation,
newReturnType = if (!forClassUseSiteScope && deferredReturnTypeCalculation == null) intersectReturnTypes(mostSpecific) else null,
newSource = dispatchReceiverType.toSymbol(session)?.source,
).apply {
originalForIntersectionOverrideAttr = keyFir
}
@@ -385,7 +386,8 @@ class FirTypeIntersectionScopeContext(
deferredReturnTypeCalculation = deferredReturnTypeCalculation,
// If any of the properties are vars and the types are not equal, these declarations are conflicting
// anyway and their uses should result in an overload resolution error.
newReturnType = returnType
newReturnType = returnType,
newSource = dispatchReceiverType.toSymbol(session)?.source,
)
}
}