Boo
  1. Boo
  2. BOO-1016

Conflict between generic and non-generic methods overloads when return type is generic parameter

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.8.1
    • Fix Version/s: 0.8.2
    • Component/s: Compiler
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      Two test cases and corresponding errors follows...

      interface ITest:
      def DoSomething() as string

      def DoSomething[of T]() as T

      class Test(ITest):
      def DoSomething() as string:
      pass

      def DoSomething[of T]() as T:
      pass

      Program.boo(10,9) : Error BCE0035: 'Test.DoSomething' conflicts with inherited member 'ITest.DoSomething'.
      Program.boo(7,9) : Error BCE0035: 'Test.DoSomething' conflicts with inherited member 'ITest.DoSomething`1'.

      class Test2Base:
      virtual def DoSomething() as string:
      pass

      virtual def DoSomething[of T]() as T:
      pass

      class Test2(Test2Base):
      def DoSomething() as string:
      pass

      def DoSomething[of T]() as T:
      pass

      Program.boo(12,32) : Error BCE0072: Overridden method 'Test2Base.DoSomething' has a return type of 'string' not 'Test2.DoSomething`1.T'.

        Activity

        Hide
        Cedric Vivier added a comment -

        Hmm.. I guess the errors are legit aren't they?

        interface ITest:
            def DoSomething() as string
            def DoSomething[of T](x as T) as string
        
        class Test(ITest):
            def DoSomething() as string:
                 pass
            def DoSomething[of T](x as T) as string:
                 pass
        

        Works.

        Show
        Cedric Vivier added a comment - Hmm.. I guess the errors are legit aren't they? interface ITest: def DoSomething() as string def DoSomething[of T](x as T) as string class Test(ITest): def DoSomething() as string: pass def DoSomething[of T](x as T) as string: pass Works.
        Hide
        Spruce Weber added a comment -

        I'm not sure they are. The C# equivalent seems to compile fine...
        public interface ITest

        { string DoSomething(); T DoSomething<T>(); }

        public class Test:ITest
        {
        public string DoSomething()

        {return null;}

        public T DoSomething<T>()

        {return default(T);}

        }

        By the way. What are the tags for the nice code formatting?

        Show
        Spruce Weber added a comment - I'm not sure they are. The C# equivalent seems to compile fine... public interface ITest { string DoSomething(); T DoSomething<T>(); } public class Test:ITest { public string DoSomething() {return null;} public T DoSomething<T>() {return default(T);} } By the way. What are the tags for the nice code formatting?
        Hide
        Cedric Vivier added a comment - - edited

        Hmm true, so this is ok only when return types differ because of genericity?

        surround your code with {{ code }} (without spaces) for the nice formatting.

        Show
        Cedric Vivier added a comment - - edited Hmm true, so this is ok only when return types differ because of genericity? surround your code with {{ code }} (without spaces) for the nice formatting.
        Hide
        Spruce Weber added a comment -

        The C# version compiles regardless of whether or not the return types differ. Boo fails when the return types differ even when a non-generic type is returned from the generic method.

        Show
        Spruce Weber added a comment - The C# version compiles regardless of whether or not the return types differ. Boo fails when the return types differ even when a non-generic type is returned from the generic method.
        Hide
        Cedric Vivier added a comment -

        Fixed in rev. 2952

        Show
        Cedric Vivier added a comment - Fixed in rev. 2952

          People

          • Assignee:
            Cedric Vivier
            Reporter:
            Spruce Weber
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: