dotnet/roslyn

Unclear CS0252 (Possible unintended reference comparison)

Aberta

#58.996 aberto em 21 de jan. de 2022

 (0 comentário) (0 reação) (0 responsável)C# (4.257 forks)batch import
Area-CompilersBugConcept-Diagnostic Clarityhelp wanted

Métricas do repositório

Stars
 (20.414 estrelas)
Métricas de merge de PR
 (Mesclagem média 6d 17h) (256 fundiu PRs em 30d)

Description

Version Used:

17.1.0 P1.1

Steps to Reproduce:

using System;

public class C
{
    public void M(Action x, Action y)
    {
        _ = (MulticastDelegate)x == y;
    }
}

Expected Behavior:

Either no warning, or a more clear warning.

Actual Behavior:

warning CS0252: Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'MulticastDelegate'

Guia do colaborador