Use generics for DepSets

Use Go's generics for DepSets so they don't require a type-specific
wrapper and reflection.

Test: depsets_test.go
Change-Id: I22ba0b7d680d37d2cd05230b0f560d166c4dd20b
This commit is contained in:
Colin Cross
2022-04-21 12:50:51 -07:00
parent abcfc77717
commit c85750bfe3
26 changed files with 262 additions and 627 deletions

View File

@@ -282,23 +282,3 @@ func (p *PackagingBase) CopyDepsToZip(ctx ModuleContext, specs map[string]Packag
builder.Build("zip_deps", fmt.Sprintf("Zipping deps for %s", ctx.ModuleName()))
return entries
}
// packagingSpecsDepSet is a thin type-safe wrapper around the generic depSet. It always uses
// topological order.
type packagingSpecsDepSet struct {
depSet
}
// newPackagingSpecsDepSet returns an immutable packagingSpecsDepSet with the given direct and
// transitive contents.
func newPackagingSpecsDepSet(direct []PackagingSpec, transitive []*packagingSpecsDepSet) *packagingSpecsDepSet {
return &packagingSpecsDepSet{*newDepSet(TOPOLOGICAL, direct, transitive)}
}
// ToList returns the packagingSpecsDepSet flattened to a list in topological order.
func (d *packagingSpecsDepSet) ToList() []PackagingSpec {
if d == nil {
return nil
}
return d.depSet.ToList().([]PackagingSpec)
}