Skip to content

Commit

Permalink
Merge pull request #17607 from owen-mc/go/add-comments-about-interfac…
Browse files Browse the repository at this point in the history
…e-methods-from-embedded-interfaces

Go: Add comments noting methods from embedded interfaces are already included
  • Loading branch information
owen-mc authored Sep 28, 2024
2 parents 7de1182 + ca68aaa commit 654d970
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions go/extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,9 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
case *types.Interface:
kind = dbscheme.InterfaceType.Index()
for i := 0; i < tp.NumMethods(); i++ {
// Note that methods coming from embedded interfaces can be
// accessed through `Method(i)`, so there is no need to
// deal with them separately.
meth := tp.Method(i)

// Note that methods do not have a parent scope, so they are
Expand Down
3 changes: 2 additions & 1 deletion go/ql/lib/semmle/go/Types.qll
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,8 @@ class InterfaceType extends @interfacetype, CompositeType {
/** Gets the type of method `name` of this interface type. */
Type getMethodType(string name) {
// Note that negative indices correspond to embedded interfaces and type
// set literals.
// set literals. Note also that methods coming from embedded interfaces
// have already been included in `component_types`.
exists(int i | i >= 0 | component_types(this, i, name, result))
}

Expand Down

0 comments on commit 654d970

Please sign in to comment.