Conversation
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.
Discussion experiment
Try a direct-base assignability shortcut for a generic interface that adds members to another generic interface:
This is a draft in my fork for review before proposing anything upstream. There is no associated upstream Backlog issue yet, and this is not ready for upstream submission.
The checker already normalizes single-base interfaces with no own members through
getSingleBaseForNonAugmentingSubtype. Adding even one member excludes that normalization. This experiment adds a one-way shortcut for assignability, without replacing the source type or changing generic inference.Scope
33 implementation lines across two existing checker files. Only different interface-reference targets in the assignable relation are eligible. The source must have generic arguments and exactly one direct base whose generic target matches the destination. Exclude variance marker types, explicit source
thisarguments, declarations containingthis, bases not proven this-free by the existing helper, own member overrides, and added call/construct/index signatures.Instantiate the matching base with the source arguments and use the existing relation machinery. Only
TernaryTruereturns early; all other outcomes retain the structural fallback and its diagnostics. This is intentionally conservative, with no new cache in the first prototype.The motivating Mongoose hierarchy is not covered by the current this-free restriction. This draft does not claim to recover the previously observed application-level benefit of changing an interface wrapper to an intersection. It isolates a possible assignability mechanism for discussion.
Measurements
Unmodified upstream
432307174150be61eb931ef1f754277f7197c117versus this patch, using separately built native binaries. Three runs per version, alternating order. All checks exit 0. The compiler fixture uses a distinct--tsBuildInfoFilefor every run; no traces. Counts reproduced exactly in these runs.The last row is a small regression (+48, approximately 0.02%). This is not evidence of a general compiler speedup. The large-wrapper median check time was 0.311s → 0.181s; compiler-fixture median was 0.683s → 0.690s. These short timings on a shared machine need stronger measurement before drawing conclusions.
An initial recursively expanding unrelated-target stress case was interrupted while running the unmodified compiler; it is not represented by the completed unrelated-target control above. Initial compiler-fixture runs reused incremental state and were discarded in favor of the fresh-build-info runs reported here.
Reproduce the synthetic cases
Build one binary at the base commit and one with the patch:
go -C tsc build -o /tmp/ts-before ./cmd/tsc # Apply the patch, then: go -C tsc build -o /tmp/ts-after ./cmd/tscGenerate the standalone cases:
Run each binary with
--noEmit --strict --extendedDiagnostics /tmp/large.ts(and the other two files). For the repository fixture:Correctness checks
Generated the new fixture's diagnostics/types/symbols baselines with the unmodified compiler, then verified the prototype matches them. It covers matching and incompatible arguments, argument substitution, missing derived members, narrowed overrides, multiple bases, polymorphic
this, overloads, recursion, and generic inference.No existing baselines changed. The upstream dprint check passes for both changed Go files, and
git diff --checkpasses. The initial Go/formatter sandbox failures were rerun successfully with access to the installed toolchain/cache. The full CONTRIBUTING.md release/API/language-service/lint validation matrix has not been run.Questions for review
thisworthwhile, and how should the inheritedthisargument be represented?AI assistance
Drafted and tested with GPT-6 via Codex at my request, following a specific investigation into generic interface-wrapper comparisons. This fork draft is for my review before any upstream submission.