From: Hannu Niemistö Date: Fri, 20 Jan 2017 17:36:29 +0000 (+0200) Subject: Ignore instance definitions for Eq and Hashable X-Git-Tag: v1.27.0~7 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=fa9b9d56a9a16226e6409724cedfbbe94463b301;p=simantics%2Fplatform.git Ignore instance definitions for Eq and Hashable refs #6996 Change-Id: Ieb342aff6cc68b75a259bb34fb62fb46b0bd2c75 --- 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