Skip to content

Commit

Permalink
[FIR] Copy attributes onto fake override accessors
Browse files Browse the repository at this point in the history
This fixes a false positive NON_PUBLIC_CALL_FROM_PUBLIC_INLINE caused
by the published visibility attribute not being copied to a fake
override accessor.

#KT-70901 Fixed
  • Loading branch information
cypressious authored and qodana-bot committed Aug 23, 2024
1 parent 8f0b2b7 commit 5529c50
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public open [ResolvedTo(BODY_RESOLVE)] fun foo([ResolvedTo(BODY_RESOLVE)] x: R|F

public? open override [ResolvedTo(BODY_RESOLVE)] [IntersectionOverrideOriginalKey=second/B.bar, SubstitutedOverrideOriginalKey=second/B.bar] var bar: R|@R|second/Anno|(str = <strcat>(String(object ), R|second/constant|)) kotlin/String|

public? [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=<anonymous>] set([ResolvedTo(BODY_RESOLVE)] value: R|@R|second/Anno|(str = <strcat>(String(object ), R|second/constant|)) kotlin/String|): R|kotlin/Unit|
public? [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=<anonymous>, IntersectionOverrideOriginalKey=special/accessor] set([ResolvedTo(BODY_RESOLVE)] value: R|@R|second/Anno|(str = <strcat>(String(object ), R|second/constant|)) kotlin/String|): R|kotlin/Unit|

public? open override [ResolvedTo(BODY_RESOLVE)] [IntersectionOverrideOriginalKey=second/B.bar, SubstitutedOverrideOriginalKey=second/C.bar] var bar: R|T|

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public open [ResolvedTo(STATUS)] fun foo([ResolvedTo(STATUS)] x: R|F| = LAZY_EXP

public? open override [ResolvedTo(STATUS)] [DeferredCallableCopyReturnTypeKey=DeferredReturnTypeOfSubstitution(substitutor={T -> @R|second/Anno|(str = <strcat>(String(object ), R|second/constant|)) kotlin/String}, baseSymbol=FirIntersectionOverridePropertySymbol second/B.bar), IntersectionOverrideOriginalKey=second/B.bar, SubstitutedOverrideOriginalKey=second/B.bar] var bar: <implicit>

public? [ResolvedTo(STATUS)] [ContainingClassKey=<anonymous>] set([ResolvedTo(STATUS)] value: <implicit>): R|kotlin/Unit|
public? [ResolvedTo(STATUS)] [ContainingClassKey=<anonymous>, IntersectionOverrideOriginalKey=special/accessor] set([ResolvedTo(STATUS)] value: <implicit>): R|kotlin/Unit|

public? open override [ResolvedTo(STATUS)] [DeferredCallableCopyReturnTypeKey=CallableCopyIntersection(mostSpecific=[FirPropertySymbol second/B.bar, FirPropertySymbol second/B.bar]), IntersectionOverrideOriginalKey=second/B.bar, SubstitutedOverrideOriginalKey=second/C.bar] var bar: <implicit>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public open [ResolvedTo(BODY_RESOLVE)] fun foo([ResolvedTo(BODY_RESOLVE)] x: R|F

public? open override [ResolvedTo(BODY_RESOLVE)] [IntersectionOverrideOriginalKey=second/B.bar, SubstitutedOverrideOriginalKey=second/B.bar] var bar: R|@R|second/Anno|(str = <strcat>(String(object ), R|second/constant|)) kotlin/String|

public? [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=<anonymous>] set([ResolvedTo(BODY_RESOLVE)] value: R|@R|second/Anno|(str = <strcat>(String(object ), R|second/constant|)) kotlin/String|): R|kotlin/Unit|
public? [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=<anonymous>, IntersectionOverrideOriginalKey=special/accessor] set([ResolvedTo(BODY_RESOLVE)] value: R|@R|second/Anno|(str = <strcat>(String(object ), R|second/constant|)) kotlin/String|): R|kotlin/Unit|

public? open override [ResolvedTo(BODY_RESOLVE)] [IntersectionOverrideOriginalKey=second/B.bar, SubstitutedOverrideOriginalKey=second/C.bar] var bar: R|T|

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public open [ResolvedTo(STATUS)] fun foo([ResolvedTo(STATUS)] x: R|F| = LAZY_EXP

public? open override [ResolvedTo(STATUS)] [DeferredCallableCopyReturnTypeKey=DeferredReturnTypeOfSubstitution(substitutor={T -> @R|second/Anno|(str = <strcat>(String(object ), R|second/constant|)) kotlin/String}, baseSymbol=FirIntersectionOverridePropertySymbol second/B.bar), IntersectionOverrideOriginalKey=second/B.bar, SubstitutedOverrideOriginalKey=second/B.bar] var bar: <implicit>

public? [ResolvedTo(STATUS)] [ContainingClassKey=<anonymous>] set([ResolvedTo(STATUS)] value: <implicit>): R|kotlin/Unit|
public? [ResolvedTo(STATUS)] [ContainingClassKey=<anonymous>, IntersectionOverrideOriginalKey=special/accessor] set([ResolvedTo(STATUS)] value: <implicit>): R|kotlin/Unit|

public? open override [ResolvedTo(STATUS)] [DeferredCallableCopyReturnTypeKey=CallableCopyIntersection(mostSpecific=[FirPropertySymbol second/B.bar, FirPropertySymbol second/B.bar]), IntersectionOverrideOriginalKey=second/B.bar, SubstitutedOverrideOriginalKey=second/C.bar] var bar: <implicit>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ object FirFakeOverrideGenerator {
effectiveVisibility = effectiveVisibility,
resolvePhase = origin.resolvePhaseForCopy,
isOverride = true,
attributes = attributes.copy(),
).apply {
replaceAnnotations(this@buildCopy.annotations)
}
Expand All @@ -517,6 +518,7 @@ object FirFakeOverrideGenerator {
resolvePhase = origin.resolvePhaseForCopy,
parameterSource = valueParameters.first().source,
isOverride = true,
attributes = attributes.copy(),
).apply {
replaceAnnotations(this@buildCopy.annotations)
}
Expand All @@ -530,6 +532,7 @@ object FirFakeOverrideGenerator {
this.body = null
resolvePhase = origin.resolvePhaseForCopy
this.status = status.copy(visibility = newVisibility)
this.attributes = this@buildCopy.attributes.copy()
}.also {
if (it.isSetter) {
val originalParameter = it.valueParameters.first()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ abstract class FirDefaultPropertyAccessor(
isOverride: Boolean,
symbol: FirPropertyAccessorSymbol,
resolvePhase: FirResolvePhase,
attributes: FirDeclarationAttributes,
) : FirPropertyAccessorImpl(
source,
resolvePhase,
moduleData,
origin,
FirDeclarationAttributes(),
attributes,
status = when (effectiveVisibility) {
null -> FirDeclarationStatusImpl(visibility, modality)
else -> FirResolvedDeclarationStatusImpl(visibility, modality, effectiveVisibility)
Expand Down Expand Up @@ -114,6 +115,7 @@ class FirDefaultPropertyGetter(
isOverride: Boolean = false,
symbol: FirPropertyAccessorSymbol = FirPropertyAccessorSymbol(),
resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR,
attributes: FirDeclarationAttributes = FirDeclarationAttributes()
) : FirDefaultPropertyAccessor(
source,
moduleData,
Expand All @@ -129,6 +131,7 @@ class FirDefaultPropertyGetter(
isOverride = isOverride,
symbol = symbol,
resolvePhase = resolvePhase,
attributes = attributes,
)

/**
Expand All @@ -150,6 +153,7 @@ class FirDefaultPropertySetter(
parameterSource: KtSourceElement? = null,
parameterAnnotations: List<FirAnnotation> = emptyList(),
resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR,
attributes: FirDeclarationAttributes = FirDeclarationAttributes()
) : FirDefaultPropertyAccessor(
source,
moduleData,
Expand All @@ -176,4 +180,5 @@ class FirDefaultPropertySetter(
isOverride = isOverride,
symbol = propertyAccessorSymbol,
resolvePhase = resolvePhase,
attributes = attributes,
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
@PublishedApi
internal interface History<T> {
var isIgnoringPlatformChanges: Boolean
Expand Down

0 comments on commit 5529c50

Please sign in to comment.