]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Ignore instance definitions for Eq and Hashable 84/284/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 20 Jan 2017 17:36:29 +0000 (19:36 +0200)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Fri, 20 Jan 2017 17:36:29 +0000 (19:36 +0200)
refs #6996

Change-Id: Ieb342aff6cc68b75a259bb34fb62fb46b0bd2c75

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/DeclarationClassification.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java
tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/SkipEqAndHashable.scl [new file with mode: 0644]

index 6f82720c4675b805f997e1976695571be3ad6951..6c2befb5cdb15c2e72d171cfbc88c0c3663b6972 100644 (file)
@@ -34,10 +34,14 @@ import org.simantics.scl.compiler.internal.parsing.translation.ProcessedDInstanc
 import org.simantics.scl.compiler.internal.parsing.translation.RelationRepository;
 import org.simantics.scl.compiler.internal.parsing.translation.ValueRepository;
 import org.simantics.scl.compiler.module.ImportDeclaration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.map.hash.THashMap;
 
 public class DeclarationClassification {
+    private static final Logger LOGGER = LoggerFactory.getLogger(DeclarationClassification.class);
+    
     ArrayList<ImportDeclaration> importsAst = new ArrayList<ImportDeclaration>();
     ArrayList<DDataAst> dataTypesAst = new ArrayList<DDataAst>();
     ArrayList<DTypeAst> typeAliasesAst = new ArrayList<DTypeAst>();
@@ -236,6 +240,10 @@ public class DeclarationClassification {
             errorLog.log(declaration.location, "Annotations not supported.");
             currentAnnotations = new ArrayList<DAnnotationAst>(2);
         }
+        if(declaration.name.name.equals("Eq") || declaration.name.name.equals("Hashable")) {
+            LOGGER.warn("Skipped instance definition for " + declaration.name + " for " + declaration.types[0]);
+            return;
+        }
         instancesAst.add(new ProcessedDInstanceAst(
                 declaration,
                 valueDefs));
@@ -246,6 +254,10 @@ public class DeclarationClassification {
             errorLog.log(declaration.location, "Annotations not supported.");
             currentAnnotations = new ArrayList<DAnnotationAst>(2);
         }
+        if(declaration.name.name.equals("Eq") || declaration.name.name.equals("Hashable")) {
+            LOGGER.warn("Skipped instance definition for " + declaration.name + " for " + declaration.types[0]);
+            return;
+        }
         derivingInstancesAst.add(declaration);
     }
 
index df3576ff11a4e6af5e3ee2b1912a6c8761f73ecb..38506c6f4997070d86d72ca1d3f2222cd707445c 100644 (file)
@@ -212,6 +212,7 @@ public class ModuleRegressionTests extends TestBase {
     @Test public void SharedTypeVariable() { test(); }
     @Test public void ShortcutFusion() { test(); }
     @Test public void Show1() { test(); }
+    @Test public void SkipEqAndHashable() { test(); }
     @Test public void SinConst1() { test(); }
     @Test public void Sort() { test(); }
     @Test public void Sort2() { test(); }
diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/SkipEqAndHashable.scl b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/SkipEqAndHashable.scl
new file mode 100644 (file)
index 0000000..4abbf5b
--- /dev/null
@@ -0,0 +1,17 @@
+import "Prelude"
+
+data Foo = Foo Integer
+
+deriving instance Eq Foo
+deriving instance Hashable Foo
+
+data Bar = Bar
+
+instance Eq Bar where
+    _ == _ = True
+instance Hashable Bar where
+    hash _ = 123 
+
+main = ()
+--
+()
\ No newline at end of file