Beef icon indicating copy to clipboard operation
Beef copied to clipboard

Explicit interface implementation doesn't compile

Open disarray2077 opened this issue 3 years ago • 0 comments

The below code doesn't compile, looks like the compiler gets confused because the methods have the same name:

ERROR: 'test8.Program.TestGet' does not implement interface member 'test8.Program.ITestGet<System.String>.Get()' at line 422:9 in d:\BeefLang\test8\src\Program.bf
  class TestGet : ITestGet<String>, ITestGet<int>
        ^^^^^^^
  > 'test8.Program.ITestGet<System.String>.Get()' cannot match because it does not have the return type 'System.String' at line 429:11 in d:\BeefLang\test8\src\Program.bf
    public int ITestGet<int>.Get()
           ^^^
  > 'test8.Program.TestGet.[test8.Program.ITestGet<System.String>].Get()' is a candidate at line 424:35 in d:\BeefLang\test8\src\Program.bf
    public String ITestGet<String>.Get()
                                   ^^^
  > 'test8.Program.TestGet.[test8.Program.ITestGet<int>].Get()' is a candidate at line 429:29 in d:\BeefLang\test8\src\Program.bf
    public int ITestGet<int>.Get()
                             ^^^
  > 'test8.Program.TestGet.[test8.Program.ITestGet<System.String>].Get()' is a candidate at line 424:35 in d:\BeefLang\test8\src\Program.bf
    public String ITestGet<String>.Get()
                                   ^^^
  > 'test8.Program.TestGet.[test8.Program.ITestGet<int>].Get()' is a candidate at line 429:29 in d:\BeefLang\test8\src\Program.bf
    public int ITestGet<int>.Get()
                             ^^^

Repro code:

interface ITestGet<T>
{
	T Get();
}

class TestGet : ITestGet<String>, ITestGet<int>
{
	public String ITestGet<String>.Get()
	{
		return "Hello world!";
	}

	public int ITestGet<int>.Get()
	{
		return 1337;
	}
}

Tested with: https://github.com/beefytech/Beef/commit/aaa08e9a4e9d217b58ea9f5c5fd81f1053d60a10

disarray2077 avatar Aug 14 '22 22:08 disarray2077