]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: minor cleanup (remove TODO)
authorRobert Griesemer <gri@google.com>
Mon, 13 Oct 2025 22:55:04 +0000 (15:55 -0700)
committerRobert Griesemer <gri@google.com>
Tue, 14 Oct 2025 15:50:15 +0000 (08:50 -0700)
Follow-up to CL 711420.

Change-Id: If577e96f413e46b98dd86d11605de1004637851a
Reviewed-on: https://go-review.googlesource.com/c/go/+/711540
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/types2/decl.go
src/go/types/decl.go

index 3ff24269669a941fb29d625d85b42db00bb1aa5d..4ebd945407075701add76c2ca30ca46362c6b1ad 100644 (file)
@@ -225,8 +225,8 @@ func (check *Checker) validCycle(obj Object) (valid bool) {
        start := obj.color() - grey // index of obj in objPath
        cycle := check.objPath[start:]
        tparCycle := false // if set, the cycle is through a type parameter list
-       nval := 0          // number of (constant or variable) values in the cycle; valid if !generic
-       ndef := 0          // number of type definitions in the cycle; valid if !generic
+       nval := 0          // number of (constant or variable) values in the cycle
+       ndef := 0          // number of type definitions in the cycle
 loop:
        for _, obj := range cycle {
                switch obj := obj.(type) {
@@ -235,7 +235,7 @@ loop:
                case *TypeName:
                        // If we reach a generic type that is part of a cycle
                        // and we are in a type parameter list, we have a cycle
-                       // through a type parameter list, which is invalid.
+                       // through a type parameter list.
                        if check.inTParamList && isGeneric(obj.typ) {
                                tparCycle = true
                                break loop
@@ -286,25 +286,22 @@ loop:
                }()
        }
 
-       if !tparCycle {
-               // A cycle involving only constants and variables is invalid but we
-               // ignore them here because they are reported via the initialization
-               // cycle check.
-               if nval == len(cycle) {
-                       return true
-               }
+       // Cycles through type parameter lists are ok (go.dev/issue/68162).
+       if tparCycle {
+               return true
+       }
 
-               // A cycle involving only types (and possibly functions) must have at least
-               // one type definition to be permitted: If there is no type definition, we
-               // have a sequence of alias type names which will expand ad infinitum.
-               if nval == 0 && ndef > 0 {
-                       return true
-               }
+       // A cycle involving only constants and variables is invalid but we
+       // ignore them here because they are reported via the initialization
+       // cycle check.
+       if nval == len(cycle) {
+               return true
        }
 
-       // Cycles through type parameter lists are ok (go.dev/issue/68162).
-       // TODO(gri) if we are happy with this this, remove this flag and simplify code.
-       if tparCycle {
+       // A cycle involving only types (and possibly functions) must have at least
+       // one type definition to be permitted: If there is no type definition, we
+       // have a sequence of alias type names which will expand ad infinitum.
+       if nval == 0 && ndef > 0 {
                return true
        }
 
index fcae1f95295a676d0b8f51c06dc59d46d3902d0b..aef7f6ad0b90998007266d3552ed9e32cb866ac3 100644 (file)
@@ -226,8 +226,8 @@ func (check *Checker) validCycle(obj Object) (valid bool) {
        start := obj.color() - grey // index of obj in objPath
        cycle := check.objPath[start:]
        tparCycle := false // if set, the cycle is through a type parameter list
-       nval := 0          // number of (constant or variable) values in the cycle; valid if !generic
-       ndef := 0          // number of type definitions in the cycle; valid if !generic
+       nval := 0          // number of (constant or variable) values in the cycle
+       ndef := 0          // number of type definitions in the cycle
 loop:
        for _, obj := range cycle {
                switch obj := obj.(type) {
@@ -236,7 +236,7 @@ loop:
                case *TypeName:
                        // If we reach a generic type that is part of a cycle
                        // and we are in a type parameter list, we have a cycle
-                       // through a type parameter list, which is invalid.
+                       // through a type parameter list.
                        if check.inTParamList && isGeneric(obj.typ) {
                                tparCycle = true
                                break loop
@@ -287,25 +287,22 @@ loop:
                }()
        }
 
-       if !tparCycle {
-               // A cycle involving only constants and variables is invalid but we
-               // ignore them here because they are reported via the initialization
-               // cycle check.
-               if nval == len(cycle) {
-                       return true
-               }
+       // Cycles through type parameter lists are ok (go.dev/issue/68162).
+       if tparCycle {
+               return true
+       }
 
-               // A cycle involving only types (and possibly functions) must have at least
-               // one type definition to be permitted: If there is no type definition, we
-               // have a sequence of alias type names which will expand ad infinitum.
-               if nval == 0 && ndef > 0 {
-                       return true
-               }
+       // A cycle involving only constants and variables is invalid but we
+       // ignore them here because they are reported via the initialization
+       // cycle check.
+       if nval == len(cycle) {
+               return true
        }
 
-       // Cycles through type parameter lists are ok (go.dev/issue/68162).
-       // TODO(gri) if we are happy with this this, remove this flag and simplify code.
-       if tparCycle {
+       // A cycle involving only types (and possibly functions) must have at least
+       // one type definition to be permitted: If there is no type definition, we
+       // have a sequence of alias type names which will expand ad infinitum.
+       if nval == 0 && ndef > 0 {
                return true
        }