Skip to content

Commit

Permalink
For_Func_returned_type_with_lazy_dependency_Func_parameters_are_corre…
Browse files Browse the repository at this point in the history
…ctly_passed (#394)
  • Loading branch information
wgebczyk authored Apr 21, 2021
1 parent dab4dd4 commit 6046dd6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DryIoc/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3181,7 +3181,7 @@ public static bool TryInterpret(IResolverContext r, Expression expr,
for (var i = 0; i < multipleParams.Count; i++)
if (expr == multipleParams[i])
{
result = ((object[]) paramValues)[i];
result = ((object[]) p.ParamValues)[i];
return true;
}
}
Expand Down
18 changes: 18 additions & 0 deletions test/DryIoc.UnitTests/FuncTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,24 @@ public void Can_supply_fresh_args_in_different_open_scopes()
}
}

[Test]
public void For_Func_returned_type_with_lazy_dependency_Func_parameters_are_correctly_passed()
{
var c = new Container();

c.Register<A>();
c.RegisterDelegate<F>(() => new F("notUsed"));
c.Register<L>();
c.Register<Y>();

var lFunc = c.Resolve<Func<A, Y, L>>();
var l = lFunc(new A(), new Y(new A()));

var f = l.F;

Assert.IsNotNull(f, "Expected F will be created via Lazy<> evaluation.");
}

#region CUT

class SS
Expand Down

0 comments on commit 6046dd6

Please sign in to comment.