mirror of https://github.com/golang/go.git
cmd/compile/internal/types2: implement compiler helper functions without using under
These functions are exported for the compiler and are used after type checking is finished. There is no need to call under() in their implementations; they can rely entirely on the public API. This opens the door to moving them into the compiler eventually. They may also be slightly more efficient. Change-Id: Ib4f83d2dcf82e3c319c3147e01ecaea684553ea5 Reviewed-on: https://go-review.googlesource.com/c/go/+/361214 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
5fd0c49a4d
commit
2cf85b1fb8
|
|
@ -81,10 +81,32 @@ func asTypeParam(t Type) *TypeParam {
|
|||
return u
|
||||
}
|
||||
|
||||
// Exported for the compiler.
|
||||
// Helper functions exported for the compiler.
|
||||
// These functions assume type checking has completed
|
||||
// and Type.Underlying() is returning the fully set up
|
||||
// underlying type. Do not use internally.
|
||||
|
||||
func AsPointer(t Type) *Pointer { return asPointer(t) }
|
||||
func AsNamed(t Type) *Named { return asNamed(t) }
|
||||
func AsSignature(t Type) *Signature { return asSignature(t) }
|
||||
func AsInterface(t Type) *Interface { return asInterface(t) }
|
||||
func AsTypeParam(t Type) *TypeParam { return asTypeParam(t) }
|
||||
func AsPointer(t Type) *Pointer {
|
||||
u, _ := t.Underlying().(*Pointer)
|
||||
return u
|
||||
}
|
||||
|
||||
func AsNamed(t Type) *Named {
|
||||
u, _ := t.(*Named)
|
||||
return u
|
||||
}
|
||||
|
||||
func AsSignature(t Type) *Signature {
|
||||
u, _ := t.Underlying().(*Signature)
|
||||
return u
|
||||
}
|
||||
|
||||
func AsInterface(t Type) *Interface {
|
||||
u, _ := t.Underlying().(*Interface)
|
||||
return u
|
||||
}
|
||||
|
||||
func AsTypeParam(t Type) *TypeParam {
|
||||
u, _ := t.Underlying().(*TypeParam)
|
||||
return u
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue