1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
package p
// apidiff's output (but not its correctness) could depend on the order
// in which declarations were visited.
// For example, this always correctly reported that U changed from T to U:
// old
type U = T
// new
// i U: changed from T to U
type U T
// both
type T int
// But the test below, which is just a renaming of the one above, would report
// that B was changed from B to B! apidiff was not wrong--there is an
// incompatibility here--but it expressed itself poorly.
//
// This happened because old.A was processed first (Scope.Names returns names
// sorted), resulting in old.B corresponding with new.A. Later, when old.B
// was processed, it was matched with new.B. But since there was already a
// correspondence for old.B, the blame for the incompatibility was put on new.B.
// The fix is to establish the correspondence between same-named types first.
// old
type A = B
// new
// i A: changed from B to A
type A B
// both
type B int
|