@@ -1856,9 +1856,13 @@ cached module Types {
18561856 result = getInheritedMetaclass ( cls , 0 )
18571857 or
18581858 // Best guess if base is not a known class
1859+ hasUnknownBase ( cls ) and result = ObjectInternal:: unknownClass ( )
1860+ }
1861+
1862+ /* Helper for getInheritedMetaclass */
1863+ private predicate hasUnknownBase ( ClassObjectInternal cls ) {
18591864 exists ( ObjectInternal base |
1860- base = getBase ( cls , _) and
1861- result = ObjectInternal:: unknownClass ( ) |
1865+ base = getBase ( cls , _) |
18621866 base .isClass ( ) = false
18631867 or
18641868 base = ObjectInternal:: unknownClass ( )
@@ -1868,14 +1872,18 @@ cached module Types {
18681872 private ClassObjectInternal getInheritedMetaclass ( ClassObjectInternal cls , int n ) {
18691873 exists ( Class c |
18701874 c = cls .( PythonClassObjectInternal ) .getScope ( ) and
1871- n = count ( c .getABase ( ) )
1875+ n = count ( c .getABase ( ) ) and n != 1
18721876 |
18731877 result = ObjectInternal:: type ( ) and major_version ( ) = 3
18741878 or
18751879 result = ObjectInternal:: classType ( ) and major_version ( ) = 2
18761880 )
18771881 or
1882+ base_count ( cls ) = 1 and n = 0 and
1883+ result = getBase ( cls , 0 ) .getClass ( )
1884+ or
18781885 exists ( ClassObjectInternal meta1 , ClassObjectInternal meta2 |
1886+ base_count ( cls ) > 1 and
18791887 meta1 = getBase ( cls , n ) .getClass ( ) and
18801888 meta2 = getInheritedMetaclass ( cls , n + 1 )
18811889 |
0 commit comments