[AA] allow navigation from '==' to the equals method of lhs
This commit is contained in:
+18
@@ -160,6 +160,18 @@ public class Fe10IdeNormalAnalysisSourceModuleReferenceResolveTestGenerated exte
|
|||||||
runTest("analysis/analysis-api/testData/referenceResolve/EnumValues.kt");
|
runTest("analysis/analysis-api/testData/referenceResolve/EnumValues.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("EqualsOperator.kt")
|
||||||
|
public void testEqualsOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/EqualsOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("EqualsOperatorNoInfix.kt")
|
||||||
|
public void testEqualsOperatorNoInfix() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/EqualsOperatorNoInfix.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("explicitFunctionalInterfaceInvoke_globalVal.kt")
|
@TestMetadata("explicitFunctionalInterfaceInvoke_globalVal.kt")
|
||||||
public void testExplicitFunctionalInterfaceInvoke_globalVal() throws Exception {
|
public void testExplicitFunctionalInterfaceInvoke_globalVal() throws Exception {
|
||||||
@@ -352,6 +364,12 @@ public class Fe10IdeNormalAnalysisSourceModuleReferenceResolveTestGenerated exte
|
|||||||
runTest("analysis/analysis-api/testData/referenceResolve/NamedClassObject.kt");
|
runTest("analysis/analysis-api/testData/referenceResolve/NamedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("NotEqualsOperator.kt")
|
||||||
|
public void testNotEqualsOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/NotEqualsOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("PackageReference.kt")
|
@TestMetadata("PackageReference.kt")
|
||||||
public void testPackageReference() throws Exception {
|
public void testPackageReference() throws Exception {
|
||||||
|
|||||||
+26
@@ -30,8 +30,10 @@ import org.jetbrains.kotlin.fir.references.*
|
|||||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.unwrapSmartcastExpression
|
import org.jetbrains.kotlin.fir.resolve.dfa.unwrapSmartcastExpression
|
||||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnmatchedTypeArgumentsError
|
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnmatchedTypeArgumentsError
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.scope
|
||||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.FirImportResolveTransformer
|
import org.jetbrains.kotlin.fir.resolve.transformers.FirImportResolveTransformer
|
||||||
|
import org.jetbrains.kotlin.fir.scopes.FakeOverrideTypeCalculator
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope
|
import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope
|
||||||
import org.jetbrains.kotlin.fir.scopes.processClassifiersByName
|
import org.jetbrains.kotlin.fir.scopes.processClassifiersByName
|
||||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
@@ -46,6 +48,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType
|
import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector
|
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.unwrapNullability
|
import org.jetbrains.kotlin.psi.psiUtil.unwrapNullability
|
||||||
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
|
|
||||||
internal object FirReferenceResolveHelper {
|
internal object FirReferenceResolveHelper {
|
||||||
@@ -216,10 +219,33 @@ internal object FirReferenceResolveHelper {
|
|||||||
getSymbolByDelegatedConstructorCall(expression, adjustedResolutionExpression, fir, session, symbolBuilder)
|
getSymbolByDelegatedConstructorCall(expression, adjustedResolutionExpression, fir, session, symbolBuilder)
|
||||||
is FirResolvable -> getSymbolsByResolvable(fir, expression, session, symbolBuilder)
|
is FirResolvable -> getSymbolsByResolvable(fir, expression, session, symbolBuilder)
|
||||||
is FirNamedArgumentExpression -> getSymbolsByNameArgumentExpression(expression, analysisSession, symbolBuilder)
|
is FirNamedArgumentExpression -> getSymbolsByNameArgumentExpression(expression, analysisSession, symbolBuilder)
|
||||||
|
is FirEqualityOperatorCall -> getSymbolsByEqualsName(fir, session, analysisSession, symbolBuilder)
|
||||||
else -> handleUnknownFirElement(expression, analysisSession, session, symbolBuilder)
|
else -> handleUnknownFirElement(expression, analysisSession, session, symbolBuilder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getSymbolsByEqualsName(
|
||||||
|
expression: FirEqualityOperatorCall,
|
||||||
|
session: FirSession,
|
||||||
|
analysisSession: KtFirAnalysisSession,
|
||||||
|
symbolBuilder: KtSymbolByFirBuilder
|
||||||
|
): Collection<KtSymbol> {
|
||||||
|
val lhs = expression.arguments.firstOrNull() ?: return emptyList()
|
||||||
|
val scope = lhs.typeRef.coneType.scope(
|
||||||
|
session,
|
||||||
|
analysisSession.getScopeSessionFor(analysisSession.useSiteSession),
|
||||||
|
FakeOverrideTypeCalculator.DoNothing
|
||||||
|
) ?: return emptyList()
|
||||||
|
return buildList {
|
||||||
|
scope.processFunctionsByName(OperatorNameConventions.EQUALS) { functionSymbol ->
|
||||||
|
val parameterSymbol = functionSymbol.valueParameterSymbols.singleOrNull()
|
||||||
|
if (parameterSymbol != null && parameterSymbol.fir.returnTypeRef.isNullableAny) {
|
||||||
|
add(functionSymbol.buildSymbol(symbolBuilder))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getSymbolByDelegatedConstructorCall(
|
private fun getSymbolByDelegatedConstructorCall(
|
||||||
expression: KtSimpleNameExpression,
|
expression: KtSimpleNameExpression,
|
||||||
adjustedResolutionExpression: KtElement,
|
adjustedResolutionExpression: KtElement,
|
||||||
|
|||||||
+18
@@ -160,6 +160,18 @@ public class FirIdeDependentAnalysisSourceModuleReferenceResolveTestGenerated ex
|
|||||||
runTest("analysis/analysis-api/testData/referenceResolve/EnumValues.kt");
|
runTest("analysis/analysis-api/testData/referenceResolve/EnumValues.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("EqualsOperator.kt")
|
||||||
|
public void testEqualsOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/EqualsOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("EqualsOperatorNoInfix.kt")
|
||||||
|
public void testEqualsOperatorNoInfix() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/EqualsOperatorNoInfix.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("explicitFunctionalInterfaceInvoke_globalVal.kt")
|
@TestMetadata("explicitFunctionalInterfaceInvoke_globalVal.kt")
|
||||||
public void testExplicitFunctionalInterfaceInvoke_globalVal() throws Exception {
|
public void testExplicitFunctionalInterfaceInvoke_globalVal() throws Exception {
|
||||||
@@ -352,6 +364,12 @@ public class FirIdeDependentAnalysisSourceModuleReferenceResolveTestGenerated ex
|
|||||||
runTest("analysis/analysis-api/testData/referenceResolve/NamedClassObject.kt");
|
runTest("analysis/analysis-api/testData/referenceResolve/NamedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("NotEqualsOperator.kt")
|
||||||
|
public void testNotEqualsOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/NotEqualsOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("PackageReference.kt")
|
@TestMetadata("PackageReference.kt")
|
||||||
public void testPackageReference() throws Exception {
|
public void testPackageReference() throws Exception {
|
||||||
|
|||||||
+18
@@ -160,6 +160,18 @@ public class FirIdeNormalAnalysisLibrarySourceModuleReferenceResolveTestGenerate
|
|||||||
runTest("analysis/analysis-api/testData/referenceResolve/EnumValues.kt");
|
runTest("analysis/analysis-api/testData/referenceResolve/EnumValues.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("EqualsOperator.kt")
|
||||||
|
public void testEqualsOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/EqualsOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("EqualsOperatorNoInfix.kt")
|
||||||
|
public void testEqualsOperatorNoInfix() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/EqualsOperatorNoInfix.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("explicitFunctionalInterfaceInvoke_globalVal.kt")
|
@TestMetadata("explicitFunctionalInterfaceInvoke_globalVal.kt")
|
||||||
public void testExplicitFunctionalInterfaceInvoke_globalVal() throws Exception {
|
public void testExplicitFunctionalInterfaceInvoke_globalVal() throws Exception {
|
||||||
@@ -352,6 +364,12 @@ public class FirIdeNormalAnalysisLibrarySourceModuleReferenceResolveTestGenerate
|
|||||||
runTest("analysis/analysis-api/testData/referenceResolve/NamedClassObject.kt");
|
runTest("analysis/analysis-api/testData/referenceResolve/NamedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("NotEqualsOperator.kt")
|
||||||
|
public void testNotEqualsOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/NotEqualsOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("PackageReference.kt")
|
@TestMetadata("PackageReference.kt")
|
||||||
public void testPackageReference() throws Exception {
|
public void testPackageReference() throws Exception {
|
||||||
|
|||||||
+18
@@ -160,6 +160,18 @@ public class FirIdeNormalAnalysisSourceModuleReferenceResolveTestGenerated exten
|
|||||||
runTest("analysis/analysis-api/testData/referenceResolve/EnumValues.kt");
|
runTest("analysis/analysis-api/testData/referenceResolve/EnumValues.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("EqualsOperator.kt")
|
||||||
|
public void testEqualsOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/EqualsOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("EqualsOperatorNoInfix.kt")
|
||||||
|
public void testEqualsOperatorNoInfix() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/EqualsOperatorNoInfix.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("explicitFunctionalInterfaceInvoke_globalVal.kt")
|
@TestMetadata("explicitFunctionalInterfaceInvoke_globalVal.kt")
|
||||||
public void testExplicitFunctionalInterfaceInvoke_globalVal() throws Exception {
|
public void testExplicitFunctionalInterfaceInvoke_globalVal() throws Exception {
|
||||||
@@ -352,6 +364,12 @@ public class FirIdeNormalAnalysisSourceModuleReferenceResolveTestGenerated exten
|
|||||||
runTest("analysis/analysis-api/testData/referenceResolve/NamedClassObject.kt");
|
runTest("analysis/analysis-api/testData/referenceResolve/NamedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("NotEqualsOperator.kt")
|
||||||
|
public void testNotEqualsOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/NotEqualsOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("PackageReference.kt")
|
@TestMetadata("PackageReference.kt")
|
||||||
public void testPackageReference() throws Exception {
|
public void testPackageReference() throws Exception {
|
||||||
|
|||||||
+18
@@ -160,6 +160,18 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceResolveTestGenerate
|
|||||||
runTest("analysis/analysis-api/testData/referenceResolve/EnumValues.kt");
|
runTest("analysis/analysis-api/testData/referenceResolve/EnumValues.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("EqualsOperator.kt")
|
||||||
|
public void testEqualsOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/EqualsOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("EqualsOperatorNoInfix.kt")
|
||||||
|
public void testEqualsOperatorNoInfix() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/EqualsOperatorNoInfix.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("explicitFunctionalInterfaceInvoke_globalVal.kt")
|
@TestMetadata("explicitFunctionalInterfaceInvoke_globalVal.kt")
|
||||||
public void testExplicitFunctionalInterfaceInvoke_globalVal() throws Exception {
|
public void testExplicitFunctionalInterfaceInvoke_globalVal() throws Exception {
|
||||||
@@ -352,6 +364,12 @@ public class FirStandaloneNormalAnalysisSourceModuleReferenceResolveTestGenerate
|
|||||||
runTest("analysis/analysis-api/testData/referenceResolve/NamedClassObject.kt");
|
runTest("analysis/analysis-api/testData/referenceResolve/NamedClassObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("NotEqualsOperator.kt")
|
||||||
|
public void testNotEqualsOperator() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/referenceResolve/NotEqualsOperator.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("PackageReference.kt")
|
@TestMetadata("PackageReference.kt")
|
||||||
public void testPackageReference() throws Exception {
|
public void testPackageReference() throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class A(val n: Any) {
|
||||||
|
override infix fun equals(other: Any?): Boolean = other is A && other.n <caret>== n
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Resolved to:
|
||||||
|
0: (in kotlin.Any) open operator fun equals(other: kotlin.Any?): kotlin.Boolean
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class A(val n: Any) {
|
||||||
|
override fun equals(other: Any?): Boolean = other is A && other.n <caret>== n
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Resolved to:
|
||||||
|
0: (in kotlin.Any) open operator fun equals(other: kotlin.Any?): kotlin.Boolean
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class A(val n: Any) {
|
||||||
|
override infix fun equals(other: Any?): Boolean = other is A && other.n <caret>!= n
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Resolved to:
|
||||||
|
0: (in kotlin.Any) open operator fun equals(other: kotlin.Any?): kotlin.Boolean
|
||||||
Reference in New Issue
Block a user