コード例 #1
0
		public static IReturnType[] InferTypeArguments(IMethod method, IList<IReturnType> arguments, out bool success)
		{
			TypeInference ti = new TypeInference();
			Log("Doing type inference for " + new CSharpAmbience().Convert(method));
			Log(" with arguments = ", arguments);
			ti.typeParameters = method.TypeParameters.Select(tp => new TP(tp)).ToList();
			ti.parameterTypes = method.Parameters.Select(p => p.ReturnType).Take(arguments.Count).ToList();
			ti.arguments = arguments.Take(ti.parameterTypes.Count).ToArray();
			ti.PhaseOne();
			success = ti.PhaseTwo();
			IReturnType[] result = ti.typeParameters.Select(tp => tp.FixedTo).ToArray();
			Log("Type inference for " + method.DotNetName + " " + (success ? "succeeded" : "failed") + ": ", result);
			return result;
		}