EA-37664 - NPE: InlineUtil.getTailCallType

This commit is contained in:
anna
2012-07-24 15:15:05 +02:00
parent 858a95e9bd
commit 8ec1c012c4
2 changed files with 8 additions and 5 deletions
@@ -196,10 +196,12 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
if (value != null && !(value instanceof PsiCallExpression)) {
for (UsageInfo info : usagesIn) {
PsiReference reference = info.getReference();
InlineUtil.TailCallType type = InlineUtil.getTailCallType(reference);
if (type == InlineUtil.TailCallType.Simple) {
conflicts.putValue(statement, "Inlined result won't be a valid statement");
break;
if (reference != null) {
InlineUtil.TailCallType type = InlineUtil.getTailCallType(reference);
if (type == InlineUtil.TailCallType.Simple) {
conflicts.putValue(statement, "Inlined result won't be a valid statement");
break;
}
}
}
}
@@ -30,6 +30,7 @@ import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -276,7 +277,7 @@ public class InlineUtil {
return result && nonTailCallUsages.isEmpty();
}
public static TailCallType getTailCallType(final PsiReference psiReference) {
public static TailCallType getTailCallType(@NotNull final PsiReference psiReference) {
PsiElement element = psiReference.getElement();
PsiExpression methodCall = PsiTreeUtil.getParentOfType(element, PsiMethodCallExpression.class);
if (methodCall == null) return TailCallType.None;