-
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
Changes from all commits
2221e47
a14d48c
4536f7f
7093420
74ca5c1
5b5839f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,8 +105,8 @@ Class C | |
End Class]]>.Value | ||
|
||
Dim expectedOperationTree = <![CDATA[ | ||
IAwaitOperation (OperationKind.Await, Type: System.Void, IsInvalid) (Syntax: 'Await UndefinedTask') | ||
Expression: | ||
IAwaitOperation (OperationKind.Await, Type: ?, IsInvalid) (Syntax: 'Await UndefinedTask') | ||
Expression: | ||
IInvalidOperation (OperationKind.Invalid, Type: ?, IsInvalid) (Syntax: 'UndefinedTask') | ||
Children(0) | ||
]]>.Value | ||
|
@@ -134,8 +134,8 @@ Class C | |
End Class]]>.Value | ||
|
||
Dim expectedOperationTree = <![CDATA[ | ||
IAwaitOperation (OperationKind.Await, Type: System.Void, IsInvalid) (Syntax: 'Await i') | ||
Expression: | ||
IAwaitOperation (OperationKind.Await, Type: ?, IsInvalid) (Syntax: 'Await i') | ||
Expression: | ||
IParameterReferenceOperation: i (OperationKind.ParameterReference, Type: System.Int32, IsInvalid) (Syntax: 'i') | ||
]]>.Value | ||
|
||
|
@@ -162,8 +162,8 @@ Class C | |
End Class]]>.Value | ||
|
||
Dim expectedOperationTree = <![CDATA[ | ||
IAwaitOperation (OperationKind.Await, Type: System.Void, IsInvalid) (Syntax: 'Await') | ||
Expression: | ||
IAwaitOperation (OperationKind.Await, Type: ?, IsInvalid) (Syntax: 'Await') | ||
Expression: | ||
IInvalidOperation (OperationKind.Invalid, Type: null, IsInvalid) (Syntax: '') | ||
Children(0) | ||
]]>.Value | ||
|
@@ -211,5 +211,115 @@ BC30800: Method arguments must be enclosed in parentheses. | |
|
||
VerifyOperationTreeAndDiagnosticsForTest(Of ExpressionStatementSyntax)(source, expectedOperationTree, expectedDiagnostics, useLatestFramework:=True) | ||
End Sub | ||
|
||
<CompilerTrait(CompilerFeature.IOperation)> | ||
<Fact, WorkItem("https://github.com/dotnet/roslyn/issues/67616")> | ||
Public Sub TestAwaitExpression_InStatement() | ||
Dim source = <![CDATA[ | ||
Imports System.Threading.Tasks | ||
|
||
Public Module Program | ||
Public Async Function M() As Task(Of Integer) | ||
Await M2()'BIND:"Await M2()" | ||
Return 0 | ||
End Function | ||
|
||
Public Function M2() As Task(Of String) | ||
Throw New System.Exception() | ||
End Function | ||
End Module | ||
]]>.Value | ||
|
||
Dim expectedOperationTree = <![CDATA[ | ||
IAwaitOperation (OperationKind.Await, Type: System.String) (Syntax: 'Await M2()') | ||
Expression: | ||
IInvocationOperation (Function Program.M2() As System.Threading.Tasks.Task(Of System.String)) (OperationKind.Invocation, Type: System.Threading.Tasks.Task(Of System.String)) (Syntax: 'M2()') | ||
Instance Receiver: | ||
null | ||
Arguments(0) | ||
]]>.Value | ||
|
||
Dim expectedDiagnostics = String.Empty | ||
|
||
VerifyOperationTreeAndDiagnosticsForTest(Of AwaitExpressionSyntax)(source, expectedOperationTree, expectedDiagnostics, useLatestFramework:=True) | ||
End Sub | ||
|
||
<CompilerTrait(CompilerFeature.IOperation)> | ||
<Fact, WorkItem("https://github.com/dotnet/roslyn/issues/67616")> | ||
Public Sub TestAwaitExpression_InStatement_InSubLambda() | ||
Dim source = <compilation> | ||
<file name="c.vb"><![CDATA[ | ||
Imports System | ||
Imports System.Threading.Tasks | ||
|
||
Public Module Program | ||
Public Sub Main() | ||
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 commentThe 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
Let's keep this scenario too. #Closed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Here I was referring to the body of the lambda rather than to the error. |
||
|
||
lambda() | ||
End Sub | ||
|
||
Public Function M2() As Task(Of String) | ||
System.Console.WriteLine("M2") | ||
Return Task.FromResult("") | ||
End Function | ||
End Module | ||
]]></file> | ||
</compilation> | ||
|
||
Dim expectedOperationTree = <![CDATA[ | ||
IAwaitOperation (OperationKind.Await, Type: System.String) (Syntax: 'Await M2()') | ||
Expression: | ||
IInvocationOperation (Function Program.M2() As System.Threading.Tasks.Task(Of System.String)) (OperationKind.Invocation, Type: System.Threading.Tasks.Task(Of System.String)) (Syntax: 'M2()') | ||
Instance Receiver: | ||
null | ||
Arguments(0) | ||
]]>.Value | ||
|
||
Dim expectedDiagnostics = String.Empty | ||
|
||
VerifyOperationTreeAndDiagnosticsForTest(Of AwaitExpressionSyntax)(source.Value, expectedOperationTree, expectedDiagnostics, useLatestFramework:=True) | ||
CompileAndVerify(source, expectedOutput:="M2", useLatestFramework:=True) | ||
End Sub | ||
|
||
<CompilerTrait(CompilerFeature.IOperation)> | ||
<Fact, WorkItem("https://github.com/dotnet/roslyn/issues/67616")> | ||
Public Sub TestAwaitExpression_InStatement_InSubWithExpressionLambda() | ||
Dim source = <compilation> | ||
<file name="c.vb"><![CDATA[ | ||
Imports System | ||
Imports System.Threading.Tasks | ||
|
||
Public Module Program | ||
Public Sub Main() | ||
Dim lambda As Action = Async Sub() Await M2()'BIND:"Await M2()" | ||
|
||
lambda() | ||
End Sub | ||
|
||
Public Function M2() As Task(Of String) | ||
System.Console.WriteLine("M2") | ||
Return Task.FromResult("") | ||
End Function | ||
End Module | ||
]]></file> | ||
</compilation> | ||
|
||
Dim expectedOperationTree = <![CDATA[ | ||
IAwaitOperation (OperationKind.Await, Type: System.String) (Syntax: 'Await M2()') | ||
Expression: | ||
IInvocationOperation (Function Program.M2() As System.Threading.Tasks.Task(Of System.String)) (OperationKind.Invocation, Type: System.Threading.Tasks.Task(Of System.String)) (Syntax: 'M2()') | ||
Instance Receiver: | ||
null | ||
Arguments(0) | ||
]]>.Value | ||
|
||
Dim expectedDiagnostics = String.Empty | ||
|
||
VerifyOperationTreeAndDiagnosticsForTest(Of AwaitExpressionSyntax)(source.Value, expectedOperationTree, expectedDiagnostics, useLatestFramework:=True) | ||
CompileAndVerify(source, expectedOutput:="M2", useLatestFramework:=True) | ||
End Sub | ||
End Class | ||
End Namespace |
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 will be good to have a test for a scenario when we are awaiting a
Task
rather than aTask(Of T)
. #ClosedThere 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.
I think
TestAwaitExpression
(first test in that file) covers that.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.
Emit, execution, optionally IOperation.