-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Use non-void type for BoundAwaitOperator
in VB statement
#67822
Conversation
@dotnet/roslyn-compiler for review. Thanks |
Consider to be more specific, "proper" doesn't provide enough clarity, in my opinion. In reply to: 1516336775 |
@@ -4909,7 +4901,7 @@ lElseClause: | |||
Return New BoundAwaitOperator(node, operand, | |||
awaitableInstancePlaceholder, getAwaiter, | |||
awaiterInstancePlaceholder, isCompleted, getResult, | |||
resultType, hasErrors) | |||
type:=getResult.Type, hasErrors) |
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.
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.
Also it would be good to test the effect of this change on an await
in a Sub expression lambda.
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.
a scenario when we are awaiting a Task rather than a Task(Of T).
I think TestAwaitExpression
(first test in that file) covers that.
an await in a Sub expression lambda.
Can you clarify what you'd like this test to verify? Just the IOperation node for the await in statement in lambda, or something else?
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.
Can you clarify what you'd like this test to verify? Just the IOperation node for the await in statement in lambda, or something else?
Emit, execution, optionally IOperation.
@@ -2,16 +2,10 @@ | |||
' The .NET Foundation licenses this file to you under the MIT license. | |||
' See the LICENSE file in the project root for more information. | |||
|
|||
Imports System.Collections.Generic |
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.
It looks like this file doesn't have meaningful changes. Please revert. #Closed
@@ -99,7 +93,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic | |||
Me.F.AssignmentExpression(Me.F.Local(resultTemp, True), rewrittenGetResult), | |||
clearAwaiterTemp, | |||
Me.F.Local(resultTemp, False)) | |||
|
|||
Else |
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.
The empty line before Else is intentional. #Closed
Done with review pass (commit 1) |
BoundAwaitOperator
in VB statementBoundAwaitOperator
in VB statement
@dotnet/roslyn-compiler for another review. Thanks |
]]>.Value | ||
|
||
Dim expectedDiagnostics = <![CDATA[ | ||
BC30491: Expression does not produce a value. |
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.
Is there a benefit in having this error?
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 think we actually want to verify that we can emit and run the code.
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.
This scenario hasn't changed. We already produce an error today, so I'm not sure what you're asking.
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.
This scenario hasn't changed. We already produce an error today, so I'm not sure what you're asking.
I am asking why you are testing this error scenario. An action cannot be awaited, and it really doesn't matter what is in the lambda that was used to create the Action. The error doesn't test anything related to the change you are making.
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.
So, unless you have a specific reason to test this error scenario in connection to the change that you are making, consider getting rid of the error and converting the test into a success form (build/execute) similar to the test below.
Public Async Function M() as Task | ||
Dim lambda As Action = Async Sub() | ||
Await M2()'BIND:"Await M2()" | ||
End Sub |
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.
This isn't an expression lambda though. And expression lambda would look like
Async Sub() Await M2()
Let's keep this scenario too. #Closed
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.
Let's keep this scenario too.
Here I was referring to the body of the lambda rather than to the error.
Await M2()'BIND:"Await M2()" | ||
End Sub | ||
|
||
Await lambda() |
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.
Done with review pass (commit 4) |
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.
LGTM (commit 5)
@dotnet/roslyn-compiler for second review. Thanks |
@dotnet/roslyn-compiler for a second review. Thanks |
Fixes #67616
I looked for places that use
BoundAwaitOperator.Type
. The main place that is affected is in AsyncRewriter.AsyncMethodToClassRewriter.Await.vb and it is still correct and covered (Task
andTask<T>
involve awaiters withGetResult()
methods that returnvoid
andT
respectively).