public static IMember GetReturnValueFromAnnotation(ExpressionEval eval, Expression annotation) { if (eval == null || annotation == null) { return(null); } var annotationType = eval.GetTypeFromAnnotation(annotation, LookupOptions.All); if (annotationType.IsUnknown()) { return(null); } // Annotations are typically types while actually functions return // instances unless specifically annotated to a type such as Type[T]. // TODO: try constructing argument set from types. Consider Tuple[_T1, _T2] where _T1 = TypeVar('_T1', str, bytes) var t = annotationType.CreateInstance(ArgumentSet.Empty(annotation, eval)); // If instance could not be created, such as when return type is List[T] and // type of T is not yet known, just use the type. var instance = t.IsUnknown() ? (IMember)annotationType : t; return(instance); }