mirror of
https://github.com/golang/go
synced 2024-11-17 13:54:46 -07:00
cfd0868fc3
The delayTransform only checks whether ir.CurFunc is generic function or not. but when compiling a non-generic closure inside a generic function, we also want to delay the transformation, which delayTransform fails to detect, since when ir.CurFunc is the closure, not the top level function. Instead, we must rely on irgen.topFuncIsGeneric field to decide whether to delay the transformation, the same logic with what is being done for not adding closure inside a generic function to g.target.Decls list. Fixes #48609 Change-Id: I5bf5592027d112fe8b19c92eb906add424c46507 Reviewed-on: https://go-review.googlesource.com/c/go/+/351855 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Dan Scales <danscales@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
19 lines
330 B
Go
19 lines
330 B
Go
// compile -G=3
|
|
|
|
// Copyright 2021 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package p
|
|
|
|
import "constraints"
|
|
|
|
func f[T constraints.Chan[E], E any](e E) T {
|
|
ch := make(T)
|
|
go func() {
|
|
defer close(ch)
|
|
ch <- e
|
|
}()
|
|
return ch
|
|
}
|