[kotlin] UsePropertyAccessSyntaxInspection: Get receiver types correctly for callable references on constructors

For example, Foo()::getFoo

^KTIJ-29118 Fixed


Merge-request: IJ-MR-130070
Merged-by: Victoria Petrakovich <Victoria.Petrakovich@jetbrains.com>

GitOrigin-RevId: 043bbaae95e30f22963db8dcf4c8c7ee06098aa6
This commit is contained in:
Victoria.Petrakovich
2024-03-26 20:16:03 +00:00
committed by intellij-monorepo-bot
parent 0d7ec13856
commit beeb0f1098
3 changed files with 6 additions and 5 deletions
@@ -117,7 +117,10 @@ class UsePropertyAccessSyntaxInspection : LocalInspectionTool(), CleanupLocalIns
val problemHighlightType = getProblemHighlightType(symbolPsi)
val receiverType = callableReferenceExpression.getReceiverKtType()?.lowerBoundIfFlexible() ?: return
val receiverType =
callableReferenceExpression.resolveCall()
?.successfulFunctionCallOrNull()?.partiallyAppliedSymbol?.dispatchReceiver?.type?.lowerBoundIfFlexible()
?: callableReferenceExpression.getReceiverKtType()?.lowerBoundIfFlexible() ?: return
val syntheticProperty = getSyntheticProperty(propertyNames, receiverType) ?: return
@@ -1,8 +1,7 @@
// LANGUAGE_VERSION: 2.1
// COMPILER_ARGUMENTS: -XXLanguage:+ReferencesToSyntheticJavaProperties
// FIX: Use property access syntax
// IGNORE_K2
// Delete the ignore directive after fixing KTIJ-29118
fun main() {
suppressUnused(Foo()::<caret>getFoo)
}
@@ -1,8 +1,7 @@
// LANGUAGE_VERSION: 2.1
// COMPILER_ARGUMENTS: -XXLanguage:+ReferencesToSyntheticJavaProperties
// FIX: Use property access syntax
// IGNORE_K2
// Delete the ignore directive after fixing KTIJ-29118
fun main() {
suppressUnused(Foo()::foo)
}