A compiler may perform type checking as part of analyzing source code. The type checking may include existential type packing for structurally-restricted existential types. At compile time, the compiler may need to use an existential type that does not conform to the language's structural rules. The compiler may apply the “pack” operation described herein to produce a supertype of the desired existential type that does conform to the language's structural rules, and thus can be used as an approximation of the desired type. The compiler may then perform additional type checking using the resulting type.
展开▼