diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/BindFieldsFromParametersAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/BindFieldsFromParametersAction.java index 1395cf126039..fecbdfc0da62 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/BindFieldsFromParametersAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/BindFieldsFromParametersAction.java @@ -75,6 +75,7 @@ public final class BindFieldsFromParametersAction implements ModCommandAction { private static boolean isAvailable(@NotNull PsiParameter psiParameter) { PsiType type = FieldFromParameterUtils.getSubstitutedType(psiParameter); + if (type != null && !type.isAssignableFrom(psiParameter.getType())) return false; PsiClass targetClass = PsiTreeUtil.getParentOfType(psiParameter, PsiClass.class); return FieldFromParameterUtils.isAvailable(psiParameter, type, targetClass) && psiParameter.getLanguage().isKindOf(JavaLanguage.INSTANCE); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/bindFieldsFromParameters/beforeMethodGeneric.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/bindFieldsFromParameters/beforeMethodGeneric.java new file mode 100644 index 000000000000..2c0113bb5ae6 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/bindFieldsFromParameters/beforeMethodGeneric.java @@ -0,0 +1,8 @@ +// "Bind constructor parameters to fields" "false" + +class Bar { + + void get(Class a) { + + } +} \ No newline at end of file