Repository navigation
TSLANG 212: generic class for a constructor type, own instanceof narrowing and forward captures, constructor interfaces, rc leak of calls through function values - #1046
Merged
Conversation
…arrowing borrows + generic instanceof (164), own record strings into dictionaries (152), own forward-captured consts (144), array of a union as members (191), class to a constructor interface (139), object literal function callee named Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ree one keeps its cast) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…); an implicit conversion stays as it was Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Leftovers from 211's triage (TSLANG 212), plus a leak found along the way. It affected every call through a function value under
-mm=rc.Fixed
fruitFactory1(Banana)fornew (...args: any[]) => TFruit) failed with "Can't find class Banana". Its type arguments now come from the constructor type's parameters. A rest parameter's element type goes to each constructor parameter the others don't reach, including the constructor's own rest, soanygivesBanana<any>, as in TypeScript. The tsc test contextualSignatureInstantiation4 compiles.-mm=own. An interface narrowed to a class byinstanceof(v: IAorIA | IB) failed with "'v' is a parameter, kept here". The narrowed value is now the object the interface holds, a borrow like the interface itself.00union_interfaces_instanceof.tsnow runs under own as well.instanceofon a generic class.v instanceof Gnarrowed to the generic class itself. For an interfacevthat crashed the compiler; for a union it failed with "Can't resolve property". It now narrows a union to the members that are aG<T>(or derive from one), and otherwise doesn't narrow.-mm=own. A record's strings spread into a dictionary, or given toObject.assign, failed with "a value that borrows a field cannot be stored". The strings are now copied. A literal given toObject.assigngoes into a local of its own, which releases what it holds.-mm=own. Aconstread by a function declared before it (const f = () => g(); const g = () => 10;) failed with "'g' is captured by a closure, but -mm=own cannot tell who owns its value". The variable now owns the value its declaration gives it. Aconstinitialized with a borrow (const q = p) is still refused, as before.x.slice(1) as readonly string[], tsc sliceResultCast) failed at lowering with no location. It is now converted element by element into a new array, but only for an explicitasor<T>assertion of a union that carries a tag. An implicit conversion (const s: string[] = m), which TypeScript refuses, fails as before.interface PtCtor { new (x: number): Pt },const c: Constructor<A> = A) is now accepted. Before, it was TSLANG 204's error, which only replaced an internal error. An interface with other members as well is still refused, andclass_itself_interface_error.tsnow tests that. Under own this is still refused, as it already was for a construct signature in a type literal.o.make(i)). The call now names its callee, so its result is released. It leaked under rc and own.Leak in the DefaultLib (DefaultLib #122)
Temporal.Nowwithout@owned. Its functions were the only heap results in the library the compiler couldn't classify.Not done (recorded in TSLANG_ISSUES 212)
new c(i)through a type literal's construct signature crashes at run time. It did before this change too.Checks
o.make(i).🤖 Generated with Claude Code