Bugzilla – Bug 319276
[GMCS] improper CS0408 - cannot define overload members one of them has a generic parameter
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by atsushi@ximian.com 2005-10-12 04:23:50 MST ---- mcs raises an error CS0408 when there is a set of overloaded methods one of that takes such arguments of a generic parameter type in the generic class. However, it does not seem correct (see the last part of the description below). class Foo<T> { public string this [int index] { get { return null; } } public string this [T key] { get { return null; } } } Actual Results: possible-substitutes.cs(7,16): error CS0408: `Foo<T>' cannot define overload members that may unify for some type parameter substitutions Expected Results: no CS0408 error. How often does this happen? consistently. Additional Information: Here is an excerpt from ECMA 334. 25.1.7 Overloading in generic classes Methods, constructors, indexers, and operators within a generic class declaration can be overloaded. While signatures as declared must be unique, it is possible that substitution of type arguments results in identical signatures. The tie-breaking rules of overload resolution will pick the most specific one. csc compiles it as I expected from above. ---- Additional Comments From atsushi@ximian.com 2005-10-18 00:38:19 MST ---- The latest msdn documentation does not have CS0408 error case - maybe it is just removed? ---- Additional Comments From martin@ximian.com 2005-10-19 14:09:55 MST ---- This change has been made in the spec around November 2004; the CS0408 error doesn't exist anymore. ---- Additional Comments From martin@ximian.com 2005-10-19 14:10:36 MST ---- Low priority - it may be a lot of work to implement this. However, I'll try to figure out how much work exactly it'll be next week. ---- Additional Comments From terry@triplett.org 2006-01-16 12:00:45 MST ---- *Bump* "I'll try to figure out how much work exactly it'll be next week." Was wondering what the outcome was? Just ran into this bug in a real-world context while updating a (cross-platform) codebase to use Generics and was hoping it would be addressed in the bug-fixing push towards Mono 1.2. ---- Additional Comments From martin@ximian.com 2006-01-18 11:39:52 MST ---- Fixed in SVN. The runtime part is in r55726, the gmcs changes and tests are in r55728 and a required compiler-tester change is in r55727. Removed gcs408*.cs and added gtest-236, gtest-237, gtest-238 and gtest-239. Unknown operating system unknown. Setting to default OS "Other".