Skip to content

Build override error messages only where they are reported - #1538

Merged
Frotty merged 3 commits into
masterfrom
lazy-override-messages
Oct 22, 2026
Merged

Frotty merged 3 commits into
masterfrom
lazy-override-messages

Conversation

@Frotty

@Frotty Frotty commented Oct 22, 2026

Copy link
Copy Markdown
Member

Checking whether one function can override another built the message explaining why not. canOverride compared that message with null. Most pairs it compares are overloads with different parameter counts, so a build formatted thousands of messages nobody read. Each went through Utils.printElement, which runs three regular expressions for the element's type name, even for element kinds that never print it. NameLinks also built a message for every failed pair, but reads them only for a function marked override that overrides nothing.

Change:

  • canOverride and checkOverride share overrideError(..., explain), so canOverride gets a constant instead of a built message.
  • NameLinks records the failed pair, and makes its message only when reporting "does not override anything", in the same order.
  • printElement makes the readable type name only for the elements that print it.
  • No message text changes.

Measured on a large real map's Lua build, by JFR main-thread samples:

  • checkOverride fell from 22–33 samples to 0, printElement and makeReadableTypeName from 7–20 to 0, and canOverride from 14–19 to 3–6.
  • That is about 1% of the main thread, roughly 0.3 s of type check.
  • Phase wall times were too noisy on the shared machine to show it.
  • The emitted Lua is byte-identical to master's (cmp, over interleaved runs).

Tests, which assert the override messages: ClassesTests, ClassesExtTests, GenericsTests, GenericsWithTypeclassesTests, TypeClassTests, InterfaceTests, GenericSpecialisationMatrixTests, ModuleTests and DispatchImplementationTests all pass, 1,001 tests in total.

A check whether one function can override another built the message saying why not,
and most pairs it compares are overloads which cannot, so a large real map spent about
1% of its build formatting messages nobody read (three regular expressions each for
the element's type name). canOverride now asks for the answer alone, the class name
links record a failed override and make its message only for a function marked
override which overrides nothing, and printElement makes the readable type name only
for the elements which print it. The messages are unchanged.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-22T09:19:32.739178Z 7ed6fa6 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 22, 2026

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@Frotty

Frotty commented Oct 22, 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

String typeParameterError = checkOwnTypeParameters(func1.getDef(), func2.getDef());

P2 Badge Skip generic diagnostic construction in predicate mode

When canOverride compares same-arity methods whose own type-parameter counts or constraints differ, this unconditional call still constructs the full error string in checkOwnTypeParameters—including Utils.printElement/source formatting—even though explain is false. This leaves the hot predicate allocating diagnostics for generic overload sets and contradicts overrideError's documented constant-only predicate mode; pass explain into this check or separate the compatibility predicate from message construction.

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

… answer is asked

canOverride still built checkOwnTypeParameters' message, with the overridden function's printed
element and source, for a pair whose own type parameters differ in number or bounds. It now takes
explain too and answers with the constant.
@Frotty

Frotty commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

Addressed in 1284438: checkOwnTypeParameters takes explain too and returns the constant in predicate mode.

@Frotty

Frotty commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 128443808d

ℹ️ 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 22, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 7ed6fa6a5f

ℹ️ 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 22d980e into master Oct 22, 2026
2 checks passed
@Frotty
Frotty deleted the lazy-override-messages branch November 25, 2026 08:54
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