diff --git a/.gitignore b/.gitignore index edb3238b8e..6b91caceb4 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ /.h2Start.sh.swp **/.DS_Store +**/pure-duckDB-test-Db diff --git a/legend-pure-core/legend-pure-m3-core/src/main/antlr4/org/finos/legend/pure/m3/serialization/grammar/m3parser/antlr/core/M3CoreParser.g4 b/legend-pure-core/legend-pure-m3-core/src/main/antlr4/org/finos/legend/pure/m3/serialization/grammar/m3parser/antlr/core/M3CoreParser.g4 index b9ebb161d5..07cbb76c18 100644 --- a/legend-pure-core/legend-pure-m3-core/src/main/antlr4/org/finos/legend/pure/m3/serialization/grammar/m3parser/antlr/core/M3CoreParser.g4 +++ b/legend-pure-core/legend-pure-m3-core/src/main/antlr4/org/finos/legend/pure/m3/serialization/grammar/m3parser/antlr/core/M3CoreParser.g4 @@ -363,8 +363,8 @@ buildMilestoningVariableExpression: LATEST_DATE | DATE | variable expressionInstance: NEW_SYMBOL (variable | qualifiedName) - (typeVariableValues)? (LESSTHAN typeArguments? (PIPE multiplicityArguments)? GREATERTHAN)? (identifier)? + (typeVariableValues)? GROUP_OPEN expressionInstanceParserPropertyAssignment? (COMMA expressionInstanceParserPropertyAssignment)* GROUP_CLOSE @@ -461,7 +461,7 @@ booleanPart: AND expression functionVariableExpression: identifier COLON type multiplicity ; -type: ( qualifiedName typeVariableValues? (LESSTHAN (typeArguments? (PIPE multiplicityArguments)?) GREATERTHAN)? ) +type: ( qualifiedName (LESSTHAN (typeArguments? (PIPE multiplicityArguments)?) GREATERTHAN)?) typeVariableValues? | ( CURLY_BRACKET_OPEN diff --git a/legend-pure-core/legend-pure-m3-core/src/main/java/org/finos/legend/pure/m3/navigation/_class/_Class.java b/legend-pure-core/legend-pure-m3-core/src/main/java/org/finos/legend/pure/m3/navigation/_class/_Class.java index e26cc2ac53..4f4c61f88e 100644 --- a/legend-pure-core/legend-pure-m3-core/src/main/java/org/finos/legend/pure/m3/navigation/_class/_Class.java +++ b/legend-pure-core/legend-pure-m3-core/src/main/java/org/finos/legend/pure/m3/navigation/_class/_Class.java @@ -131,8 +131,10 @@ public static T print(T appendable, CoreInstance cls, boo { ListIterable typeParameters = cls.getValueForMetaPropertyToMany(M3Properties.typeParameters); ListIterable multiplicityParameters = cls.getValueForMetaPropertyToMany(M3Properties.multiplicityParameters); + ListIterable typeVariables = cls.getValueForMetaPropertyToMany(M3Properties.typeVariables); boolean hasTypeParams = typeParameters.notEmpty(); boolean hasMultParams = multiplicityParameters.notEmpty(); + boolean hasTypeVariables = typeVariables.notEmpty(); SafeAppendable safeAppendable = SafeAppendable.wrap(appendable); if (fullPaths) @@ -181,6 +183,12 @@ public static T print(T appendable, CoreInstance cls, boo } safeAppendable.append('>'); } + if (hasTypeVariables) + { + safeAppendable.append("("); + safeAppendable.append(typeVariables.collect(x -> x.getValueForMetaPropertyToOne("name").getName() + ":" + x.getValueForMetaPropertyToOne(M3Properties.genericType).getValueForMetaPropertyToOne(M3Properties.rawType).getValueForMetaPropertyToOne(M3Properties.name).getName()).makeString(",")); + safeAppendable.append(")"); + } return appendable; } diff --git a/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/grammar/v1/TestM3AntlrParser.java b/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/grammar/v1/TestM3AntlrParser.java index 3158ddc900..acdafeddc1 100644 --- a/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/grammar/v1/TestM3AntlrParser.java +++ b/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/serialization/grammar/v1/TestM3AntlrParser.java @@ -206,13 +206,13 @@ public void testClassVariable() " ret(){$x} :Integer[1];" + " values : U[1];" + "}" + - "Class meta::pure::metamodel::path::test::ListStringMax200 extends List(200)\n" + + "Class meta::pure::metamodel::path::test::ListStringMax200 extends List(200)\n" + "{\n" + "}" + "" + "function meta::pure::metamodel::path::test::testFunc():Boolean[1]" + "{" + - " ^List(200)(values = [1,2,3]);" + + " ^List(200)(values = [1,2,3]);" + " true;" + "}"; new M3AntlrParser(null).parse(code, "test" + i++, true, 0, repository, this.newInstances, this.stateListener, context, 0, null); diff --git a/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/tests/elements/primitive/TestPrimitiveCompile.java b/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/tests/elements/primitive/TestPrimitiveCompile.java index 10bd800275..ba0578ec29 100644 --- a/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/tests/elements/primitive/TestPrimitiveCompile.java +++ b/legend-pure-core/legend-pure-m3-core/src/test/java/org/finos/legend/pure/m3/tests/elements/primitive/TestPrimitiveCompile.java @@ -85,7 +85,7 @@ public void testPrimitiveWithVariable() "{\n" + " 2->cast(@test::IntCap(1));\n" + "}", - "Compilation error at (resource:fromString.pure line:6 column:26), \"Type variable mismatch for the class IntCap (expected 2, got 1): IntCap(1)\""); + "Compilation error at (resource:fromString.pure line:6 column:26), \"Type variable mismatch for the class IntCap(x:Integer,z:String) (expected 2, got 1): IntCap(1)\""); } @Test @@ -101,7 +101,7 @@ public void testPrimitiveWrongVariableType() "{\n" + " [];\n" + "}", - "Compilation error at (resource:fromString.pure line:6 column:26), \"Type variable type mismatch for the class IntCap (expected Integer, got String): \""); + "Compilation error at (resource:fromString.pure line:6 column:26), \"Type variable type mismatch for the class IntCap(x:Integer) (expected Integer, got String): \""); } @Test @@ -171,7 +171,7 @@ public void testPrimitiveWithParameterInClassError() "{" + " v : test::IntCap()[1];" + "}", - "Compilation error at (resource:fromString.pure line:1 column:88), \"Type variable mismatch for the class IntCap (expected 1, got 0): IntCap\""); + "Compilation error at (resource:fromString.pure line:1 column:88), \"Type variable mismatch for the class IntCap(x:Integer) (expected 1, got 0): IntCap\""); } diff --git a/legend-pure-runtime/legend-pure-runtime-java-engine-compiled/src/main/java/org/finos/legend/pure/runtime/java/compiled/generation/processors/support/coreinstance/ValCoreInstance.java b/legend-pure-runtime/legend-pure-runtime-java-engine-compiled/src/main/java/org/finos/legend/pure/runtime/java/compiled/generation/processors/support/coreinstance/ValCoreInstance.java index b58b996a5a..457b99bdb1 100644 --- a/legend-pure-runtime/legend-pure-runtime-java-engine-compiled/src/main/java/org/finos/legend/pure/runtime/java/compiled/generation/processors/support/coreinstance/ValCoreInstance.java +++ b/legend-pure-runtime/legend-pure-runtime-java-engine-compiled/src/main/java/org/finos/legend/pure/runtime/java/compiled/generation/processors/support/coreinstance/ValCoreInstance.java @@ -32,6 +32,7 @@ import java.math.BigDecimal; import java.math.BigInteger; +import java.util.Objects; public class ValCoreInstance extends AbstractCompiledCoreInstance { @@ -44,6 +45,23 @@ public ValCoreInstance(String val, String type) this.type = type; } + @Override + public boolean equals(Object o) + { + if (!(o instanceof ValCoreInstance)) + { + return false; + } + ValCoreInstance that = (ValCoreInstance) o; + return Objects.equals(val, that.val) && Objects.equals(type, that.type); + } + + @Override + public int hashCode() + { + return Objects.hash(super.hashCode(), val, type); + } + public Object getValue() { switch (this.type)