Skip to content

Commit f1cd356

Browse files
committed
Merge branch 'ncb/development' into development
2 parents 8fdfa29 + 656ece8 commit f1cd356

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

core/interpreter/src/main/java/org/overture/interpreter/values/FunctionValue.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.overture.ast.patterns.APatternTypePair;
5151
import org.overture.ast.patterns.PPattern;
5252
import org.overture.ast.types.AFunctionType;
53+
import org.overture.ast.types.ANamedInvariantType;
5354
import org.overture.ast.types.PType;
5455
import org.overture.ast.util.Utils;
5556
import org.overture.config.Settings;
@@ -804,15 +805,23 @@ protected Value convertValueTo(PType to, Context ctxt, Set<PType> done)
804805
List<PType> domain = tc.narrowest(type.getParameters(), restrictedType.getParameters());
805806
PType range = tc.narrowest(type.getResult(), restrictedType.getResult());
806807
AFunctionType newType = AstFactory.newAFunctionType(location, true, domain, range);
807-
808+
808809
// Create a new function with the narrowest domain/range.
809810
FunctionValue restricted = new FunctionValue(location, name,
810811
newType, paramPatternList, body, precondition, postcondition,
811812
freeVariables, checkInvariants, curriedArgs, measureName,
812813
measureValues, result);
813814

814815
restricted.typeValues = typeValues;
815-
return restricted;
816+
817+
if (to instanceof ANamedInvariantType)
818+
{
819+
return new InvariantValue((ANamedInvariantType)to, restricted, ctxt);
820+
}
821+
else
822+
{
823+
return restricted;
824+
}
816825
}
817826
}
818827
}

core/typechecker/src/main/java/org/overture/typechecker/utilities/pattern/AllDefinitionLocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public List<PDefinition> caseARecordPattern(ARecordPattern pattern,
200200

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

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

0 commit comments

Comments
 (0)