[AA] Consider context receivers in FirTowerDataElement.getAvailableScope
This commit is contained in:
committed by
teamcity
parent
5996b41443
commit
d89d774411
+4
-3
@@ -236,9 +236,10 @@ private class FirShorteningContext(val analysisSession: KtFirAnalysisSession) {
|
||||
): List<FirScope>? {
|
||||
val towerDataContext = towerContextProvider.getClosestAvailableParentContext(position) ?: return null
|
||||
val result = buildList {
|
||||
addAll(towerDataContext.nonLocalTowerDataElements.mapNotNull {
|
||||
// We must use `it.getAvailableScope()` instead of `it.scope` to check scopes of companion objects as well.
|
||||
it.getAvailableScope()
|
||||
addAll(towerDataContext.nonLocalTowerDataElements.flatMap {
|
||||
// We must use `it.getAvailableScopes()` instead of `it.scope` to check scopes of companion objects
|
||||
// and context receivers as well.
|
||||
it.getAvailableScopes()
|
||||
})
|
||||
addIfNotNull(createFakeImportingScope(newImports))
|
||||
addAll(towerDataContext.localScopes)
|
||||
|
||||
+6
@@ -160,6 +160,12 @@ public class FirIdeNormalAnalysisSourceModuleReferenceShortenerTestGenerated ext
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/companionUsedOutOfClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextReceiver.kt")
|
||||
public void testContextReceiver() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/contextReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumClassCompanionAlreadyImported.kt")
|
||||
public void testEnumClassCompanionAlreadyImported() throws Exception {
|
||||
|
||||
+6
@@ -160,6 +160,12 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceShortenerTestGenera
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/companionUsedOutOfClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("contextReceiver.kt")
|
||||
public void testContextReceiver() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/components/referenceShortener/referenceShortener/contextReceiver.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enumClassCompanionAlreadyImported.kt")
|
||||
public void testEnumClassCompanionAlreadyImported() throws Exception {
|
||||
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: main.kt
|
||||
package a.b.c
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
}
|
||||
fun foo() = 1
|
||||
|
||||
context(A)
|
||||
fun test() {
|
||||
<expr>a.b.c.foo()</expr>
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
Before shortening: a.b.c.foo()
|
||||
with DO_NOT_SHORTEN:
|
||||
with SHORTEN_IF_ALREADY_IMPORTED:
|
||||
with SHORTEN_AND_IMPORT:
|
||||
with SHORTEN_AND_STAR_IMPORT:
|
||||
Reference in New Issue
Block a user