Skip to content

Commit

Permalink
Revert signature change
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Oct 4, 2024
1 parent 0da3c4a commit 8fde573
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/Compilers/CSharp/Portable/Binder/Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@ internal virtual ConsList<FieldSymbol> FieldsBeingBound
}
}

internal virtual ConsList<LocalSymbol> LocalsInProgress
internal virtual LocalSymbol? LocalInProgress
{
get
{
RoslynDebug.Assert(Next is object);
return this.Next.LocalsInProgress;
return this.Next.LocalInProgress;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -867,10 +867,10 @@ private BoundExpression BindDeconstructionVariable(
CSharpSyntaxNode syntax,
BindingDiagnosticBag diagnostics)
{
SourceLocalSymbol? localSymbol = LookupLocal(designation.Identifier);
SourceLocalSymbol localSymbol = LookupLocal(designation.Identifier);

// is this a local?
if ((object?)localSymbol != null)
if ((object)localSymbol != null)
{
if (designation.Parent is DeclarationExpressionSyntax declExpr && declExpr.Designation == designation)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2065,7 +2065,7 @@ private BoundExpression BindNonMethod(SimpleNameSyntax node, Symbol symbol, Bind
}

var constantValueOpt = localSymbol.IsConst && !IsInsideNameof && !type.IsErrorType()
? localSymbol.GetConstantValue(node, this.LocalsInProgress, diagnostics) : null;
? localSymbol.GetConstantValue(node, this.LocalInProgress, diagnostics) : null;
return new BoundLocal(node, localSymbol, BoundLocalDeclarationKind.None, constantValueOpt: constantValueOpt, isNullableUnknown: isNullableUnknown, type: type, hasErrors: isError);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ private void BindPatternDesignation(
{
case SingleVariableDesignationSyntax singleVariableDesignation:
SyntaxToken identifier = singleVariableDesignation.Identifier;
SourceLocalSymbol? localSymbol = this.LookupLocal(identifier);
SourceLocalSymbol localSymbol = this.LookupLocal(identifier);

if (!permitDesignations && !identifier.IsMissing)
diagnostics.Add(ErrorCode.ERR_DesignatorBeneathPatternCombinator, identifier.GetLocation());
Expand Down
8 changes: 3 additions & 5 deletions src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,8 @@ protected BoundLocalDeclaration BindVariableDeclaration(
CSharpSyntaxNode associatedSyntaxNode = null)
{
Debug.Assert(declarator != null);
return this.BindVariableDeclaration(LocateDeclaredVariableSymbol(declarator, typeSyntax, kind),

return BindVariableDeclaration(LocateDeclaredVariableSymbol(declarator, typeSyntax, kind),
kind,
isVar,
declarator,
Expand Down Expand Up @@ -1844,13 +1845,10 @@ private BoundExpression BindPossibleArrayInitializer(
return CheckValue(result, valueKind, diagnostics);
}

#nullable enable
protected virtual SourceLocalSymbol? LookupLocal(SyntaxToken nameToken)
protected virtual SourceLocalSymbol LookupLocal(SyntaxToken nameToken)
{
Debug.Assert(Next is not null);
return Next.LookupLocal(nameToken);
}
#nullable disable

protected virtual LocalFunctionSymbol LookupLocalFunction(SyntaxToken nameToken)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/CSharp/Portable/Binder/BuckStopsHereBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ internal override ConsList<FieldSymbol> FieldsBeingBound
}
}

internal override ConsList<LocalSymbol> LocalsInProgress
internal override LocalSymbol? LocalInProgress
{
get
{
return ConsList<LocalSymbol>.Empty;
return null;
}
}

Expand Down
10 changes: 2 additions & 8 deletions src/Compilers/CSharp/Portable/Binder/LocalInProgressBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,11 @@ internal LocalInProgressBinder(EqualsValueClauseSyntax initializerSyntax, Binder
InitializerSyntax = initializerSyntax;
}

internal override ConsList<LocalSymbol> LocalsInProgress
internal override LocalSymbol? LocalInProgress
{
get
{
var result = base.LocalsInProgress;
if (_localSymbol is not null)
{
return result.Push(_localSymbol);
}

return result;
return _localSymbol;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/CodeGen/Optimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2403,7 +2403,7 @@ public override ImmutableArray<SyntaxReference> DeclaringSyntaxReferences
get { throw new NotImplementedException(); }
}

internal override ConstantValue GetConstantValue(SyntaxNode node, ConsList<LocalSymbol> inProgress, BindingDiagnosticBag diagnostics)
internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics)
{
throw new NotImplementedException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,6 @@ private static Binder GetEnclosingBinderInternalWithinRoot(SyntaxNode node, int
{
binder = rootBinder.GetBinder(current);
}
else if (kind == SyntaxKind.VariableDeclarator)
{
binder = rootBinder.GetBinder(current);
}
else if ((current as ExpressionSyntax).IsValidScopeDesignator())
{
binder = rootBinder.GetBinder(current);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override bool Equals(Symbol obj, TypeCompareKind compareKind)
internal override bool IsKnownToReferToTempIfReferenceType => false;
public override RefKind RefKind => RefKind.None;
internal override SynthesizedLocalKind SynthesizedKind => throw ExceptionUtilities.Unreachable();
internal override ConstantValue GetConstantValue(SyntaxNode node, ConsList<LocalSymbol> inProgress, BindingDiagnosticBag diagnostics = null) => null;
internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics = null) => null;
internal override ReadOnlyBindingDiagnostic<AssemblySymbol> GetConstantValueDiagnostics(BoundExpression boundInitValue) => ReadOnlyBindingDiagnostic<AssemblySymbol>.Empty;
internal override SyntaxNode GetDeclaratorSyntax() => throw ExceptionUtilities.Unreachable();
internal override bool HasSourceLocation => false;
Expand Down
4 changes: 1 addition & 3 deletions src/Compilers/CSharp/Portable/Symbols/LocalSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,7 @@ internal abstract bool IsCompilerGenerated
get;
}

#nullable enable
internal abstract ConstantValue? GetConstantValue(SyntaxNode node, ConsList<LocalSymbol>? inProgress, BindingDiagnosticBag? diagnostics = null);
#nullable disable
internal abstract ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics = null);

internal abstract ReadOnlyBindingDiagnostic<AssemblySymbol> GetConstantValueDiagnostics(BoundExpression boundInitValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ internal override bool IsCompilerGenerated
get { return false; }
}

internal override ConstantValue GetConstantValue(SyntaxNode node, ConsList<LocalSymbol> inProgress, BindingDiagnosticBag diagnostics)
internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics)
{
return null;
}
Expand Down Expand Up @@ -547,24 +547,22 @@ protected override TypeWithAnnotations InferTypeOfVarVariable(BindingDiagnosticB

internal override SyntaxNode ForbiddenZone => _initializer;

#nullable enable
/// <summary>
/// Determine the constant value of this local and the corresponding diagnostics.
/// Set both to constantTuple in a single operation for thread safety.
/// </summary>
/// <param name="inProgress">Null for the initial call, non-null if we are in the process of evaluating a constant.</param>
/// <param name="boundInitValue">If we already have the bound node for the initial value, pass it in to avoid recomputing it.</param>
private void MakeConstantTuple(ConsList<LocalSymbol>? inProgress, BoundExpression? boundInitValue)
private void MakeConstantTuple(LocalSymbol inProgress, BoundExpression boundInitValue)
{
if (this.IsConst && _constantTuple == null)
{
var value = Microsoft.CodeAnalysis.ConstantValue.Bad;
var diagnostics = BindingDiagnosticBag.GetInstance();
Debug.Assert(inProgress?.Contains(this) != true);
Debug.Assert(inProgress != this);
var type = this.Type;
if (boundInitValue == null)
{
// TODO2
recordLocalInBinderChain(this, _initializer, this._initializerBinder);
boundInitValue = this._initializerBinder.BindVariableOrAutoPropInitializerValue(_initializer, this.RefKind, type, diagnostics);
}
Expand All @@ -588,9 +586,9 @@ static void recordLocalInBinderChain(LocalSymbol local, EqualsValueClauseSyntax
}
}

internal override ConstantValue? GetConstantValue(SyntaxNode node, ConsList<LocalSymbol>? inProgress, BindingDiagnosticBag? diagnostics = null)
internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics = null)
{
if (this.IsConst && inProgress?.Contains(this) == true)
if (this.IsConst && inProgress == this)
{
if (diagnostics != null)
{
Expand All @@ -610,7 +608,6 @@ internal override ReadOnlyBindingDiagnostic<AssemblySymbol> GetConstantValueDiag
MakeConstantTuple(inProgress: null, boundInitValue: boundInitValue);
return _constantTuple == null ? ReadOnlyBindingDiagnostic<AssemblySymbol>.Empty : _constantTuple.Diagnostics;
}
#nullable disable
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.CSharp.Symbols
{
Expand Down Expand Up @@ -188,7 +187,7 @@ internal sealed override bool IsCompilerGenerated

internal sealed override ScopedKind Scope => ScopedKind.None;

internal sealed override ConstantValue GetConstantValue(SyntaxNode node, ConsList<LocalSymbol> inProgress, BindingDiagnosticBag diagnostics)
internal sealed override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public override RefKind RefKind
/// </summary>
internal override ScopedKind Scope => throw new System.NotImplementedException();

internal override ConstantValue GetConstantValue(SyntaxNode node, ConsList<LocalSymbol> inProgress, BindingDiagnosticBag diagnostics)
internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics)
{
return _originalVariable.GetConstantValue(node, inProgress, diagnostics);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public override bool Equals(Symbol other, TypeCompareKind compareKind)
internal override bool IsKnownToReferToTempIfReferenceType => _underlyingLocal.IsKnownToReferToTempIfReferenceType;
internal override bool IsCompilerGenerated => _underlyingLocal.IsCompilerGenerated;
internal override ScopedKind Scope => _underlyingLocal.Scope;
internal override ConstantValue GetConstantValue(SyntaxNode node, ConsList<LocalSymbol>? inProgress, BindingDiagnosticBag? diagnostics = null) =>
internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag? diagnostics = null) =>
_underlyingLocal.GetConstantValue(node, inProgress, diagnostics);
internal override ReadOnlyBindingDiagnostic<AssemblySymbol> GetConstantValueDiagnostics(BoundExpression boundInitValue) =>
_underlyingLocal.GetConstantValueDiagnostics(boundInitValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal override bool IsCompilerGenerated
get { return false; }
}

internal override ConstantValue GetConstantValue(SyntaxNode node, ConsList<LocalSymbol> inProgress, BindingDiagnosticBag diagnostics)
internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics)
{
if (diagnostics != null && _value.IsBad)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal abstract class EELocalSymbolBase : LocalSymbol

internal abstract EELocalSymbolBase ToOtherMethod(MethodSymbol method, TypeMap typeMap);

internal override ConstantValue GetConstantValue(SyntaxNode node, ConsList<LocalSymbol> inProgress, BindingDiagnosticBag diagnostics)
internal override ConstantValue GetConstantValue(SyntaxNode node, LocalSymbol inProgress, BindingDiagnosticBag diagnostics)
{
return null;
}
Expand Down

0 comments on commit 8fde573

Please sign in to comment.