Copy into a C# 8.0 app:
#nullable enable
namespace ConsoleApp65
{
class C
{
void M()
{
object? o = null;
var s = (string?)o;
Console.WriteLine(s);
}
}
}
Invoke extract method on the "o" in the "var s..." line. Do not select the cast, just the o.
Expected: the generated method returns string? because that's the explicit cast before it.
Actual: it returns just string which breaks code.