]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: recognize unnamed directional channels
authorDavid Crawshaw <crawshaw@golang.org>
Fri, 4 Mar 2016 19:53:26 +0000 (14:53 -0500)
committerDavid Crawshaw <crawshaw@golang.org>
Fri, 4 Mar 2016 20:34:30 +0000 (20:34 +0000)
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>
src/reflect/all_test.go
src/reflect/set_test.go
src/reflect/type.go
src/runtime/type.go

index 5df228db1acd71b54a11e3e7d0fc9f25ef747e11..352b2046e7c0811cc84ec4b8e36b6baee41a5c9f 100644 (file)
@@ -5019,6 +5019,8 @@ var nameTests = []nameTest{
        {[]D1{}, ""},
        {(chan D1)(nil), ""},
        {(func() D1)(nil), ""},
+       {(<-chan D1)(nil), ""},
+       {(chan<- D1)(nil), ""},
 }
 
 func TestNames(t *testing.T) {
index a3b5af55c7f4845383147a0044a640586133dd36..bc35c78e1bb3964de047de147a3a5100411338ee 100644 (file)
@@ -194,11 +194,13 @@ var assignableTests = []struct {
        {new(*int), new(IntPtr), true},
        {new(IntPtr), new(*int), true},
        {new(IntPtr), new(IntPtr1), false},
+       {new(Ch), new(<-chan interface{}), true},
        // test runs implementsTests too
 }
 
 type IntPtr *int
 type IntPtr1 *int
+type Ch <-chan interface{}
 
 func TestAssignableTo(t *testing.T) {
        for _, tt := range append(assignableTests, implementsTests...) {
index dd8084ed0f666062f7124708b1f3a17bda684883..425b27588173d3a3701986583ea5e99278d75dd0 100644 (file)
@@ -563,10 +563,14 @@ func (t *rtype) Name() string {
        if hasPrefix(t.string, "chan ") {
                return ""
        }
+       if hasPrefix(t.string, "chan<-") {
+               return ""
+       }
        if hasPrefix(t.string, "func(") {
                return ""
        }
-       if t.string[0] == '[' || t.string[0] == '*' {
+       switch t.string[0] {
+       case '[', '*', '<':
                return ""
        }
        i := len(t.string) - 1
index 18c6a32ecba710cbbbbb8b53bc9f52adc39a6a1b..2312f819ea0db2a4cb334a99407c2cd9d2e20654 100644 (file)
@@ -42,10 +42,14 @@ func (t *_type) name() string {
        if hasPrefix(t._string, "chan ") {
                return ""
        }
+       if hasPrefix(t._string, "chan<-") {
+               return ""
+       }
        if hasPrefix(t._string, "func(") {
                return ""
        }
-       if t._string[0] == '[' || t._string[0] == '*' {
+       switch t._string[0] {
+       case '[', '*', '<':
                return ""
        }
        i := len(t._string) - 1