Enable model inheritence by subinterfaces

Previously only a concrete (non-interface) method could inherit such a model
This commit is contained in:
Chris Smowton
2023-03-23 14:33:32 +00:00
parent 9c45192a4e
commit 53723479c8
2 changed files with 13 additions and 2 deletions

View File

@@ -533,9 +533,20 @@ class Method extends Function {
* implement themselves.
*/
predicate implements(Method m) {
if this.isInterfaceMethod() then this = m else implementsIncludingInterfaceMethods(m)
}
/**
* Holds if this method implements the method `m`, that is, if `m` is a method
* on an interface, and this is a method with the same name on a type that
* implements that interface.
*
* Note that all methods implement themselves, and that unlike the predicate `implements`
* this does allow interface methods to implement other interfaces.
*/
predicate implementsIncludingInterfaceMethods(Method m) {
this = m
or
not this.isInterfaceMethod() and
exists(Type t |
this = t.getMethod(m.getName()) and
t.implements(m.getReceiverType().getUnderlyingType())

View File

@@ -287,7 +287,7 @@ SourceOrSinkElement interpretElement(
exists(Method m | m.hasQualifiedName(interpretPackage(pkg), type, name) |
result.asEntity() = m
or
subtypes = true and result.asEntity().(Method).implements(m)
subtypes = true and result.asEntity().(Method).implementsIncludingInterfaceMethods(m)
)
or
type = "" and