Skip to content

Commit 6d2309b

Browse files
aclementsgopherbot
authored andcommitted
Revert "reflect: change rtype so that it (not *rtype) implements Type"
This reverts CL 487558, which is causing test failures in Google. See b/282133554. Change-Id: Icafa4ffc6aaa24a363abb90b8ae0b0183aca2b89 Reviewed-on: https://go-review.googlesource.com/c/go/+/494410 TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Austin Clements <[email protected]> Reviewed-by: David Chase <[email protected]> Run-TryBot: Austin Clements <[email protected]>
1 parent c308e9b commit 6d2309b

File tree

6 files changed

+139
-146
lines changed

6 files changed

+139
-146
lines changed

src/reflect/all_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7215,11 +7215,11 @@ func join(b ...[]byte) []byte { return bytes.Join(b, nil) }
72157215
func lit(x ...byte) []byte { return x }
72167216

72177217
func TestTypeOfTypeOf(t *testing.T) {
7218-
// Check that all the type constructors return concrete rtype implementations.
7218+
// Check that all the type constructors return concrete *rtype implementations.
72197219
// It's difficult to test directly because the reflect package is only at arm's length.
7220-
// The easiest thing to do is just call a function that crashes if it doesn't get an rtype.
7220+
// The easiest thing to do is just call a function that crashes if it doesn't get an *rtype.
72217221
check := func(name string, typ Type) {
7222-
if underlying := TypeOf(typ).String(); underlying != "reflect.rtype" {
7222+
if underlying := TypeOf(typ).String(); underlying != "*reflect.rtype" {
72237223
t.Errorf("%v returned %v, not *reflect.rtype", name, underlying)
72247224
}
72257225
}

src/reflect/benchmark_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,10 @@ func BenchmarkPtrTo(b *testing.B) {
247247
// Construct a type with a zero ptrToThis.
248248
type T struct{ int }
249249
t := SliceOf(TypeOf(T{}))
250-
ptrToThis := ValueOf(t).Field(0).Elem().FieldByName("PtrToThis")
250+
ptrToThis := ValueOf(t).Elem().FieldByName("PtrToThis")
251251
if !ptrToThis.IsValid() {
252-
b.Fatalf("%v has no ptrToThis field; was it removed from rtype?", t)
252+
b.Skipf("%v has no ptrToThis field; was it removed from rtype?", t) // TODO fix this at top of refactoring
253+
// b.Fatalf("%v has no ptrToThis field; was it removed from rtype?", t)
253254
}
254255
if ptrToThis.Int() != 0 {
255256
b.Fatalf("%v.ptrToThis unexpectedly nonzero", t)

src/reflect/export_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func FuncLayout(t Type, rcvr Type) (frametype Type, argSize, retOffset uintptr,
3535
if rcvr != nil {
3636
ft, _, abid = funcLayout((*funcType)(unsafe.Pointer(t.common())), rcvr.common())
3737
} else {
38-
ft, _, abid = funcLayout((*funcType)(unsafe.Pointer(t.common())), nil)
38+
ft, _, abid = funcLayout((*funcType)(unsafe.Pointer(t.(*rtype))), nil)
3939
}
4040
// Extract size information.
4141
argSize = abid.stackCallArgsSize
@@ -80,7 +80,7 @@ func TypeLinks() []string {
8080
for i, offs := range offset {
8181
rodata := sections[i]
8282
for _, off := range offs {
83-
typ := toRType((*abi.Type)(resolveTypeOff(unsafe.Pointer(rodata), off)))
83+
typ := (*rtype)(resolveTypeOff(unsafe.Pointer(rodata), off))
8484
r = append(r, typ.String())
8585
}
8686
}
@@ -96,11 +96,11 @@ func MapBucketOf(x, y Type) Type {
9696
}
9797

9898
func CachedBucketOf(m Type) Type {
99-
t := m.(rtype)
99+
t := m.(*rtype)
100100
if Kind(t.t.Kind_&kindMask) != Map {
101101
panic("not map")
102102
}
103-
tt := (*mapType)(unsafe.Pointer(t.t))
103+
tt := (*mapType)(unsafe.Pointer(t))
104104
return toType(tt.Bucket)
105105
}
106106

@@ -122,7 +122,7 @@ func FirstMethodNameBytes(t Type) *byte {
122122
panic("type has no methods")
123123
}
124124
m := ut.Methods()[0]
125-
mname := t.(rtype).nameOff(m.Name)
125+
mname := t.(*rtype).nameOff(m.Name)
126126
if *mname.DataChecked(0, "name flag field")&(1<<2) == 0 {
127127
panic("method name does not have pkgPath *string")
128128
}
@@ -135,7 +135,7 @@ type OtherPkgFields struct {
135135
}
136136

137137
func IsExported(t Type) bool {
138-
typ := t.(rtype)
138+
typ := t.(*rtype)
139139
n := typ.nameOff(typ.t.Str)
140140
return n.IsExported()
141141
}

src/reflect/makefunc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func makeMethodValue(op string, v Value) Value {
104104
rcvr := Value{v.typ, v.ptr, fl}
105105

106106
// v.Type returns the actual type of the method value.
107-
ftyp := (*funcType)(unsafe.Pointer(v.Type().common()))
107+
ftyp := (*funcType)(unsafe.Pointer(v.Type().(*rtype)))
108108

109109
code := methodValueCallCodePtr()
110110

0 commit comments

Comments
 (0)