Detect factory functions by checking for returned values from new expressions