Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This does a few things to improve the results from
methods
, and clean up some internals:sig
andtvars
fields toMethod
. Although technically redundant, this makesMethod
more intuitive for describing a method definition.TypeMapEntry
in reflection, de-coupling the method cache representation from anything user-facing.Finally, we had a problem where
methods(f)
returned a full MethodTable (except sometimes!), butmethods(f, t)
returned an array ofMethod
s. Those types are printed differently, plus we are only able to show keyword arguments if we have access to theMethodTable
, due to how kwargs are implemented. We could always useMethodTable
, but it's not iterable and building one is a very non-trivial process just for showing a list of methods.To address this I added a
MethodSet
type, so we can return any subset of methods with a consistent interface and printing. This solves all of the problems, but I don't quite love it, so suggestions are welcome.This could be used in
methodswith
as well, except that it can return methods from multiple functions so it doesn't quite fit.Another option would be to return matches from a function's keyword arg sorter as well, so you'd get 2 entries in a returned array for each method with keyword args. The downside is that these are not really methods of the same function, and have non-obvious argument lists.