Source file test/typeparam/issue49246.dir/a.go

     1  // Copyright 2021 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package a
     6  
     7  type R[T any] struct{ v T }
     8  
     9  func (r R[T]) Self() R[T] { return R[T]{} }
    10  
    11  type Fn[T any] func() R[T]
    12  
    13  func X() (r R[int]) { return r.Self() }
    14  
    15  func Y[T any](a Fn[T]) Fn[int] {
    16  	return func() (r R[int]) {
    17  		// No crash: return R[int]{}
    18  		return r.Self()
    19  	}
    20  }
    21  

View as plain text