Skip to content

Instance extension methods block legitimate unqualified name resolutions #13965

@dsyme

Description

@dsyme

From @NiklasGustafsson in TorchSharp repo

If a C# type has both a nested type C.Name and there is an instance extension method called Name then the latter is always preferred, even for static unqualified resolution

Repro is something like this:

class C {
    class Name { 
        static public void Method() ... 
    }
}

class Extensions {
    static public T Name(T this) { ... }
}

C.Name.Method()

Here the extension method is an instance extension method but is being used as a resolution for a static invocation. It's being used only to report a later error - and instead we should filter on static v. instance in name resolution.

Metadata

Metadata

Assignees

Labels

Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBug

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions