Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,19 @@ void Evaluate(ISymbol affectedSymbol, ITypeSymbol fromType, PooledConcurrentSet<
return;
}

// if any of the methods that are invoked on toType are explicit implementations of interface methods, then we don't want
// to recommend upgrading the type otherwise it would break those call sites
if (targets != null)
{
foreach (var t in targets)
{
// if any of the methods that are invoked on fromType are default implementations of interface methods,
// then we don't want to recommend upgrading the type because it would break those call sites.
if (!t.IsAbstract && fromType.TypeKind is TypeKind.Interface)
{
return;
}

// if any of the methods that are invoked on toType are explicit implementations of interface methods,
// then we don't want to recommend upgrading the type because it would break those call sites.
var check = toType;
while (check != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,32 @@ static int Bar()
await TestCSAsync(Source);
}

[Fact]
[WorkItem(50328, "https://github.com/dotnet/sdk/issues/50328")]
public static async Task ShouldNotTrigger6()
{
const string Source = @"
#nullable enable
interface IFoo
{
int M() => 42;
}
public class C : IFoo
{
}
public class Use
{
static int Bar()
{
IFoo f = new C();
return f.M();
}
}
";

await TestCSAsync(Source);
}

[Fact]
public static async Task ShouldTrigger_InterpolatedString_Mameof()
{
Expand Down
Loading