Skip to content

Commit

Permalink
Allow partial function assignment to total function, with subtype PO
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Apr 11, 2022
1 parent ba32646 commit fefa1b3
Showing 1 changed file with 11 additions and 6 deletions.
Expand Up @@ -232,7 +232,7 @@ private Result searchCompatible(PType to, PType from, boolean paramOnly)
}

// The pair.result is "Maybe" until this call returns.
pair.result = test(to, from, paramOnly);
pair.result = comptest(to, from, paramOnly);

return pair.result;
}
Expand All @@ -257,7 +257,7 @@ private Result searchCompatible(PType to, PType from, boolean paramOnly)
* @return Yes or No.
*/

private Result test(PType to, PType from, boolean paramOnly)
private Result comptest(PType to, PType from, boolean paramOnly)
{
if (to instanceof AUnresolvedType)
{
Expand Down Expand Up @@ -487,10 +487,10 @@ && searchCompatible(ma.getTo(), mb.getTo(), paramOnly) == Result.Yes ? Result.Ye
AFunctionType fa = (AFunctionType) to;
AFunctionType fb = (AFunctionType) from;

if (fb.getPartial() && !fa.getPartial())
{
return Result.No;
}
// if (fb.getPartial() && !fa.getPartial())
// {
// return Result.No;
// }

return allCompatible(fa.getParameters(), fb.getParameters(), paramOnly) == Result.Yes
&& (paramOnly || searchCompatible(fa.getResult(), fb.getResult(), paramOnly) == Result.Yes) ? Result.Yes
Expand Down Expand Up @@ -946,6 +946,11 @@ && searchSubType(subm.getTo(), supm.getTo(), invignore) == Result.Yes)
AFunctionType subf = (AFunctionType) sub;
AFunctionType supf = (AFunctionType) sup;

if (subf.getPartial() && !supf.getPartial())
{
return Result.No;
}

return allSubTypes(subf.getParameters(), supf.getParameters(), invignore) == Result.Yes
&& searchSubType(subf.getResult(), supf.getResult(), invignore) == Result.Yes ? Result.Yes
: Result.No;
Expand Down

0 comments on commit fefa1b3

Please sign in to comment.