Skip to content

Commit

Permalink
Merge branch 'ncb/development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
idhugoid committed Nov 10, 2020
2 parents ab7de77 + 656ece8 commit 9b20fd5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.overture.ast.patterns.APatternTypePair;
import org.overture.ast.patterns.PPattern;
import org.overture.ast.types.AFunctionType;
import org.overture.ast.types.ANamedInvariantType;
import org.overture.ast.types.PType;
import org.overture.ast.util.Utils;
import org.overture.config.Settings;
Expand Down Expand Up @@ -804,15 +805,23 @@ protected Value convertValueTo(PType to, Context ctxt, Set<PType> done)
List<PType> domain = tc.narrowest(type.getParameters(), restrictedType.getParameters());
PType range = tc.narrowest(type.getResult(), restrictedType.getResult());
AFunctionType newType = AstFactory.newAFunctionType(location, true, domain, range);

// Create a new function with the narrowest domain/range.
FunctionValue restricted = new FunctionValue(location, name,
newType, paramPatternList, body, precondition, postcondition,
freeVariables, checkInvariants, curriedArgs, measureName,
measureValues, result);

restricted.typeValues = typeValues;
return restricted;

if (to instanceof ANamedInvariantType)
{
return new InvariantValue((ANamedInvariantType)to, restricted, ctxt);
}
else
{
return restricted;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public List<PDefinition> caseARecordPattern(ARecordPattern pattern,

ARecordInvariantType pattype = af.createPTypeAssistant().getRecord(type, pattern.getLocation().getModule());

if (!af.createPTypeAssistant().isType(question.ptype, pattype.getClass()))
if (!af.getTypeComparator().compatible(pattype, question.ptype))
{
TypeCheckerErrors.report(3201, "Matching expression is not a compatible record type", pattern.getLocation(), pattern);
TypeCheckerErrors.detail2("Pattern type", type, "Expression type", question.ptype);
Expand Down

0 comments on commit 9b20fd5

Please sign in to comment.