mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
go/types, types2: clarify docs for resolveUnderlying
The resolveUnderlying method only detects cycles among type names, where no type literal or predeclared type can be found (which would yield an underlying type). Change-Id: I203f3856eaf63a8a9d317c22521755390f9c1023 Reviewed-on: https://go-review.googlesource.com/c/go/+/714402 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
d8a32f3d4b
commit
180c07e2c1
2 changed files with 16 additions and 18 deletions
|
|
@ -607,15 +607,14 @@ func (t *Named) String() string { return TypeString(t, nil) }
|
||||||
|
|
||||||
// resolveUnderlying computes the underlying type of n.
|
// resolveUnderlying computes the underlying type of n.
|
||||||
//
|
//
|
||||||
// It does so by following RHS type chains. If a type literal is found, each
|
// It does so by following RHS type chains for alias and named types. If any
|
||||||
// named type in the chain has its underlying set to that type. Aliases are
|
// other type T is found, each named type in the chain has its underlying
|
||||||
// skipped because their underlying type is not memoized.
|
// type set to T. Aliases are skipped because their underlying type is
|
||||||
|
// not memoized.
|
||||||
//
|
//
|
||||||
// This function also checks for instantiated layout cycles, which are
|
// This method also checks for cycles among alias and named types, which will
|
||||||
// reachable only in the case where unpack() expanded an instantiated
|
// yield no underlying type. If such a cycle is found, the underlying type is
|
||||||
// type which became self-referencing without indirection.
|
// set to Typ[Invalid] and a cycle is reported.
|
||||||
// If such a cycle is found, the underlying type is set to Typ[Invalid]
|
|
||||||
// and a cycle is reported.
|
|
||||||
func (n *Named) resolveUnderlying() {
|
func (n *Named) resolveUnderlying() {
|
||||||
assert(n.stateHas(unpacked))
|
assert(n.stateHas(unpacked))
|
||||||
|
|
||||||
|
|
@ -663,7 +662,7 @@ func (n *Named) resolveUnderlying() {
|
||||||
rhs = t.rhs()
|
rhs = t.rhs()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
u = rhs // any type literal works
|
u = rhs // any type literal or predeclared type works
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -610,15 +610,14 @@ func (t *Named) String() string { return TypeString(t, nil) }
|
||||||
|
|
||||||
// resolveUnderlying computes the underlying type of n.
|
// resolveUnderlying computes the underlying type of n.
|
||||||
//
|
//
|
||||||
// It does so by following RHS type chains. If a type literal is found, each
|
// It does so by following RHS type chains for alias and named types. If any
|
||||||
// named type in the chain has its underlying set to that type. Aliases are
|
// other type T is found, each named type in the chain has its underlying
|
||||||
// skipped because their underlying type is not memoized.
|
// type set to T. Aliases are skipped because their underlying type is
|
||||||
|
// not memoized.
|
||||||
//
|
//
|
||||||
// This function also checks for instantiated layout cycles, which are
|
// This method also checks for cycles among alias and named types, which will
|
||||||
// reachable only in the case where unpack() expanded an instantiated
|
// yield no underlying type. If such a cycle is found, the underlying type is
|
||||||
// type which became self-referencing without indirection.
|
// set to Typ[Invalid] and a cycle is reported.
|
||||||
// If such a cycle is found, the underlying type is set to Typ[Invalid]
|
|
||||||
// and a cycle is reported.
|
|
||||||
func (n *Named) resolveUnderlying() {
|
func (n *Named) resolveUnderlying() {
|
||||||
assert(n.stateHas(unpacked))
|
assert(n.stateHas(unpacked))
|
||||||
|
|
||||||
|
|
@ -666,7 +665,7 @@ func (n *Named) resolveUnderlying() {
|
||||||
rhs = t.rhs()
|
rhs = t.rhs()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
u = rhs // any type literal works
|
u = rhs // any type literal or predeclared type works
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue