Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Duplicate detection of forwarded dependencies #72

Open
kubukoz opened this issue May 13, 2021 · 2 comments
Open

Duplicate detection of forwarded dependencies #72

kubukoz opened this issue May 13, 2021 · 2 comments

Comments

@kubukoz
Copy link

kubukoz commented May 13, 2021

Hi!

In 0.3.2, as I understand, this is an issue:

import zio.ZLayer
import zio.Has
import zio.magic._

class Demo {
  trait A
  trait B
  trait C

  val a: ZLayer[Any, Nothing, Has[A]] =
    ZLayer.succeed(new A {})

  val x: ZLayer[Has[A], Nothing, Has[B] with Has[A]] =
    ZLayer.wireSome[Has[A], Has[B] with Has[A]](ZLayer.succeed(new B {}))

  val y: ZLayer[Has[A], Nothing, Has[C]] =
    ZLayer.wire[Has[C]](ZLayer.succeed(new C {}))

  val bc: ZLayer[Any, Nothing, Has[B] with Has[C]] =
    ZLayer.wire[Has[B] with Has[C]](a, x, y)
}

The macro says:

  ZLayer Wiring Error  

❯ Demo.this.A is provided by multiple layers:
❯ — a
❯ — x


Which is true. However, A appears in both the input and output of the x layer, which zio-magic could probably always treat as "passing the same thing we got in the input" and allow.

If this change stays as it is, I'll need to do some extra work to migrate, which is fine, just wanted to make sure this was intended and not going to change :)

@kubukoz kubukoz changed the title Duplicate detection in forwarded dependencies Duplicate detection of forwarded dependencies May 13, 2021
@kitlangton
Copy link
Owner

I'll fix this. Basically, I'll prune each layers inputs from its outputs, so it doesn't consider these "pass-through" layers as candidates—or worse, as circular dependencies.

@kubukoz
Copy link
Author

kubukoz commented Jul 1, 2021

Sounds great :) thanks for looking at this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants