Skip to content

IDE0004 false positive for overload by parameter type #55621

@MaceWindu

Description

@MaceWindu

Version Used:
VisualStudio.16.Release/16.11.0+31605.320
C# Tools 3.11.0-4.21403.6+ae1fff344d46976624e68ae17164e0607ab68b10

Steps to Reproduce:

#nullable enable
using System;
public class TestClass
{
	public TestClass(object? value) { }
	public TestClass(Func<object?> value) { }

        // IDE0004: Cast is redundant.
        public TestClass Create1() => new ((object?)null);
        // CS8625: Cannot convert null literal to non-nullable reference type
	public TestClass Create2() => new (null);
}

Expected Behavior:

Wether Create1 or Create2 shouldn't generate any messages.

Actual Behavior:

Both variants generate error or IDE warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEBughelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions