Type Parameter Inference from Constraints #9454
Replies: 3 comments 2 replies
-
In your proposal you mentioned a possible breaking change example (in Drawbacks section). I'm referring to that one. When choosing extension methods during overload resolution the algorithm will select the one with the least generic arity - if I recall correctly. Shouldn't we do the very same here? That could remove that particular breaking. Do I miss something? |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
Due to the lack of this inference from constraints, the extensions feature introduced CS9295 for when an extension member does not reference every type parameter introduced by the Rationale for the following code: The public readonly record struct GridRowMovedArgs<TRowArgs>(TRowArgs Row, int NewIndex);
public static class GridRowMovedArgsExtensions
{
extension<TRow, TRowArgs>(GridRowMovedArgs<TRowArgs> args)
where TRowArgs : IndexedValueArgs<TRow>
{
// ❌ CS9295 The extended type 'GridRowMovedArgs<TRowArgs>' must reference all the type parameters declared by
// the extension, but type parameter 'TRow' is not referenced.
public int OldIndex => args.Row.Index;
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Champion issue: #9453
Discussion area for the championed type inference issue. This is by no means the first discussion topic on this, linked below, but I wanted to make a fresh topic for the championed proposal.
Beta Was this translation helpful? Give feedback.
All reactions