mirror of
https://github.com/golang/go
synced 2024-11-11 20:40:21 -07:00
cmd/compile: prevent typecheck importer reading type parameter twice
This is a port of CL 349009 to typecheck importer. Fixes #48306 Change-Id: Iec3f078089346bd85f0ab739896e079940325011 Reviewed-on: https://go-review.googlesource.com/c/go/+/349011 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>
This commit is contained in:
parent
2953cd0083
commit
ee91bb8319
@ -316,16 +316,12 @@ func (r *importReader) doDecl(sym *types.Sym) *ir.Name {
|
||||
return n
|
||||
|
||||
case 'T', 'U':
|
||||
var rparams []*types.Type
|
||||
if tag == 'U' {
|
||||
rparams = r.typeList()
|
||||
}
|
||||
|
||||
// Types can be recursive. We need to setup a stub
|
||||
// declaration before recursing.
|
||||
n := importtype(pos, sym)
|
||||
t := n.Type()
|
||||
if tag == 'U' {
|
||||
rparams := r.typeList()
|
||||
t.SetRParams(rparams)
|
||||
}
|
||||
|
||||
|
@ -167,8 +167,6 @@ func TestImportTypeparamTests(t *testing.T) {
|
||||
skip := map[string]string{
|
||||
"equal.go": "inconsistent embedded sorting", // TODO(rfindley): investigate this.
|
||||
"nested.go": "fails to compile", // TODO(rfindley): investigate this.
|
||||
|
||||
"issue46461.go": "known issue with type parameter constraints referring back to parameterized type",
|
||||
}
|
||||
|
||||
for _, entry := range list {
|
||||
|
@ -2188,8 +2188,6 @@ var g3Failures = setOf(
|
||||
|
||||
"typeparam/nested.go", // -G=3 doesn't support function-local types with generics
|
||||
|
||||
"typeparam/issue46461b.go", // -G=3 fails when type parameters refer back to the parameterized type itself
|
||||
|
||||
"typeparam/mdempsky/4.go", // -G=3 can't export functions with labeled breaks in loops
|
||||
)
|
||||
|
||||
|
9
test/typeparam/issue48306.dir/a.go
Normal file
9
test/typeparam/issue48306.dir/a.go
Normal file
@ -0,0 +1,9 @@
|
||||
// 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
|
||||
|
||||
type I[T I[T]] interface {
|
||||
F() T
|
||||
}
|
15
test/typeparam/issue48306.dir/main.go
Normal file
15
test/typeparam/issue48306.dir/main.go
Normal file
@ -0,0 +1,15 @@
|
||||
// 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
|
||||
|
||||
import "a"
|
||||
|
||||
type S struct{}
|
||||
|
||||
func (*S) F() *S { return nil }
|
||||
|
||||
func main() {
|
||||
var _ a.I[*S] = &S{}
|
||||
}
|
7
test/typeparam/issue48306.go
Normal file
7
test/typeparam/issue48306.go
Normal file
@ -0,0 +1,7 @@
|
||||
// rundir -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 ignored
|
Loading…
Reference in New Issue
Block a user