Skip to content

Simplify implementation of interface hierarchies with equally named abstract slots #1430

@T-Gro

Description

@T-Gro

I propose we do something about the situation described here: dotnet/runtime#116497 , which was triggered by a desired change in the BCL to make mutable generic ICollection interfaces implement IReadOnlyCollection types. This change now has a PR suggesting its revert, until F# makes it easier to consumer and/or to workaround.

Causing:

type C<'T> =

    interface ICollection<'T> with

       // members omitted for clarity

        member s.Count = s.Count
/* --------------^^^^^  error FS0361: The override 'get_Count: unit -> int' implements more than one abstract slot
, e.g. 'ICollection.get_Count() : int' and 'IReadOnlyCollection.get_Count() : int' */

The existing way of approaching this problem in F# is to know to explicitly declare implemented interfaces in case of slot conflicts.

Pros and Cons

The advantages of making this adjustment to F# are : Decrease chances of a BCL/C# change causing a source-break for F# programs.

The disadvantages of making this adjustment to F# are : It is a change.

Extra information

Estimated cost (XS, S, M, L, XL, XXL):
Related suggestions: (put links to related suggestions here)

Affidavit (please submit!)

Please tick these items by placing a cross in the box:

  • [x ] This is not a question (e.g. like one you might ask on StackOverflow) and I have searched StackOverflow for discussions of this issue
  • [ x] This is a language change and not purely a tooling change (e.g. compiler bug, editor support, warning/error messages, new warning, non-breaking optimisation) belonging to the compiler and tooling repository
  • [ x] This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it
  • [ x] I have searched both open and closed suggestions on this site and believe this is not a duplicate

Please tick all that apply:

  • [x ] This is not a breaking change to the F# language design
  • I or my company would be willing to help implement and/or test this

For Readers

If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions