diff --git a/src/main/java/com/intellij/plugins/haxe/lang/psi/HaxeResolver.java b/src/main/java/com/intellij/plugins/haxe/lang/psi/HaxeResolver.java index 5941fb8a8..88e5363c0 100644 --- a/src/main/java/com/intellij/plugins/haxe/lang/psi/HaxeResolver.java +++ b/src/main/java/com/intellij/plugins/haxe/lang/psi/HaxeResolver.java @@ -375,7 +375,7 @@ else if (expression instanceof HaxeExtractorMatchExpression matchExpression) { } /* - HaxeExtractorMatchExpression can be chained so we need to loop until we get a refrence + HaxeExtractorMatchExpression can be chained so we need to loop until we get a reference ex. case add(_, 1) => mul(_1, 3) => a: */ private HaxeReferenceExpression getReferenceFromExtractorMatchExpression(HaxeExtractorMatchExpression expression) { 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 c1d431010..4bc39d4da 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 @@ -307,7 +307,7 @@ static private ResultHolder _handle(final PsiElement element, HaxePsiField fieldDeclaration = PsiTreeUtil.getParentOfType(expression, HaxePsiField.class); if (fieldDeclaration != null && fieldDeclaration.getTypeTag() == null) { SpecificHaxeClassReference classType = typeHolder.getClassType(); - // if class does not have any generics there no need to search for refrences + // if class does not have any generics there no need to search for references if (classType != null && classType.getSpecifics().length > 0) { ResultHolder searchResult = searchReferencesForTypeParameters(fieldDeclaration, context, resolver, typeHolder); if (!searchResult.isUnknown()) { @@ -987,6 +987,16 @@ else if (subelement instanceof AbstractHaxeNamedComponent namedComponent) { SpecificTypeReference result = SpecificHaxeClassReference.createArray(elementTypeHolder, element); if (allConstants) result = result.withConstantValue(constants); ResultHolder holder = result.createHolder(); + + // 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; + } + } + return holder; } diff --git a/src/main/java/com/intellij/plugins/haxe/model/type/HaxeTypeCompatible.java b/src/main/java/com/intellij/plugins/haxe/model/type/HaxeTypeCompatible.java index 396a4459c..ae7c45812 100644 --- a/src/main/java/com/intellij/plugins/haxe/model/type/HaxeTypeCompatible.java +++ b/src/main/java/com/intellij/plugins/haxe/model/type/HaxeTypeCompatible.java @@ -53,22 +53,6 @@ else if (from.isUnknown()) { return canAssignToFrom(to.getType(), from.getType(), true, to.getOrigin(), from.getOrigin()); } - //TODO mlo, hack to allow macro expressions to assign to anything - // thoughts: ExprOf might be mapped to T when only one part of the assignment is macro - private static boolean isMacroExpression(ResultHolder from) { - SpecificHaxeClassReference type = from.getClassType(); - if (type != null && type.getHaxeClass() != null) { - String qualifiedName = type.getHaxeClass().getQualifiedName(); - return switch (qualifiedName) { - case "haxe.macro.Expr" -> true; - case "haxe.macro.ExprOf" -> true; - default -> false; - }; - } - return false; - } - - static private boolean isFunctionTypeOrReference(SpecificTypeReference ref) { return ref instanceof SpecificFunctionReference