@@ -823,9 +823,15 @@ module InterProceduralPointsTo {
823823 /* A decorator and we don't understand it. Use the original, undecorated value */
824824 f .isDecoratorCall ( ) and returnValue = ObjectInternal:: unknown ( ) and
825825 PointsToInternal:: pointsTo ( f .getArg ( 0 ) , context , value , origin )
826+ or
827+ Types:: six_add_metaclass ( f , value , _) and
828+ PointsToInternal:: pointsTo ( f .getArg ( 0 ) , context , value , origin )
826829 )
827830 or
828831 Expressions:: typeCallPointsTo ( f , context , value , origin , _, _)
832+ or
833+ Types:: six_add_metaclass ( f , value , _) and
834+ PointsToInternal:: pointsTo ( f .getArg ( 0 ) , context , value , origin )
829835 }
830836
831837 /** Points-to for parameter. `def foo(param): ...`. */
@@ -1390,8 +1396,7 @@ module Expressions {
13901396 }
13911397
13921398 pragma [ nomagic]
1393- //private
1394- boolean isinstanceEvaluatesTo ( CallNode call , PointsToContext context , ControlFlowNode use , ObjectInternal val ) {
1399+ private boolean isinstanceEvaluatesTo ( CallNode call , PointsToContext context , ControlFlowNode use , ObjectInternal val ) {
13951400 exists ( ObjectInternal cls |
13961401 isinstance_call ( call , use , context , val , cls ) |
13971402 result = Types:: improperSubclass ( val .getClass ( ) , cls )
@@ -1637,9 +1642,9 @@ cached module Types {
16371642 n = count ( pycls .getABase ( ) ) and result = false
16381643 )
16391644 or
1640- hasDeclaredMetaclass ( cls ) = false and
16411645 exists ( ClassObjectInternal base |
16421646 base = getBase ( cls , n ) |
1647+ hasDeclaredMetaclass ( cls ) = false and
16431648 isOldStyle ( base ) and result = newStylePython2 ( cls , n + 1 )
16441649 or
16451650 isNewStyle ( base ) and result = true
@@ -1738,7 +1743,6 @@ cached module Types {
17381743 cls .( ImportTimeScope ) .entryEdge ( result .getAUse ( ) , _)
17391744 }
17401745
1741- /** INTERNAL -- Do not use */
17421746 cached predicate six_add_metaclass ( CallNode decorator_call , ClassObjectInternal decorated , ControlFlowNode metaclass ) {
17431747 exists ( CallNode decorator |
17441748 PointsToInternal:: pointsTo ( decorator_call .getArg ( 0 ) , _, decorated , _) and
@@ -1754,10 +1758,9 @@ cached module Types {
17541758 }
17551759
17561760 private ObjectInternal six_add_metaclass_function ( ) {
1757- exists ( Module six , FunctionExpr add_metaclass |
1758- add_metaclass .getInnerScope ( ) .getName ( ) = "add_metaclass" and
1759- add_metaclass .getScope ( ) = six and
1760- result .getOrigin ( ) = add_metaclass .getAFlowNode ( )
1761+ exists ( ModuleObjectInternal six |
1762+ six .getName ( ) = "six" and
1763+ six .attribute ( "add_metaclass" , result , _)
17611764 )
17621765 }
17631766
@@ -1812,7 +1815,7 @@ cached module Types {
18121815 or
18131816 reason = "Missing base " + missingBase ( cls )
18141817 or
1815- exists ( cls .( PythonClassObjectInternal ) . getScope ( ) . getMetaClass ( ) ) and not exists ( cls . getClass ( ) ) and reason = "Failed to infer metaclass"
1818+ not exists ( ObjectInternal meta | meta = cls .getClass ( ) and not meta = ObjectInternal :: unknownClass ( ) ) and reason = "Failed to infer metaclass"
18161819 or
18171820 exists ( int i , ObjectInternal base1 , ObjectInternal base2 |
18181821 base1 = getBase ( cls , i ) and
@@ -1831,7 +1834,7 @@ cached module Types {
18311834 private int missingBase ( ClassObjectInternal cls ) {
18321835 exists ( cls .( PythonClassObjectInternal ) .getScope ( ) .getBase ( result ) )
18331836 and
1834- not exists ( getBase ( cls , result ) ) or getBase ( cls , result ) = ObjectInternal:: unknownClass ( )
1837+ not exists ( ObjectInternal base | base = getBase ( cls , result ) and not base = ObjectInternal:: unknownClass ( ) )
18351838 }
18361839
18371840 private predicate duplicateBase ( ClassObjectInternal cls ) {
0 commit comments