These two functions were copied from InterfaceStubGenerator. I'm not sure where we should place them to remove duplication. Is there a good place?