mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
a991d9dc27
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>
23 lines
418 B
Go
23 lines
418 B
Go
// Copyright 2022 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package a
|
|
|
|
func Marshal[foobar any]() {
|
|
_ = NewEncoder[foobar]()
|
|
}
|
|
|
|
func NewEncoder[foobar any]() *Encoder[foobar] {
|
|
return nil
|
|
}
|
|
|
|
type Encoder[foobar any] struct {
|
|
}
|
|
|
|
func (e *Encoder[foobar]) EncodeToken(t Token[foobar]) {
|
|
|
|
}
|
|
|
|
type Token[foobar any] any
|