diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index 29633028f3..e131077371 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -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) } diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue51593.go2 b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue51593.go2 new file mode 100644 index 0000000000..d323618ee8 --- /dev/null +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue51593.go2 @@ -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 +} diff --git a/src/go/types/infer.go b/src/go/types/infer.go index 429510291e..6bed55c270 100644 --- a/src/go/types/infer.go +++ b/src/go/types/infer.go @@ -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) } diff --git a/src/go/types/testdata/fixedbugs/issue51593.go2 b/src/go/types/testdata/fixedbugs/issue51593.go2 new file mode 100644 index 0000000000..e06c39fac0 --- /dev/null +++ b/src/go/types/testdata/fixedbugs/issue51593.go2 @@ -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 +}