]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Types.java
Merge "List the unsatisfied dependencies in CanvasContext"
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / types / Types.java
index 5e332742ab29debd7f8c3674c4b2ac38f993448f..b20ee9f121ba4890be21b58e53540de72b4a1a6a 100644 (file)
@@ -98,9 +98,7 @@ public class Types {
     public static final TCon ORDERED_RING = con("Prelude", "OrderedRing");
     public static final TCon REAL = con("Prelude", "Real");
     public static final TCon SHOW = con("Prelude", "Show");
-    public static final TCon EQ = con("Prelude", "Eq");
     public static final TCon ORD = con("Prelude", "Ord");
-    public static final TCon HASHABLE = con("Prelude", "Hashable");
     public static final TCon IO = con("Serialization", "IO");
 
     public static final Type REF = con("Prelude", "Ref");
@@ -154,11 +152,13 @@ public class Types {
      * Get the concrete type pointed to by a chain of type meta-variables.
      */
     public static Type canonical(Type type) {
-        while(type instanceof TMetaVar) {
+        if(type instanceof TMetaVar) {
             TMetaVar metaVar = (TMetaVar)type;
             type = metaVar.ref;
             if(type == null)
                 return metaVar;
+            else
+                return metaVar.ref = canonical(type);
         }
         return type;
     }
@@ -554,7 +554,15 @@ public class Types {
             parameters.add(Types.canonical(apply.parameter));
             type = canonical(apply.function);
         }
-        return new MultiApply(type, parameters.toArray(new Type[parameters.size()]));
+        Type[] parametersArray;
+        if(parameters.isEmpty())
+            parametersArray = Type.EMPTY_ARRAY;
+        else {
+            parametersArray = new Type[parameters.size()];
+            for(int i=0,j=parametersArray.length-1;i<parametersArray.length;++i,--j)
+                parametersArray[i] = parameters.get(j);
+        }
+        return new MultiApply(type, parametersArray);
     }
     
     public static Type unifyApply(TCon func, Type type) throws MatchException {
@@ -1024,6 +1032,10 @@ public class Types {
         else
             return new TUnion(effects);
     }
+    
+    public static Type union(Type effect1, Type effect2) {
+        return new TUnion(effect1, effect2);
+    }
 
     public static Type union(List<Type> effects) {
         if(effects.size() == 0)