-
Notifications
You must be signed in to change notification settings - Fork 820
Unused opens false positive: extension method is preferred to instance method #5306
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
Comments
I cannot run Unused Open analyser tests in any way (VS, cmd, Rider), see #5308, hence no fix for this. |
My impression is that this issue is more serious than "just" an unused open. I will restate the example code and explain how I think about it. This code compiles and the reference to using System;
namespace Ns1 {
public class Extended {
public void M(Action<string> _) { }
}
}
namespace Ns2 {
public static class ExtensionMethods {
public static void M(this Ns1.Extended a, Action<string> b) { }
}
} module Top
open Ns1
open Ns2 // marked as an unused open
type T() =
member _.Foo(_: string) = ()
member x.Bar() =
Extended().M(x.Foo) // M resolves to the instance method with that name I expect to be able to rename the instance method. I manually rename the definition and the one reference to it. However, the resulting code doesn't compile. using System;
namespace Ns1 {
public class Extended {
public void M1(Action<string> _) { }
}
}
namespace Ns2 {
public static class ExtensionMethods {
public static void M(this Ns1.Extended a, Action<string> b) { }
}
} module Top
open Ns1
open Ns2
type T() =
member _.Foo(_: string) = ()
member x.Bar() =
Extended().M1(x.Foo) // FS0002 This function takes too many arguments, or is used in a context where a function is not expected |
Uh oh!
There was an error while loading. Please reload this page.
During checking
open ...
statements, extension method is chosen instead of instance one, which differs from actual name resolution during the type check phase.A guess before looking into: It may be another getting declaring vs apparent entity bug.
The text was updated successfully, but these errors were encountered: