Remove un-necessary ITuple constraint (dotnet/coreclr#8793)
authorJulien Couvreur <jcouv@users.noreply.github.com>
Wed, 4 Jan 2017 02:09:17 +0000 (18:09 -0800)
committerJan Kotas <jkotas@microsoft.com>
Wed, 4 Jan 2017 02:09:17 +0000 (18:09 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/3bb7653f9f2fa470c577586230687c01a3a729f8

src/coreclr/src/mscorlib/src/System/ValueTuple.cs

index bc5dc3e..8476122 100644 (file)
@@ -1897,7 +1897,7 @@ namespace System
     [StructLayout(LayoutKind.Auto)]
     public struct ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>
     : IEquatable<ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>>, IStructuralEquatable, IStructuralComparable, IComparable, IComparable<ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>>, IValueTupleInternal, ITuple
-    where TRest : struct, ITuple
+    where TRest : struct
     {
         /// <summary>
         /// The current <see cref="ValueTuple{T1, T2, T3, T4, T5, T6, T7, TRest}"/> instance's first component.
@@ -2269,7 +2269,8 @@ namespace System
         {
             get
             {
-                return 7 + Rest.Length;
+                IValueTupleInternal rest = Rest as IValueTupleInternal;
+                return rest == null ? 8 : 7 + rest.Length;
             }
         }
 
@@ -2298,7 +2299,16 @@ namespace System
                         return Item7;
                 }
 
-                return Rest[index - 7];
+                IValueTupleInternal rest = Rest as IValueTupleInternal;
+                if (rest == null)
+                {
+                    if (index == 7)
+                    {
+                        return Rest;
+                    }
+                    throw new IndexOutOfRangeException();
+                }
+                return rest[index - 7];
             }
         }
     }