diff --git a/distage/distage-core/src/main/scala/izumi/distage/provisioning/PlanInterpreterNonSequentialRuntimeImpl.scala b/distage/distage-core/src/main/scala/izumi/distage/provisioning/PlanInterpreterNonSequentialRuntimeImpl.scala index db5349ead7..18e1a7a4df 100644 --- a/distage/distage-core/src/main/scala/izumi/distage/provisioning/PlanInterpreterNonSequentialRuntimeImpl.scala +++ b/distage/distage-core/src/main/scala/izumi/distage/provisioning/PlanInterpreterNonSequentialRuntimeImpl.scala @@ -7,6 +7,7 @@ import izumi.distage.model.definition.errors.ProvisionerIssue.IncompatibleEffect import izumi.distage.model.definition.errors.ProvisionerIssue.ProvisionerExceptionIssue.{IntegrationCheckFailure, UnexpectedIntegrationCheck} import izumi.distage.model.exceptions.runtime.IntegrationCheckException import izumi.distage.model.plan.ExecutableOp.* +import izumi.distage.model.plan.operations.OperationOrigin import izumi.distage.model.plan.{ExecutableOp, Plan, Roots} import izumi.distage.model.provisioning.* import izumi.distage.model.provisioning.PlanInterpreter.{FailedProvision, FailedProvisionInternal, FinalizerFilter} @@ -62,7 +63,18 @@ class PlanInterpreterNonSequentialRuntimeImpl( ): F[Either[FailedProvisionInternal[F], LocatorDefaultImpl[F]]] = { val integrationCheckFType = SafeType.get[IntegrationCheck[F]] - val privateBindings = plan.input.bindings.bindings.filter(b => b.tags.contains(BindingTag.Confined)).map(_.key) + val privateBindings = plan.stepsUnordered + .filter { + op => + op.origin.value match { + case OperationOrigin.UserBinding(binding) => + binding.tags.contains(BindingTag.Confined) + case OperationOrigin.SyntheticBinding(binding) => + binding.tags.contains(BindingTag.Confined) + case OperationOrigin.Unknown => + false // TODO: true if everyting is private + } + }.map(_.target).toSet val ctx: ProvisionMutable[F] = new ProvisionMutable[F](plan, parentContext, privateBindings) diff --git a/distage/distage-core/src/test/scala/izumi/distage/injector/PrivateBindingsTest.scala b/distage/distage-core/src/test/scala/izumi/distage/injector/PrivateBindingsTest.scala index 4db6a99a6d..744edf0b21 100644 --- a/distage/distage-core/src/test/scala/izumi/distage/injector/PrivateBindingsTest.scala +++ b/distage/distage-core/src/test/scala/izumi/distage/injector/PrivateBindingsTest.scala @@ -4,16 +4,31 @@ import distage.{Injector, ModuleDef} import izumi.distage.fixtures.BasicCases.BasicCase1 import izumi.distage.model.PlannerInput import org.scalatest.wordspec.AnyWordSpec +import BasicCase1.* class PrivateBindingsTest extends AnyWordSpec with MkInjector { "Support private bindings" in { - import BasicCase1.* + val loc2 = prepareInheritedLocator(new ModuleDef { + make[TestDependency0].from[TestImpl0].confined + }) - val injector = mkInjector() + assert(loc2.find[JustTrait].nonEmpty) + assert(loc2.find[TestDependency0].isEmpty) + } - val def1 = PlannerInput.everything(new ModuleDef { - make[TestDependency0].from[TestImpl0].confined + "Support public bindings" in { + val loc2 = prepareInheritedLocator(new ModuleDef { + make[TestDependency0].from[TestImpl0] }) + + assert(loc2.find[JustTrait].nonEmpty) + assert(loc2.find[TestDependency0].nonEmpty) + } + + private def prepareInheritedLocator(m: ModuleDef) = { + val injector = mkInjector() + + val def1 = PlannerInput.everything(m) val plan1 = injector.planUnsafe(def1) val loc = injector.produce(plan1).unsafeGet() assert(loc.find[TestDependency0].nonEmpty) @@ -25,9 +40,7 @@ class PrivateBindingsTest extends AnyWordSpec with MkInjector { }) val plan2 = injector2.planUnsafe(def2) val loc2 = injector2.produce(plan2).unsafeGet() - - assert(loc2.find[JustTrait].nonEmpty) - assert(loc2.find[TestDependency0].isEmpty) + loc2 } }