At the moment, type specifications from ParticleSpecs are eagerly copied into HandleConnections when the HandleConnection is created. Because of type variables, this means that there can be shared references to variable info objects from the ParticleSpec and from the HandleConnection.
This in turn means that when cloning ParticleSpec objects as part of a recipe clone, we need to clone them with the same context as we cloned the recipe Particle with. Previously this wasn't a problem because all HandleConnections were eagerly created and we could ignore the ParticleSpec at that point.
What we should do instead is always clone the ParticleSpec types into the relevant handles immediately before type-checking. This will also allow us to get rid of the type/rawType confusion, and we can probably do something similar for storage types.
In addition it would be good to remove our dependence on null in the type checker, which would help with adding types to the file (as null has type any).
At the moment, type specifications from ParticleSpecs are eagerly copied into HandleConnections when the HandleConnection is created. Because of type variables, this means that there can be shared references to variable info objects from the ParticleSpec and from the HandleConnection.
This in turn means that when cloning ParticleSpec objects as part of a recipe clone, we need to clone them with the same context as we cloned the recipe Particle with. Previously this wasn't a problem because all HandleConnections were eagerly created and we could ignore the ParticleSpec at that point.
What we should do instead is always clone the ParticleSpec types into the relevant handles immediately before type-checking. This will also allow us to get rid of the type/rawType confusion, and we can probably do something similar for storage types.