X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FEApply.java;h=06ff05c18bf4aec3cb60325734daa382e2544a92;hb=ae3bfd23d4b7c6bd581ad1238e25bd4f513b2643;hp=02c7dff4585c95e0d55d7bf485266f90327b31e6;hpb=fe1a2f532761669e67da4db4ae15096ced8a04db;p=simantics%2Fplatform.git 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 02c7dff45..06ff05c18 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,56 @@ public class EApply extends Expression { setType(Types.metaVar(Kinds.STAR)); for(int i=0;i