@@ -135,10 +135,10 @@ func parseAndAugment(xctx XContext, pkg *PackageData, isTest bool, fileSet *toke
135
135
var files []* ast.File
136
136
137
137
type overrideInfo struct {
138
- keepOverridden bool
138
+ keepOriginal bool
139
+ pruneOriginal bool
139
140
}
140
141
replacedDeclNames := make (map [string ]overrideInfo )
141
- pruneOriginalFuncs := make (map [string ]bool )
142
142
143
143
isXTest := strings .HasSuffix (pkg .ImportPath , "_test" )
144
144
importPath := pkg .ImportPath
@@ -177,8 +177,10 @@ func parseAndAugment(xctx XContext, pkg *PackageData, isTest bool, fileSet *toke
177
177
switch d := decl .(type ) {
178
178
case * ast.FuncDecl :
179
179
k := astutil .FuncKey (d )
180
- replacedDeclNames [k ] = overrideInfo {keepOverridden : astutil .KeepOriginal (d )}
181
- pruneOriginalFuncs [k ] = astutil .PruneOriginal (d )
180
+ replacedDeclNames [k ] = overrideInfo {
181
+ keepOriginal : astutil .KeepOriginal (d ),
182
+ pruneOriginal : astutil .PruneOriginal (d ),
183
+ }
182
184
case * ast.GenDecl :
183
185
switch d .Tok {
184
186
case token .TYPE :
@@ -242,12 +244,12 @@ func parseAndAugment(xctx XContext, pkg *PackageData, isTest bool, fileSet *toke
242
244
case * ast.FuncDecl :
243
245
k := astutil .FuncKey (d )
244
246
if info , ok := replacedDeclNames [k ]; ok {
245
- if pruneOriginalFuncs [ k ] {
247
+ if info . pruneOriginal {
246
248
// Prune function bodies, since it may contain code invalid for
247
249
// GopherJS and pin unwanted imports.
248
250
d .Body = nil
249
251
}
250
- if info .keepOverridden {
252
+ if info .keepOriginal {
251
253
// Allow overridden function calls
252
254
// The standard library implementation of foo() becomes _gopherjs_overridden_foo()
253
255
d .Name .Name = "_gopherjs_overridden_" + d .Name .Name
0 commit comments