Line Markers: Detect recursive calls of companion invoke() member
#KT-21076 Fixed
This commit is contained in:
@@ -21,6 +21,7 @@ package org.jetbrains.kotlin.idea.util
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||
import org.jetbrains.kotlin.psi.KtReferenceExpression
|
||||
import org.jetbrains.kotlin.psi.KtThisExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
@@ -113,3 +114,21 @@ fun ReceiverValue?.getThisReceiverOwner(bindingContext: BindingContext): Declara
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
fun ReceiverValue?.getReceiverTargetDescriptor(bindingContext: BindingContext): DeclarationDescriptor? {
|
||||
return when (this) {
|
||||
is ExpressionReceiver -> {
|
||||
val expression = KtPsiUtil.deparenthesize(this.expression)
|
||||
val refExpression = when (expression) {
|
||||
is KtThisExpression -> expression.instanceReference
|
||||
is KtReferenceExpression -> expression
|
||||
else -> null
|
||||
} ?: return null
|
||||
bindingContext[BindingContext.REFERENCE_TARGET, refExpression]
|
||||
}
|
||||
|
||||
is ImplicitReceiver -> this.declarationDescriptor
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user