Rename: Implement Rename conflict analysis for properties. Qualify property references to resove rename conflicts when possible

#KT-8732 Fixed
 #KT-12543 Fixed
(cherry picked from commit e23029d)
This commit is contained in:
Alexey Sedunov
2016-06-14 15:07:52 +03:00
parent 43f5da0ece
commit 77b0bb9849
41 changed files with 878 additions and 9 deletions
@@ -459,3 +459,8 @@ fun KtElement.nonStaticOuterClasses(): Sequence<KtClass> {
}
fun KtElement.containingClass(): KtClass? = getStrictParentOfType<KtClass>()
fun KtClassOrObject.findPropertyByName(name: String): KtNamedDeclaration? {
return declarations.firstOrNull { it is KtProperty && it.name == name } as KtNamedDeclaration?
?: getPrimaryConstructorParameters().firstOrNull { it.hasValOrVar() && it.name == name }
}
@@ -69,13 +69,13 @@ fun ResolvedCall<*>.getExplicitReceiverValue(): ReceiverValue? {
}
}
fun ResolvedCall<*>.getImplicitReceiverValue(): ReceiverValue? {
fun ResolvedCall<*>.getImplicitReceiverValue(): ImplicitReceiver? {
return when (explicitReceiverKind) {
ExplicitReceiverKind.NO_EXPLICIT_RECEIVER -> extensionReceiver ?: dispatchReceiver
ExplicitReceiverKind.DISPATCH_RECEIVER -> extensionReceiver
ExplicitReceiverKind.EXTENSION_RECEIVER -> dispatchReceiver
else -> null
}
} as? ImplicitReceiver
}
private fun ResolvedCall<*>.hasSafeNullableReceiver(context: CallResolutionContext<*>): Boolean {