X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fparsing%2Ftypes%2FTVarAst.java;h=cf5a7a862c45fa99a5cad9b5148a6ec586910585;hb=refs%2Fchanges%2F32%2F1732%2F1;hp=9633d8619daed76b35f66ccc75d7b36b5a416ea8;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TVarAst.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TVarAst.java index 9633d8619..cf5a7a862 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TVarAst.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/types/TVarAst.java @@ -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; @@ -10,6 +11,8 @@ import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.kinds.Kind; import org.simantics.scl.compiler.types.kinds.Kinds; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import gnu.trove.map.hash.TObjectIntHashMap; import gnu.trove.set.hash.TIntHashSet; @@ -19,7 +22,8 @@ import gnu.trove.set.hash.TIntHashSet; * This class represents an abstract syntax tree node for a type variable. * The only property of a type variable is its name. */ -public class TVarAst extends TypeAst { +public class TVarAst extends TypeAst { + private static final Logger LOGGER = LoggerFactory.getLogger(TVarAst.class); public final String name; public TVarAst(String name) { @@ -40,7 +44,7 @@ public class TVarAst extends TypeAst { for(int i=1;i 0) { context.getErrorLog().log(location, "The alias expects " + alias.getArity() + " parameters, but none are given."); @@ -71,16 +82,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; } } @@ -99,7 +101,7 @@ public class TVarAst extends TypeAst { if(name.charAt(i) != ',') { con = context.resolveTypeConstructor(name.substring(1, name.length()-1)); if(con == null) { - System.err.println("Didn't find type constructor " + name + "."); + LOGGER.warn("Didn't find type constructor " + name + "."); return Types.metaVar(Kinds.STAR); } break block; @@ -108,10 +110,12 @@ public class TVarAst extends TypeAst { } else if(Character.isLowerCase(c)) return context.resolveTypeVariable(name); + else if(c == '?') + return context.resolveExistential(name); else { con = context.resolveTypeConstructor(name); if(con == null) { - System.err.println("Didn't find type constructor " + name + "."); + LOGGER.warn("Didn't find type constructor " + name + "."); return Types.metaVar(Kinds.STAR); } } @@ -153,10 +157,12 @@ public class TVarAst extends TypeAst { char c = name.charAt(0); if(Character.isLowerCase(c)) return context.resolveTypeVariable(name); + else if(c == '?') + return context.resolveExistential(name); else { Type con = context.resolveTypeConstructor(name); if(con == null) { - System.err.println("Didn't find effect constructor " + name + "."); + LOGGER.warn("Didn't find effect constructor " + name + "."); return Types.metaVar(Kinds.EFFECT); } return con;