2009-07-02 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Thu, 2 Jul 2009 12:28:33 +0000 (12:28 -0000)
committerMarek Safar <marek.safar@gmail.com>
Thu, 2 Jul 2009 12:28:33 +0000 (12:28 -0000)
* generic.cs: Handle type inference of identical type parameters
with different bounds.

svn path=/trunk/mcs/; revision=137284

mcs/mcs/ChangeLog
mcs/mcs/generic.cs

index 23f1afe8e74d7c8748176fc9b3fabc98535ed7ec..b2ce78d790b264b29f019d12111d3312f7cafbf4 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-02  Marek Safar  <marek.safar@gmail.com>
+
+       * generic.cs: Handle type inference of identical type parameters
+       with different bounds.
+
 2009-07-01  Marek Safar  <marek.safar@gmail.com>
 
        * expression.cs, class.cs: Events variance.
index 8fa1b1a704157b4ddc12e660a185c8bc61d936c2..c9224e2f931222518230f5d0060723f790c27f68 100644 (file)
@@ -2588,10 +2588,15 @@ namespace Mono.CSharp {
                                        if (cii == ci)
                                                continue;
 
+                                       Type ctype = ((BoundInfo) candidates[cii]).Type;
+                                       
+                                       // Same type parameters with different bounds
+                                       if (ctype == bound.Type)
+                                               continue;
+
                                        if (bound.Kind == BoundKind.Exact)
                                                break;
 
-                                       Type ctype = ((BoundInfo) candidates[cii]).Type;
                                        if (bound.Kind == BoundKind.Lower) {
                                                if (!Convert.ImplicitConversionExists (null, new TypeExpression (ctype, Location.Null), bound.Type)) {
                                                        break;
@@ -2606,7 +2611,7 @@ namespace Mono.CSharp {
                                if (cii != candidates_count)
                                        continue;
 
-                               if (best_candidate != null)
+                               if (best_candidate != null && best_candidate != bound.Type)
                                        return false;
 
                                best_candidate = bound.Type;
@@ -2742,9 +2747,7 @@ namespace Mono.CSharp {
                                                return 0;
 
                                        v_i = TypeManager.GetTypeArguments (v) [0];
-                                       Type v_i_open = TypeManager.GetTypeArguments (g_v)[0];
-                                       Variance variance = TypeManager.GetTypeParameterVariance (v_i_open);
-                                       if (variance == Variance.None)
+                                       if (TypeManager.IsValueType (u_i))
                                                return ExactInference (u_i, v_i);
 
                                        return LowerBoundInference (u_i, v_i);