@Override
    public Type resolve(@NotNull Scope s, int tag) {
        ClassType classType = new ClassType(getName().getId(), s);
        List<Type> baseTypes = new ArrayList<Type>();
        for (Node base : bases) {
            Type baseType = resolveExpr(base, s, tag);
            if (baseType.isClassType()) {
                classType.addSuper(baseType);
            } else if (baseType.isUnionType()) {
                for (Type b : baseType.asUnionType().getTypes()) {
                    classType.addSuper(b);
                    break;
                }
            } else {
                Indexer.idx.putProblem(base, base + " is not a class");
            }
            baseTypes.add(baseType);
        }

        // XXX: Not sure if we should add "bases", "name" and "dict" here. They
        // must be added _somewhere_ but I'm just not sure if it should be HERE.
        Builtins builtins = Indexer.idx.builtins;
        addSpecialAttribute(classType.getTable(), "__bases__", new TupleType(baseTypes));
        addSpecialAttribute(classType.getTable(), "__name__", builtins.BaseStr);
        addSpecialAttribute(classType.getTable(), "__dict__", new DictType(builtins.BaseStr, Indexer.idx.builtins.unknown));
        addSpecialAttribute(classType.getTable(), "__module__", builtins.BaseStr);
        addSpecialAttribute(classType.getTable(), "__doc__", builtins.BaseStr);

        // Bind ClassType to name here before resolving the body because the
        // methods need this type as self.
        NameBinder.bind(s, name, classType, Binding.Kind.CLASS, tag);
        resolveExpr(body, classType.getTable(), tag);
        return Indexer.idx.builtins.Cont;
    }