cmd/compile/internal/syntax: actually collect type list types (fix bug)

The existing code collected empty fields. Collect the actual
field and added type string test.

(This was not found before because the generic tests are still
disabled in this port because of different position information.)

Change-Id: I959711892aac3c8f7587a4025c4b32f1598f5df3
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go2-dev/+/756088
Reviewed-by: Robert Griesemer <gri@google.com>
This commit is contained in:
Robert Griesemer 2020-05-27 20:46:21 -07:00
parent 8355f8a9ee
commit cb7d43b2ea
3 changed files with 4 additions and 27 deletions

View File

@ -1370,13 +1370,13 @@ func (p *parser) interfaceType() *InterfaceType {
f.pos = p.pos()
f.Name = type_
f.Type = p.type_(true)
typ.MethodList = append(typ.MethodList, &Field{})
typ.MethodList = append(typ.MethodList, f)
for p.got(_Comma) {
f := new(Field)
f.pos = p.pos()
f.Name = type_
f.Type = p.type_(true)
typ.MethodList = append(typ.MethodList, &Field{})
typ.MethodList = append(typ.MethodList, f)
}
}

View File

@ -1,25 +1,3 @@
package p
type B(type P) interface{}
func _f(type P B)() {}
// These are only ok if AcceptContracts = false.
// (The comparable contract cannot be embedded in Bound.)
/*
func _(type T comparable)(x, y T) bool {
return x == y || x != y
}
type Bound interface {
comparable
}
func _(type T Bound)(x, y T) bool {
return x == y || x != y
}
func _(type A, B Bound)(a1, a2 A, b1, b2 B) bool {
return a1 == a2 || b1 != b2
}
*/
type T interface{type int}

View File

@ -15,7 +15,6 @@ import (
const filename = "<src>"
func makePkg(src string) (*Package, error) {
//file, err := parser.ParseFile(fset, filename, src, parser.DeclarationErrors)
file, err := parseSrc(filename, src)
if err != nil {
return nil, err
@ -92,7 +91,7 @@ var independentTestTypes = []testEntry{
dup("interface{}"),
dup("interface{m()}"),
dup(`interface{String() string; m(int) float32}`),
// dup(`interface{type int, float32, complex128}`), // TODO(gri) fix this
dup(`interface{type int, float32, complex128}`),
// maps
dup("map[string]int"),