fix: Fix dropping diamonds on constructor calls #3362
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.
Fix #3360
This is an attempt to fix the problem discussed in #3360
What I do here is essentially to try to recover the type arguments from the
AllocationExpression
's expected type. To the best of my knowledge, empty diamonds are only allowed on constructor calls, so I only have an assert that the stack's top element is anAllocationExpression
. It shouldn't be possible for it to be anything else.If the constructor call occurs inside of an unresolved method, or another constructor call, then the
AllocationExpression
doesn't have an expected type (because it can't be resolved). In that case, I add the newOMITTED_TYPE_ARG_TYPE
(name could use some work) to the type argument list so at least Spoon can detect that the constructor is in fact parameterized, and will then print<>
.This appears to work as intended, but I'll be running some more tests locally with my merge tool to see if other issues crop up.