a9f684e624
In https://dartbug.com/55357 a crash is reported happening after a hot restart (not reload!) with a compilation error. This causes a "reject" call, which means we create a new incremental compiler, initializing it from the component of the previous good world. World 1: Initial state. World 2: The library is new, but (most) references are reused because of advanced invaidation. References of unnamed extensions are not reused. Instead the canonical names are unbound (so they can successfully be bound to the new reference). We now have: * ref1 (from world1) pointing to no canonical name. * ref2 (from world2) pointing to the canonical name. * The canonical name pointing to ref2. This world is rejected. World 3: We start from the world 1 state, but because world 2 *did* happen and that only most references (i.e. not references for unnamed extensions) were reused, when about to unbind the unnamed extenesion we are looking at ref1 and have nothing to unbind. Compiling creates ref3 (from world 3). Upon attempt to serialize we try to bind the canonical name to "ref3", but it is already bound to "ref2" and we crash. The main problem here is that not only `Reference`s are reused, but because `Reference`s point to `CanonicalName`s these are reused too. This CL clears the canonical name in the references in the libraries that are reused, meaning that a whole new canonical name tree for those libraries will be created. This is more in line with what the non-advanced-invalidation does (by it not reusing references and naturally getting a whole new canonical name tree). In my opinion it even makes more sense --- and the fact that the canonical names were reused was probably more me not thinking about it, than it was a deliberate design decision. Fixes https://github.com/dart-lang/sdk/issues/55357 Change-Id: I90bd579984f4aefad78243e8366ac0ab91a905bf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363563 Commit-Queue: Jens Johansen <jensj@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>