go/test/typeparam/issue53477.go
Cuong Manh Le f86c6b9a32 [release-branch.go1.18] cmd/compile: fix generic inter-inter comparisons from value switch statements
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
2022-07-06 19:33:49 +00:00

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")
}
}