Skip to content

"Implement Interface" defines multiple methods for nested interfaces #5813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tracked by #15408
EBrown8534 opened this issue Oct 24, 2018 · 0 comments
Open
Tracked by #15408
Labels
Area-LangService-CodeFixes Code fixes associated with diagnostics Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone

Comments

@EBrown8534
Copy link

EBrown8534 commented Oct 24, 2018

This one is a bit weird, and I don't know if this is the right place for it.

If you define two interfaces that implement a common, third interface, the "quick action" (CTRL + .) will re-implement the common interface when it should not, even if the third interface is explicitly implemented. (If the third interface is not explicitly implemented, the quick-action does nothing.)

Repro steps

Consider the following code:

type IFoo =
    abstract member Foo : unit -> unit

type IBar =
    inherit IFoo
    abstract member Bar : unit -> unit

type IBaz =
    inherit IFoo
    abstract member Baz : unit -> unit
    abstract member Baz2 : unit -> unit

If you define a type, Foo as the following:

type Foo () =
    interface IFoo with
        member this.Foo () = ()
    interface IBar with
        member this.Bar() = raise (System.NotImplementedException())
    interface IBaz with
        member this.Baz() = raise (System.NotImplementedException())

The attempting to use the quick-action to implement IBaz completely will result in:

type Foo () =
    interface IFoo with
        member this.Foo () = ()
    interface IBar with
        member this.Bar() = raise (System.NotImplementedException())
    interface IBaz with
        member this.Baz2() = raise (System.NotImplementedException())
        member this.Foo() = raise (System.NotImplementedException())
        member this.Baz() = raise (System.NotImplementedException())

This is obviously not the correct action for a nested interface.

Expected behavior

The interface function that has already been implemented for a higher-level interface should not be reimplemented.

Actual behavior

The member is reimplemented, and FS0855: No abstract or interface member was found that corresponds to this override is thrown. (Thus, the resulting code cannot compile without modification.)

Known workarounds

Delete the extraneous member(s).

Related information

Provide any related information

  • Operating system: Microsoft Windows 10 Pro for Workstations
  • Branch: VS 15.7.5 Public Release
  • .NET Runtime, CoreCLR or Mono Version: .NET 4.7.2
  • Editing Tools (e.g. Visual Studio Version): Visual Studio 15.7.5
  • Links to F# RFCs or entries on https://github.com/fsharp/fslang-suggestions: Not Applicable
  • Links to performance testing scripts: Not Applicable
  • Indications of severity: Minor / Convenience
@cartermp cartermp added this to the 16.0 milestone Oct 28, 2018
@cartermp cartermp modified the milestones: 16.0, 16.1 Feb 21, 2019
@cartermp cartermp modified the milestones: 16.1, 16.2 Apr 23, 2019
@cartermp cartermp modified the milestones: 16.2, Backlog Apr 30, 2019
@dsyme dsyme added the Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. label Aug 26, 2020
@dsyme dsyme added Area-LangService-CodeFixes Code fixes associated with diagnostics and removed Area-LangService-API labels Apr 5, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Jun 17, 2022
@psfinaki psfinaki mentioned this issue Jun 15, 2023
85 tasks
@edgarfgp edgarfgp assigned edgarfgp and unassigned edgarfgp Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-LangService-CodeFixes Code fixes associated with diagnostics Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
Status: New
Development

No branches or pull requests

5 participants