Skip to content

Commit

Permalink
Bugfixes: allow logical operators for enumValues (to support pattern …
Browse files Browse the repository at this point in the history
…matching with EnumValue.match()) and fixing bug with canAssign for abstract enums
  • Loading branch information
m0rkeulv committed Jul 15, 2024
1 parent 5805cf2 commit c03a406
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ static public SpecificTypeReference getBinaryOperatorResult(
if (operator.equals("/")) result = SpecificHaxeClassReference.getFloat( elementContext);
}

// avoid marking Enum Patterns as errors (EnumValue.match accepts these inputs)
boolean bothAreEnumValues = left.isEnumValue() && right.isEnumValue();
if (bothAreEnumValues && (operator.equals("&") || operator.equals("|"))) {
return SpecificHaxeClassReference.getDynamic(elementContext);
}

if (canAssignLeftToInt && canAssignRightToInt) {
if (operator.equals("<<")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ static public boolean canAssignToFrom(
PsiElement commonParent = PsiTreeUtil.findCommonParent(reference.context, haxeClass);
if (commonParent == haxeClass) {
SpecificTypeReference underlyingType = haxeClass.getModel().getUnderlyingType();
return canAssignToFrom(underlyingType, from);
boolean canAssignToUnderlying = canAssignToFrom(underlyingType, from);
// we only return true when allowed, we continue checks below if not as the assign might be Enum to Enum (and not underlying to enum)
if (canAssignToUnderlying) return true;
}
}
}
Expand Down

0 comments on commit c03a406

Please sign in to comment.