Skip to content

Commit 654d970

Browse files
authored
Merge pull request github#17607 from owen-mc/go/add-comments-about-interface-methods-from-embedded-interfaces
Go: Add comments noting methods from embedded interfaces are already included
2 parents 7de1182 + ca68aaa commit 654d970

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

go/extractor/extractor.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,9 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
16181618
case *types.Interface:
16191619
kind = dbscheme.InterfaceType.Index()
16201620
for i := 0; i < tp.NumMethods(); i++ {
1621+
// Note that methods coming from embedded interfaces can be
1622+
// accessed through `Method(i)`, so there is no need to
1623+
// deal with them separately.
16211624
meth := tp.Method(i)
16221625

16231626
// Note that methods do not have a parent scope, so they are

go/ql/lib/semmle/go/Types.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,8 @@ class InterfaceType extends @interfacetype, CompositeType {
742742
/** Gets the type of method `name` of this interface type. */
743743
Type getMethodType(string name) {
744744
// Note that negative indices correspond to embedded interfaces and type
745-
// set literals.
745+
// set literals. Note also that methods coming from embedded interfaces
746+
// have already been included in `component_types`.
746747
exists(int i | i >= 0 | component_types(this, i, name, result))
747748
}
748749

0 commit comments

Comments
 (0)