From fa9b9d56a9a16226e6409724cedfbbe94463b301 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Hannu=20Niemist=C3=B6?= Date: Fri, 20 Jan 2017 19:36:29 +0200 Subject: [PATCH] Ignore instance definitions for Eq and Hashable refs #6996 Change-Id: Ieb342aff6cc68b75a259bb34fb62fb46b0bd2c75 --- .../compilation/DeclarationClassification.java | 12 ++++++++++++ .../compiler/tests/ModuleRegressionTests.java | 1 + .../compiler/tests/scl/SkipEqAndHashable.scl | 17 +++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/SkipEqAndHashable.scl diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/DeclarationClassification.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/DeclarationClassification.java index 6f82720c4..6c2befb5c 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/DeclarationClassification.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/compilation/DeclarationClassification.java @@ -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 importsAst = new ArrayList(); ArrayList dataTypesAst = new ArrayList(); ArrayList typeAliasesAst = new ArrayList(); @@ -236,6 +240,10 @@ public class DeclarationClassification { errorLog.log(declaration.location, "Annotations not supported."); currentAnnotations = new ArrayList(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(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); } diff --git a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java index df3576ff1..38506c6f4 100644 --- a/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/ModuleRegressionTests.java @@ -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 index 000000000..4abbf5bf7 --- /dev/null +++ b/tests/org.simantics.scl.compiler.tests/src/org/simantics/scl/compiler/tests/scl/SkipEqAndHashable.scl @@ -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 -- 2.47.1