Skip to content
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

Fix inference to indexed access type containing substitution type #31141

Merged
merged 4 commits into from May 1, 2019

Conversation

ahejlsberg
Copy link
Member

Fixes #31086.

else if (target.flags & TypeFlags.IndexedAccess && (
(<IndexedAccessType>target).objectType.flags & TypeFlags.Substitution ||
(<IndexedAccessType>target).indexType.flags & TypeFlags.Substitution)) {
target = getIndexedAccessType(getActualTypeVariable((<IndexedAccessType>target).objectType), getActualTypeVariable((<IndexedAccessType>target).indexType));
Copy link
Member

Choose a reason for hiding this comment

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

What about a Substitute<T[Substitute<K>]>? Substitutes can in theory nest arbitrarily, provided they keep instantiating to type variables.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've moved the logic to getActualTypeVariable and made it recurse appropriately.

@ahejlsberg ahejlsberg merged commit 9509a54 into master May 1, 2019
@ahejlsberg ahejlsberg deleted the fixInferenceToIndexedAccessWithSubstitution branch May 1, 2019 00:45
@timsuchanek
Copy link
Contributor

Just tried it out - I can confirm that it's now working 🎉
Thanks for fixing this so quick!

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.

Regression in 3.4: Type inference with generic type guard breaks
4 participants