boolean (PsiElement element, PsiClass targetClass) { if (element instanceof PsiExpression) { ExpectedTypeInfo[] types = ExpectedTypesProvider.getExpectedTypes((PsiExpression)element, false); if (types.length == 1) { PsiType type = types[0].getType(); return type.isAssignableFrom(JavaPsiFacade.getElementFactory(element.getProject()).createType(targetClass)); } } return false; }