]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] go/types: fix the type parameter index in applyTypeFunc
authorRob Findley <rfindley@google.com>
Fri, 11 Jun 2021 16:40:42 +0000 (12:40 -0400)
committerRobert Findley <rfindley@google.com>
Mon, 19 Jul 2021 17:42:35 +0000 (17:42 +0000)
We should preserve type parameter indices when transforming them using
applyTypeFunc.

Change-Id: Ib75f5cf1a146bd7e6850368fa954c1affcba3ad1
Reviewed-on: https://go-review.googlesource.com/c/go/+/327269
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/compile/internal/types2/builtins.go
src/go/types/builtins.go

index 1f7eb23cdf0cd7ea6a6ec3df2e4d4ab2ef6f142d..14be24e2514be0360859ac17a2207e9df9a31727 100644 (file)
@@ -802,7 +802,7 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x Type) Type {
                // type param is placed in the current package so export/import
                // works as expected.
                tpar := NewTypeName(nopos, check.pkg, "<type parameter>", nil)
-               ptyp := check.NewTypeParam(tpar, 0, &emptyInterface) // assigns type to tpar as a side-effect
+               ptyp := check.NewTypeParam(tpar, tp.index, &emptyInterface) // assigns type to tpar as a side-effect
                tsum := newUnion(rtypes, tildes)
                ptyp.bound = &Interface{complete: true, tset: &TypeSet{types: tsum}}
 
index eb3503fd6b5533631bf907a7ca2f1b1b28d72e85..2edf90116540407503f89219354ed86ad56121be 100644 (file)
@@ -806,7 +806,7 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x Type) Type {
                // type param is placed in the current package so export/import
                // works as expected.
                tpar := NewTypeName(token.NoPos, check.pkg, "<type parameter>", nil)
-               ptyp := check.NewTypeParam(tpar, 0, &emptyInterface) // assigns type to tpar as a side-effect
+               ptyp := check.NewTypeParam(tpar, tp.index, &emptyInterface) // assigns type to tpar as a side-effect
                tsum := newUnion(rtypes, tildes)
                ptyp.bound = &Interface{complete: true, tset: &TypeSet{types: tsum}}