EA-235765 // NPE at refactoring suggestion
Fixed exception: java.lang.NullPointerException: null cannot be cast to non-null type org.jetbrains.kotlin.descriptors.CallableDescriptor More info: https://ea.jetbrains.com/browser/ea_problems/235765
This commit is contained in:
+8
-9
@@ -4,7 +4,6 @@ import com.intellij.openapi.util.Key
|
|||||||
import com.intellij.psi.PsiNamedElement
|
import com.intellij.psi.PsiNamedElement
|
||||||
import com.intellij.psi.search.LocalSearchScope
|
import com.intellij.psi.search.LocalSearchScope
|
||||||
import com.intellij.psi.search.searches.ReferencesSearch
|
import com.intellij.psi.search.searches.ReferencesSearch
|
||||||
import com.intellij.psi.util.parents
|
|
||||||
import com.intellij.refactoring.suggested.*
|
import com.intellij.refactoring.suggested.*
|
||||||
import com.intellij.refactoring.suggested.SuggestedRefactoringSupport.Parameter
|
import com.intellij.refactoring.suggested.SuggestedRefactoringSupport.Parameter
|
||||||
import com.intellij.refactoring.suggested.SuggestedRefactoringSupport.Signature
|
import com.intellij.refactoring.suggested.SuggestedRefactoringSupport.Signature
|
||||||
@@ -48,8 +47,8 @@ class KotlinSuggestedRefactoringAvailability(refactoringSupport: SuggestedRefact
|
|||||||
val oldDeclaration = state.restoredDeclarationCopy() as? KtCallableDeclaration ?: return state
|
val oldDeclaration = state.restoredDeclarationCopy() as? KtCallableDeclaration ?: return state
|
||||||
oldDeclaration.containingKtFile.forcedModuleInfo = newDeclaration.getModuleInfo()
|
oldDeclaration.containingKtFile.forcedModuleInfo = newDeclaration.getModuleInfo()
|
||||||
|
|
||||||
val descriptorWithOldSignature = oldDeclaration.resolveToDescriptorIfAny() as CallableDescriptor
|
val descriptorWithOldSignature = oldDeclaration.resolveToDescriptorIfAny() as CallableDescriptor?
|
||||||
val descriptorWithNewSignature = newDeclaration.resolveToDescriptorIfAny() as CallableDescriptor
|
val descriptorWithNewSignature = newDeclaration.resolveToDescriptorIfAny() as CallableDescriptor?
|
||||||
|
|
||||||
val oldSignature = state.oldSignature
|
val oldSignature = state.oldSignature
|
||||||
val newSignature = state.newSignature
|
val newSignature = state.newSignature
|
||||||
@@ -57,8 +56,8 @@ class KotlinSuggestedRefactoringAvailability(refactoringSupport: SuggestedRefact
|
|||||||
val (oldReturnType, newReturnType) = refineType(
|
val (oldReturnType, newReturnType) = refineType(
|
||||||
oldSignature.type,
|
oldSignature.type,
|
||||||
newSignature.type,
|
newSignature.type,
|
||||||
descriptorWithOldSignature.returnType,
|
descriptorWithOldSignature?.returnType,
|
||||||
descriptorWithNewSignature.returnType
|
descriptorWithNewSignature?.returnType
|
||||||
)
|
)
|
||||||
|
|
||||||
val improvedOldParameterTypesById = mutableMapOf<Any, String>()
|
val improvedOldParameterTypesById = mutableMapOf<Any, String>()
|
||||||
@@ -71,8 +70,8 @@ class KotlinSuggestedRefactoringAvailability(refactoringSupport: SuggestedRefact
|
|||||||
val (oldType, newType) = refineType(
|
val (oldType, newType) = refineType(
|
||||||
oldParameter.type,
|
oldParameter.type,
|
||||||
newParameter.type,
|
newParameter.type,
|
||||||
descriptorWithOldSignature.valueParameters[oldIndex].type,
|
descriptorWithOldSignature?.valueParameters?.get(oldIndex)?.type,
|
||||||
descriptorWithNewSignature.valueParameters[newIndex].type
|
descriptorWithNewSignature?.valueParameters?.get(newIndex)?.type
|
||||||
)
|
)
|
||||||
// oldType and newType may not be null because arguments of refineType call were all non-null
|
// oldType and newType may not be null because arguments of refineType call were all non-null
|
||||||
improvedOldParameterTypesById[id] = oldType!!
|
improvedOldParameterTypesById[id] = oldType!!
|
||||||
@@ -86,8 +85,8 @@ class KotlinSuggestedRefactoringAvailability(refactoringSupport: SuggestedRefact
|
|||||||
val (oldReceiverType, newReceiverType) = refineType(
|
val (oldReceiverType, newReceiverType) = refineType(
|
||||||
oldAdditionalData?.receiverType,
|
oldAdditionalData?.receiverType,
|
||||||
newAdditionalData?.receiverType,
|
newAdditionalData?.receiverType,
|
||||||
descriptorWithOldSignature.extensionReceiverParameter?.type,
|
descriptorWithOldSignature?.extensionReceiverParameter?.type,
|
||||||
descriptorWithNewSignature.extensionReceiverParameter?.type
|
descriptorWithNewSignature?.extensionReceiverParameter?.type
|
||||||
)
|
)
|
||||||
|
|
||||||
return state
|
return state
|
||||||
|
|||||||
Reference in New Issue
Block a user