[FIR] Remove the redundant backing field check
This commit fixes a failing visibility check (FirSymbolByPsiTestGenerated.testBackingField) for the backing field. Merge-request: KT-MR-6389 Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
This commit is contained in:
+6
@@ -124,6 +124,12 @@ public class Fe10IdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated extends A
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/enumValueMember.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("explicitBackingField.kt")
|
||||
public void testExplicitBackingField() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/explicitBackingField.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
|
||||
+6
@@ -124,6 +124,12 @@ public class FirIdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated extends Ab
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/enumValueMember.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("explicitBackingField.kt")
|
||||
public void testExplicitBackingField() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/explicitBackingField.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
|
||||
+2
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.psi.KtBackingField
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
@@ -28,6 +29,7 @@ abstract class AbstractSymbolByPsiTest : AbstractSymbolTest() {
|
||||
private val KtDeclaration.isValidForSymbolCreation
|
||||
get() =
|
||||
when (this) {
|
||||
is KtBackingField -> false
|
||||
is KtParameter -> !this.isFunctionTypeParameter
|
||||
else -> true
|
||||
}
|
||||
|
||||
+6
@@ -124,6 +124,12 @@ public class FirStandaloneNormalAnalysisSourceModuleSymbolByPsiTestGenerated ext
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/enumValueMember.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("explicitBackingField.kt")
|
||||
public void testExplicitBackingField() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/explicitBackingField.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
var p: Int
|
||||
field = "test"
|
||||
get() = field.length
|
||||
set(value) {
|
||||
field = value.toString()
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
var p: kotlin.Int
|
||||
@@ -0,0 +1,91 @@
|
||||
KtPropertyGetterSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: null
|
||||
hasBody: true
|
||||
hasStableParameterNames: true
|
||||
isDefault: false
|
||||
isExtension: false
|
||||
isInline: false
|
||||
isOverride: false
|
||||
modality: FINAL
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
returnType: kotlin/Int
|
||||
symbolKind: ACCESSOR
|
||||
typeParameters: []
|
||||
valueParameters: []
|
||||
visibility: Public
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
|
||||
KtValueParameterSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: null
|
||||
generatedPrimaryConstructorProperty: null
|
||||
hasDefaultValue: false
|
||||
isExtension: false
|
||||
isImplicitLambdaParameter: false
|
||||
isVararg: false
|
||||
name: value
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
returnType: kotlin/Int
|
||||
symbolKind: LOCAL
|
||||
typeParameters: []
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
|
||||
KtPropertySetterSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: null
|
||||
hasBody: true
|
||||
hasStableParameterNames: true
|
||||
isDefault: false
|
||||
isExtension: false
|
||||
isInline: false
|
||||
isOverride: false
|
||||
modality: FINAL
|
||||
origin: SOURCE
|
||||
parameter: KtValueParameterSymbol(value)
|
||||
receiverType: null
|
||||
returnType: kotlin/Unit
|
||||
symbolKind: ACCESSOR
|
||||
typeParameters: []
|
||||
valueParameters: [
|
||||
KtValueParameterSymbol(value)
|
||||
]
|
||||
visibility: Public
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
|
||||
KtKotlinPropertySymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: /p
|
||||
getter: KtPropertyGetterSymbol(<getter>)
|
||||
hasBackingField: true
|
||||
hasGetter: true
|
||||
hasSetter: true
|
||||
initializer: null
|
||||
isConst: false
|
||||
isDelegatedProperty: false
|
||||
isExtension: false
|
||||
isFromPrimaryConstructor: false
|
||||
isLateInit: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isVal: false
|
||||
modality: FINAL
|
||||
name: p
|
||||
origin: SOURCE
|
||||
receiverType: null
|
||||
returnType: kotlin/Int
|
||||
setter: KtPropertySetterSymbol(<setter>)
|
||||
symbolKind: TOP_LEVEL
|
||||
typeParameters: []
|
||||
visibility: Public
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
getterDeprecationStatus: null
|
||||
javaGetterName: getP
|
||||
javaSetterName: setP
|
||||
setterDeprecationStatus: null
|
||||
+5
-6
@@ -68,13 +68,12 @@ internal class LLFirProvider(
|
||||
symbol.fir.originalForSubstitutionOverride?.symbol?.let {
|
||||
return getFirCallableContainerFile(it)
|
||||
}
|
||||
if (symbol is FirSyntheticPropertySymbol) {
|
||||
val fir = symbol.fir
|
||||
if (fir is FirSyntheticProperty) {
|
||||
return getFirCallableContainerFile(fir.getter.delegate.symbol)
|
||||
}
|
||||
val fir = symbol.fir
|
||||
return when {
|
||||
symbol is FirBackingFieldSymbol -> getFirCallableContainerFile(symbol.fir.propertySymbol)
|
||||
symbol is FirSyntheticPropertySymbol && fir is FirSyntheticProperty -> getFirCallableContainerFile(fir.getter.delegate.symbol)
|
||||
else -> moduleComponents.cache.getContainerFirFile(symbol.fir)
|
||||
}
|
||||
return moduleComponents.cache.getContainerFirFile(symbol.fir)
|
||||
}
|
||||
|
||||
override fun getFirFilesByPackage(fqName: FqName): List<FirFile> = error("Should not be called in FIR IDE")
|
||||
|
||||
@@ -31,12 +31,6 @@ fun FirVisibilityChecker.isVisible(
|
||||
return isVisible(declaration.originalIfFakeOverride() as FirMemberDeclaration, callInfo, dispatchReceiverValue)
|
||||
}
|
||||
|
||||
// We won't resolve into the backing field
|
||||
// in the first place, if it's not accessible.
|
||||
if (declaration is FirBackingField) {
|
||||
return true
|
||||
}
|
||||
|
||||
val useSiteFile = callInfo.containingFile
|
||||
val containingDeclarations = callInfo.containingDeclarations
|
||||
val session = callInfo.session
|
||||
|
||||
Reference in New Issue
Block a user