KEMBAR78
Fix infinite recursive generics by hez2010 · Pull Request #24211 · dotnet/efcore · GitHub
Skip to content

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