mirror of
https://github.com/golang/go
synced 2024-10-06 08:00:07 +00:00
go/types, types2: remove incorrect assertion (don't crash)
The removed assertion was never incorrect, as signatures may be from methods in interfaces, and (some) interfaces set the receivers of their methods (so we have a position for error reporting). This CL changes the issue below from a release blocker to an issue for Go 1.19. For #51593. Change-Id: I0c5f2913b397b9ab557ed74a80cc7a715e840412 Reviewed-on: https://go-review.googlesource.com/c/go/+/391615 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
2e46a0a997
commit
914195c132
|
@ -739,8 +739,6 @@ func (w *cycleFinder) typ(typ Type) {
|
|||
// in signatures where they are handled explicitly.
|
||||
|
||||
case *Signature:
|
||||
// There are no "method types" so we should never see a recv.
|
||||
assert(t.recv == nil)
|
||||
if t.params != nil {
|
||||
w.varList(t.params.vars)
|
||||
}
|
||||
|
|
13
src/cmd/compile/internal/types2/testdata/fixedbugs/issue51593.go2
vendored
Normal file
13
src/cmd/compile/internal/types2/testdata/fixedbugs/issue51593.go2
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2022 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
|
||||
|
||||
func f[P interface{ m(R) }, R any]() {}
|
||||
|
||||
type T = interface { m(int) }
|
||||
|
||||
func _() {
|
||||
_ = f[ /* ERROR cannot infer R */ T] // don't crash in type inference
|
||||
}
|
|
@ -738,8 +738,6 @@ func (w *cycleFinder) typ(typ Type) {
|
|||
// in signatures where they are handled explicitly.
|
||||
|
||||
case *Signature:
|
||||
// There are no "method types" so we should never see a recv.
|
||||
assert(t.recv == nil)
|
||||
if t.params != nil {
|
||||
w.varList(t.params.vars)
|
||||
}
|
||||
|
|
13
src/go/types/testdata/fixedbugs/issue51593.go2
vendored
Normal file
13
src/go/types/testdata/fixedbugs/issue51593.go2
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2022 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
|
||||
|
||||
func f[P interface{ m(R) }, R any]() {}
|
||||
|
||||
type T = interface { m(int) }
|
||||
|
||||
func _() {
|
||||
_ = f /* ERROR cannot infer R */ [T] // don't crash in type inference
|
||||
}
|
Loading…
Reference in a new issue