Python: Fix Builtin.isClass() and use in ClassObject. Also fix a couple of typos.

This commit is contained in:
Mark Shannon
2019-03-22 10:00:14 +00:00
parent 9d31d09f08
commit 57368921d2
3 changed files with 6 additions and 5 deletions

View File

@@ -40,6 +40,7 @@ class Builtin extends @py_cobject {
}
Builtin getBaseClass() {
/* The extractor uses the special name ".super." to indicate the super class of a builtin class */
py_cmembers_versioned(this, ".super.", result, major_version().toString())
}
@@ -54,7 +55,9 @@ class Builtin extends @py_cobject {
}
predicate isClass() {
py_cobjecttypes(_, this) or this = Builtin::unknownType()
py_cobjecttypes(_, this) or
this = Builtin::unknownType() or
exists(Builtin meta | meta.inheritsFromType() and py_cobjecttypes(this, meta))
}
predicate isFunction() {

View File

@@ -22,9 +22,7 @@ class ClassObject extends Object {
ClassObject() {
this.getOrigin() instanceof ClassExpr or
exists(Builtin o | o.getClass() = this.asBuiltin()) or
this.asBuiltin().getClass().inheritsFromType() or
this.asBuiltin() = Builtin::special("_semmle_unknown_type")
this.asBuiltin().isClass()
}
private predicate isStr() {

View File

@@ -37,7 +37,7 @@ class Object extends @py_object {
ClassObject getAnInferredType() {
exists(ControlFlowNode somewhere | somewhere.refersTo(this, result, _))
or
this.asBuiltin().getClass() = result.asBuiltin()and not this = unknownValue()
this.asBuiltin().getClass() = result.asBuiltin() and not this = unknownValue()
or
this = unknownValue() and result = theUnknownType()
}