dotnet/roslyn

Unclear CS0252 (Possible unintended reference comparison)

开放

#58,996 创建于 2022年1月21日

 (0 条评论) (0 个反应) (0 位负责人)C# (4,257 个派生)batch import
Area-CompilersBugConcept-Diagnostic Clarityhelp wanted

仓库指标

星标
 (20,414 个星标)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

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'

贡献者指南