import generic functions from extracted Go code as interpreted code
This PR fixes issues like #1457 #1601 by importing the source code for generic functions in extracted Go code, so that it can be interpreted in yaegi.
You need to add a //yaegi:add comment directive to functions to so import, as importing all generic functions might not be desirable or feasible. In particular, given the need to interpret the generic code, it can not access any non-exported functions, types, or fields.
The extracted code is wrapped in a GenericFunc string type value as below:
err := i.Use(Exports{
"guthib.com/generic/generic": map[string]reflect.Value{
"Hello": reflect.ValueOf(GenericFunc("func Hello[T any](v T) { println(v) }")),
},
})
This PR builds on #1642 which interacts with this code in extracting the function source.
This and all the other PRs from me should now be good in terms of passing tests and working in our "real world" codebase which uses a lot of generics.
Excuse me, will this feature be merged into the main branch?
how about merging this one too -- then we can go back to using this official version instead of our fork :)