From dd059a1e63af4a4a2166457f4580a4e58a14f11d Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Wed, 14 Jun 2023 11:11:13 +0200 Subject: [PATCH] [LL] find fir by psi: allow fallthrough to traverse tree for invalid code In case of broken code e.g., duplicated classes provider would return first class, though we definitely need some code insight in this case at least to add navigation fixes, etc. Similar to this, a file copy is created during completion, where additional elements might appear and we need to search for them. Added test cases for duplicated classes. --- ...alysisApiPsiTypeProviderTestGenerated.java | 6 + ...alysisApiPsiTypeProviderTestGenerated.java | 6 + ...alysisApiPsiTypeProviderTestGenerated.java | 6 + ...alysisApiPsiTypeProviderTestGenerated.java | 6 + .../duplicatedClass_functionParameter.kt | 6 + .../duplicatedClass_functionParameter.txt | 2 + .../level/api/fir/util/declarationUtils.kt | 37 +-- .../invalidCode/duplicatedClasses.kt | 6 + .../invalidCode/duplicatedClasses.txt | 7 + .../duplicatedClassesFunctionParameter.kt | 6 + .../duplicatedClassesFunctionParameter.txt | 6 + .../lazyResolve/typeParameterOfClass2.kt | 10 + .../lazyResolve/typeParameterOfClass2.txt | 237 ++++++++++++++++++ ...otLazyDeclarationResolveTestGenerated.java | 6 + ...ceLazyDeclarationResolveTestGenerated.java | 6 + ...ContentRootGetOrBuildFirTestGenerated.java | 12 + .../fir/SourceGetOrBuildFirTestGenerated.java | 12 + 17 files changed, 347 insertions(+), 30 deletions(-) create mode 100644 analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.kt create mode 100644 analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.txt create mode 100644 analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClasses.kt create mode 100644 analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClasses.txt create mode 100644 analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClassesFunctionParameter.kt create mode 100644 analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClassesFunctionParameter.txt create mode 100644 analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass2.kt create mode 100644 analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass2.txt diff --git a/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/components/psiTypeProvider/Fe10IdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java b/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/components/psiTypeProvider/Fe10IdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java index c291c1a8e3a..8ab66d5af33 100644 --- a/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/components/psiTypeProvider/Fe10IdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java +++ b/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/components/psiTypeProvider/Fe10IdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java @@ -64,6 +64,12 @@ public class Fe10IdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGene runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/anonymousObject_exposedAsReturnValue.kt"); } + @Test + @TestMetadata("duplicatedClass_functionParameter.kt") + public void testDuplicatedClass_functionParameter() throws Exception { + runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.kt"); + } + @Test @TestMetadata("errorTypeInNestedTypeArgument.kt") public void testErrorTypeInNestedTypeArgument() throws Exception { diff --git a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/psiTypeProvider/FirIdeDependentAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/psiTypeProvider/FirIdeDependentAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java index c437988896a..36900be5f01 100644 --- a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/psiTypeProvider/FirIdeDependentAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java +++ b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/psiTypeProvider/FirIdeDependentAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java @@ -64,6 +64,12 @@ public class FirIdeDependentAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGe runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/anonymousObject_exposedAsReturnValue.kt"); } + @Test + @TestMetadata("duplicatedClass_functionParameter.kt") + public void testDuplicatedClass_functionParameter() throws Exception { + runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.kt"); + } + @Test @TestMetadata("errorTypeInNestedTypeArgument.kt") public void testErrorTypeInNestedTypeArgument() throws Exception { diff --git a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/psiTypeProvider/FirIdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/psiTypeProvider/FirIdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java index 328703836f0..4e27c4f30d7 100644 --- a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/psiTypeProvider/FirIdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java +++ b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/psiTypeProvider/FirIdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java @@ -64,6 +64,12 @@ public class FirIdeNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGener runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/anonymousObject_exposedAsReturnValue.kt"); } + @Test + @TestMetadata("duplicatedClass_functionParameter.kt") + public void testDuplicatedClass_functionParameter() throws Exception { + runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.kt"); + } + @Test @TestMetadata("errorTypeInNestedTypeArgument.kt") public void testErrorTypeInNestedTypeArgument() throws Exception { diff --git a/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/psiTypeProvider/FirStandaloneNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java b/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/psiTypeProvider/FirStandaloneNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java index c333ea5d90e..7ffbbb8c0da 100644 --- a/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/psiTypeProvider/FirStandaloneNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java +++ b/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/components/psiTypeProvider/FirStandaloneNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTestGenerated.java @@ -64,6 +64,12 @@ public class FirStandaloneNormalAnalysisSourceModuleAnalysisApiPsiTypeProviderTe runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/anonymousObject_exposedAsReturnValue.kt"); } + @Test + @TestMetadata("duplicatedClass_functionParameter.kt") + public void testDuplicatedClass_functionParameter() throws Exception { + runTest("analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.kt"); + } + @Test @TestMetadata("errorTypeInNestedTypeArgument.kt") public void testErrorTypeInNestedTypeArgument() throws Exception { diff --git a/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.kt b/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.kt new file mode 100644 index 00000000000..7a95b93b38a --- /dev/null +++ b/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.kt @@ -0,0 +1,6 @@ +class SomeClass { + val prop = "abc" +} +class SomeClass { + fun foo(p: Int) {} +} \ No newline at end of file diff --git a/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.txt b/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.txt new file mode 100644 index 00000000000..d2d0b0655d1 --- /dev/null +++ b/analysis/analysis-api/testData/components/psiTypeProvider/psiType/forDeclaration/duplicatedClass_functionParameter.txt @@ -0,0 +1,2 @@ +KtType: kotlin.Int +PsiType: PsiType:int diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/declarationUtils.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/declarationUtils.kt index 89ef3e7443a..64301d608ef 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/declarationUtils.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/util/declarationUtils.kt @@ -127,11 +127,11 @@ private fun KtDeclaration.findSourceNonLocalFirDeclarationByProvider( } this is KtScript -> containerFirFile?.declarations?.singleOrNull { it is FirScript } this is KtPropertyAccessor -> { - val firPropertyDeclaration = property.nonLocalFirDeclaration( + val firPropertyDeclaration = property.findSourceNonLocalFirDeclarationByProvider( firFileBuilder, provider, containerFirFile, - ) + ) as? FirVariable ?: return null if (isGetter) { firPropertyDeclaration.getter @@ -143,11 +143,11 @@ private fun KtDeclaration.findSourceNonLocalFirDeclarationByProvider( val ownerFunction = ownerFunction ?: errorWithFirSpecificEntries("Containing function should be not null for KtParameter", psi = this) - val firFunctionDeclaration = ownerFunction.nonLocalFirDeclaration( + val firFunctionDeclaration = ownerFunction.findSourceNonLocalFirDeclarationByProvider( firFileBuilder, provider, containerFirFile, - ) + ) as? FirFunction ?: return null firFunctionDeclaration.valueParameters[parameterIndex()] } @@ -155,42 +155,19 @@ private fun KtDeclaration.findSourceNonLocalFirDeclarationByProvider( val declaration = containingDeclaration ?: errorWithFirSpecificEntries("Containing declaration should be not null for KtTypeParameter", psi = this) - val firTypeParameterOwner = declaration.nonLocalFirDeclaration( + val firTypeParameterOwner = declaration.findSourceNonLocalFirDeclarationByProvider( firFileBuilder, provider, containerFirFile, - ) + ) as? FirTypeParameterRefsOwner ?: return null - val index = (parent as KtTypeParameterList).parameters.indexOf(this) - firTypeParameterOwner.typeParameters[index] as FirDeclaration + firTypeParameterOwner.typeParameters.firstOrNull { it.psi == this } as FirDeclaration } else -> errorWithFirSpecificEntries("Invalid container", psi = this) } return candidate?.takeIf { it.realPsi == this } } -private inline fun KtDeclaration.nonLocalFirDeclaration( - firFileBuilder: LLFirFileBuilder, - provider: FirProvider, - containerFirFile: FirFile?, -): T { - val firResult = findSourceNonLocalFirDeclarationByProvider( - firFileBuilder, - provider, - containerFirFile, - ) - - if (firResult !is T) { - errorWithFirSpecificEntries( - "${T::class.simpleName} for ${this::class.simpleName} declaration is not found", - psi = this, - fir = firResult, - ) - } - - return firResult -} - fun FirAnonymousInitializer.containingClass(): FirRegularClass { val dispatchReceiverType = this.dispatchReceiverType as? ConeLookupTagBasedType ?: error("dispatchReceiverType for FirAnonymousInitializer modifier cannot be null") diff --git a/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClasses.kt b/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClasses.kt new file mode 100644 index 00000000000..14e620e3c04 --- /dev/null +++ b/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClasses.kt @@ -0,0 +1,6 @@ +class SomeClass { + val prop = "abc" +} +class SomeClass { + fun foo() {} +} \ No newline at end of file diff --git a/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClasses.txt b/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClasses.txt new file mode 100644 index 00000000000..0b3effb65b6 --- /dev/null +++ b/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClasses.txt @@ -0,0 +1,7 @@ +KT element: KtNamedFunction +FIR element: FirSimpleFunctionImpl +FIR source kind: KtRealSourceElementKind + +FIR element rendered: +public final [ResolvedTo(BODY_RESOLVE)] fun foo(): R|kotlin/Unit| { +} diff --git a/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClassesFunctionParameter.kt b/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClassesFunctionParameter.kt new file mode 100644 index 00000000000..5ad44e2ea21 --- /dev/null +++ b/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClassesFunctionParameter.kt @@ -0,0 +1,6 @@ +class SomeClass { + val prop = "abc" +} +class SomeClass { + fun foo(p: Int) {} +} \ No newline at end of file diff --git a/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClassesFunctionParameter.txt b/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClassesFunctionParameter.txt new file mode 100644 index 00000000000..de147ce665d --- /dev/null +++ b/analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClassesFunctionParameter.txt @@ -0,0 +1,6 @@ +KT element: KtParameter +FIR element: FirValueParameterImpl +FIR source kind: KtRealSourceElementKind + +FIR element rendered: +[ResolvedTo(BODY_RESOLVE)] p: R|kotlin/Int| diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass2.kt b/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass2.kt new file mode 100644 index 00000000000..3ba2f99fca0 --- /dev/null +++ b/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass2.kt @@ -0,0 +1,10 @@ +/* + * Copyright 2010-2023 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. + */ + +class MyClass { + inner class Seconde2> { + + } +} \ No newline at end of file diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass2.txt b/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass2.txt new file mode 100644 index 00000000000..bb52025f502 --- /dev/null +++ b/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass2.txt @@ -0,0 +1,237 @@ +RAW_FIR: +FILE: [ResolvedTo(RAW_FIR)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public? final? [ResolvedTo(RAW_FIR)] class MyClass<[ResolvedTo(RAW_FIR)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(RAW_FIR)] Type>(): R|MyClass| { + LAZY_super + } + + public? final? inner [ResolvedTo(RAW_FIR)] class Second<[ResolvedTo(RAW_FIR)] Type2, [ResolvedTo(RAW_FIR)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(RAW_FIR)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +IMPORTS: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public? final? [ResolvedTo(RAW_FIR)] class MyClass<[ResolvedTo(RAW_FIR)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(RAW_FIR)] Type>(): R|MyClass| { + LAZY_super + } + + public? final? inner [ResolvedTo(RAW_FIR)] class Second<[ResolvedTo(RAW_FIR)] Type2, [ResolvedTo(RAW_FIR)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(RAW_FIR)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +COMPILER_REQUIRED_ANNOTATIONS: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public? final? [ResolvedTo(RAW_FIR)] class MyClass<[ResolvedTo(RAW_FIR)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(RAW_FIR)] Type>(): R|MyClass| { + LAZY_super + } + + public? final? inner [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] class Second<[ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] Type2, [ResolvedTo(RAW_FIR)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +COMPANION_GENERATION: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public? final? [ResolvedTo(RAW_FIR)] class MyClass<[ResolvedTo(RAW_FIR)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(RAW_FIR)] Type>(): R|MyClass| { + LAZY_super + } + + public? final? inner [ResolvedTo(COMPANION_GENERATION)] class Second<[ResolvedTo(COMPANION_GENERATION)] Type2, [ResolvedTo(RAW_FIR)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(COMPANION_GENERATION)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +SUPER_TYPES: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public? final? [ResolvedTo(SUPER_TYPES)] class MyClass<[ResolvedTo(SUPER_TYPES)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(SUPER_TYPES)] Type>(): R|MyClass| { + LAZY_super + } + + public? final? inner [ResolvedTo(SUPER_TYPES)] class Second<[ResolvedTo(SUPER_TYPES)] Type2, [ResolvedTo(SUPER_TYPES)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(SUPER_TYPES)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +TYPES: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public? final? [ResolvedTo(TYPES)] class MyClass<[ResolvedTo(TYPES)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(TYPES)] Type>(): R|MyClass| { + LAZY_super + } + + public? final? inner [ResolvedTo(TYPES)] class Second<[ResolvedTo(TYPES)] Type2, [ResolvedTo(TYPES)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(TYPES)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +STATUS: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public final [ResolvedTo(STATUS)] class MyClass<[ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(STATUS)] Type>(): R|MyClass| { + LAZY_super + } + + public final inner [ResolvedTo(STATUS)] class Second<[ResolvedTo(STATUS)] Type2, [ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(STATUS)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +EXPECT_ACTUAL_MATCHING: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public final [ResolvedTo(STATUS)] class MyClass<[ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(STATUS)] Type>(): R|MyClass| { + LAZY_super + } + + public final inner [ResolvedTo(EXPECT_ACTUAL_MATCHING)] class Second<[ResolvedTo(EXPECT_ACTUAL_MATCHING)] Type2, [ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(EXPECT_ACTUAL_MATCHING)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +ARGUMENTS_OF_ANNOTATIONS: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public final [ResolvedTo(STATUS)] class MyClass<[ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(STATUS)] Type>(): R|MyClass| { + LAZY_super + } + + public final inner [ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] class Second<[ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] Type2, [ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +CONTRACTS: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public final [ResolvedTo(STATUS)] class MyClass<[ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(STATUS)] Type>(): R|MyClass| { + LAZY_super + } + + public final inner [ResolvedTo(CONTRACTS)] class Second<[ResolvedTo(CONTRACTS)] Type2, [ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(CONTRACTS)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +IMPLICIT_TYPES_BODY_RESOLVE: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public final [ResolvedTo(STATUS)] class MyClass<[ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(STATUS)] Type>(): R|MyClass| { + LAZY_super + } + + public final inner [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] class Second<[ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] Type2, [ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +ANNOTATIONS_ARGUMENTS_MAPPING: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public final [ResolvedTo(STATUS)] class MyClass<[ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(STATUS)] Type>(): R|MyClass| { + LAZY_super + } + + public final inner [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] class Second<[ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] Type2, [ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] Type2>(): R|MyClass.Second| { + LAZY_super + } + + } + + } + +BODY_RESOLVE: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public final [ResolvedTo(STATUS)] class MyClass<[ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(STATUS)] Type>(): R|MyClass| { + LAZY_super + } + + public final inner [ResolvedTo(BODY_RESOLVE)] class Second<[ResolvedTo(BODY_RESOLVE)] Type2, [ResolvedTo(STATUS)] Type> : R|kotlin/Any| { + public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(BODY_RESOLVE)] Type2>(): R|MyClass.Second| { + super() + } + + } + + } + +FILE RAW TO BODY: +FILE: [ResolvedTo(IMPORTS)] typeParameterOfClass2.kt + [ResolvedTo(BODY_RESOLVE)] annotations container + public final [ResolvedTo(BODY_RESOLVE)] class MyClass<[ResolvedTo(BODY_RESOLVE)] Type> : R|kotlin/Any| { + public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=MyClass] constructor<[ResolvedTo(BODY_RESOLVE)] Type>(): R|MyClass| { + super() + } + + public final inner [ResolvedTo(BODY_RESOLVE)] class Second<[ResolvedTo(BODY_RESOLVE)] Type2, [ResolvedTo(BODY_RESOLVE)] Type> : R|kotlin/Any| { + public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=Second] MyClass.constructor<[ResolvedTo(BODY_RESOLVE)] Type2>(): R|MyClass.Second| { + super() + } + + } + + } diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirOutOfContentRootLazyDeclarationResolveTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirOutOfContentRootLazyDeclarationResolveTestGenerated.java index 87b787180d4..c9f3e1b70d1 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirOutOfContentRootLazyDeclarationResolveTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirOutOfContentRootLazyDeclarationResolveTestGenerated.java @@ -444,6 +444,12 @@ public class FirOutOfContentRootLazyDeclarationResolveTestGenerated extends Abst runTest("analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass.kt"); } + @Test + @TestMetadata("typeParameterOfClass2.kt") + public void testTypeParameterOfClass2() throws Exception { + runTest("analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass2.kt"); + } + @Test @TestMetadata("typeParameterOfNonLocalFunction.kt") public void testTypeParameterOfNonLocalFunction() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirSourceLazyDeclarationResolveTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirSourceLazyDeclarationResolveTestGenerated.java index 0e2da1b1663..3a88e5f20f9 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirSourceLazyDeclarationResolveTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/FirSourceLazyDeclarationResolveTestGenerated.java @@ -444,6 +444,12 @@ public class FirSourceLazyDeclarationResolveTestGenerated extends AbstractFirSou runTest("analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass.kt"); } + @Test + @TestMetadata("typeParameterOfClass2.kt") + public void testTypeParameterOfClass2() throws Exception { + runTest("analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfClass2.kt"); + } + @Test @TestMetadata("typeParameterOfNonLocalFunction.kt") public void testTypeParameterOfNonLocalFunction() 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 890499db3c8..552de8d7f5b 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 @@ -805,6 +805,18 @@ public class OutOfContentRootGetOrBuildFirTestGenerated extends AbstractOutOfCon runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/delegatedProperty.kt"); } + @Test + @TestMetadata("duplicatedClasses.kt") + public void testDuplicatedClasses() throws Exception { + runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClasses.kt"); + } + + @Test + @TestMetadata("duplicatedClassesFunctionParameter.kt") + public void testDuplicatedClassesFunctionParameter() throws Exception { + runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClassesFunctionParameter.kt"); + } + @Test @TestMetadata("incompletePropertyWithAnnotation.kt") public void testIncompletePropertyWithAnnotation() 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 b39b07d7d92..b0691d98b0f 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 @@ -805,6 +805,18 @@ public class SourceGetOrBuildFirTestGenerated extends AbstractSourceGetOrBuildFi runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/delegatedProperty.kt"); } + @Test + @TestMetadata("duplicatedClasses.kt") + public void testDuplicatedClasses() throws Exception { + runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClasses.kt"); + } + + @Test + @TestMetadata("duplicatedClassesFunctionParameter.kt") + public void testDuplicatedClassesFunctionParameter() throws Exception { + runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/invalidCode/duplicatedClassesFunctionParameter.kt"); + } + @Test @TestMetadata("incompletePropertyWithAnnotation.kt") public void testIncompletePropertyWithAnnotation() throws Exception {