Skip to content

Generic function instance types are registered in the origin package #153

@chriso

Description

@chriso

We use the x/tools/go/ssa package to instantiate generics for us. We collect generic functions and their instances here, and then register type information for the runtime here.

If a package in which a generic function is instantiated refers to the package in which the generic function was defined, and the instance has a parameter that refers to a package-local type, registering function types in the origin package will cause a circular import. There's a repro here.

We either need to:

  1. register function types in a brand new package (which nothing depends on), or
  2. we need to figure out a way to register the types of generic function instances in a/the package in which the instance was created/required.

I've been digging through the SSA package to see if there's a way to do (2), but have had no luck. The *ssa.Function of generic instances has a .Pkg == nil. There don't seem to be any methods or fields that would help us determine the package (or packages) in which the instance is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions