mirror of
https://github.com/golang/go
synced 2024-11-17 00:14:50 -07:00
go/internal/gcimporter: fix ureader.go handling of local defined types
In unified IR, local defined types are promoted to a global defined type with a "vargen" suffix. These shouldn't actually be exposed to go/types users, because they're only relevant within function bodies, which go/types doesn't support importing. Moreover, in the case of defined types that were declared within a generic function, they can have ambient type parameters, which the go/types importer doesn't know how to handle (because they shouldn't be needed for that use case). While here, prune the gcimporter_test.go skip list, because some of the listed failures have actually been fixed and all of them are specific to the Go 1.18 (nounified) frontend. They all work correctly with GOEXPERIMENT=unified. Fixes #55110. Change-Id: I7dd8b86355d910dfed1d47edbad7695144c3f84d Reviewed-on: https://go-review.googlesource.com/c/go/+/431495 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
38cecb2290
commit
29153be757
@ -173,13 +173,14 @@ func TestImportTypeparamTests(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
skip := map[string]string{
|
||||
"equal.go": "inconsistent embedded sorting", // TODO(rfindley): investigate this.
|
||||
"nested.go": "fails to compile", // TODO(rfindley): investigate this.
|
||||
"issue50417.go": "inconsistent interface member sorting",
|
||||
"issue53419.go": "fails to compile",
|
||||
"issue53477.go": "fails to compile",
|
||||
"issue55101.go": "fails to compile",
|
||||
var skip map[string]string
|
||||
if !goexperiment.Unified {
|
||||
// The Go 1.18 frontend still fails several cases.
|
||||
skip = map[string]string{
|
||||
"equal.go": "inconsistent embedded sorting", // TODO(rfindley): investigate this.
|
||||
"nested.go": "fails to compile", // TODO(rfindley): investigate this.
|
||||
"issue55101.go": "fails to compile",
|
||||
}
|
||||
}
|
||||
|
||||
for _, entry := range list {
|
||||
|
@ -167,3 +167,17 @@ type typeInfo struct {
|
||||
idx pkgbits.Index
|
||||
derived bool
|
||||
}
|
||||
|
||||
// See cmd/compile/internal/types.SplitVargenSuffix.
|
||||
func splitVargenSuffix(name string) (base, suffix string) {
|
||||
i := len(name)
|
||||
for i > 0 && name[i-1] >= '0' && name[i-1] <= '9' {
|
||||
i--
|
||||
}
|
||||
const dot = "·"
|
||||
if i >= len(dot) && name[i-len(dot):i] == dot {
|
||||
i -= len(dot)
|
||||
return name[:i], name[i:]
|
||||
}
|
||||
return name, ""
|
||||
}
|
||||
|
@ -469,6 +469,11 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
|
||||
return objPkg, objName
|
||||
}
|
||||
|
||||
// Ignore local types promoted to global scope (#55110).
|
||||
if _, suffix := splitVargenSuffix(objName); suffix != "" {
|
||||
return objPkg, objName
|
||||
}
|
||||
|
||||
if objPkg.Scope().Lookup(objName) == nil {
|
||||
dict := pr.objDictIdx(idx)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user