diff --git a/backend/schema/module.go b/backend/schema/module.go index 85bc6dfc81..571102afc8 100644 --- a/backend/schema/module.go +++ b/backend/schema/module.go @@ -149,6 +149,14 @@ func (m *Module) Imports() []string { if n.Module != "" && n.Module != m.Name { imports[n.Module] = true } + // add imports for type parameters DataRefs as well + for _, p := range n.TypeParameters { + if p, ok := p.(*DataRef); ok { + if p.Module != "" && p.Module != m.Name { + imports[p.Module] = true + } + } + } case *VerbRef: if n.Module != "" && n.Module != m.Name { diff --git a/backend/schema/schema_test.go b/backend/schema/schema_test.go index 3bbfdd9d50..35d7b5f60f 100644 --- a/backend/schema/schema_test.go +++ b/backend/schema/schema_test.go @@ -55,15 +55,19 @@ func normaliseString(s string) string { func TestImports(t *testing.T) { input := ` module test { + data Generic { + value T + } data Data { ref other.Data ref another.Data + ref Generic } } ` schema, err := ParseModuleString("", input) assert.NoError(t, err) - assert.Equal(t, []string{"another", "other"}, schema.Imports()) + assert.Equal(t, []string{"another", "new", "other"}, schema.Imports()) } func TestVisit(t *testing.T) {