Bug 15757 - Overriding an abstract generic method can cause a build failure under certain conditions
Summary: Overriding an abstract generic method can cause a build failure under certain...
Status: RESOLVED DUPLICATE of bug 15523
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 3.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2013-10-28 17:46 UTC by Brandon Vaughan
Modified: 2013-11-03 08:03 UTC (History)
3 users (show)

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


Attachments
Reproducing Project (14.22 KB, application/zip)
2013-10-28 17:51 UTC, Brandon Vaughan
Details


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 DUPLICATE of bug 15523

Description Brandon Vaughan 2013-10-28 17:46:34 UTC
If you create an abstract class with an abstract method that uses generics, inherit from that class and override the method, then inherit from the class that overrides the method and call the base method, the build will fail.  It says you cannot call an abstract base member seemingly bypassing the class and override in the middle.  

Steps:
1. Create an abstract base class
2. Create an abstract method with a generic
3. Create a class that inherits from that base class and overrides the abstract method
4. Create a class that inherits from the class created in step 3 and overrides the abstract method
5. Call base.Method in the overridden method from step 4.
6. Build

See the attached project.
Comment 1 Brandon Vaughan 2013-10-28 17:50:30 UTC
A compressed, default Android project with this one file added is too large to upload as an attachment.  Create a default project and add these 3 classes.

using System;

namespace AbstractGenericsTest
{
    public abstract class BaseClass
    {
        protected abstract string Foo<TData>(TData value, object args);
    }

    public class InheritsFromBase : BaseClass
    {
        protected override string Foo<TData>(TData value, object args)
        {
            return "Anything";
        }
    }

    public sealed class ThisOneBreaks : InheritsFromBase
    {
        protected override string Foo<TData>(TData value, object args)
        {
            return base.Foo<String>("Bar", args);
        }
    }
}
Comment 2 Brandon Vaughan 2013-10-28 17:51:55 UTC
Created attachment 5258 [details]
Reproducing Project

Forgot to delete the obj and bin directories...
Comment 3 Jonathan Pryor 2013-11-01 17:29:34 UTC
@Marek: See Comment #1 for a minimal test case. It compiles under .NET, fails with mcs:

> bxc15757.cs(22,25): error CS0205: Cannot call an abstract base member `AbstractGenericsTest.BaseClass.Foo<string>(string, object)'
Comment 4 Marek Safar 2013-11-03 08:03:28 UTC

*** This bug has been marked as a duplicate of bug 15523 ***