augmentAction.apply(new InferenceAction() {
@Override
public void apply(final InferenceContext ctx) {
+ if (!augmentNode.isSupportedToBuildEffective()) {
+ // We are not building effective model, hence we should not be performing any effects
+ return;
+ }
+
final StatementContextBase<?, ?, ?> augmentTargetCtx =
(StatementContextBase<?, ?, ?>) target.resolve(ctx);
if (!isSupportedAugmentTarget(augmentTargetCtx)
throw new InferenceException(augmentNode.getStatementSourceReference(),
"Augment target '%s' not found", augmentNode.getStatementArgument());
}
+
+ @Override
+ public void prerequisiteUnavailable(final Prerequisite<?> unavail) {
+ if (target.equals(unavail)) {
+ augmentNode.setIsSupportedToBuildEffective(false);
+ } else {
+ prerequisiteFailed(List.of(unavail));
+ }
+ }
});
}
--- /dev/null
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Set;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+
+public class YT1370Test {
+ @Test
+ public void testAugmentUnsupportedByFeatures() throws Exception {
+ assertNotNull(StmtTestUtils.parseYangSources("/bugs/YT1370", Set.of(), StatementParserMode.DEFAULT_MODE));
+ }
+}