Support super with instanceof

This commit is contained in:
Taus
2021-10-15 12:26:11 +00:00
committed by GitHub
parent 684600cc54
commit 5b261d88bb
3 changed files with 10 additions and 2 deletions

View File

@@ -754,6 +754,11 @@ class Class extends TClass, TypeDeclaration, ModuleDeclaration {
*/
TypeExpr getASuperType() { toQL(result) = cls.getExtends(_) }
/**
* Gets a type referenced in the `instanceof` part of the class declaration.
*/
TypeExpr getAnInstanceofType() { toQL(result) = cls.getInstanceof(_) }
/** Gets the type that this class is defined to be an alias of. */
TypeExpr getAliasType() { toQL(result) = cls.getChild(_).(QL::TypeAliasBody).getChild() }

View File

@@ -79,10 +79,11 @@ private module Cached {
)
or
// super calls
exists(Super sup, ClassType type |
exists(Super sup, ClassType type, Type supertype |
mc.getBase() = sup and
sup.getEnclosingPredicate().(ClassPredicate).getParent().getType() = type and
p = type.getASuperType().getClassPredicate(mc.getMemberName(), mc.getNumberOfArguments())
supertype in [type.getASuperType(), type.getAnInstanceofType()] and
p = supertype.getClassPredicate(mc.getMemberName(), mc.getNumberOfArguments())
)
}

View File

@@ -94,6 +94,8 @@ class ClassType extends Type, TClass {
override Type getASuperType() { result = decl.getASuperType().getResolvedType() }
Type getAnInstanceofType() { result = decl.getAnInstanceofType().getResolvedType() }
override Type getAnInternalSuperType() {
result.(ClassCharType).getClassType() = this
or