Repository navigation
Old generics: bridge an interface implemented through a superclass - #1419
Conversation
InterfaceTranslator took the type arguments of the interface only from the class's own implements list. A subclass of a class implementing I<real>, or a class implementing J<real> with J<T> extends I<T>, got an empty binding, so its implementation was registered without the bridge which converts the argument from its index: Jass and the interpreter passed the index as the real, Lua bound the superclass's bridge. The binding is taken from the class's transitive super interfaces now.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a8a302d553
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
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 |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
The lookup walked the superclass before the class's own interfaces, so a class which implements I itself could be bound by the I its superclass implements. It goes breadth first now, own interfaces before the superclass at each level, as the direct lookup preferred them before.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbe4656d84
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
With old generics, a class implementing
I<real>(a type withrealToIndex/realFromIndex) gets a bridge,B_foo_wrapper, which converts the index back to the real before calling its implementation (OverrideUtils.addOverride).InterfaceTranslatorlooked for the interface's type arguments only in the class's ownimplementslist, so every other instance of the interface got an empty binding and its implementation was registered as a sub-method without a bridge:viaI(new D())should be 1500. Jass and the interpreter passed the index (15) as the real and returned 15000; Lua bound D's slot toB_foo_wrapperand returned 150. A subclass without its ownfoofailed too (viaI(new D())!= 150), and so did a class implementingJ<real>withinterface J<T> extends I<T>(theTODO also add extended interfacesin that loop). This predates the recent commits; the audit of the dispatch commits found it.The binding is now taken from
transitiveSuperInterfaces(), which applies the type arguments along the superclass and extended-interface chain.Tests (GenericsTests): an overriding subclass, a subclass without an override and an implementation of an extending interface, each on the Jass variants and Lua; all three fail on master and pass with the change. GenericsTests, InterfaceTests, ClassesTests, ClosureTests, GenericsWithTypeclassesTests, NewFeatureTests, DeterministicChecks, LuaBackendAuditTests and LuaTranslationTests pass. Castle fight and zombie defense (Lua, -inline -localOptimizations) compile to the same scripts (zombie defense differs only in its embedded build time).