From 716a4274222e106fe76730ddeef3663ba20a2943 Mon Sep 17 00:00:00 2001 From: m0rkeulv Date: Fri, 9 Feb 2024 00:43:54 +0100 Subject: [PATCH] trying to fix resolver regression --- .../model/type/HaxeExpressionEvaluator.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/intellij/plugins/haxe/model/type/HaxeExpressionEvaluator.java b/src/main/java/com/intellij/plugins/haxe/model/type/HaxeExpressionEvaluator.java index 361f2de26..26bcd0eca 100644 --- a/src/main/java/com/intellij/plugins/haxe/model/type/HaxeExpressionEvaluator.java +++ b/src/main/java/com/intellij/plugins/haxe/model/type/HaxeExpressionEvaluator.java @@ -26,6 +26,7 @@ import com.intellij.openapi.progress.ProgressIndicatorProvider; import com.intellij.plugins.haxe.HaxeBundle; import com.intellij.plugins.haxe.ide.annotator.HaxeStandardAnnotation; +import com.intellij.plugins.haxe.ide.annotator.semantics.HaxeCallExpressionUtil; import com.intellij.plugins.haxe.lang.lexer.HaxeTokenTypeSets; import com.intellij.plugins.haxe.lang.lexer.HaxeTokenTypes; import com.intellij.plugins.haxe.lang.psi.*; @@ -350,22 +351,31 @@ static private ResultHolder _handle(final PsiElement element, HaxeMethod method = constructor.getMethod(); HaxeMethodModel methodModel = method.getModel(); if (methodModel.getGenericParams().isEmpty()) { + boolean changedTypeParameters = false; + HaxeCallExpressionUtil.CallExpressionValidation validation = HaxeCallExpressionUtil.checkConstructor(expression); + Map toParameterIndex = validation.getArgumentToParameterIndex(); + + List arguments = expression.getExpressionList(); List parameters = methodModel.getParameters(); + if (!parameters.isEmpty()) { - for (HaxeParameterModel parameter : parameters) { + + for (Map.Entry entry : toParameterIndex.entrySet()) { + Integer argumentIndex = entry.getKey(); + Integer parameterIndex = entry.getValue(); + + HaxeParameterModel parameter = parameters.get(parameterIndex); if (parameter.getType().isTypeParameter()) { for (int i = 0; i < Math.min(specificNames.length, arguments.size()); i++) { if (specificNames[i].equals(parameter.getTypeTagPsi().getTypeOrAnonymous().getText())) { // we could try to map parameters and args, but in most cases this probably won't be necessary and it would make this part very complex @NotNull ResultHolder[] specifics = classReference.getSpecifics(); if (specifics[i].isUnknown()) { - ResultHolder handle = handle(arguments.get(i), context, resolver); - if (specifics[i].isUnknown()) { + ResultHolder handle = handle(arguments.get(argumentIndex), context, resolver); + if (!handle.isUnknown()) { + changedTypeParameters = true; specifics[i] = handle; - }else { - ResultHolder unified = HaxeTypeUnifier.unify(handle, specifics[i]); - specifics[i] = unified; } } } @@ -373,7 +383,8 @@ static private ResultHolder _handle(final PsiElement element, } } } - } + if (changedTypeParameters) return typeHolder.duplicate(); + } } } }