Source file test/typeparam/issue48137.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  type Constraint[T any] interface {
    10  	~func() T
    11  }
    12  
    13  func Foo[T Constraint[T]]() T {
    14  	var t T
    15  
    16  	t = func() T {
    17  		return t
    18  	}
    19  	return t
    20  }
    21  
    22  func main() {
    23  	type Bar func() Bar
    24  	Foo[Bar]()
    25  }
    26  

View as plain text