ArrayType extends UnqualifiedType { @Override public boolean equals(Object that) { if (this == that) { return true; } if (!(that instanceof ArrayType)) { return false; } final ArrayType thatArrayType = (ArrayType) that; if (!this.baseType.equals(thatArrayType.baseType)) { return false; } if (this.arrayInfo.hasConstantSize()) { return thatArrayType.arrayInfo.hasConstantSize() && this.arrayInfo.getConstantSize().equals(thatArrayType.arrayInfo.getConstantSize()); } else { return !thatArrayType.arrayInfo.hasConstantSize(); } } ArrayType(Type baseType, ArrayInfo arrayInfo); Type getBaseType(); ArrayInfo getArrayInfo(); @Override void accept(IAstVisitor visitor); @Override boolean equals(Object that); @Override int hashCode(); @Override ArrayType clone(); @Override boolean hasCanonicalConstant(Scope scope); @Override Expr getCanonicalConstant(Scope scope);  }
@Test public void testEquals() { final ArrayType intArrayNoSize = new ArrayType(BasicType.INT, new ArrayInfo()); final ArrayType anotherIntArrayNoSize = new ArrayType(BasicType.INT, new ArrayInfo()); final ArrayType floatArrayNoSize = new ArrayType(BasicType.FLOAT, new ArrayInfo()); final ArrayType anotherFloatArrayNoSize = new ArrayType(BasicType.FLOAT, new ArrayInfo()); final ArrayType intArraySize2 = new ArrayType(BasicType.INT, new ArrayInfo(new BinaryExpr(new IntConstantExpr("1"), new IntConstantExpr("1"), BinOp.ADD))); intArraySize2.getArrayInfo().setConstantSizeExpr(2); final ArrayType intArraySize3 = new ArrayType(BasicType.INT, new ArrayInfo(new BinaryExpr(new IntConstantExpr("2"), new IntConstantExpr("1"), BinOp.ADD))); intArraySize3.getArrayInfo().setConstantSizeExpr(3); final ArrayType anotherIntArraySize2 = new ArrayType(BasicType.INT, new ArrayInfo(new IntConstantExpr("2"))); anotherIntArraySize2.getArrayInfo().setConstantSizeExpr(2); assertEquals(intArrayNoSize, anotherIntArrayNoSize); assertEquals(intArrayNoSize.hashCode(), anotherIntArrayNoSize.hashCode()); assertNotEquals(intArrayNoSize, intArraySize2); assertEquals(floatArrayNoSize, anotherFloatArrayNoSize); assertEquals(floatArrayNoSize.hashCode(), anotherFloatArrayNoSize.hashCode()); assertNotEquals(intArrayNoSize, floatArrayNoSize); assertEquals(intArraySize2, anotherIntArraySize2); assertEquals(intArraySize2.hashCode(), anotherIntArraySize2.hashCode()); assertNotEquals(intArraySize2, intArraySize3); }