]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/contexts/TypingContext.java
(refs #7498) Bugfixing implementation of skeleton refs
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / contexts / TypingContext.java
index ac004eab692a062e0777c0ebd1d8c3dab3329087..410ec0213fd5949720cc45dc13d924017bb86a19 100644 (file)
@@ -22,6 +22,7 @@ import org.simantics.scl.compiler.internal.elaboration.constraints.ExpressionAug
 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;
@@ -116,8 +117,10 @@ public class TypingContext {
         
         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);
@@ -182,6 +185,11 @@ public class TypingContext {
         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;
         }
@@ -232,6 +240,11 @@ public class TypingContext {
         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;
         }
@@ -372,7 +385,7 @@ public class TypingContext {
                 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;