Fix/parse expression with expected types #190
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WARNING: This PR is still in progress and doesn't yet compile...
In this PR I want to try to change how arguments inside expressions are parsed. Before we first parse the arguments and then we try to search for a method that match the arguments. The problem of this approach is that in some cases we cannot parse the arguments without knowing what is the expected type.
For example in a case like:
The paramenter
p => p.SomeMethod()
cannot be parsed without knowing the type of thelist
variable and theWhere
method signature.The idea is that to instead check if each method is acceptable by parsing the arguments with the expected type, so for example in the above case parse the
p => p.SomeMethod()
knowin that we expect aFunc<TSource,bool> predicate
as a first argument ...This change require to invert some logic and to pass within all the parse stack the expected return type (see
expectedReturnType
).Also from now on I want to use
typeof(Object)
whenever we don't know the type instead of usingtypeof(void)
.In particular I have changed these methods:
ParseLambdaInvocation
,ParseDelegateInvocation
andParseMethodGroupInvocation
.PrepareDelegateInvoke
has been deleted and replaced withFindInvokeMethod
.The goal is to also fix #185 .