Weaver icon indicating copy to clipboard operation
Weaver copied to clipboard

Crash when dependency cycle allowed with self reference

Open trupin opened this issue 5 years ago • 1 comments

There's a case where Weaver allows for a dependency cycle to be built even though the code crashes at runtime.

class App {
   // weaver: foo = Foo
   // weaver: bar = Bar
}

class Foo {
  // weaver: bar <- Bar

  // self reference causing Weaver to accept the cycle foo <-> bar.
  // weaver: foo <- Foo
}

class Bar {
  // weaver: foo <- Foo
}

Because foo and bar are built outside of the dependency cycle, the self reference doesn't break that cycle. Weaver should detect that and output an error.

trupin avatar Apr 24 '20 16:04 trupin

@trupin I have same case, can do you provide small recommendations, how to break this cycles? I try to configure VIPER with this DI, moving from Typhoon DI. And I have presenter which resolve viewInput protocol, and view which resolving ViewOutput protocol and got cycloramic dependency. I tried to make weak scope in registration, and others variants with reference but nothing help.

bimawa avatar Sep 17 '20 03:09 bimawa