47
47
import static com .oracle .graal .python .runtime .exception .PythonErrorType .TypeError ;
48
48
49
49
import java .util .Arrays ;
50
+ import java .util .Objects ;
50
51
51
52
import com .oracle .graal .python .PythonLanguage ;
52
53
import com .oracle .graal .python .builtins .Builtin ;
@@ -162,6 +163,25 @@ String[] getFieldsForRepr() {
162
163
assert k == inSequence ;
163
164
return fieldNamesForRepr ;
164
165
}
166
+
167
+ @ Override
168
+ public boolean equals (Object o ) {
169
+ if (this == o )
170
+ return true ;
171
+ if (!(o instanceof Descriptor ))
172
+ return false ;
173
+ Descriptor that = (Descriptor ) o ;
174
+ return inSequence == that .inSequence && allowInstances == that .allowInstances && Objects .equals (docString , that .docString ) && Arrays .equals (fieldNames , that .fieldNames ) &&
175
+ Arrays .equals (fieldDocStrings , that .fieldDocStrings );
176
+ }
177
+
178
+ @ Override
179
+ public int hashCode () {
180
+ int result = Objects .hash (docString , inSequence , allowInstances );
181
+ result = 31 * result + Arrays .hashCode (fieldNames );
182
+ result = 31 * result + Arrays .hashCode (fieldDocStrings );
183
+ return result ;
184
+ }
165
185
}
166
186
167
187
/**
@@ -181,6 +201,26 @@ public BuiltinTypeDescriptor(PythonBuiltinClassType type, String docString, int
181
201
public BuiltinTypeDescriptor (PythonBuiltinClassType type , String docString , int inSequence , String [] fieldNames , String [] fieldDocStrings ) {
182
202
this (type , docString , inSequence , fieldNames , fieldDocStrings , true );
183
203
}
204
+
205
+ @ Override
206
+ public boolean equals (Object o ) {
207
+ if (this == o ) {
208
+ return true ;
209
+ }
210
+ if (!(o instanceof BuiltinTypeDescriptor )) {
211
+ return false ;
212
+ }
213
+ if (!super .equals (o )) {
214
+ return false ;
215
+ }
216
+ BuiltinTypeDescriptor that = (BuiltinTypeDescriptor ) o ;
217
+ return type == that .type ;
218
+ }
219
+
220
+ @ Override
221
+ public int hashCode () {
222
+ return Objects .hash (super .hashCode (), type );
223
+ }
184
224
}
185
225
186
226
/**
0 commit comments