PrimitiveTypeUsage implements TypeUsage { @Override public boolean sameType(TypeUsage other) { if (!other.isPrimitive()) { return false; } if (other instanceof UnsignedPrimitiveTypeUsage) { return false; } return getName().equals(other.asPrimitiveTypeUsage().getName()); } private  PrimitiveTypeUsage(String name, JvmType jvmType, Class<?> boxTypeClazz, List<PrimitiveTypeUsage> promotionsTypes); private  PrimitiveTypeUsage(String name, JvmType jvmType, Class<?> boxTypeClazz); @Override boolean isPrimitive(); @Override TypeUsage replaceTypeVariables(Map<String, T> typeParams); @Override boolean canBeAssignedTo(TypeUsage other); static Optional<PrimitiveTypeUsage> findByJvmType(JvmType jvmType); TypeUsage getBoxType(SymbolResolver resolver); @Override JvmType jvmType(); String turinName(); static PrimitiveTypeUsage getByName(String name); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static boolean isPrimitiveTypeName(String typeName); @Override PrimitiveTypeUsage asPrimitiveTypeUsage(); boolean isLong(); boolean isFloat(); boolean isDouble(); boolean isStoredInInt(); boolean isInt(); boolean isShort(); boolean isChar(); boolean isByte(); boolean isBoolean(); String getName(); @Override String describe(); @Override boolean sameType(TypeUsage other); @Override boolean hasInstanceField(String fieldName, Symbol instance); @Override Symbol getInstanceField(String fieldName, Symbol instance); @Override Optional<Invokable> getMethod(String method, boolean staticContext); static PrimitiveTypeUsage BOOLEAN; static PrimitiveTypeUsage CHAR; static PrimitiveTypeUsage LONG; static PrimitiveTypeUsage INT; static PrimitiveTypeUsage SHORT; static PrimitiveTypeUsage BYTE; static PrimitiveTypeUsage DOUBLE; static PrimitiveTypeUsage FLOAT; static List<PrimitiveTypeUsage> ALL; }
@Test public void testSameType() { for (int i=0; i<PrimitiveTypeUsage.ALL.size(); i++) { for (int j=0; j<PrimitiveTypeUsage.ALL.size(); j++) { assertEquals(i == j, PrimitiveTypeUsage.ALL.get(i).sameType(PrimitiveTypeUsage.ALL.get(j))); } for (UnsignedPrimitiveTypeUsage btu : UnsignedPrimitiveTypeUsage.ALL) { assertFalse(PrimitiveTypeUsage.ALL.get(i).describe() + " sameType as " + btu.describe(), PrimitiveTypeUsage.ALL.get(i).sameType(btu)); } assertFalse(PrimitiveTypeUsage.ALL.get(i).sameType(string)); assertFalse(PrimitiveTypeUsage.ALL.get(i).sameType(object)); } }