diff options
author | Martin Baulig <martin@novell.com> | 2006-01-18 18:32:55 +0300 |
---|---|---|
committer | Martin Baulig <martin@novell.com> | 2006-01-18 18:32:55 +0300 |
commit | a6335857892fc2e5cab232212947257716c63020 (patch) | |
tree | 227dd6fb00b5f45a29337be664b3afdff4eedcdf /mcs/tests/gtest-239.cs | |
parent | 1212d1ddd0d78f6e87550860f39bfb3478f7125f (diff) |
2006-01-18 Martin Baulig <martin@ximian.com>
Fix #76417: a generic class may now have methods which may unify
for some type parameter substitutions.
* class.cs (Method.IsDuplicateImplementation): Don't report CS0408
for methods which may unify anymore.
* expression.cs (Invocation.MoreSpecific): New private static
method; checks whether one method is more specific than another
according to 14.4.2.2 of the spec.
(Invocation.BetterFunction): Implement the tie-breaking rules from
14.4.2.2 of the spec: if two methods unify for some type parameter
substitution, we need to pick the more specific one.
svn path=/trunk/mcs/; revision=55728
Diffstat (limited to 'mcs/tests/gtest-239.cs')
-rw-r--r-- | mcs/tests/gtest-239.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/mcs/tests/gtest-239.cs b/mcs/tests/gtest-239.cs new file mode 100644 index 00000000000..6add5879654 --- /dev/null +++ b/mcs/tests/gtest-239.cs @@ -0,0 +1,60 @@ +using System; + +class Foo<T,U> +{ + public int Test (T t, U u) + { + return 1; + } + + public int Test (int t, U u) + { + return 2; + } + + public int Test (T t, float u) + { + return 3; + } + + public int Test (int t, float u) + { + return 4; + } +} + +class X +{ + static int Main () + { + Foo<long,float> a = new Foo<long,float> (); + if (a.Test (3L, 3.14F) != 3) + return 1; + if (a.Test (3L, 8) != 3) + return 2; + if (a.Test (3, 3.14F) != 4) + return 3; + if (a.Test (3, 8) != 4) + return 4; + + Foo<long,double> b = new Foo<long,double> (); + if (b.Test (3L, 3.14F) != 3) + return 5; + if (b.Test (3, 3.14F) != 4) + return 6; + if (b.Test (3L, 3.14F) != 3) + return 7; + if (b.Test (3L, 5) != 3) + return 8; + + Foo<string,float> c = new Foo<string,float> (); + if (c.Test ("Hello", 3.14F) != 3) + return 9; + + Foo<int,string> d = new Foo<int,string> (); + if (d.Test (3, "Hello") != 2) + return 10; + + return 0; + } +} |