@Test public void testCanBeAssignedTo() { assertEquals(true, arrayOfBoolean.canBeAssignedTo(arrayOfBoolean)); assertEquals(false, arrayOfBoolean.canBeAssignedTo(arrayOfString)); assertEquals(false, arrayOfBoolean.canBeAssignedTo(arrayOfArrayOfString)); assertEquals(false, arrayOfBoolean.canBeAssignedTo(PrimitiveTypeUsage.BOOLEAN)); assertEquals(false, arrayOfBoolean.canBeAssignedTo(string)); assertEquals(true, arrayOfBoolean.canBeAssignedTo(object)); assertEquals(false, arrayOfString.canBeAssignedTo(arrayOfBoolean)); assertEquals(true, arrayOfString.canBeAssignedTo(arrayOfString)); assertEquals(false, arrayOfString.canBeAssignedTo(arrayOfArrayOfString)); assertEquals(false, arrayOfString.canBeAssignedTo(PrimitiveTypeUsage.BOOLEAN)); assertEquals(false, arrayOfString.canBeAssignedTo(string)); assertEquals(true, arrayOfString.canBeAssignedTo(object)); assertEquals(false, arrayOfArrayOfString.canBeAssignedTo(arrayOfBoolean)); assertEquals(false, arrayOfArrayOfString.canBeAssignedTo(arrayOfString)); assertEquals(true, arrayOfArrayOfString.canBeAssignedTo(arrayOfArrayOfString)); assertEquals(false, arrayOfArrayOfString.canBeAssignedTo(PrimitiveTypeUsage.BOOLEAN)); assertEquals(false, arrayOfArrayOfString.canBeAssignedTo(string)); assertEquals(true, arrayOfArrayOfString.canBeAssignedTo(object)); }
@Override public boolean canBeAssignedTo(TypeUsage type) { if (type.isArray()) { return componentType.equals(type.asArrayTypeUsage().getComponentType()); } else { return type.isReferenceTypeUsage() && type.asReferenceTypeUsage().getQualifiedName().equals(Object.class.getCanonicalName()); } }
ArrayTypeUsage implements TypeUsage { @Override public boolean canBeAssignedTo(TypeUsage type) { if (type.isArray()) { return componentType.equals(type.asArrayTypeUsage().getComponentType()); } else { return type.isReferenceTypeUsage() && type.asReferenceTypeUsage().getQualifiedName().equals(Object.class.getCanonicalName()); } } }
ArrayTypeUsage implements TypeUsage { @Override public boolean canBeAssignedTo(TypeUsage type) { if (type.isArray()) { return componentType.equals(type.asArrayTypeUsage().getComponentType()); } else { return type.isReferenceTypeUsage() && type.asReferenceTypeUsage().getQualifiedName().equals(Object.class.getCanonicalName()); } } ArrayTypeUsage(TypeUsage componentType); }
ArrayTypeUsage implements TypeUsage { @Override public boolean canBeAssignedTo(TypeUsage type) { if (type.isArray()) { return componentType.equals(type.asArrayTypeUsage().getComponentType()); } else { return type.isReferenceTypeUsage() && type.asReferenceTypeUsage().getQualifiedName().equals(Object.class.getCanonicalName()); } } ArrayTypeUsage(TypeUsage componentType); TypeUsage getComponentType(); @Override boolean equals(Object o); @Override int hashCode(); @Override boolean isArray(); @Override boolean isReference(); @Override ArrayTypeUsage asArrayTypeUsage(); @Override JvmType jvmType(); @Override boolean hasInstanceField(String fieldName, Symbol instance); @Override Symbol getInstanceField(String fieldName, Symbol instance); @Override Optional<Invokable> getMethod(String method, boolean staticContext); @Override boolean canBeAssignedTo(TypeUsage type); @Override String toString(); @Override TypeUsage replaceTypeVariables(Map<String, T> typeParams); @Override boolean sameType(TypeUsage other); @Override String describe(); }
ArrayTypeUsage implements TypeUsage { @Override public boolean canBeAssignedTo(TypeUsage type) { if (type.isArray()) { return componentType.equals(type.asArrayTypeUsage().getComponentType()); } else { return type.isReferenceTypeUsage() && type.asReferenceTypeUsage().getQualifiedName().equals(Object.class.getCanonicalName()); } } ArrayTypeUsage(TypeUsage componentType); TypeUsage getComponentType(); @Override boolean equals(Object o); @Override int hashCode(); @Override boolean isArray(); @Override boolean isReference(); @Override ArrayTypeUsage asArrayTypeUsage(); @Override JvmType jvmType(); @Override boolean hasInstanceField(String fieldName, Symbol instance); @Override Symbol getInstanceField(String fieldName, Symbol instance); @Override Optional<Invokable> getMethod(String method, boolean staticContext); @Override boolean canBeAssignedTo(TypeUsage type); @Override String toString(); @Override TypeUsage replaceTypeVariables(Map<String, T> typeParams); @Override boolean sameType(TypeUsage other); @Override String describe();  }