1. A non-transitory computer-readable storage medium storing program instructions executable by a computer to implement a compiler, wherein the compiler is configured to: receive source code for a computer program; determine that the source code includes an assignment context associating a variable with a value, the assignment context having: a declaration expression introducing the variable, wherein the declaration expression specifies a part of a type for the variable and does not specify another part of the type for the variable, wherein: the type for the variable is a parameterized type; the part of the type specified in the declaration expression comprises a ground type; and the part of the type not specified in the declaration expression comprises one or more type arguments for the parameterized type; and an initialization expression whose evaluation will result in the value, wherein a type of the initialization expression is a parameterized type corresponding to a given ground type and one or more type arguments; infer the type for the variable based at least on the specified part of the type in the parameterized type in the declaration expression and on the parameterized type of the initialization expression, wherein to infer the type for the variable, the compiler is configured to: identify a generic type corresponding to the parameterized type of the initialization expression; identify a generic supertype of the identified generic type, wherein the identified generic supertype has the same ground type as a ground type indicated by the part of the type for the variable introduced in the declaration expression; and infer a parameterized type for the variable by parameterizing the generic supertype with one or more type arguments of the parameterized type of the initialization expression; in response to said inferring, bind the variable to the inferred type; and compile the source code into an executable version of the computer program, wherein the compiling is dependent on the binding of the variable to the inferred type.