Search in sources :

Example 1 with CompoundTypeReference

use of org.eclipse.xtext.xbase.typesystem.references.CompoundTypeReference in project xtext-xtend by eclipse.

the class AbstractAssignabilityTest method testIsAssignable.

public boolean testIsAssignable(final LightweightTypeReference lhs, final LightweightTypeReference rhs) {
    Assert.assertTrue(this.doIsAssignable(lhs, lhs));
    Assert.assertTrue(this.doIsAssignable(lhs, this.toLightweightTypeReference(lhs.toTypeReference())));
    Assert.assertTrue(this.doIsAssignable(rhs, this.toLightweightTypeReference(rhs.toTypeReference())));
    final boolean result = this.doIsAssignable(lhs, rhs);
    boolean _isPrimitiveVoid = rhs.isPrimitiveVoid();
    boolean _not = (!_isPrimitiveVoid);
    if (_not) {
        final WildcardTypeReference wcRhs = this.getOwner().newWildcardTypeReference();
        wcRhs.addUpperBound(rhs.getWrapperTypeIfPrimitive());
        Assert.assertEquals(Boolean.valueOf(result), Boolean.valueOf(this.doIsAssignable(lhs, wcRhs)));
        final CompoundTypeReference compoundRhs = this.getOwner().newCompoundTypeReference(true);
        compoundRhs.addComponent(rhs);
        final JvmType object = rhs.getOwner().getServices().getTypeReferences().findDeclaredType(Object.class, rhs.getOwner().getContextResourceSet());
        compoundRhs.addComponent(rhs.getOwner().newParameterizedTypeReference(object));
        String _plus = (lhs + " := ");
        String _string = compoundRhs.toString();
        String _plus_1 = (_plus + _string);
        Assert.assertEquals(_plus_1, Boolean.valueOf(result), Boolean.valueOf(this.doIsAssignable(lhs, compoundRhs)));
    }
    return result;
}
Also used : WildcardTypeReference(org.eclipse.xtext.xbase.typesystem.references.WildcardTypeReference) JvmType(org.eclipse.xtext.common.types.JvmType) CompoundTypeReference(org.eclipse.xtext.xbase.typesystem.references.CompoundTypeReference)

Example 2 with CompoundTypeReference

use of org.eclipse.xtext.xbase.typesystem.references.CompoundTypeReference in project xtext-xtend by eclipse.

the class AbstractAssignabilityTest method testIsAssignable.

public boolean testIsAssignable(final LightweightTypeReference lhs, final LightweightTypeReference rhs) {
    Assert.assertTrue(this.doIsAssignable(lhs, lhs));
    Assert.assertTrue(this.doIsAssignable(lhs, this.toLightweightTypeReference(lhs.toTypeReference())));
    Assert.assertTrue(this.doIsAssignable(rhs, this.toLightweightTypeReference(rhs.toTypeReference())));
    final boolean result = this.doIsAssignable(lhs, rhs);
    boolean _isPrimitiveVoid = rhs.isPrimitiveVoid();
    boolean _not = (!_isPrimitiveVoid);
    if (_not) {
        final WildcardTypeReference wcRhs = this.getOwner().newWildcardTypeReference();
        wcRhs.addUpperBound(rhs.getWrapperTypeIfPrimitive());
        Assert.assertEquals(Boolean.valueOf(result), Boolean.valueOf(this.doIsAssignable(lhs, wcRhs)));
        final CompoundTypeReference compoundRhs = this.getOwner().newCompoundTypeReference(true);
        compoundRhs.addComponent(rhs);
        final JvmType object = rhs.getOwner().getServices().getTypeReferences().findDeclaredType(Object.class, rhs.getOwner().getContextResourceSet());
        compoundRhs.addComponent(rhs.getOwner().newParameterizedTypeReference(object));
        String _plus = (lhs + " := ");
        String _string = compoundRhs.toString();
        String _plus_1 = (_plus + _string);
        Assert.assertEquals(_plus_1, Boolean.valueOf(result), Boolean.valueOf(this.doIsAssignable(lhs, compoundRhs)));
    }
    return result;
}
Also used : WildcardTypeReference(org.eclipse.xtext.xbase.typesystem.references.WildcardTypeReference) JvmType(org.eclipse.xtext.common.types.JvmType) CompoundTypeReference(org.eclipse.xtext.xbase.typesystem.references.CompoundTypeReference)

Aggregations

JvmType (org.eclipse.xtext.common.types.JvmType)2 CompoundTypeReference (org.eclipse.xtext.xbase.typesystem.references.CompoundTypeReference)2 WildcardTypeReference (org.eclipse.xtext.xbase.typesystem.references.WildcardTypeReference)2