Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5372347

Browse files
committed
Enable model inheritence by subinterfaces
Previously only a concrete (non-interface) method could inherit such a model
1 parent 9c45192 commit 5372347

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

go/ql/lib/semmle/go/Scopes.qll

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,20 @@ class Method extends Function {
533533
* implement themselves.
534534
*/
535535
predicate implements(Method m) {
536+
if this.isInterfaceMethod() then this = m else implementsIncludingInterfaceMethods(m)
537+
}
538+
539+
/**
540+
* Holds if this method implements the method `m`, that is, if `m` is a method
541+
* on an interface, and this is a method with the same name on a type that
542+
* implements that interface.
543+
*
544+
* Note that all methods implement themselves, and that unlike the predicate `implements`
545+
* this does allow interface methods to implement other interfaces.
546+
*/
547+
predicate implementsIncludingInterfaceMethods(Method m) {
536548
this = m
537549
or
538-
not this.isInterfaceMethod() and
539550
exists(Type t |
540551
this = t.getMethod(m.getName()) and
541552
t.implements(m.getReceiverType().getUnderlyingType())

go/ql/lib/semmle/go/dataflow/ExternalFlow.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ SourceOrSinkElement interpretElement(
287287
exists(Method m | m.hasQualifiedName(interpretPackage(pkg), type, name) |
288288
result.asEntity() = m
289289
or
290-
subtypes = true and result.asEntity().(Method).implements(m)
290+
subtypes = true and result.asEntity().(Method).implementsIncludingInterfaceMethods(m)
291291
)
292292
or
293293
type = "" and

0 commit comments

Comments
 (0)