Permalink
Browse files

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.
  • Loading branch information...
dmitshur committed Jun 27, 2018
1 parent 004a367 commit a6e22d021c8af6dbd8af8523a4d9cff78a160811
Showing with 10 additions and 10 deletions.
  1. +7 −7 compiler/natives/src/reflect/reflect.go
  2. +1 −1 compiler/package.go
  3. +2 −2 compiler/prelude/types.go
@@ -143,14 +143,14 @@ func reflectType(typ *js.Object) *rtype {
reflectFields := make([]structField, fields.Length())
for i := range reflectFields {
f := fields.Index(i)
offsetAnon := uintptr(i) << 1
if f.Get("anonymous").Bool() {
offsetAnon |= 1
offsetEmbed := uintptr(i) << 1
if f.Get("embedded").Bool() {
offsetEmbed |= 1
}
reflectFields[i] = structField{
name: newName(internalStr(f.Get("name")), internalStr(f.Get("tag")), f.Get("exported").Bool()),
typ: reflectType(f.Get("typ")),
offsetAnon: offsetAnon,
name: newName(internalStr(f.Get("name")), internalStr(f.Get("tag")), f.Get("exported").Bool()),
typ: reflectType(f.Get("typ")),
offsetEmbed: offsetEmbed,
}
}
setKindType(rt, &structType{
@@ -993,7 +993,7 @@ func (v Value) Field(i int) Value {
fl := v.flag&(flagStickyRO|flagIndir|flagAddr) | flag(typ.Kind())
if !field.name.isExported() {
if field.anon() {
if field.embedded() {
fl |= flagEmbedRO
} else {
fl |= flagStickyRO
View
@@ -592,7 +592,7 @@ func (c *funcContext) initArgs(ty types.Type) string {
if !field.Exported() {
pkgPath = field.Pkg().Path()
}
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)))
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)))
}
return fmt.Sprintf(`"%s", [%s]`, pkgPath, strings.Join(fields, ", "))
default:
@@ -289,7 +289,7 @@ var $newType = function(size, kind, string, named, pkg, exported, constructor) {
};
};
fields.forEach(function(f) {
if (f.anonymous) {
if (f.embedded) {
$methodSet(f.typ).forEach(function(m) {
synthesizeMethod(typ, m, f);
synthesizeMethod(typ.ptr, m, f);
@@ -429,7 +429,7 @@ var $methodSet = function(typ) {
switch (e.typ.kind) {
case $kindStruct:
e.typ.fields.forEach(function(f) {
if (f.anonymous) {
if (f.embedded) {
var fTyp = f.typ;
var fIsPtr = (fTyp.kind === $kindPtr);
next.push({typ: fIsPtr ? fTyp.elem : fTyp, indirect: e.indirect || fIsPtr});

0 comments on commit a6e22d0

Please sign in to comment.