Add comments noting methods from embedded interfaces are already included

This commit is contained in:
Owen Mansel-Chan
2024-09-27 15:03:09 +01:00
parent fdff209938
commit 796db77104
2 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -737,12 +737,17 @@ class TypeSetLiteralType extends @typesetliteraltype, CompositeType {
override string toString() { result = "type set literal type" }
}
predicate foo(NamedType t, string name, Type mt) {
t.getUnderlyingType().(InterfaceType).getMethodType(name) = mt
}
/** An interface type. */
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))
}