mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-03 03:31:14 +00:00
## Why this should be merged To be able to generate RLP code using type aliases (defined e.g. in `coreth`). This can and should be PR-ed upstream as well I think. ## How this works Call `types.Unalias()` at the start of `buildContext.makeOp()`. The alternative of adding a `case` to the switch statement adds unnecessary recursive calls while `types.Unalias()` is a no-op if not an alias. ## How this was tested New `rlpgen` unit test with aliases of well-known types that have special handling—these make their proper handling easy to spot when inspecting generated code. A recursive alias in the same test also demonstrates full alias resolution. --------- Co-authored-by: Arran Schlosberg <me@arranschlosberg.com>
22 lines
419 B
Go
22 lines
419 B
Go
// -*- mode: go -*-
|
|
|
|
package test
|
|
|
|
import (
|
|
"math/big"
|
|
"github.com/holiman/uint256"
|
|
)
|
|
|
|
// Alias types chosen because their originals have special handling that is easy
|
|
// to spot when inspecting generated output.
|
|
type (
|
|
Big = big.Int
|
|
// Demonstrate recursive unaliasing
|
|
intermediate = uint256.Int
|
|
Uint256 = intermediate
|
|
)
|
|
|
|
type Test struct {
|
|
BigAlias Big
|
|
Uint256Alias Uint256
|
|
}
|