]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TVarAst.java
Merged changes from feature/scl to master.
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / parsing / types / TVarAst.java
index 9633d8619daed76b35f66ccc75d7b36b5a416ea8..e95b3ad9a9a4cdf21aab2abafa835b6457d013ad 100644 (file)
@@ -2,6 +2,7 @@ package org.simantics.scl.compiler.internal.parsing.types;
 
 import org.simantics.scl.compiler.elaboration.contexts.TypeTranslationContext;
 import org.simantics.scl.compiler.elaboration.modules.TypeAlias;
+import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
 import org.simantics.scl.compiler.environment.AmbiguousNameException;
 import org.simantics.scl.compiler.environment.Environments;
 import org.simantics.scl.compiler.internal.types.TypeElaborationContext;
@@ -40,7 +41,7 @@ public class TVarAst extends TypeAst {
                 for(int i=1;i<name.length()-1;++i)
                     if(name.charAt(i) != ',') {
                         try {
-                            con = Environments.getTypeConstructorName(context.getEnvironment(), name.substring(1, name.length()-1));
+                            con = Environments.getTypeDescriptorName(context.getEnvironment(), name.substring(1, name.length()-1));
                         } catch(AmbiguousNameException e) {
                             context.getErrorLog().log(location, e.getMessage());
                             return Types.metaVar(Kinds.STAR);
@@ -56,14 +57,19 @@ public class TVarAst extends TypeAst {
             else if(Character.isLowerCase(c))
                 return context.resolveTypeVariable(location, name, expectedKind);
             else {
-                TypeAlias alias;
+                TypeDescriptor tdesc;
                 try {
-                    alias = Environments.getTypeAlias(context.getEnvironment(), name);
-                } catch (AmbiguousNameException e1) {
-                    context.getErrorLog().log(location, e1.getMessage());
+                    tdesc = Environments.getTypeDescriptor(context.getEnvironment(), name);
+                } catch (AmbiguousNameException e) {
+                    context.getErrorLog().log(location, e.getMessage());
+                    return Types.metaVar(Kinds.STAR);
+                }
+                if(tdesc == null) {
+                    context.getErrorLog().log(location, "Didn't find type constructor " + name + ".");
                     return Types.metaVar(Kinds.STAR);
                 }
-                if(alias != null) {
+                if(tdesc instanceof TypeAlias) {
+                    TypeAlias alias = (TypeAlias)tdesc;
                     if(alias.getArity() > 0) {
                         context.getErrorLog().log(location, "The alias expects " +
                                 alias.getArity() + " parameters, but none are given.");
@@ -71,16 +77,7 @@ public class TVarAst extends TypeAst {
                     }
                     return alias.body;
                 }
-                try {
-                    con = Environments.getTypeConstructorName(context.getEnvironment(), name);
-                } catch(AmbiguousNameException e) {
-                    context.getErrorLog().log(location, e.getMessage());
-                    return Types.metaVar(Kinds.STAR);
-                }
-                if(con == null) {
-                    context.getErrorLog().log(location, "Didn't find type constructor " + name + ".");
-                    return Types.metaVar(Kinds.STAR);
-                }
+                con = tdesc.name;
             }
         }