@@ -10,7 +10,6 @@ use std::ops::Deref;
1010use std:: sync:: Arc ;
1111
1212use dupe:: Dupe ;
13- use itertools:: Itertools ;
1413use pyrefly_python:: ast:: Ast ;
1514use pyrefly_python:: dunder;
1615use pyrefly_python:: short_identifier:: ShortIdentifier ;
@@ -75,7 +74,6 @@ use crate::binding::binding::FunctionParameter;
7574use crate :: binding:: binding:: FunctionStubOrImpl ;
7675use crate :: binding:: binding:: IsAsync ;
7776use crate :: binding:: binding:: Key ;
78- use crate :: binding:: binding:: KeyClassField ;
7977use crate :: binding:: binding:: KeyExport ;
8078use crate :: binding:: binding:: KeyLegacyTypeParam ;
8179use crate :: binding:: binding:: KeyUndecoratedFunction ;
@@ -1563,47 +1561,7 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
15631561 // If we are inheriting from multiple base types, we should
15641562 // check whether the multiple inheritance is consistent
15651563 if class_bases. as_ref ( ) . base_type_count ( ) > 1 {
1566- // Maps field from inherited class
1567- let mro = self . get_mro_for_class ( cls) ;
1568- let mut inherited_fields: SmallMap < & Name , Vec < ( & Name , Type ) > > = SmallMap :: new ( ) ;
1569-
1570- for parent_cls in mro. ancestors_no_object ( ) . iter ( ) {
1571- let class_fields = parent_cls. class_object ( ) . fields ( ) ;
1572- for field in class_fields {
1573- let key = KeyClassField ( parent_cls. class_object ( ) . index ( ) , field. clone ( ) ) ;
1574- let field_entry = self . get_from_class ( cls, & key) ;
1575- if let Some ( field_entry) = field_entry. as_ref ( ) {
1576- inherited_fields
1577- . entry ( field)
1578- . or_default ( )
1579- . push ( ( parent_cls. name ( ) , field_entry. ty ( ) ) ) ;
1580- }
1581- }
1582- }
1583-
1584- for ( field_name, class_and_types) in inherited_fields. iter ( ) {
1585- if class_and_types. len ( ) > 1 {
1586- let types: Vec < Type > =
1587- class_and_types. iter ( ) . map ( |( _, ty) | ty. clone ( ) ) . collect ( ) ;
1588- let intersect = self . intersects ( & types) ;
1589- if matches ! ( intersect, Type :: Never ( _) ) {
1590- let class_and_types_str = class_and_types
1591- . iter ( )
1592- . map ( |( cls, ty) | {
1593- format ! ( "`{}` from `{}`" , self . for_display( ty. clone( ) ) , cls)
1594- } )
1595- . join ( ", " ) ;
1596- self . error (
1597- errors,
1598- cls. range ( ) ,
1599- ErrorInfo :: Kind ( ErrorKind :: InconsistentOverload ) ,
1600- format ! (
1601- "Inconsistent types for field `{field_name}` inherited from multiple base classes: {class_and_types_str}" ,
1602- ) ,
1603- ) ;
1604- }
1605- }
1606- }
1564+ self . check_consistent_multiple_inheritance ( cls, errors) ;
16071565 }
16081566 }
16091567 Arc :: new ( EmptyAnswer )
0 commit comments