(x, y reflectlite.Value)
| 31 | } |
| 32 | |
| 33 | func reflectValueEqual(x, y reflectlite.Value) bool { |
| 34 | // Note: doing a x.Type() == y.Type() comparison would not work here as that |
| 35 | // would introduce an infinite recursion: comparing two reflectlite.Type values |
| 36 | // is done with this reflectValueEqual runtime call. |
| 37 | if x.RawType() == nil || y.RawType() == nil { |
| 38 | // One of them is nil. |
| 39 | return x.RawType() == y.RawType() |
| 40 | } |
| 41 | |
| 42 | if x.RawType() != y.RawType() { |
| 43 | // The type is not the same, which means the interfaces are definitely |
| 44 | // not the same. |
| 45 | return false |
| 46 | } |
| 47 | |
| 48 | switch x.RawType().Kind() { |
| 49 | case reflectlite.Bool: |
| 50 | return x.Bool() == y.Bool() |
| 51 | case reflectlite.Int, reflectlite.Int8, reflectlite.Int16, reflectlite.Int32, reflectlite.Int64: |
| 52 | return x.Int() == y.Int() |
| 53 | case reflectlite.Uint, reflectlite.Uint8, reflectlite.Uint16, reflectlite.Uint32, reflectlite.Uint64, reflectlite.Uintptr: |
| 54 | return x.Uint() == y.Uint() |
| 55 | case reflectlite.Float32, reflectlite.Float64: |
| 56 | return x.Float() == y.Float() |
| 57 | case reflectlite.Complex64, reflectlite.Complex128: |
| 58 | return x.Complex() == y.Complex() |
| 59 | case reflectlite.String: |
| 60 | return x.String() == y.String() |
| 61 | case reflectlite.Chan, reflectlite.Ptr, reflectlite.UnsafePointer: |
| 62 | return x.UnsafePointer() == y.UnsafePointer() |
| 63 | case reflectlite.Array: |
| 64 | for i := 0; i < x.Len(); i++ { |
| 65 | if !reflectValueEqual(x.Index(i), y.Index(i)) { |
| 66 | return false |
| 67 | } |
| 68 | } |
| 69 | return true |
| 70 | case reflectlite.Struct: |
| 71 | for i := 0; i < x.NumField(); i++ { |
| 72 | if !reflectValueEqual(x.Field(i), y.Field(i)) { |
| 73 | return false |
| 74 | } |
| 75 | } |
| 76 | return true |
| 77 | case reflectlite.Interface: |
| 78 | return reflectValueEqual(x.Elem(), y.Elem()) |
| 79 | default: |
| 80 | runtimePanic("comparing un-comparable type") |
| 81 | return false // unreachable |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // interfaceTypeAssert is called when a type assert without comma-ok still |
| 86 | // returns false. |
no test coverage detected