]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: some fixes in type substituter for Instantiate
authorDan Scales <danscales@google.com>
Mon, 4 Oct 2021 18:56:12 +0000 (11:56 -0700)
committerDan Scales <danscales@google.com>
Tue, 12 Oct 2021 20:09:58 +0000 (20:09 +0000)
commit4186db6155ccd4cfcf71dee0bce566a097f49406
treed4fe88bf69d0f05deb813a90f34fde988ac5a26c
parent26b6833308548f78a0926309c3acf7fd59b287f5
cmd/compile: some fixes in type substituter for Instantiate

In the case in (*TSubster).Type() that we were running into an
incomplete underlying type (TFORW), we should just be immediately
returning the type returned by ts.SubstForwFunc(forw), since that call
returns a proper type node, and has set up any remaining work that has
to be done when we get done with the current top-level type definition.
(For import, that function is doInst, which does an Instantiate of the
new substituted type, with the delayed part via deferredInstStack.) We
should not continue doing the later parts of (*TSubster).Type(), since
the underlying type may not yet have its methods filled in, etc.

Also, in Instantiate(), we need to put the desired new type on
deferredInstStack, even if the base type node already exists, if the
type node is in TFORW state. This is now exactly the case when
Instantiate is called from (*TSubster).Type via doInst, since
(*TSubster).Type has already called NewIncompleteNamedType().

Fixes #48716
Fixes #48889

Change-Id: Icd6be5721c4ac75bf8869b8bbdeca50069d632ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/355250
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/typecheck/iimport.go
src/cmd/compile/internal/typecheck/subr.go
test/typeparam/issue48716.dir/a.go [new file with mode: 0644]
test/typeparam/issue48716.dir/main.go [new file with mode: 0644]
test/typeparam/issue48716.go [new file with mode: 0644]