167167import com .oracle .graal .python .builtins .objects .cext .structs .CFields ;
168168import com .oracle .graal .python .builtins .objects .cext .structs .CStructAccess .ReadPointerNode ;
169169import com .oracle .graal .python .builtins .objects .cext .structs .CStructAccess .WritePointerNode ;
170- import com .oracle .graal .python .builtins .objects .common .HashingStorageNodes .HashingStorageGetItem ;
171170import com .oracle .graal .python .builtins .objects .dict .PDict ;
172171import com .oracle .graal .python .builtins .objects .function .PBuiltinFunction ;
173172import com .oracle .graal .python .builtins .objects .method .PBuiltinMethod ;
@@ -1435,12 +1434,12 @@ private static void toNative(Object prtToWrite, TpSlotMeta def, Object slotNativ
14351434
14361435 @ TruffleBoundary
14371436 public static void inherit (PythonClass klass , PDict namespace , MroSequenceStorage mro , boolean allocateAllGroups ) {
1438- Builder klassSlots = buildInherited (klass , null , mro , allocateAllGroups );
1437+ Builder klassSlots = buildInherited (klass , mro , allocateAllGroups );
14391438 klass .setTpSlots (klassSlots .build ());
14401439 }
14411440
14421441 @ TruffleBoundary
1443- public static TpSlots .Builder buildInherited (PythonClass klass , PDict namespace , MroSequenceStorage mro , boolean allocateAllGroups ) {
1442+ public static TpSlots .Builder buildInherited (PythonClass klass , MroSequenceStorage mro , boolean allocateAllGroups ) {
14441443 // partially implements CPython:type_ready_inherit
14451444 // slots of native classes are initialized in GraalPyPrivate_AddInheritedSlots, they are
14461445 // just a mirror of the native slots initialized and inherited on the native side
@@ -1458,7 +1457,7 @@ public static TpSlots.Builder buildInherited(PythonClass klass, PDict namespace,
14581457 TpSlots slots = GetTpSlotsNode .executeUncached (type );
14591458 assert slots != null || type == klass ;
14601459 if (slots != null ) {
1461- klassSlots .inherit (klass , namespace , slots );
1460+ klassSlots .inherit (klass , slots );
14621461 }
14631462 }
14641463 return klassSlots ;
@@ -1814,7 +1813,7 @@ public Builder overrideIgnoreGroups(TpSlots other) {
18141813 return this ;
18151814 }
18161815
1817- private Builder inherit (PythonClass klass , PDict namespace , TpSlots base ) {
1816+ private Builder inherit (PythonClass klass , TpSlots base ) {
18181817 // similar to CPython:inherit_slots
18191818 // indirect slots (from tp_as_number etc.) are not inherited if the group is not
18201819 // allocated explicitly. Note: native heap types and managed types have always all
@@ -1843,22 +1842,19 @@ private Builder inherit(PythonClass klass, PDict namespace, TpSlots base) {
18431842 set (TpSlotMeta .TP_SETATTRO , base .tp_setattro ());
18441843 }
18451844 if (get (TpSlotMeta .TP_RICHCOMPARE ) == null && get (TpSlotMeta .TP_HASH ) == null ) {
1846- if (!overridesHash (namespace )) {
1845+ if (!overridesHash (klass )) {
18471846 set (TpSlotMeta .TP_RICHCOMPARE , base .tp_richcmp ());
18481847 set (TpSlotMeta .TP_HASH , base .tp_hash ());
18491848 }
18501849 }
18511850 return this ;
18521851 }
18531852
1854- private static boolean overridesHash (PDict namespace ) {
1855- if (namespace == null ) {
1856- return false ;
1857- }
1858- Object eq = HashingStorageGetItem .executeUncached (namespace .getDictStorage (), T___EQ__ );
1859- if (eq == null ) {
1860- Object hash = HashingStorageGetItem .executeUncached (namespace .getDictStorage (), T___HASH__ );
1861- return hash != null ;
1853+ private static boolean overridesHash (PythonClass klass ) {
1854+ Object eq = klass .getAttribute (T___EQ__ );
1855+ if (eq == PNone .NO_VALUE ) {
1856+ Object hash = klass .getAttribute (T___HASH__ );
1857+ return hash != PNone .NO_VALUE ;
18621858 }
18631859 return true ;
18641860 }
0 commit comments