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;
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);
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.");
}
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;
}
}