Fix possible StackOverflowError in emitOn.