Deconstruct with exact type match should be preferred in case in ambiguity #3828
Replies: 4 comments
-
Since this is requesting a language change, transferring to |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@HaloFour Well there's no way to disable the generated Deconstruct with record types without losing the convenient shorthand for properties and constructors. |
Beta Was this translation helpful? Give feedback.
-
Symmetry between construction/deconstruction is one of the purposes of positional records. You could use a nominal record. That doesn't have either a constructor or deconstructor, but you can use initializers and bring your own Deconstruct method. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Version Used: latest master (687393280df246e67b5878c5377b1a6b062fa3b1)
Steps to Reproduce: https://sharplab.io/#v2:EYLgtghgzgLgpgJwD4DsJjlADhAxnAAgAEBGAOgCUBXFGASwzIGEB7MLOgG0QGVEA3OvigEA3sQBMBAJJQAogA94CNJ2ko6MMQQC+ugLAAoI0QDMBBHFwsEAEwIANABR1aBBQEptOk+cvW7AgBNJwd3L3EzYgAWAgARKxYUWAQqXBgnFiotVy0wLwBeAD4CMAIC9zIFAG4DY0MiKQAtbWAWFk4CACEnIIIAT0KS/oI6ERCSD1qfQyA==
Expected Behavior: The overload with
int
is chosen since1
is anint
which is an exact type match.Actual Behavior:
error CS0121: The call is ambiguous between the following methods or properties: 'Y.Deconstruct(out X)' and 'Y.Deconstruct(out int)'
Beta Was this translation helpful? Give feedback.
All reactions