boolean (PsiCall callToInline, PsiType superType) { if (callToInline != null) { final PsiElement parent = callToInline.getParent(); if (parent instanceof PsiExpressionStatement || parent instanceof PsiSynchronizedStatement) { return true; } else if (parent instanceof PsiReferenceExpression) { return true; } else if (parent instanceof PsiExpressionList) { final PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(parent, PsiMethodCallExpression.class); if (methodCallExpression != null) { int paramIdx = ArrayUtil.find(methodCallExpression.getArgumentList().getExpressions(), callToInline); if (paramIdx != -1) { final JavaResolveResult resolveResult = methodCallExpression.resolveMethodGenerics(); final PsiElement resolvedMethod = resolveResult.getElement(); if (resolvedMethod instanceof PsiMethod) { PsiType paramType; final PsiParameter[] parameters = ((PsiMethod)resolvedMethod).getParameterList().getParameters(); if (paramIdx >= parameters.length) { final PsiParameter varargParameter = parameters[parameters.length - 1]; paramType = varargParameter.getType(); } else { paramType = parameters[paramIdx].getType(); } if (paramType instanceof PsiEllipsisType) { paramType = ((PsiEllipsisType)paramType).getComponentType(); } paramType = resolveResult.getSubstitutor().substitute(paramType); final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)callToInline).getClassOrAnonymousClassReference(); if (classReference != null) { superType = classReference.advancedResolve(false).getSubstitutor().substitute(superType); if (TypeConversionUtil.isAssignable(paramType, superType)) { return true; } } } } } } } return false; }