[Proposal] Infer generic type arguments from deconstruction variables #8408
Unanswered
BlinD-HuNTeR
asked this question in
Language Ideas
Replies: 1 comment 3 replies
-
Since no one gave me attention, I decided to implement it myself 😂 As a bonus, the package also enables inference of type parameters from constraints (based on pull request #7850) |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Consider the following example:
Compiler is unable to infer the correct types, even though all necessary information is there.
If I try to manually call the Deconstruct method with out parameters, it works as expected.
It turns out that this is a really simple fix, pretty much one line of code (plus 1 line of XML):
And change the
BoundNodes.xml
file such that theType
is no longer "AlwaysNull":2529 2529 <Node Name="OutDeconstructVarPendingInference" Base="BoundExpression"> 2530 2530 <!-- Type is not significant for this node type; always null --> - 2531 <Field Name="Type" Type="TypeSymbol?" Override="true" Null="always"/> 2532 2531 <Field Name="VariableSymbol" Type="Symbol?"/> 2533 2532 <Field Name="IsDiscardExpression" Type="bool" Null="NotApplicable"/> 2534 2533 </Node>
After making the above changes, the example compiles perfectly and works as expected.
Beta Was this translation helpful? Give feedback.
All reactions