KTIJ-27050 [Analysis API] Correctly handle type parameters in KtFirReferenceShortener

Make `FirShorteningContext` correctly return symbols for type
parameters, so they are not ignored when scopes are inspected

Add additional type of `PartialOrderOfScope` - `TypeParameter`, because
otherwise it would have been classified as `Unclassified`, and that
breaks scopes comparison

Add missing type parameters to the scope of class header in
`ContextCollector`, add testdata for that

There is a bug in the compiler with type parameters leaking to nested
classes headers (KT-61959). After it's fixed, the testData with
incorrect expected shortenings/scopes should be adjusted and fixed too

^KTIJ-27050 Fixed
This commit is contained in:
Roman Golyshev
2023-09-14 17:06:15 +02:00
committed by teamcity
parent e2019ceb95
commit a78d631b16
29 changed files with 560 additions and 12 deletions
@@ -755,4 +755,38 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerTestGenera
}
}
}
@Nested
@TestMetadata("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters")
@TestDataPath("$PROJECT_ROOT")
public class TypeParameters {
@Test
public void testAllFilesPresentInTypeParameters() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("functionTypeParameterVsType.kt")
public void testFunctionTypeParameterVsType() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/functionTypeParameterVsType.kt");
}
@Test
@TestMetadata("typeParameterVsNestedType.kt")
public void testTypeParameterVsNestedType() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/typeParameterVsNestedType.kt");
}
@Test
@TestMetadata("typeParameterVsType_conflict.kt")
public void testTypeParameterVsType_conflict() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/typeParameterVsType_conflict.kt");
}
@Test
@TestMetadata("typeParameterVsType_noConflict.kt")
public void testTypeParameterVsType_noConflict() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/typeParameters/typeParameterVsType_noConflict.kt");
}
}
}