]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: add missing shape check in (*Tsubster).tinter
authorDan Scales <danscales@google.com>
Thu, 27 Jan 2022 01:58:08 +0000 (17:58 -0800)
committerDan Scales <danscales@google.com>
Thu, 27 Jan 2022 05:30:27 +0000 (05:30 +0000)
commita991d9dc27bda23018e23488806c8f8d027e4f7b
treef441100f1575e22ced15c4c411ef7d7156c633c5
parentf4aa021985e9ae4a9a395f8fbe32ad08d2bfda3b
cmd/compile: add missing shape check in (*Tsubster).tinter

Add a missing shape check in (*Tsubster).tinter when substituting on a
generic type which is an empty interface, analogous to same check in
(*Tsubster).tstruct. Empty structs/interfaces that have rparams (i.e.
are a generic type or a shape type) need to get a new type of their
rparams - they will be different even though they don't have any
fields/methods. Without this shape check, we were not correctly
completing the Token[int] type during substitution in the example in the
issue. This issue only happens for a generic type which is an empty
interface (i.e. doesn't actually use the type param, hence quite unusual).

Added the test case already created by Keith.

Fixes #50841

Change-Id: Ia985b9f52c0e87ed0647b46373e44c51cb748ba4
Reviewed-on: https://go-review.googlesource.com/c/go/+/381175
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/typecheck/subr.go
test/typeparam/issue50841.dir/a.go [new file with mode: 0644]
test/typeparam/issue50841.dir/b.go [new file with mode: 0644]
test/typeparam/issue50841.go [new file with mode: 0644]