Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/Compilers/Core/Portable/Binding/AbstractLookupSymbolsInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand All @@ -15,12 +17,12 @@ public struct ArityEnumerator : IEnumerator<int>
{
private int _current;
private readonly int _low32bits;
private int[] _arities;
private int[]? _arities;

private const int resetValue = -1;
private const int reachedEndValue = int.MaxValue;

internal ArityEnumerator(int bitVector, HashSet<int> arities)
internal ArityEnumerator(int bitVector, HashSet<int>? arities)
{
_current = resetValue;
_low32bits = bitVector;
Expand All @@ -39,7 +41,7 @@ internal ArityEnumerator(int bitVector, HashSet<int> arities)

public void Dispose() => _arities = null;

object System.Collections.IEnumerator.Current => _current;
object? System.Collections.IEnumerator.Current => _current;

public bool MoveNext()
{
Expand Down Expand Up @@ -118,7 +120,7 @@ private struct UniqueSymbolOrArities : IArityEnumerable
// Then arityBitVectorOrUniqueArity is interpreted as a bitvector
// of arities for arities from zero to 31 and the HashSet contains
// arities of 32 or more.
private object _uniqueSymbolOrArities;
private object? _uniqueSymbolOrArities;
private int _arityBitVectorOrUniqueArity;

public UniqueSymbolOrArities(int arity, TSymbol uniqueSymbol)
Expand Down Expand Up @@ -181,12 +183,14 @@ private void AddArity(int arity)
hashSet.Add(arity);
}

public void GetUniqueSymbolOrArities(out IArityEnumerable arities, out TSymbol uniqueSymbol)
public void GetUniqueSymbolOrArities(out IArityEnumerable? arities, out TSymbol? uniqueSymbol)
{
if (this.HasUniqueSymbol)
{
arities = null;
#nullable disable // Can '_uniqueSymbolOrArities' be null? https://github.com/dotnet/roslyn/issues/39166
uniqueSymbol = (TSymbol)_uniqueSymbolOrArities;
#nullable enable
}
else
{
Expand All @@ -198,7 +202,7 @@ public void GetUniqueSymbolOrArities(out IArityEnumerable arities, out TSymbol u
public ArityEnumerator GetEnumerator()
{
Debug.Assert(!this.HasUniqueSymbol);
return new ArityEnumerator(_arityBitVectorOrUniqueArity, (HashSet<int>)_uniqueSymbolOrArities);
return new ArityEnumerator(_arityBitVectorOrUniqueArity, (HashSet<int>?)_uniqueSymbolOrArities);
}

public int Count
Expand All @@ -207,7 +211,7 @@ public int Count
{
Debug.Assert(!this.HasUniqueSymbol);
int count = BitArithmeticUtilities.CountBits(_arityBitVectorOrUniqueArity);
var set = (HashSet<int>)_uniqueSymbolOrArities;
var set = (HashSet<int>?)_uniqueSymbolOrArities;
if (set != null)
{
count += set.Count;
Expand All @@ -218,13 +222,13 @@ public int Count
}

#if DEBUG
internal TSymbol UniqueSymbol => _uniqueSymbolOrArities as TSymbol;
internal TSymbol? UniqueSymbol => _uniqueSymbolOrArities as TSymbol;
#endif
}

private readonly IEqualityComparer<string> _comparer;
private readonly Dictionary<string, UniqueSymbolOrArities> _nameMap;
internal string FilterName { get; set; }
internal string? FilterName { get; set; }

protected AbstractLookupSymbolsInfo(IEqualityComparer<string> comparer)
{
Expand Down Expand Up @@ -275,8 +279,8 @@ public void AddSymbol(TSymbol symbol, string name, int arity)
/// <returns></returns>
public bool TryGetAritiesAndUniqueSymbol(
string name,
out IArityEnumerable arities,
out TSymbol uniqueSymbol)
out IArityEnumerable? arities,
out TSymbol? uniqueSymbol)
{
Debug.Assert(CanBeAdded(name));

Expand Down
10 changes: 6 additions & 4 deletions src/Compilers/Core/Portable/CodeGen/ArrayMembers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using Microsoft.CodeAnalysis.PooledObjects;
using Roslyn.Utilities;
using System;
Expand Down Expand Up @@ -324,14 +326,14 @@ protected virtual ImmutableArray<ArrayMethodParameterInfo> MakeParameters()

public bool IsGeneric => false;

public Cci.IMethodDefinition GetResolvedMethod(EmitContext context) => null;
public Cci.IMethodDefinition? GetResolvedMethod(EmitContext context) => null;

public ImmutableArray<Cci.IParameterTypeInformation> ExtraParameters
=> ImmutableArray<Cci.IParameterTypeInformation>.Empty;

public Cci.IGenericMethodInstanceReference AsGenericMethodInstanceReference => null;
public Cci.IGenericMethodInstanceReference? AsGenericMethodInstanceReference => null;

public Cci.ISpecializedMethodReference AsSpecializedMethodReference => null;
public Cci.ISpecializedMethodReference? AsSpecializedMethodReference => null;

public Cci.CallingConvention CallingConvention => Cci.CallingConvention.HasThis;

Expand All @@ -356,7 +358,7 @@ public Cci.ITypeReference GetContainingType(EmitContext context)
public void Dispatch(Cci.MetadataVisitor visitor)
=> visitor.Visit(this);

public Cci.IDefinition AsDefinition(EmitContext context)
public Cci.IDefinition? AsDefinition(EmitContext context)
=> null;

public override string ToString()
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/Core/Portable/CodeGen/ClosureDebugInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Diagnostics;
using Roslyn.Utilities;
Expand All @@ -24,7 +26,7 @@ public bool Equals(ClosureDebugInfo other)
ClosureId.Equals(other.ClosureId);
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
return obj is ClosureDebugInfo && Equals((ClosureDebugInfo)obj);
}
Expand Down
8 changes: 5 additions & 3 deletions src/Compilers/Core/Portable/CodeGen/CompilationTestData.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using Microsoft.CodeAnalysis.Emit;
using Microsoft.DiaSymReader;
using System;
Expand Down Expand Up @@ -29,16 +31,16 @@ public MethodData(ILBuilder ilBuilder, IMethodSymbol method)
public readonly ConcurrentDictionary<IMethodSymbol, MethodData> Methods = new ConcurrentDictionary<IMethodSymbol, MethodData>();

// The emitted module.
public CommonPEModuleBuilder Module;
public CommonPEModuleBuilder? Module;

public Func<ISymWriterMetadataProvider, SymUnmanagedWriter> SymWriterFactory;
public Func<ISymWriterMetadataProvider, SymUnmanagedWriter>? SymWriterFactory;

public ILBuilder GetIL(Func<IMethodSymbol, bool> predicate)
{
return Methods.Single(p => predicate(p.Key)).Value.ILBuilder;
}

private ImmutableDictionary<string, MethodData> _lazyMethodsByName;
private ImmutableDictionary<string, MethodData>? _lazyMethodsByName;

// Returns map indexed by name for those methods that have a unique name.
public ImmutableDictionary<string, MethodData> GetMethodsByName()
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/CodeGen/DebugDocumentProvider.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

namespace Microsoft.CodeAnalysis.CodeGen
{
internal delegate Cci.DebugSourceDocument DebugDocumentProvider(string path, string basePath);
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/Core/Portable/CodeGen/DebugId.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Diagnostics;
using Roslyn.Utilities;
Expand Down Expand Up @@ -43,7 +45,7 @@ public bool Equals(DebugId other)
&& this.Generation == other.Generation;
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
return obj is DebugId && Equals((DebugId)obj);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System.Collections.Immutable;
using System.Diagnostics;

Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/CodeGen/EmitState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Diagnostics;
using Microsoft.CodeAnalysis.Text;
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/CodeGen/ILBuilderConversions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Diagnostics;
using System.Reflection.Metadata;
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/Core/Portable/CodeGen/ILBuilderEmit.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down Expand Up @@ -240,7 +242,7 @@ internal void EmitStringSwitchJumpTable(
KeyValuePair<ConstantValue, object>[] caseLabels,
object fallThroughLabel,
LocalOrParameter key,
LocalDefinition keyHash,
LocalDefinition? keyHash,
SwitchStringJumpTableEmitter.EmitStringCompareAndBranch emitStringCondBranchDelegate,
SwitchStringJumpTableEmitter.GetStringHashCode computeStringHashcodeDelegate)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/CodeGen/ILEmitStyle.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

namespace Microsoft.CodeAnalysis.CodeGen
{
internal enum ILEmitStyle : byte
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/CodeGen/ILOpCodeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Diagnostics;
using System.Reflection.Metadata;
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/CodeGen/ITokenDeferral.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System.Collections.Immutable;

namespace Microsoft.CodeAnalysis.CodeGen
Expand Down
2 changes: 2 additions & 0 deletions src/Compilers/Core/Portable/CodeGen/ItemTokenMap.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System.Collections.Concurrent;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.PooledObjects;
Expand Down
8 changes: 5 additions & 3 deletions src/Compilers/Core/Portable/CodeGen/LabelInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis.CodeGen
Expand All @@ -17,7 +19,7 @@ private struct LabelInfo
//if a label is marked before any branches to the label have been seen
//the stack is considered to be 0.
internal readonly int stack;
internal readonly BasicBlock bb;
internal readonly BasicBlock? bb;

/// <summary>
/// Sometimes we need to know if a label is targeted by conditional branches.
Expand All @@ -37,14 +39,14 @@ internal LabelInfo(int stack, bool targetOfConditionalBranches)
/// <summary>
/// Used when label is marked to the code.
/// </summary>
internal LabelInfo(BasicBlock bb, int stack, bool targetOfConditionalBranches)
internal LabelInfo(BasicBlock? bb, int stack, bool targetOfConditionalBranches)
{
this.stack = stack;
this.bb = bb;
this.targetOfConditionalBranches = targetOfConditionalBranches;
}

internal LabelInfo WithNewTarget(BasicBlock bb)
internal LabelInfo WithNewTarget(BasicBlock? bb)
{
return new LabelInfo(bb, this.stack, this.targetOfConditionalBranches);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/Core/Portable/CodeGen/LambdaDebugInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Diagnostics;
using Roslyn.Utilities;
Expand Down Expand Up @@ -49,7 +51,7 @@ public bool Equals(LambdaDebugInfo other)
&& LambdaId.Equals(other.LambdaId);
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
return obj is LambdaDebugInfo && Equals((LambdaDebugInfo)obj);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Reflection.Metadata;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.CodeGen
{
Expand All @@ -20,8 +23,8 @@ public LocalConstantDefinition(
ImmutableArray<bool> dynamicTransformFlags,
ImmutableArray<string> tupleElementNames)
{
Debug.Assert(!string.IsNullOrEmpty(name));
Debug.Assert(compileTimeValue != null);
RoslynDebug.Assert(!RoslynString.IsNullOrEmpty(name));
RoslynDebug.Assert(compileTimeValue != null);

Name = name;
Location = location;
Expand Down Expand Up @@ -59,7 +62,7 @@ public ImmutableArray<Cci.ICustomModifier> CustomModifiers

public int SlotIndex => -1;

public byte[] Signature => null;
public byte[]? Signature => null;

public LocalSlotDebugInfo SlotInfo
=> new LocalSlotDebugInfo(SynthesizedLocalKind.UserDefined, LocalDebugId.None);
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/Core/Portable/CodeGen/LocalDebugId.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

#nullable enable

using System;
using System.Diagnostics;
using Roslyn.Utilities;
Expand Down Expand Up @@ -72,7 +74,7 @@ public override int GetHashCode()
return Hash.Combine(SyntaxOffset, Ordinal);
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
return obj is LocalDebugId && Equals((LocalDebugId)obj);
}
Expand Down
Loading