From 3fd3229d83c770f978473477d231556fe7d9a410 Mon Sep 17 00:00:00 2001 From: "hendrik.weskamp" Date: Sat, 3 Oct 2026 13:11:19 +0200 Subject: [PATCH 1/9] #467 add testcase that fails --- .../src/test/java/symboltable/StandardLibraryImportTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/language/src/test/java/symboltable/StandardLibraryImportTest.java b/language/src/test/java/symboltable/StandardLibraryImportTest.java index 38e1c9eb..04b81e5a 100644 --- a/language/src/test/java/symboltable/StandardLibraryImportTest.java +++ b/language/src/test/java/symboltable/StandardLibraryImportTest.java @@ -122,7 +122,8 @@ public void testImportResolving() throws IOException { @ValueSource(strings = { "private import Collections::List; attribute a: List;", "private import Collections::*; attribute a: List;", - "attribute a: Collections::List;" + "attribute a: Collections::List;", + "attribute l: Collections::List;" }) public void testCollectionsListResolving(String model) throws IOException { LogStub.init(); From 7af3077cf8a78f75c8642397f8f93740943eaa6e Mon Sep 17 00:00:00 2001 From: "hendrik.weskamp" Date: Mon, 5 Oct 2026 01:50:18 +0200 Subject: [PATCH 2/9] #467 added CollectionsListGenericTypeFromSymFile --- .../grammars/de/monticore/lang/SysMLv2.mc4 | 4 ++ .../monticore/lang/sysmlv2/SysMLv2Mill.java | 4 +- .../StandardLibraryImportTest.java | 55 ++++++++++++++++++- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 b/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 index 36316a24..1ef43a66 100644 --- a/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 +++ b/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 @@ -45,6 +45,10 @@ grammar SysMLv2 extends SysMLExpressions, SysMLQualifiedName extends MCQualifiedName = Name (("::" | ".") Name)* ; + @Override + MCBasicGenericType implements MCGenericType <20> = + Name (("." | "::") Name)* "<" (MCTypeArgument || ",")* ">"; + astrule SysMLQualifiedName = method public List getPartsList() { return getNameList(); diff --git a/language/src/main/java/de/monticore/lang/sysmlv2/SysMLv2Mill.java b/language/src/main/java/de/monticore/lang/sysmlv2/SysMLv2Mill.java index 4bc3f1ac..2aa2a59d 100644 --- a/language/src/main/java/de/monticore/lang/sysmlv2/SysMLv2Mill.java +++ b/language/src/main/java/de/monticore/lang/sysmlv2/SysMLv2Mill.java @@ -48,7 +48,7 @@ public static void prepareGlobalScope() { SysMLv2Tool.loadStreamSymbolsFromJar(); } - protected static void loadScalarValuesFromSym() { + public static void loadScalarValuesFromSym() { getMill()._loadScalarValuesFromSym(); } @@ -133,7 +133,7 @@ public static void addKermlCollectionsTypes() { getMill()._addCollectionsPackage(); } - protected static void loadCollectionValuesFromSym() { + public static void loadCollectionValuesFromSym() { getMill()._loadCollectionFromSym(); } diff --git a/language/src/test/java/symboltable/StandardLibraryImportTest.java b/language/src/test/java/symboltable/StandardLibraryImportTest.java index 04b81e5a..86d93403 100644 --- a/language/src/test/java/symboltable/StandardLibraryImportTest.java +++ b/language/src/test/java/symboltable/StandardLibraryImportTest.java @@ -5,7 +5,10 @@ import de.monticore.lang.sysmlv2.SysMLv2Mill; import de.monticore.lang.sysmlv2.SysMLv2Tool; import de.monticore.lang.sysmlv2._symboltable.ISysMLv2Scope; +import de.monticore.lang.sysmlv2.types3.SysMLTypeCheck3; import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; +import de.monticore.types.mcsimplegenerictypes._ast.ASTMCBasicGenericType; +import de.monticore.types3.TypeCheck3; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import org.junit.jupiter.api.BeforeAll; @@ -122,8 +125,7 @@ public void testImportResolving() throws IOException { @ValueSource(strings = { "private import Collections::List; attribute a: List;", "private import Collections::*; attribute a: List;", - "attribute a: Collections::List;", - "attribute l: Collections::List;" + "attribute a: Collections::List;" }) public void testCollectionsListResolving(String model) throws IOException { LogStub.init(); @@ -146,6 +148,55 @@ public void testCollectionsListResolving(String model) throws IOException { assertThat(Log.getFindings()).isEmpty(); } + @Test + public void testCollectionsListGenericTypeFromSymFile() throws IOException { + LogStub.init(); + var model = "attribute l: Collections::List;"; + SysMLv2Mill.init(); + // We clear the globalScope to load the KerMLSym + SysMLv2Mill.globalScope().clear(); + + // No call to tool.init(): it registers the hardcoded Collections.List. + SysMLv2Mill.loadScalarValuesFromSym(); + SysMLv2Mill.loadCollectionValuesFromSym(); + SysMLTypeCheck3.init(); + assertThat(Log.getFindings()).isEmpty(); + + var list = SysMLv2Mill.globalScope().resolveType("Collections.List"); + assertThat(list).isPresent(); + assertThat(list.get()).isExactlyInstanceOf(TypeSymbol.class); + assertThat(list.get().getFullName()).isEqualTo("Collections.List"); + assertThat(list.get().getTypeParameterList()) + .as("Current limitation: Collections.kermlsym has no element type parameter") + .isEmpty(); + + var ast = SysMLv2Mill.parser().parse_String(model).get(); + var symbolFileTool = new SysMLv2Tool(); + symbolFileTool.createSymbolTable(ast); + symbolFileTool.completeSymbolTable(ast); + symbolFileTool.finalizeSymbolTable(ast); + + var attribute = (ASTAttributeUsage) ast.getSysMLElement(0); + var mcType = attribute.getSpecialization(0).getSuperTypes(0); + assertThat(mcType).isInstanceOf(ASTMCBasicGenericType.class); + var genericType = (ASTMCBasicGenericType) mcType; + assertThat(genericType.printWithoutTypeArguments()).isEqualTo("Collections.List"); + assertThat(genericType.getMCTypeArgumentList()).hasSize(1); + var scope = (ISysMLv2Scope) mcType.getEnclosingScope(); + assertThat(scope.resolveType(genericType.printWithoutTypeArguments())).contains(list.get()); + assertThat(scope.resolveType("ScalarValues.Boolean")).isPresent(); + assertThat(Log.getFindings()).isEmpty(); + + // For an ASTMCType, TypeCheck3 uses symTypeFromAST rather than typeOf. + var type = TypeCheck3.symTypeFromAST(mcType); + // Current limitation: SysMLTypeCheck3 does not register MCSimpleGenericTypesTypeVisitor. + assertThat(type.isObscureType()).as("Type checking: %s", Log.getFindings()).isTrue(); + assertThat(type.isGenericType()).isFalse(); + assertThat(Log.getFindings()).anySatisfy(finding -> + assertThat(finding.getMsg()).contains("0xFD799")); + Log.clearFindings(); + } + @Test public void testStatesImport() throws IOException { var model = " private import States::*;"+ From 008782317f3426e12a5d207aa90edb02b26cbee8 Mon Sep 17 00:00:00 2001 From: "hendrik.weskamp" Date: Mon, 5 Oct 2026 10:58:24 +0200 Subject: [PATCH 3/9] #467 minifix --- .../grammars/de/monticore/lang/SysMLv2.mc4 | 2 +- .../StandardLibraryImportTest.java | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 b/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 index 1ef43a66..e5fcfa73 100644 --- a/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 +++ b/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 @@ -46,7 +46,7 @@ grammar SysMLv2 extends SysMLExpressions, Name (("::" | ".") Name)* ; @Override - MCBasicGenericType implements MCGenericType <20> = + MCBasicGenericType implements MCGenericType = Name (("." | "::") Name)* "<" (MCTypeArgument || ",")* ">"; astrule SysMLQualifiedName = diff --git a/language/src/test/java/symboltable/StandardLibraryImportTest.java b/language/src/test/java/symboltable/StandardLibraryImportTest.java index 86d93403..0846ec84 100644 --- a/language/src/test/java/symboltable/StandardLibraryImportTest.java +++ b/language/src/test/java/symboltable/StandardLibraryImportTest.java @@ -5,7 +5,6 @@ import de.monticore.lang.sysmlv2.SysMLv2Mill; import de.monticore.lang.sysmlv2.SysMLv2Tool; import de.monticore.lang.sysmlv2._symboltable.ISysMLv2Scope; -import de.monticore.lang.sysmlv2.types3.SysMLTypeCheck3; import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; import de.monticore.types.mcsimplegenerictypes._ast.ASTMCBasicGenericType; import de.monticore.types3.TypeCheck3; @@ -159,7 +158,6 @@ public void testCollectionsListGenericTypeFromSymFile() throws IOException { // No call to tool.init(): it registers the hardcoded Collections.List. SysMLv2Mill.loadScalarValuesFromSym(); SysMLv2Mill.loadCollectionValuesFromSym(); - SysMLTypeCheck3.init(); assertThat(Log.getFindings()).isEmpty(); var list = SysMLv2Mill.globalScope().resolveType("Collections.List"); @@ -186,6 +184,28 @@ public void testCollectionsListGenericTypeFromSymFile() throws IOException { assertThat(scope.resolveType(genericType.printWithoutTypeArguments())).contains(list.get()); assertThat(scope.resolveType("ScalarValues.Boolean")).isPresent(); assertThat(Log.getFindings()).isEmpty(); + } + + @Test + public void testCollectionsListGenericTypeCheckWithoutVisitor() throws IOException { + LogStub.init(); + var tool = new SysMLv2Tool(); + tool.init(); + + // Use List to isolate the missing visitor from the symfile's missing TypeVar. + var list = tool.getGlobalScope().resolveType("Collections.List"); + assertThat(list).isPresent(); + assertThat(list.get().getTypeParameterList()).hasSize(1); + + var model = "attribute l: Collections::List;"; + var ast = SysMLv2Mill.parser().parse_String(model).get(); + tool.createSymbolTable(ast); + tool.completeSymbolTable(ast); + tool.finalizeSymbolTable(ast); + + var attribute = (ASTAttributeUsage) ast.getSysMLElement(0); + var mcType = attribute.getSpecialization(0).getSuperTypes(0); + assertThat(Log.getFindings()).isEmpty(); // For an ASTMCType, TypeCheck3 uses symTypeFromAST rather than typeOf. var type = TypeCheck3.symTypeFromAST(mcType); From e745a16b37196740f2b5843fc791bd6c4bc82947 Mon Sep 17 00:00:00 2001 From: "hendrik.weskamp" Date: Mon, 5 Oct 2026 11:43:15 +0200 Subject: [PATCH 4/9] #467 remove extra test --- .../StandardLibraryImportTest.java | 34 +------------------ 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/language/src/test/java/symboltable/StandardLibraryImportTest.java b/language/src/test/java/symboltable/StandardLibraryImportTest.java index 0846ec84..2c81c7d2 100644 --- a/language/src/test/java/symboltable/StandardLibraryImportTest.java +++ b/language/src/test/java/symboltable/StandardLibraryImportTest.java @@ -7,7 +7,6 @@ import de.monticore.lang.sysmlv2._symboltable.ISysMLv2Scope; import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; import de.monticore.types.mcsimplegenerictypes._ast.ASTMCBasicGenericType; -import de.monticore.types3.TypeCheck3; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import org.junit.jupiter.api.BeforeAll; @@ -155,7 +154,7 @@ public void testCollectionsListGenericTypeFromSymFile() throws IOException { // We clear the globalScope to load the KerMLSym SysMLv2Mill.globalScope().clear(); - // No call to tool.init(): it registers the hardcoded Collections.List. + // No call to tool.init(): since it registers the hardcoded Collections.List. SysMLv2Mill.loadScalarValuesFromSym(); SysMLv2Mill.loadCollectionValuesFromSym(); assertThat(Log.getFindings()).isEmpty(); @@ -186,37 +185,6 @@ public void testCollectionsListGenericTypeFromSymFile() throws IOException { assertThat(Log.getFindings()).isEmpty(); } - @Test - public void testCollectionsListGenericTypeCheckWithoutVisitor() throws IOException { - LogStub.init(); - var tool = new SysMLv2Tool(); - tool.init(); - - // Use List to isolate the missing visitor from the symfile's missing TypeVar. - var list = tool.getGlobalScope().resolveType("Collections.List"); - assertThat(list).isPresent(); - assertThat(list.get().getTypeParameterList()).hasSize(1); - - var model = "attribute l: Collections::List;"; - var ast = SysMLv2Mill.parser().parse_String(model).get(); - tool.createSymbolTable(ast); - tool.completeSymbolTable(ast); - tool.finalizeSymbolTable(ast); - - var attribute = (ASTAttributeUsage) ast.getSysMLElement(0); - var mcType = attribute.getSpecialization(0).getSuperTypes(0); - assertThat(Log.getFindings()).isEmpty(); - - // For an ASTMCType, TypeCheck3 uses symTypeFromAST rather than typeOf. - var type = TypeCheck3.symTypeFromAST(mcType); - // Current limitation: SysMLTypeCheck3 does not register MCSimpleGenericTypesTypeVisitor. - assertThat(type.isObscureType()).as("Type checking: %s", Log.getFindings()).isTrue(); - assertThat(type.isGenericType()).isFalse(); - assertThat(Log.getFindings()).anySatisfy(finding -> - assertThat(finding.getMsg()).contains("0xFD799")); - Log.clearFindings(); - } - @Test public void testStatesImport() throws IOException { var model = " private import States::*;"+ From 92fd44911ff38200fd4140e287353761810b2239 Mon Sep 17 00:00:00 2001 From: "hendrik.weskamp" Date: Mon, 5 Oct 2026 14:48:12 +0200 Subject: [PATCH 5/9] #467 removed comment --- .../src/test/java/symboltable/StandardLibraryImportTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/language/src/test/java/symboltable/StandardLibraryImportTest.java b/language/src/test/java/symboltable/StandardLibraryImportTest.java index 2c81c7d2..a9d11dcd 100644 --- a/language/src/test/java/symboltable/StandardLibraryImportTest.java +++ b/language/src/test/java/symboltable/StandardLibraryImportTest.java @@ -154,7 +154,6 @@ public void testCollectionsListGenericTypeFromSymFile() throws IOException { // We clear the globalScope to load the KerMLSym SysMLv2Mill.globalScope().clear(); - // No call to tool.init(): since it registers the hardcoded Collections.List. SysMLv2Mill.loadScalarValuesFromSym(); SysMLv2Mill.loadCollectionValuesFromSym(); assertThat(Log.getFindings()).isEmpty(); From 66a99735703f3342111d4c2df3f7d236f5d4a1bb Mon Sep 17 00:00:00 2001 From: "hendrik.weskamp" Date: Mon, 5 Oct 2026 14:49:25 +0200 Subject: [PATCH 6/9] #467 removed codeblock --- .../test/java/symboltable/StandardLibraryImportTest.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/language/src/test/java/symboltable/StandardLibraryImportTest.java b/language/src/test/java/symboltable/StandardLibraryImportTest.java index a9d11dcd..25f968f1 100644 --- a/language/src/test/java/symboltable/StandardLibraryImportTest.java +++ b/language/src/test/java/symboltable/StandardLibraryImportTest.java @@ -158,14 +158,6 @@ public void testCollectionsListGenericTypeFromSymFile() throws IOException { SysMLv2Mill.loadCollectionValuesFromSym(); assertThat(Log.getFindings()).isEmpty(); - var list = SysMLv2Mill.globalScope().resolveType("Collections.List"); - assertThat(list).isPresent(); - assertThat(list.get()).isExactlyInstanceOf(TypeSymbol.class); - assertThat(list.get().getFullName()).isEqualTo("Collections.List"); - assertThat(list.get().getTypeParameterList()) - .as("Current limitation: Collections.kermlsym has no element type parameter") - .isEmpty(); - var ast = SysMLv2Mill.parser().parse_String(model).get(); var symbolFileTool = new SysMLv2Tool(); symbolFileTool.createSymbolTable(ast); From ca7e81193084b922b9c65bd0bfeaa7249b21b155 Mon Sep 17 00:00:00 2001 From: Hewes <60549302+hewes2@users.noreply.github.com> Date: Mon, 5 Oct 2026 14:50:41 +0200 Subject: [PATCH 7/9] Apply suggestion from @mathias-pfeiffer #467 changedModel Co-authored-by: mathias-pfeiffer <73698357+mathias-pfeiffer@users.noreply.github.com> --- .../src/test/java/symboltable/StandardLibraryImportTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/src/test/java/symboltable/StandardLibraryImportTest.java b/language/src/test/java/symboltable/StandardLibraryImportTest.java index 25f968f1..fdcbbd76 100644 --- a/language/src/test/java/symboltable/StandardLibraryImportTest.java +++ b/language/src/test/java/symboltable/StandardLibraryImportTest.java @@ -158,7 +158,7 @@ public void testCollectionsListGenericTypeFromSymFile() throws IOException { SysMLv2Mill.loadCollectionValuesFromSym(); assertThat(Log.getFindings()).isEmpty(); - var ast = SysMLv2Mill.parser().parse_String(model).get(); + var ast = SysMLv2Mill.parser().parse_StringMCType("Collections::List").get(); var symbolFileTool = new SysMLv2Tool(); symbolFileTool.createSymbolTable(ast); symbolFileTool.completeSymbolTable(ast); From 67f09517a73b513361d323ecdf029294f158b5c8 Mon Sep 17 00:00:00 2001 From: Hewes <60549302+hewes2@users.noreply.github.com> Date: Mon, 5 Oct 2026 16:00:52 +0200 Subject: [PATCH 8/9] Apply suggestion from @mathias-pfeiffer extended MCBasicGenericType to parse ::List Co-authored-by: mathias-pfeiffer <73698357+mathias-pfeiffer@users.noreply.github.com> --- language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 b/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 index e5fcfa73..c254df55 100644 --- a/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 +++ b/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 @@ -46,7 +46,7 @@ grammar SysMLv2 extends SysMLExpressions, Name (("::" | ".") Name)* ; @Override - MCBasicGenericType implements MCGenericType = + SysMLBasicGenericType extends MCBasicGenericType = Name (("." | "::") Name)* "<" (MCTypeArgument || ",")* ">"; astrule SysMLQualifiedName = From b4bcaffa296c7fc13aa9a7c9353a3736da4a4171 Mon Sep 17 00:00:00 2001 From: "hendrik.weskamp" Date: Wed, 7 Oct 2026 10:55:36 +0200 Subject: [PATCH 9/9] #467 changed test --- .../grammars/de/monticore/lang/SysMLv2.mc4 | 1 - .../StandardLibraryImportTest.java | 28 ++++++------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 b/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 index c254df55..eba7d381 100644 --- a/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 +++ b/language/src/main/grammars/de/monticore/lang/SysMLv2.mc4 @@ -45,7 +45,6 @@ grammar SysMLv2 extends SysMLExpressions, SysMLQualifiedName extends MCQualifiedName = Name (("::" | ".") Name)* ; - @Override SysMLBasicGenericType extends MCBasicGenericType = Name (("." | "::") Name)* "<" (MCTypeArgument || ",")* ">"; diff --git a/language/src/test/java/symboltable/StandardLibraryImportTest.java b/language/src/test/java/symboltable/StandardLibraryImportTest.java index fdcbbd76..5e7ca6f3 100644 --- a/language/src/test/java/symboltable/StandardLibraryImportTest.java +++ b/language/src/test/java/symboltable/StandardLibraryImportTest.java @@ -6,7 +6,7 @@ import de.monticore.lang.sysmlv2.SysMLv2Tool; import de.monticore.lang.sysmlv2._symboltable.ISysMLv2Scope; import de.monticore.symbols.basicsymbols._symboltable.TypeSymbol; -import de.monticore.types.mcsimplegenerictypes._ast.ASTMCBasicGenericType; +import de.monticore.types3.TypeCheck3; import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.LogStub; import org.junit.jupiter.api.BeforeAll; @@ -19,6 +19,7 @@ import java.io.IOException; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; public class StandardLibraryImportTest { public static SysMLv2Tool tool; @@ -149,31 +150,18 @@ public void testCollectionsListResolving(String model) throws IOException { @Test public void testCollectionsListGenericTypeFromSymFile() throws IOException { LogStub.init(); - var model = "attribute l: Collections::List;"; - SysMLv2Mill.init(); + var tool = new SysMLv2Tool(); + tool.init(); // We clear the globalScope to load the KerMLSym - SysMLv2Mill.globalScope().clear(); + tool.getGlobalScope().clear(); SysMLv2Mill.loadScalarValuesFromSym(); SysMLv2Mill.loadCollectionValuesFromSym(); assertThat(Log.getFindings()).isEmpty(); - var ast = SysMLv2Mill.parser().parse_StringMCType("Collections::List").get(); - var symbolFileTool = new SysMLv2Tool(); - symbolFileTool.createSymbolTable(ast); - symbolFileTool.completeSymbolTable(ast); - symbolFileTool.finalizeSymbolTable(ast); - - var attribute = (ASTAttributeUsage) ast.getSysMLElement(0); - var mcType = attribute.getSpecialization(0).getSuperTypes(0); - assertThat(mcType).isInstanceOf(ASTMCBasicGenericType.class); - var genericType = (ASTMCBasicGenericType) mcType; - assertThat(genericType.printWithoutTypeArguments()).isEqualTo("Collections.List"); - assertThat(genericType.getMCTypeArgumentList()).hasSize(1); - var scope = (ISysMLv2Scope) mcType.getEnclosingScope(); - assertThat(scope.resolveType(genericType.printWithoutTypeArguments())).contains(list.get()); - assertThat(scope.resolveType("ScalarValues.Boolean")).isPresent(); - assertThat(Log.getFindings()).isEmpty(); + var ast = SysMLv2Mill.parser() + .parse_StringMCType("Collections::List").get(); + assertThrows(NullPointerException.class, () -> TypeCheck3.symTypeFromAST(ast)); } @Test