Commit ec75230b authored by Ross Light's avatar Ross Light Committed by Ian Lance Taylor

reflect: document equality guarantee for Type

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/27170Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 8050782c
...@@ -29,6 +29,12 @@ import ( ...@@ -29,6 +29,12 @@ import (
// Use the Kind method to find out the kind of type before // Use the Kind method to find out the kind of type before
// calling kind-specific methods. Calling a method // calling kind-specific methods. Calling a method
// inappropriate to the kind of type causes a run-time panic. // 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 { type Type interface {
// Methods applicable to all types. // Methods applicable to all types.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment