KT-64080 [LL] Resolve super calls to BODY_RESOLVE for on-air resolve
^KT-64080 Fixed
This commit is contained in:
+19
-1
@@ -456,13 +456,31 @@ object LowLevelFirApiFacadeForResolveOnAir {
|
|||||||
|
|
||||||
private fun bodyResolveRequired(container: KtDeclaration, elementToReplace: PsiElement): Boolean = when {
|
private fun bodyResolveRequired(container: KtDeclaration, elementToReplace: PsiElement): Boolean = when {
|
||||||
container == elementToReplace -> true
|
container == elementToReplace -> true
|
||||||
container is KtDeclarationWithBody -> container.bodyExpression.isAncestor(elementToReplace)
|
|
||||||
|
container is KtDeclarationWithBody -> {
|
||||||
|
val bodyExpression = container.bodyExpression
|
||||||
|
val secondaryConstructorSuperCallArgs = (container as? KtSecondaryConstructor)?.getDelegationCallOrNull()?.valueArgumentList
|
||||||
|
|
||||||
|
bodyExpression.isAncestor(elementToReplace) || secondaryConstructorSuperCallArgs.isAncestor(elementToReplace)
|
||||||
|
}
|
||||||
|
|
||||||
container is KtProperty -> container.delegateExpressionOrInitializer.isAncestor(elementToReplace)
|
container is KtProperty -> container.delegateExpressionOrInitializer.isAncestor(elementToReplace)
|
||||||
container is KtParameter -> container.defaultValue.isAncestor(elementToReplace)
|
container is KtParameter -> container.defaultValue.isAncestor(elementToReplace)
|
||||||
|
|
||||||
container is KtEnumEntry -> {
|
container is KtEnumEntry -> {
|
||||||
container.initializerList.isAncestor(elementToReplace) || container.body.isAncestor(elementToReplace)
|
container.initializerList.isAncestor(elementToReplace) || container.body.isAncestor(elementToReplace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
container is KtClassOrObject -> {
|
||||||
|
container.superTypeListEntries.any { superTypeEntry ->
|
||||||
|
when (superTypeEntry) {
|
||||||
|
is KtSuperTypeCallEntry -> superTypeEntry.valueArgumentList.isAncestor(elementToReplace)
|
||||||
|
is KtDelegatedSuperTypeEntry -> superTypeEntry.delegateExpression.isAncestor(elementToReplace)
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
container is KtScript || container is KtAnonymousInitializer -> true
|
container is KtScript || container is KtAnonymousInitializer -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
|||||||
analysis/low-level-api-fir/testData/dependentCopy/superCallArgument_delegatedConstructor.context.txt
Vendored
+19
@@ -0,0 +1,19 @@
|
|||||||
|
Tower Data Context:
|
||||||
|
Element 0
|
||||||
|
Scope: FirDefaultStarImportingScope
|
||||||
|
Element 1
|
||||||
|
Scope: FirExplicitStarImportingScope
|
||||||
|
Element 2
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 3
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 4
|
||||||
|
Scope: FirPackageMemberScope
|
||||||
|
Element 5
|
||||||
|
Scope: FirExplicitSimpleImportingScope
|
||||||
|
Element 6
|
||||||
|
Implicit receiver:
|
||||||
|
FirRegularClassSymbol public final class MyClass : R|kotlin/Any|
|
||||||
|
Type: test.MyClass
|
||||||
|
Element 7
|
||||||
|
Scope: FirLocalScope
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
KT element: KtNameReferenceExpression
|
||||||
|
FIR element: FirPropertyAccessExpressionImpl
|
||||||
|
FIR source kind: KtRealSourceElementKind
|
||||||
|
|
||||||
|
FIR element rendered:
|
||||||
|
R|test/property|
|
||||||
Vendored
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
val property = 10
|
||||||
|
|
||||||
|
class MyClass(i: Int) {
|
||||||
|
constructor(): this(prop<caret>erty)
|
||||||
|
}
|
||||||
Vendored
+19
@@ -0,0 +1,19 @@
|
|||||||
|
Tower Data Context:
|
||||||
|
Element 0
|
||||||
|
Scope: FirDefaultStarImportingScope
|
||||||
|
Element 1
|
||||||
|
Scope: FirExplicitStarImportingScope
|
||||||
|
Element 2
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 3
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 4
|
||||||
|
Scope: FirPackageMemberScope
|
||||||
|
Element 5
|
||||||
|
Scope: FirExplicitSimpleImportingScope
|
||||||
|
Element 6
|
||||||
|
Implicit receiver:
|
||||||
|
FirRegularClassSymbol public final class Child : R|test/Base|
|
||||||
|
Type: test.Child
|
||||||
|
Element 7
|
||||||
|
Scope: FirLocalScope
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
KT element: KtNameReferenceExpression
|
||||||
|
FIR element: FirPropertyAccessExpressionImpl
|
||||||
|
FIR source kind: KtRealSourceElementKind
|
||||||
|
|
||||||
|
FIR element rendered:
|
||||||
|
R|test/property|
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
open class Base(action: Int)
|
||||||
|
|
||||||
|
val property = 10
|
||||||
|
|
||||||
|
class Child : Base(prop<caret>erty)
|
||||||
analysis/low-level-api-fir/testData/dependentCopy/superCallArgument_secondaryConstructor.context.txt
Vendored
+19
@@ -0,0 +1,19 @@
|
|||||||
|
Tower Data Context:
|
||||||
|
Element 0
|
||||||
|
Scope: FirDefaultStarImportingScope
|
||||||
|
Element 1
|
||||||
|
Scope: FirExplicitStarImportingScope
|
||||||
|
Element 2
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 3
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 4
|
||||||
|
Scope: FirPackageMemberScope
|
||||||
|
Element 5
|
||||||
|
Scope: FirExplicitSimpleImportingScope
|
||||||
|
Element 6
|
||||||
|
Implicit receiver:
|
||||||
|
FirRegularClassSymbol public final class Child : R|test/Base|
|
||||||
|
Type: test.Child
|
||||||
|
Element 7
|
||||||
|
Scope: FirLocalScope
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
KT element: KtNameReferenceExpression
|
||||||
|
FIR element: FirPropertyAccessExpressionImpl
|
||||||
|
FIR source kind: KtRealSourceElementKind
|
||||||
|
|
||||||
|
FIR element rendered:
|
||||||
|
R|test/property|
|
||||||
Vendored
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
open class Base(i: Int)
|
||||||
|
|
||||||
|
val property = 10
|
||||||
|
|
||||||
|
class Child : Base {
|
||||||
|
constructor(): super(prop<caret>erty)
|
||||||
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
Tower Data Context:
|
||||||
|
Element 0
|
||||||
|
Scope: FirDefaultStarImportingScope
|
||||||
|
Element 1
|
||||||
|
Scope: FirExplicitStarImportingScope
|
||||||
|
Element 2
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 3
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 4
|
||||||
|
Scope: FirPackageMemberScope
|
||||||
|
Element 5
|
||||||
|
Scope: FirExplicitSimpleImportingScope
|
||||||
|
Element 6
|
||||||
|
Implicit receiver:
|
||||||
|
FirRegularClassSymbol public final class MyClass : R|test/MyInterface|
|
||||||
|
Type: test.MyClass
|
||||||
|
Element 7
|
||||||
|
Scope: FirLocalScope
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
KT element: KtNameReferenceExpression
|
||||||
|
FIR element: FirPropertyAccessExpressionImpl
|
||||||
|
FIR source kind: KtRealSourceElementKind
|
||||||
|
|
||||||
|
FIR element rendered:
|
||||||
|
R|test/property|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
interface MyInterface
|
||||||
|
|
||||||
|
val property: MyInterface = object : MyInterface {}
|
||||||
|
|
||||||
|
class MyClass: MyInterface by prop<caret>erty
|
||||||
Vendored
+27
@@ -0,0 +1,27 @@
|
|||||||
|
Tower Data Context:
|
||||||
|
Element 0
|
||||||
|
Scope: FirDefaultStarImportingScope
|
||||||
|
Element 1
|
||||||
|
Scope: FirExplicitStarImportingScope
|
||||||
|
Element 2
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 3
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 4
|
||||||
|
Scope: FirPackageMemberScope
|
||||||
|
Element 5
|
||||||
|
Scope: FirExplicitSimpleImportingScope
|
||||||
|
Element 6
|
||||||
|
Implicit receiver:
|
||||||
|
FirRegularClassSymbol public final companion object Companion : R|test/MyInterface|
|
||||||
|
Type: test.MyClass.Companion
|
||||||
|
Element 7
|
||||||
|
Scope: FirNestedClassifierScopeImpl
|
||||||
|
Classifiers:
|
||||||
|
FirRegularClassSymbol public final companion object Companion : R|test/MyInterface|
|
||||||
|
Element 8
|
||||||
|
Implicit receiver:
|
||||||
|
FirRegularClassSymbol public final class MyClass : R|test/MyInterface|
|
||||||
|
Type: test.MyClass
|
||||||
|
Element 9
|
||||||
|
Scope: FirLocalScope
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
KT element: KtNameReferenceExpression
|
||||||
|
FIR element: FirResolvedQualifierImpl
|
||||||
|
FIR source kind: KtRealSourceElementKind
|
||||||
|
|
||||||
|
FIR element rendered:
|
||||||
|
Q|test/MyClass.Companion|
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
interface MyInterface
|
||||||
|
|
||||||
|
class MyClass: MyInterface by Comp<caret>anion {
|
||||||
|
companion object : MyInterface
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
Tower Data Context:
|
||||||
|
Element 0
|
||||||
|
Scope: FirDefaultStarImportingScope
|
||||||
|
Element 1
|
||||||
|
Scope: FirExplicitStarImportingScope
|
||||||
|
Element 2
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 3
|
||||||
|
Scope: FirDefaultSimpleImportingScope
|
||||||
|
Element 4
|
||||||
|
Scope: FirPackageMemberScope
|
||||||
|
Element 5
|
||||||
|
Scope: FirExplicitSimpleImportingScope
|
||||||
|
Element 6
|
||||||
|
Implicit receiver:
|
||||||
|
FirRegularClassSymbol public final class MyClass : R|test/MyInterface|
|
||||||
|
Type: test.MyClass
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
KT element: KtNameReferenceExpression
|
||||||
|
FIR element: FirPropertyAccessExpressionImpl
|
||||||
|
FIR source kind: KtRealSourceElementKind
|
||||||
|
|
||||||
|
FIR element rendered:
|
||||||
|
R|<local>/param|
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
interface MyInterface
|
||||||
|
|
||||||
|
class MyClass(param: MyInterface): MyInterface by par<caret>am
|
||||||
+36
@@ -53,4 +53,40 @@ public class SourceDependentCopyContextTestGenerated extends AbstractSourceDepen
|
|||||||
public void testFunction() throws Exception {
|
public void testFunction() throws Exception {
|
||||||
runTest("analysis/low-level-api-fir/testData/dependentCopy/function.kt");
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/function.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superCallArgument_delegatedConstructor.kt")
|
||||||
|
public void testSuperCallArgument_delegatedConstructor() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superCallArgument_delegatedConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superCallArgument_primaryConstructor.kt")
|
||||||
|
public void testSuperCallArgument_primaryConstructor() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superCallArgument_primaryConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superCallArgument_secondaryConstructor.kt")
|
||||||
|
public void testSuperCallArgument_secondaryConstructor() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superCallArgument_secondaryConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superTypeDelegation.kt")
|
||||||
|
public void testSuperTypeDelegation() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superTypeDelegation.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superTypeDelegation_toCompanion.kt")
|
||||||
|
public void testSuperTypeDelegation_toCompanion() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superTypeDelegation_toCompanion.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superTypeDelegation_toPrimaryConstructorParam.kt")
|
||||||
|
public void testSuperTypeDelegation_toPrimaryConstructorParam() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superTypeDelegation_toPrimaryConstructorParam.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+36
@@ -53,4 +53,40 @@ public class SourceDependentCopyFirTestGenerated extends AbstractSourceDependent
|
|||||||
public void testFunction() throws Exception {
|
public void testFunction() throws Exception {
|
||||||
runTest("analysis/low-level-api-fir/testData/dependentCopy/function.kt");
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/function.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superCallArgument_delegatedConstructor.kt")
|
||||||
|
public void testSuperCallArgument_delegatedConstructor() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superCallArgument_delegatedConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superCallArgument_primaryConstructor.kt")
|
||||||
|
public void testSuperCallArgument_primaryConstructor() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superCallArgument_primaryConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superCallArgument_secondaryConstructor.kt")
|
||||||
|
public void testSuperCallArgument_secondaryConstructor() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superCallArgument_secondaryConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superTypeDelegation.kt")
|
||||||
|
public void testSuperTypeDelegation() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superTypeDelegation.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superTypeDelegation_toCompanion.kt")
|
||||||
|
public void testSuperTypeDelegation_toCompanion() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superTypeDelegation_toCompanion.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("superTypeDelegation_toPrimaryConstructorParam.kt")
|
||||||
|
public void testSuperTypeDelegation_toPrimaryConstructorParam() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testData/dependentCopy/superTypeDelegation_toPrimaryConstructorParam.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user