diff --git a/Makefile b/Makefile index e2c9bd6..0ebe32f 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,8 @@ generate: root build .root/src/$(PKG)/tests/snake.go \ .root/src/$(PKG)/tests/data.go \ .root/src/$(PKG)/tests/omitempty.go \ - .root/src/$(PKG)/tests/nothing.go + .root/src/$(PKG)/tests/nothing.go \ + .root/src/$(PKG)/tests/named_type.go .root/bin/easyjson -all .root/src/$(PKG)/tests/data.go .root/bin/easyjson -all .root/src/$(PKG)/tests/nothing.go @@ -29,6 +30,7 @@ generate: root build .root/bin/easyjson -omit_empty .root/src/$(PKG)/tests/omitempty.go .root/bin/easyjson -build_tags=use_easyjson .root/src/$(PKG)/benchmark/data.go .root/bin/easyjson .root/src/$(PKG)/tests/nested_easy.go + .root/bin/easyjson .root/src/$(PKG)/tests/named_type.go test: generate root go test \ diff --git a/tests/named_type.go b/tests/named_type.go new file mode 100644 index 0000000..a157553 --- /dev/null +++ b/tests/named_type.go @@ -0,0 +1,15 @@ +package tests + +//easyjson:json +type NamedType struct { + Inner struct { + // easyjson is mistakenly naming the type of this field 'tests.MyString' in the generated output + // something about a named type inside an anonmymous type is triggering this bug + Field MyString + } +} + +type MyString string + +var namedTypeValue = NamedType{Inner: struct{ Field MyString }{Field: "test"}} +var namedTypeValueString = `{"Inner":{"Field":"test"}}`