From 6d51dd1e85bbed9f59023a468c4cbbeed598608f Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 4 Oct 2018 16:43:34 -0700 Subject: [PATCH] go/types: remove work-around for issue #26124 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 --- src/go/types/decl.go | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/go/types/decl.go b/src/go/types/decl.go index 5a6eda8ee4..3d8054de23 100644 --- a/src/go/types/decl.go +++ b/src/go/types/decl.go @@ -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 -- 2.50.0