boolean (@NotNull PsiAnonymousClass anonymousClass, @NotNull PsiNewExpression expression) { PsiElement parent = expression.getParent(); if (parent instanceof PsiReferenceExpression || parent instanceof PsiAssignmentExpression) { return true; } ExpectedTypeInfo[] types = ExpectedTypesProvider.getExpectedTypes(expression, false); return types.length != 1 || !types[0].getType().equals(anonymousClass.getBaseClassType()); }