Revert "account/abi: convert if-else-if chain to tagged switch (#27869)"

This reverts commit c8563890cb.
This commit is contained in:
devopsbo3 2023-11-10 12:27:53 -06:00 committed by GitHub
parent 14db2e93b8
commit 44acf23df9
3 changed files with 9 additions and 12 deletions

View file

@ -127,12 +127,11 @@ func NewMethod(name string, rawName string, funType FunctionType, mutability str
state = state + " "
}
identity := fmt.Sprintf("function %v", rawName)
switch funType {
case Fallback:
if funType == Fallback {
identity = "fallback"
case Receive:
} else if funType == Receive {
identity = "receive"
case Constructor:
} else if funType == Constructor {
identity = "constructor"
}
str := fmt.Sprintf("%v(%v) %sreturns(%v)", identity, strings.Join(inputNames, ", "), state, strings.Join(outputNames, ", "))

View file

@ -84,12 +84,11 @@ func TestMethodString(t *testing.T) {
for _, test := range table {
var got string
switch test.method {
case "fallback":
if test.method == "fallback" {
got = abi.Fallback.String()
case "receive":
} else if test.method == "receive" {
got = abi.Receive.String()
default:
} else {
got = abi.Methods[test.method].String()
}
if got != test.expectation {

View file

@ -160,14 +160,13 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
// this value will become our slice or our array, depending on the type
var refSlice reflect.Value
switch t.T {
case SliceTy:
if t.T == SliceTy {
// declare our slice
refSlice = reflect.MakeSlice(t.GetType(), size, size)
case ArrayTy:
} else if t.T == ArrayTy {
// declare our array
refSlice = reflect.New(t.GetType()).Elem()
default:
} else {
return nil, errors.New("abi: invalid type in array/slice unpacking stage")
}