Details
Description
When the compiler automatically adds stubs for unimplemented interface methods, they can conflict with other defined or stubbed methods which differ by return type only.
Failing testcase:
import System.Collections.Generic public class StubMePlease(IEnumerable of int): pass
The compiler will create a stub for "GetEnumerator() as IEnumerator" as defined by IEnumerable, and for "GetEnumerator() as IEnumerator of int" as defined by IEnumerable of int. The two methods, differing only by return type, create a conflict.
Proposed solution: use explicit interface implementation for interface stubs. This will work well since the stubs are empty anyway, so there's no use in listing them as public members of the stubbed class.
Issue Links
- relates to
-
BOO-789
Compiler should warn but automatically create stubs for non implemented interfaces methods
-
Created a patch for the issue, thought it breaks several test cases (which rely on the old behavior).
These are the tests that fail:
tests\testcases\warnings\BCW0011-6.boo
tests\testcases\semantics\interfaces-0.boo
tests\testcases\semantics\interfaces-2.boo
tests\testcases\integration/types\interfaces-15.boo
tests\testcases\integration/types\interfaces-16.boo
tests\testcases\integration/types\interfaces-18.boo
Any code affected by this was getting a warning anyway, so it's not really a breaking change.