Source file test/fixedbugs/issue81089.go

     1  // run
     2  
     3  // Copyright 2026 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.
     6  
     7  package main
     8  
     9  type Conn interface{ Hello() }
    10  type Pool[T Conn] struct{}
    11  
    12  func (p *Pool[T]) Hello(conn T) { conn.Hello() }
    13  
    14  type PoolConn struct{ Conn }
    15  type CustomConn struct{}
    16  
    17  func (p CustomConn) Hello() { called = true }
    18  
    19  func NewPool[T Conn]() *Pool[T] { return &Pool[T]{} }
    20  
    21  var called bool
    22  
    23  func main() {
    24  	NewPool[*PoolConn]().Hello(&PoolConn{Conn: CustomConn{}})
    25  	if !called {
    26  		panic("the embedded interface method Hello was not called")
    27  	}
    28  }
    29  

View as plain text