-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Detect circular instantiated types #3316
Conversation
if (type.flags & TypeFlags.Reference && depth >= 10) { | ||
let target = (<TypeReference>type).target; | ||
if (type.flags & (TypeFlags.Reference | TypeFlags.Instantiated) && depth >= 10) { | ||
let symbol = type.symbol; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary because you only refer to symbol
once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean. It is referenced in a loop that will run at least 10 times (as we known depth >= 10).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean just once lexically. I didn't know the runtime references count individually wrt to local vars.
👍 |
Conflicts: src/compiler/checker.ts src/compiler/types.ts
Detect circular instantiated types
Fixes #3309 (and revises fix for #3237).
This PR switches our
isDeeplyNestedGeneric
function to track both type references and instantiated anonymous types. The key change is that we use the symbol associated with the type as the tracked identity (which is always the symbol of the type being instantiated). We likewise now use symbols to track cyclic anonymous types in the type-to-string logic.The PR removes the anonymous type instantiation caching implemented in #3239 as it is no longer necessary.