protected override void VisitMethodCallSyntax(MethodCallSyntax pNode) { base.VisitMethodCallSyntax(pNode); SmallType[] types = new SmallType[pNode.Arguments.Count]; for (int i = 0; i < types.Length; i++) { types[i] = pNode.Arguments[i].Type; if (types[i] == SmallTypeCache.NoValue) { CompilerErrors.ExpressionNoValue(pNode.Arguments[i].Span); } } if (SyntaxHelper.HasUndefinedCastAsArg(pNode)) { IList <MethodDefinition> matches = _unit.GetAllMatches(Namespace, pNode.Value, pNode.Arguments.Count); if (matches.Count > 1) { //If multiple matches are found the implicit cast could map to either method, so we can't tell CompilerErrors.InferImplicitCast(pNode.Span); return; } else if (matches.Count == 1) { //Check if we can determine implicit cast type yet for (int j = 0; j < Math.Min(matches[0].ArgumentTypes.Count, pNode.Arguments.Count); j++) { if (SyntaxHelper.IsUndefinedCast(pNode.Arguments[j])) { TrySetImplicitCastType(pNode.Arguments[j], matches[0].ArgumentTypes[j]); types[j] = pNode.Arguments[j].Type; } } } } //Check to ensure this method exists var result = SyntaxHelper.FindMethodOnType(out MethodDefinition m, _unit, Namespace, pNode.Value, CurrentType, types); switch (result) { case Compiler.FindResult.NotFound: CompilerErrors.MethodNotFound(m, Struct, pNode.Value, pNode.Arguments, pNode.Span); return; case Compiler.FindResult.IncorrectScope: CompilerErrors.MethodNotInScope(m, Struct, pNode.Value, pNode.Arguments, pNode.Span); return; } for (int i = 0; i < m.ArgumentTypes.Count; i++) { ForceCastLiteral(m.ArgumentTypes[i], pNode.Arguments[i]); } //Poly our method definition to match any generic types m = m.MakeConcreteDefinition(CurrentType); pNode.SetType(m.ReturnType); }