Repository navigation
New generics: specialise a subclass's superclasses without rewriting the list in place - #1422
Merged
Merged
Conversation
…the list in place A method of a generic class overridden again in a plain subclass and called through a non-generic base (class C<T:> extends Base, class D extends C<int>, Base.m() called) crashed the compiler with a ConcurrentModificationException on every target. adaptSubmethods rewrote D's superclass list in place with replaceAll(specializeType). Specialising C<int> runs the trigger registered on C, which specialises C.m and adapts its submethods, D.m among them, and so rewrites D's list again inside the outer replaceAll. The specialisation of a generic class's own superclasses had the same shape, and rewriteRuntimeTypeSuperEdges rewrites every class's list in place too. One helper now specialises a class's superclasses into a new list from a copy and replaces the old one; adaptSubmethods, specializeClass and the use queued for each non-generic class all call it. The InterfaceTranslator note which named this crash as a reason to skip generic classes is updated.
Member
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The compiler crashed with a
ConcurrentModificationExceptioninEliminateGenerics.adaptSubmethodson Jass, the interpreter and Lua. It happened when a method of a generic class was overridden again in a plain subclass and called through a non-generic base:adaptSubmethodsrewroteD's superclass list in place withreplaceAll(specializeType). SpecialisingC<int>runs the trigger registered onC. That trigger specialisesC.mand adapts its submethods,D.mamong them, so it rewritesD's list again inside the outerreplaceAll.The same in-place rewrite existed in two other places:
specializeClass, for a generic class's own superclasses.rewriteRuntimeTypeSuperEdges, which rewrites every class's list in place.Change
A new helper,
specializeSuperClasses, reads a class's superclass list from a copy and replaces the list rather than rewriting it in place. All three callers now use it:adaptSubmethodsspecializeClassThe
InterfaceTranslatornote named this crash as one reason the bridge skips generic classes. I removed that clause; the other reason still stands.Checks
GenericsWithTypeclassesTests: the plain subclass, and a subclass that also implements an interface. Both run on Jass, the interpreter and Lua. Both failed with the exception before this change and pass after it.GenericsWithTypeclassesTests,GenericsTests,ClassesTests,InterfaceTests,LuaBackendAuditTests,DeterministicChecks,FieldIterationTests,LuaKeyedMapTests,TreeShakerTests,LuaTranslationTests,BugTests,NewFeatureTests.-lua -inline -localOptimizations, produce Lua byte-identical to master. Zombie defense differs only in its embedded build minute.Not in this PR
The interface bridge from #1421 is still limited to non-generic classes. Extending it to generic classes is a separate change.