1
0
mirror of https://github.com/golang/go synced 2024-11-23 15:50:07 -07:00

go/types: move Identical* predicates into api.go file (cleanup)

Follow-up CL removing a TODO.

Change-Id: If900d2f999f6a3e2f2ead29283375547e03cac86
Reviewed-on: https://go-review.googlesource.com/c/go/+/196337
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Robert Griesemer 2019-09-18 09:25:28 -07:00
parent 1ee9bc9b0f
commit 110bbc4966
2 changed files with 14 additions and 17 deletions

View File

@ -374,3 +374,15 @@ func Implements(V Type, T *Interface) bool {
f, _ := MissingMethod(V, T, true)
return f == nil
}
// Identical reports whether x and y are identical types.
// Receivers of Signature types are ignored.
func Identical(x, y Type) bool {
return (*Checker)(nil).identical(x, y)
}
// IdenticalIgnoreTags reports whether x and y are identical types if tags are ignored.
// Receivers of Signature types are ignored.
func IdenticalIgnoreTags(x, y Type) bool {
return (*Checker)(nil).identicalIgnoreTags(x, y)
}

View File

@ -110,29 +110,14 @@ func hasNil(typ Type) bool {
return false
}
// The functions Identical and IdenticalIgnoreTags are
// provided for external use only, after interface types
// were fully set up (completed). During type-checking,
// use the methods identical and identicalIgnoreTags
// which take a non-nil *Checker receiver.
// TODO(gri) factor these out into api.go.
// Identical reports whether x and y are identical types.
// identical reports whether x and y are identical types.
// Receivers of Signature types are ignored.
func Identical(x, y Type) bool {
return (*Checker)(nil).identical(x, y)
}
func (check *Checker) identical(x, y Type) bool {
return check.identical0(x, y, true, nil)
}
// IdenticalIgnoreTags reports whether x and y are identical types if tags are ignored.
// identicalIgnoreTags reports whether x and y are identical types if tags are ignored.
// Receivers of Signature types are ignored.
func IdenticalIgnoreTags(x, y Type) bool {
return (*Checker)(nil).identicalIgnoreTags(x, y)
}
func (check *Checker) identicalIgnoreTags(x, y Type) bool {
return check.identical0(x, y, false, nil)
}