@@ -63,7 +63,6 @@ type parser struct {
63
63
topScope * ast.Scope // top-most scope; may be pkgScope
64
64
unresolved []* ast.Ident // unresolved identifiers
65
65
imports []* ast.ImportSpec // list of imports
66
- inStruct bool // if set, parser is parsing a struct or interface (for comment collection)
67
66
68
67
// Label scopes
69
68
// (maintained by open/close LabelScope)
@@ -338,15 +337,7 @@ func (p *parser) next() {
338
337
// consume successor comments, if any
339
338
endline = - 1
340
339
for p .tok == token .COMMENT {
341
- n := 1
342
- // When inside a struct (or interface), we don't want to lose comments
343
- // separated from individual field (or method) documentation by empty
344
- // lines. Allow for some white space in this case and collect those
345
- // comments as a group. See issue #10858 for details.
346
- if p .inStruct {
347
- n = 2
348
- }
349
- comment , endline = p .consumeCommentGroup (n )
340
+ comment , endline = p .consumeCommentGroup (1 )
350
341
}
351
342
352
343
if endline + 1 == p .file .Line (p .pos ) {
@@ -757,7 +748,6 @@ func (p *parser) parseStructType() *ast.StructType {
757
748
}
758
749
759
750
pos := p .expect (token .STRUCT )
760
- p .inStruct = true
761
751
lbrace := p .expect (token .LBRACE )
762
752
scope := ast .NewScope (nil ) // struct scope
763
753
var list []* ast.Field
@@ -768,7 +758,6 @@ func (p *parser) parseStructType() *ast.StructType {
768
758
list = append (list , p .parseFieldDecl (scope ))
769
759
}
770
760
rbrace := p .expect (token .RBRACE )
771
- p .inStruct = false
772
761
773
762
return & ast.StructType {
774
763
Struct : pos ,
@@ -970,15 +959,13 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType {
970
959
}
971
960
972
961
pos := p .expect (token .INTERFACE )
973
- p .inStruct = true
974
962
lbrace := p .expect (token .LBRACE )
975
963
scope := ast .NewScope (nil ) // interface scope
976
964
var list []* ast.Field
977
965
for p .tok == token .IDENT {
978
966
list = append (list , p .parseMethodSpec (scope ))
979
967
}
980
968
rbrace := p .expect (token .RBRACE )
981
- p .inStruct = false
982
969
983
970
return & ast.InterfaceType {
984
971
Interface : pos ,
0 commit comments