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

Infer delegate type from lambda expression with explicit return statements without expressions #56236

Merged
merged 2 commits into from
Sep 14, 2021

Conversation

cston
Copy link
Member

@cston cston commented Sep 8, 2021

Fixes #55320.

Test plan #52192

@@ -624,7 +624,7 @@ private static TypeWithAnnotations DelegateReturnTypeWithAnnotations(MethodSymbo
returnType = inferredReturnType.TypeWithAnnotations;
returnRefKind = inferredReturnType.RefKind;

if (!returnType.HasType && returnTypes.Count > 0)
if (!returnType.HasType && inferredReturnType.NumExpressions > 0)
Copy link
Contributor

@AlekseyTs AlekseyTs Sep 9, 2021

Choose a reason for hiding this comment

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

if (!returnType.HasType && inferredReturnType.NumExpressions > 0)

It looks like the change only affects scenarios that involve return statements without expressions. Is this correct? If so, consider adjusting commit's title/description as right now it feels too broad. #Closed

@@ -624,7 +624,7 @@ private static TypeWithAnnotations DelegateReturnTypeWithAnnotations(MethodSymbo
returnType = inferredReturnType.TypeWithAnnotations;
returnRefKind = inferredReturnType.RefKind;

if (!returnType.HasType && returnTypes.Count > 0)
if (!returnType.HasType && inferredReturnType.NumExpressions > 0)
Copy link
Contributor

@AlekseyTs AlekseyTs Sep 9, 2021

Choose a reason for hiding this comment

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

inferredReturnType.NumExpressions > 0

It looks like all added tests are success tests. Do we have failure tests for this condition? Specifically when there is a mix of returns with and without an expression. #Closed

@AlekseyTs
Copy link
Contributor

Done with review pass (commit 1)

@cston cston changed the title Infer delegate type from lambda expression with explicit return statements Infer delegate type from lambda expression with explicit return statements without expressions Sep 13, 2021
@cston cston requested a review from a team September 13, 2021 21:30
Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 2)

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

LGTM (commit 2)

@cston cston merged commit 9f2ec4e into dotnet:main Sep 14, 2021
@ghost ghost added this to the Next milestone Sep 14, 2021
@cston cston deleted the 55320 branch September 14, 2021 22:51
@Cosifne Cosifne modified the milestones: Next, 17.0.P5 Sep 27, 2021
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.

Cannot infer delegate type for lambda expression with implicit and explicit return statements
4 participants