More roboust isGenerator check.

/cc @jonathanong