Fix StatementContextBase.childCopyOf()
[yangtools.git] / parser / yang-parser-reactor / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / reactor / StatementContextBase.java
index b54ce1c26c4acc0fe0365b3115a27a6aec390719..9c537eafcac9fbc40222d32006c025a80795b4ae 100644 (file)
@@ -806,8 +806,13 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
     public final Mutable<?, ?, ?> childCopyOf(final StmtContext<?, ?, ?> stmt, final CopyType type,
             final QNameModule targetModule) {
         checkEffectiveModelCompleted(stmt);
-        checkArgument(stmt instanceof StatementContextBase, "Unsupported statement %s", stmt);
-        return childCopyOf((StatementContextBase<?, ?, ?>) stmt, type, targetModule);
+        if (stmt instanceof StatementContextBase) {
+            return childCopyOf((StatementContextBase<?, ?, ?>) stmt, type, targetModule);
+        } else if (stmt instanceof ReplicaStatementContext) {
+            return ((ReplicaStatementContext<?, ?, ?>) stmt).replicaAsChildOf(this);
+        } else {
+            throw new IllegalArgumentException("Unsupported statement " + stmt);
+        }
     }
 
     private <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<X, Y>> Mutable<X, Y, Z> childCopyOf(