Avoid creating TAnons from object declarations if we have an expected type #11474
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.
I saw in the hxb writer that we were dealing with hundreds of TAnons that should really be
haxe.PosInfos
. Anons are difficult to handle for a binary interface because we have to identify them properly, and doing so is not particularly pleasantA large portion of them come from object declaration typing against an expected type, which results in something like
[ObjectDecl:{ methodName : String, lineNumber : Int, fileName : String, className : String }]
in the typed AST. With this PR, it emits[ObjectDecl:haxe.PosInfos]
instead.This cuts the amount of generated anons in our unit tests roughly in half, from 1700 to 800. It's still a rather high number that I want to investigate, but I think some of it comes from macro reification not creating objects against an explicit type.
Right now this doesn't quite work yet on HL:
The dump diff looks like what I'd expect:
I don't know why genhl is offended by that because its
to_type
seems to be recursing upon typedefs, so I must be missing something else here.