1. A computer implemented method for generating a typed intermediate representation of a computer program, the method comprising: receiving a source code representation of the computer program in an object-oriented language, the source code representation comprising code portions related to defining one or more classes; and based on the source code representation, generating the typed intermediate representation of the computer program comprising at least some class name-based information which retains a class name-based class hierarchy expressed in the source code representation related to the one or more classes defined in the source code representation along with at least some structure- based information related to the one or more classes defined in the source code representation, by generating a class name-based representation of at least one of the one or more classes defined in the source code, and generating a corresponding structure-based record type representation of the at least one of the one or more classes defined in the source code; wherein generating the typed intermediate representation of the computer program further comprises: generating one or more coercion functions to coerce between objects of the class name-based representation of the class and records of the corresponding structure-based record type representation of the class; and generating an existential type that binds a type variable with sub-classing bounds, wherein the type variable represents an exact dynamic type corresponding to the at least one of the one or more classes defined in the source code.