]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: make Identical(nil, T) == Identical(T, nil)
authorAlan Donovan <adonovan@google.com>
Thu, 7 Apr 2016 14:07:10 +0000 (10:07 -0400)
committerAlan Donovan <adonovan@google.com>
Thu, 7 Apr 2016 14:21:18 +0000 (14:21 +0000)
Fixes #15173

Change-Id: I353756f7bc36db0d2b24d40c80771481b7b18f6b
Reviewed-on: https://go-review.googlesource.com/21585
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

src/go/types/api_test.go
src/go/types/predicates.go

index c2feed3813eb43e9eba2987e9b68da3c681f7cc3..9573d80a17dc8af554a2c99f4b83fae42e44ae7d 100644 (file)
@@ -1042,3 +1042,20 @@ func f() {
                }
        }
 }
+
+func TestIdentical_issue15173(t *testing.T) {
+       // Identical should allow nil arguments and be symmetric.
+       for _, test := range []struct {
+               x, y Type
+               want bool
+       }{
+               {Typ[Int], Typ[Int], true},
+               {Typ[Int], nil, false},
+               {nil, Typ[Int], false},
+               {nil, nil, true},
+       } {
+               if got := Identical(test.x, test.y); got != test.want {
+                       t.Errorf("Identical(%v, %v) = %t", test.x, test.y, got)
+               }
+       }
+}
index 993c6d290b13ad06439c119ab9ffdd91e5037f71..5509069fb63ecd64bb4be099212b62c876de1906 100644 (file)
@@ -277,6 +277,8 @@ func identical(x, y Type, p *ifacePair) bool {
                        return x.obj == y.obj
                }
 
+       case nil:
+
        default:
                unreachable()
        }