]> Cypherpunks.ru repositories - gostls13.git/commit
go/types, types2: remove Named.once in favor of monotonic state
authorRobert Findley <rfindley@google.com>
Sun, 15 May 2022 23:31:42 +0000 (19:31 -0400)
committerRobert Findley <rfindley@google.com>
Mon, 6 Jun 2022 15:15:21 +0000 (15:15 +0000)
commit846f971daa03fda149a3d66a3fda6eb6a2a7484e
tree6c84a7c69e6a8f9f3299b36dd585504034af58b0
parent66cbf67345b1631adbee2109f5bb78fb4e321144
go/types, types2: remove Named.once in favor of monotonic state

Introduce a monotonic state variable to track the lifecycle of a named
type, replacing the existing sync.Once. Having a single guard for the
state of underlying and methods will allow for cleaning-up when the type
is fully expanded. In the future, this state may also be used for
detecting access to information such as underlying or methods before the
type is fully set-up, though that will require rethinking our
type-checking of invalid cyclic types.

Also remove support for type-type inference. If we ever support this
feature in the future (inference of missing type arguments for named
type instances), it will likely involve additional machinery that does
not yet exist. Remove the current partial support to simplify our
internal APIs. In particular, this means that Named.resolver is only
used for lazy loading. As a result, we can revert the lazy loader
signature to its previous form.

A lot of exposition is added for how Named types work. Along the way,
the terminology we use to describe them is refined.

Some microbenchmarks are added that were useful in evaluating the
tradeoffs between synchronization mechanisms.

Updates #52728

Change-Id: I4e147360bc6e5d8cd4f37e32e86fece0530a6480
Reviewed-on: https://go-review.googlesource.com/c/go/+/404875
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
14 files changed:
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/decl.go
src/cmd/compile/internal/types2/instantiate.go
src/cmd/compile/internal/types2/named.go
src/cmd/compile/internal/types2/named_test.go [new file with mode: 0644]
src/cmd/compile/internal/types2/object.go
src/cmd/compile/internal/types2/typexpr.go
src/go/types/api_test.go
src/go/types/decl.go
src/go/types/instantiate.go
src/go/types/named.go
src/go/types/named_test.go [new file with mode: 0644]
src/go/types/object.go
src/go/types/typexpr.go