Bug 11482 - Default enum parameters in templated classes won't compile
Summary: Default enum parameters in templated classes won't compile
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2013-03-29 19:12 UTC by Thomas Smith
Modified: 2013-03-30 04:27 UTC (History)
1 user (show)

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:

Description Thomas Smith 2013-03-29 19:12:38 UTC
The following code is syntatically correct, but won't compile with Mono (it compiles fine in Visual Studio).

    public enum TestEnum { A, B, C };

    public abstract class TestClass<T>
        public TestClass()

        public void Test0() { }

        public void Test1(TestEnum param = TestEnum.A) { }

        public void Test2() { }

The compiler errors at the Test1 and Test2 calls in the constructor:

  error CS0103: The name `Test1' does not exist in the current context
  error CS0103: The name `Test2' does not exist in the current context

The compiler seems unable to locate the Test1 and Test2 methods in this case. It's capable of locating the Test0 method though (order seems to matter?). Doing one of the following things allows the code to compile:
- moving the Test2 declaration above Test1
- removing the template on the class
- removing the default value for the parameter "param" of Test1
- changing the type of parameter "param" to a non-enum type
Comment 1 Marek Safar 2013-03-30 04:27:36 UTC
Already fixed in Mono 3.0