摘要:
One embodiment of the present invention provides a system for generating executable code. During operation, the system receives source code, wherein the source code can include declarations for types and operations, wherein the type declarations may be parameterized, and wherein the source code may specify subtyping relationships between declared types. Next, the system compiles or interprets the source code to produce executable code, wherein the type parameters may be instantiated by different types during execution, and wherein the result of executing operations may depend upon the instantiations of the type parameters. While compiling or interpreting the source code, the system checks the types and operations in the source code to ensure that the executable code generated is type-safe, and hence will not generate type errors during execution.