[go1.21] Updated reflect, reflectlite, and abi#1417
Merged
grantnelson-wf merged 1 commit intogopherjs:go1.21from Mar 2, 2026
Merged
[go1.21] Updated reflect, reflectlite, and abi#1417grantnelson-wf merged 1 commit intogopherjs:go1.21from
grantnelson-wf merged 1 commit intogopherjs:go1.21from
Conversation
nevkontakte
approved these changes
Mar 2, 2026
Member
nevkontakte
left a comment
There was a problem hiding this comment.
I will be 100% honest and admit that I can't fully wrap my mind around these changes, and so I will put my trust into tests for validating correctness.
It does look reasonable to me from readability/maintainability perspective. The overlap between reflect and reflectlite has been bugging me and moving some commonalities out into internal/abi is nice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
There was a large refactor in
reflectandreflectlitethat moved a lot of the duplicate code out toabi. For example, they consolidated thereflect.nameandreflectlite.nameobject intoabi.Name. I updated the native overrides to adjust for these changes. I also removed anything inreflectlitethat was no longer needed.The main issues I ran into was that I didn't remember or wasn't aware of the
kindTypecasts. I added comments into the code to help devs with future updates. With many of the type methods moving toabi, there was a new type of object created, extensions on kind types, e.g.type structType { abi.StructType }, that needed another way to cast. The code now would cast between*rtype,*abi.Type,*abi.StructType, andreflect.structType. I added a function into reflect to handle this complication.toKindTypeExtwill perform the additional types of casting that couldn't be handled withkindType.kindTypeis still being used forreflectlite,abi, and most of thereflectcasts.I tried to minimize the diffs for this PR but with things moving around, it was difficult. Most of the stuff in
abiis very similar to what was inreflectandreflectliteexcept with exported identifier names. However, there were some notable changes:abi.Name, formerlyreflect.name, used to use a*byteto lookup name information in a map.NameOffuses an index to lookup a name in a slice of names. To keep from using a global map or slice, I changedabi.Nameto store the name information directly andNameOffto store a pointer to thatName.This does mean we'll need to update
TestLinknameReflectNamesince it was linking toreflect.nameusing a*byte, but since we have to do that anyway for the move toabi.Name, it has to be updated anyway. I left that test update for a later PR.TypeOffandTextOffhad similar updates toNameand I followed the same pattern as I used forName.reflect.Value.Clearis new to go1.21 so I implemented it as well.If #1416 is in merged into go1.21, then the
reflect,reflectlite, andabipackages should pass when tests are run on them. However, since go1.21 is an integration branch, it may be difficult to test and CI will continue to fail.Related to #1415