Skip to content

Commit

Permalink
Fix incorrect handling of functionType and specializations + resolve …
Browse files Browse the repository at this point in the history
…argument type from init
  • Loading branch information
m0rkeulv committed Oct 30, 2023
1 parent e214a94 commit eb8cb0b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,9 @@ public static HaxeGenericSpecialization fromGenericResolver(@Nullable PsiElement
HaxeResolveResult resolved = HaxeResolveResult.create(clazz, fromGenericResolver(context, classType.getGenericResolver()));
specialization.put(element, name, resolved);
} else if (holder.getFunctionType() != null) {
SpecificFunctionReference type = holder.getFunctionType();
if (type.getElementContext() instanceof HaxeFunctionType functionType){
HaxeResolveResult resolved = HaxeResolveResult.create(functionType, fromGenericResolver(context, resolver));
//HaxeSpecificFunction function = new HaxeSpecificFunction(functionType, specialization);
//HaxeClassResolveResult resolved = HaxeClassResolveResult.create(function, fromGenericResolver(context, resolver));
if (context instanceof HaxeFunctionType functionType){
// functions currently do not have specialization
HaxeResolveResult resolved = HaxeResolveResult.create(functionType, new HaxeGenericSpecialization());
specialization.put(element, name, resolved);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ public HaxeClassModel getDeclaringClass() {
public ResultHolder getResultType() {
final HaxeTypeTag typeTag = getTypeTagPsi();
final HaxeTypeOrAnonymous type = typeTag != null ? typeTag.getTypeOrAnonymous() : null;
return type != null ? HaxeTypeResolver.getTypeFromTypeOrAnonymous(type) : null;
ResultHolder holder = type != null ? HaxeTypeResolver.getTypeFromTypeOrAnonymous(type) : null;
if (holder != null) return holder;

HaxeVarInit initPsi = getVarInitPsi();
if (initPsi == null) return SpecificHaxeClassReference.getUnknown(getParameterPsi()).createHolder();
return HaxeExpressionEvaluator.evaluate(initPsi, new HaxeExpressionEvaluatorContext(initPsi), null).result;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public static class Argument {
final private String name;
final private ResultHolder type;

public Argument(int index, boolean optional, ResultHolder type, @Nullable String name) {
public Argument(int index, boolean optional, @NotNull ResultHolder type, @Nullable String name) {
this.index = index;
this.optional = optional;
this.name = name;
Expand Down

0 comments on commit eb8cb0b

Please sign in to comment.