Source file test/typeparam/issue49659b.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  // Testing that AddrTaken logic doesn't cause problems for function instantiations
     8  
     9  package main
    10  
    11  type A[T interface{ []int | [5]int }] struct {
    12  	val T
    13  }
    14  
    15  //go:noinline
    16  func (a A[T]) F() {
    17  	_ = &a.val[2]
    18  }
    19  
    20  func main() {
    21  	var x A[[]int]
    22  	x.val = make([]int, 4)
    23  	_ = &x.val[3]
    24  	x.F()
    25  	var y A[[5]int]
    26  	_ = &y.val[3]
    27  	y.F()
    28  }
    29  

View as plain text