private MethodSymbol addEnumCompareTo(JCClassDecl cdef, VarSymbol ordinalSymbol) {
        Symbol compareToSym = lookupMethod(cdef.pos(),
                                   names.compareTo,
                                   cdef.type,
                                   List.of(cdef.sym.type));

        assert(compareToSym != null);
        assert(compareToSym instanceof MethodSymbol);

        JCMethodDecl compareToDecl = (JCMethodDecl) TreeInfo.declarationFor(compareToSym, cdef);

        ListBuffer<JCStatement> blockStatements = new ListBuffer<JCStatement>();

        JCModifiers mod1 = make.Modifiers(0L);
        Name oName = Name.fromString(names, "o");
        JCVariableDecl par1 = make.Param(oName, cdef.type, compareToSym);

        JCIdent paramId1 = make.Ident(names.java_lang_Object);
        paramId1.type = cdef.type;
        paramId1.sym = par1.sym;

        ((MethodSymbol)compareToSym).params = List.of(par1.sym);

        JCIdent par1UsageId = make.Ident(par1.sym);
        JCIdent castTargetIdent = make.Ident(cdef.sym);
        JCTypeCast cast = make.TypeCast(castTargetIdent, par1UsageId);
        cast.setType(castTargetIdent.type);

        Name otherName = Name.fromString(names, "other");

        VarSymbol otherVarSym = new VarSymbol(mod1.flags,
                                              otherName,
                                              cdef.type,
                                              compareToSym);
        JCVariableDecl otherVar = make.VarDef(otherVarSym, cast);
        blockStatements.append(otherVar);

        JCIdent id1 = make.Ident(ordinalSymbol);

        JCIdent fLocUsageId = make.Ident(otherVarSym);
        JCExpression sel = make.Select(fLocUsageId, ordinalSymbol);
        JCBinary bin = makeBinary(JCTree.MINUS, id1, sel);
        JCReturn ret = make.Return(bin);
        blockStatements.append(ret);
        JCMethodDecl compareToMethod = make.MethodDef((MethodSymbol)compareToSym,
                                                   make.Block(0L,
                                                              blockStatements.toList()));
        compareToMethod.params = List.of(par1);
        cdef.defs = cdef.defs.append(compareToMethod);

        return (MethodSymbol)compareToSym;
    }