Support generic types in crystal tool hierarchy
#13715
Merged
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.
Right now, the hierarchy tool does not support generic types, in that it simply prints those types' instance variables themselves again instead of their types and sizes:
This PR adds support for those members by ensuring that the byte sizes are queried only when they are independent of any unbound type parameters, most notably instances of
Pointer
andProc
:In this case, all of
Array
andSlice
's members have constant sizes, so their total sizes are also shown.When used as an instance variable,
Array
has a fixed size regardless of its members, becauseArray
is a reference:For structs, an example of a constant-size generic type being used generically is
Set
:Here
Iterator::UniqIterator
does not have a constant size because@iterator
's size can change depending onI
.