Inferring arguments to a method
Is there any way to get C# to infer "A" here correctly?
Why doesn't it infer that A is string in this case?
Why doesn't it infer that A is string in this case?
public interface IScene<A> {
public void Init(A args);
}
class MyType : IScene<string> {
public void Init(string args) { ... }
}
...
public T Spawn<T, A>(PackedScene scene, A args) where T : class, IScene<A> {
T t = scene.Instantiate<T>();
t.Init(args);
return t;
}
...
MyType myType = Spawn<MyType>(scene, "hi"); // compiler complains about omitting type of A here