boolean (@Nullable PsiType exprType, @Nullable PsiType parameterType) { if (exprType == null || !exprType.isValid() || !(parameterType instanceof PsiClassType) || !parameterType.isValid()) { return false; } final PsiClassType.ClassResolveResult resolve = ((PsiClassType)parameterType).resolveGenerics(); final PsiClass resolvedClass = resolve.getElement(); if (resolvedClass == null || !CommonClassNames.JAVA_UTIL_OPTIONAL.equals(resolvedClass.getQualifiedName())) return false; final Collection<PsiType> values = resolve.getSubstitutor().getSubstitutionMap().values(); if (values.isEmpty()) return true; if (values.size() > 1) return false; final PsiType optionalTypeParameter = ContainerUtil.getFirstItem(values); if (optionalTypeParameter == null) return false; return TypeConversionUtil.isAssignable(optionalTypeParameter, exprType); }