Repository: goplus/gop
Pull request #1853 (2024-04-10 09:48:25)

cl & printer: set astFnClassfname shadow and no printer

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/goplus/gop/pull/1853?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus) Report
Attention: Patch coverage is `33.33333%` with `2 lines` in your changes are missing coverage. Please review.
> Project coverage is 93.82%. Comparing base [(`570665d`)](https://app.codecov.io/gh/goplus/gop/commit/570665d69c60d04027c1e55a5833abc30d2dc8da?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus) to head [(`5115547`)](https://app.codecov.io/gh/goplus/gop/pull/1853?dropdown=coverage&src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus).

| [Files](https://app.codecov.io/gh/goplus/gop/pull/1853?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus) | Patch % | Lines |
|---|---|---|
| [printer/nodes.go](https://app.codecov.io/gh/goplus/gop/pull/1853?src=pr&el=tree&filepath=printer%2Fnodes.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus#diff-cHJpbnRlci9ub2Rlcy5nbw==) | 0.00% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/goplus/gop/pull/1853?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main    #1853      +/-   ##
==========================================
+ Coverage   93.23%   93.82%   +0.59%     
==========================================
  Files          40       39       -1     
  Lines       11533     9497    -2036     
==========================================
- Hits        10753     8911    -1842     
+ Misses        623      428     -195     
- Partials      157      158       +1     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/goplus/gop/pull/1853?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus).


Patch:
diff --git a/cl/classfile.go b/cl/classfile.go
index 9a101c85..2944b03d 100644
--- a/cl/classfile.go
+++ b/cl/classfile.go
@@ -427,6 +427,7 @@ func astFnClassfname(c *gmxClass) *ast.FuncDecl {
 				},
 			},
 		},
+		Shadow: true,
 	}
 }
 
diff --git a/printer/nodes.go b/printer/nodes.go
index 309c977f..2cf61f61 100644
--- a/printer/nodes.go
+++ b/printer/nodes.go
@@ -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)


Test patch:
diff --git a/printer/gop_test.go b/printer/gop_test.go
index 8aadd297..83fae961 100644
--- a/printer/gop_test.go
+++ b/printer/gop_test.go
@@ -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 {