zzarchive-VisualFSharpPowerTools icon indicating copy to clipboard operation
zzarchive-VisualFSharpPowerTools copied to clipboard

Renaming virtual methods doesn't work

Open buybackoff opened this issue 8 years ago • 3 comments

This is an edge case, just stumbled upon it and wanted to let you know. Sorry if this is a know issue already.

If I rename the virtual TestMethod, its name in the overloaded method doesn't change. I am using version 1.9.0.

type Test() =
  abstract TestMethod: unit -> unit      // rename this
  default this.TestMethod() =                // or this with F2
    Console.WriteLine("No args")

  member this.TestMethod(txt:string) = 
    Console.WriteLine(txt)
    this.TestMethod()                             // this is unchanged

The result of renaming is:

type Test() =
  abstract TestMethod2: unit -> unit
  default this.TestMethod2() = 
    Console.WriteLine("No args")

  member this.TestMethod(txt:string) = 
    Console.WriteLine(txt)
    this.TestMethod()                          // error

For non-virtual methods it works as expected.

Before:

type Test() =

  member this.TestMethod() = 
    Console.WriteLine("No args")

  member this.TestMethod(txt:string) = 
    Console.WriteLine(txt)
    this.TestMethod() 

After:

type Test() =
  member this.TestMethod2() = 
    Console.WriteLine("No args")

  member this.TestMethod(txt:string) = 
    Console.WriteLine(txt)
    this.TestMethod2() 

It also works for abstract methods: Before:

[<AbstractClassAttribute>]
type Test() =

  abstract TestMethod: unit -> unit

  member this.TestMethod(txt:string) = 
    Console.WriteLine(txt)
    this.TestMethod() 

After:

[<AbstractClassAttribute>]
type Test() =

  abstract TestMethod2: unit -> unit

  member this.TestMethod(txt:string) = 
    Console.WriteLine(txt)
    this.TestMethod2()  

buybackoff avatar Jul 16 '15 11:07 buybackoff

Hm. I've never used virtual methods in F# :)

vasily-kirichenko avatar Jul 16 '15 13:07 vasily-kirichenko

This is also evident from the highlighting: image

If you remove the default keyword, it's highlighted (and renamed) just fine: image

Makes me think symbol usage is not returning correct results...

hmemcpy avatar Aug 08 '15 17:08 hmemcpy

@hmemcpy Yes, FCS gives us wrong data. It's not a new issue actually. See a related one at https://github.com/fsharp/FSharp.Compiler.Service/issues/189

dungpa avatar Aug 08 '15 18:08 dungpa