]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: document equality guarantee for Type
authorRoss Light <light@google.com>
Tue, 16 Aug 2016 18:10:36 +0000 (11:10 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 23 Aug 2016 23:20:48 +0000 (23:20 +0000)
The only previous mention of this property was in the String() method.
Since this is the only way to uniquely identify a type and we can't
change this property without breaking the Go 1 guarantee, it seems
better to document this property than hiding it on a method.

Fixes #16348

Change-Id: I3d25f7d6e6007e3c15c2e13010869888d0181fc2
Reviewed-on: https://go-review.googlesource.com/27170
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/reflect/type.go

index 891671017af0f864f0f3fe15fdf33162ca8350f9..94c5d020c6a4cf56061f4be02acd3c0d72e1c6e5 100644 (file)
@@ -29,6 +29,12 @@ import (
 // Use the Kind method to find out the kind of type before
 // calling kind-specific methods. Calling a method
 // inappropriate to the kind of type causes a run-time panic.
+//
+// You can use == with reflect.Type values to check whether two types
+// are the same.  If T1 and T2 are Go types, and v1 and v2 are values of
+// those types respectively, then reflect.TypeOf(v1) == reflect.TypeOf(v2)
+// if and only if both (interface{})(v2).(T1) and (interface{})(v1).(T2)
+// succeed.
 type Type interface {
        // Methods applicable to all types.