Skip to content

Commit 3c29284

Browse files
committed
natives/reflect: Use 'embedded' rather than 'anonymous'.
These have been renamed in Go 1.11. Update our code to match upstream. Fixes: $ gopherjs build reflect reflect/reflect.go:153:6: unknown field offsetAnon in struct literal reflect/reflect.go:995:12: invalid operation: field (variable of type *structField) has no field or method anon Follows golang/go@47be3d4.
1 parent 9f7f458 commit 3c29284

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

compiler/natives/src/reflect/reflect.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ func reflectType(typ *js.Object) *rtype {
143143
reflectFields := make([]structField, fields.Length())
144144
for i := range reflectFields {
145145
f := fields.Index(i)
146-
offsetAnon := uintptr(i) << 1
147-
if f.Get("anonymous").Bool() {
148-
offsetAnon |= 1
146+
offsetEmbed := uintptr(i) << 1
147+
if f.Get("embedded").Bool() {
148+
offsetEmbed |= 1
149149
}
150150
reflectFields[i] = structField{
151-
name: newName(internalStr(f.Get("name")), internalStr(f.Get("tag")), f.Get("exported").Bool()),
152-
typ: reflectType(f.Get("typ")),
153-
offsetAnon: offsetAnon,
151+
name: newName(internalStr(f.Get("name")), internalStr(f.Get("tag")), f.Get("exported").Bool()),
152+
typ: reflectType(f.Get("typ")),
153+
offsetEmbed: offsetEmbed,
154154
}
155155
}
156156
setKindType(rt, &structType{
@@ -993,7 +993,7 @@ func (v Value) Field(i int) Value {
993993

994994
fl := v.flag&(flagStickyRO|flagIndir|flagAddr) | flag(typ.Kind())
995995
if !field.name.isExported() {
996-
if field.anon() {
996+
if field.embedded() {
997997
fl |= flagEmbedRO
998998
} else {
999999
fl |= flagStickyRO

compiler/package.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ func (c *funcContext) initArgs(ty types.Type) string {
592592
if !field.Exported() {
593593
pkgPath = field.Pkg().Path()
594594
}
595-
fields[i] = fmt.Sprintf(`{prop: "%s", name: %s, anonymous: %t, exported: %t, typ: %s, tag: %s}`, fieldName(t, i), encodeString(field.Name()), field.Anonymous(), field.Exported(), c.typeName(field.Type()), encodeString(t.Tag(i)))
595+
fields[i] = fmt.Sprintf(`{prop: "%s", name: %s, embedded: %t, exported: %t, typ: %s, tag: %s}`, fieldName(t, i), encodeString(field.Name()), field.Anonymous(), field.Exported(), c.typeName(field.Type()), encodeString(t.Tag(i)))
596596
}
597597
return fmt.Sprintf(`"%s", [%s]`, pkgPath, strings.Join(fields, ", "))
598598
default:

compiler/prelude/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ var $newType = function(size, kind, string, named, pkg, exported, constructor) {
289289
};
290290
};
291291
fields.forEach(function(f) {
292-
if (f.anonymous) {
292+
if (f.embedded) {
293293
$methodSet(f.typ).forEach(function(m) {
294294
synthesizeMethod(typ, m, f);
295295
synthesizeMethod(typ.ptr, m, f);
@@ -429,7 +429,7 @@ var $methodSet = function(typ) {
429429
switch (e.typ.kind) {
430430
case $kindStruct:
431431
e.typ.fields.forEach(function(f) {
432-
if (f.anonymous) {
432+
if (f.embedded) {
433433
var fTyp = f.typ;
434434
var fIsPtr = (fTyp.kind === $kindPtr);
435435
next.push({typ: fIsPtr ? fTyp.elem : fTyp, indirect: e.indirect || fIsPtr});

0 commit comments

Comments
 (0)