.net - C# compiler type inference difference between inline method call and separate method call -
it seems c# compiler infers types differently depending on how method called:
void foo<t>() t : bar { var instance = new t() { id = 1 }. extensionmethod(); } in case compiler seems infer type of instance bar, because have class bar extensionmethod declared.
void foo<t>() t : bar { var instance = new t() { id = 1 }; instance.extensionmethod(); } in case compiler infers type of instance t, expect in first case well. why there such difference?
in first case, assign result of method call instance. in second case discard call's result. instead, assign new t difference.
Comments
Post a Comment