Wrong constructor overload gets called
See original GitHub issueWhen Locating a class with a default constructor and a constructor with params object[] args
the overload with the args
always gets invoked even though no configuration for args
was Exported. Also the args
contains a single object
instance.
Version: 7.0.0
Repo:
var container = new DependencyInjectionContainer();
container.Configure(x => x.Export<Test>());
var test = container.Locate<Test>();
public class Test
{
public Test() {}
public Test(params object[] args)
{
throw new Exception("Wrong constructor called");
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Wrong constructor is being called - c++
If you pass a const char* , bool overload is preferred over std::string& : ... means a std::string constructor and taking reference.
Read more >Call of overloaded constructor is ambigu - C++ Forum
When I try to instantiate objects of class Foo in main() of foo.cpp, I keep getting errors about how the call to the...
Read more >Removing repetitive code (overloading methods and ...
The technique of having two (or more) constructors in a class is known as constructor overloading. A class can have multiple constructors that...
Read more >Call to overloaded constructor is ambiguous
I am trying to write a class that has two overloaded constructors: One that takes a std::function and another that takes a…
Read more >Constructor Overloading in C++
Overloaded constructors essentially have the same name (exact name of the class) and different by number and type of arguments.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sounds like the container auto registered the class Object and returned an instance in the array.
While not proper I don’t want to change the behavior of discovering object till 8.0 as it’s a breaking change.
I’m going to close this out