]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7561) Allow extra parameters to the application of type alias 24/1124/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 18 Oct 2017 11:28:14 +0000 (14:28 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Wed, 18 Oct 2017 11:28:14 +0000 (14:28 +0300)
Change-Id: I02da6fe19a96d110bfcd43516c893fea40082cf1

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TApplyAst.java
bundles/org.simantics.scl.osgi/scl/Extras/HashMap.scl

index 3c77000757f67b96d56a2f4f6a5125888a4a8300..1aeba20713063dc70728bf443b907fdbb491b951 100644 (file)
@@ -49,15 +49,19 @@ public class TApplyAst extends TypeAst {
                 return Types.metaVar(Kinds.STAR);
             }
             if(alias != null) {
-                if(parameters.length != alias.getArity()) {
+                int arity = alias.getArity();
+                if(parameters.length < arity) {
                     context.getErrorLog().log(location, "Wrong number of parameters are given to the type alias. Expected " +
-                            alias.getArity() + " parameters, got " + parameters.length + " parameters.");
+                            arity + " parameters, got " + parameters.length + " parameters.");
                     return Types.metaVar(Kinds.metaVar());
                 }
-                Type[] parameterTypes = new Type[parameters.length];
-                for(int i=0;i<parameters.length;++i)
+                Type[] parameterTypes = new Type[arity];
+                for(int i=0;i<arity;++i)
                     parameterTypes[i] = parameters[i].toType(context, Kinds.metaVar());
-                return alias.body.replace(alias.parameters, parameterTypes);
+                Type result = alias.body.replace(alias.parameters, parameterTypes);
+                for(int i=arity;i<parameters.length;++i)
+                    result = Types.apply(result, parameters[i].toType(context, Kinds.metaVar()));
+                return result;
             }
         }
         
index 312f57c5465dfee82fb8f1003331045bd4d5a29f..76ab15c6c384d5f15197c506a70b6021dbcc9aa1 100644 (file)
@@ -4,7 +4,7 @@ module {
 
 import "MMap" as MMap
 
-type T a b = MMap.T a b
+type T = MMap.T
 
 create :: () -> <Proc> T a b
 create = MMap.create