In response to a report from Raphael Valyi I have discovered some crucial flaws in the constant caching logic; some of them may not be reconcilable with the current design.
The first is when a value previously cached gets shadowed by new value in an intermediate module or class in the inheritance hierarchy:
This should print 1, then 2, but it prints 1 and 1.
The second case is when a previously cached value is shadowed by a new value in an intermediate module or class in the containment hierarchy.
The first case seems like it would be caused by bad generation-twiddling. It could probably be fixed by sorting out when generation-twiddling is not happening and making sure it is cascading properly.
The second case, however, is a more serious problem. Because we do not currently track cref containment from parent to child, there's no way for an update to a cref constant scope to inform containing scopes of the change. We would need to add a new weak list of contained crefs similar to the subclasses list currently in RubyModule.
If we can't resolve these problems 1.1.5 will have to ship without constant caching. I'm committing a change to temporarily disable constant caching, and I am adding the tests I describe above.