This project is read-only.

Override Equals(object) - RangeVariableSymbol: C# & VB differ at where & implementation


C# overrides the Equals(object) method in the only no abstract RangeVariableSymbol.

While VB's RangeVariableSymbol is MustInherit and the Equals(object) is only overridden in one of its private derived symbol - WithIdentifierToken
Note: it has 3 private derived symbols, the other 2 are: ForErrorRecovery->CompilerGenerated

The implementations are also different:

VB: Friend MustInherit Class RangeVariableSymbol

Private Class WithIdentifierToken
        Inherits RangeVariableSymbol
Public Overrides Function Equals(obj As Object) As Boolean
            Dim other = TryCast(obj, RangeVariableSymbol.WithIdentifierToken)
            If Me Is other Then
                Return True
            End If
            Return other IsNot Nothing AndAlso other.m_IdentifierToken.Equals(m_IdentifierToken)
        End Function

C#: internal class RangeVariableSymbol : Symbol, IRangeVariableSymbol

public override bool Equals(object obj) {
        if (obj == (object)this)
            return true;
        var symbol = obj as RangeVariableSymbol;
        return (object)symbol != null
            && symbol.locations[0].Equals(this.locations[0])
            && Equals(containingSymbol, symbol.ContainingSymbol);
For C#: it means we don't care ReferenceEquals; for VB, we do ReferenceEquals for error recovery symbols.