Examples of UnionType


Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

        super.visit(that);
        List<ProducedType> types = new ArrayList<ProducedType>(2);
        types.add(unit.getType(unit.getNullDeclaration()));
        ProducedType dt = that.getDefiniteType().getTypeModel();
        if (dt!=null) types.add(dt);
        UnionType ut = new UnionType(unit);
        ut.setCaseTypes(types);
        that.setTypeModel(ut.getType());
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

        for (int i=last; i>=0; i--) {
            ProducedType elemType = elemTypes.get(i);
            List<ProducedType> pair = new ArrayList<ProducedType>();
            pair.add(elemType);
            pair.add(union);
            UnionType ut = new UnionType(unit);
            ut.setCaseTypes(pair);
            union = ut.getType();
            if (variadic && i==last) {
                result = atLeastOne ?
                        unit.getSequenceType(elemType) :
                        unit.getSequentialType(elemType);
            }
            else {
                result = producedType(unit.getTupleDeclaration(),
                        union, elemType, result);
                if (firstDefaulted>=0 && i>=firstDefaulted) {
                    pair = new ArrayList<ProducedType>();
                    pair.add(unit.getType(unit.getEmptyDeclaration()));
                    pair.add(result);
                    ut = new UnionType(unit);
                    ut.setCaseTypes(pair);
                    result = ut.getType();
                }
            }
        }
        return result;
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

            return false;
        TypeDeclaration declaration = type.getDeclaration();
        if(declaration == null)
            return false;
        if(declaration instanceof UnionType){
            UnionType ut = (UnionType) declaration;
            java.util.List<ProducedType> caseTypes = ut.getCaseTypes();
            for(ProducedType pt : caseTypes){
                if(hasTypeParameterWithConstraintsOutsideScopeResolved(pt, scope))
                    return true;
            }
            return false;
        }
        if(declaration instanceof IntersectionType){
            IntersectionType ut = (IntersectionType) declaration;
            java.util.List<ProducedType> satisfiedTypes = ut.getSatisfiedTypes();
            for(ProducedType pt : satisfiedTypes){
                if(hasTypeParameterWithConstraintsOutsideScopeResolved(pt, scope))
                    return true;
            }
            return false;
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

        // we do not use Unit.getOptionalType because it causes lots of lazy loading that ultimately triggers the typechecker's
        // infinite recursion loop
        List<ProducedType> list = new ArrayList<ProducedType>(2);
        list.add(typeFactory.getNullDeclaration().getType());
        list.add(type);
        UnionType ut = new UnionType(getUnitForModule(moduleScope));
        ut.setCaseTypes(list);
        return ut.getType();
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

            return false;
        TypeDeclaration declaration = type.getDeclaration();
        if(declaration == null)
            return false;
        if(declaration instanceof UnionType){
            UnionType ut = (UnionType) declaration;
            java.util.List<ProducedType> caseTypes = ut.getCaseTypes();
            // special case for optional types
            if(caseTypes.size() == 2){
                if(isOptional(caseTypes.get(0)))
                    return hasErasureResolved(caseTypes.get(1));
                if(isOptional(caseTypes.get(1)))
                    return hasErasureResolved(caseTypes.get(0));
            }
            // must be erased
            return true;
        }
        if(declaration instanceof IntersectionType){
            IntersectionType ut = (IntersectionType) declaration;
            java.util.List<ProducedType> satisfiedTypes = ut.getSatisfiedTypes();
            // special case for non-optional types
            if(satisfiedTypes.size() == 2){
                if(isObject(satisfiedTypes.get(0)))
                    return hasErasureResolved(satisfiedTypes.get(1));
                if(isObject(satisfiedTypes.get(1)))
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

    }

    private boolean isErasedUnionOrIntersection(ProducedType producedType) {
        TypeDeclaration typeDeclaration = producedType.getDeclaration();
        if(typeDeclaration instanceof UnionType){
            UnionType ut = (UnionType) typeDeclaration;
            java.util.List<ProducedType> caseTypes = ut.getCaseTypes();
            // special case for optional types
            if(caseTypes.size() == 2){
                if(isNull(caseTypes.get(0))){
                    return isErasedUnionOrIntersection(caseTypes.get(1));
                }else if(isNull(caseTypes.get(1))){
                    return isErasedUnionOrIntersection(caseTypes.get(0));
                }
            }
            // it is erased
            return true;
        }
        if(typeDeclaration instanceof IntersectionType){
            IntersectionType ut = (IntersectionType) typeDeclaration;
            java.util.List<ProducedType> satisfiedTypes = ut.getSatisfiedTypes();
            // special case for non-optional types
            if(satisfiedTypes.size() == 2){
                if(isObject(satisfiedTypes.get(0))){
                    return isErasedUnionOrIntersection(satisfiedTypes.get(1));
                }else if(isObject(satisfiedTypes.get(1))){
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

                        return typeTester.isReified(varExpr, testedType);
                    }
                }
            }
        } else if (typeFact().isUnion(testedType)) {
            UnionType union = (UnionType)declaration;
            for (ProducedType pt : union.getCaseTypes()) {
                R partExpr = makeTypeTest(typeTester, firstTimeExpr, varName, pt, expressionType);
                firstTimeExpr = null;
                if (result == null) {
                    result = partExpr;
                } else {
                    result = typeTester.andOr(result, partExpr, JCTree.OR);
                }
            }
            return result;
        } else if (typeFact().isIntersection(testedType)) {
            IntersectionType union = (IntersectionType)declaration;
            for (ProducedType pt : union.getSatisfiedTypes()) {
                R partExpr = makeTypeTest(typeTester, firstTimeExpr, varName, pt, expressionType);
                firstTimeExpr = null;
                if (result == null) {
                    result = partExpr;
                } else {
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

        ProducedType type = new TypeParser(MockLoader.instance).decodeType("a|b|c", null, mockModule, mockUnit);
        Assert.assertNotNull(type);
        TypeDeclaration declaration = type.getDeclaration();
        Assert.assertNotNull(declaration);
        Assert.assertTrue(declaration instanceof UnionType);
        UnionType union = (UnionType) declaration;
        List<ProducedType> types = union.getCaseTypes();
        Assert.assertEquals(3, types.size());
        Assert.assertEquals("a", types.get(0).getDeclaration().getName());
        Assert.assertTrue(types.get(0).getDeclaration() instanceof Class);
        Assert.assertEquals("b", types.get(1).getDeclaration().getName());
        Assert.assertTrue(types.get(1).getDeclaration() instanceof Class);
View Full Code Here

Examples of com.redhat.ceylon.compiler.typechecker.model.UnionType

        ProducedType type = new TypeParser(MockLoader.instance).decodeType("a&b|c", null, mockModule, mockUnit);
        Assert.assertNotNull(type);
        TypeDeclaration declaration = type.getDeclaration();
        Assert.assertNotNull(declaration);
        Assert.assertTrue(declaration instanceof UnionType);
        UnionType union = (UnionType) declaration;
        List<ProducedType> unionTypes = union.getCaseTypes();
        Assert.assertEquals(2, unionTypes.size());
       
        Assert.assertTrue(unionTypes.get(0).getDeclaration() instanceof IntersectionType);
        IntersectionType intersection = (IntersectionType) unionTypes.get(0).getDeclaration();
View Full Code Here

Examples of org.apache.axis2.corba.idl.types.UnionType

            } else if (dataType instanceof UnionType) {
                XmlSchemaComplexType complexType = new XmlSchemaComplexType(xmlSchema);
                XmlSchemaChoice choice = new XmlSchemaChoice();
                XmlSchemaObjectCollection items = choice.getItems();

                UnionType unionType = (UnionType) dataType;
                Member[] members = unionType.getMembers();
                for (int i = 0; i < members.length; i++) {
                    items.add(generateSchemaforFieldsandProperties(xmlSchema, members[i].getDataType(),
                            members[i].getName(), true));
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.