Fix SOE with macros in dependencies extraction

In some cases, expanded macros report that their original tree and
its expansion are the same, thus creating a cyclic chain. This chain
may then produce a SOE during dependencies or used names extraction.

This kind of problem was already reported in sbt/sbt#1237 and
sbt/sbt#1408. Unfortunately, the fix that was applied to the
dependencies extraction part was not sufficient.

This commit ports the fix applied to the used names extraction part
to the dependencies extraction part.

Mark test 'source-dependencies/macro' as passing

Fixes #1544