1
0
mirror of https://github.com/golang/go synced 2024-07-05 09:50:19 +00:00
go/test/typeparam/issue49497.dir/a.go
Dan Scales 229b909313 cmd/compile: don't do Resolve on OKEY identifiers during import
For generic functions, we can export untransformed OKEY nodes, and the
key identifier is written as an ONONAME. But in this case, we do not
want to call Resolve() on the identifier, since we may resolve to a
global type (as happens in this issue) or other global symbol with the
same name, if it exists. We just want to keep the key identifier as an
Ident node.

To solve this, I added an extra bool when exporting an ONONAME entry,
which indicates if this entry is for a key or for a global (external)
symbol. When the bool is true (this is for a key), we avoid calling
Resolve().

Fixes #49497

Change-Id: Ic8fa93d37bcad2110e0e0d060080b733e07e35d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/363074
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-11-10 21:53:03 +00:00

27 lines
365 B
Go

// 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 a
func F[T any]() A[T] {
var x A[T]
return x
}
type A[T any] struct {
b B[T]
}
func (a A[T]) M() C[T] {
return C[T]{
B: a.b,
}
}
type B[T any] struct{}
type C[T any] struct {
B B[T]
}