Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(10)

Unified Diff: src/pkg/exp/types/gcimporter.go

Issue 5523047: code review 5523047: gc: fix infinite recursion for embedded interfaces (Closed)
Patch Set: diff -r 4f026dec52ea https://go.googlecode.com/hg/ Created 13 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/cmd/gc/go.y ('k') | test/fixedbugs/bug395.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/exp/types/gcimporter.go
===================================================================
--- a/src/pkg/exp/types/gcimporter.go
+++ b/src/pkg/exp/types/gcimporter.go
@@ -460,29 +460,32 @@
return &Func{Params: params, Results: results, IsVariadic: isVariadic}
}
-// MethodSpec = ( identifier | ExportedName ) Signature .
+// MethodOrEmbedSpec = Name [ Signature ] .
//
-func (p *gcParser) parseMethodSpec() *ast.Object {
- if p.tok == scanner.Ident {
- p.expect(scanner.Ident)
- } else {
- p.parseExportedName()
+func (p *gcParser) parseMethodOrEmbedSpec() *ast.Object {
+ p.parseName()
+ if p.tok == '(' {
+ p.parseSignature()
+ // TODO(gri) compute method object
+ return ast.NewObj(ast.Fun, "_")
}
- p.parseSignature()
-
- // TODO(gri) compute method object
- return ast.NewObj(ast.Fun, "_")
+ // TODO lookup name and return that type
+ return ast.NewObj(ast.Typ, "_")
}
-// InterfaceType = "interface" "{" [ MethodList ] "}" .
-// MethodList = MethodSpec { ";" MethodSpec } .
+// InterfaceType = "interface" "{" [ MethodOrEmbedList ] "}" .
+// MethodOrEmbedList = MethodOrEmbedSpec { ";" MethodOrEmbedSpec } .
//
func (p *gcParser) parseInterfaceType() Type {
var methods ObjList
parseMethod := func() {
- meth := p.parseMethodSpec()
- methods = append(methods, meth)
+ switch m := p.parseMethodOrEmbedSpec(); m.Kind {
+ case ast.Typ:
+ // TODO expand embedded methods
+ case ast.Fun:
+ methods = append(methods, m)
+ }
}
p.expectKeyword("interface")
« no previous file with comments | « src/cmd/gc/go.y ('k') | test/fixedbugs/bug395.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b