-
Notifications
You must be signed in to change notification settings - Fork 12
Description
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:
- register function types in a brand new package (which nothing depends on), or
- 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.