Skip to content

Ensure that lambdas are not cached in runtime async#82559

Merged
333fred merged 4 commits into
dotnet:mainfrom
333fred:nre
Mar 3, 2026
Merged

Ensure that lambdas are not cached in runtime async#82559
333fred merged 4 commits into
dotnet:mainfrom
333fred:nre

Conversation

@333fred

@333fred 333fred commented Feb 27, 2026

Copy link
Copy Markdown
Member

When we bind for return type inference, we don't yet know if the body of the lambda will be a Task/ValueTask, so we can't say for certain whether runtime async will be enabled in the lambda. Therefore, when we come back to do real binding, and we do know for certain that the lambda is runtime async capable, we need to rebind with runtime async enabled. Fixes #82551.

Relates to test plan #75960

When we bind for return type inference, we don't yet know if the body of the lambda will be a `Task`/`ValueTask`, so we can't say for certain whether runtime async will be enabled in the lambda. Therefore, when we come back to do real binding, and we do know for certain that the lambda is runtime async capable, we need to rebind with runtime async enabled. Fixes dotnet#82551.
Comment thread src/Compilers/CSharp/Portable/BoundTree/UnboundLambda.cs Outdated
Comment thread src/Compilers/CSharp/Portable/BoundTree/UnboundLambda.cs Outdated
Comment thread src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncTests.cs Outdated
@AlekseyTs

AlekseyTs commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Done with review pass (commit 1) #Closed

@jcouv jcouv self-assigned this Feb 27, 2026
@333fred

333fred commented Mar 2, 2026

Copy link
Copy Markdown
Member Author

@AlekseyTs @jcouv @dotnet/roslyn-compiler for reviews

@AlekseyTs

This comment has been minimized.

Comment thread src/Compilers/CSharp/Portable/Symbols/Source/LambdaSymbol.cs Outdated
@AlekseyTs

AlekseyTs commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Done with review pass (commit 2) #Closed

@333fred

333fred commented Mar 3, 2026

Copy link
Copy Markdown
Member Author

@AlekseyTs address your feedback. @jcouv for review as well.

}

Debug.Assert(ReferenceEquals(method.ContainingAssembly, Assembly));
Debug.Assert(method.IsDefinition);

@AlekseyTs AlekseyTs Mar 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Debug.Assert(method.IsDefinition);

Is it expected that this method will be called for non-definition non-method?

@AlekseyTs AlekseyTs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM (commit 4)

@jcouv jcouv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM Thanks (commit 4)

@333fred 333fred enabled auto-merge (squash) March 3, 2026 23:07
@333fred 333fred merged commit 6cc99f7 into dotnet:main Mar 3, 2026
23 of 24 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Mar 3, 2026
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.

[RuntimeAsync] NullReferenceException in RuntimeAsyncRewriter.VisitAwaitExpression when compiling large project

4 participants