[Analysis API FIR] fix member scope for enum entries without body
This commit is contained in:
+2
-2
@@ -71,8 +71,8 @@ internal class KtFirScopeProvider(
|
|||||||
}
|
}
|
||||||
is KtFirEnumEntrySymbol -> {
|
is KtFirEnumEntrySymbol -> {
|
||||||
firSymbol.ensureResolved(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE)
|
firSymbol.ensureResolved(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE)
|
||||||
val initializer = firSymbol.fir.initializer
|
val initializer = firSymbol.fir.initializer ?: return null
|
||||||
check(initializer is FirAnonymousObjectExpression) { "Unexpected enum entry initializer: ${initializer?.javaClass}" }
|
check(initializer is FirAnonymousObjectExpression) { "Unexpected enum entry initializer: ${initializer.javaClass}" }
|
||||||
body(initializer.anonymousObject)
|
body(initializer.anonymousObject)
|
||||||
}
|
}
|
||||||
else -> error { "Unknown KtSymbolWithDeclarations implementation ${this::class.qualifiedName}" }
|
else -> error { "Unknown KtSymbolWithDeclarations implementation ${this::class.qualifiedName}" }
|
||||||
|
|||||||
+12
@@ -46,6 +46,18 @@ public class FirIdeNormalAnalysisSourceModuleMemberScopeByFqNameTestGenerated ex
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/scopes/memberScopeByFqName"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/scopes/memberScopeByFqName"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("emumEntryWithoutMembers.kt")
|
||||||
|
public void testEmumEntryWithoutMembers() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/scopes/memberScopeByFqName/emumEntryWithoutMembers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enumEntry.kt")
|
||||||
|
public void testEnumEntry() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/scopes/memberScopeByFqName/enumEntry.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("Int.kt")
|
@TestMetadata("Int.kt")
|
||||||
public void testInt() throws Exception {
|
public void testInt() throws Exception {
|
||||||
|
|||||||
+2
-1
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.analysis.api.impl.base.test.SymbolByFqName
|
|||||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.AbstractSymbolByFqNameTest
|
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.AbstractSymbolByFqNameTest
|
||||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolsData
|
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolsData
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtClassOrObjectSymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtClassOrObjectSymbol
|
||||||
|
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithMembers
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.jetbrains.kotlin.test.services.TestServices
|
import org.jetbrains.kotlin.test.services.TestServices
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ abstract class AbstractMemberScopeByFqNameTest : AbstractSymbolByFqNameTest() {
|
|||||||
override fun KtAnalysisSession.collectSymbols(ktFile: KtFile, testServices: TestServices): SymbolsData {
|
override fun KtAnalysisSession.collectSymbols(ktFile: KtFile, testServices: TestServices): SymbolsData {
|
||||||
val symbolData = SymbolByFqName.getSymbolDataFromFile(testDataPath)
|
val symbolData = SymbolByFqName.getSymbolDataFromFile(testDataPath)
|
||||||
val symbols = with(symbolData) { toSymbols() }
|
val symbols = with(symbolData) { toSymbols() }
|
||||||
val classSymbol = symbols.singleOrNull() as? KtClassOrObjectSymbol
|
val classSymbol = symbols.singleOrNull() as? KtSymbolWithMembers
|
||||||
?: error("Should be a single class symbol, but $symbols found")
|
?: error("Should be a single class symbol, but $symbols found")
|
||||||
return SymbolsData(classSymbol.getMemberScope().getAllSymbols().toList())
|
return SymbolsData(classSymbol.getMemberScope().getAllSymbols().toList())
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -90,13 +90,17 @@ abstract class AbstractSymbolTest : AbstractAnalysisApiSingleFileTest() {
|
|||||||
data: SymbolPointersData,
|
data: SymbolPointersData,
|
||||||
testServices: TestServices,
|
testServices: TestServices,
|
||||||
) {
|
) {
|
||||||
val actual = data.pointers.joinToString(separator = "\n\n") { it.rendered }
|
val actual = data.pointers.renderDeclarations()
|
||||||
testServices.assertions.assertEqualsToTestDataFileSibling(actual)
|
testServices.assertions.assertEqualsToTestDataFileSibling(actual)
|
||||||
|
|
||||||
val actualPretty = data.pointersForPrettyRendering.joinToString(separator = "\n\n") { it.rendered }
|
val actualPretty = data.pointersForPrettyRendering.renderDeclarations()
|
||||||
testServices.assertions.assertEqualsToTestDataFileSibling(actualPretty, extension = ".pretty.txt")
|
testServices.assertions.assertEqualsToTestDataFileSibling(actualPretty, extension = ".pretty.txt")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun List<PointerWithRenderedSymbol>.renderDeclarations(): String =
|
||||||
|
if (isEmpty()) "NO_SYMBOLS"
|
||||||
|
else joinToString(separator = "\n\n") { it.rendered }
|
||||||
|
|
||||||
private fun restoreSymbolsInOtherReadActionAndCompareResults(
|
private fun restoreSymbolsInOtherReadActionAndCompareResults(
|
||||||
ktFile: KtFile,
|
ktFile: KtFile,
|
||||||
pointersWithRendered: List<PointerWithRenderedSymbol>,
|
pointersWithRendered: List<PointerWithRenderedSymbol>,
|
||||||
|
|||||||
+12
@@ -46,6 +46,18 @@ public class FirStandaloneNormalAnalysisSourceModuleMemberScopeByFqNameTestGener
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/scopes/memberScopeByFqName"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/scopes/memberScopeByFqName"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("emumEntryWithoutMembers.kt")
|
||||||
|
public void testEmumEntryWithoutMembers() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/scopes/memberScopeByFqName/emumEntryWithoutMembers.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enumEntry.kt")
|
||||||
|
public void testEnumEntry() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/scopes/memberScopeByFqName/enumEntry.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("Int.kt")
|
@TestMetadata("Int.kt")
|
||||||
public void testInt() throws Exception {
|
public void testInt() throws Exception {
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
enum class E {
|
||||||
|
A
|
||||||
|
}
|
||||||
|
|
||||||
|
// callable: test/E.A
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
NO_SYMBOLS
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
NO_SYMBOLS
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
enum class E {
|
||||||
|
A {
|
||||||
|
val x: String = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// callable: test/E.A
|
||||||
|
// DO_NOT_CHECK_SYMBOL_RESTORE
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
val x: kotlin.String
|
||||||
|
|
||||||
|
protected fun clone(): kotlin.Any
|
||||||
|
|
||||||
|
operator fun compareTo(other: test.E): kotlin.Int
|
||||||
|
|
||||||
|
operator fun equals(other: kotlin.Any?): kotlin.Boolean
|
||||||
|
|
||||||
|
fun hashCode(): kotlin.Int
|
||||||
|
|
||||||
|
open fun toString(): kotlin.String
|
||||||
|
|
||||||
|
@kotlin.internal.IntrinsicConstEvaluation
|
||||||
|
val name: kotlin.String
|
||||||
|
|
||||||
|
val ordinal: kotlin.Int
|
||||||
|
|
||||||
|
fun getDeclaringClass(): java.lang.Class<test.E!>!
|
||||||
|
|
||||||
|
companion object
|
||||||
|
|
||||||
|
private constructor()
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
KtKotlinPropertySymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
getter: KtPropertyGetterSymbol(<getter>)
|
||||||
|
hasBackingField: true
|
||||||
|
hasGetter: true
|
||||||
|
hasSetter: false
|
||||||
|
initializer: KtConstantInitializerValue("")
|
||||||
|
isConst: false
|
||||||
|
isDelegatedProperty: false
|
||||||
|
isExtension: false
|
||||||
|
isFromPrimaryConstructor: false
|
||||||
|
isLateInit: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isVal: true
|
||||||
|
modality: FINAL
|
||||||
|
name: x
|
||||||
|
origin: SOURCE
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/String
|
||||||
|
setter: null
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): <anonymous>
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
getterDeprecationStatus: null
|
||||||
|
javaGetterName: getX
|
||||||
|
javaSetterName: null
|
||||||
|
setterDeprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: kotlin/Enum.clone
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: clone
|
||||||
|
origin: LIBRARY
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/Any
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: []
|
||||||
|
visibility: Protected
|
||||||
|
getDispatchReceiver(): kotlin/Enum<E>
|
||||||
|
getContainingModule: KtLibraryModule "Library kotlin-stdlib"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: test/E.compareTo
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: true
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: compareTo
|
||||||
|
origin: SUBSTITUTION_OVERRIDE
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/Int
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: [
|
||||||
|
KtValueParameterSymbol(other)
|
||||||
|
]
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): test/E
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: kotlin/Enum.equals
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: true
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: equals
|
||||||
|
origin: LIBRARY
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/Boolean
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: [
|
||||||
|
KtValueParameterSymbol(other)
|
||||||
|
]
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): kotlin/Enum<E>
|
||||||
|
getContainingModule: KtLibraryModule "Library kotlin-stdlib"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: kotlin/Enum.hashCode
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: hashCode
|
||||||
|
origin: LIBRARY
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/Int
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): kotlin/Enum<E>
|
||||||
|
getContainingModule: KtLibraryModule "Library kotlin-stdlib"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: kotlin/Enum.toString
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: OPEN
|
||||||
|
name: toString
|
||||||
|
origin: LIBRARY
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/String
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): kotlin/Enum<E>
|
||||||
|
getContainingModule: KtLibraryModule "Library kotlin-stdlib"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtKotlinPropertySymbol:
|
||||||
|
annotationsList: [
|
||||||
|
kotlin/internal/IntrinsicConstEvaluation()
|
||||||
|
psi: null
|
||||||
|
]
|
||||||
|
callableIdIfNonLocal: kotlin/Enum.name
|
||||||
|
getter: KtPropertyGetterSymbol(<getter>)
|
||||||
|
hasBackingField: true
|
||||||
|
hasGetter: true
|
||||||
|
hasSetter: false
|
||||||
|
initializer: null
|
||||||
|
isConst: false
|
||||||
|
isDelegatedProperty: false
|
||||||
|
isExtension: false
|
||||||
|
isFromPrimaryConstructor: false
|
||||||
|
isLateInit: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isVal: true
|
||||||
|
modality: FINAL
|
||||||
|
name: name
|
||||||
|
origin: LIBRARY
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/String
|
||||||
|
setter: null
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): kotlin/Enum<E>
|
||||||
|
getContainingModule: KtLibraryModule "Library kotlin-stdlib"
|
||||||
|
deprecationStatus: null
|
||||||
|
getterDeprecationStatus: null
|
||||||
|
javaGetterName: getName
|
||||||
|
javaSetterName: null
|
||||||
|
setterDeprecationStatus: null
|
||||||
|
|
||||||
|
KtKotlinPropertySymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: kotlin/Enum.ordinal
|
||||||
|
getter: KtPropertyGetterSymbol(<getter>)
|
||||||
|
hasBackingField: true
|
||||||
|
hasGetter: true
|
||||||
|
hasSetter: false
|
||||||
|
initializer: null
|
||||||
|
isConst: false
|
||||||
|
isDelegatedProperty: false
|
||||||
|
isExtension: false
|
||||||
|
isFromPrimaryConstructor: false
|
||||||
|
isLateInit: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isVal: true
|
||||||
|
modality: FINAL
|
||||||
|
name: ordinal
|
||||||
|
origin: LIBRARY
|
||||||
|
receiverType: null
|
||||||
|
returnType: kotlin/Int
|
||||||
|
setter: null
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): kotlin/Enum<E>
|
||||||
|
getContainingModule: KtLibraryModule "Library kotlin-stdlib"
|
||||||
|
deprecationStatus: null
|
||||||
|
getterDeprecationStatus: null
|
||||||
|
javaGetterName: getOrdinal
|
||||||
|
javaSetterName: null
|
||||||
|
setterDeprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: test/E.getDeclaringClass
|
||||||
|
hasStableParameterNames: false
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: getDeclaringClass
|
||||||
|
origin: SUBSTITUTION_OVERRIDE
|
||||||
|
receiverType: null
|
||||||
|
returnType: ft<java/lang/Class<ft<test/E, test/E?>>, java/lang/Class<ft<test/E, test/E?>>?>
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getDispatchReceiver(): test/E
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtNamedClassOrObjectSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
classIdIfNonLocal: kotlin/Enum.Companion
|
||||||
|
classKind: COMPANION_OBJECT
|
||||||
|
companionObject: null
|
||||||
|
isData: false
|
||||||
|
isExternal: false
|
||||||
|
isFun: false
|
||||||
|
isInline: false
|
||||||
|
isInner: false
|
||||||
|
modality: FINAL
|
||||||
|
name: Companion
|
||||||
|
origin: LIBRARY
|
||||||
|
superTypes: [
|
||||||
|
kotlin/Any
|
||||||
|
]
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtLibraryModule "Library kotlin-stdlib"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtConstructorSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
containingClassIdIfNonLocal: null
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isExtension: false
|
||||||
|
isPrimary: true
|
||||||
|
origin: SOURCE_MEMBER_GENERATED
|
||||||
|
receiverType: null
|
||||||
|
returnType: <anonymous>
|
||||||
|
symbolKind: CLASS_MEMBER
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: []
|
||||||
|
visibility: Private
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
Reference in New Issue
Block a user