Skip to content

Nullable does not correctly look at object/collection initializers of NoPIA object creation #45082

@333fred

Description

@333fred

PIA Assembly:

#nullable enable
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

[assembly: PrimaryInteropAssemblyAttribute(1,1)]
[assembly: Guid("f9c2d51d-4f44-45f0-9eda-c9d599b58257")]

[ComImport()]
[Guid("f9c2d51d-4f44-45f0-9eda-c9d599b58279")]
[CoClass(typeof(ClassITest33))]
public interface ITest33 : System.Collections.IEnumerable
{
    void Add(object x);
}

[Guid("f9c2d51d-4f44-45f0-9eda-c9d599b58278")]
public abstract class ClassITest33
{
}

Consumption assembly:

#nullable enable
class UsePia
{
    public void M1(ITest33 x, object? y)
    {
        x = new ITest33 { y };
    }
}

Expected: warning on the y for a possible null passed to the Add method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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