From 29b705c07cdc1978e8b921924e3ee1cb96c377e3 Mon Sep 17 00:00:00 2001 From: Jaskeerat Singh Saluja Date: Sat, 7 Sep 2024 14:27:10 +0530 Subject: [PATCH] feat(bug): Simple fix Signed-off-by: Jaskeerat Singh Saluja --- .../concerto-core/lib/introspect/modelfile.js | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/concerto-core/lib/introspect/modelfile.js b/packages/concerto-core/lib/introspect/modelfile.js index f582b05e6..8012d8e8c 100644 --- a/packages/concerto-core/lib/introspect/modelfile.js +++ b/packages/concerto-core/lib/introspect/modelfile.js @@ -275,19 +275,19 @@ class ModelFile extends Decorated { // Validate all of the types in this model file. // Check if names of the declarations are unique. const uniqueNames = new Set(); - this.declarations.forEach( - d => { - const fqn = d.getFullyQualifiedName(); - if (!uniqueNames.has(fqn)) { - uniqueNames.add(fqn); - } else { - throw new IllegalModelException( - `Duplicate class name ${fqn}` - ); - } + this.declarations.forEach(d => { + const fqn = d.getFullyQualifiedName(); + const shortName = ModelUtil.getShortName(fqn); + if (uniqueNames.has(fqn)) { + throw new IllegalModelException(`Duplicate class name: ${fqn}`); } - ); - + if (this.importShortNames.has(shortName)) { + throw new IllegalModelException( + `TypeName Conflict: The type '${shortName}' is being redefined, but it already exists as an imported type from '${this.importShortNames.get(shortName)}'. Please rename your local type or avoid importing conflicting types.` + ); + } + uniqueNames.add(fqn); + }); // Run validations on class declarations for(let n=0; n < this.declarations.length; n++) { let classDeclaration = this.declarations[n];