diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java index bf68e18d2f3d..98d8894c7034 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java @@ -427,7 +427,12 @@ public class GenerateMembersUtil { private static PsiType substituteType(final PsiSubstitutor substitutor, final PsiType type) { final PsiType psiType = substitutor.substitute(type); - if (psiType != null) return psiType; + if (psiType != null) { + final PsiType deepComponentType = psiType.getDeepComponentType(); + if (!(deepComponentType instanceof PsiCapturedWildcardType || deepComponentType instanceof PsiWildcardType)){ + return psiType; + } + } return TypeConversionUtil.erasure(type); } diff --git a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java index 0dcb61f2251d..d4fe594814c9 100644 --- a/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java +++ b/java/java-impl/src/com/intellij/refactoring/typeMigration/TypeMigrationLabeler.java @@ -116,7 +116,7 @@ public class TypeMigrationLabeler { usages.add(new UsageInfo(expr) { @Nullable public String getTooltipText() { - final PsiType type = expr.getType(); + final PsiType type = expr.isValid() ? expr.getType() : null; if (type == null) return null; return "Cannot convert type of the expression from " + type.getCanonicalText() + " to " + p.getSecond().getCanonicalText(); diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java index dbfc77322661..45efd2b53250 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java @@ -115,8 +115,8 @@ public class TypeConversionUtil { final PsiClass psiClass = classType.resolve(); if (psiClass == null || psiClass instanceof PsiTypeParameter) return false; final PsiClassType boxedType = ((PsiPrimitiveType)toType).getBoxedType(psiClass.getManager(), psiClass.getResolveScope()); - if (boxedType != null) { - return isAssignable(fromType, boxedType); + if (boxedType != null && isAssignable(fromType, boxedType)) { + return true; } } return fromTypeRank == toTypeRank || diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java index c967a7328b62..8be16fc1db85 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PolymorphicTypeCast.java @@ -90,4 +90,8 @@ class C { } void m(int i) { } + + void asLongs(Integer i) { + long l = (long) i; + } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterErasureWildcard.java b/java/java-tests/testData/codeInsight/overrideImplement/afterErasureWildcard.java new file mode 100644 index 000000000000..4c7590955daa --- /dev/null +++ b/java/java-tests/testData/codeInsight/overrideImplement/afterErasureWildcard.java @@ -0,0 +1,9 @@ +interface Generic { + T foo(); +} + +class II implements Generic { + public Object foo() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/overrideImplement/beforeErasureWildcard.java b/java/java-tests/testData/codeInsight/overrideImplement/beforeErasureWildcard.java new file mode 100644 index 000000000000..9c2cfbc37a34 --- /dev/null +++ b/java/java-tests/testData/codeInsight/overrideImplement/beforeErasureWildcard.java @@ -0,0 +1,7 @@ +interface Generic { + T foo(); +} + +class II implements Generic { + +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java index 6de5002321a7..0e8813f19043 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplementTest.java @@ -61,6 +61,7 @@ public class OverrideImplementTest extends LightCodeInsightTestCase { public void testClone() { doTest(false); } public void testOnTheLineWithExistingExpression() { doTest(false); } public void testSimplifyObjectWildcard() { doTest(false); } + public void testErasureWildcard() { doTest(false); } public void testImplementExtensionMethods() { doTest8(false, true); } public void testDoNotImplementExtensionMethods() { doTest8(false, true); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/HTMLComposerImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/HTMLComposerImpl.java index d48c53a4915a..dc75dd7ed4ea 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/HTMLComposerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/HTMLComposerImpl.java @@ -126,17 +126,18 @@ public abstract class HTMLComposerImpl extends HTMLComposer { final HTMLComposerExtension extension = getLanguageExtension(refElement); if (extension != null) { extension.appendShortName(refElement, buf); - } - refElement.accept(new RefVisitor() { - @Override public void visitFile(RefFile file) { - final PsiFile psiFile = file.getElement(); - if (psiFile != null) { - buf.append(B_OPENING); - buf.append(psiFile.getName()); - buf.append(B_CLOSING); + } else { + refElement.accept(new RefVisitor() { + @Override public void visitFile(RefFile file) { + final PsiFile psiFile = file.getElement(); + if (psiFile != null) { + buf.append(B_OPENING); + buf.append(psiFile.getName()); + buf.append(B_CLOSING); + } } - } - }); + }); + } } protected void appendQualifiedName(StringBuffer buf, RefEntity refEntity) { diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/FinalUtils.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/FinalUtils.java index 6ed4cfaec704..143da3cfdd17 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/FinalUtils.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/FinalUtils.java @@ -630,8 +630,9 @@ public class FinalUtils { } private void satisfyVacuously() { - definitelyAssigned = true; - definitelyUnassigned = true; + if (definitelyAssigned) { + definitelyUnassigned = true; + } } private static boolean isPrePostFixExpression( diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/field_final/FieldMayBeFinal.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/field_final/FieldMayBeFinal.java index c0d4b9886655..39803b92a53e 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/style/field_final/FieldMayBeFinal.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/style/field_final/FieldMayBeFinal.java @@ -398,4 +398,21 @@ class Q implements Iterator { public void remove() { throw new UnsupportedOperationException(); } +} +class R { + private static final String someStaticStuff; + static { + try { + someStaticStuff = ""; + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + + private String someInjectedStuff; + + public String getSomeInjectedStuff() { + return someInjectedStuff; + } } \ No newline at end of file