Skip to content

Cache anonymous object type instantiations #4464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 26, 2015
Merged

Conversation

ahejlsberg
Copy link
Member

Fixes #4443.

This PR adds a cache to TypeMapper which caches instantiations of anonymous object types previously created using that type mapper. The PR supercedes #4456.

@ahejlsberg
Copy link
Member Author

Tests copied from #4456.

@DanielRosenwasser
Copy link
Member

Can you also add this test?

tests/cases/compiler/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral03.ts

type TreeNode = {
    leftRight: [TreeNode, TreeNode];
};

function foo<U>(x: TreeNode) { }
var n: TreeNode;
foo(n);

@ahejlsberg
Copy link
Member Author

@DanielRosenwasser Don't think we need that test. It doesn't really test anything new, rather it just reveals an issue with the solution in #4456 that doesn't apply here.

@DanielRosenwasser
Copy link
Member

👍

@JsonFreeman
Copy link
Contributor

👍
I remember when we tried this before, but dismissed it because it didn't work for infinitely expanding anonymous types. But it sure works for recursive types.

@DanielRosenwasser
Copy link
Member

@JsonFreeman what are the cases in which it didn't work?

@JsonFreeman
Copy link
Contributor

@DanielRosenwasser, we fixed those already. See PR #3316 and #3452 (there are links to related issues there).

ahejlsberg added a commit that referenced this pull request Aug 26, 2015
Cache anonymous object type instantiations
@ahejlsberg ahejlsberg merged commit bbaf322 into master Aug 26, 2015
@ahejlsberg ahejlsberg deleted the cacheTypeInstantiations branch August 26, 2015 20:30
@DanielRosenwasser
Copy link
Member

@ahejlsberg can you cherry pick this into release-1.6 if it hasn't been done already?

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants