diff --git a/__tests__/InvalidMutations.ts b/__tests__/InvalidMutations.ts index 2345eb393..977cad095 100644 --- a/__tests__/InvalidMutations.ts +++ b/__tests__/InvalidMutations.ts @@ -38,11 +38,6 @@ class R1 extends Reactor { [this.in1], [this.in1, this.in2, this.out1, this.out2], function (this, __in1, __in2, __out1, __out2) { - test("expect error on creating creating direct feed through", () => { - expect(() => { - this.connect(__in2.asConnectable(), __out2.asConnectable()); - }).toThrowError("New connection introduces direct feed through."); - }); test("expect error when creating connection outside container", () => { expect(() => { this.connect(__out2.asConnectable(), __in2.asConnectable()); diff --git a/src/core/reactor.ts b/src/core/reactor.ts index 7fa4263cc..0b70bdfed 100644 --- a/src/core/reactor.ts +++ b/src/core/reactor.ts @@ -1168,34 +1168,23 @@ export abstract class Reactor extends Component { return CanConnectResult.RT_CONNECTION_OUTSIDE_CONTAINER; } - // Take the local graph and merge in all the causality interfaces - // of contained reactors. Then: - const graph = new PrecedenceGraph | Reaction>(); - graph.addAll(this._dependencyGraph); - - for (const r of this._getOwnReactors()) { - graph.addAll(r._getCausalityInterface()); + /** + * TODO (axmmisaka): The following code is commented for multiple reasons: + * The causality interface check is not fully implemented so new checks are failing + * Second, direct feedthrough itself would not cause any problem *per se*. + * To ensure there is no cycle, the safest way is to check against the global dependency graph. + */ + + let app = this as Reactor; + while (app._getContainer() !== app) { + app = app._getContainer(); } - - // Add the new edge. + const graph = app._getPrecedenceGraph(); graph.addEdge(src, dst); - - // 1) check for loops - const hasCycle = graph.hasCycle(); - if (hasCycle) { + if (graph.hasCycle()) { return CanConnectResult.RT_CYCLE; } - // 2) check for direct feed through. - // FIXME: This doesn't handle while direct feed thorugh cases. - if ( - src instanceof InPort && - dst instanceof OutPort && - dst.getContainer() === src.getContainer() - ) { - return CanConnectResult.RT_DIRECT_FEED_THROUGH; - } - return CanConnectResult.SUCCESS; } }