diff --git a/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeAssignExpressionAnnotator.java b/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeAssignExpressionAnnotator.java index 0a06b6931..fdfccc943 100644 --- a/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeAssignExpressionAnnotator.java +++ b/src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeAssignExpressionAnnotator.java @@ -42,7 +42,7 @@ public static void check(HaxeAssignExpression psi, AnnotationHolder holder) { HaxeGenericResolver rhsResolver = HaxeGenericResolverUtil.generateResolverFromScopeParents(rhs); ResultHolder lhsType = HaxeTypeResolver.getPsiElementType(lhs, psi, lhsResolver); - rhsResolver.add("", lhsType, ResolveSource.ASSIGN_TYPE); + rhsResolver.add("", lhsType.tryUnwrapNullType(), ResolveSource.ASSIGN_TYPE); // if class add type hinting for resolver if(lhsType.isClassType()){ SpecificHaxeClassReference type = lhsType.getClassType(); 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 cc4d19e82..78c7e7cd5 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 @@ -569,8 +569,12 @@ public static ResultHolder searchReferencesForType(final HaxeComponentName compo } else if (!possibleType.isUnknown() && !possibleType.isDynamic()) { //NOTE: don't use unify here (will break function type from usage) // we want to search only for more specific types (ex. EnumValue & SomeEnum) - boolean canAssign = lastValue.canAssign(possibleType); - if (canAssign) lastValue = possibleType; + if (lastValue.isEnumValueType() || lastValue.isFunctionType()) { + boolean canAssign = lastValue.canAssign(possibleType); + if (canAssign) lastValue = possibleType; + }else { + break; + } } } } diff --git a/src/main/java/com/intellij/plugins/haxe/model/type/HaxeExpressionEvaluatorHandlers.java b/src/main/java/com/intellij/plugins/haxe/model/type/HaxeExpressionEvaluatorHandlers.java index 4aef1c49e..5ac043b0f 100644 --- a/src/main/java/com/intellij/plugins/haxe/model/type/HaxeExpressionEvaluatorHandlers.java +++ b/src/main/java/com/intellij/plugins/haxe/model/type/HaxeExpressionEvaluatorHandlers.java @@ -1228,30 +1228,10 @@ static ResultHolder handleCallExpression( HaxeGenericResolver resolver, HaxeCallExpression callExpression) { HaxeExpression callExpressionRef = callExpression.getExpression(); - - HaxeGenericResolver localResolver = new HaxeGenericResolver(); + // generateResolverFromScopeParents - making sure we got typeParameters from arguments/parameters + HaxeGenericResolver localResolver = HaxeGenericResolverUtil.generateResolverFromScopeParents(callExpression); localResolver.addAll(resolver); - ResultHolder callie = tryGetCallieType(callExpression); - - if (callie != null && callie.getClassType() != null && callie.getClassType().isNullType()) { - callie = callie.getClassType().unwrapNullType().createHolder(); - } - // TODO should we resolve callie if callie is typeParam ? - - HaxeGenericResolver resolverForMethodDeclaringClass = new HaxeGenericResolver(); - if (callie != null && !callie.isUnknown() && !callie.isTypeParameter() ) { - if (callExpression.getExpression() instanceof HaxeReferenceExpression referenceExpression) { - PsiElement resolve = referenceExpression.resolve(); - if (resolve instanceof HaxeMethodDeclaration methodDeclaration) { - HaxeClassModel aClass = methodDeclaration.getModel().getDeclaringClass(); - SpecificHaxeClassReference type = callie.getClassType(); - if (type != null && type.getHaxeClass() != null) { - resolverForMethodDeclaringClass = createInheritedClassResolver(aClass.haxeClass, type.getHaxeClass(), resolverForMethodDeclaringClass); - localResolver.addAll(resolverForMethodDeclaringClass); - } - } - } - } + SpecificTypeReference functionType = handle(callExpressionRef, context, localResolver).getType(); boolean varIsMacroFunction = isCallExpressionToMacroMethod(callExpressionRef); boolean callIsFromMacroContext = isInMacroFunction(callExpressionRef);