Skip to content

Commit

Permalink
Merge pull request #1853 from visualfc/shadow
Browse files Browse the repository at this point in the history
cl & printer: set astFnClassfname shadow and no printer
  • Loading branch information
xushiwei committed Apr 12, 2024
2 parents 444d455 + 115c876 commit 5192883
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions cl/classfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ func astFnClassfname(c *gmxClass) *ast.FuncDecl {
},
},
},
Shadow: true,
}
}

Expand Down
6 changes: 6 additions & 0 deletions printer/gop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ func TestFuncs(t *testing.T) {
Name: &ast.Ident{Name: "bar"},
Body: &ast.BlockStmt{},
},
&ast.FuncDecl{
Type: &ast.FuncType{Params: &ast.FieldList{}},
Name: &ast.Ident{Name: "Classname"},
Body: &ast.BlockStmt{},
Shadow: true,
},
},
NoPkgDecl: true,
}); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions printer/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,10 @@ func declToken(decl ast.Decl) (tok token.Token) {
func (p *printer) declList(list []ast.Decl) {
tok := token.ILLEGAL
for _, d := range list {
// skip no entry shadow
if decl, ok := d.(*ast.FuncDecl); ok && decl.Shadow && decl != p.shadowEntry {
continue
}
prev := tok
tok = declToken(d)
// If the declaration token changed (e.g., from CONST to TYPE)
Expand Down

0 comments on commit 5192883

Please sign in to comment.