]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile/internal/types2: merge Instantiate and InstantiateLazy
authorRob Findley <rfindley@google.com>
Tue, 10 Aug 2021 18:00:56 +0000 (14:00 -0400)
committerRobert Findley <rfindley@google.com>
Sat, 14 Aug 2021 15:14:35 +0000 (15:14 +0000)
commitfc27eb50ffcada3d4f5e7e00a5c120f474cc0da4
tree5e83de648776a3b1b1654774814b723d8e662d0b
parent7eaabae84d8b69216356b84ebc7c86917100f99a
cmd/compile/internal/types2: merge Instantiate and InstantiateLazy

Instantiate and InstantiateLazy have the same signature; on first
principles, if Instantiate should work for importers it should be
possible to consolidate these APIs.

This CL does this. In order to make it work, a typMap needs to be
threaded through type expansion to prevent infinite recursion in the
case that the Checker is nil.

Notably, Named types now must be expanded before returning from
Underlying(). This makes Underlying generally unsafe to call while type
checking a package, so a helper function safeUnderlying is added to
provide the previous behavior. This is probably overly conservative at
most call sites, but cleanup is deferred to a later CL.

Change-Id: I03cfb75bea0750862cd6eea4e3cdc875a7daa989
Reviewed-on: https://go-review.googlesource.com/c/go/+/341855
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
15 files changed:
src/cmd/compile/internal/noder/reader2.go
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/call.go
src/cmd/compile/internal/types2/decl.go
src/cmd/compile/internal/types2/expr.go
src/cmd/compile/internal/types2/infer.go
src/cmd/compile/internal/types2/instantiate.go
src/cmd/compile/internal/types2/lookup.go
src/cmd/compile/internal/types2/named.go
src/cmd/compile/internal/types2/predicates.go
src/cmd/compile/internal/types2/signature.go
src/cmd/compile/internal/types2/subst.go
src/cmd/compile/internal/types2/type.go
src/cmd/compile/internal/types2/typexpr.go
src/cmd/compile/internal/types2/unify.go