Skip to content

Commit 2ed2e46

Browse files
authored
Fix CS8762 suppression in ConcurrentBag (#121122)
Closes #36132
1 parent e9efcaa commit 2ed2e46

File tree

1 file changed

+2
-8
lines changed
  • src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent

1 file changed

+2
-8
lines changed

src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentBag.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,11 @@ private bool TrySteal([MaybeNullWhen(false)] out T result, bool take)
211211
// then start from the next queue after it, and then iterate around back from the head to this queue,
212212
// not including it.
213213
WorkStealingQueue? localQueue = GetCurrentThreadWorkStealingQueue(forceCreate: false);
214-
bool gotItem = localQueue == null ?
214+
if (localQueue is null ?
215215
TryStealFromTo(_workStealingQueues, null, out result, take) :
216-
(TryStealFromTo(localQueue._nextQueue, null, out result, take) || TryStealFromTo(_workStealingQueues, localQueue, out result, take));
217-
if (gotItem)
216+
(TryStealFromTo(localQueue._nextQueue, null, out result, take) || TryStealFromTo(_workStealingQueues, localQueue, out result, take)))
218217
{
219-
#pragma warning disable CS8762
220-
// https://github.com/dotnet/runtime/issues/36132
221-
// Compiler can't automatically deduce that nullability constraints
222-
// for 'result' are satisfied at this exit point.
223218
return true;
224-
#pragma warning restore CS8762
225219
}
226220

227221
if (Interlocked.Read(ref _emptyToNonEmptyListTransitionCount) == initialEmptyToNonEmptyCounts)

0 commit comments

Comments
 (0)