Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch in keeping interfaces with explicit implementation #1421

Closed
MichalStrehovsky opened this issue Aug 10, 2020 · 0 comments · Fixed by #1429
Closed

Mismatch in keeping interfaces with explicit implementation #1421

MichalStrehovsky opened this issue Aug 10, 2020 · 0 comments · Fixed by #1429

Comments

@MichalStrehovsky
Copy link
Member

Reported in dotnet/runtime#40582.

I'm working on this right now, just filing an issue for tracking.

Simplified repro without regex:

    interface IFoo<T>
    {
        void Frob();
    }

    class Foo : IBar, IFoo<string>, IFoo<object>
    {
        void IFoo<string>.Frob()
        {   
        }

        void IFoo<object>.Frob()
        {
        }

        public void Bork()
        {
        }
    }

    interface IBar : IFoo<object>
    {
        void Bork();
    }

    class Bar : IBar
    {
        public void Bork()
        {
        }

        public void Frob()
        {
        }
    }

    class Program
    {
        static Foo f;

        static void Main(string[] args)
        {
            ((IBar)new Bar()).Bork();

            if (f != null)
                ((IFoo<object>)f).Frob();
        }
    }

Results in:

Unhandled exception. System.TypeLoadException: Type 'cns.Foo' from assembly 'cns, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' tried to override method 'cns.IFoo<System.String>.Frob' but does not implement or inherit that method.
   at cns.Program.Main(String[] args)
MichalStrehovsky added a commit to MichalStrehovsky/linker that referenced this issue Aug 11, 2020
…cursively

`IsInterfaceImplementationMarkedRecursively` was incorrectly rewritten from a global prepass to a local interface walk in dotnet#1186.

The new code was looking at the wrong interface list (looking at `IBar`'s interface list instead of `Bar`). We need to keep looking at the same interface list that we started with.

Fixes dotnet#1421.
MichalStrehovsky added a commit that referenced this issue Aug 12, 2020
…cursively (#1429)

`IsInterfaceImplementationMarkedRecursively` was incorrectly rewritten from a global prepass to a local interface walk in #1186.

The new code was looking at the wrong interface list (looking at `IBar`'s interface list instead of `Bar`). We need to keep looking at the same interface list that we started with.

Fixes #1421.
tkapin pushed a commit to tkapin/runtime that referenced this issue Jan 31, 2023
…cursively (dotnet/linker#1429)

`IsInterfaceImplementationMarkedRecursively` was incorrectly rewritten from a global prepass to a local interface walk in dotnet/linker#1186.

The new code was looking at the wrong interface list (looking at `IBar`'s interface list instead of `Bar`). We need to keep looking at the same interface list that we started with.

Fixes dotnet/linker#1421.

Commit migrated from dotnet/linker@fc5e4aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant