diff --git a/java/java-analysis-impl/src/com/intellij/refactoring/util/duplicates/Match.java b/java/java-analysis-impl/src/com/intellij/refactoring/util/duplicates/Match.java index ef633f70fa50..40c96324523e 100644 --- a/java/java-analysis-impl/src/com/intellij/refactoring/util/duplicates/Match.java +++ b/java/java-analysis-impl/src/com/intellij/refactoring/util/duplicates/Match.java @@ -402,7 +402,7 @@ public final class Match { final PsiMethod replacedMethod = PsiTreeUtil.getParentOfType(parent, PsiMethod.class); LOG.assertTrue(replacedMethod != null); final PsiType replacedMethodReturnType = replacedMethod.getReturnType(); - if (weakerType(psiMethod, returnType, replacedMethodReturnType)) { + if (replacedMethodReturnType != null && weakerType(psiMethod, returnType, replacedMethodReturnType)) { return replacedMethodReturnType; } } @@ -411,7 +411,7 @@ public final class Match { return null; } - private static boolean weakerType(final PsiMethod psiMethod, final PsiType returnType, final PsiType currentType) { + private static boolean weakerType(final PsiMethod psiMethod, final PsiType returnType, @NotNull final PsiType currentType) { final PsiTypeParameter[] typeParameters = psiMethod.getTypeParameters(); final PsiSubstitutor substitutor = JavaPsiFacade.getInstance(psiMethod.getProject()).getResolveHelper().inferTypeArguments(typeParameters, new PsiType[]{returnType}, new PsiType[]{currentType}, PsiUtil.getLanguageLevel(psiMethod));