Buggy code:
public class CheckTypeVisitor implements AbstractExpressionVisitor < Expression , CheckTypeVisitor . Result > { private final Map < String , Definition > myGlobalContext ; private final List < Binding > myLocalContext ; private final List < TypeCheckingError > myErrors ; private final CheckTypeVisitor . Side mySide ; private static class Arg { boolean isExplicit ; String name ; Abstract . Expression expression ; Arg ( boolean isExplicit , String name , Abstract . Expression expression ) { } } public static abstract class Result { public Expression expression ; } public static class OKResult extends CheckTypeVisitor . Result { public Expression type ; public List < CompareVisitor . Equation > equations ; public OKResult ( Expression expression , Expression type , List < CompareVisitor . Equation > equations ) { } } public static class InferErrorResult extends CheckTypeVisitor . Result { public TypeCheckingError error ; public InferErrorResult ( InferHoleExpression hole , TypeCheckingError error ) { } } public enum Side { LHS , RHS ; } public CheckTypeVisitor ( Map < String , Definition > globalContext , List < Binding > localContext , List < TypeCheckingError > errors , CheckTypeVisitor . Side side ) { } private CheckTypeVisitor . Result checkResult ( Expression expectedType , CheckTypeVisitor . OKResult result , Abstract . Expression expression ) { } private CheckTypeVisitor . Result checkResultImplicit ( Expression expectedType , CheckTypeVisitor . OKResult result , Abstract . Expression expression ) { } private CheckTypeVisitor . Result typeCheck ( Abstract . Expression expr , Expression expectedType ) { } private int solveEquations ( int size , CheckTypeVisitor . Arg [ ] argsImp , CheckTypeVisitor . Result [ ] resultArgs , List < CompareVisitor . Equation > equations , List < CompareVisitor . Equation > resultEquations , Abstract . Expression fun ) { } private boolean typeCheckArgs ( CheckTypeVisitor . Arg [ ] argsImp , CheckTypeVisitor . Result [ ] resultArgs , List < TypeArgument > signature , List < CompareVisitor . Equation > resultEquations , int startIndex , Abstract . Expression fun ) { } private CheckTypeVisitor . Result typeCheckApps ( Abstract . Expression fun , List < Abstract . ArgumentExpression > args , Expression expectedType , Abstract . Expression expression ) { } public CheckTypeVisitor . OKResult checkType ( Abstract . Expression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitApp ( Abstract . AppExpression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitDefCall ( Abstract . DefCallExpression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitIndex ( Abstract . IndexExpression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitLam ( Abstract . LamExpression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitPi ( Abstract . PiExpression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitUniverse ( Abstract . UniverseExpression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitVar ( Abstract . VarExpression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitError ( Abstract . ErrorExpression expr , Expression expectedType ) { <START_BUG> myErrors . add ( new GoalError ( myLocalContext , expectedType ) ) ; <END_BUG> return null ; } @ Override public CheckTypeVisitor . Result visitInferHole ( Abstract . InferHoleExpression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitTuple ( Abstract . TupleExpression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitSigma ( Abstract . SigmaExpression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitBinOp ( Abstract . BinOpExpression expr , Expression expectedType ) { } @ Override public CheckTypeVisitor . Result visitElim ( Abstract . ElimExpression expr , Expression expectedType ) { } }

Fix:
myErrors . add ( new GoalError ( myLocalContext , expectedType , expr ) ) ;