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 infinite recursive generics #24211

Merged
merged 1 commit into from
Feb 22, 2021
Merged

Fix infinite recursive generics #24211

merged 1 commit into from
Feb 22, 2021

Conversation

hez2010
Copy link
Contributor

@hez2010 hez2010 commented Feb 21, 2021

Fix infinite recursive generics

Using recursive generics with nested type parameters will make AOT compilers impossible to complete compilation, because all methods and types need to be resolved at compile-time, but compiler has no way to know how many levels of recursion need to be expanded.

In this PR, I made the type of operation and verifySucceeded in ExecuteImplement and ExecuteImplementAsync be same to avoid recursive generics call with TResult = ExecutionResult<TResult>. It's a better way to fix the issue than previously attempt #20494 and won't affect maintainability and introduce any public API changes.

Fixes #20393

@roji
Copy link
Member

roji commented Feb 22, 2021

Another approach is to make the method non-recursive - this results in a tiny bit more code duplication, but makes it overall clearer for me personally (recursion always adds a mental tax): I played around with it a while back: roji@5a6251a.

@AndriySvyryd let us know what you think.

Copy link
Member

@AndriySvyryd AndriySvyryd left a comment

Choose a reason for hiding this comment

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

This is the fix I had in mind

@AndriySvyryd AndriySvyryd merged commit e134127 into dotnet:main Feb 22, 2021
@AndriySvyryd
Copy link
Member

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite generic expansions cause efcore perform poorly with AOT compilation
4 participants