Skip to content

Old generics: bridge an interface implemented through a superclass - #1419

Merged
Frotty merged 5 commits into
masterfrom
generic-bridge-subclass-override
Oct 9, 2026
Merged

Frotty merged 5 commits into
masterfrom
generic-bridge-subclass-override

Conversation

@Frotty

@Frotty Frotty commented Oct 9, 2026

Copy link
Copy Markdown
Member

With old generics, a class implementing I<real> (a type with realToIndex/realFromIndex) gets a bridge, B_foo_wrapper, which converts the index back to the real before calling its implementation (OverrideUtils.addOverride). InterfaceTranslator looked for the interface's type arguments only in the class's own implements list, so every other instance of the interface got an empty binding and its implementation was registered as a sub-method without a bridge:

class B implements I<real>
    override function foo(real t) returns int
        return R2I(t * 100.)
class D extends B
    override function foo(real t) returns int
        return R2I(t * 1000.)
function viaI(I<real> i) returns int
    return i.foo(1.5)

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 to B_foo_wrapper and returned 150. A subclass without its own foo failed too (viaI(new D()) != 150), and so did a class implementing J<real> with interface J<T> extends I<T> (the TODO also add extended interfaces in 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).

Frotty added 2 commits October 9, 2026 17:54
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T16:28:06.204209Z 34227a1 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Frotty

Frotty commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: b03ca7e331

ℹ️ 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".

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.
@Frotty

Frotty commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

@Frotty

Frotty commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 34227a171d

ℹ️ 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".

@Frotty
Frotty merged commit cd28120 into master Oct 9, 2026
3 checks passed
@Frotty
Frotty deleted the generic-bridge-subclass-override branch October 9, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant