Skip to content

Commit

Permalink
Prevent recursive type search loop for empty literal array.
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rkeulv committed Dec 31, 2023
1 parent c29771a commit 631ddea
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1051,10 +1051,15 @@ else if (subelement instanceof AbstractHaxeNamedComponent namedComponent) {

// try to resolve typeParameter when we got empty literal array with declaration without typeTag
if (elementTypeHolder.isUnknown()) {
HaxePsiField declaringField = PsiTreeUtil.getParentOfType(element, HaxePsiField.class);
if (declaringField != null) {
ResultHolder searchResult = searchReferencesForTypeParameters(declaringField, context, resolver, holder);
if (!searchResult.isUnknown()) holder = searchResult;
// note to avoid recursive loop we only do this check if its part of a varInit and not part of any expression,
// it would not make sense trying to look it up in a callExpression etc because then its type should be defined in the parameter list.
if (element.getParent() instanceof HaxeVarInit) {
HaxePsiField declaringField =
UsefulPsiTreeUtil.findParentOfTypeButStopIfTypeIs(element, HaxePsiField.class, HaxeCallExpression.class);
if (declaringField != null) {
ResultHolder searchResult = searchReferencesForTypeParameters(declaringField, context, resolver, holder);
if (!searchResult.isUnknown()) holder = searchResult;
}
}
}
return holder;
Expand Down

0 comments on commit 631ddea

Please sign in to comment.