Introduce & use resolveToDescriptorIfAny<DescriptorType>
This allows to omit casts after resolveToDescriptorIfAny() call, get different descriptors for different receivers (in future), distinguish parameter / property situation for primary constructor
This commit is contained in:
@@ -47,7 +47,7 @@ import org.jetbrains.kotlin.resolve.OverridingUtil
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
|
||||
val KtDeclaration.descriptor: DeclarationDescriptor?
|
||||
get() = this.resolveToDescriptorIfAny(BodyResolveMode.FULL)
|
||||
get() = if (this is KtParameter) this.descriptor else this.resolveToDescriptorIfAny(BodyResolveMode.FULL)
|
||||
|
||||
val KtDeclaration.constructor: ConstructorDescriptor?
|
||||
get() {
|
||||
@@ -59,8 +59,11 @@ val KtDeclaration.constructor: ConstructorDescriptor?
|
||||
}
|
||||
}
|
||||
|
||||
val KtParameter.descriptor: ValueParameterDescriptor?
|
||||
get() = this.resolveToDescriptorIfAny<ValueParameterDescriptor>(BodyResolveMode.FULL)
|
||||
|
||||
val KtParameter.propertyDescriptor: PropertyDescriptor?
|
||||
get() = this.analyze().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, this)
|
||||
get() = this.resolveToDescriptorIfAny<PropertyDescriptor>(BodyResolveMode.FULL)
|
||||
|
||||
fun PsiReference.checkUsageVsOriginalDescriptor(
|
||||
targetDescriptor: DeclarationDescriptor,
|
||||
|
||||
Reference in New Issue
Block a user