X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FEApply.java;h=7f50d730b9f0d536fc91f6dfa439f8ccebc43fcd;hp=5d915a98dce93b2ac88e2476effaed460e2d25ba;hb=e515d1fda563f0fa3b8b71f9099696cf49a06d25;hpb=11eb20e8c57df9fc846ff200112fafb4b8683a05 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java index 5d915a98d..7f50d730b 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java @@ -1,6 +1,7 @@ package org.simantics.scl.compiler.elaboration.expressions; import java.util.ArrayList; +import java.util.Arrays; import org.simantics.scl.compiler.common.names.Name; import org.simantics.scl.compiler.common.names.Names; @@ -28,7 +29,6 @@ import org.simantics.scl.compiler.types.TFun; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; -import org.simantics.scl.compiler.types.exceptions.UnificationException; import org.simantics.scl.compiler.types.kinds.Kinds; import org.simantics.scl.compiler.types.util.MultiFunction; @@ -220,14 +220,13 @@ public class EApply extends Expression { return new IApply(function.toIExpression(target), parametersI); } - private void inferType(TypingContext context, boolean ignoreResult) { + private Expression inferType(TypingContext context, boolean ignoreResult) { function = function.inferType(context); function = context.instantiate(function); - MultiFunction mfun; - try { - mfun = Types.unifyFunction(function.getType(), parameters.length); - } catch (UnificationException e) { - int arity = Types.getArity(function.getType()); + Type functionType = function.getType(); + + int arity = Types.getMaxArity(functionType); + if(arity < parameters.length) { if(arity == 0) context.getErrorLog().log(location, "Application of non-function."); else @@ -236,40 +235,50 @@ public class EApply extends Expression { setType(Types.metaVar(Kinds.STAR)); for(int i=0;i