]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: remove work-around for issue #26124
authorRobert Griesemer <gri@golang.org>
Thu, 4 Oct 2018 23:43:34 +0000 (16:43 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 5 Oct 2018 17:56:22 +0000 (17:56 +0000)
This work-around is not needed anymore now that method
signatures are type-checked separately from their receiver
base types: no artificial cycles are introduced anymore
and so there is no need to artificially cut them.

Updates #26124.

Change-Id: I9d50171f12dd8977116a5d3f63ac39a06b1cd492
Reviewed-on: https://go-review.googlesource.com/c/139899
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/types/decl.go

index 5a6eda8ee4903cc733f507762b6810cf4e33f98a..3d8054de2390f4f28c0a9c7fe5ebc9fdd3a02bb9 100644 (file)
@@ -245,14 +245,6 @@ func (check *Checker) objDecl(obj Object, def *Named) {
 // Indirections are used to break type cycles.
 var indir = NewTypeName(token.NoPos, nil, "*", nil)
 
-// cutCycle is a sentinel type name that is pushed onto the object path
-// to indicate that a cycle doesn't actually exist. This is currently
-// needed to break cycles formed via method declarations because they
-// are type-checked together with their receiver base types. Once methods
-// are type-checked separately (see also TODO in Checker.typeDecl), we
-// can get rid of this.
-var cutCycle = NewTypeName(token.NoPos, nil, "!", nil)
-
 // typeCycle checks if the cycle starting with obj is valid and
 // reports an error if it is not.
 // TODO(gri) rename s/typeCycle/cycle/ once we don't need the other
@@ -293,16 +285,10 @@ func (check *Checker) typeCycle(obj Object) (isCycle bool) {
                case *Const, *Var:
                        nval++
                case *TypeName:
-                       switch {
-                       case obj == indir:
+                       if obj == indir {
                                ncycle-- // don't count (indirections are not objects)
                                hasIndir = true
-                       case obj == cutCycle:
-                               // The cycle is not real and only caused by the fact
-                               // that we type-check methods when we type-check their
-                               // receiver base types.
-                               return false
-                       default:
+                       } else {
                                // Determine if the type name is an alias or not. For
                                // package-level objects, use the object map which
                                // provides syntactic information (which doesn't rely
@@ -554,14 +540,6 @@ func (check *Checker) addMethodDecls(obj *TypeName) {
                }
        }
 
-       // Suppress detection of type cycles occurring through method
-       // declarations - they wouldn't exist if methods were type-
-       // checked separately from their receiver base types. See also
-       // comment at the end of Checker.typeDecl.
-       // TODO(gri) Remove this once methods are type-checked separately.
-       check.push(cutCycle)
-       defer check.pop()
-
        // add valid methods
        for _, m := range methods {
                // spec: "For a base type, the non-blank names of methods bound