mirror of
https://github.com/golang/go
synced 2024-09-30 22:08:32 -06:00
reflect: recognize unnamed directional channels
go test github.com/onsi/gomega/gbytes now passes at tip, and tests added to the reflect package. Fixes #14645 Change-Id: I16216c1a86211a1103d913237fe6bca5000cf885 Reviewed-on: https://go-review.googlesource.com/20221 Run-TryBot: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
4c69e92f51
commit
69285a8b46
@ -5019,6 +5019,8 @@ var nameTests = []nameTest{
|
|||||||
{[]D1{}, ""},
|
{[]D1{}, ""},
|
||||||
{(chan D1)(nil), ""},
|
{(chan D1)(nil), ""},
|
||||||
{(func() D1)(nil), ""},
|
{(func() D1)(nil), ""},
|
||||||
|
{(<-chan D1)(nil), ""},
|
||||||
|
{(chan<- D1)(nil), ""},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNames(t *testing.T) {
|
func TestNames(t *testing.T) {
|
||||||
|
@ -194,11 +194,13 @@ var assignableTests = []struct {
|
|||||||
{new(*int), new(IntPtr), true},
|
{new(*int), new(IntPtr), true},
|
||||||
{new(IntPtr), new(*int), true},
|
{new(IntPtr), new(*int), true},
|
||||||
{new(IntPtr), new(IntPtr1), false},
|
{new(IntPtr), new(IntPtr1), false},
|
||||||
|
{new(Ch), new(<-chan interface{}), true},
|
||||||
// test runs implementsTests too
|
// test runs implementsTests too
|
||||||
}
|
}
|
||||||
|
|
||||||
type IntPtr *int
|
type IntPtr *int
|
||||||
type IntPtr1 *int
|
type IntPtr1 *int
|
||||||
|
type Ch <-chan interface{}
|
||||||
|
|
||||||
func TestAssignableTo(t *testing.T) {
|
func TestAssignableTo(t *testing.T) {
|
||||||
for _, tt := range append(assignableTests, implementsTests...) {
|
for _, tt := range append(assignableTests, implementsTests...) {
|
||||||
|
@ -563,10 +563,14 @@ func (t *rtype) Name() string {
|
|||||||
if hasPrefix(t.string, "chan ") {
|
if hasPrefix(t.string, "chan ") {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
if hasPrefix(t.string, "chan<-") {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
if hasPrefix(t.string, "func(") {
|
if hasPrefix(t.string, "func(") {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if t.string[0] == '[' || t.string[0] == '*' {
|
switch t.string[0] {
|
||||||
|
case '[', '*', '<':
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
i := len(t.string) - 1
|
i := len(t.string) - 1
|
||||||
|
@ -42,10 +42,14 @@ func (t *_type) name() string {
|
|||||||
if hasPrefix(t._string, "chan ") {
|
if hasPrefix(t._string, "chan ") {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
if hasPrefix(t._string, "chan<-") {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
if hasPrefix(t._string, "func(") {
|
if hasPrefix(t._string, "func(") {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
if t._string[0] == '[' || t._string[0] == '*' {
|
switch t._string[0] {
|
||||||
|
case '[', '*', '<':
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
i := len(t._string) - 1
|
i := len(t._string) - 1
|
||||||
|
Loading…
Reference in New Issue
Block a user