]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: swap object.color for Checker.objPathIdx
authorMark Freeman <mark@golang.org>
Tue, 28 Oct 2025 21:54:52 +0000 (17:54 -0400)
committerGopher Robot <gobot@golang.org>
Fri, 14 Nov 2025 18:30:00 +0000 (10:30 -0800)
commitddd8558e61c80f51a2c65565f8354d12d3c6a418
treeb205bb16e7c0da9d86be29b171482772ee8870d1
parent9daaab305c4d1dede9e4f6efdc5e1268a69327e6
go/types, types2: swap object.color for Checker.objPathIdx

The type checker assigns types to objects. An object can be in
1 of 3 states, which are mapped to colors. This is stored as a
field on the object.

 - white : type not known, awaiting processing
 - grey  : type pending, in processing
 - black : type known, done processing

With the addition of Checker.objPathIdx, which maps objects to
a path index, presence in the map could signal grey coloring.
White and black coloring can be signaled by presence of
object.typ (a simple nil check).

This change removes the object.color field and its associated
methods, replacing it with an equivalent use of Checker.objPathIdx.
Checker.objPathIdx is integrated into the existing push and pop
methods, while slightly simplifying their signatures.

Note that the concept of object coloring remains the same - we
are merely changing and simplifying the mechanism which represents
the colors.

Change-Id: I91fb5e9a59dcb34c08ffc5b4ebc3f20a400094b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/715840
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
14 files changed:
src/cmd/compile/internal/types2/check.go
src/cmd/compile/internal/types2/cycles.go
src/cmd/compile/internal/types2/decl.go
src/cmd/compile/internal/types2/object.go
src/cmd/compile/internal/types2/scope.go
src/cmd/compile/internal/types2/sizeof_test.go
src/cmd/compile/internal/types2/universe.go
src/go/types/check.go
src/go/types/cycles.go
src/go/types/decl.go
src/go/types/object.go
src/go/types/scope.go
src/go/types/sizeof_test.go
src/go/types/universe.go