From 06950f57db3e376ad47350b070420ee94480ea40 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridin Date: Wed, 27 Dec 2023 17:50:23 +0100 Subject: [PATCH] [Analysis API] add tests for delegate field ^KT-64584 --- ...oduleDelegateMemberScopeTestGenerated.java | 6 + ...oduleDeclaredMemberScopeTestGenerated.java | 12 + ...oduleDelegateMemberScopeTestGenerated.java | 6 + ...oduleDeclaredMemberScopeTestGenerated.java | 12 + ...oduleDelegateMemberScopeTestGenerated.java | 6 + .../declaredMemberScope/delegateInterface.kt | 13 + .../delegateInterface.pretty.txt | 3 + .../declaredMemberScope/delegateInterface.txt | 229 ++++++++++++++++++ .../delegateInterfaceLibrary.kt | 16 ++ .../delegateInterfaceLibrary.pretty.txt | 3 + .../delegateInterfaceLibrary.txt | 140 +++++++++++ .../delegatedMemberScope/simpleLibrary.kt | 16 ++ .../simpleLibrary.pretty.txt | 1 + .../delegatedMemberScope/simpleLibrary.txt | 1 + .../wholeDeclaration/delegate.kt | 12 + .../wholeDeclaration/delegate.txt | 50 ++++ .../testData/getOrBuildFirBinary/delegate.kt | 11 + .../testData/getOrBuildFirBinary/delegate.txt | 16 ++ .../fir/AbstractLibraryGetOrBuildFirTest.kt | 4 +- .../LibraryGetOrBuildFirTestGenerated.java | 6 + ...ContentRootGetOrBuildFirTestGenerated.java | 6 + .../fir/SourceGetOrBuildFirTestGenerated.java | 6 + 22 files changed, 573 insertions(+), 2 deletions(-) create mode 100644 analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.kt create mode 100644 analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.pretty.txt create mode 100644 analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.txt create mode 100644 analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.kt create mode 100644 analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.pretty.txt create mode 100644 analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.txt create mode 100644 analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.kt create mode 100644 analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.pretty.txt create mode 100644 analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.txt create mode 100644 analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/delegate.kt create mode 100644 analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/delegate.txt create mode 100644 analysis/low-level-api-fir/testData/getOrBuildFirBinary/delegate.kt create mode 100644 analysis/low-level-api-fir/testData/getOrBuildFirBinary/delegate.txt diff --git a/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/components/scopeProvider/Fe10IdeNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java b/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/components/scopeProvider/Fe10IdeNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java index dde89ebd99e..e8d46e3d2af 100644 --- a/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/components/scopeProvider/Fe10IdeNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java +++ b/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/components/scopeProvider/Fe10IdeNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java @@ -58,6 +58,12 @@ public class Fe10IdeNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated e runTest("analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simple.kt"); } + @Test + @TestMetadata("simpleLibrary.kt") + public void testSimpleLibrary() throws Exception { + runTest("analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.kt"); + } + @Test @TestMetadata("withImplicitType.kt") public void testWithImplicitType() throws Exception { diff --git a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/scopeProvider/FirIdeNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.java b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/scopeProvider/FirIdeNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.java index c78a75435ac..74db70b15be 100644 --- a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/scopeProvider/FirIdeNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.java +++ b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/scopeProvider/FirIdeNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.java @@ -52,6 +52,18 @@ public class FirIdeNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated ex runTest("analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/class.kt"); } + @Test + @TestMetadata("delegateInterface.kt") + public void testDelegateInterface() throws Exception { + runTest("analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.kt"); + } + + @Test + @TestMetadata("delegateInterfaceLibrary.kt") + public void testDelegateInterfaceLibrary() throws Exception { + runTest("analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.kt"); + } + @Test @TestMetadata("enumClass.kt") public void testEnumClass() throws Exception { diff --git a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/scopeProvider/FirIdeNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/scopeProvider/FirIdeNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java index aa212af216c..d5440add697 100644 --- a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/scopeProvider/FirIdeNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java +++ b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/scopeProvider/FirIdeNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java @@ -58,6 +58,12 @@ public class FirIdeNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated ex runTest("analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simple.kt"); } + @Test + @TestMetadata("simpleLibrary.kt") + public void testSimpleLibrary() throws Exception { + runTest("analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.kt"); + } + @Test @TestMetadata("withImplicitType.kt") public void testWithImplicitType() throws Exception { diff --git a/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/scopeProvider/FirStandaloneNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.java b/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/scopeProvider/FirStandaloneNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.java index 753b8fc6319..5a11ac2b0ef 100644 --- a/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/scopeProvider/FirStandaloneNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.java +++ b/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/scopeProvider/FirStandaloneNormalAnalysisSourceModuleDeclaredMemberScopeTestGenerated.java @@ -52,6 +52,18 @@ public class FirStandaloneNormalAnalysisSourceModuleDeclaredMemberScopeTestGener runTest("analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/class.kt"); } + @Test + @TestMetadata("delegateInterface.kt") + public void testDelegateInterface() throws Exception { + runTest("analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.kt"); + } + + @Test + @TestMetadata("delegateInterfaceLibrary.kt") + public void testDelegateInterfaceLibrary() throws Exception { + runTest("analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.kt"); + } + @Test @TestMetadata("enumClass.kt") public void testEnumClass() throws Exception { diff --git a/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/scopeProvider/FirStandaloneNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java b/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/scopeProvider/FirStandaloneNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java index 252f27563fa..63974009205 100644 --- a/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/scopeProvider/FirStandaloneNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java +++ b/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/scopeProvider/FirStandaloneNormalAnalysisSourceModuleDelegateMemberScopeTestGenerated.java @@ -58,6 +58,12 @@ public class FirStandaloneNormalAnalysisSourceModuleDelegateMemberScopeTestGener runTest("analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simple.kt"); } + @Test + @TestMetadata("simpleLibrary.kt") + public void testSimpleLibrary() throws Exception { + runTest("analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.kt"); + } + @Test @TestMetadata("withImplicitType.kt") public void testWithImplicitType() throws Exception { diff --git a/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.kt b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.kt new file mode 100644 index 00000000000..4c56b08d112 --- /dev/null +++ b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.kt @@ -0,0 +1,13 @@ +// FILE: A.kt +interface A { + var Int.zoo: Unit + fun foo() + fun Int.smth(): Short + val foo: Int + var bar: Long + val Int.doo: String +} +® +class I(private val p: A) : A by p + +// class: I diff --git a/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.pretty.txt b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.pretty.txt new file mode 100644 index 00000000000..8791781bd9a --- /dev/null +++ b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.pretty.txt @@ -0,0 +1,3 @@ +private val p: A + +constructor(p: A) \ No newline at end of file diff --git a/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.txt b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.txt new file mode 100644 index 00000000000..26322f9fbcf --- /dev/null +++ b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterface.txt @@ -0,0 +1,229 @@ +KtKotlinPropertySymbol: + annotationsList: [] + backingFieldSymbol: KtBackingFieldSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + isExtension: false + name: field + origin: PROPERTY_BACKING_FIELD + owningProperty: KtKotlinPropertySymbol(/I.p) + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: A + symbolKind: LOCAL + typeParameters: [] + getContainingFileSymbol: KtFileSymbol(A.kt) + getContainingJvmClassName: I + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null + callableIdIfNonLocal: /I.p + contextReceivers: [] + getter: KtPropertyGetterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + hasBody: false + hasStableParameterNames: true + isDefault: true + isExtension: false + isInline: false + isOverride: false + modality: FINAL + origin: SOURCE + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: A + symbolKind: ACCESSOR + typeParameters: [] + valueParameters: [] + visibility: Private + getDispatchReceiver(): KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: I + getContainingFileSymbol: KtFileSymbol(A.kt) + getContainingJvmClassName: I + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null + hasBackingField: true + hasGetter: true + hasSetter: false + initializer: KtNonConstantInitializerValue(private val p: A) + isActual: false + isConst: false + isDelegatedProperty: false + isExpect: false + isExtension: false + isFromPrimaryConstructor: true + isLateInit: false + isOverride: false + isStatic: false + isVal: true + modality: FINAL + name: p + origin: SOURCE + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: A + setter: null + symbolKind: CLASS_MEMBER + typeParameters: [] + visibility: Private + getDispatchReceiver(): KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: I + getContainingFileSymbol: KtFileSymbol(A.kt) + getContainingJvmClassName: I + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null + getterDeprecationStatus: null + javaGetterName: getP + javaSetterName: null + setterDeprecationStatus: null + +KtConstructorSymbol: + annotationsList: [] + callableIdIfNonLocal: null + containingClassIdIfNonLocal: I + contextReceivers: [] + hasStableParameterNames: true + isActual: false + isExpect: false + isExtension: false + isPrimary: true + origin: SOURCE + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: I + symbolKind: CLASS_MEMBER + typeParameters: [] + valueParameters: [ + KtValueParameterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + generatedPrimaryConstructorProperty: KtKotlinPropertySymbol: + annotationsList: [] + backingFieldSymbol: KtBackingFieldSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + isExtension: false + name: field + origin: PROPERTY_BACKING_FIELD + owningProperty: KtKotlinPropertySymbol(/I.p) + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: A + symbolKind: LOCAL + typeParameters: [] + getContainingFileSymbol: KtFileSymbol(A.kt) + getContainingJvmClassName: I + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null + callableIdIfNonLocal: /I.p + contextReceivers: [] + getter: KtPropertyGetterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + hasBody: false + hasStableParameterNames: true + isDefault: true + isExtension: false + isInline: false + isOverride: false + modality: FINAL + origin: SOURCE + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: A + symbolKind: ACCESSOR + typeParameters: [] + valueParameters: [] + visibility: Private + getDispatchReceiver(): KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: I + getContainingFileSymbol: KtFileSymbol(A.kt) + getContainingJvmClassName: I + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null + hasBackingField: true + hasGetter: true + hasSetter: false + initializer: KtNonConstantInitializerValue(private val p: A) + isActual: false + isConst: false + isDelegatedProperty: false + isExpect: false + isExtension: false + isFromPrimaryConstructor: true + isLateInit: false + isOverride: false + isStatic: false + isVal: true + modality: FINAL + name: p + origin: SOURCE + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: A + setter: null + symbolKind: CLASS_MEMBER + typeParameters: [] + visibility: Private + getDispatchReceiver(): KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: I + getContainingFileSymbol: KtFileSymbol(A.kt) + getContainingJvmClassName: I + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null + getterDeprecationStatus: null + javaGetterName: getP + javaSetterName: null + setterDeprecationStatus: null + hasDefaultValue: false + isCrossinline: false + isExtension: false + isImplicitLambdaParameter: false + isNoinline: false + isVararg: false + name: p + origin: SOURCE + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: A + symbolKind: LOCAL + typeParameters: [] + getContainingFileSymbol: KtFileSymbol(A.kt) + getContainingJvmClassName: I + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null + ] + visibility: Public + getContainingFileSymbol: KtFileSymbol(A.kt) + getContainingJvmClassName: I + getContainingModule: KtSourceModule "Sources of main" + deprecationStatus: null \ No newline at end of file diff --git a/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.kt b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.kt new file mode 100644 index 00000000000..f858e71491b --- /dev/null +++ b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.kt @@ -0,0 +1,16 @@ +// MODULE: main +// MODULE_KIND: LibraryBinary +// FILE: A.kt +interface A { + var Int.zoo: Unit + fun foo() + fun Int.smth(): Short + val foo: Int + var bar: Long + val Int.doo: String +} + +class I(private val p: A) : A by p + +// class: I + diff --git a/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.pretty.txt b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.pretty.txt new file mode 100644 index 00000000000..b0771732344 --- /dev/null +++ b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.pretty.txt @@ -0,0 +1,3 @@ +private val p: A + +constructor(p: A) diff --git a/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.txt b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.txt new file mode 100644 index 00000000000..2eb42107769 --- /dev/null +++ b/analysis/analysis-api/testData/components/scopeProvider/declaredMemberScope/delegateInterfaceLibrary.txt @@ -0,0 +1,140 @@ +KtKotlinPropertySymbol: + annotationsList: [] + backingFieldSymbol: KtBackingFieldSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + isExtension: false + name: field + origin: PROPERTY_BACKING_FIELD + owningProperty: KtKotlinPropertySymbol(/I.p) + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: A + symbolKind: LOCAL + typeParameters: [] + getContainingFileSymbol: KtFileSymbol(I.class) + getContainingJvmClassName: I + getContainingModule: KtLibraryModule "Library main" + deprecationStatus: null + callableIdIfNonLocal: /I.p + contextReceivers: [] + getter: KtPropertyGetterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + hasBody: false + hasStableParameterNames: true + isDefault: true + isExtension: false + isInline: false + isOverride: false + modality: FINAL + origin: SOURCE + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: A + symbolKind: ACCESSOR + typeParameters: [] + valueParameters: [] + visibility: Private + getDispatchReceiver(): KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: I + getContainingFileSymbol: KtFileSymbol(I.class) + getContainingJvmClassName: I + getContainingModule: KtLibraryModule "Library main" + deprecationStatus: null + hasBackingField: true + hasGetter: true + hasSetter: false + initializer: null + isActual: false + isConst: false + isDelegatedProperty: false + isExpect: false + isExtension: false + isFromPrimaryConstructor: false + isLateInit: false + isOverride: false + isStatic: false + isVal: true + modality: FINAL + name: p + origin: SOURCE + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: A + setter: null + symbolKind: CLASS_MEMBER + typeParameters: [] + visibility: Private + getDispatchReceiver(): KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: I + getContainingFileSymbol: KtFileSymbol(I.class) + getContainingJvmClassName: I + getContainingModule: KtLibraryModule "Library main" + deprecationStatus: null + getterDeprecationStatus: null + javaGetterName: getP + javaSetterName: null + setterDeprecationStatus: null + +KtConstructorSymbol: + annotationsList: [] + callableIdIfNonLocal: null + containingClassIdIfNonLocal: I + contextReceivers: [] + hasStableParameterNames: true + isActual: false + isExpect: false + isExtension: false + isPrimary: true + origin: SOURCE + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: I + symbolKind: CLASS_MEMBER + typeParameters: [] + valueParameters: [ + KtValueParameterSymbol: + annotationsList: [] + callableIdIfNonLocal: null + contextReceivers: [] + generatedPrimaryConstructorProperty: null + hasDefaultValue: false + isCrossinline: false + isExtension: false + isImplicitLambdaParameter: false + isNoinline: false + isVararg: false + name: p + origin: SOURCE + receiverParameter: null + returnType: KtUsualClassType: + annotationsList: [] + ownTypeArguments: [] + type: A + symbolKind: LOCAL + typeParameters: [] + getContainingFileSymbol: KtFileSymbol(I.class) + getContainingJvmClassName: I + getContainingModule: KtLibraryModule "Library main" + deprecationStatus: null + ] + visibility: Public + getContainingFileSymbol: KtFileSymbol(I.class) + getContainingJvmClassName: I + getContainingModule: KtLibraryModule "Library main" + deprecationStatus: null diff --git a/analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.kt b/analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.kt new file mode 100644 index 00000000000..37bf07fde7b --- /dev/null +++ b/analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.kt @@ -0,0 +1,16 @@ +// IGNORE_FE10 +// MODULE: main +// MODULE_KIND: LibraryBinary +// FILE: A.kt +interface A { + var Int.zoo: Unit + fun foo() + fun Int.smth(): Short + val foo: Int + var bar: Long + val Int.doo: String +} + +class I(private val p: A) : A by p + +// class: I diff --git a/analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.pretty.txt b/analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.pretty.txt new file mode 100644 index 00000000000..e71fee3bda8 --- /dev/null +++ b/analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.pretty.txt @@ -0,0 +1 @@ +NO_SYMBOLS diff --git a/analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.txt b/analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.txt new file mode 100644 index 00000000000..e71fee3bda8 --- /dev/null +++ b/analysis/analysis-api/testData/components/scopeProvider/delegatedMemberScope/simpleLibrary.txt @@ -0,0 +1 @@ +NO_SYMBOLS diff --git a/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/delegate.kt b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/delegate.kt new file mode 100644 index 00000000000..97799477796 --- /dev/null +++ b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/delegate.kt @@ -0,0 +1,12 @@ + +class I(private val p: A) : A by p + + +interface A { + var Int.zoo: Unit + fun foo() + fun Int.smth(): Short + val foo: Int + var bar: Long + val Int.doo: String +} diff --git a/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/delegate.txt b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/delegate.txt new file mode 100644 index 00000000000..2190caa7815 --- /dev/null +++ b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/delegate.txt @@ -0,0 +1,50 @@ +KT element: KtClass +FIR element: FirRegularClassImpl +FIR source kind: KtRealSourceElementKind + +FIR element rendered: +public final [ResolvedTo(BODY_RESOLVE)] [DelegateFieldsMapKey={0=FirFieldSymbol /I.$$delegate_0}] class I : R|A| { + public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=I] constructor([ResolvedTo(BODY_RESOLVE)] [CorrespondingProperty=/I.p] p: R|A|): R|I| { + super() + } + + private final [ResolvedTo(BODY_RESOLVE)] field $$delegate_0: R|A| = R|/p| + + private final [ResolvedTo(BODY_RESOLVE)] [IsFromPrimaryConstructor=true] val p: R|A| = R|/p| + private [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=I] get(): R|A| + +} + +FIR FILE: +FILE: [ResolvedTo(IMPORTS)] delegate.kt + public final [ResolvedTo(BODY_RESOLVE)] [DelegateFieldsMapKey={0=FirFieldSymbol /I.$$delegate_0}] class I : R|A| { + public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=I] constructor([ResolvedTo(BODY_RESOLVE)] [CorrespondingProperty=/I.p] p: R|A|): R|I| { + super() + } + + private final [ResolvedTo(BODY_RESOLVE)] field $$delegate_0: R|A| = R|/p| + + private final [ResolvedTo(BODY_RESOLVE)] [IsFromPrimaryConstructor=true] val p: R|A| = R|/p| + private [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=I] get(): R|A| + + } + public abstract [ResolvedTo(STATUS)] interface A : R|kotlin/Any| { + public abstract [ResolvedTo(STATUS)] var R|kotlin/Int|.zoo: R|kotlin/Unit| + public [ResolvedTo(STATUS)] [ContainingClassKey=A] get(): R|kotlin/Unit| + public [ResolvedTo(STATUS)] [ContainingClassKey=A] set([ResolvedTo(STATUS)] value: R|kotlin/Unit|): R|kotlin/Unit| + + public abstract [ResolvedTo(STATUS)] fun foo(): R|kotlin/Unit| + + public abstract [ResolvedTo(STATUS)] fun R|kotlin/Int|.smth(): R|kotlin/Short| + + public abstract [ResolvedTo(STATUS)] val foo: R|kotlin/Int| + public [ResolvedTo(STATUS)] [ContainingClassKey=A] get(): R|kotlin/Int| + + public abstract [ResolvedTo(STATUS)] var bar: R|kotlin/Long| + public [ResolvedTo(STATUS)] [ContainingClassKey=A] get(): R|kotlin/Long| + public [ResolvedTo(STATUS)] [ContainingClassKey=A] set([ResolvedTo(STATUS)] value: R|kotlin/Long|): R|kotlin/Unit| + + public abstract [ResolvedTo(STATUS)] val R|kotlin/Int|.doo: R|kotlin/String| + public [ResolvedTo(STATUS)] [ContainingClassKey=A] get(): R|kotlin/String| + + } \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/getOrBuildFirBinary/delegate.kt b/analysis/low-level-api-fir/testData/getOrBuildFirBinary/delegate.kt new file mode 100644 index 00000000000..744ce3b245b --- /dev/null +++ b/analysis/low-level-api-fir/testData/getOrBuildFirBinary/delegate.kt @@ -0,0 +1,11 @@ +// DECLARATION_TYPE: org.jetbrains.kotlin.psi.KtClass +class I(private val p: A) : A by p + +interface A { + var Int.zoo: Unit + fun foo() + fun Int.smth(): Short + val foo: Int + var bar: Long + val Int.doo: String +} diff --git a/analysis/low-level-api-fir/testData/getOrBuildFirBinary/delegate.txt b/analysis/low-level-api-fir/testData/getOrBuildFirBinary/delegate.txt new file mode 100644 index 00000000000..58eac69e467 --- /dev/null +++ b/analysis/low-level-api-fir/testData/getOrBuildFirBinary/delegate.txt @@ -0,0 +1,16 @@ +KT element: KtClass +KT element text: +public final class I public constructor(p: A) : A { + private final val p: A /* compiled code */ +} +FIR element: FirRegularClassImpl +FIR source kind: KtRealSourceElementKind + +FIR element rendered: +public final [ResolvedTo(BODY_RESOLVE)] class I : R|A| { + private final [ResolvedTo(BODY_RESOLVE)] val p: R|A| + + + public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=I] constructor([ResolvedTo(BODY_RESOLVE)] p: R|A|): R|I| + +} \ No newline at end of file diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/AbstractLibraryGetOrBuildFirTest.kt b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/AbstractLibraryGetOrBuildFirTest.kt index fb1f3a174cf..905b1a9303c 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/AbstractLibraryGetOrBuildFirTest.kt +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/AbstractLibraryGetOrBuildFirTest.kt @@ -6,7 +6,7 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiSingleFileTest +import org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiLastModuleFirstFileTest import org.jetbrains.kotlin.analysis.low.level.api.fir.test.configurators.AnalysisApiFirLibraryBinaryTestConfigurator import org.jetbrains.kotlin.analysis.low.level.api.fir.util.FirDeclarationForCompiledElementSearcher import org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.service -abstract class AbstractLibraryGetOrBuildFirTest : AbstractLowLevelApiSingleFileTest() { +abstract class AbstractLibraryGetOrBuildFirTest : AbstractLowLevelApiLastModuleFirstFileTest() { override val configurator = AnalysisApiFirLibraryBinaryTestConfigurator override fun configureTest(builder: TestConfigurationBuilder) { builder.forTestsMatching("analysis/low-level-api-fir/testData/getOrBuildFirBinary/js/*") { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/LibraryGetOrBuildFirTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/LibraryGetOrBuildFirTestGenerated.java index b8801be96ba..6ce2553c192 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/LibraryGetOrBuildFirTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/LibraryGetOrBuildFirTestGenerated.java @@ -24,6 +24,12 @@ public class LibraryGetOrBuildFirTestGenerated extends AbstractLibraryGetOrBuild KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testData/getOrBuildFirBinary"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @Test + @TestMetadata("delegate.kt") + public void testDelegate() throws Exception { + runTest("analysis/low-level-api-fir/testData/getOrBuildFirBinary/delegate.kt"); + } + @Test @TestMetadata("enumEntry.kt") public void testEnumEntry() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java index 83c3578ba1c..71f128801b3 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java @@ -1247,6 +1247,12 @@ public class OutOfContentRootGetOrBuildFirTestGenerated extends AbstractOutOfCon runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/classTypeParemeter.kt"); } + @Test + @TestMetadata("delegate.kt") + public void testDelegate() throws Exception { + runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/delegate.kt"); + } + @Test @TestMetadata("enum.kt") public void testEnum() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java index 6eba19ef141..b833a5ea56b 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java @@ -1247,6 +1247,12 @@ public class SourceGetOrBuildFirTestGenerated extends AbstractSourceGetOrBuildFi runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/classTypeParemeter.kt"); } + @Test + @TestMetadata("delegate.kt") + public void testDelegate() throws Exception { + runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/delegate.kt"); + } + @Test @TestMetadata("enum.kt") public void testEnum() throws Exception {