go/types, types2: remove superfluous assertion (fix build)

Remove an assertion that was overly restrictive and hard to get
correct under all circumstances (i.e., in the presence of incorrect)
code. This matches the code for *Named types in that specific switch.

Fixes #71284.

Change-Id: Ifccf8b73dc70cac9cb1c8b24946d16851d511454
Reviewed-on: https://go-review.googlesource.com/c/go/+/643255
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Robert Griesemer 2025-01-16 16:08:26 -08:00 committed by Gopher Robot
parent 1a93e4a2cf
commit 80bf7d83ed
3 changed files with 10 additions and 10 deletions

View file

@ -423,11 +423,6 @@ func setDefType(def *TypeName, typ Type) {
if def != nil { if def != nil {
switch t := def.typ.(type) { switch t := def.typ.(type) {
case *Alias: case *Alias:
// t.fromRHS should always be set, either to an invalid type
// in the beginning, or to typ in certain cyclic declarations.
if t.fromRHS != Typ[Invalid] && t.fromRHS != typ {
panic(sprintf(nil, true, "t.fromRHS = %s, typ = %s\n", t.fromRHS, typ))
}
t.fromRHS = typ t.fromRHS = typ
case *Basic: case *Basic:
assert(t == Typ[Invalid]) assert(t == Typ[Invalid])

View file

@ -419,11 +419,6 @@ func setDefType(def *TypeName, typ Type) {
if def != nil { if def != nil {
switch t := def.typ.(type) { switch t := def.typ.(type) {
case *Alias: case *Alias:
// t.fromRHS should always be set, either to an invalid type
// in the beginning, or to typ in certain cyclic declarations.
if t.fromRHS != Typ[Invalid] && t.fromRHS != typ {
panic(sprintf(nil, nil, true, "t.fromRHS = %s, typ = %s\n", t.fromRHS, typ))
}
t.fromRHS = typ t.fromRHS = typ
case *Basic: case *Basic:
assert(t == Typ[Invalid]) assert(t == Typ[Invalid])

View file

@ -0,0 +1,10 @@
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package A
type (
_ = A
A /* ERROR "invalid recursive type: A refers to itself" */ = A
)