-
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
IOperation: BoundLambda - value returned by IOperation.Type property might be inconsistent across languages #8851
Comments
@AlekseyTs is correct. Example time. Given the following C# code: using System;
class Program
{
static void Main(string[] args)
{
Action test = () => { };
}
} We have a syntax tree that looks like this: If we get the IOperation node for the
For the following VB code: Module Program
Sub Main(args As String())
Dim test = Sub()
End Sub
End Sub
End Module We get the following sytnax tree: Getting the IOperation of the
The difference here is twofold:
|
I actually think that we shouldn't get conversion node for an implicit conversion, therefore should go for the lowest node. Conversion can be discovered from looking at the parent node. |
Perhaps we should have an extension on ILambdaExpression for this? @jinujoseph, can we add this to next week's IOperation meeting? |
For getting the conversion? That isn't lambda specific, that is how it should work for all expressions, I believe. So, I am not sure if any special helper is needed, it is easy enough to look at the parent. |
I guess I'm just concerned that just getting the parent to find the the type of an expression doesn't feel like a particularly natural thing for me to do. |
We need to investigate SemanticModel.GetTypeInfo for lambdas. See in C# what GetTypeINfo returns for both "TypeInfo.Type" and "TypeInfo.ConvertedType". Our initial impression is that we probably want C# and VB to be the same (but htat might mean htat C# differs in IOperation from SemanticModel). We liked that lambdas were typeless as htat definitely matches VB's language interpretation, and we think it matches C#'s (though we need to confirm). |
If users want the type of a lambda, they would walk up to the parent conversion node if it exists. (we may provide an extension for this). |
I tested the following cases:
Looks like we'll want to make C#'s version be consistent with VB, as that's what the SemanticModel does. |
Fixed in e047f24. |
BoundLambda node in VB never has a Type, whereas in C# I believe it's Type is a target delegate type. If implementation of IOperation.Type simply returns value of the Type property, then returned value for VB will always be null and often (if not always) not null for C#.
I think IOperation.Type for ILambdaExpression should always be null and the target type (a delegate type or an Expression) can be discovered from the conversion on top of the lambda.
The text was updated successfully, but these errors were encountered: