diff --git a/analysis/analysis-api-fe10/tests/org/jetbrains/kotlin/analysis/api/descriptors/test/symbols/KtFe10SymbolByReferenceTestGenerated.java b/analysis/analysis-api-fe10/tests/org/jetbrains/kotlin/analysis/api/descriptors/test/symbols/KtFe10SymbolByReferenceTestGenerated.java index 113e118bfbe..2ee8ff7b66c 100644 --- a/analysis/analysis-api-fe10/tests/org/jetbrains/kotlin/analysis/api/descriptors/test/symbols/KtFe10SymbolByReferenceTestGenerated.java +++ b/analysis/analysis-api-fe10/tests/org/jetbrains/kotlin/analysis/api/descriptors/test/symbols/KtFe10SymbolByReferenceTestGenerated.java @@ -36,6 +36,18 @@ public class KtFe10SymbolByReferenceTestGenerated extends AbstractKtFe10SymbolBy runTest("analysis/analysis-api/testData/symbols/symbolByReference/constructorViaTypeAlias.kt"); } + @Test + @TestMetadata("genericFromFunctionInLocalClass.kt") + public void testGenericFromFunctionInLocalClass() throws Exception { + runTest("analysis/analysis-api/testData/symbols/symbolByReference/genericFromFunctionInLocalClass.kt"); + } + + @Test + @TestMetadata("genericFromOuterClassInInnerClass.kt") + public void testGenericFromOuterClassInInnerClass() throws Exception { + runTest("analysis/analysis-api/testData/symbols/symbolByReference/genericFromOuterClassInInnerClass.kt"); + } + @Test @TestMetadata("samConstructor.kt") public void testSamConstructor() throws Exception { diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt index 62ffe108c85..8795daee3e6 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/KtSymbolByFirBuilder.kt @@ -23,20 +23,22 @@ import org.jetbrains.kotlin.builtins.functions.FunctionClassKind import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.impl.FirFieldImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirOuterClassTypeParameterRef import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty import org.jetbrains.kotlin.fir.java.declarations.FirJavaField +import org.jetbrains.kotlin.fir.resolve.getContainingClass import org.jetbrains.kotlin.fir.resolve.getSymbolByLookupTag import org.jetbrains.kotlin.fir.resolve.originalConstructorIfTypeAlias import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor +import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutorByMap import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl -import org.jetbrains.kotlin.analysis.api.fir.symbols.KtFirClassInitializerSymbol -import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutorByMap +import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.types.Variance @@ -206,6 +208,10 @@ internal class KtSymbolByFirBuilder private constructor( } fun buildFunctionSymbol(fir: FirSimpleFunction): KtFirFunctionSymbol { + fir.unwrapSubstitutionOverrideIfNeeded()?.let { + return buildFunctionSymbol(it) + } + check(fir.origin != FirDeclarationOrigin.SamConstructor) return symbolsCache.cache(fir) { KtFirFunctionSymbol(fir, resolveState, token, this@KtSymbolByFirBuilder) } } @@ -258,9 +264,14 @@ internal class KtSymbolByFirBuilder private constructor( } } - fun buildPropertySymbol(fir: FirProperty): KtKotlinPropertySymbol { + fun buildPropertySymbol(fir: FirProperty): KtVariableSymbol { checkRequirementForBuildingSymbol(fir, !fir.isLocal) checkRequirementForBuildingSymbol(fir, fir !is FirSyntheticProperty) + + fir.unwrapSubstitutionOverrideIfNeeded()?.let { + return buildVariableSymbol(it) + } + return symbolsCache.cache(fir) { KtFirKotlinPropertySymbol(fir, resolveState, token, this@KtSymbolByFirBuilder) } @@ -406,6 +417,44 @@ internal class KtSymbolByFirBuilder private constructor( } } + /** + * We want to unwrap a SUBSTITUTION_OVERRIDE wrapper if it doesn't affect the declaration's signature in any way. If the signature + * is somehow changed, then we want to keep the wrapper. + * + * If the declaration references only its own type parameters, or parameters from the outer declarations, then + * we consider that it's signature will not be changed by the SUBSTITUTION_OVERRIDE, so the wrapper can be unwrapped. + * + * This have a few caveats when it comes to the inner classes. TODO Provide a reference to some more in-detail description of that. + * + * N.B. This functions lifts only a single layer of SUBSTITUTION_OVERRIDE at a time. + * + * @receiver A declaration that needs to be unwrapped. + * @return An unsubstituted declaration ([originalForSubstitutionOverride]]) if it exists and if it does not have any change + * in signature; `null` otherwise. + */ + private inline fun T.unwrapSubstitutionOverrideIfNeeded(): T? { + val containingClass = getContainingClass(rootSession) ?: return null + val originalDeclaration = originalForSubstitutionOverride ?: return null + + val allowedTypeParameters = buildSet { + // declaration's own parameters + originalDeclaration.typeParameters.mapTo(this) { it.symbol.toLookupTag() } + + // captured outer parameters + containingClass.typeParameters.mapNotNullTo(this) { + (it as? FirOuterClassTypeParameterRef)?.symbol?.toLookupTag() + } + } + + val usedTypeParameters = collectReferencedTypeParameters(originalDeclaration) + + return if (allowedTypeParameters.containsAll(usedTypeParameters)) { + originalDeclaration + } else { + null + } + } + companion object { private fun throwUnexpectedElementError(element: Any): Nothing { error("Unexpected ${element::class.simpleName}") @@ -427,7 +476,7 @@ internal class KtSymbolByFirBuilder private constructor( } -private class BuilderCache private constructor( +private class BuilderCache private constructor( private val cache: ConcurrentMap, private val isReadOnly: Boolean ) { @@ -452,3 +501,46 @@ internal fun FirElement.buildSymbol(builder: KtSymbolByFirBuilder) = internal fun FirDeclaration.buildSymbol(builder: KtSymbolByFirBuilder) = builder.buildSymbol(this) + +private fun collectReferencedTypeParameters(declaration: FirCallableDeclaration): Set { + val allUsedTypeParameters = mutableSetOf() + + declaration.accept(object : FirVisitorVoid() { + override fun visitElement(element: FirElement) { + element.acceptChildren(this) + } + + override fun visitSimpleFunction(simpleFunction: FirSimpleFunction) { + simpleFunction.typeParameters.forEach { it.accept(this) } + + simpleFunction.receiverTypeRef?.accept(this) + simpleFunction.valueParameters.forEach { it.returnTypeRef.accept(this) } + simpleFunction.returnTypeRef.accept(this) + } + + override fun visitProperty(property: FirProperty) { + property.typeParameters.forEach { it.accept(this) } + + property.receiverTypeRef?.accept(this) + property.returnTypeRef.accept(this) + } + + override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) { + super.visitResolvedTypeRef(resolvedTypeRef) + + handleTypeRef(resolvedTypeRef) + } + + private fun handleTypeRef(resolvedTypeRef: FirResolvedTypeRef) { + val resolvedType = resolvedTypeRef.type + + resolvedType.forEachType { + if (it is ConeTypeParameterType) { + allUsedTypeParameters.add(it.lookupTag) + } + } + } + }) + + return allUsedTypeParameters +} diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirBackingFieldSymbol.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirBackingFieldSymbol.kt index 9f6bb1e176d..5e02ff30d39 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirBackingFieldSymbol.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirBackingFieldSymbol.kt @@ -31,7 +31,7 @@ internal class KtFirBackingFieldSymbol( } override val owningProperty: KtKotlinPropertySymbol by propertyFirRef.withFirAndCache { fir -> - builder.variableLikeBuilder.buildPropertySymbol(fir) + builder.buildSymbol(fir) as KtKotlinPropertySymbol } override fun createPointer(): KtSymbolPointer { diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirFunctionSymbol.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirFunctionSymbol.kt index 1b49f15bd28..dd838f3bb77 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirFunctionSymbol.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirFunctionSymbol.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.api.FirModuleResolveState import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.fir.containingClass +import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.declarations.utils.* @@ -92,7 +93,10 @@ internal class KtFirFunctionSymbol( override val visibility: Visibility get() = getVisibility() override fun createPointer(): KtSymbolPointer { - KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it } + if (firRef.withFir { it.origin != FirDeclarationOrigin.SubstitutionOverride }) { + KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it } + } + return when (symbolKind) { KtSymbolKind.TOP_LEVEL -> firRef.withFir { fir -> KtFirTopLevelFunctionSymbolPointer(fir.symbol.callableId, fir.createSignature()) diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirKotlinPropertySymbol.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirKotlinPropertySymbol.kt index 0f2f4455e46..af0b2a5af14 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirKotlinPropertySymbol.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/symbols/KtFirKotlinPropertySymbol.kt @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.api.FirModuleResolveState import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.fir.containingClass +import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirResolvePhase import org.jetbrains.kotlin.fir.declarations.synthetic.FirSyntheticProperty @@ -115,7 +116,10 @@ internal class KtFirKotlinPropertySymbol( override val hasSetter: Boolean get() = firRef.withFir { it.setter != null } override fun createPointer(): KtSymbolPointer { - KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it } + if (firRef.withFir { it.origin != FirDeclarationOrigin.SubstitutionOverride }) { + KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it } + } + return when (symbolKind) { KtSymbolKind.TOP_LEVEL -> TODO("Creating symbol for top level properties is not supported yet") KtSymbolKind.CLASS_MEMBER -> firRef.withFir { fir -> diff --git a/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/AbstractFirSubstitutionOverridesUnwrappingTest.kt b/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/AbstractFirSubstitutionOverridesUnwrappingTest.kt new file mode 100644 index 00000000000..ba690c210b3 --- /dev/null +++ b/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/AbstractFirSubstitutionOverridesUnwrappingTest.kt @@ -0,0 +1,11 @@ +/* + * Copyright 2010-2021 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. + */ + +package org.jetbrains.kotlin.analysis.api.fir.scopes + +import org.jetbrains.kotlin.analysis.api.fir.FirFrontendApiTestConfiguratorService +import org.jetbrains.kotlin.analysis.api.impl.base.test.scopes.AbstractSubstitutionOverridesUnwrappingTest + +abstract class AbstractFirSubstitutionOverridesUnwrappingTest : AbstractSubstitutionOverridesUnwrappingTest(FirFrontendApiTestConfiguratorService) \ No newline at end of file diff --git a/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/FirMemberScopeByFqNameTestGenerated.java b/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/FirMemberScopeByFqNameTestGenerated.java index e649c18b14a..1ad17dc076c 100644 --- a/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/FirMemberScopeByFqNameTestGenerated.java +++ b/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/FirMemberScopeByFqNameTestGenerated.java @@ -47,10 +47,4 @@ public class FirMemberScopeByFqNameTestGenerated extends AbstractFirMemberScopeB public void testMutableList() throws Exception { runTest("analysis/analysis-api/testData/scopes/memberScopeByFqName/MutableList.kt"); } - - @Test - @TestMetadata("overridenFunctionWithGenericBound.kt") - public void testOverridenFunctionWithGenericBound() throws Exception { - runTest("analysis/analysis-api/testData/scopes/memberScopeByFqName/overridenFunctionWithGenericBound.kt"); - } } diff --git a/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/FirSubstitutionOverridesUnwrappingTestGenerated.java b/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/FirSubstitutionOverridesUnwrappingTestGenerated.java new file mode 100644 index 00000000000..02f1928b399 --- /dev/null +++ b/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/scopes/FirSubstitutionOverridesUnwrappingTestGenerated.java @@ -0,0 +1,110 @@ +/* + * Copyright 2010-2021 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. + */ + +package org.jetbrains.kotlin.analysis.api.fir.scopes; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping") +@TestDataPath("$PROJECT_ROOT") +public class FirSubstitutionOverridesUnwrappingTestGenerated extends AbstractFirSubstitutionOverridesUnwrappingTest { + @Test + public void testAllFilesPresentInSubstitutionOverridesUnwrapping() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("ClassWithGenericBase1.kt") + public void testClassWithGenericBase1() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase1.kt"); + } + + @Test + @TestMetadata("ClassWithGenericBase2.kt") + public void testClassWithGenericBase2() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase2.kt"); + } + + @Test + @TestMetadata("ClassWithGenericBase3.kt") + public void testClassWithGenericBase3() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase3.kt"); + } + + @Test + @TestMetadata("ClassWithGenericBase4.kt") + public void testClassWithGenericBase4() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase4.kt"); + } + + @Test + @TestMetadata("GenericFromFunctionInLocalClass1.kt") + public void testGenericFromFunctionInLocalClass1() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass1.kt"); + } + + @Test + @TestMetadata("GenericFromFunctionInLocalClass2.kt") + public void testGenericFromFunctionInLocalClass2() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass2.kt"); + } + + @Test + @TestMetadata("GenericFromOuterClassInInnerClass1.kt") + public void testGenericFromOuterClassInInnerClass1() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass1.kt"); + } + + @Test + @TestMetadata("GenericFromOuterClassInInnerClass2.kt") + public void testGenericFromOuterClassInInnerClass2() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass2.kt"); + } + + @Test + @TestMetadata("GenericFromOuterClassInInnerClassInInheritor1.kt") + public void testGenericFromOuterClassInInnerClassInInheritor1() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor1.kt"); + } + + @Test + @TestMetadata("GenericFromOuterClassInInnerClassInInheritor2.kt") + public void testGenericFromOuterClassInInnerClassInInheritor2() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor2.kt"); + } + + @Test + @TestMetadata("GenericFromOuterClassInInnerClassInInheritor3.kt") + public void testGenericFromOuterClassInInnerClassInInheritor3() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor3.kt"); + } + + @Test + @TestMetadata("Implement_java_util_Collection.kt") + public void testImplement_java_util_Collection() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/Implement_java_util_Collection.kt"); + } + + @Test + @TestMetadata("MemberFunctionWithOuterTypeParameterBound.kt") + public void testMemberFunctionWithOuterTypeParameterBound() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberFunctionWithOuterTypeParameterBound.kt"); + } + + @Test + @TestMetadata("MemberPropertyWithOuterTypeParameterBound.kt") + public void testMemberPropertyWithOuterTypeParameterBound() throws Exception { + runTest("analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberPropertyWithOuterTypeParameterBound.kt"); + } +} diff --git a/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/symbols/FirSymbolByReferenceTestGenerated.java b/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/symbols/FirSymbolByReferenceTestGenerated.java index 7204b5d73a9..1c307a2a5af 100644 --- a/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/symbols/FirSymbolByReferenceTestGenerated.java +++ b/analysis/analysis-api-fir/tests/org/jetbrains/kotlin/analysis/api/fir/symbols/FirSymbolByReferenceTestGenerated.java @@ -36,6 +36,18 @@ public class FirSymbolByReferenceTestGenerated extends AbstractFirSymbolByRefere runTest("analysis/analysis-api/testData/symbols/symbolByReference/constructorViaTypeAlias.kt"); } + @Test + @TestMetadata("genericFromFunctionInLocalClass.kt") + public void testGenericFromFunctionInLocalClass() throws Exception { + runTest("analysis/analysis-api/testData/symbols/symbolByReference/genericFromFunctionInLocalClass.kt"); + } + + @Test + @TestMetadata("genericFromOuterClassInInnerClass.kt") + public void testGenericFromOuterClassInInnerClass() throws Exception { + runTest("analysis/analysis-api/testData/symbols/symbolByReference/genericFromOuterClassInInnerClass.kt"); + } + @Test @TestMetadata("samConstructor.kt") public void testSamConstructor() throws Exception { diff --git a/analysis/analysis-api-impl-base/tests/org/jetbrains/kotlin/analysis/api/impl/base/test/scopes/AbstractSubstitutionOverridesUnwrappingTest.kt b/analysis/analysis-api-impl-base/tests/org/jetbrains/kotlin/analysis/api/impl/base/test/scopes/AbstractSubstitutionOverridesUnwrappingTest.kt new file mode 100644 index 00000000000..657121e99f5 --- /dev/null +++ b/analysis/analysis-api-impl-base/tests/org/jetbrains/kotlin/analysis/api/impl/base/test/scopes/AbstractSubstitutionOverridesUnwrappingTest.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2021 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. + */ + +package org.jetbrains.kotlin.analysis.api.impl.base.test.scopes + +import org.jetbrains.kotlin.analysis.api.KtAnalysisSession +import org.jetbrains.kotlin.analysis.api.impl.barebone.test.FrontendApiTestConfiguratorService +import org.jetbrains.kotlin.analysis.api.impl.barebone.test.expressionMarkerProvider +import org.jetbrains.kotlin.analysis.api.impl.base.test.symbols.AbstractSymbolTest +import org.jetbrains.kotlin.analysis.api.symbols.DebugSymbolRenderer +import org.jetbrains.kotlin.analysis.api.symbols.KtClassLikeSymbol +import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol +import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithMembers +import org.jetbrains.kotlin.psi.KtClassLikeDeclaration +import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder +import org.jetbrains.kotlin.test.directives.ConfigurationDirectives +import org.jetbrains.kotlin.test.services.TestServices + +abstract class AbstractSubstitutionOverridesUnwrappingTest( + configurator: FrontendApiTestConfiguratorService +) : AbstractSymbolTest(configurator) { + + override fun KtAnalysisSession.collectSymbols(ktFile: KtFile, testServices: TestServices): List { + val declarationUnderCaret = testServices.expressionMarkerProvider.getElementOfTypAtCaret(ktFile) + val classSymbolUnderCaret = declarationUnderCaret.getSymbol() as KtClassLikeSymbol + + require(classSymbolUnderCaret is KtSymbolWithMembers) + + return classSymbolUnderCaret.getMemberScope().getAllSymbols().toList() + } + + override fun KtAnalysisSession.renderSymbolForComparison(symbol: KtSymbol): String { + return with(DebugSymbolRenderer) { renderForSubstitutionOverrideUnwrappingTest(symbol) } + } + + override fun configureTest(builder: TestConfigurationBuilder) { + super.configureTest(builder) + with(builder) { + defaultDirectives { + +ConfigurationDirectives.WITH_STDLIB + } + } + } +} \ No newline at end of file diff --git a/analysis/analysis-api-impl-base/tests/org/jetbrains/kotlin/analysis/api/impl/base/test/symbols/AbstractSymbolTest.kt b/analysis/analysis-api-impl-base/tests/org/jetbrains/kotlin/analysis/api/impl/base/test/symbols/AbstractSymbolTest.kt index 7371c8574d0..c3e71792c47 100644 --- a/analysis/analysis-api-impl-base/tests/org/jetbrains/kotlin/analysis/api/impl/base/test/symbols/AbstractSymbolTest.kt +++ b/analysis/analysis-api-impl-base/tests/org/jetbrains/kotlin/analysis/api/impl/base/test/symbols/AbstractSymbolTest.kt @@ -35,7 +35,7 @@ abstract class AbstractSymbolTest(configurator: FrontendApiTestConfiguratorServi collectSymbols(ktFile, testServices).map { symbol -> PointerWithRenderedSymbol( if (createPointers) symbol.createPointer() else null, - with(DebugSymbolRenderer) { renderExtra(symbol) } + renderSymbolForComparison(symbol) ) } } @@ -66,12 +66,17 @@ abstract class AbstractSymbolTest(configurator: FrontendApiTestConfiguratorServi pointersWithRendered.map { (pointer, expectedRender) -> val restored = pointer!!.restoreSymbol() ?: error("Symbol $expectedRender was not restored") - with(DebugSymbolRenderer) { renderExtra(restored) } + + renderSymbolForComparison(restored) } } val actual = restored.joinToString(separator = "\n\n") testServices.assertions.assertEqualsToTestDataFileSibling(actual) } + + protected open fun KtAnalysisSession.renderSymbolForComparison(symbol: KtSymbol): String { + return with(DebugSymbolRenderer) { renderExtra(symbol) } + } } private object SymbolTestDirectives : SimpleDirectivesContainer() { diff --git a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/symbols/DebugSymbolRenderer.kt b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/symbols/DebugSymbolRenderer.kt index e0a072f343d..8702cb1da4a 100644 --- a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/symbols/DebugSymbolRenderer.kt +++ b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/symbols/DebugSymbolRenderer.kt @@ -53,6 +53,26 @@ public object DebugSymbolRenderer { } }.toString() + public fun KtAnalysisSession.renderForSubstitutionOverrideUnwrappingTest(symbol: KtSymbol): String = Block().apply { + if (symbol !is KtCallableSymbol) return@apply + + renderSymbolHeader(symbol) + + withIndent { + renderProperty(KtCallableSymbol::callableIdIfNonLocal, symbol) + if (symbol is KtNamedSymbol) { + renderProperty(KtNamedSymbol::name, symbol) + } + renderProperty(KtCallableSymbol::origin, symbol) + + @Suppress("DEPRECATION") + (symbol as? KtPossibleMemberSymbol)?.getDispatchReceiverType()?.let { dispatchType -> + appendLine().append("getDispatchReceiver()").append(": ") + renderType(dispatchType) + } + } + }.toString() + private fun Block.renderProperty(property: KProperty<*>, vararg args: Any) { try { appendLine().append(property.name).append(": ") @@ -63,9 +83,9 @@ public object DebugSymbolRenderer { } private fun Block.renderSymbol(symbol: KtSymbol) { - val apiClass = getSymbolApiClass(symbol) - append(apiClass.simpleName).append(':') + renderSymbolHeader(symbol) + val apiClass = getSymbolApiClass(symbol) withIndent { apiClass.members .asSequence() @@ -76,6 +96,11 @@ public object DebugSymbolRenderer { } } + private fun Block.renderSymbolHeader(symbol: KtSymbol) { + val apiClass = getSymbolApiClass(symbol) + append(apiClass.simpleName).append(':') + } + private fun Block.renderList(values: List<*>) { if (values.isEmpty()) { append("[]") diff --git a/analysis/analysis-api/testData/components/callResolver/resolveCall/memberFunctionCallWithTypeArgument.descriptors.txt b/analysis/analysis-api/testData/components/callResolver/resolveCall/memberFunctionCallWithTypeArgument.descriptors.txt new file mode 100644 index 00000000000..87158fe0e86 --- /dev/null +++ b/analysis/analysis-api/testData/components/callResolver/resolveCall/memberFunctionCallWithTypeArgument.descriptors.txt @@ -0,0 +1,4 @@ +KtFunctionCall: +argumentMapping = { 1 -> (r: kotlin.Int) } +targetFunction = /A.foo(: A, r: kotlin.Int): kotlin.Unit +substitutor = \ No newline at end of file diff --git a/analysis/analysis-api/testData/components/callResolver/resolveCall/memberFunctionCallWithTypeArgument.txt b/analysis/analysis-api/testData/components/callResolver/resolveCall/memberFunctionCallWithTypeArgument.txt index 87158fe0e86..8004b408882 100644 --- a/analysis/analysis-api/testData/components/callResolver/resolveCall/memberFunctionCallWithTypeArgument.txt +++ b/analysis/analysis-api/testData/components/callResolver/resolveCall/memberFunctionCallWithTypeArgument.txt @@ -1,4 +1,4 @@ KtFunctionCall: argumentMapping = { 1 -> (r: kotlin.Int) } -targetFunction = /A.foo(: A, r: kotlin.Int): kotlin.Unit +targetFunction = /A.foo(: A, r: R): kotlin.Unit substitutor = \ No newline at end of file diff --git a/analysis/analysis-api/testData/referenceResolve/forLoopIn/inBuiltIns/member.txt b/analysis/analysis-api/testData/referenceResolve/forLoopIn/inBuiltIns/member.txt index fdcd7a47249..f8d5381c7c9 100644 --- a/analysis/analysis-api/testData/referenceResolve/forLoopIn/inBuiltIns/member.txt +++ b/analysis/analysis-api/testData/referenceResolve/forLoopIn/inBuiltIns/member.txt @@ -1,4 +1,4 @@ Resolved to: -0: (in kotlin.collections.IntIterator) abstract operator fun hasNext(): kotlin.Boolean -1: (in kotlin.collections.IntIterator) operator fun next(): kotlin.Int +0: (in kotlin.collections.IntIterator) operator fun next(): kotlin.Int +1: (in kotlin.collections.Iterator) operator fun hasNext(): kotlin.Boolean 2: (in kotlin.ranges.IntProgression) open operator fun iterator(): kotlin.collections.IntIterator \ No newline at end of file diff --git a/analysis/analysis-api/testData/referenceResolve/forLoopIn/inLibrary/extension.txt b/analysis/analysis-api/testData/referenceResolve/forLoopIn/inLibrary/extension.txt index a13df3fcc3e..1e717c8fd58 100644 --- a/analysis/analysis-api/testData/referenceResolve/forLoopIn/inLibrary/extension.txt +++ b/analysis/analysis-api/testData/referenceResolve/forLoopIn/inLibrary/extension.txt @@ -1,4 +1,4 @@ Resolved to: -0: (in kotlin.collections.CharIterator) abstract operator fun hasNext(): kotlin.Boolean -1: (in kotlin.collections.CharIterator) operator fun next(): kotlin.Char +0: (in kotlin.collections.CharIterator) operator fun next(): kotlin.Char +1: (in kotlin.collections.Iterator) operator fun hasNext(): kotlin.Boolean 2: (in kotlin.text) operator fun kotlin.CharSequence.iterator(): kotlin.collections.CharIterator \ No newline at end of file diff --git a/analysis/analysis-api/testData/scopes/memberScopeByFqName/MutableList.txt b/analysis/analysis-api/testData/scopes/memberScopeByFqName/MutableList.txt index 415f1342db1..99467effade 100644 --- a/analysis/analysis-api/testData/scopes/memberScopeByFqName/MutableList.txt +++ b/analysis/analysis-api/testData/scopes/memberScopeByFqName/MutableList.txt @@ -442,7 +442,7 @@ KtFunctionSymbol: KtFunctionSymbol: annotationsList: [] - callableIdIfNonLocal: kotlin/collections/MutableList.isEmpty + callableIdIfNonLocal: kotlin/collections/List.isEmpty hasStableParameterNames: true isExtension: false isExternal: false @@ -461,7 +461,7 @@ KtFunctionSymbol: typeParameters: [] valueParameters: [] visibility: Public - getDispatchReceiver(): kotlin/collections/MutableList + getDispatchReceiver(): kotlin/collections/List deprecationStatus: null KtFunctionSymbol: @@ -516,10 +516,10 @@ KtFunctionSymbol: KtKotlinPropertySymbol: annotationsList: [] - callableIdIfNonLocal: kotlin/collections/MutableList.size - getter: null + callableIdIfNonLocal: kotlin/collections/List.size + getter: KtPropertyGetterSymbol() hasBackingField: false - hasGetter: false + hasGetter: true hasSetter: false initializer: null isConst: false @@ -539,7 +539,7 @@ KtKotlinPropertySymbol: symbolKind: CLASS_MEMBER typeParameters: [] visibility: Public - getDispatchReceiver(): kotlin/collections/MutableList + getDispatchReceiver(): kotlin/collections/List deprecationStatus: null getterDeprecationStatus: null javaGetterName: getSize diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase1.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase1.kt new file mode 100644 index 00000000000..0771b8e3f9d --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase1.kt @@ -0,0 +1,15 @@ +package test + +class Foo + +abstract class Base { + fun noGeneric() {} + + fun withOuterGeneric(t: T) {} + + fun withOwnGeneric(tt: TT) {} + + fun withOuterAndOwnGeneric(t: T, tt: TT) {} +} + +class ClassWithGenericBase : Base() diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase1.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase1.txt new file mode 100644 index 00000000000..6160c1af57c --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase1.txt @@ -0,0 +1,45 @@ +KtFunctionSymbol: + callableIdIfNonLocal: test/Base.noGeneric + name: noGeneric + origin: SOURCE + getDispatchReceiver(): test/Base + +KtFunctionSymbol: + callableIdIfNonLocal: test/ClassWithGenericBase.withOuterGeneric + name: withOuterGeneric + origin: SOURCE + getDispatchReceiver(): test/ClassWithGenericBase + +KtFunctionSymbol: + callableIdIfNonLocal: test/Base.withOwnGeneric + name: withOwnGeneric + origin: SOURCE + getDispatchReceiver(): test/Base + +KtFunctionSymbol: + callableIdIfNonLocal: test/ClassWithGenericBase.withOuterAndOwnGeneric + name: withOuterAndOwnGeneric + origin: SOURCE + getDispatchReceiver(): test/ClassWithGenericBase + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase2.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase2.kt new file mode 100644 index 00000000000..3053dd1dfc4 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase2.kt @@ -0,0 +1,15 @@ +package test + +class Foo + +abstract class Base { + val noGeneric: Foo? = null + + val withOuterGeneric: T? = null + + val TT.withOwnGeneric: TT? get() = null + + val TT.withOuterAndOwnGeneric: T? get() = null +} + +class ClassWithGenericBase : Base() \ No newline at end of file diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase2.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase2.txt new file mode 100644 index 00000000000..694c5fe763a --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase2.txt @@ -0,0 +1,45 @@ +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/Base.noGeneric + name: noGeneric + origin: SOURCE + getDispatchReceiver(): test/Base + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/ClassWithGenericBase.withOuterGeneric + name: withOuterGeneric + origin: SOURCE + getDispatchReceiver(): test/ClassWithGenericBase + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/Base.withOwnGeneric + name: withOwnGeneric + origin: SOURCE + getDispatchReceiver(): test/Base + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/ClassWithGenericBase.withOuterAndOwnGeneric + name: withOuterAndOwnGeneric + origin: SOURCE + getDispatchReceiver(): test/ClassWithGenericBase + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase3.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase3.kt new file mode 100644 index 00000000000..537260d6aa8 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase3.kt @@ -0,0 +1,20 @@ +package test + +class SomeClass1 +class SomeClass2 + +interface InterfaceWithFunBase { + fun noGenerics_InterfaceWithFunBase() {} + + fun withOuterGenericT1_InterfaceWithFunBase(): T1 {} + + fun withOuterGenericT2_InterfaceWithFunBase(): T2 {} +} + +interface InterfaceWithFun : InterfaceWithFunBase { + fun noGenerics_InterfaceWithFun() {} + + fun withOuterGeneric_InterfaceWithFun(): T {} +} + +abstract class ClassWithInterfaceWithFun : InterfaceWithFun diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase3.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase3.txt new file mode 100644 index 00000000000..6cf23e29de4 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase3.txt @@ -0,0 +1,51 @@ +KtFunctionSymbol: + callableIdIfNonLocal: test/InterfaceWithFun.noGenerics_InterfaceWithFun + name: noGenerics_InterfaceWithFun + origin: SOURCE + getDispatchReceiver(): test/InterfaceWithFun + +KtFunctionSymbol: + callableIdIfNonLocal: test/ClassWithInterfaceWithFun.withOuterGeneric_InterfaceWithFun + name: withOuterGeneric_InterfaceWithFun + origin: SOURCE + getDispatchReceiver(): test/ClassWithInterfaceWithFun + +KtFunctionSymbol: + callableIdIfNonLocal: test/InterfaceWithFunBase.noGenerics_InterfaceWithFunBase + name: noGenerics_InterfaceWithFunBase + origin: SOURCE + getDispatchReceiver(): test/InterfaceWithFunBase + +KtFunctionSymbol: + callableIdIfNonLocal: test/InterfaceWithFun.withOuterGenericT1_InterfaceWithFunBase + name: withOuterGenericT1_InterfaceWithFunBase + origin: SOURCE + getDispatchReceiver(): test/InterfaceWithFun + +KtFunctionSymbol: + callableIdIfNonLocal: test/ClassWithInterfaceWithFun.withOuterGenericT2_InterfaceWithFunBase + name: withOuterGenericT2_InterfaceWithFunBase + origin: SOURCE + getDispatchReceiver(): test/ClassWithInterfaceWithFun + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase4.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase4.kt new file mode 100644 index 00000000000..7285ae9db95 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase4.kt @@ -0,0 +1,31 @@ +package test + +class SomeClass1 +class SomeClass2 + +interface InterfaceWithValBase { + val noGenerics_InterfaceWithValBase: SomeClass1 + + val withOuterGenericT1_InterfaceWithValBase: T1 + + val withOuterGenericT2_InterfaceWithValBase: T2 + + val Own.withOwnGeneric_InterfaceWithValBase: SomeClass1 + + val Own.withOwnAndOuterGenericT1_InterfaceWithValBase: T1 + + val Own.withOwnAndOuterGenericT2_InterfaceWithValBase: T2 +} + +interface InterfaceWithVal : InterfaceWithValBase { + val noGenerics_InterfaceWithVal: SomeClass1 + + val withOuterGeneric_InterfaceWithVal: T + + val Own.withOwnGeneric_InterfaceWithVal: SomeClass1 + + val Own.withOwnAndOuterGeneric_InterfaceWithVal: T +} + + +abstract class ClassWithInterfaceWithVal : InterfaceWithVal diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase4.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase4.txt new file mode 100644 index 00000000000..21f236b3e2f --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/ClassWithGenericBase4.txt @@ -0,0 +1,81 @@ +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/InterfaceWithVal.noGenerics_InterfaceWithVal + name: noGenerics_InterfaceWithVal + origin: SOURCE + getDispatchReceiver(): test/InterfaceWithVal + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/ClassWithInterfaceWithVal.withOuterGeneric_InterfaceWithVal + name: withOuterGeneric_InterfaceWithVal + origin: SOURCE + getDispatchReceiver(): test/ClassWithInterfaceWithVal + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/InterfaceWithVal.withOwnGeneric_InterfaceWithVal + name: withOwnGeneric_InterfaceWithVal + origin: SOURCE + getDispatchReceiver(): test/InterfaceWithVal + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/ClassWithInterfaceWithVal.withOwnAndOuterGeneric_InterfaceWithVal + name: withOwnAndOuterGeneric_InterfaceWithVal + origin: SOURCE + getDispatchReceiver(): test/ClassWithInterfaceWithVal + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/InterfaceWithValBase.noGenerics_InterfaceWithValBase + name: noGenerics_InterfaceWithValBase + origin: SOURCE + getDispatchReceiver(): test/InterfaceWithValBase + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/InterfaceWithVal.withOuterGenericT1_InterfaceWithValBase + name: withOuterGenericT1_InterfaceWithValBase + origin: SOURCE + getDispatchReceiver(): test/InterfaceWithVal + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/ClassWithInterfaceWithVal.withOuterGenericT2_InterfaceWithValBase + name: withOuterGenericT2_InterfaceWithValBase + origin: SOURCE + getDispatchReceiver(): test/ClassWithInterfaceWithVal + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/InterfaceWithValBase.withOwnGeneric_InterfaceWithValBase + name: withOwnGeneric_InterfaceWithValBase + origin: SOURCE + getDispatchReceiver(): test/InterfaceWithValBase + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/InterfaceWithVal.withOwnAndOuterGenericT1_InterfaceWithValBase + name: withOwnAndOuterGenericT1_InterfaceWithValBase + origin: SOURCE + getDispatchReceiver(): test/InterfaceWithVal + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/ClassWithInterfaceWithVal.withOwnAndOuterGenericT2_InterfaceWithValBase + name: withOwnAndOuterGenericT2_InterfaceWithValBase + origin: SOURCE + getDispatchReceiver(): test/ClassWithInterfaceWithVal + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass1.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass1.kt new file mode 100644 index 00000000000..c0ba64c9b7e --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass1.kt @@ -0,0 +1,14 @@ +// DO_NOT_CHECK_SYMBOL_RESTORE +package test + +class SomeClass + +fun topLevel() { + open class Base { + fun withOuter(): Outer? = null + } + + class Child : Base() { + fun noGenerics() {} + } +} diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass1.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass1.txt new file mode 100644 index 00000000000..efa98e7f336 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass1.txt @@ -0,0 +1,33 @@ +KtFunctionSymbol: + callableIdIfNonLocal: null + name: noGenerics + origin: SOURCE + getDispatchReceiver(): test/Child + +KtFunctionSymbol: + callableIdIfNonLocal: null + name: withOuter + origin: SOURCE + getDispatchReceiver(): test/Base + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass2.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass2.kt new file mode 100644 index 00000000000..735b5bef3f3 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass2.kt @@ -0,0 +1,15 @@ +// DO_NOT_CHECK_SYMBOL_RESTORE +package test + +class SomeClass + +fun topLevel() { + open class Base { + fun withOuter(): Outer? = null + fun withOuterAndOwn(t: T): Outer? = null + } + + class Child : Base() { + fun noGenerics() {} + } +} diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass2.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass2.txt new file mode 100644 index 00000000000..6e75f46a4fc --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromFunctionInLocalClass2.txt @@ -0,0 +1,39 @@ +KtFunctionSymbol: + callableIdIfNonLocal: null + name: noGenerics + origin: SOURCE + getDispatchReceiver(): test/Child + +KtFunctionSymbol: + callableIdIfNonLocal: null + name: withOuter + origin: SOURCE + getDispatchReceiver(): test/Base + +KtFunctionSymbol: + callableIdIfNonLocal: null + name: withOuterAndOwn + origin: SOURCE + getDispatchReceiver(): test/Child + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass1.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass1.kt new file mode 100644 index 00000000000..71b3434785c --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass1.kt @@ -0,0 +1,12 @@ +package test + +class SomeClass + +open class TopLevel { + open inner class Base { + fun noGeneric() {} + fun withOuter(): Outer? = null + } + inner class Child : Base() +} + diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass1.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass1.txt new file mode 100644 index 00000000000..08a25e2c4b2 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass1.txt @@ -0,0 +1,34 @@ +KtFunctionSymbol: + callableIdIfNonLocal: test/TopLevel.Base.noGeneric + name: noGeneric + origin: SOURCE + getDispatchReceiver(): test/TopLevel.Base + +KtFunctionSymbol: + callableIdIfNonLocal: test/TopLevel.Base.withOuter + name: withOuter + origin: SOURCE + getDispatchReceiver(): test/TopLevel.Base + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED + getDispatchReceiver(): test/TopLevel diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass2.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass2.kt new file mode 100644 index 00000000000..460d01bd96f --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass2.kt @@ -0,0 +1,13 @@ +package test + +class SomeClass + +open class TopLevel { + open inner class Base { + fun noGeneric() {} + fun withOuter(): Outer? = null + fun withOwnAndOuter(t: T): Outer? = null + } + + inner class Child : Base() +} diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass2.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass2.txt new file mode 100644 index 00000000000..7b5eb8d4933 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClass2.txt @@ -0,0 +1,40 @@ +KtFunctionSymbol: + callableIdIfNonLocal: test/TopLevel.Base.noGeneric + name: noGeneric + origin: SOURCE + getDispatchReceiver(): test/TopLevel.Base + +KtFunctionSymbol: + callableIdIfNonLocal: test/TopLevel.Base.withOuter + name: withOuter + origin: SOURCE + getDispatchReceiver(): test/TopLevel.Base + +KtFunctionSymbol: + callableIdIfNonLocal: test/TopLevel.Child.withOwnAndOuter + name: withOwnAndOuter + origin: SOURCE + getDispatchReceiver(): test/TopLevel.Child + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED + getDispatchReceiver(): test/TopLevel diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor1.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor1.kt new file mode 100644 index 00000000000..96b39b2bba4 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor1.kt @@ -0,0 +1,14 @@ +package test + +class SomeClass + +open class TopLevel { + open inner class Base { + fun noGeneric() {} + fun withOuter(): Outer? = null + } +} + +class OtherTopLevel : TopLevel() { + inner class Child : Base() +} diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor1.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor1.txt new file mode 100644 index 00000000000..83a71dd6841 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor1.txt @@ -0,0 +1,34 @@ +KtFunctionSymbol: + callableIdIfNonLocal: test/TopLevel.Base.noGeneric + name: noGeneric + origin: SOURCE + getDispatchReceiver(): test/TopLevel.Base + +KtFunctionSymbol: + callableIdIfNonLocal: test/OtherTopLevel.Child.withOuter + name: withOuter + origin: SOURCE + getDispatchReceiver(): test/OtherTopLevel.Child + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED + getDispatchReceiver(): test/OtherTopLevel diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor2.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor2.kt new file mode 100644 index 00000000000..db39bf04d7b --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor2.kt @@ -0,0 +1,14 @@ +package test + +class SomeClass + +open class TopLevel { + open inner class Base { + fun noGeneric() {} + fun withOuter(): Outer? = null + } +} + +class OtherTopLevel : TopLevel() { + inner class Child : Base() +} diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor2.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor2.txt new file mode 100644 index 00000000000..679ac3a3cf6 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor2.txt @@ -0,0 +1,34 @@ +KtFunctionSymbol: + callableIdIfNonLocal: test/TopLevel.Base.noGeneric + name: noGeneric + origin: SOURCE + getDispatchReceiver(): test/TopLevel.Base + +KtFunctionSymbol: + callableIdIfNonLocal: test/OtherTopLevel.Child.withOuter + name: withOuter + origin: SOURCE + getDispatchReceiver(): test/OtherTopLevel.Child + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED + getDispatchReceiver(): test/OtherTopLevel diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor3.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor3.kt new file mode 100644 index 00000000000..ce0b1ee0e73 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor3.kt @@ -0,0 +1,15 @@ +package test + +class SomeClass + +open class TopLevel { + open inner class Base { + fun noGeneric() {} + fun withOuter(): Outer? = null + fun withOwnAndOuter(t: T): Outer? = null + } +} + +class OtherTopLevel : TopLevel() { + inner class Child : Base() +} diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor3.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor3.txt new file mode 100644 index 00000000000..7e4d781c740 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/GenericFromOuterClassInInnerClassInInheritor3.txt @@ -0,0 +1,40 @@ +KtFunctionSymbol: + callableIdIfNonLocal: test/TopLevel.Base.noGeneric + name: noGeneric + origin: SOURCE + getDispatchReceiver(): test/TopLevel.Base + +KtFunctionSymbol: + callableIdIfNonLocal: test/OtherTopLevel.Child.withOuter + name: withOuter + origin: SOURCE + getDispatchReceiver(): test/OtherTopLevel.Child + +KtFunctionSymbol: + callableIdIfNonLocal: test/OtherTopLevel.Child.withOwnAndOuter + name: withOwnAndOuter + origin: SOURCE + getDispatchReceiver(): test/OtherTopLevel.Child + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED + getDispatchReceiver(): test/OtherTopLevel diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/Implement_java_util_Collection.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/Implement_java_util_Collection.kt new file mode 100644 index 00000000000..1fefe6c6bf4 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/Implement_java_util_Collection.kt @@ -0,0 +1,5 @@ +package test + +class SomeClass + +abstract class MyList : java.util.Collection diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/Implement_java_util_Collection.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/Implement_java_util_Collection.txt new file mode 100644 index 00000000000..40e2d424ea6 --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/Implement_java_util_Collection.txt @@ -0,0 +1,99 @@ +KtFunctionSymbol: + callableIdIfNonLocal: java/util/Collection.size + name: size + origin: JAVA + getDispatchReceiver(): java/util/Collection + +KtFunctionSymbol: + callableIdIfNonLocal: java/util/Collection.isEmpty + name: isEmpty + origin: JAVA + getDispatchReceiver(): java/util/Collection + +KtFunctionSymbol: + callableIdIfNonLocal: java/util/Collection.contains + name: contains + origin: JAVA + getDispatchReceiver(): java/util/Collection + +KtFunctionSymbol: + callableIdIfNonLocal: test/MyList.iterator + name: iterator + origin: JAVA + getDispatchReceiver(): test/MyList + +KtFunctionSymbol: + callableIdIfNonLocal: java/util/Collection.toArray + name: toArray + origin: JAVA + getDispatchReceiver(): java/util/Collection + +KtFunctionSymbol: + callableIdIfNonLocal: java/util/Collection.toArray + name: toArray + origin: JAVA + getDispatchReceiver(): java/util/Collection + +KtFunctionSymbol: + callableIdIfNonLocal: test/MyList.add + name: add + origin: JAVA + getDispatchReceiver(): test/MyList + +KtFunctionSymbol: + callableIdIfNonLocal: java/util/Collection.remove + name: remove + origin: JAVA + getDispatchReceiver(): java/util/Collection + +KtFunctionSymbol: + callableIdIfNonLocal: java/util/Collection.containsAll + name: containsAll + origin: JAVA + getDispatchReceiver(): java/util/Collection + +KtFunctionSymbol: + callableIdIfNonLocal: test/MyList.addAll + name: addAll + origin: JAVA + getDispatchReceiver(): test/MyList + +KtFunctionSymbol: + callableIdIfNonLocal: java/util/Collection.removeAll + name: removeAll + origin: JAVA + getDispatchReceiver(): java/util/Collection + +KtFunctionSymbol: + callableIdIfNonLocal: java/util/Collection.retainAll + name: retainAll + origin: JAVA + getDispatchReceiver(): java/util/Collection + +KtFunctionSymbol: + callableIdIfNonLocal: java/util/Collection.clear + name: clear + origin: JAVA + getDispatchReceiver(): java/util/Collection + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED diff --git a/analysis/analysis-api/testData/scopes/memberScopeByFqName/overridenFunctionWithGenericBound.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberFunctionWithOuterTypeParameterBound.kt similarity index 76% rename from analysis/analysis-api/testData/scopes/memberScopeByFqName/overridenFunctionWithGenericBound.kt rename to analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberFunctionWithOuterTypeParameterBound.kt index 773cd5f1046..5fc22156abe 100644 --- a/analysis/analysis-api/testData/scopes/memberScopeByFqName/overridenFunctionWithGenericBound.kt +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberFunctionWithOuterTypeParameterBound.kt @@ -1,7 +1,5 @@ -// DO_NOT_CHECK_SYMBOL_RESTORE package test - interface OtherInterface interface TwoParams @@ -14,6 +12,4 @@ interface MyInterface { class Foo -abstract class MyClass : MyInterface - -// class: test/MyClass \ No newline at end of file +abstract class MyClass : MyInterface diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberFunctionWithOuterTypeParameterBound.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberFunctionWithOuterTypeParameterBound.txt new file mode 100644 index 00000000000..b91a6a6b7fb --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberFunctionWithOuterTypeParameterBound.txt @@ -0,0 +1,33 @@ +KtFunctionSymbol: + callableIdIfNonLocal: test/MyClass.funWithOuterAndOwnGenericsAndBounds + name: funWithOuterAndOwnGenericsAndBounds + origin: SOURCE + getDispatchReceiver(): test/MyClass + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/MyClass.propWithOuterAndOwnGenericsAndBounds + name: propWithOuterAndOwnGenericsAndBounds + origin: SOURCE + getDispatchReceiver(): test/MyClass + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED \ No newline at end of file diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberPropertyWithOuterTypeParameterBound.kt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberPropertyWithOuterTypeParameterBound.kt new file mode 100644 index 00000000000..044dd427e6d --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberPropertyWithOuterTypeParameterBound.kt @@ -0,0 +1,11 @@ +package test + +interface ClassA +interface ClassB + +interface MyInterface { + val Own.withOwnGeneric_InterfaceWithValBase: ClassA + val Own.withOwnAndOuterGenericAsTypeBound_InterfaceWithValBase: ClassA +} + +abstract class Inheritor : MyInterface diff --git a/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberPropertyWithOuterTypeParameterBound.txt b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberPropertyWithOuterTypeParameterBound.txt new file mode 100644 index 00000000000..f569a32b88a --- /dev/null +++ b/analysis/analysis-api/testData/scopes/substitutionOverridesUnwrapping/MemberPropertyWithOuterTypeParameterBound.txt @@ -0,0 +1,33 @@ +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/MyInterface.withOwnGeneric_InterfaceWithValBase + name: withOwnGeneric_InterfaceWithValBase + origin: SOURCE + getDispatchReceiver(): test/MyInterface + +KtKotlinPropertySymbol: + callableIdIfNonLocal: test/Inheritor.withOwnAndOuterGenericAsTypeBound_InterfaceWithValBase + name: withOwnAndOuterGenericAsTypeBound_InterfaceWithValBase + origin: SOURCE + getDispatchReceiver(): test/Inheritor + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.equals + name: equals + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.hashCode + name: hashCode + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtFunctionSymbol: + callableIdIfNonLocal: kotlin/Any.toString + name: toString + origin: LIBRARY + getDispatchReceiver(): kotlin/Any + +KtConstructorSymbol: + callableIdIfNonLocal: null + origin: SOURCE_MEMBER_GENERATED diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/genericFromFunctionInLocalClass.kt b/analysis/analysis-api/testData/symbols/symbolByReference/genericFromFunctionInLocalClass.kt new file mode 100644 index 00000000000..3aeeb613330 --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/genericFromFunctionInLocalClass.kt @@ -0,0 +1,14 @@ +// DO_NOT_CHECK_SYMBOL_RESTORE +package test + +class SomeClass + +fun topLevel() { + open class Base { + fun withOuter(): Outer? = null + } + + class Child : Base() {} + + Child().withOuter() +} \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/genericFromFunctionInLocalClass.txt b/analysis/analysis-api/testData/symbols/symbolByReference/genericFromFunctionInLocalClass.txt new file mode 100644 index 00000000000..5d6c9f3dabf --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/genericFromFunctionInLocalClass.txt @@ -0,0 +1,23 @@ +KtFunctionSymbol: + annotationsList: [] + callableIdIfNonLocal: null + hasStableParameterNames: true + isExtension: false + isExternal: false + isInfix: false + isInline: false + isOperator: false + isOverride: false + isStatic: false + isSuspend: false + modality: FINAL + name: withOuter + origin: SOURCE + receiverType: null + returnType: Outer? + symbolKind: CLASS_MEMBER + typeParameters: [] + valueParameters: [] + visibility: Public + getDispatchReceiver(): test/Base + deprecationStatus: null diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/genericFromOuterClassInInnerClass.descriptors.txt b/analysis/analysis-api/testData/symbols/symbolByReference/genericFromOuterClassInInnerClass.descriptors.txt new file mode 100644 index 00000000000..472d06ae238 --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/genericFromOuterClassInInnerClass.descriptors.txt @@ -0,0 +1,23 @@ +KtFunctionSymbol: + annotationsList: [] + callableIdIfNonLocal: test/TopLevel.Child.withOuter + hasStableParameterNames: true + isExtension: false + isExternal: false + isInfix: false + isInline: false + isOperator: false + isOverride: false + isStatic: false + isSuspend: false + modality: FINAL + name: withOuter + origin: SOURCE + receiverType: null + returnType: Outer? + symbolKind: CLASS_MEMBER + typeParameters: [] + valueParameters: [] + visibility: Public + getDispatchReceiver(): test/TopLevel.test/TopLevel.Base + deprecationStatus: null diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/genericFromOuterClassInInnerClass.kt b/analysis/analysis-api/testData/symbols/symbolByReference/genericFromOuterClassInInnerClass.kt new file mode 100644 index 00000000000..c72010b87a4 --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/genericFromOuterClassInInnerClass.kt @@ -0,0 +1,16 @@ +// DO_NOT_CHECK_SYMBOL_RESTORE +package test + +class SomeClass + +class TopLevel { + inner open class Base { + fun withOuter(): Outer? = null + } + + inner class Child : Base {} + + fun usage() { + Child().withOuter() + } +} diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/genericFromOuterClassInInnerClass.txt b/analysis/analysis-api/testData/symbols/symbolByReference/genericFromOuterClassInInnerClass.txt new file mode 100644 index 00000000000..61307716347 --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/genericFromOuterClassInInnerClass.txt @@ -0,0 +1,23 @@ +KtFunctionSymbol: + annotationsList: [] + callableIdIfNonLocal: test/TopLevel.Base.withOuter + hasStableParameterNames: true + isExtension: false + isExternal: false + isInfix: false + isInline: false + isOperator: false + isOverride: false + isStatic: false + isSuspend: false + modality: FINAL + name: withOuter + origin: SOURCE + receiverType: null + returnType: Outer? + symbolKind: CLASS_MEMBER + typeParameters: [] + valueParameters: [] + visibility: Public + getDispatchReceiver(): test/TopLevel.Base + deprecationStatus: null diff --git a/generators/analysis-api-generator/tests/org/jetbrains/kotlin/generators/tests/analysis/api/analysisApi.kt b/generators/analysis-api-generator/tests/org/jetbrains/kotlin/generators/tests/analysis/api/analysisApi.kt index 9772eb94c7b..e9f074b9f94 100644 --- a/generators/analysis-api-generator/tests/org/jetbrains/kotlin/generators/tests/analysis/api/analysisApi.kt +++ b/generators/analysis-api-generator/tests/org/jetbrains/kotlin/generators/tests/analysis/api/analysisApi.kt @@ -44,6 +44,7 @@ import org.jetbrains.kotlin.analysis.api.fir.components.typeProvider.AbstractFir import org.jetbrains.kotlin.analysis.api.fir.components.typeProvider.AbstractFirHasCommonSubtypeTest import org.jetbrains.kotlin.analysis.api.fir.scopes.AbstractFirDelegateMemberScopeTest import org.jetbrains.kotlin.analysis.api.fir.scopes.AbstractFirFileScopeTest +import org.jetbrains.kotlin.analysis.api.fir.scopes.AbstractFirSubstitutionOverridesUnwrappingTest import org.jetbrains.kotlin.analysis.api.fir.scopes.AbstractFirMemberScopeByFqNameTest import org.jetbrains.kotlin.analysis.api.fir.symbols.AbstractFirSymbolByFqNameTest import org.jetbrains.kotlin.analysis.api.fir.symbols.AbstractFirSymbolByPsiTest @@ -64,6 +65,13 @@ private fun TestGroupSuite.generateAnalysisApiNonComponentsTests() { } group("scopes") { + test( + fir = AbstractFirSubstitutionOverridesUnwrappingTest::class, + fe10 = null, + ) { + model("substitutionOverridesUnwrapping") + } + test( fir = AbstractFirMemberScopeByFqNameTest::class, fe10 = null,