KTIJ-26576 [Analysis API] Add where clause to classHeaderParts in FirTowerDataContextAllElementsCollector

In `where` clause there are type constraints, and there are no
supertypes scopes at those positions

^KTIJ-26576 Fixed
This commit is contained in:
Roman Golyshev
2023-08-08 23:28:20 +02:00
committed by teamcity
parent 5b0c075c8d
commit 71a4f36faf
5 changed files with 27 additions and 0 deletions
@@ -645,6 +645,12 @@ public class FirIdeNormalAnalysisSourceModuleReferenceShortenerTestGenerated ext
public void testTypeBound_nested() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses/classHeaderPositions/typeBound_nested.kt");
}
@Test
@TestMetadata("typeBound_whereClause.kt")
public void testTypeBound_whereClause() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses/classHeaderPositions/typeBound_whereClause.kt");
}
}
}
}
@@ -645,6 +645,12 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerTestGenera
public void testTypeBound_nested() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses/classHeaderPositions/typeBound_nested.kt");
}
@Test
@TestMetadata("typeBound_whereClause.kt")
public void testTypeBound_whereClause() throws Exception {
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/nestedClasses/classHeaderPositions/typeBound_whereClause.kt");
}
}
}
}
@@ -0,0 +1,7 @@
// FILE: main.kt
abstract class Outer {
abstract class Nested : Outer()
}
class Foo<T> : Outer.Nested() where T : <expr>Outer.Nested</expr>
@@ -0,0 +1,7 @@
Before shortening: Outer.Nested
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
with SHORTEN_AND_IMPORT:
[type] Outer.Nested
with SHORTEN_AND_STAR_IMPORT:
[type] Outer.Nested
@@ -157,6 +157,7 @@ private fun KtClassOrObject.containsInHeader(element: PsiElement): Boolean {
addIfNotNull(getContextReceiverList())
addIfNotNull(modifierList) // for annotations declared on class
addIfNotNull(typeParameterList)
addIfNotNull(typeConstraintList) // `where` clause type constraints
for (superTypeEntry in superTypeListEntries) {
addIfNotNull(superTypeEntry.typeReference)