From 8593a477fb8f41029f9d7963658922b8d504c76e Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Thu, 30 Jan 2020 15:18:00 -0500 Subject: [PATCH] Remove defunct !s after Roslyn changes for default(T) (#2377) --- .../System/Collections/Concurrent/ConcurrentDictionary.cs | 2 +- .../src/System/Collections/Concurrent/PartitionerStatic.cs | 2 +- .../System/Collections/Immutable/ImmutableExtensions.cs | 2 +- .../src/System/Collections/Immutable/ImmutableList_1.cs | 2 +- .../src/System/Collections/Generic/HashSet.cs | 8 ++++---- .../src/System/Collections/Generic/SortedDictionary.cs | 4 ++-- .../src/System/Collections/Generic/SortedList.cs | 4 ++-- .../Runtime/CompilerServices/ReadOnlyCollectionBuilder.cs | 4 ++-- .../Linq/Parallel/Enumerables/AggregationMinMaxHelpers.cs | 8 ++++---- .../src/System/Linq/Parallel/Scheduling/Scheduling.cs | 2 +- .../src/System/Collections/Generic/Dictionary.cs | 12 ++++++------ .../src/System/Collections/Generic/List.cs | 2 +- .../src/System/Collections/ObjectModel/Collection.cs | 2 +- .../System/Collections/ObjectModel/ReadOnlyCollection.cs | 2 +- src/libraries/System.Private.CoreLib/src/System/Memory.cs | 6 +++--- .../System.Private.CoreLib/src/System/MemoryExtensions.cs | 6 +++--- .../Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs | 8 ++++---- .../src/System/Runtime/CompilerServices/RuntimeHelpers.cs | 2 +- .../src/System/Runtime/InteropServices/MemoryMarshal.cs | 2 +- src/libraries/System.Private.CoreLib/src/System/Span.cs | 4 ++-- .../System.Private.CoreLib/src/System/SpanHelpers.T.cs | 14 +++++++------- .../System.Private.CoreLib/src/System/ThrowHelper.cs | 2 +- 22 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs index 5a0d052..ff15506 100644 --- a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs +++ b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentDictionary.cs @@ -939,7 +939,7 @@ namespace System.Collections.Concurrent ThrowValueNullException(); } } - else if (default(TValue)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + else if (default(TValue) != null) { ThrowValueNullException(); } diff --git a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/PartitionerStatic.cs b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/PartitionerStatic.cs index b6f9115..06df026 100644 --- a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/PartitionerStatic.cs +++ b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/PartitionerStatic.cs @@ -1674,7 +1674,7 @@ namespace System.Collections.Concurrent // Because of the lack of typeof(T).IsValueType we need two pieces of information // to determine this. default(T) will return a non null for Value Types, except those // using Nullable<>, that is why we need a second condition. - if (default(TSource)! != null || Nullable.GetUnderlyingType(typeof(TSource)) != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(TSource) != null || Nullable.GetUnderlyingType(typeof(TSource)) != null) { // Marshal.SizeOf fails for value types that don't have explicit layouts. We // just fall back to some arbitrary constant in that case. Is there a better way? diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableExtensions.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableExtensions.cs index c5b0439..c4f908b 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableExtensions.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableExtensions.cs @@ -17,7 +17,7 @@ namespace System.Collections.Immutable { internal static bool IsValueType() { - if (default(T)! != null) + if (default(T) != null) { return true; } diff --git a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.cs b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.cs index 2b4fb31..aa90536 100644 --- a/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.cs +++ b/src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableList_1.cs @@ -1169,7 +1169,7 @@ namespace System.Collections.Immutable { // Non-null values are fine. Only accept nulls if T is a class or Nullable. // Note that default(T) is not equal to null for value types except when T is Nullable. - return ((value is T) || (value == null && default(T)! == null)); + return ((value is T) || (value == null && default(T) == null)); } /// diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/HashSet.cs b/src/libraries/System.Collections/src/System/Collections/Generic/HashSet.cs index 9a440fb..6b38643 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/HashSet.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/HashSet.cs @@ -267,7 +267,7 @@ namespace System.Collections.Generic { int hashCode = item == null ? 0 : InternalGetHashCode(item.GetHashCode()); - if (default(T)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null) { // see note at "HashSet" level describing why "- 1" appears in for loop for (int i = buckets[hashCode % buckets.Length] - 1; i >= 0; i = slots[i].next) @@ -369,7 +369,7 @@ namespace System.Collections.Generic hashCode = item == null ? 0 : InternalGetHashCode(item.GetHashCode()); bucket = hashCode % _buckets!.Length; - if (default(T)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null) { for (i = _buckets[bucket] - 1; i >= 0; last = i, i = slots[i].next) { @@ -1342,7 +1342,7 @@ namespace System.Collections.Generic hashCode = value == null ? 0 : InternalGetHashCode(value.GetHashCode()); bucket = hashCode % _buckets!.Length; - if (default(T)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null) { for (int i = _buckets[bucket] - 1; i >= 0; i = slots[i].next) { @@ -1578,7 +1578,7 @@ namespace System.Collections.Generic { int hashCode = item == null ? 0 : InternalGetHashCode(item.GetHashCode()); - if (default(T)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null) { // see note at "HashSet" level describing why "- 1" appears in for loop for (int i = buckets[hashCode % buckets.Length] - 1; i >= 0; i = slots[i].next) diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/SortedDictionary.cs b/src/libraries/System.Collections/src/System/Collections/Generic/SortedDictionary.cs index 795551a..5f59ab4 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/SortedDictionary.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/SortedDictionary.cs @@ -343,7 +343,7 @@ namespace System.Collections.Generic throw new ArgumentNullException(nameof(key)); } - if (value == null && !(default(TValue)! == null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (value == null && !(default(TValue) == null)) throw new ArgumentNullException(nameof(value)); try @@ -372,7 +372,7 @@ namespace System.Collections.Generic throw new ArgumentNullException(nameof(key)); } - if (value == null && !(default(TValue)! == null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (value == null && !(default(TValue) == null)) throw new ArgumentNullException(nameof(value)); try diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/SortedList.cs b/src/libraries/System.Collections/src/System/Collections/Generic/SortedList.cs index 96cf1fb..d7fb7dd 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/SortedList.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/SortedList.cs @@ -271,7 +271,7 @@ namespace System.Collections.Generic if (key == null) throw new ArgumentNullException(nameof(key)); - if (value == null && !(default(TValue)! == null)) // null is an invalid value for Value types // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (value == null && !(default(TValue) == null)) // null is an invalid value for Value types throw new ArgumentNullException(nameof(value)); if (!(key is TKey)) @@ -624,7 +624,7 @@ namespace System.Collections.Generic throw new ArgumentNullException(nameof(key)); } - if (value == null && !(default(TValue)! == null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (value == null && !(default(TValue) == null)) throw new ArgumentNullException(nameof(value)); TKey tempKey = (TKey)key; diff --git a/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/ReadOnlyCollectionBuilder.cs b/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/ReadOnlyCollectionBuilder.cs index e5349f2..5a588e9 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/ReadOnlyCollectionBuilder.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/ReadOnlyCollectionBuilder.cs @@ -479,12 +479,12 @@ namespace System.Runtime.CompilerServices private static bool IsCompatibleObject(object? value) { - return ((value is T) || (value == null && default(T)! == null)); + return ((value is T) || (value == null && default(T) == null)); } private static void ValidateNullValue(object? value, string argument) { - if (value == null && default(T)! != null) + if (value == null && default(T) != null) { throw Error.InvalidNullValue(typeof(T), argument); } diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Enumerables/AggregationMinMaxHelpers.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Enumerables/AggregationMinMaxHelpers.cs index adf863c..b52a5ac 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Enumerables/AggregationMinMaxHelpers.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Enumerables/AggregationMinMaxHelpers.cs @@ -33,7 +33,7 @@ namespace System.Linq AssociativeAggregationOperator, T> aggregation = new AssociativeAggregationOperator, T>(source, new Pair(false, default!), null, - true, intermediateReduce, finalReduce, resultSelector, default(T)! != null, QueryAggregationOptions.AssociativeCommutative); + true, intermediateReduce, finalReduce, resultSelector, default(T) != null, QueryAggregationOptions.AssociativeCommutative); return aggregation.Aggregate(); } @@ -75,7 +75,7 @@ namespace System.Linq // the existing accumulated result is equal to the sign requested by the function factory, // we will return a new pair that contains the current element as the best item. We will // ignore null elements (for reference and nullable types) in the input stream. - if ((default(T)! != null || element != null) && + if ((default(T) != null || element != null) && (!accumulator.First || Util.Sign(comparer.Compare(element, accumulator.Second)) == sign)) { return new Pair(true, element); @@ -102,7 +102,7 @@ namespace System.Linq if (element.First && (!accumulator.First || Util.Sign(comparer.Compare(element.Second, accumulator.Second)) == sign)) { - Debug.Assert(default(T)! != null || element.Second != null, "nulls unexpected in final reduce"); + Debug.Assert(default(T) != null || element.Second != null, "nulls unexpected in final reduce"); return new Pair(true, element.Second); } @@ -119,7 +119,7 @@ namespace System.Linq // empty sequences. Else, we will just return the element, which may be null for other types. return delegate (Pair accumulator) { - Debug.Assert(accumulator.First || default(T)! == null, + Debug.Assert(accumulator.First || default(T) == null, "for non-null types we expect an exception to be thrown before getting here"); return accumulator.Second; }; diff --git a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/Scheduling.cs b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/Scheduling.cs index 3087025..c75997d 100644 --- a/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/Scheduling.cs +++ b/src/libraries/System.Linq.Parallel/src/System/Linq/Parallel/Scheduling/Scheduling.cs @@ -78,7 +78,7 @@ namespace System.Linq.Parallel // Because of the lack of typeof(T).IsValueType we need two pieces of information // to determine this. default(T) will return a non null for Value Types, except those // using Nullable<>, that is why we need a second condition. - if (default(T)! != null || Nullable.GetUnderlyingType(typeof(T)) != null) + if (default(T) != null || Nullable.GetUnderlyingType(typeof(T)) != null) { // Marshal.SizeOf fails for value types that don't have explicit layouts. We // just fall back to some arbitrary constant in that case. Is there a better way? diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs index 3680216..8ed75d5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs @@ -250,7 +250,7 @@ namespace System.Collections.Generic } else { - if (default(TValue)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(TValue) != null) { // ValueType: Devirtualize with EqualityComparer.Default intrinsic for (int i = 0; i < _count; i++) @@ -344,7 +344,7 @@ namespace System.Collections.Generic int i = GetBucket(hashCode); Entry[]? entries = _entries; uint collisionCount = 0; - if (default(TKey)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(TKey) != null) { // ValueType: Devirtualize with EqualityComparer.Default intrinsic @@ -495,7 +495,7 @@ namespace System.Collections.Generic if (comparer == null) { - if (default(TKey)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(TKey) != null) { // ValueType: Devirtualize with EqualityComparer.Default intrinsic while (true) @@ -658,7 +658,7 @@ namespace System.Collections.Generic _version++; // Value types never rehash - if (default(TKey)! == null && collisionCount > HashHelpers.HashCollisionThreshold && comparer is NonRandomizedStringEqualityComparer) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(TKey) == null && collisionCount > HashHelpers.HashCollisionThreshold && comparer is NonRandomizedStringEqualityComparer) { // If we hit the collision threshold we'll need to switch to the comparer which is using randomized string hashing // i.e. EqualityComparer.Default. @@ -720,7 +720,7 @@ namespace System.Collections.Generic private void Resize(int newSize, bool forceNewHashCodes) { // Value types never rehash - Debug.Assert(!forceNewHashCodes || default(TKey)! == null); // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + Debug.Assert(!forceNewHashCodes || default(TKey) == null); Debug.Assert(_entries != null, "_entries should be non-null"); Debug.Assert(newSize >= _entries.Length); @@ -729,7 +729,7 @@ namespace System.Collections.Generic int count = _count; Array.Copy(_entries, entries, count); - if (default(TKey)! == null && forceNewHashCodes) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(TKey) == null && forceNewHashCodes) { for (int i = 0; i < count; i++) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs index ac626c5..9092b95 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs @@ -169,7 +169,7 @@ namespace System.Collections.Generic { // Non-null values are fine. Only accept nulls if T is a class or Nullable. // Note that default(T) is not equal to null for value types except when T is Nullable. - return (value is T) || (value == null && default(T)! == null); // default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + return (value is T) || (value == null && default(T) == null); } object? IList.this[int index] diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs index 11a45cf..4f7486d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs @@ -359,7 +359,7 @@ namespace System.Collections.ObjectModel { // Non-null values are fine. Only accept nulls if T is a class or Nullable. // Note that default(T) is not equal to null for value types except when T is Nullable. - return (value is T) || (value == null && default(T)! == null); + return (value is T) || (value == null && default(T) == null); } } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyCollection.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyCollection.cs index 850b72d..5144e6c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyCollection.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyCollection.cs @@ -189,7 +189,7 @@ namespace System.Collections.ObjectModel { // Non-null values are fine. Only accept nulls if T is a class or Nullable. // Note that default(T) is not equal to null for value types except when T is Nullable. - return (value is T) || (value == null && default(T)! == null); + return (value is T) || (value == null && default(T) == null); } bool IList.Contains(object? value) diff --git a/src/libraries/System.Private.CoreLib/src/System/Memory.cs b/src/libraries/System.Private.CoreLib/src/System/Memory.cs index 49e37a0..c9a7bf7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Memory.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Memory.cs @@ -53,7 +53,7 @@ namespace System this = default; return; // returns default } - if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) == null && array.GetType() != typeof(T[])) ThrowHelper.ThrowArrayTypeMismatchException(); _object = array; @@ -71,7 +71,7 @@ namespace System this = default; return; // returns default } - if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) == null && array.GetType() != typeof(T[])) ThrowHelper.ThrowArrayTypeMismatchException(); if ((uint)start > (uint)array.Length) ThrowHelper.ThrowArgumentOutOfRangeException(); @@ -103,7 +103,7 @@ namespace System this = default; return; // returns default } - if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) == null && array.GetType() != typeof(T[])) ThrowHelper.ThrowArrayTypeMismatchException(); #if BIT64 // See comment in Span.Slice for how this works. diff --git a/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs b/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs index 63534ad..78299b5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs @@ -34,7 +34,7 @@ namespace System ThrowHelper.ThrowArgumentOutOfRangeException(); return default; } - if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) == null && array.GetType() != typeof(T[])) ThrowHelper.ThrowArrayTypeMismatchException(); if ((uint)start > (uint)array.Length) ThrowHelper.ThrowArgumentOutOfRangeException(); @@ -56,7 +56,7 @@ namespace System return default; } - if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) == null && array.GetType() != typeof(T[])) ThrowHelper.ThrowArrayTypeMismatchException(); int actualIndex = startIndex.GetOffset(array.Length); @@ -83,7 +83,7 @@ namespace System return default; } - if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) == null && array.GetType() != typeof(T[])) ThrowHelper.ThrowArrayTypeMismatchException(); (int start, int length) = range.GetOffsetAndLength(array.Length); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs index 0cea738..65b206d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs @@ -106,17 +106,17 @@ namespace System.Runtime.CompilerServices // The null tests here ensure that the jit can optimize away the interface // tests when TAwaiter is a ref type. - if ((null != (object)default(TAwaiter)!) && (awaiter is ITaskAwaiter)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if ((null != (object?)default(TAwaiter)) && (awaiter is ITaskAwaiter)) { ref TaskAwaiter ta = ref Unsafe.As(ref awaiter); // relies on TaskAwaiter/TaskAwaiter having the same layout TaskAwaiter.UnsafeOnCompletedInternal(ta.m_task, box, continueOnCapturedContext: true); } - else if ((null != (object)default(TAwaiter)!) && (awaiter is IConfiguredTaskAwaiter)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + else if ((null != (object?)default(TAwaiter)) && (awaiter is IConfiguredTaskAwaiter)) { ref ConfiguredTaskAwaitable.ConfiguredTaskAwaiter ta = ref Unsafe.As(ref awaiter); TaskAwaiter.UnsafeOnCompletedInternal(ta.m_task, box, ta.m_continueOnCapturedContext); } - else if ((null != (object)default(TAwaiter)!) && (awaiter is IStateMachineBoxAwareAwaiter)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + else if ((null != (object?)default(TAwaiter)) && (awaiter is IStateMachineBoxAwareAwaiter)) { try { @@ -547,7 +547,7 @@ namespace System.Runtime.CompilerServices // find a cached value, since static fields (even if readonly and integral types) // require special access helpers in this NGEN'd and domain-neutral. - if (null != (object)default(TResult)!) // help the JIT avoid the value type branches for ref types // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (null != (object?)default(TResult)) // help the JIT avoid the value type branches for ref types { // Special case simple value types: // - Boolean diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs index e094e45..8860428 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs @@ -27,7 +27,7 @@ namespace System.Runtime.CompilerServices (int offset, int length) = range.GetOffsetAndLength(array.Length); - if (default(T)! != null || typeof(T[]) == array.GetType()) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null || typeof(T[]) == array.GetType()) { // We know the type of the array to be exactly T[]. diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MemoryMarshal.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MemoryMarshal.cs index 167ca08..16d431c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MemoryMarshal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MemoryMarshal.cs @@ -522,7 +522,7 @@ namespace System.Runtime.InteropServices ThrowHelper.ThrowArgumentOutOfRangeException(); return default; } - if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) == null && array.GetType() != typeof(T[])) ThrowHelper.ThrowArrayTypeMismatchException(); if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start)) ThrowHelper.ThrowArgumentOutOfRangeException(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Span.cs b/src/libraries/System.Private.CoreLib/src/System/Span.cs index ff8ed41..e5b3f5e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Span.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Span.cs @@ -50,7 +50,7 @@ namespace System this = default; return; // returns default } - if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) == null && array.GetType() != typeof(T[])) ThrowHelper.ThrowArrayTypeMismatchException(); _pointer = new ByReference(ref MemoryMarshal.GetArrayDataReference(array)); @@ -79,7 +79,7 @@ namespace System this = default; return; // returns default } - if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) == null && array.GetType() != typeof(T[])) ThrowHelper.ThrowArrayTypeMismatchException(); #if BIT64 // See comment in Span.Slice for how this works. diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs index fce93c4..2530dcf 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs @@ -53,7 +53,7 @@ namespace System IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations - if (default(T)! != null || (object)value != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null || (object)value != null) { while (length >= 8) { @@ -122,7 +122,7 @@ namespace System Debug.Assert(length >= 0); IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations - if (default(T)! != null || (object)value != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null || (object)value != null) { while (length >= 8) { @@ -210,7 +210,7 @@ namespace System T lookUp; int index = 0; - if (default(T)! != null || ((object)value0 != null && (object)value1 != null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null || ((object)value0 != null && (object)value1 != null)) { while ((length - index) >= 8) { @@ -314,7 +314,7 @@ namespace System T lookUp; int index = 0; - if (default(T)! != null || ((object)value0 != null && (object)value1 != null && (object)value2 != null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null || ((object)value0 != null && (object)value1 != null && (object)value2 != null)) { while ((length - index) >= 8) { @@ -474,7 +474,7 @@ namespace System { Debug.Assert(length >= 0); - if (default(T)! != null || (object)value != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null || (object)value != null) { while (length >= 8) { @@ -556,7 +556,7 @@ namespace System Debug.Assert(length >= 0); T lookUp; - if (default(T)! != null || ((object)value0 != null && (object)value1 != null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null || ((object)value0 != null && (object)value1 != null)) { while (length >= 8) { @@ -659,7 +659,7 @@ namespace System Debug.Assert(length >= 0); T lookUp; - if (default(T)! != null || ((object)value0 != null && (object)value1 != null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (default(T) != null || ((object)value0 != null && (object)value1 != null)) { while (length >= 8) { diff --git a/src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs b/src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs index 88c91e9..8ddc596 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs @@ -478,7 +478,7 @@ namespace System internal static void IfNullAndNullsAreIllegalThenThrow(object? value, ExceptionArgument argName) { // Note that default(T) is not equal to null for value types except when T is Nullable. - if (!(default(T)! == null) && value == null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757) + if (!(default(T) == null) && value == null) ThrowHelper.ThrowArgumentNullException(argName); } -- 2.7.4