Source file test/typeparam/issue53419.go

     1  // run
     2  
     3  // Copyright 2022 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 T1 struct{}
    10  type T2 struct{}
    11  type Both struct {
    12  	T1
    13  	T2
    14  }
    15  
    16  func (T1) m()   { panic("FAIL") }
    17  func (T2) m()   { panic("FAIL") }
    18  func (Both) m() {}
    19  
    20  func f[T interface{ m() }](c T) {
    21  	c.m()
    22  }
    23  
    24  func main() {
    25  	var b Both
    26  	b.m()
    27  	f(b)
    28  }
    29  

View as plain text