@@ -238,30 +238,27 @@ private void onTraitDefinition(ShapeId target, TraitDefinition definition) {
238
238
private boolean validateOnShape (ShapeId id , FromSourceLocation source ) {
239
239
if (!hasDefinedShape (id )) {
240
240
return true ;
241
+ } else if (Prelude .isPreludeShape (id )) {
242
+ // Ignore prelude shape conflicts since it's such a common case of
243
+ // passing an already built model into a ModelAssembler.
244
+ return false ;
241
245
}
242
246
243
- // Ignore prelude shape conflicts since it's such a common case of
244
- // passing an already built model into a ModelAssembler.
245
- if (!Prelude .isPreludeShape (id )) {
246
- // The shape has been duplicated, so get the previously defined pending shape or built shape.
247
- SourceLocation previous = Optional .<FromSourceLocation >ofNullable (pendingShapes .get (id ))
248
- .orElseGet (() -> builtShapes .get (id )).getSourceLocation ();
249
- // Cannot ignore duplicate member definitions.
250
- boolean canIgnore = !id .getMember ().isPresent ()
251
- // Ignore duplicate shapes defined in the same file.
252
- && previous != SourceLocation .NONE
253
- && previous .equals (source .getSourceLocation ());
254
- if (canIgnore ) {
255
- LOGGER .warning (() -> "Ignoring duplicate shape definition defined in the same file: "
256
- + id + " defined at " + source .getSourceLocation ());
257
- } else {
258
- String message = String .format ("Duplicate shape definition for `%s` found at `%s` and `%s`" ,
259
- id , previous .getSourceLocation (), source .getSourceLocation ());
260
- throw new SourceException (message , source );
261
- }
262
- }
247
+ // The shape has been duplicated, so get the previously defined pending shape or built shape.
248
+ SourceLocation previous = Optional .<FromSourceLocation >ofNullable (pendingShapes .get (id ))
249
+ .orElseGet (() -> builtShapes .get (id )).getSourceLocation ();
263
250
264
- return false ;
251
+ // Ignore duplicate shapes defined in the same file (this can happen
252
+ // when the same file is included multiple times in a model assembler).
253
+ if (previous != SourceLocation .NONE && previous .equals (source .getSourceLocation ())) {
254
+ LOGGER .warning (() -> "Ignoring duplicate shape definition defined in the same file: "
255
+ + id + " defined at " + source .getSourceLocation ());
256
+ return false ;
257
+ } else {
258
+ String message = String .format ("Duplicate shape definition for `%s` found at `%s` and `%s`" ,
259
+ id , previous .getSourceLocation (), source .getSourceLocation ());
260
+ throw new SourceException (message , source );
261
+ }
265
262
}
266
263
267
264
/**
0 commit comments