3 // Copyright 2021 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Make sure we handle instantiated empty interfaces.
11 type E[T any] interface {
15 func f[T any](x E[T]) interface{} {
20 func g[T any](x interface{}) E[T] {
24 type I[T any] interface {
30 func (x myint) foo() {}
33 func h[T any](x I[T]) interface{ foo() } {
38 func i[T any](x interface{ foo() }) I[T] {
44 println("test 1 failed")
46 if f[int](2) != (interface{})(2) {
47 println("test 2 failed")
50 println("test 3 failed")
52 if g[int](4) != (E[int])(4) {
53 println("test 4 failed")
55 if h[int](myint(5)) != myint(5) {
56 println("test 5 failed")
58 if h[int](myint(6)) != interface{ foo() }(myint(6)) {
59 println("test 6 failed")
61 if i[int](myint(7)) != myint(7) {
62 println("test 7 failed")
64 if i[int](myint(8)) != I[int](myint(8)) {
65 println("test 8 failed")