Fix warning about incompatible types.
This commit is contained in:
+3
-3
@@ -60,7 +60,7 @@ object BuiltinSpecialProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun CallableMemberDescriptor.hasBuiltinSpecialPropertyFqNameImpl(): Boolean {
|
private fun CallableMemberDescriptor.hasBuiltinSpecialPropertyFqNameImpl(): Boolean {
|
||||||
if (FQ_NAMES.containsRaw(fqNameOrNull())) return true
|
if (fqNameOrNull() in FQ_NAMES) return true
|
||||||
if (!isFromBuiltins()) return false
|
if (!isFromBuiltins()) return false
|
||||||
|
|
||||||
return overriddenDescriptors.any { hasBuiltinSpecialPropertyFqName(it) }
|
return overriddenDescriptors.any { hasBuiltinSpecialPropertyFqName(it) }
|
||||||
@@ -108,7 +108,7 @@ object BuiltinMethodsWithSpecialGenericSignature {
|
|||||||
ERASED_VALUE_PARAMETERS_FQ_NAMES.map { it.shortName() }.toSet()
|
ERASED_VALUE_PARAMETERS_FQ_NAMES.map { it.shortName() }.toSet()
|
||||||
|
|
||||||
private val CallableMemberDescriptor.hasErasedValueParametersInJava: Boolean
|
private val CallableMemberDescriptor.hasErasedValueParametersInJava: Boolean
|
||||||
get() = ERASED_VALUE_PARAMETERS_FQ_NAMES.containsRaw(fqNameOrNull())
|
get() = fqNameOrNull() in ERASED_VALUE_PARAMETERS_FQ_NAMES
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getOverriddenBuiltinFunctionWithErasedValueParametersInJava(
|
fun getOverriddenBuiltinFunctionWithErasedValueParametersInJava(
|
||||||
@@ -122,7 +122,7 @@ object BuiltinMethodsWithSpecialGenericSignature {
|
|||||||
fun getDefaultValueForOverriddenBuiltinFunction(functionDescriptor: FunctionDescriptor): DefaultValue? {
|
fun getDefaultValueForOverriddenBuiltinFunction(functionDescriptor: FunctionDescriptor): DefaultValue? {
|
||||||
if (functionDescriptor.name !in ERASED_VALUE_PARAMETERS_SHORT_NAMES) return null
|
if (functionDescriptor.name !in ERASED_VALUE_PARAMETERS_SHORT_NAMES) return null
|
||||||
return functionDescriptor.firstOverridden {
|
return functionDescriptor.firstOverridden {
|
||||||
GENERIC_PARAMETERS_METHODS_TO_DEFAULT_VALUES_MAP.keys.containsRaw(it.fqNameOrNull())
|
it.fqNameOrNull() in GENERIC_PARAMETERS_METHODS_TO_DEFAULT_VALUES_MAP.keys
|
||||||
}?.let { GENERIC_PARAMETERS_METHODS_TO_DEFAULT_VALUES_MAP[it.fqNameSafe] }
|
}?.let { GENERIC_PARAMETERS_METHODS_TO_DEFAULT_VALUES_MAP[it.fqNameSafe] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor<Kotlin
|
|||||||
private val LOG = Logger.getInstance(javaClass<KotlinCopyPasteReferenceProcessor>())
|
private val LOG = Logger.getInstance(javaClass<KotlinCopyPasteReferenceProcessor>())
|
||||||
|
|
||||||
private val IGNORE_REFERENCES_INSIDE: Array<Class<out KtElement>> = arrayOf(
|
private val IGNORE_REFERENCES_INSIDE: Array<Class<out KtElement>> = arrayOf(
|
||||||
javaClass<KtImportList>(),
|
KtImportList::class.java,
|
||||||
javaClass<KtPackageDirective>()
|
KtPackageDirective::class.java
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun extractTransferableData(content: Transferable): List<KotlinReferenceTransferableData> {
|
override fun extractTransferableData(content: Transferable): List<KotlinReferenceTransferableData> {
|
||||||
@@ -139,7 +139,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor<Kotlin
|
|||||||
) {
|
) {
|
||||||
if (PsiTreeUtil.getNonStrictParentOfType(element, *IGNORE_REFERENCES_INSIDE) != null) return
|
if (PsiTreeUtil.getNonStrictParentOfType(element, *IGNORE_REFERENCES_INSIDE) != null) return
|
||||||
|
|
||||||
element.forEachDescendantOfType<KtElement>(canGoInside = { it.javaClass !in IGNORE_REFERENCES_INSIDE }) { element ->
|
element.forEachDescendantOfType<KtElement>(canGoInside = { it.javaClass as Class<*> !in IGNORE_REFERENCES_INSIDE }) { element ->
|
||||||
val reference = element.mainReference ?: return@forEachDescendantOfType
|
val reference = element.mainReference ?: return@forEachDescendantOfType
|
||||||
|
|
||||||
val descriptors = reference.resolveToDescriptors(element.analyze()) //TODO: we could use partial body resolve for all references together
|
val descriptors = reference.resolveToDescriptors(element.analyze()) //TODO: we could use partial body resolve for all references together
|
||||||
|
|||||||
@@ -116,10 +116,10 @@ class KotlinEditorTextProvider : EditorTextProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val NOT_ACCEPTED_AS_CONTEXT_TYPES =
|
private val NOT_ACCEPTED_AS_CONTEXT_TYPES =
|
||||||
arrayOf(javaClass<KtUserType>(), javaClass<KtImportDirective>(), javaClass<KtPackageDirective>())
|
arrayOf(KtUserType::class.java, KtImportDirective::class.java, KtPackageDirective::class.java)
|
||||||
|
|
||||||
fun isAcceptedAsCodeFragmentContext(element: PsiElement): Boolean {
|
fun isAcceptedAsCodeFragmentContext(element: PsiElement): Boolean {
|
||||||
return element.javaClass !in NOT_ACCEPTED_AS_CONTEXT_TYPES &&
|
return element.javaClass as Class<*> !in NOT_ACCEPTED_AS_CONTEXT_TYPES &&
|
||||||
PsiTreeUtil.getParentOfType(element, *NOT_ACCEPTED_AS_CONTEXT_TYPES) == null
|
PsiTreeUtil.getParentOfType(element, *NOT_ACCEPTED_AS_CONTEXT_TYPES) == null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -420,7 +420,7 @@ public class KotlinPositionManager(private val myDebugProcess: DebugProcess) : M
|
|||||||
KtAnonymousInitializer::class.java)
|
KtAnonymousInitializer::class.java)
|
||||||
|
|
||||||
private fun getElementToCalculateClassName(notPositionedElement: PsiElement?): KtElement? {
|
private fun getElementToCalculateClassName(notPositionedElement: PsiElement?): KtElement? {
|
||||||
if (notPositionedElement?.javaClass in TYPES_TO_CALCULATE_CLASSNAME ) return notPositionedElement as KtElement
|
if (notPositionedElement?.javaClass as Class<*> in TYPES_TO_CALCULATE_CLASSNAME) return notPositionedElement as KtElement
|
||||||
|
|
||||||
return PsiTreeUtil.getParentOfType(notPositionedElement, *TYPES_TO_CALCULATE_CLASSNAME)
|
return PsiTreeUtil.getParentOfType(notPositionedElement, *TYPES_TO_CALCULATE_CLASSNAME)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public class ConvertFunctionToPropertyIntention : SelfTargetingIntention<KtNamed
|
|||||||
if (callable is PsiMethod) {
|
if (callable is PsiMethod) {
|
||||||
callable.getContainingClass()
|
callable.getContainingClass()
|
||||||
?.findMethodsByName(getterName, true)
|
?.findMethodsByName(getterName, true)
|
||||||
?.firstOrNull { it.getParameterList().getParametersCount() == 0 && it.namedUnwrappedElement !in callables }
|
?.firstOrNull { it.getParameterList().getParametersCount() == 0 && it.namedUnwrappedElement as PsiElement? !in callables }
|
||||||
?.let { reportDeclarationConflict(conflicts, it) { "$it already exists" } }
|
?.let { reportDeclarationConflict(conflicts, it) { "$it already exists" } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class ConvertPropertyToFunctionIntention : SelfTargetingIntention<KtPrope
|
|||||||
else if (callable is PsiMethod) {
|
else if (callable is PsiMethod) {
|
||||||
callable.getContainingClass()
|
callable.getContainingClass()
|
||||||
?.findMethodsByName(propertyName, true)
|
?.findMethodsByName(propertyName, true)
|
||||||
?.firstOrNull { it.getParameterList().getParametersCount() == 0 && it.namedUnwrappedElement !in callables }
|
?.firstOrNull { it.getParameterList().getParametersCount() == 0 && it.namedUnwrappedElement as PsiElement? !in callables }
|
||||||
?.let { reportDeclarationConflict(conflicts, it) { "$it already exists" } }
|
?.let { reportDeclarationConflict(conflicts, it) { "$it already exists" } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,8 +191,8 @@ internal class AutoImportFix(expression: KtSimpleNameExpression) : AutoImportFix
|
|||||||
if (conventionName != null) {
|
if (conventionName != null) {
|
||||||
if (element is KtOperationReferenceExpression) {
|
if (element is KtOperationReferenceExpression) {
|
||||||
val elementType = element.firstChild.node.elementType
|
val elementType = element.firstChild.node.elementType
|
||||||
if (OperatorConventions.ASSIGNMENT_OPERATIONS.containsKeyRaw(elementType)) {
|
if (elementType in OperatorConventions.ASSIGNMENT_OPERATIONS) {
|
||||||
val counterpart = OperatorConventions.ASSIGNMENT_OPERATION_COUNTERPARTS.getRaw(elementType)
|
val counterpart = OperatorConventions.ASSIGNMENT_OPERATION_COUNTERPARTS[elementType]
|
||||||
val counterpartName = OperatorConventions.BINARY_OPERATION_NAMES.get(counterpart)
|
val counterpartName = OperatorConventions.BINARY_OPERATION_NAMES.get(counterpart)
|
||||||
if (counterpartName != null) {
|
if (counterpartName != null) {
|
||||||
return@run listOf(conventionName, counterpartName)
|
return@run listOf(conventionName, counterpartName)
|
||||||
|
|||||||
+3
-3
@@ -154,8 +154,8 @@ class KotlinFunctionCallUsage(
|
|||||||
private fun needSeparateVariable(element: PsiElement): Boolean {
|
private fun needSeparateVariable(element: PsiElement): Boolean {
|
||||||
return when {
|
return when {
|
||||||
element is KtConstantExpression, element is KtThisExpression, element is KtSimpleNameExpression -> false
|
element is KtConstantExpression, element is KtThisExpression, element is KtSimpleNameExpression -> false
|
||||||
element is KtBinaryExpression && OperatorConventions.ASSIGNMENT_OPERATIONS.containsKeyRaw(element.operationToken) -> true
|
element is KtBinaryExpression && OperatorConventions.ASSIGNMENT_OPERATIONS.contains(element.operationToken) -> true
|
||||||
element is KtUnaryExpression && OperatorConventions.INCREMENT_OPERATIONS.containsRaw(element.operationToken) -> true
|
element is KtUnaryExpression && OperatorConventions.INCREMENT_OPERATIONS.contains(element.operationToken) -> true
|
||||||
element is KtCallExpression -> element.getResolvedCall(context)?.resultingDescriptor is ConstructorDescriptor
|
element is KtCallExpression -> element.getResolvedCall(context)?.resultingDescriptor is ConstructorDescriptor
|
||||||
else -> element.children.any { needSeparateVariable(it) }
|
else -> element.children.any { needSeparateVariable(it) }
|
||||||
}
|
}
|
||||||
@@ -210,7 +210,7 @@ class KotlinFunctionCallUsage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var expressionToReplace: KtExpression = nameCounterpartMap.getRaw(ref.element) ?: continue
|
var expressionToReplace: KtExpression = nameCounterpartMap[ref.element] ?: continue
|
||||||
val parent = expressionToReplace.parent
|
val parent = expressionToReplace.parent
|
||||||
|
|
||||||
if (parent is KtThisExpression) {
|
if (parent is KtThisExpression) {
|
||||||
|
|||||||
+3
-3
@@ -305,9 +305,9 @@ private fun ExtractionData.analyzeControlFlow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val outParameters =
|
val outParameters =
|
||||||
parameters.filter { it.mirrorVarName != null && modifiedVarDescriptors.getRaw(it.originalDescriptor) != null }.sortedBy { it.nameForRef }
|
parameters.filter { it.mirrorVarName != null && modifiedVarDescriptors[it.originalDescriptor] != null }.sortedBy { it.nameForRef }
|
||||||
val outDeclarations =
|
val outDeclarations =
|
||||||
declarationsToCopy.filter { modifiedVarDescriptors.getRaw(bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, it]) != null }
|
declarationsToCopy.filter { modifiedVarDescriptors[bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, it]] != null }
|
||||||
val modifiedValueCount = outParameters.size + outDeclarations.size
|
val modifiedValueCount = outParameters.size + outDeclarations.size
|
||||||
|
|
||||||
val outputValues = ArrayList<OutputValue>()
|
val outputValues = ArrayList<OutputValue>()
|
||||||
@@ -339,7 +339,7 @@ private fun ExtractionData.analyzeControlFlow(
|
|||||||
val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, it] as? CallableDescriptor
|
val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, it] as? CallableDescriptor
|
||||||
Initializer(it as KtProperty, descriptor?.returnType ?: module.builtIns.defaultParameterType)
|
Initializer(it as KtProperty, descriptor?.returnType ?: module.builtIns.defaultParameterType)
|
||||||
}
|
}
|
||||||
outParameters.mapTo(outputValues) { ParameterUpdate(it, modifiedVarDescriptors.getRaw(it.originalDescriptor)!!) }
|
outParameters.mapTo(outputValues) { ParameterUpdate(it, modifiedVarDescriptors[it.originalDescriptor]!!) }
|
||||||
|
|
||||||
if (outputValues.isNotEmpty()) {
|
if (outputValues.isNotEmpty()) {
|
||||||
if (jumpExits.isNotEmpty()) return outputAndExitsError
|
if (jumpExits.isNotEmpty()) return outputAndExitsError
|
||||||
|
|||||||
+2
-2
@@ -459,7 +459,7 @@ fun ExtractionGeneratorConfiguration.generateDeclaration(
|
|||||||
val counterpartMap = createNameCounterpartMap(currentResultExpression, expressionToUnifyWith ?: newResultExpression)
|
val counterpartMap = createNameCounterpartMap(currentResultExpression, expressionToUnifyWith ?: newResultExpression)
|
||||||
counterpartMap.entries.forEach {
|
counterpartMap.entries.forEach {
|
||||||
val (cmOriginalExpr, cmNewExpr) = it
|
val (cmOriginalExpr, cmNewExpr) = it
|
||||||
nameByOffset.entrySet().find { it.value.containsRaw(cmOriginalExpr) }?.let {
|
nameByOffset.entrySet().find { cmOriginalExpr in it.value }?.let {
|
||||||
nameByOffset.remove(it.key, cmOriginalExpr)
|
nameByOffset.remove(it.key, cmOriginalExpr)
|
||||||
nameByOffset.putValue(it.key, cmNewExpr)
|
nameByOffset.putValue(it.key, cmNewExpr)
|
||||||
}
|
}
|
||||||
@@ -512,7 +512,7 @@ fun ExtractionGeneratorConfiguration.generateDeclaration(
|
|||||||
val jumpValue = descriptor.controlFlow.jumpOutputValue
|
val jumpValue = descriptor.controlFlow.jumpOutputValue
|
||||||
if (jumpValue != null) {
|
if (jumpValue != null) {
|
||||||
replacingReturn = psiFactory.createExpression(if (jumpValue.conditional) "return true" else "return")
|
replacingReturn = psiFactory.createExpression(if (jumpValue.conditional) "return true" else "return")
|
||||||
returnsForLabelRemoval.removeAllRaw(jumpValue.elementsToReplace)
|
returnsForLabelRemoval.removeAll(jumpValue.elementsToReplace)
|
||||||
expressionsToReplaceWithReturn = getCounterparts(jumpValue.elementsToReplace, body, bodyOffset, file)
|
expressionsToReplaceWithReturn = getCounterparts(jumpValue.elementsToReplace, body, bodyOffset, file)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@ internal fun ExtractionData.inferParametersInfo(
|
|||||||
if (currentName == null) {
|
if (currentName == null) {
|
||||||
currentName = KotlinNameSuggester.suggestNamesByType(getParameterType(options.allowSpecialClassNames), varNameValidator, "p").first()
|
currentName = KotlinNameSuggester.suggestNamesByType(getParameterType(options.allowSpecialClassNames), varNameValidator, "p").first()
|
||||||
}
|
}
|
||||||
mirrorVarName = if (modifiedVarDescriptors.containsRaw(descriptorToExtract)) KotlinNameSuggester.suggestNameByName(name, varNameValidator) else null
|
mirrorVarName = if (descriptorToExtract in modifiedVarDescriptors) KotlinNameSuggester.suggestNameByName(name, varNameValidator) else null
|
||||||
info.parameters.add(this)
|
info.parameters.add(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,10 +164,10 @@ private fun KotlinPullUpData.checkVisibility(
|
|||||||
val childrenToCheck = member.allChildren.toArrayList()
|
val childrenToCheck = member.allChildren.toArrayList()
|
||||||
if (memberInfo.isToAbstract && member is KtCallableDeclaration) {
|
if (memberInfo.isToAbstract && member is KtCallableDeclaration) {
|
||||||
when (member) {
|
when (member) {
|
||||||
is KtNamedFunction -> childrenToCheck.remove(member.bodyExpression)
|
is KtNamedFunction -> childrenToCheck.remove(member.bodyExpression as PsiElement?)
|
||||||
is KtProperty -> {
|
is KtProperty -> {
|
||||||
childrenToCheck.remove(member.initializer)
|
childrenToCheck.remove(member.initializer as PsiElement?)
|
||||||
childrenToCheck.remove(member.delegateExpression)
|
childrenToCheck.remove(member.delegateExpression as PsiElement?)
|
||||||
childrenToCheck.removeAll(member.accessors)
|
childrenToCheck.removeAll(member.accessors)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user