@Test public void testCanBeAssignedTo() { assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(object)); assertEquals(false, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(string)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UBYTE)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.USHORT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UINT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.ULONG)); assertEquals(false, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UFLOAT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UDOUBLE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(PrimitiveTypeUsage.CHAR)); assertEquals(false, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(PrimitiveTypeUsage.BOOLEAN)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(PrimitiveTypeUsage.BYTE)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(PrimitiveTypeUsage.SHORT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(PrimitiveTypeUsage.INT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(PrimitiveTypeUsage.LONG)); assertEquals(false, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(PrimitiveTypeUsage.FLOAT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(PrimitiveTypeUsage.DOUBLE)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(byteBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(shortBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(integerBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.UBYTE.canBeAssignedTo(longBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(object)); assertEquals(false, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(string)); assertEquals(false, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UBYTE)); assertEquals(true, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.USHORT)); assertEquals(true, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UINT)); assertEquals(true, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.ULONG)); assertEquals(false, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UFLOAT)); assertEquals(false, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UDOUBLE)); assertEquals(false, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(PrimitiveTypeUsage.CHAR)); assertEquals(false, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(PrimitiveTypeUsage.BOOLEAN)); assertEquals(false, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(PrimitiveTypeUsage.BYTE)); assertEquals(true, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(PrimitiveTypeUsage.SHORT)); assertEquals(true, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(PrimitiveTypeUsage.INT)); assertEquals(true, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(PrimitiveTypeUsage.LONG)); assertEquals(false, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(PrimitiveTypeUsage.FLOAT)); assertEquals(false, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(PrimitiveTypeUsage.DOUBLE)); assertEquals(false, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(byteBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(shortBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(integerBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.USHORT.canBeAssignedTo(longBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(object)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(string)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UBYTE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.USHORT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UINT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.ULONG)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UFLOAT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UDOUBLE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(PrimitiveTypeUsage.CHAR)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(PrimitiveTypeUsage.BOOLEAN)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(PrimitiveTypeUsage.BYTE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(PrimitiveTypeUsage.SHORT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(PrimitiveTypeUsage.INT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(PrimitiveTypeUsage.LONG)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(PrimitiveTypeUsage.FLOAT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(PrimitiveTypeUsage.DOUBLE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(byteBoxType)); assertEquals(false, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(shortBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(integerBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.UINT.canBeAssignedTo(longBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(object)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(string)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UBYTE)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(UnsignedPrimitiveTypeUsage.USHORT)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UINT)); assertEquals(true, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(UnsignedPrimitiveTypeUsage.ULONG)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UFLOAT)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UDOUBLE)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(PrimitiveTypeUsage.CHAR)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(PrimitiveTypeUsage.BOOLEAN)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(PrimitiveTypeUsage.BYTE)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(PrimitiveTypeUsage.SHORT)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(PrimitiveTypeUsage.INT)); assertEquals(true, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(PrimitiveTypeUsage.LONG)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(PrimitiveTypeUsage.FLOAT)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(PrimitiveTypeUsage.DOUBLE)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(byteBoxType)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(shortBoxType)); assertEquals(false, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(integerBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.ULONG.canBeAssignedTo(longBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(object)); assertEquals(false, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(string)); assertEquals(false, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UBYTE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.USHORT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UINT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.ULONG)); assertEquals(true, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UFLOAT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UDOUBLE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(PrimitiveTypeUsage.CHAR)); assertEquals(false, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(PrimitiveTypeUsage.BOOLEAN)); assertEquals(false, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(PrimitiveTypeUsage.BYTE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(PrimitiveTypeUsage.SHORT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(PrimitiveTypeUsage.INT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(PrimitiveTypeUsage.LONG)); assertEquals(true, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(PrimitiveTypeUsage.FLOAT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(PrimitiveTypeUsage.DOUBLE)); assertEquals(true, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(floatBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.UFLOAT.canBeAssignedTo(doubleBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(object)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(string)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UBYTE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.USHORT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UINT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.ULONG)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UFLOAT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(UnsignedPrimitiveTypeUsage.UDOUBLE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(PrimitiveTypeUsage.CHAR)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(PrimitiveTypeUsage.BOOLEAN)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(PrimitiveTypeUsage.BYTE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(PrimitiveTypeUsage.SHORT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(PrimitiveTypeUsage.INT)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(PrimitiveTypeUsage.LONG)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(PrimitiveTypeUsage.FLOAT)); assertEquals(true, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(PrimitiveTypeUsage.DOUBLE)); assertEquals(false, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(floatBoxType)); assertEquals(true, UnsignedPrimitiveTypeUsage.UDOUBLE.canBeAssignedTo(doubleBoxType)); }
@Override public boolean canBeAssignedTo(TypeUsage type) { return asPrimitiveTypeUsage().canBeAssignedTo(type) || this == type || promotionTypes.contains(type); }
UnsignedPrimitiveTypeUsage implements TypeUsage { @Override public boolean canBeAssignedTo(TypeUsage type) { return asPrimitiveTypeUsage().canBeAssignedTo(type) || this == type || promotionTypes.contains(type); } }
UnsignedPrimitiveTypeUsage implements TypeUsage { @Override public boolean canBeAssignedTo(TypeUsage type) { return asPrimitiveTypeUsage().canBeAssignedTo(type) || this == type || promotionTypes.contains(type); } private  UnsignedPrimitiveTypeUsage(String name, PrimitiveTypeUsage correspondingPrimitiveTypeUsage); private  UnsignedPrimitiveTypeUsage(String name, PrimitiveTypeUsage correspondingPrimitiveTypeUsage,
                                       List<UnsignedPrimitiveTypeUsage> promotionTypes); }
UnsignedPrimitiveTypeUsage implements TypeUsage { @Override public boolean canBeAssignedTo(TypeUsage type) { return asPrimitiveTypeUsage().canBeAssignedTo(type) || this == type || promotionTypes.contains(type); } private  UnsignedPrimitiveTypeUsage(String name, PrimitiveTypeUsage correspondingPrimitiveTypeUsage); private  UnsignedPrimitiveTypeUsage(String name, PrimitiveTypeUsage correspondingPrimitiveTypeUsage,
                                       List<UnsignedPrimitiveTypeUsage> promotionTypes); @Override boolean isPrimitive(); @Override PrimitiveTypeUsage asPrimitiveTypeUsage(); @Override TypeUsage replaceTypeVariables(Map<String, T> typeParams); @Override boolean sameType(TypeUsage other); @Override JvmType jvmType(); @Override boolean canBeAssignedTo(TypeUsage type); @Override String toString(); static Optional<UnsignedPrimitiveTypeUsage> findByName(String typeName); static UnsignedPrimitiveTypeUsage getByName(String typeName); @Override boolean hasInstanceField(String fieldName, Symbol instance); @Override Symbol getInstanceField(String fieldName, Symbol instance); @Override String describe(); @Override Optional<Invokable> getMethod(String method, boolean staticContext); }
UnsignedPrimitiveTypeUsage implements TypeUsage { @Override public boolean canBeAssignedTo(TypeUsage type) { return asPrimitiveTypeUsage().canBeAssignedTo(type) || this == type || promotionTypes.contains(type); } private  UnsignedPrimitiveTypeUsage(String name, PrimitiveTypeUsage correspondingPrimitiveTypeUsage); private  UnsignedPrimitiveTypeUsage(String name, PrimitiveTypeUsage correspondingPrimitiveTypeUsage,
                                       List<UnsignedPrimitiveTypeUsage> promotionTypes); @Override boolean isPrimitive(); @Override PrimitiveTypeUsage asPrimitiveTypeUsage(); @Override TypeUsage replaceTypeVariables(Map<String, T> typeParams); @Override boolean sameType(TypeUsage other); @Override JvmType jvmType(); @Override boolean canBeAssignedTo(TypeUsage type); @Override String toString(); static Optional<UnsignedPrimitiveTypeUsage> findByName(String typeName); static UnsignedPrimitiveTypeUsage getByName(String typeName); @Override boolean hasInstanceField(String fieldName, Symbol instance); @Override Symbol getInstanceField(String fieldName, Symbol instance); @Override String describe(); @Override Optional<Invokable> getMethod(String method, boolean staticContext); static UnsignedPrimitiveTypeUsage ULONG; static UnsignedPrimitiveTypeUsage UINT; static UnsignedPrimitiveTypeUsage USHORT; static UnsignedPrimitiveTypeUsage UBYTE; static UnsignedPrimitiveTypeUsage UDOUBLE; static UnsignedPrimitiveTypeUsage UFLOAT; static ImmutableList<UnsignedPrimitiveTypeUsage> ALL; }