Reporter | Guest 256 (guest256) |
---|---|
Created | Jul 25, 2012 7:06:04 PM |
Updated | Apr 16, 2018 2:51:42 PM |
Subsystem | Quick Fixes - Create From Usage |
Assignee | Alisa Afonina (alisa.afonina) |
Priority | Normal |
State | Submitted |
Type | Bug |
Fix version | Backlog |
Affected versions | 2018.1, 7.0 |
Fixed In Version ReSharper | Undefined |
VsVersion | All Versions |
Original code:
Current:
Expected:
Having overloaded methods with different return types isn't best practice, so R# should create overloads with the same return type.
Note: replacing implicitly-typed variable “i” with explicitly-typed solves the problem, but it's workaround because R# type will inferred from usage, not from overload origin.
internal static class Bar
{
public static void SomeMethod()
{
var i = Foo(DateTime.Now);
^
// set cursor here and call “Create overload for 'Foo'” action
}
private static int Foo(string s)
{
return 42;
}
}
Current:
internal static class Bar
{
public static void SomeMethod()
{
var i = Foo(DateTime.Now); // compilation error, cannot assign void value!
}
private static void Foo(DateTime now) // return type is void
{
throw new NotImplementedException();
}
private static int Foo(string s)
{
return 42;
}
}
Expected:
internal static class Bar
{
public static void SomeMethod()
{
var i = Foo(DateTime.Now);
}
private static int Foo(DateTime now) // return type is int
{
throw new NotImplementedException();
}
private static int Foo(string s)
{
return 42;
}
}
Having overloaded methods with different return types isn't best practice, so R# should create overloads with the same return type.
Note: replacing implicitly-typed variable “i” with explicitly-typed solves the problem, but it's workaround because R# type will inferred from usage, not from overload origin.