1
0
mirror of https://github.com/golang/go synced 2024-11-11 21:20:21 -07:00

cmd/compile: fix function contains no TParam in generic function

Fixes #47948

Change-Id: I446a9548265d195ae4d88aff6b1361474d1b6214
Reviewed-on: https://go-review.googlesource.com/c/go/+/344910
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
This commit is contained in:
korzhao 2021-08-25 16:01:49 +08:00 committed by Dan Scales
parent 4f2ebfe34b
commit 3d667671ad
2 changed files with 20 additions and 1 deletions

View File

@ -1051,7 +1051,8 @@ func (ts *Tsubster) typ1(t *types.Type) *types.Type {
var targsChanged bool var targsChanged bool
var forw *types.Type var forw *types.Type
if t.Sym() != nil { if t.Sym() != nil && t.HasTParam() {
// Need to test for t.HasTParam() again because of special TFUNC case above.
// Translate the type params for this type according to // Translate the type params for this type according to
// the tparam/targs mapping from subst. // the tparam/targs mapping from subst.
neededTargs = make([]*types.Type, len(t.RParams())) neededTargs = make([]*types.Type, len(t.RParams()))

View File

@ -0,0 +1,18 @@
// 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 main
type fun func()
func F[T any]() {
_ = fun(func() {
})
}
func main() {
F[int]()
}