Bug 20266 - Error CS0205 when calling overridden base w/ specialized generic return type
Summary: Error CS0205 when calling overridden base w/ specialized generic return type
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 3.2.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2014-06-02 11:11 UTC by jacobf
Modified: 2014-06-04 13:11 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description jacobf 2014-06-02 11:11:29 UTC
The following code should build. An error is given on line 33 when calling `base.Get<string>()`.

Example.cs(33,40): error CS0205: Cannot call an abstract base member `CallingBaseMethodWithSpecializedReturnType.LowerClass.Get<string>()'

Note that the error implies that UpperClass is calling LowerClass.Get, when it should be calling MiddleClass.Get. And, since MiddleClass.Get is implemented, there should be no error.

This seems limited to invoking a specialization of an overridden abstract base method with a generic return type. From the example you can see, if we use a void return type there is no problem. Or, if we do not specialize the call to the base method with a concrete type parameter, there is no problem.

````

namespace CallingBaseMethodWithSpecializedReturnType
{
    public abstract class LowerClass
    {
        public abstract void Go<T>();
        public abstract T Get<T>();
    }

    public class MiddleClass : LowerClass
    {
        public override void Go<T>() 
        {
        }

        public override T Get<T>() 
        {
            return default(T);
        }
    }

    public class UpperClass : MiddleClass
    {
        public override void Go<T>() 
        {
            base.Go<T>();
            base.Go<string>();
        }

        public override T Get<T>()
        {
            if (typeof(T) == typeof(string))
                return (T)(object)base.Get<string>();
            return base.Get<T>();
        }
    }
}
````
Comment 1 Marek Safar 2014-06-04 13:11:03 UTC
Already fixed in mono 3.4