@@ -1826,31 +1826,38 @@ cached module Types {
18261826
18271827 /* Holds if type inference failed to compute the full class hierarchy for this class for the reason given. */
18281828 cached predicate failedInference ( ClassObjectInternal cls , string reason ) {
1829- strictcount ( cls .( PythonClassObjectInternal ) .getScope ( ) .getADecorator ( ) ) > 1 and reason = "Multiple decorators"
1829+ exists ( int priority |
1830+ failedInference ( cls , reason , priority ) and
1831+ priority = max ( int p | failedInference ( cls , _, p ) )
1832+ )
1833+ }
1834+
1835+ /* Holds if type inference failed to compute the full class hierarchy for this class for the reason given. */
1836+ private predicate failedInference ( ClassObjectInternal cls , string reason , int priority ) {
1837+ strictcount ( cls .( PythonClassObjectInternal ) .getScope ( ) .getADecorator ( ) ) > 1 and reason = "Multiple decorators" and priority = 0
18301838 or
1831- exists ( cls .( PythonClassObjectInternal ) .getScope ( ) .getADecorator ( ) ) and not six_add_metaclass ( _, cls , _) and reason = "Decorator not understood"
1839+ exists ( cls .( PythonClassObjectInternal ) .getScope ( ) .getADecorator ( ) ) and not six_add_metaclass ( _, cls , _) and reason = "Decorator not understood" and priority = 1
18321840 or
1833- reason = "Missing base " + missingBase ( cls )
1841+ reason = "Missing base " + missingBase ( cls ) and priority = 6
18341842 or
1835- not exists ( ObjectInternal meta | meta = cls .getClass ( ) and not meta = ObjectInternal:: unknownClass ( ) ) and reason = "Failed to infer metaclass"
1843+ not exists ( ObjectInternal meta | meta = cls .getClass ( ) and not meta = ObjectInternal:: unknownClass ( ) ) and reason = "Failed to infer metaclass" and priority = 4
18361844 or
18371845 exists ( int i , ObjectInternal base1 , ObjectInternal base2 |
18381846 base1 = getBase ( cls , i ) and
18391847 base2 = getBase ( cls , i ) and
18401848 base1 != base2 and
18411849 reason = "Multiple bases at position " + i
1842- )
1850+ ) and priority = 6
18431851 or
1844- duplicateBase ( cls ) and reason = "Duplicate bases classes"
1852+ duplicateBase ( cls ) and reason = "Duplicate bases classes" and priority = 6
18451853 or
1846- not exists ( getMro ( cls ) ) and reason = "Failed to compute MRO" and not exists ( missingBase ( cls ) ) and not duplicateBase ( cls )
1854+ not exists ( getMro ( cls ) ) and reason = "Failed to compute MRO" and priority = 3
18471855 or
1848- exists ( int i | failedInference ( getBase ( cls , i ) , _) and reason = "Failed inference for base class at position " + i )
1856+ exists ( int i | failedInference ( getBase ( cls , i ) , _, _ ) and reason = "Failed inference for base class at position " + i ) and priority = 5
18491857 }
18501858
18511859 private int missingBase ( ClassObjectInternal cls ) {
1852- exists ( cls .( PythonClassObjectInternal ) .getScope ( ) .getBase ( result ) )
1853- and
1860+ exists ( cls .( PythonClassObjectInternal ) .getScope ( ) .getBase ( result ) ) and
18541861 not exists ( ObjectInternal base | base = getBase ( cls , result ) and not base = ObjectInternal:: unknownClass ( ) )
18551862 }
18561863
0 commit comments