Skip to content

Commit

Permalink
Fixing commonSuperType and canBeAssignedTo methods for ReferenceType
Browse files Browse the repository at this point in the history
  • Loading branch information
VincenzoArceri committed Oct 19, 2023
1 parent ce0700b commit 26841f9
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ public ReferenceType(
@Override
public boolean canBeAssignedTo(
Type other) {
return other instanceof PointerType || other.isUntyped();
return other instanceof ReferenceType && getInnerType().canBeAssignedTo(other.asReferenceType().getInnerType()) || other.isUntyped();
}

@Override
public Type commonSupertype(
Type other) {
return equals(other) ? this : Untyped.INSTANCE;
if (equals(other))
return this;
else if (other instanceof ReferenceType)
return new ReferenceType(getInnerType().commonSupertype(other.asReferenceType().getInnerType()));

return Untyped.INSTANCE;
}

@Override
Expand Down

0 comments on commit 26841f9

Please sign in to comment.