Skip to content

Commit

Permalink
improve asArrayType
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Sep 9, 2024
1 parent 9dd6f67 commit f399509
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/esaulpaugh/headlong/abi/ABIType.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public int getFlags() {
return FLAGS_UNSET;
}

public final ArrayType<?, ?, J> asArrayType() {
return (ArrayType<?, ?, J>) this;
public final <E, ET extends ABIType<E>> ArrayType<ET, E, J> asArrayType() {
return (ArrayType<ET, E, J>) this;
}

public final TupleType<? extends Tuple> asTupleType() {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/esaulpaugh/headlong/abi/PackedDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static Tuple decodeTuple(TupleType<?> tupleType, ByteBuffer bb, int end)
break;
}
if (type instanceof ArrayType) {
final ArrayType<?, ?, ?> arrayType = type.asArrayType();
final ArrayType<ABIType<Object>, ?, ?> arrayType = type.asArrayType();
final int elementByteLength = arrayType.getElementType() instanceof UnitType
? UNIT_LENGTH_BYTES
: arrayType.getElementType().byteLengthPacked(null);
Expand Down Expand Up @@ -159,9 +159,8 @@ private static BigInteger getSignedBigInt(ByteBuffer bb, int elementLen) {
return new BigInteger(temp);
}

@SuppressWarnings("unchecked")
private static Object decodeArray(ArrayType<?, ?, ?> arrayType, ByteBuffer bb, int end) {
final ABIType<Object> elementType = (ABIType<Object>) arrayType.getElementType();
private static Object decodeArray(ArrayType<ABIType<Object>, ?, ?> arrayType, ByteBuffer bb, int end) {
final ABIType<Object> elementType = arrayType.getElementType();
final int elementByteLen = elementType instanceof UnitType ? UNIT_LENGTH_BYTES : elementType.byteLengthPacked(null);
final int typeLen = arrayType.getLength();
final int arrayLen;
Expand Down

0 comments on commit f399509

Please sign in to comment.