Annotate more of the binder

上级 ad8ec29f
......@@ -674,7 +674,7 @@ internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(Diagn
internal static bool IsSymbolAccessibleConditional(
Symbol symbol,
AssemblySymbol within,
ref HashSet<DiagnosticInfo> useSiteDiagnostics)
ref HashSet<DiagnosticInfo>? useSiteDiagnostics)
{
return AccessCheck.IsSymbolAccessible(symbol, within, ref useSiteDiagnostics);
}
......@@ -682,7 +682,7 @@ internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(Diagn
internal bool IsSymbolAccessibleConditional(
Symbol symbol,
NamedTypeSymbol within,
ref HashSet<DiagnosticInfo> useSiteDiagnostics,
ref HashSet<DiagnosticInfo>? useSiteDiagnostics,
TypeSymbol? throughTypeOpt = null)
{
return this.Flags.Includes(BinderFlags.IgnoreAccessibility) || AccessCheck.IsSymbolAccessible(symbol, within, ref useSiteDiagnostics, throughTypeOpt);
......@@ -693,7 +693,7 @@ internal static ObsoleteDiagnosticKind ReportDiagnosticsIfObsoleteInternal(Diagn
NamedTypeSymbol within,
TypeSymbol throughTypeOpt,
out bool failedThroughTypeCheck,
ref HashSet<DiagnosticInfo> useSiteDiagnostics,
ref HashSet<DiagnosticInfo>? useSiteDiagnostics,
ConsList<TypeSymbol>? basesBeingResolved = null)
{
if (this.Flags.Includes(BinderFlags.IgnoreAccessibility))
......
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
using System.Collections.Generic;
using System.Diagnostics;
......@@ -8,6 +9,7 @@
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.PooledObjects;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
......@@ -40,7 +42,7 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
for (int i = 0; i < fieldCount; i++)
{
AnonymousObjectMemberDeclaratorSyntax fieldInitializer = initializers[i];
NameEqualsSyntax nameEquals = fieldInitializer.NameEquals;
NameEqualsSyntax? nameEquals = fieldInitializer.NameEquals;
ExpressionSyntax expression = fieldInitializer.Expression;
SyntaxToken nameToken = default(SyntaxToken);
......@@ -63,11 +65,11 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
boundExpressions[i] = BindRValueWithoutTargetType(expression, diagnostics);
// check the name to be unique
string fieldName = null;
string? fieldName = null;
if (nameToken.Kind() == SyntaxKind.IdentifierToken)
{
fieldName = nameToken.ValueText;
if (!uniqueFieldNames.Add(fieldName))
if (!uniqueFieldNames.Add(fieldName!))
{
// name duplication
Error(diagnostics, ErrorCode.ERR_AnonymousTypeDuplicatePropertyName, fieldInitializer);
......@@ -85,7 +87,7 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
TypeSymbol fieldType = GetAnonymousTypeFieldType(boundExpressions[i], fieldInitializer, diagnostics, ref hasError);
// build anonymous type field descriptor
fieldSyntaxNodes[i] = (nameToken.Kind() == SyntaxKind.IdentifierToken) ? (CSharpSyntaxNode)nameToken.Parent : fieldInitializer;
fieldSyntaxNodes[i] = (nameToken.Kind() == SyntaxKind.IdentifierToken) ? (CSharpSyntaxNode)nameToken.Parent! : fieldInitializer;
fields[i] = new AnonymousTypeField(
fieldName == null ? "$" + i.ToString() : fieldName,
fieldSyntaxNodes[i].Location,
......@@ -107,7 +109,7 @@ private BoundExpression BindAnonymousObjectCreation(AnonymousObjectCreationExpre
ArrayBuilder<BoundAnonymousPropertyDeclaration>.GetInstance();
for (int i = 0; i < fieldCount; i++)
{
NameEqualsSyntax explicitName = initializers[i].NameEquals;
NameEqualsSyntax? explicitName = initializers[i].NameEquals;
if (explicitName != null)
{
AnonymousTypeField field = fields[i];
......@@ -178,7 +180,7 @@ private static bool IsAnonymousTypeMemberExpression(ExpressionSyntax expr)
private bool IsAnonymousTypesAllowed()
{
var member = this.ContainingMemberOrLambda;
if ((object)member == null)
if (member is null)
{
return false;
}
......@@ -205,13 +207,14 @@ private bool IsAnonymousTypesAllowed()
/// </summary>
private TypeSymbol GetAnonymousTypeFieldType(BoundExpression expression, CSharpSyntaxNode errorSyntax, DiagnosticBag diagnostics, ref bool hasError)
{
object errorArg = null;
TypeSymbol expressionType = expression.Type;
object? errorArg = null;
TypeSymbol? expressionType = expression.Type;
if (!expression.HasAnyErrors)
{
if (expression.HasExpressionType())
{
RoslynDebug.Assert(expressionType is object);
if (expressionType.IsVoidType())
{
errorArg = expressionType;
......@@ -233,7 +236,7 @@ private TypeSymbol GetAnonymousTypeFieldType(BoundExpression expression, CSharpS
}
}
if ((object)expressionType == null)
if (expressionType is null)
{
expressionType = CreateErrorType("error");
}
......
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
......@@ -45,15 +48,15 @@ internal void ReportBadAwaitDiagnostics(SyntaxNode node, Location location, Diag
hasErrors |= ReportBadAwaitContext(node, location, diagnostics);
}
internal BoundAwaitableInfo BindAwaitInfo(BoundAwaitableValuePlaceholder placeholder, SyntaxNode node, DiagnosticBag diagnostics, ref bool hasErrors, BoundExpression expressionOpt = null)
internal BoundAwaitableInfo BindAwaitInfo(BoundAwaitableValuePlaceholder placeholder, SyntaxNode node, DiagnosticBag diagnostics, ref bool hasErrors, BoundExpression? expressionOpt = null)
{
bool hasGetAwaitableErrors = !GetAwaitableExpressionInfo(
expressionOpt ?? placeholder,
placeholder,
out bool isDynamic,
out BoundExpression getAwaiter,
out PropertySymbol isCompleted,
out MethodSymbol getResult,
out BoundExpression? getAwaiter,
out PropertySymbol? isCompleted,
out MethodSymbol? getResult,
getAwaiterGetResultCall: out _,
node,
diagnostics);
......@@ -78,7 +81,7 @@ private bool CouldBeAwaited(BoundExpression expression)
}
var type = expression.Type;
if (((object)type == null) ||
if ((type is null) ||
type.IsDynamic() ||
(type.IsVoidType()))
{
......@@ -101,7 +104,7 @@ private bool CouldBeAwaited(BoundExpression expression)
// Finally, if we're in an async method, and the expression could be awaited, report that it is instead discarded.
var containingMethod = this.ContainingMemberOrLambda as MethodSymbol;
if ((object)containingMethod == null || !containingMethod.IsAsync)
if (containingMethod is null || !containingMethod.IsAsync)
{
return false;
}
......@@ -136,9 +139,9 @@ private bool ContextForbidsAwait
/// <returns>True if the expression contains errors.</returns>
private bool ReportBadAwaitWithoutAsync(Location location, DiagnosticBag diagnostics)
{
DiagnosticInfo info = null;
DiagnosticInfo? info = null;
var containingMemberOrLambda = this.ContainingMemberOrLambda;
if ((object)containingMemberOrLambda != null)
if (containingMemberOrLambda is object)
{
switch (containingMemberOrLambda.Kind)
{
......@@ -230,7 +233,7 @@ private bool ReportBadAwaitContext(SyntaxNode node, Location location, Diagnosti
/// <returns>True if the expression is awaitable; false otherwise.</returns>
internal bool GetAwaitableExpressionInfo(
BoundExpression expression,
out BoundExpression getAwaiterGetResultCall,
[NotNullWhen(true)] out BoundExpression? getAwaiterGetResultCall,
SyntaxNode node,
DiagnosticBag diagnostics)
{
......@@ -241,10 +244,10 @@ private bool ReportBadAwaitContext(SyntaxNode node, Location location, Diagnosti
BoundExpression expression,
BoundExpression getAwaiterArgument,
out bool isDynamic,
out BoundExpression getAwaiter,
out PropertySymbol isCompleted,
out MethodSymbol getResult,
out BoundExpression getAwaiterGetResultCall,
out BoundExpression? getAwaiter,
out PropertySymbol? isCompleted,
out MethodSymbol? getResult,
out BoundExpression? getAwaiterGetResultCall,
SyntaxNode node,
DiagnosticBag diagnostics)
{
......@@ -272,10 +275,10 @@ private bool ReportBadAwaitContext(SyntaxNode node, Location location, Diagnosti
return false;
}
TypeSymbol awaiterType = getAwaiter.Type;
return GetIsCompletedProperty(awaiterType, node, expression.Type, diagnostics, out isCompleted)
TypeSymbol awaiterType = getAwaiter.Type!;
return GetIsCompletedProperty(awaiterType, node, expression.Type!, diagnostics, out isCompleted)
&& AwaiterImplementsINotifyCompletion(awaiterType, node, diagnostics)
&& GetGetResultMethod(getAwaiter, node, expression.Type, diagnostics, out getResult, out getAwaiterGetResultCall);
&& GetGetResultMethod(getAwaiter, node, expression.Type!, diagnostics, out getResult, out getAwaiterGetResultCall);
}
/// <summary>
......@@ -289,7 +292,7 @@ private static bool ValidateAwaitedExpression(BoundExpression expression, Syntax
return false;
}
if ((object)expression.Type == null)
if (expression.Type is null)
{
Error(diagnostics, ErrorCode.ERR_BadAwaitArgIntrinsic, node, expression.Display);
return false;
......@@ -309,8 +312,9 @@ private static bool ValidateAwaitedExpression(BoundExpression expression, Syntax
/// NOTE: this is an error in the spec. An extension method of the form
/// Awaiter&lt;T&gt; GetAwaiter&lt;T&gt;(this Task&lt;T&gt;) may be used.
/// </remarks>
private bool GetGetAwaiterMethod(BoundExpression expression, SyntaxNode node, DiagnosticBag diagnostics, out BoundExpression getAwaiterCall)
private bool GetGetAwaiterMethod(BoundExpression expression, SyntaxNode node, DiagnosticBag diagnostics, [NotNullWhen(true)] out BoundExpression? getAwaiterCall)
{
RoslynDebug.Assert(expression.Type is object);
if (expression.Type.IsVoidType())
{
Error(diagnostics, ErrorCode.ERR_BadAwaitArgVoidCall, node);
......@@ -352,7 +356,7 @@ private bool GetGetAwaiterMethod(BoundExpression expression, SyntaxNode node, Di
/// Spec 7.7.7.1:
/// An Awaiter A has an accessible, readable instance property IsCompleted of type bool.
/// </remarks>
private bool GetIsCompletedProperty(TypeSymbol awaiterType, SyntaxNode node, TypeSymbol awaitedExpressionType, DiagnosticBag diagnostics, out PropertySymbol isCompletedProperty)
private bool GetIsCompletedProperty(TypeSymbol awaiterType, SyntaxNode node, TypeSymbol awaitedExpressionType, DiagnosticBag diagnostics, [NotNullWhen(true)] out PropertySymbol? isCompletedProperty)
{
var receiver = new BoundLiteral(node, ConstantValue.Null, awaiterType);
var name = WellKnownMemberNames.IsCompleted;
......@@ -398,7 +402,7 @@ private bool GetIsCompletedProperty(TypeSymbol awaiterType, SyntaxNode node, Typ
private bool AwaiterImplementsINotifyCompletion(TypeSymbol awaiterType, SyntaxNode node, DiagnosticBag diagnostics)
{
var INotifyCompletion = GetWellKnownType(WellKnownType.System_Runtime_CompilerServices_INotifyCompletion, diagnostics, node);
HashSet<DiagnosticInfo> useSiteDiagnostics = null;
HashSet<DiagnosticInfo>? useSiteDiagnostics = null;
var conversion = this.Conversions.ClassifyImplicitConversionFromType(awaiterType, INotifyCompletion, ref useSiteDiagnostics);
if (!conversion.IsImplicit)
......@@ -419,7 +423,7 @@ private bool AwaiterImplementsINotifyCompletion(TypeSymbol awaiterType, SyntaxNo
/// Spec 7.7.7.1:
/// An Awaiter A has an accessible instance method GetResult with no parameters and no type parameters.
/// </remarks>
private bool GetGetResultMethod(BoundExpression awaiterExpression, SyntaxNode node, TypeSymbol awaitedExpressionType, DiagnosticBag diagnostics, out MethodSymbol getResultMethod, out BoundExpression getAwaiterGetResultCall)
private bool GetGetResultMethod(BoundExpression awaiterExpression, SyntaxNode node, TypeSymbol awaitedExpressionType, DiagnosticBag diagnostics, out MethodSymbol? getResultMethod, [NotNullWhen(true)] out BoundExpression? getAwaiterGetResultCall)
{
var awaiterType = awaiterExpression.Type;
getAwaiterGetResultCall = MakeInvocationExpression(node, awaiterExpression, WellKnownMemberNames.GetResult, ImmutableArray<BoundExpression>.Empty, diagnostics);
......@@ -430,6 +434,7 @@ private bool GetGetResultMethod(BoundExpression awaiterExpression, SyntaxNode no
return false;
}
RoslynDebug.Assert(awaiterType is object);
if (getAwaiterGetResultCall.Kind != BoundKind.Call)
{
Error(diagnostics, ErrorCode.ERR_NoSuchMember, node, awaiterType, WellKnownMemberNames.GetResult);
......@@ -461,7 +466,7 @@ private bool GetGetResultMethod(BoundExpression awaiterExpression, SyntaxNode no
private static bool HasOptionalOrVariableParameters(MethodSymbol method)
{
Debug.Assert(method != null);
RoslynDebug.Assert(method != null);
if (method.ParameterCount != 0)
{
......
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
using System.Collections.Generic;
using System.Collections.Immutable;
......@@ -30,7 +31,7 @@ internal partial class Binder
bool isForOverride = false)
{
Debug.Assert(this.Flags.Includes(BinderFlags.GenericConstraintsClause));
Debug.Assert((object)containingSymbol != null);
RoslynDebug.Assert((object)containingSymbol != null);
Debug.Assert((containingSymbol.Kind == SymbolKind.NamedType) || (containingSymbol.Kind == SymbolKind.Method));
Debug.Assert(typeParameters.Length > 0);
Debug.Assert(clauses.Count > 0);
......@@ -51,20 +52,20 @@ internal partial class Binder
}
// An array of constraint clauses, one for each type parameter, indexed by ordinal.
var results = ArrayBuilder<TypeParameterConstraintClause>.GetInstance(n, fillWithValue: null);
var syntaxNodes = ArrayBuilder<ArrayBuilder<TypeConstraintSyntax>>.GetInstance(n, fillWithValue: null);
var results = ArrayBuilder<TypeParameterConstraintClause?>.GetInstance(n, fillWithValue: null);
var syntaxNodes = ArrayBuilder<ArrayBuilder<TypeConstraintSyntax>?>.GetInstance(n, fillWithValue: null);
// Bind each clause and add to the results.
foreach (var clause in clauses)
{
var name = clause.Name.Identifier.ValueText;
int ordinal;
if (names.TryGetValue(name, out ordinal))
if (names.TryGetValue(name!, out ordinal))
{
Debug.Assert(ordinal >= 0);
Debug.Assert(ordinal < n);
(TypeParameterConstraintClause constraintClause, ArrayBuilder<TypeConstraintSyntax> typeConstraintNodes) = this.BindTypeParameterConstraints(typeParameterList.Parameters[ordinal], clause, isForOverride, diagnostics);
(TypeParameterConstraintClause constraintClause, ArrayBuilder<TypeConstraintSyntax>? typeConstraintNodes) = this.BindTypeParameterConstraints(typeParameterList.Parameters[ordinal], clause, isForOverride, diagnostics);
if (results[ordinal] == null)
{
results[ordinal] = constraintClause;
......@@ -100,7 +101,7 @@ internal partial class Binder
TypeParameterConstraintClause.AdjustConstraintTypes(containingSymbol, typeParameters, results, ref isValueTypeOverride);
RemoveInvalidConstraints(typeParameters, results, syntaxNodes, diagnostics);
RemoveInvalidConstraints(typeParameters, results!, syntaxNodes, diagnostics);
foreach (var typeConstraintsSyntaxes in syntaxNodes)
{
......@@ -109,17 +110,17 @@ internal partial class Binder
syntaxNodes.Free();
return results.ToImmutableAndFree();
return results.ToImmutableAndFree()!;
}
/// <summary>
/// Bind and return a single type parameter constraint clause along with syntax nodes corresponding to type constraints.
/// </summary>
private (TypeParameterConstraintClause, ArrayBuilder<TypeConstraintSyntax>) BindTypeParameterConstraints(TypeParameterSyntax typeParameterSyntax, TypeParameterConstraintClauseSyntax constraintClauseSyntax, bool isForOverride, DiagnosticBag diagnostics)
private (TypeParameterConstraintClause, ArrayBuilder<TypeConstraintSyntax>?) BindTypeParameterConstraints(TypeParameterSyntax typeParameterSyntax, TypeParameterConstraintClauseSyntax constraintClauseSyntax, bool isForOverride, DiagnosticBag diagnostics)
{
var constraints = TypeParameterConstraintKind.None;
ArrayBuilder<TypeWithAnnotations> constraintTypes = null;
ArrayBuilder<TypeConstraintSyntax> syntaxBuilder = null;
ArrayBuilder<TypeWithAnnotations>? constraintTypes = null;
ArrayBuilder<TypeConstraintSyntax>? syntaxBuilder = null;
SeparatedSyntaxList<TypeParameterConstraintSyntax> constraintsSyntax = constraintClauseSyntax.Constraints;
Debug.Assert(!InExecutableBinder); // Cannot eagerly report diagnostics handled by LazyMissingNonNullTypesContextDiagnosticInfo
bool hasTypeLikeConstraint = false;
......@@ -258,7 +259,7 @@ internal partial class Binder
}
constraintTypes.Add(type);
syntaxBuilder.Add(typeConstraintSyntax);
syntaxBuilder!.Add(typeConstraintSyntax);
}
continue;
default:
......@@ -309,7 +310,7 @@ private TypeParameterConstraintClause GetDefaultTypeParameterConstraintClause(Ty
private static void RemoveInvalidConstraints(
ImmutableArray<TypeParameterSymbol> typeParameters,
ArrayBuilder<TypeParameterConstraintClause> constraintClauses,
ArrayBuilder<ArrayBuilder<TypeConstraintSyntax>> syntaxNodes,
ArrayBuilder<ArrayBuilder<TypeConstraintSyntax>?> syntaxNodes,
DiagnosticBag diagnostics)
{
Debug.Assert(typeParameters.Length > 0);
......@@ -324,7 +325,7 @@ private TypeParameterConstraintClause GetDefaultTypeParameterConstraintClause(Ty
private static TypeParameterConstraintClause RemoveInvalidConstraints(
TypeParameterSymbol typeParameter,
TypeParameterConstraintClause constraintClause,
ArrayBuilder<TypeConstraintSyntax> syntaxNodesOpt,
ArrayBuilder<TypeConstraintSyntax>? syntaxNodesOpt,
DiagnosticBag diagnostics)
{
if (syntaxNodesOpt != null)
......@@ -367,7 +368,7 @@ private TypeParameterConstraintClause GetDefaultTypeParameterConstraintClause(Ty
TypeWithAnnotations constraintType,
DiagnosticBag diagnostics)
{
HashSet<DiagnosticInfo> useSiteDiagnostics = null;
HashSet<DiagnosticInfo>? useSiteDiagnostics = null;
if (!containingSymbol.IsNoMoreVisibleThan(constraintType, ref useSiteDiagnostics))
{
// "Inconsistent accessibility: constraint type '{1}' is less accessible than '{0}'"
......
......@@ -60,7 +60,7 @@ internal override Imports GetImports(ConsList<TypeSymbol> basesBeingResolved)
protected override bool InExecutableBinder => false;
internal override bool IsAccessibleHelper(Symbol symbol, TypeSymbol accessThroughType, out bool failedThroughTypeCheck, ref HashSet<DiagnosticInfo> useSiteDiagnostics, ConsList<TypeSymbol> basesBeingResolved)
internal override bool IsAccessibleHelper(Symbol symbol, TypeSymbol accessThroughType, out bool failedThroughTypeCheck, ref HashSet<DiagnosticInfo>? useSiteDiagnostics, ConsList<TypeSymbol> basesBeingResolved)
{
failedThroughTypeCheck = false;
return IsSymbolAccessibleConditional(symbol, Compilation.Assembly, ref useSiteDiagnostics);
......
......@@ -1783,11 +1783,11 @@ internal bool ReturnsAwaitableToVoidOrInt(MethodSymbol method, DiagnosticBag dia
var syntax = method.ExtractReturnTypeSyntax();
var dumbInstance = new BoundLiteral(syntax, ConstantValue.Null, namedType);
var binder = GetBinder(syntax);
BoundExpression result;
BoundExpression? result;
var success = binder.GetAwaitableExpressionInfo(dumbInstance, out result, syntax, diagnostics);
return success &&
(result.Type!.IsVoidType() || result.Type!.SpecialType == SpecialType.System_Int32);
(result!.Type!.IsVoidType() || result.Type!.SpecialType == SpecialType.System_Int32);
}
/// <summary>
......@@ -3168,7 +3168,7 @@ protected override IPointerTypeSymbol CommonCreatePointerTypeSymbol(ITypeSymbol
return NamedTypeSymbol.CreateTuple(
locationOpt: null, // no location for the type declaration
elementTypesWithAnnotations: typesBuilder.ToImmutableAndFree(),
elementLocations: elementLocations,
elementLocations: elementLocations!,
elementNames: elementNames,
compilation: this,
shouldCheckConstraints: false,
......@@ -3194,7 +3194,7 @@ protected override IPointerTypeSymbol CommonCreatePointerTypeSymbol(ITypeSymbol
CheckTupleElementNullableAnnotations(cardinality, elementNullableAnnotations);
var tupleType = NamedTypeSymbol.CreateTuple(
csharpUnderlyingTuple, elementNames, elementLocations: elementLocations);
csharpUnderlyingTuple, elementNames, elementLocations: elementLocations!);
if (!elementNullableAnnotations.IsDefault)
{
tupleType = tupleType.WithElementTypes(
......
......@@ -91,7 +91,7 @@ public static bool IsNoMoreVisibleThan(this Symbol symbol, TypeSymbol type, ref
return type.IsAtLeastAsVisibleAs(symbol, ref useSiteDiagnostics);
}
public static bool IsNoMoreVisibleThan(this Symbol symbol, TypeWithAnnotations type, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
public static bool IsNoMoreVisibleThan(this Symbol symbol, TypeWithAnnotations type, ref HashSet<DiagnosticInfo>? useSiteDiagnostics)
{
return type.IsAtLeastAsVisibleAs(symbol, ref useSiteDiagnostics);
}
......
......@@ -29,7 +29,7 @@ internal abstract partial class NamedTypeSymbol
internal static NamedTypeSymbol CreateTuple(
Location? locationOpt,
ImmutableArray<TypeWithAnnotations> elementTypesWithAnnotations,
ImmutableArray<Location> elementLocations,
ImmutableArray<Location?> elementLocations,
ImmutableArray<string?> elementNames,
CSharpCompilation compilation,
bool shouldCheckConstraints,
......@@ -104,7 +104,7 @@ static NamedTypeSymbol getTupleUnderlyingType(ImmutableArray<TypeWithAnnotations
NamedTypeSymbol tupleCompatibleType,
ImmutableArray<string?> elementNames = default,
ImmutableArray<bool> errorPositions = default,
ImmutableArray<Location> elementLocations = default,
ImmutableArray<Location?> elementLocations = default,
ImmutableArray<Location> locations = default)
{
Debug.Assert(tupleCompatibleType.IsTupleType);
......@@ -162,7 +162,7 @@ internal NamedTypeSymbol WithElementTypes(ImmutableArray<TypeWithAnnotations> ne
/// Drops the inferred positions.
/// </summary>
internal NamedTypeSymbol WithElementNames(ImmutableArray<string?> newElementNames,
ImmutableArray<Location> newElementLocations,
ImmutableArray<Location?> newElementLocations,
ImmutableArray<bool> errorPositions,
ImmutableArray<Location> locations)
{
......@@ -555,7 +555,7 @@ public sealed override bool IsTupleType
private ImmutableArray<bool> TupleErrorPositions
=> _lazyTupleData is null ? default : _lazyTupleData.ErrorPositions;
private ImmutableArray<Location> TupleElementLocations
private ImmutableArray<Location?> TupleElementLocations
=> _lazyTupleData is null ? default : _lazyTupleData.ElementLocations;
public sealed override ImmutableArray<TypeWithAnnotations> TupleElementTypesWithAnnotations
......@@ -898,7 +898,7 @@ internal sealed class TupleExtraData
/// Declaration locations for individual elements, if provided.
/// Declaration location for this tuple type symbol
/// </summary>
internal ImmutableArray<Location> ElementLocations { get; }
internal ImmutableArray<Location?> ElementLocations { get; }
/// <summary>
/// Which element names were inferred and therefore cannot be used.
......@@ -933,7 +933,7 @@ internal TupleExtraData(NamedTypeSymbol underlyingType)
}
internal TupleExtraData(NamedTypeSymbol underlyingType, ImmutableArray<string?> elementNames,
ImmutableArray<Location> elementLocations, ImmutableArray<bool> errorPositions, ImmutableArray<Location> locations)
ImmutableArray<Location?> elementLocations, ImmutableArray<bool> errorPositions, ImmutableArray<Location> locations)
: this(underlyingType)
{
ElementNames = elementNames;
......
......@@ -488,9 +488,9 @@ public static MethodSymbol DelegateInvokeMethod(this TypeSymbol type)
return null;
}
public static SpecialType GetSpecialTypeSafe(this TypeSymbol type)
public static SpecialType GetSpecialTypeSafe(this TypeSymbol? type)
{
return (object)type != null ? type.SpecialType : SpecialType.None;
return type is object ? type.SpecialType : SpecialType.None;
}
public static bool IsAtLeastAsVisibleAs(this TypeSymbol type, Symbol sym, ref HashSet<DiagnosticInfo>? useSiteDiagnostics)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册