Skip to content

Commit

Permalink
Try to fix subtype obligation for unions
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Oct 28, 2024
1 parent 3051cf0 commit 74a37f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ public SubTypeObligation(
source = ctxt.getSource(oneType(false, result, def.type.result, actualResult));
}

// NOTE! The atype parameter used to allow null to mean "any type", but this
// also caused problems sometimes with POs. Currently atype is not null...

private String oneType(boolean rec, POExpression exp, TCType etype, TCType atype)
{
if (atype != null && rec)
Expand All @@ -215,7 +218,7 @@ private String oneType(boolean rec, POExpression exp, TCType etype, TCType atype
return ""; // A sub comparison is OK without checks
}
}

StringBuilder sb = new StringBuilder();
String prefix = "";
etype = etype.deBracket();
Expand All @@ -237,7 +240,7 @@ private String oneType(boolean rec, POExpression exp, TCType etype, TCType atype

for (TCType poss: possibles)
{
String s = oneType(true, exp, poss, null);
String s = oneType(true, exp, poss, atype);

sb.append(prefix);
sb.append("(");
Expand Down Expand Up @@ -287,7 +290,7 @@ else if (etype instanceof TCNamedType)
}
else
{
atype = null;
// atype = null;
}

String s = oneType(true, exp, nt.type, atype);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ public void setOpaque(boolean opaque)
{
this.opaque = opaque;
}

/**
* Is this opaque from here?
*/
public boolean isOpaque(LexLocation from)
{
return opaque && !from.module.equals(location.module);
}

public void setInvariant(TCExplicitFunctionDefinition invdef)
{
Expand Down

0 comments on commit 74a37f4

Please sign in to comment.