Skip to content

Commit

Permalink
Avoid assign check when init expression is invalid.
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rkeulv committed Feb 4, 2024
1 parent aea8bd8 commit 564977a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static void check(
) {
final ResultHolder varType = HaxeTypeResolver.getTypeFromTypeTag(tag, erroredElement);
final ResultHolder initType = getTypeFromVarInit(initExpression, varType);
if (initType.isInvalid()) return;

if (!varType.canAssign(initType)) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,15 @@ private static boolean containsAllMembers(SpecificHaxeClassReference to, Specifi

if (to == null || from == null) return false;

List<HaxeMemberModel> toMembers = to.getHaxeClassModel().getAllMembers(to.getGenericResolver());
List<HaxeMemberModel> fromMembers = from.getHaxeClassModel().getAllMembers(to.getGenericResolver());
HaxeClassModel toClassModel = to.getHaxeClassModel();
HaxeClassModel fromClassModel = from.getHaxeClassModel();

// unable to determine, consider if we should return true or false in this case
if (toClassModel == null || fromClassModel == null)
return false;

List<HaxeMemberModel> toMembers = toClassModel.getAllMembers(to.getGenericResolver());
List<HaxeMemberModel> fromMembers = fromClassModel.getAllMembers(to.getGenericResolver());
for (HaxeMemberModel member : toMembers) {
String name = member.getName();
// TODO type check parameter and return type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,8 @@ public ResultHolder withOrigin(PsiElement origin) {
public PsiElement getOrigin() {
return origin;
}

public boolean isInvalid() {
return type.isInvalid();
}
}

0 comments on commit 564977a

Please sign in to comment.