private void InferResult(Expression expr, string name, LexicalInfo lexicalInfo, bool useElementType) { if (expr == null) return; // Prevent creating an infinite number of InferredReturnTypes in inferring cycles IReturnType returnType; if (expr.ContainsAnnotation("DomReturnType")) { returnType = (IReturnType)expr["DomReturnType"]; } else { returnType = new BooInferredReturnType(expr, resolver.CallingClass); expr.Annotate("DomReturnType", returnType); } if (useElementType) returnType = new ElementReturnType(resolver.ProjectContent, returnType); result = new DefaultField.LocalVariableField(returnType, name, new DomRegion(lexicalInfo.Line, lexicalInfo.Column), resolver.CallingClass); }