Package com.redhat.ceylon.compiler.typechecker.model

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


            }
            // 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


                    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

        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 IntersectionType);
        IntersectionType intersection = (IntersectionType) declaration;
        List<ProducedType> types = intersection.getSatisfiedTypes();
        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

        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();

        List<ProducedType> intersectionTypes = intersection.getSatisfiedTypes();
        Assert.assertEquals(2, intersectionTypes.size());
        Assert.assertEquals("a", intersectionTypes.get(0).getDeclaration().getName());
        Assert.assertTrue(intersectionTypes.get(0).getDeclaration() instanceof Class);
        Assert.assertEquals("b", intersectionTypes.get(1).getDeclaration().getName());
        Assert.assertTrue(intersectionTypes.get(1).getDeclaration() instanceof Class);
View Full Code Here

     * intersectionType: qualifiedType (& qualifiedType)*
     */
    private ProducedType parseIntersectionType() {
        ProducedType firstType = parseQualifiedType();
        if(lexer.lookingAt(TypeLexer.AND)){
            IntersectionType type = new IntersectionType(unit);
            List<ProducedType> satisfiedTypes = new LinkedList<ProducedType>();
            type.setSatisfiedTypes(satisfiedTypes);
            satisfiedTypes.add(firstType);
            while(lexer.lookingAt(TypeLexer.AND)){
                lexer.eat();
                satisfiedTypes.add(parseQualifiedType());
            }
            return type.getType();
        }else{
            return firstType;
        }
    }
View Full Code Here

        }

        @Override
        public ProducedType toProducedType(RuntimeModuleManager moduleManager) {
            Unit unit = moduleManager.getModelLoader().getUnit();
      IntersectionType ret = new IntersectionType(unit);
            ArrayList<ProducedType> satisfiedTypes = new ArrayList<ProducedType>(members.length);
            for(TypeDescriptor member : members)
              Util.addToIntersection(satisfiedTypes, Metamodel.getProducedType(member), unit);
            ret.setSatisfiedTypes(satisfiedTypes);
            return ret.canonicalize().getType();
        }
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.IntersectionType

Copyright © 2018 www.massapicom. 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.