References: Fix resolution of delegate reference for local variables
#KT-22229 Fixed
This commit is contained in:
+3
-2
@@ -18,7 +18,8 @@ package org.jetbrains.kotlin.idea.references
|
||||
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.VariableDescriptorWithAccessors
|
||||
import org.jetbrains.kotlin.descriptors.accessors
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.psi.KtPropertyDelegate
|
||||
@@ -36,7 +37,7 @@ class KtPropertyDelegationMethodsReference(element: KtPropertyDelegate) : KtMult
|
||||
|
||||
override fun getTargetDescriptors(context: BindingContext): Collection<DeclarationDescriptor> {
|
||||
val property = expression.getStrictParentOfType<KtProperty>() ?: return emptyList()
|
||||
val descriptor = context[BindingContext.DECLARATION_TO_DESCRIPTOR, property] as? PropertyDescriptor ?: return emptyList()
|
||||
val descriptor = context[BindingContext.DECLARATION_TO_DESCRIPTOR, property] as? VariableDescriptorWithAccessors ?: return emptyList()
|
||||
return (descriptor.accessors.mapNotNull {
|
||||
accessor ->
|
||||
context.get(BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, accessor)?.candidateDescriptor
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package foo
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
operator fun String.getValue(nothing: Nothing?, property: KProperty<*>) = ""
|
||||
@@ -0,0 +1,7 @@
|
||||
package bar
|
||||
|
||||
import foo.getValue
|
||||
|
||||
fun foo() {
|
||||
val x : String by ""
|
||||
}
|
||||
Reference in New Issue
Block a user