|
26 | 26 | import com.intellij.openapi.progress.ProgressIndicatorProvider;
|
27 | 27 | import com.intellij.plugins.haxe.HaxeBundle;
|
28 | 28 | import com.intellij.plugins.haxe.ide.annotator.HaxeStandardAnnotation;
|
| 29 | +import com.intellij.plugins.haxe.ide.annotator.semantics.HaxeCallExpressionUtil; |
29 | 30 | import com.intellij.plugins.haxe.lang.lexer.HaxeTokenTypeSets;
|
30 | 31 | import com.intellij.plugins.haxe.lang.lexer.HaxeTokenTypes;
|
31 | 32 | import com.intellij.plugins.haxe.lang.psi.*;
|
@@ -350,30 +351,40 @@ static private ResultHolder _handle(final PsiElement element,
|
350 | 351 | HaxeMethod method = constructor.getMethod();
|
351 | 352 | HaxeMethodModel methodModel = method.getModel();
|
352 | 353 | if (methodModel.getGenericParams().isEmpty()) {
|
| 354 | + boolean changedTypeParameters = false; |
| 355 | + HaxeCallExpressionUtil.CallExpressionValidation validation = HaxeCallExpressionUtil.checkConstructor(expression); |
| 356 | + Map<Integer, Integer> toParameterIndex = validation.getArgumentToParameterIndex(); |
| 357 | + |
| 358 | + |
353 | 359 | List<HaxeExpression> arguments = expression.getExpressionList();
|
354 | 360 | List<HaxeParameterModel> parameters = methodModel.getParameters();
|
| 361 | + |
355 | 362 | if (!parameters.isEmpty()) {
|
356 |
| - for (HaxeParameterModel parameter : parameters) { |
| 363 | + |
| 364 | + for (Map.Entry<Integer, Integer> entry : toParameterIndex.entrySet()) { |
| 365 | + Integer argumentIndex = entry.getKey(); |
| 366 | + Integer parameterIndex = entry.getValue(); |
| 367 | + |
| 368 | + HaxeParameterModel parameter = parameters.get(parameterIndex); |
357 | 369 | if (parameter.getType().isTypeParameter()) {
|
358 | 370 | for (int i = 0; i < Math.min(specificNames.length, arguments.size()); i++) {
|
359 | 371 | if (specificNames[i].equals(parameter.getTypeTagPsi().getTypeOrAnonymous().getText())) {
|
360 | 372 | // 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
|
361 | 373 | @NotNull ResultHolder[] specifics = classReference.getSpecifics();
|
362 | 374 | if (specifics[i].isUnknown()) {
|
363 |
| - ResultHolder handle = handle(arguments.get(i), context, resolver); |
364 |
| - if (specifics[i].isUnknown()) { |
| 375 | + ResultHolder handle = handle(arguments.get(argumentIndex), context, resolver); |
| 376 | + if (!handle.isUnknown()) { |
| 377 | + changedTypeParameters = true; |
365 | 378 | specifics[i] = handle;
|
366 |
| - }else { |
367 |
| - ResultHolder unified = HaxeTypeUnifier.unify(handle, specifics[i]); |
368 |
| - specifics[i] = unified; |
369 | 379 | }
|
370 | 380 | }
|
371 | 381 | }
|
372 | 382 | }
|
373 | 383 | }
|
374 | 384 | }
|
375 | 385 | }
|
376 |
| - } |
| 386 | + if (changedTypeParameters) return typeHolder.duplicate(); |
| 387 | + } |
377 | 388 | }
|
378 | 389 | }
|
379 | 390 | }
|
|
0 commit comments