]> Cypherpunks repositories - gostls13.git/commit
go/types, types: represent any using Alias
authorRob Findley <rfindley@google.com>
Fri, 19 Apr 2024 14:51:18 +0000 (14:51 +0000)
committerRobert Findley <rfindley@google.com>
Tue, 7 May 2024 20:08:23 +0000 (20:08 +0000)
commit4ed358b57efdad9ed710be7f4fc51495a7620ce2
treec7b0c3c3dfd03eaf7ad45fe26377fb442afb35c6
parent9c5269c2530162fd898e81c3eb12b98cef01d6a5
go/types, types: represent any using Alias

When GODEBUG=gotypesalias=1 is set, use an actual Alias type to
represent any, rather than a legacy alias representation. This makes any
consistent with other interface aliases, and will eventually make
obsolete the various workarounds for formatting any as 'any' rather than
'interface{}'.

Since any is a global in the Universe scope, we must hijack Scope.Lookup
to select the correct representation. Of course, this also means that we
can't support type checking concurrently while mutating gotypesalias
(or, in the case of types2, Config.EnableAlias). Some care is taken to
ensure that the type checker panics in the event of this type of misuse.

For now, we must still support the legacy representation of any, and the
existing workarounds that look for a distinguished any pointer. This is
done by ensuring that both representations have the same underlying
pointer, and by updating workarounds to consider Underlying.

Fixes golang/go#66921

Change-Id: I81db7e8e15317b7a6ed3b406545db15a2fc42f57
Reviewed-on: https://go-review.googlesource.com/c/go/+/580355
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
23 files changed:
src/cmd/compile/internal/importer/iimport.go
src/cmd/compile/internal/importer/support.go
src/cmd/compile/internal/noder/writer.go
src/cmd/compile/internal/types2/api.go
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/check.go
src/cmd/compile/internal/types2/issues_test.go
src/cmd/compile/internal/types2/object.go
src/cmd/compile/internal/types2/scope.go
src/cmd/compile/internal/types2/typestring.go
src/cmd/compile/internal/types2/typexpr.go
src/cmd/compile/internal/types2/universe.go
src/go/internal/gcimporter/iimport.go
src/go/internal/gcimporter/support.go
src/go/types/api.go
src/go/types/api_test.go
src/go/types/check.go
src/go/types/issues_test.go
src/go/types/object.go
src/go/types/scope.go
src/go/types/typestring.go
src/go/types/typexpr.go
src/go/types/universe.go