]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/contexts/TypingContext.java
New solver for SCL effects inequalities
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / contexts / TypingContext.java
index f862d2128c358999edc0a79c188c008fe348c0b5..68468076d32fa155d81d3e7c82371d33162eff97 100644 (file)
@@ -20,8 +20,8 @@ import org.simantics.scl.compiler.internal.elaboration.constraints.ConstraintEnv
 import org.simantics.scl.compiler.internal.elaboration.constraints.ConstraintSolver;
 import org.simantics.scl.compiler.internal.elaboration.constraints.ExpressionAugmentation;
 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.internal.elaboration.subsumption2.SubSolver2;
 import org.simantics.scl.compiler.types.Skeletons;
 import org.simantics.scl.compiler.types.TApply;
 import org.simantics.scl.compiler.types.TCon;
@@ -35,6 +35,7 @@ import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
 import org.simantics.scl.compiler.types.exceptions.UnificationException;
 import org.simantics.scl.compiler.types.kinds.Kinds;
+import org.simantics.scl.compiler.types.util.Polarity;
 import org.simantics.scl.compiler.types.util.TypeUnparsingContext;
 
 import gnu.trove.map.hash.THashMap;
@@ -406,8 +407,28 @@ public class TypingContext {
     }
     
     public void solveSubsumptions(long globalLoc) {
-        if(expandSubsumptions())
-            new SubSolver(compilationContext.errorLog, effectSubsumptions, potentialSingletonEffects, globalLoc).solve();
+        if(expandSubsumptions()) {
+            if(!effectSubsumptions.isEmpty())
+                SubSolver2.solve(compilationContext.errorLog, effectSubsumptions);
+            
+            if(!potentialSingletonEffects.isEmpty())
+                try {
+                    THashSet<TMetaVar> vars = new THashSet<TMetaVar>(4);
+                    for(Type type : potentialSingletonEffects)
+                        type.collectMetaVars(vars);
+                    for(TMetaVar var : vars) {
+                        if(var.getRef() == null) {
+                            Polarity polarity = var.getPolarity();
+                            if(!polarity.isNegative())
+
+                                var.setRef(Types.NO_EFFECTS);
+                        }
+                    }
+                } catch(UnificationException e) {
+                    throw new InternalCompilerError(e);
+                }
+            //new SubSolver(compilationContext.errorLog, effectSubsumptions, potentialSingletonEffects, globalLoc).solve();
+        }
     }
     
     public void declareEffect(long loc, Type effect) {