private Shape modify(Shape shape, Model model, Set<Shape> otherShapes) {
        // To show up here, the shape has to have a range trait, or the target has to have one.
        RangeTrait rangeTrait = shape.getMemberTrait(model, RangeTrait.class).get();
        LOGGER.info(() -> "Removing default trait from " + shape.getId()
                + " because of an incompatible range trait: "
                + Node.printJson(rangeTrait.toNode()));

        // Members that target a shape with a default value need to set their default to null to override it.
        // Other members and other shapes can simply remove the default trait.
        if (shape.isMemberShape()) {
            MemberShape member = shape.asMemberShape().get();
            boolean targetHasDefault = model.getShape(member.getTarget())
                    // Treat target shapes that will have their default removed as if it doesn't have a default.
                    .filter(target -> !otherShapes.contains(target) && target.hasTrait(DefaultTrait.ID))
                    .isPresent();
            if (targetHasDefault) {
                return member.toBuilder().addTrait(new DefaultTrait(Node.nullNode())).build();
            }
        }

        return Shape.shapeToBuilder(shape).removeTrait(DefaultTrait.ID).build();
    }
Removes default values from shapes where the default value is incompatible with
the constraint traits of the shape.
smithy-model/src/main/java/software/amazon/smithy/model/transform/RemoveInvalidDefaults.java