mirror of
https://github.com/golang/go
synced 2024-11-26 08:27:56 -07:00
[dev.typeparams] cmd/compile/internal/types: review of type.go
The changes between (equivalent, and reviewed) go/types/type.go and type.go can be seen by comparing patchset 1 and 3. The actual change is just removing the "// UNREVIEWED" marker and some comment adjustments. Change-Id: Ied0e2f942bc96a9fcae0466761cfaa60a87668db Reviewed-on: https://go-review.googlesource.com/c/go/+/293471 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
099374b55e
commit
c2314babb8
@ -1,4 +1,3 @@
|
|||||||
// UNREVIEWED
|
|
||||||
// Copyright 2011 The Go Authors. All rights reserved.
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
@ -207,7 +206,7 @@ type Signature struct {
|
|||||||
// and store it in the Func Object) because when type-checking a function
|
// and store it in the Func Object) because when type-checking a function
|
||||||
// literal we call the general type checker which returns a general Type.
|
// literal we call the general type checker which returns a general Type.
|
||||||
// We then unpack the *Signature and use the scope for the literal body.
|
// We then unpack the *Signature and use the scope for the literal body.
|
||||||
rparams []*TypeName // reveiver type parameters from left to right; or nil
|
rparams []*TypeName // receiver type parameters from left to right; or nil
|
||||||
tparams []*TypeName // type parameters from left to right; or nil
|
tparams []*TypeName // type parameters from left to right; or nil
|
||||||
scope *Scope // function scope, present for package-local signatures
|
scope *Scope // function scope, present for package-local signatures
|
||||||
recv *Var // nil if not a method
|
recv *Var // nil if not a method
|
||||||
@ -725,9 +724,8 @@ type TypeParam struct {
|
|||||||
bound Type // *Named or *Interface; underlying type is always *Interface
|
bound Type // *Named or *Interface; underlying type is always *Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TypeParam) Obj() *TypeName {
|
// Obj returns the type name for the type parameter t.
|
||||||
return t.obj
|
func (t *TypeParam) Obj() *TypeName { return t.obj }
|
||||||
}
|
|
||||||
|
|
||||||
// NewTypeParam returns a new TypeParam.
|
// NewTypeParam returns a new TypeParam.
|
||||||
func (check *Checker) NewTypeParam(obj *TypeName, index int, bound Type) *TypeParam {
|
func (check *Checker) NewTypeParam(obj *TypeName, index int, bound Type) *TypeParam {
|
||||||
@ -747,6 +745,7 @@ func (t *TypeParam) Bound() *Interface {
|
|||||||
if n, _ := t.bound.(*Named); n != nil {
|
if n, _ := t.bound.(*Named); n != nil {
|
||||||
pos = n.obj.pos
|
pos = n.obj.pos
|
||||||
}
|
}
|
||||||
|
// TODO(gri) switch this to an unexported method on Checker.
|
||||||
t.check.completeInterface(pos, iface)
|
t.check.completeInterface(pos, iface)
|
||||||
return iface
|
return iface
|
||||||
}
|
}
|
||||||
@ -762,7 +761,7 @@ func optype(typ Type) Type {
|
|||||||
if t := asTypeParam(typ); t != nil {
|
if t := asTypeParam(typ); t != nil {
|
||||||
// If the optype is typ, return the top type as we have
|
// If the optype is typ, return the top type as we have
|
||||||
// no information. It also prevents infinite recursion
|
// no information. It also prevents infinite recursion
|
||||||
// via the TypeParam converter methods. This can happen
|
// via the asTypeParam converter function. This can happen
|
||||||
// for a type parameter list of the form:
|
// for a type parameter list of the form:
|
||||||
// (type T interface { type T }).
|
// (type T interface { type T }).
|
||||||
// See also issue #39680.
|
// See also issue #39680.
|
||||||
|
Loading…
Reference in New Issue
Block a user