Check circular dependencies before resolving @inheritdoc.

Otherwise the documentation inheriting process will run into infinite
loop.

For example the following code cause a problem:

    /**
     * @class
     * @extends B
     */
    A = {};

    /**
     * @class
     * @extends A
     */
    B = {c: 'd'};

That's fixed now.