mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
change name of reflect.NewInitValue to the more descriptive NewZeroValue.
R=rsc DELTA=10 (0 added, 0 deleted, 10 changed) OCL=28717 CL=28720
This commit is contained in:
parent
d06a79e31b
commit
b66d703941
3 changed files with 7 additions and 7 deletions
|
|
@ -176,7 +176,7 @@ func (b *_StructBuilder) Map() {
|
||||||
if v := b.val; v.Kind() == reflect.PtrKind {
|
if v := b.val; v.Kind() == reflect.PtrKind {
|
||||||
pv := v.(reflect.PtrValue);
|
pv := v.(reflect.PtrValue);
|
||||||
if pv.Get() == nil {
|
if pv.Get() == nil {
|
||||||
pv.SetSub(reflect.NewInitValue(pv.Type().(reflect.PtrType).Sub()))
|
pv.SetSub(reflect.NewZeroValue(pv.Type().(reflect.PtrType).Sub()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ func typedump(s, t string) {
|
||||||
|
|
||||||
func valuedump(s, t string) {
|
func valuedump(s, t string) {
|
||||||
typ := reflect.ParseTypeString("", s);
|
typ := reflect.ParseTypeString("", s);
|
||||||
v := reflect.NewInitValue(typ);
|
v := reflect.NewZeroValue(typ);
|
||||||
if v == nil {
|
if v == nil {
|
||||||
panicln("valuedump", s);
|
panicln("valuedump", s);
|
||||||
}
|
}
|
||||||
|
|
@ -279,7 +279,7 @@ func TestAll(tt *testing.T) { // TODO(r): wrap up better
|
||||||
t = reflect.ParseTypeString("", "[]int32");
|
t = reflect.ParseTypeString("", "[]int32");
|
||||||
v := reflect.NewSliceValue(t.(ArrayType), 5, 10);
|
v := reflect.NewSliceValue(t.(ArrayType), 5, 10);
|
||||||
t1 := reflect.ParseTypeString("", "*[]int32");
|
t1 := reflect.ParseTypeString("", "*[]int32");
|
||||||
v1 := reflect.NewInitValue(t1);
|
v1 := reflect.NewZeroValue(t1);
|
||||||
if v1 == nil { panic("V1 is nil"); }
|
if v1 == nil { panic("V1 is nil"); }
|
||||||
v1.(reflect.PtrValue).SetSub(v);
|
v1.(reflect.PtrValue).SetSub(v);
|
||||||
a := v1.Interface().(*[]int32);
|
a := v1.Interface().(*[]int32);
|
||||||
|
|
@ -533,7 +533,7 @@ func TestIsNil(t *testing.T) {
|
||||||
doNil := []string{"*int", "interface{}", "map[string]int", "func() bool", "chan int", "[]string"};
|
doNil := []string{"*int", "interface{}", "map[string]int", "func() bool", "chan int", "[]string"};
|
||||||
for i, ts := range doNotNil {
|
for i, ts := range doNotNil {
|
||||||
ty := reflect.ParseTypeString("", ts);
|
ty := reflect.ParseTypeString("", ts);
|
||||||
v := reflect.NewInitValue(ty);
|
v := reflect.NewZeroValue(ty);
|
||||||
if nilable, ok := v.(Nillable); ok {
|
if nilable, ok := v.(Nillable); ok {
|
||||||
t.Errorf("%s is nilable; should not be", ts)
|
t.Errorf("%s is nilable; should not be", ts)
|
||||||
}
|
}
|
||||||
|
|
@ -541,7 +541,7 @@ func TestIsNil(t *testing.T) {
|
||||||
|
|
||||||
for i, ts := range doNil {
|
for i, ts := range doNil {
|
||||||
ty := reflect.ParseTypeString("", ts);
|
ty := reflect.ParseTypeString("", ts);
|
||||||
v := reflect.NewInitValue(ty);
|
v := reflect.NewZeroValue(ty);
|
||||||
if nilable, ok := v.(Nillable); !ok {
|
if nilable, ok := v.(Nillable); !ok {
|
||||||
t.Errorf("%s is not nilable; should be", ts)
|
t.Errorf("%s is not nilable; should be", ts)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -874,8 +874,8 @@ func newValueAddr(typ Type, addr Addr) Value {
|
||||||
return c(typ, addr);
|
return c(typ, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInitValue creates a new, zero-initialized Value for the specified Type.
|
// NewZeroValue creates a new, zero-initialized Value for the specified Type.
|
||||||
func NewInitValue(typ Type) Value {
|
func NewZeroValue(typ Type) Value {
|
||||||
// Some values cannot be made this way.
|
// Some values cannot be made this way.
|
||||||
switch typ.Kind() {
|
switch typ.Kind() {
|
||||||
case ArrayKind:
|
case ArrayKind:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue