mirror of
https://github.com/golang/go.git
synced 2025-05-07 16:43:03 +00:00
If value is a non-empty interface and has shape, we still need to convert it to an interface{} first. Fixes #53587 Change-Id: I516063ba4429a6cc24c483758387ec13815fc63e Reviewed-on: https://go-review.googlesource.com/c/go/+/414834 Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/414835
35 lines
569 B
Go
35 lines
569 B
Go
// run -gcflags=-G=3
|
|
|
|
// 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.
|
|
|
|
// Test that generic interface-interface comparisons resulting from
|
|
// value switch statements are handled correctly.
|
|
|
|
package main
|
|
|
|
func main() {
|
|
f[X](0)
|
|
}
|
|
|
|
type Mer[T any] interface{ M(T) }
|
|
type MNer[T any] interface {
|
|
Mer[T]
|
|
N()
|
|
}
|
|
|
|
type X int
|
|
|
|
func (X) M(X) {}
|
|
func (X) N() {}
|
|
|
|
func f[T MNer[T]](t T) {
|
|
switch Mer[T](t) {
|
|
case MNer[T](t):
|
|
// ok
|
|
default:
|
|
panic("FAIL")
|
|
}
|
|
}
|