goto Error
}
- if !isIdentical(x.typ, y.typ) {
+ if !IsIdentical(x.typ, y.typ) {
check.invalidArg(x.pos(), "mismatched types %s and %s", x.typ, y.typ)
goto Error
}
goto Error
}
- if !isIdentical(dst, src) {
+ if !IsIdentical(dst, src) {
check.invalidArg(x.pos(), "arguments to copy %s and %s have different element types %s and %s", x, &y, dst, src)
goto Error
}
V := x.typ
// x's type is identical to T
- if isIdentical(V, T) {
+ if IsIdentical(V, T) {
return true
}
// x's type V and T have identical underlying types
// and at least one of V or T is not a named type
- if isIdentical(Vu, Tu) {
+ if IsIdentical(Vu, Tu) {
return !isNamed(V) || !isNamed(T)
}
// type, x's type V and T have identical element types,
// and at least one of V or T is not a named type
if Vc, ok := Vu.(*Chan); ok && Vc.Dir == ast.SEND|ast.RECV {
- if Tc, ok := Tu.(*Chan); ok && isIdentical(Vc.Elt, Tc.Elt) {
+ if Tc, ok := Tu.(*Chan); ok && IsIdentical(Vc.Elt, Tc.Elt) {
return !isNamed(V) || !isNamed(T)
}
}
return false
}
-// identical returns true if x and y are identical.
-func isIdentical(x, y Type) bool {
+// IsIdentical returns true if x and y are identical.
+func IsIdentical(x, y Type) bool {
if x == y {
return true
}
// Two array types are identical if they have identical element types
// and the same array length.
if y, ok := y.(*Array); ok {
- return x.Len == y.Len && isIdentical(x.Elt, y.Elt)
+ return x.Len == y.Len && IsIdentical(x.Elt, y.Elt)
}
case *Slice:
// Two slice types are identical if they have identical element types.
if y, ok := y.(*Slice); ok {
- return isIdentical(x.Elt, y.Elt)
+ return IsIdentical(x.Elt, y.Elt)
}
case *Struct:
for i, f := range x.Fields {
g := y.Fields[i]
if !f.QualifiedName.IsSame(g.QualifiedName) ||
- !isIdentical(f.Type, g.Type) ||
+ !IsIdentical(f.Type, g.Type) ||
f.Tag != g.Tag ||
f.IsAnonymous != g.IsAnonymous {
return false
case *Pointer:
// Two pointer types are identical if they have identical base types.
if y, ok := y.(*Pointer); ok {
- return isIdentical(x.Base, y.Base)
+ return IsIdentical(x.Base, y.Base)
}
case *Signature:
case *Map:
// Two map types are identical if they have identical key and value types.
if y, ok := y.(*Map); ok {
- return isIdentical(x.Key, y.Key) && isIdentical(x.Elt, y.Elt)
+ return IsIdentical(x.Key, y.Key) && IsIdentical(x.Elt, y.Elt)
}
case *Chan:
// Two channel types are identical if they have identical value types
// and the same direction.
if y, ok := y.(*Chan); ok {
- return x.Dir == y.Dir && isIdentical(x.Elt, y.Elt)
+ return x.Dir == y.Dir && IsIdentical(x.Elt, y.Elt)
}
case *NamedType:
}
for i, x := range a {
y := b[i]
- if !isIdentical(x.Type, y.Type) {
+ if !IsIdentical(x.Type, y.Type) {
return false
}
}
m[x.QualifiedName] = x
}
for _, y := range b {
- if x := m[y.QualifiedName]; x == nil || !isIdentical(x.Type, y.Type) {
+ if x := m[y.QualifiedName]; x == nil || !IsIdentical(x.Type, y.Type) {
return false
}
}
if ityp, _ := underlying(typ).(*Interface); ityp != nil {
for _, m := range T.Methods {
mode, sig := lookupField(ityp, m.QualifiedName) // TODO(gri) no need to go via lookupField
- if mode != invalid && !isIdentical(sig, m.Type) {
+ if mode != invalid && !IsIdentical(sig, m.Type) {
return m, true
}
}
if mode == invalid {
return m, false
}
- if !isIdentical(sig, m.Type) {
+ if !IsIdentical(sig, m.Type) {
return m, true
}
}