Skip to content

Commit 0cb05c5

Browse files
committed
WIP: Better solution for method name encoding mismatch.
1 parent da23df8 commit 0cb05c5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler/package.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ func Compile(importPath string, files []*ast.File, fileSet *token.FileSet, impor
488488
pkgPath = method.Pkg().Path()
489489
}
490490
t := method.Type().(*types.Signature)
491-
entry := fmt.Sprintf(`{prop: "%s", name: "%s", pkg: "%s", typ: $funcType(%s)}`, name, method.Name(), pkgPath, c.initArgs(t))
491+
entry := fmt.Sprintf(`{prop: "%s", name: %s, pkg: "%s", typ: $funcType(%s)}`, name, encodeString(method.Name()), pkgPath, c.initArgs(t))
492492
if _, isPtr := t.Recv().Type().(*types.Pointer); isPtr {
493493
ptrMethods = append(ptrMethods, entry)
494494
continue
@@ -589,7 +589,7 @@ func (c *funcContext) initArgs(ty types.Type) string {
589589
if !field.Exported() {
590590
pkgPath = field.Pkg().Path()
591591
}
592-
fields[i] = fmt.Sprintf(`{prop: "%s", name: "%s", anonymous: %t, exported: %t, typ: %s, tag: %s}`, fieldName(t, i), field.Name(), field.Anonymous(), field.Exported(), c.typeName(field.Type()), encodeString(t.Tag(i)))
592+
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)))
593593
}
594594
return fmt.Sprintf(`"%s", [%s]`, pkgPath, strings.Join(fields, ", "))
595595
default:

compiler/prelude/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,9 @@ var $methodSet = function(typ) {
454454
455455
typ.methodSetCache = [];
456456
var x = Object.keys(base).sort();
457-
if (x.length === 2 && x[0] === "nonexported" && x[1] === "ΦExported") {
457+
if (x.length === 2 && x[0] === "nonexported" && x[1] === "\xCE\xA6Exported") {
458458
/* HACK: Hacky fix for TestIssue22073. Need to find a good general fix. */
459-
x[0] = "ΦExported";
459+
x[0] = "\xCE\xA6Exported";
460460
x[1] = "nonexported";
461461
}
462462
x.forEach(function(name) {

0 commit comments

Comments
 (0)