Your code probably means companion . It is a kind of factory in imperative languages.
Basically, you have a couple of objects and a class . An object (singleton in imperative langs) cannot be created several times, as people have already noted here, and is usually used to define some static logic. In fact, there is only one instance - when you call it for the first time. But an object can have compaion - an ordinary class, and, as I think, you missed the definition of this ordinary class, so the object cannot see anyone other than itself.
The solution is to define this class or omit new (but I think that would be logically wrong).
source share