Source file test/typeparam/issue48049.go

     1  // run
     2  
     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.
     6  
     7  package main
     8  
     9  func main() {
    10  	Gooer2[byte]()
    11  }
    12  
    13  type Fooer[T any] interface {
    14  	Foo(p T)
    15  }
    16  
    17  type fooer1[T any] struct{}
    18  
    19  func (fooer1[T]) Foo(T) {}
    20  
    21  type fooer2[T any] struct {
    22  	r []Fooer[T]
    23  }
    24  
    25  //go:noinline
    26  func (mr fooer2[T]) Foo(p T) {
    27  	mr.r[0] = fooer1[T]{}
    28  	return
    29  }
    30  
    31  func Gooer2[T any]() Fooer[T] {
    32  	return fooer2[T]{}
    33  }
    34  

View as plain text