Commit 110bbc49 authored by Robert Griesemer's avatar Robert Griesemer

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/+/196337Reviewed-by: default avatarAlan Donovan <adonovan@google.com>
parent 1ee9bc9b
...@@ -374,3 +374,15 @@ func Implements(V Type, T *Interface) bool { ...@@ -374,3 +374,15 @@ func Implements(V Type, T *Interface) bool {
f, _ := MissingMethod(V, T, true) f, _ := MissingMethod(V, T, true)
return f == nil 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)
}
...@@ -110,29 +110,14 @@ func hasNil(typ Type) bool { ...@@ -110,29 +110,14 @@ func hasNil(typ Type) bool {
return false return false
} }
// The functions Identical and IdenticalIgnoreTags are // identical reports whether x and y are identical types.
// 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.
// Receivers of Signature types are ignored. // 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 { func (check *Checker) identical(x, y Type) bool {
return check.identical0(x, y, true, nil) 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. // 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 { func (check *Checker) identicalIgnoreTags(x, y Type) bool {
return check.identical0(x, y, false, nil) return check.identical0(x, y, false, nil)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment