Skip to content

Introduce local adds redundant globally qualified namespace on local's type #62539

@drewnoakes

Description

@drewnoakes

Version Used:

Steps to Reproduce:

namespace MyNamespace;

record struct ID<T>(T Key);

class C
{
    void M(int id)
    {
        N(id, new Dictionary<ID<int>, string>());

        // The generic type is required for the repro
        // The inner function is required for the repro
        // The record struct is required for the repro

        void N<T>(T id, Dictionary<ID<T>, string> d)
        {
            if (d.TryGetValue(new(id), out string? s))
            //                ^^^^^^^ Introduce local for this range
            {
            }
        }
    }
}

Expected Behavior:

void N<T>(T id, Dictionary<ID<T>, string> dic)
{
    ID<T> key = new(id);
    if (dic.TryGetValue(key, out string? s))
    {
    }
}

Actual Behavior:

void N<T>(T id, Dictionary<ID<T>, string> dic)
{
    global::MyNamespace.ID<T> key = new(id);
//  ^^^^^^^^^^^^^^^^^^^ Redundant qualifier
    if (dic.TryGetValue(key, out string? s))
    {
    }
}

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

    Projects

    Status

    Completed

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions