diff --git a/java/java-impl/src/com/intellij/psi/impl/source/PsiExpressionCodeFragmentImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/PsiExpressionCodeFragmentImpl.java index 375e12db888b..f1f9fd156b5f 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/PsiExpressionCodeFragmentImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/PsiExpressionCodeFragmentImpl.java @@ -47,8 +47,8 @@ public class PsiExpressionCodeFragmentImpl extends PsiCodeFragmentImpl implement @Override public PsiType getExpectedType() { PsiType type = myExpectedType; - if (type != null) { - LOG.assertTrue(type.isValid()); + if (type != null && !type.isValid()) { + return null; } return type; } diff --git a/java/java-psi-api/src/com/intellij/psi/PsiExpressionCodeFragment.java b/java/java-psi-api/src/com/intellij/psi/PsiExpressionCodeFragment.java index 355de2deb0a4..a0a4e1d79d34 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiExpressionCodeFragment.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiExpressionCodeFragment.java @@ -15,6 +15,8 @@ */ package com.intellij.psi; +import org.jetbrains.annotations.Nullable; + /** * Represents a fragment of Java code the contents of which is an expression. * @@ -34,7 +36,7 @@ public interface PsiExpressionCodeFragment extends JavaCodeFragment { * * @return the expected type of the expression. */ - PsiType getExpectedType(); + @Nullable PsiType getExpectedType(); /** * Sets the expected type of the expression (not used by the expression itself,