import org.simantics.scl.compiler.internal.elaboration.constraints.ReducedConstraints;
import org.simantics.scl.compiler.internal.elaboration.subsumption.SubSolver;
import org.simantics.scl.compiler.internal.elaboration.subsumption.Subsumption;
+import org.simantics.scl.compiler.types.Skeletons;
import org.simantics.scl.compiler.types.TApply;
import org.simantics.scl.compiler.types.TCon;
import org.simantics.scl.compiler.types.TForAll;
if(a instanceof TMetaVar) {
TMetaVar aVar = (TMetaVar)a;
- if(b instanceof TMetaVar)
+ if(b instanceof TMetaVar) {
+ Skeletons.unifySkeletons(a, b);
subsumptions.add(new Subsumption(loc, a, b));
+ }
else {
if(b.contains(aVar))
throw new UnificationException(a, b);
else if(type instanceof TMetaVar) {
TMetaVar var = (TMetaVar)type;
TMetaVar newVar = Types.metaVar(var.getKind());
+ try {
+ newVar.setSkeletonRef(var);
+ } catch (UnificationException e) {
+ throw new InternalCompilerError(loc, e);
+ }
subsumptions.add(new Subsumption(loc, newVar, var));
return newVar;
}
else if(type instanceof TMetaVar) {
TMetaVar var = (TMetaVar)type;
TMetaVar newVar = Types.metaVar(var.getKind());
+ try {
+ newVar.setSkeletonRef(var);
+ } catch (UnificationException e) {
+ throw new InternalCompilerError(loc, e);
+ }
subsumptions.add(new Subsumption(loc, var, newVar));
return newVar;
}
Types.unify(sub.a, sub.b);
} catch (UnificationException e) {
// Should not happen. Both types should be metavars.
- throw new InternalCompilerError();
+ throw new InternalCompilerError(e);
}
subsumptions.clear();
return true;
public Expression solveConstraints(Environment environment, Expression expression) {
ArrayList<EVariable> constraintDemand = getConstraintDemand();
if(!constraintDemand.isEmpty()) {
- ConstraintEnvironment ce = new ConstraintEnvironment(environment);
+ ConstraintEnvironment ce = new ConstraintEnvironment(compilationContext);
ReducedConstraints red = ConstraintSolver.solve(
ce, new ArrayList<TPred>(0), constraintDemand,
true);