private static ThreeState canPassFunctionalExpression(PsiClass sam, PsiType paramType, PsiElement place) {
    if (paramType instanceof PsiEllipsisType) {
      paramType = ((PsiEllipsisType)paramType).getComponentType();
    }
    String paramClassName = paramType instanceof PsiClassType ? ((PsiClassType)paramType).getClassName() : null;
    if (paramClassName == null) return ThreeState.NO;

    if (paramClassName.equals(sam.getName()) && sam.getManager().areElementsEquivalent(sam, ((PsiClassType)paramType).resolve())) {
      return ThreeState.YES;
    }

    if (isTypeParameterVisible(paramClassName, place) &&
        ((PsiClassType)paramType).resolve() instanceof PsiTypeParameter &&
        hasSuperTypeAssignableFromSam(sam, paramType)) {
      return ThreeState.UNSURE;
    }
    return ThreeState.NO;
  }
private static ThreeState canPassFunctionalExpression(PsiClass sam, PsiType paramType, PsiElement place)