]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/deriving/ShowDeriver.java
Merged changes from feature/scl to master.
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / deriving / ShowDeriver.java
index e06a117e9cb20b4ecfc6ee03ed93a6f0a06eda09..afd2a4f8943dfe3d5aa711a611ac3a6827f7eae1 100644 (file)
@@ -10,7 +10,9 @@ import org.simantics.scl.compiler.elaboration.expressions.EApply;
 import org.simantics.scl.compiler.elaboration.expressions.ELiteral;
 import org.simantics.scl.compiler.elaboration.expressions.EVar;
 import org.simantics.scl.compiler.elaboration.expressions.Expression;
 import org.simantics.scl.compiler.elaboration.expressions.ELiteral;
 import org.simantics.scl.compiler.elaboration.expressions.EVar;
 import org.simantics.scl.compiler.elaboration.expressions.Expression;
+import org.simantics.scl.compiler.elaboration.modules.TypeAlias;
 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
 import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
+import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
 import org.simantics.scl.compiler.environment.AmbiguousNameException;
 import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.environment.Environments;
 import org.simantics.scl.compiler.environment.AmbiguousNameException;
 import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.environment.Environments;
@@ -46,7 +48,7 @@ class ShowDeriver implements InstanceDeriver {
         }
         TCon con;
         try {
         }
         TCon con;
         try {
-            con = Environments.getTypeConstructorName(environment, headType.name);
+            con = Environments.getTypeDescriptorName(environment, headType.name);
         } catch (AmbiguousNameException e1) {
             errorLog.log(headType.location, e1.getMessage());
             return;
         } catch (AmbiguousNameException e1) {
             errorLog.log(headType.location, e1.getMessage());
             return;
@@ -55,11 +57,16 @@ class ShowDeriver implements InstanceDeriver {
             errorLog.log(headType.location, "Couldn't resolve " + headType.name);
             return;
         }
             errorLog.log(headType.location, "Couldn't resolve " + headType.name);
             return;
         }
-        TypeConstructor tcon = environment.getTypeConstructor(con);
-        if(tcon == null) {
+        TypeDescriptor tdesc = environment.getTypeDescriptor(con);
+        if(tdesc == null) {
             errorLog.log(headType.location, "Didn't find type constructor for " + headType.name);
             return;
         }
             errorLog.log(headType.location, "Didn't find type constructor for " + headType.name);
             return;
         }
+        if(tdesc instanceof TypeAlias) {
+            errorLog.log(headType.location, "Cannot derive instance for a type alias.");
+            return;
+        }
+        TypeConstructor tcon = (TypeConstructor)tdesc;
         if(tcon.isOpen) {
             errorLog.log(headType.location, "Cannot derive instance for open data types.");
             return;
         if(tcon.isOpen) {
             errorLog.log(headType.location, "Cannot derive instance for open data types.");
             return;