Skip to content

Commit 61c1856

Browse files
committed
Order instantiated anonymous types by the types they instantiate
Instantiations of distinct object literal types made by the same declaration, such as the copies a call makes when it infers from an argument twice, were ordered only by their mappers. Instantiations with mappers of the same content then compared as equal and fell back to the type id (seen in t3code). They are now ordered by the type they instantiate first.
1 parent 11d1ab7 commit 61c1856

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎tsc/internal/checker/utilities.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,11 @@ func CompareTypes(t1, t2 *Type) int {
661661
return c
662662
}
663663
}
664+
// Instantiations are ordered by the types they instantiate, then by
665+
// their mappers.
666+
if c := CompareTypes(t1.AsObjectType().target, t2.AsObjectType().target); c != 0 {
667+
return c
668+
}
664669
m1 := t1.AsObjectType().mapper
665670
m2 := t2.AsObjectType().mapper
666671
if t1.objectFlags&ObjectFlagsMapped != 0 {

0 commit comments

Comments
 (0)