@@ -73,20 +73,18 @@ public SymbolEquivalenceComparer(
73
73
using var equivalenceVisitors = TemporaryArray < EquivalenceVisitor > . Empty ;
74
74
using var getHashCodeVisitors = TemporaryArray < GetHashCodeVisitor > . Empty ;
75
75
76
- AddVisitors ( compareMethodTypeParametersByIndex : true , objectAndDynamicCompareEqually : true ) ;
77
- AddVisitors ( compareMethodTypeParametersByIndex : true , objectAndDynamicCompareEqually : false ) ;
78
- AddVisitors ( compareMethodTypeParametersByIndex : false , objectAndDynamicCompareEqually : true ) ;
79
- AddVisitors ( compareMethodTypeParametersByIndex : false , objectAndDynamicCompareEqually : false ) ;
76
+ AddVisitors ( compareMethodTypeParametersByIndex : true ) ;
77
+ AddVisitors ( compareMethodTypeParametersByIndex : false ) ;
80
78
81
79
_equivalenceVisitors = equivalenceVisitors . ToImmutableAndClear ( ) ;
82
80
_getHashCodeVisitors = getHashCodeVisitors . ToImmutableAndClear ( ) ;
83
81
84
82
return ;
85
83
86
- void AddVisitors ( bool compareMethodTypeParametersByIndex , bool objectAndDynamicCompareEqually )
84
+ void AddVisitors ( bool compareMethodTypeParametersByIndex )
87
85
{
88
- equivalenceVisitors . Add ( new ( this , compareMethodTypeParametersByIndex , objectAndDynamicCompareEqually ) ) ;
89
- getHashCodeVisitors . Add ( new ( this , compareMethodTypeParametersByIndex , objectAndDynamicCompareEqually ) ) ;
86
+ equivalenceVisitors . Add ( new ( this , compareMethodTypeParametersByIndex ) ) ;
87
+ getHashCodeVisitors . Add ( new ( this , compareMethodTypeParametersByIndex ) ) ;
90
88
}
91
89
}
92
90
@@ -107,27 +105,21 @@ public static SymbolEquivalenceComparer Create(
107
105
// here. So, instead, when asking if parameters are equal, we pass an appropriate flag so
108
106
// that method type parameters are just compared by index and nothing else.
109
107
private EquivalenceVisitor GetEquivalenceVisitor (
110
- bool compareMethodTypeParametersByIndex = false , bool objectAndDynamicCompareEqually = false )
108
+ bool compareMethodTypeParametersByIndex = false )
111
109
{
112
- var visitorIndex = GetVisitorIndex ( compareMethodTypeParametersByIndex , objectAndDynamicCompareEqually ) ;
110
+ var visitorIndex = GetVisitorIndex ( compareMethodTypeParametersByIndex ) ;
113
111
return _equivalenceVisitors [ visitorIndex ] ;
114
112
}
115
113
116
114
private GetHashCodeVisitor GetGetHashCodeVisitor (
117
- bool compareMethodTypeParametersByIndex , bool objectAndDynamicCompareEqually )
115
+ bool compareMethodTypeParametersByIndex )
118
116
{
119
- var visitorIndex = GetVisitorIndex ( compareMethodTypeParametersByIndex , objectAndDynamicCompareEqually ) ;
117
+ var visitorIndex = GetVisitorIndex ( compareMethodTypeParametersByIndex ) ;
120
118
return _getHashCodeVisitors [ visitorIndex ] ;
121
119
}
122
120
123
- private static int GetVisitorIndex ( bool compareMethodTypeParametersByIndex , bool objectAndDynamicCompareEqually )
124
- => ( compareMethodTypeParametersByIndex , objectAndDynamicCompareEqually ) switch
125
- {
126
- ( true , true ) => 0 ,
127
- ( true , false ) => 1 ,
128
- ( false , true ) => 2 ,
129
- ( false , false ) => 3 ,
130
- } ;
121
+ private static int GetVisitorIndex ( bool compareMethodTypeParametersByIndex )
122
+ => compareMethodTypeParametersByIndex ? 0 : 1 ;
131
123
132
124
public bool ReturnTypeEquals ( IMethodSymbol x , IMethodSymbol y , Dictionary < INamedTypeSymbol , INamedTypeSymbol > ? equivalentTypesWithDifferingAssemblies = null )
133
125
=> GetEquivalenceVisitor ( ) . ReturnTypesAreEquivalent ( x , y , equivalentTypesWithDifferingAssemblies ) ;
@@ -154,7 +146,7 @@ private bool EqualsCore(ISymbol? x, ISymbol? y, Dictionary<INamedTypeSymbol, INa
154
146
=> GetEquivalenceVisitor ( ) . AreEquivalent ( x , y , equivalentTypesWithDifferingAssemblies ) ;
155
147
156
148
public int GetHashCode ( ISymbol ? x )
157
- => GetGetHashCodeVisitor ( compareMethodTypeParametersByIndex : false , objectAndDynamicCompareEqually : false ) . GetHashCode ( x , currentHash : 0 ) ;
149
+ => GetGetHashCodeVisitor ( compareMethodTypeParametersByIndex : false ) . GetHashCode ( x , currentHash : 0 ) ;
158
150
159
151
private static ISymbol UnwrapAlias ( ISymbol symbol )
160
152
=> symbol . IsKind ( SymbolKind . Alias , out IAliasSymbol ? alias ) ? alias . Target : symbol ;
0 commit comments