diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirPropertyGetterSymbol.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirPropertyGetterSymbol.kt index 0799d3db5d1..fa4531eff57 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirPropertyGetterSymbol.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirPropertyGetterSymbol.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -22,10 +22,7 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticPropertyAccessor -import org.jetbrains.kotlin.fir.declarations.utils.isInline -import org.jetbrains.kotlin.fir.declarations.utils.isOverride -import org.jetbrains.kotlin.fir.declarations.utils.modalityOrFinal -import org.jetbrains.kotlin.fir.declarations.utils.visibility +import org.jetbrains.kotlin.fir.declarations.utils.* import org.jetbrains.kotlin.fir.resolve.getHasStableParameterNames import org.jetbrains.kotlin.fir.symbols.impl.FirPropertyAccessorSymbol import org.jetbrains.kotlin.name.CallableId @@ -50,14 +47,14 @@ internal class KtFirPropertyGetterSymbol( return firSymbol.fir.propertySymbol.isOverride } - override val hasBody: Boolean get() = withValidityAssertion { firSymbol.fir.body != null } + override val hasBody: Boolean get() = withValidityAssertion { firSymbol.fir.hasBody } override val modality: Modality get() = withValidityAssertion { firSymbol.modalityOrFinal } override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility } override val returnType: KtType get() = withValidityAssertion { firSymbol.returnType(builder) } - override val receiverType: KtType? get() = withValidityAssertion { firSymbol.receiverType(builder) } + override val receiverType: KtType? get() = withValidityAssertion { firSymbol.fir.propertySymbol.receiverType(builder) } override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, firResolveSession.useSiteFirSession, token) } diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirPropertySetterSymbol.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirPropertySetterSymbol.kt index 484e4e483d9..6c026952222 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirPropertySetterSymbol.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirPropertySetterSymbol.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -22,10 +22,7 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticPropertyAccessor -import org.jetbrains.kotlin.fir.declarations.utils.isInline -import org.jetbrains.kotlin.fir.declarations.utils.isOverride -import org.jetbrains.kotlin.fir.declarations.utils.modalityOrFinal -import org.jetbrains.kotlin.fir.declarations.utils.visibility +import org.jetbrains.kotlin.fir.declarations.utils.* import org.jetbrains.kotlin.fir.resolve.getHasStableParameterNames import org.jetbrains.kotlin.fir.resolve.scope import org.jetbrains.kotlin.fir.scopes.FakeOverrideTypeCalculator @@ -63,7 +60,7 @@ internal class KtFirPropertySetterSymbol( overriddenProperties.any { it.isVar } } - override val hasBody: Boolean get() = withValidityAssertion { firSymbol.fir.body != null } + override val hasBody: Boolean get() = withValidityAssertion { firSymbol.fir.hasBody } override val modality: Modality get() = withValidityAssertion { firSymbol.modalityOrFinal } override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility } @@ -94,7 +91,7 @@ internal class KtFirPropertySetterSymbol( override val valueParameters: List by cached { listOf(parameter) } override val returnType: KtType get() = withValidityAssertion { firSymbol.returnType(builder) } - override val receiverType: KtType? get() = withValidityAssertion { firSymbol.receiverType(builder) } + override val receiverType: KtType? get() = withValidityAssertion { firSymbol.fir.propertySymbol.receiverType(builder) } override val hasStableParameterNames: Boolean diff --git a/analysis/analysis-api/testData/scopes/fileScopeTest/fileScope.txt b/analysis/analysis-api/testData/scopes/fileScopeTest/fileScope.txt index f904277829e..a4beb23b4d4 100644 --- a/analysis/analysis-api/testData/scopes/fileScopeTest/fileScope.txt +++ b/analysis/analysis-api/testData/scopes/fileScopeTest/fileScope.txt @@ -872,7 +872,7 @@ KtKotlinPropertySymbol: isOverride: false modality: FINAL origin: SOURCE - receiverType: null + receiverType: kotlin/Int returnType: kotlin/Int symbolKind: ACCESSOR typeParameters: [] @@ -922,7 +922,7 @@ KtKotlinPropertySymbol: isOverride: false modality: FINAL origin: SOURCE - receiverType: null + receiverType: T returnType: kotlin/Int symbolKind: ACCESSOR typeParameters: [] diff --git a/analysis/analysis-api/testData/symbols/symbolByPsi/memberProperties.txt b/analysis/analysis-api/testData/symbols/symbolByPsi/memberProperties.txt index ffa5ac28922..f225ff77afe 100644 --- a/analysis/analysis-api/testData/symbols/symbolByPsi/memberProperties.txt +++ b/analysis/analysis-api/testData/symbols/symbolByPsi/memberProperties.txt @@ -61,7 +61,7 @@ KtPropertyGetterSymbol: isOverride: false modality: FINAL origin: SOURCE - receiverType: null + receiverType: kotlin/Int returnType: kotlin/Int symbolKind: ACCESSOR typeParameters: [] @@ -86,7 +86,7 @@ KtKotlinPropertySymbol: isOverride: false modality: FINAL origin: SOURCE - receiverType: null + receiverType: kotlin/Int returnType: kotlin/Int symbolKind: ACCESSOR typeParameters: [] diff --git a/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.descriptors.txt b/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.descriptors.txt deleted file mode 100644 index 0073368aba9..00000000000 --- a/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.descriptors.txt +++ /dev/null @@ -1,120 +0,0 @@ -KtKotlinPropertySymbol: - annotationsList: [] - callableIdIfNonLocal: /x - contextReceivers: [] - getter: KtPropertyGetterSymbol: - annotationsList: [] - callableIdIfNonLocal: null - contextReceivers: [] - hasBody: false - hasStableParameterNames: true - isDefault: true - isExtension: false - isInline: false - isOverride: false - modality: FINAL - origin: SOURCE - receiverType: null - returnType: kotlin/Int - symbolKind: ACCESSOR - typeParameters: [] - valueParameters: [] - visibility: Public - hasBackingField: true - hasGetter: true - hasSetter: false - initializer: KtConstantInitializerValue(10) - 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/Int - setter: null - symbolKind: TOP_LEVEL - typeParameters: [] - visibility: Public - getContainingModule: KtSourceModule "Sources of main" - deprecationStatus: null - getterDeprecationStatus: null - javaGetterName: getX - javaSetterName: null - setterDeprecationStatus: null - -KtPropertyGetterSymbol: - annotationsList: [] - callableIdIfNonLocal: null - contextReceivers: [] - hasBody: true - hasStableParameterNames: true - isDefault: false - isExtension: false - isInline: false - isOverride: false - modality: FINAL - origin: SOURCE - receiverType: kotlin/Int - returnType: kotlin/Int - symbolKind: ACCESSOR - typeParameters: [] - valueParameters: [] - visibility: Public - getContainingModule: KtSourceModule "Sources of main" - deprecationStatus: null - -KtKotlinPropertySymbol: - annotationsList: [] - callableIdIfNonLocal: /y - contextReceivers: [] - getter: KtPropertyGetterSymbol: - annotationsList: [] - callableIdIfNonLocal: null - contextReceivers: [] - hasBody: true - hasStableParameterNames: true - isDefault: false - isExtension: false - isInline: false - isOverride: false - modality: FINAL - origin: SOURCE - receiverType: kotlin/Int - returnType: kotlin/Int - symbolKind: ACCESSOR - typeParameters: [] - valueParameters: [] - visibility: Public - hasBackingField: false - hasGetter: true - hasSetter: false - initializer: null - isConst: false - isDelegatedProperty: false - isExtension: true - isFromPrimaryConstructor: false - isLateInit: false - isOverride: false - isStatic: false - isVal: true - modality: FINAL - name: y - origin: SOURCE - receiverType: kotlin/Int - returnType: kotlin/Int - setter: null - symbolKind: TOP_LEVEL - typeParameters: [] - visibility: Public - getContainingModule: KtSourceModule "Sources of main" - deprecationStatus: null - getterDeprecationStatus: null - javaGetterName: getY - javaSetterName: null - setterDeprecationStatus: null \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.kt b/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.kt index 8556f4d96d2..6d54dc599d9 100644 --- a/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.kt +++ b/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.kt @@ -1,2 +1,6 @@ val x: Int = 10 val Int.y get() = this + +var Short.get: Long + get() = 2 + set(value) {} \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.pretty.txt b/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.pretty.txt index cdd1c9b1caf..762e730eee4 100644 --- a/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.pretty.txt +++ b/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.pretty.txt @@ -1,3 +1,5 @@ val x: kotlin.Int -val kotlin.Int.y: kotlin.Int \ No newline at end of file +val kotlin.Int.y: kotlin.Int + +var kotlin.Short.get: kotlin.Long \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.txt b/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.txt index 340b9b419eb..25c42913153 100644 --- a/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.txt +++ b/analysis/analysis-api/testData/symbols/symbolByPsi/topLevelProperties.txt @@ -60,7 +60,7 @@ KtPropertyGetterSymbol: isOverride: false modality: FINAL origin: SOURCE - receiverType: null + receiverType: kotlin/Int returnType: kotlin/Int symbolKind: ACCESSOR typeParameters: [] @@ -85,7 +85,7 @@ KtKotlinPropertySymbol: isOverride: false modality: FINAL origin: SOURCE - receiverType: null + receiverType: kotlin/Int returnType: kotlin/Int symbolKind: ACCESSOR typeParameters: [] @@ -117,4 +117,203 @@ KtKotlinPropertySymbol: getterDeprecationStatus: null javaGetterName: getY javaSetterName: null + setterDeprecationStatus: null + +KtPropertyGetterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + hasBody: true + hasStableParameterNames: true + isDefault: false + isExtension: false + isInline: false + isOverride: false + modality: FINAL + origin: SOURCE + receiverType: kotlin/Short + returnType: kotlin/Long + symbolKind: ACCESSOR + typeParameters: [] + valueParameters: [] + visibility: Public + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null + +KtValueParameterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + generatedPrimaryConstructorProperty: null + hasDefaultValue: false + isCrossinline: false + isExtension: false + isImplicitLambdaParameter: false + isNoinline: false + isVararg: false + name: value + origin: SOURCE + receiverType: null + returnType: kotlin/Long + symbolKind: LOCAL + typeParameters: [] + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null + +KtPropertySetterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + hasBody: true + hasStableParameterNames: true + isDefault: false + isExtension: false + isInline: false + isOverride: false + modality: FINAL + origin: SOURCE + parameter: KtValueParameterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + generatedPrimaryConstructorProperty: null + hasDefaultValue: false + isCrossinline: false + isExtension: false + isImplicitLambdaParameter: false + isNoinline: false + isVararg: false + name: value + origin: SOURCE + receiverType: null + returnType: kotlin/Long + symbolKind: LOCAL + typeParameters: [] + receiverType: kotlin/Short + returnType: kotlin/Unit + symbolKind: ACCESSOR + typeParameters: [] + valueParameters: [ + KtValueParameterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + generatedPrimaryConstructorProperty: null + hasDefaultValue: false + isCrossinline: false + isExtension: false + isImplicitLambdaParameter: false + isNoinline: false + isVararg: false + name: value + origin: SOURCE + receiverType: null + returnType: kotlin/Long + symbolKind: LOCAL + typeParameters: [] + ] + visibility: Public + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null + +KtKotlinPropertySymbol: + annotationsList: [] + callableIdIfNonLocal: /get + contextReceivers: [] + getter: KtPropertyGetterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + hasBody: true + hasStableParameterNames: true + isDefault: false + isExtension: false + isInline: false + isOverride: false + modality: FINAL + origin: SOURCE + receiverType: kotlin/Short + returnType: kotlin/Long + symbolKind: ACCESSOR + typeParameters: [] + valueParameters: [] + visibility: Public + hasBackingField: false + hasGetter: true + hasSetter: true + initializer: null + isConst: false + isDelegatedProperty: false + isExtension: true + isFromPrimaryConstructor: false + isLateInit: false + isOverride: false + isStatic: false + isVal: false + modality: FINAL + name: get + origin: SOURCE + receiverType: kotlin/Short + returnType: kotlin/Long + setter: KtPropertySetterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + hasBody: true + hasStableParameterNames: true + isDefault: false + isExtension: false + isInline: false + isOverride: false + modality: FINAL + origin: SOURCE + parameter: KtValueParameterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + generatedPrimaryConstructorProperty: null + hasDefaultValue: false + isCrossinline: false + isExtension: false + isImplicitLambdaParameter: false + isNoinline: false + isVararg: false + name: value + origin: SOURCE + receiverType: null + returnType: kotlin/Long + symbolKind: LOCAL + typeParameters: [] + receiverType: kotlin/Short + returnType: kotlin/Unit + symbolKind: ACCESSOR + typeParameters: [] + valueParameters: [ + KtValueParameterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + generatedPrimaryConstructorProperty: null + hasDefaultValue: false + isCrossinline: false + isExtension: false + isImplicitLambdaParameter: false + isNoinline: false + isVararg: false + name: value + origin: SOURCE + receiverType: null + returnType: kotlin/Long + symbolKind: LOCAL + typeParameters: [] + ] + visibility: Public + symbolKind: TOP_LEVEL + typeParameters: [] + visibility: Public + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null + getterDeprecationStatus: null + javaGetterName: getGet + javaSetterName: setGet setterDeprecationStatus: null \ No newline at end of file